forked from UtrechtUniversity/davrods
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmod_davrods.c
103 lines (76 loc) · 2.7 KB
/
mod_davrods.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/**
* \file
* \brief Davrods main module file.
* \author Chris Smeele
* \copyright Copyright (c) 2016, Utrecht University
*
* This file is part of Davrods.
*
* Davrods is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option)
* any later version.
*
* Davrods is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Davrods. If not, see <http://www.gnu.org/licenses/>.
*/
#define ALLOCATE_MODULE
#include "mod_davrods.h"
#include "config.h"
#include "auth.h"
#include "common.h"
#include "rest.h"
#include "http_request.h"
#include <curl/curl.h>
#ifdef API_NUMBER_H__
#undef API_NUMBER_H__
#include "irods/apiNumber.h"
#define API_NUMBER_H__
#endif
APLOG_USE_MODULE(davrods);
static void EIRodsDavChildInit (apr_pool_t *pool_p, server_rec *server_p);
static apr_status_t EIRodsDavChildFinalize (void *data_p);
static void register_davrods_hooks(apr_pool_t *p) {
davrods_auth_register(p);
davrods_dav_register(p);
ap_hook_child_init (EIRodsDavChildInit, NULL, NULL, APR_HOOK_FIRST);
ap_hook_fixups (EIRodsDavFixUps, NULL, NULL, APR_HOOK_FIRST);
ap_hook_handler (EIRodsDavAPIHandler, NULL, NULL, APR_HOOK_LAST);
// static const char * const aszPre[]={ "mod_authz_owner.c", NULL };
// ap_hook_auth_checker(check_user_access, aszPre,
// NULL, APR_HOOK_MIDDLE);
#ifdef IRODS_4_3
load_client_api_plugins ();
#endif
}
module AP_MODULE_DECLARE_DATA davrods_module = {
STANDARD20_MODULE_STUFF,
davrods_create_dir_config, // Directory config setup.
davrods_merge_dir_config, // .. .. merge function.
NULL, // Server config setup.
NULL, // .. .. merge function.
davrods_directives, // Command table.
register_davrods_hooks, // Hook setup.
};
static void EIRodsDavChildInit (apr_pool_t *pool_p, server_rec *server_p)
{
CURLcode res = curl_global_init (CURL_GLOBAL_DEFAULT);
if (res == CURLE_OK)
{
apr_pool_cleanup_register (pool_p, NULL, EIRodsDavChildFinalize, apr_pool_cleanup_null);
}
else
{
ap_log_perror (__FILE__, __LINE__, APLOG_MODULE_INDEX, APLOG_ERR, APR_EGENERAL, pool_p, "Failed to initialise CURL library");
}
}
static apr_status_t EIRodsDavChildFinalize (void *data_p)
{
curl_global_cleanup ();
return APR_SUCCESS;
}