Newer
Older
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
/* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "cs_config.h"
/*--------------------------------------------------------------------------*/
/* */
/* These routines are strictly internal to this module, and support its */
/* operation. They are not referenced by any external portion of the */
/* server. */
/* */
/*--------------------------------------------------------------------------*/
/*
* Locate our directory configuration record for the current request.
*/
cs_cfg *our_dconfig(const request_rec *cpt_R)
{
return (cs_cfg *) ap_get_module_config(cpt_R->per_dir_config, &g_ContextsplitModule);
}
/*
* Locate our server configuration record for the specified server.
*/
cs_cfg *our_sconfig(const server_rec *cpt_S)
{
return (cs_cfg *) ap_get_module_config(cpt_S->module_config, &g_ContextsplitModule);
}
/*
* Likewise for our configuration record for the specified request.
*/
cs_cfg *our_rconfig(const request_rec *cpt_R)
{
return (cs_cfg *) ap_get_module_config(cpt_R->request_config, &g_ContextsplitModule);
}
/*
* Likewise for our configuration record for a connection.
*/
cs_cfg *our_cconfig(const conn_rec *cpt_C)
{
return (cs_cfg *) ap_get_module_config(cpt_C->conn_config, &g_ContextsplitModule);
}
/*
* This function gets called to create a per-directory configuration
* record. This will be called for the "default" server environment, and for
* each directory for which the parser finds any of our directives applicable.
* If a directory doesn't have any of our directives involved (i.e., they
* aren't in the .htaccess file, or a <Location>, <Directory>, or related
* block), this routine will *not* be called - the configuration for the
* closest ancestor is used.
*
* The return value is a pointer to the created module-specific
* structure.
*/
void * cs_create_dir_config(apr_pool_t *p, char *dirspec)
{
cs_cfg *pt_Cfg;
char *ps_Dname = dirspec;
char *ps_Note;
/*
* Allocate the space for our record from the pool supplied.
*/
pt_Cfg = (cs_cfg *) apr_pcalloc(p, sizeof(cs_cfg));
#if 0
/*
* Now fill in the defaults. If there are any `parent' configuration
* records, they'll get merged as part of a separate callback.
*/
cfg->local = 0;
cfg->congenital = 0;
cfg->cmode = CONFIG_MODE_DIRECTORY;
#endif
/*
* Finally, add our trace to the callback list.
*/
ps_Dname = (ps_Dname != NULL) ? ps_Dname : "";
/*cfg->loc = apr_pstrcat(p, "DIR(", dname, ")", NULL);*/
ps_Note = apr_psprintf(p, "x_create_dir_config(p == %pp, dirspec == %s)",
(void*) p, ps_Dname);
/*trace_startup(p, NULL, cfg, note);*/
return (void *) pt_Cfg;
}
/*
* This function gets called to merge two per-directory configuration
* records. This is typically done to cope with things like .htaccess files
* or <Location> directives for directories that are beneath one for which a
* configuration record was already created. The routine has the
* responsibility of creating a new record and merging the contents of the
* other two into it appropriately. If the module doesn't declare a merge
* routine, the record for the closest ancestor location (that has one) is
* used exclusively.
*
* The routine MUST NOT modify any of its arguments!
*
* The return value is a pointer to the created module-specific structure
* containing the merged values.
*/
void *cs_merge_dir_config(apr_pool_t *p, void *pv_ParentConf,
void *pv_NewlocConf)
{
cs_cfg *pt_MergedConfig = (cs_cfg *) apr_pcalloc(p, sizeof(cs_cfg));
const cs_cfg *pt_Pconf = (cs_cfg *) pv_ParentConf;
const cs_cfg *pt_Nconf = (cs_cfg *) pv_NewlocConf;
char *ps_Note;
/*
* Now just record our being called in the trace list. Include the
* locations we were asked to merge.
*/
ps_Note = apr_psprintf(p, "x_merge_dir_config(p == %pp, parent_conf == "
"%pp, newloc_conf == %pp)", (void*) p,
(void*) pv_ParentConf, (void*) pv_NewlocConf);
//trace_startup(p, NULL, merged_config, note);
return (void *) pt_MergedConfig;
}
/*
* This function gets called to create a per-server configuration
* record. It will always be called for the "default" server.
*
* The return value is a pointer to the created module-specific
* structure.
*/
void *cs_create_server_config(apr_pool_t *p, server_rec *pt_S)
{
cs_cfg *pt_Cfg;
char *ps_SName = pt_S->server_hostname;
/*
* As with the x_create_dir_config() reoutine, we allocate and fill
* in an empty record.
*/
pt_Cfg = (cs_cfg *) apr_pcalloc(p, sizeof(cs_cfg));
#if 0
cfg->local = 0;
cfg->congenital = 0;
cfg->cmode = CONFIG_MODE_SERVER;
#endif
/*
* Note that we were called in the trace list.
*/
ps_SName = (ps_SName != NULL) ? ps_SName : "";
/*trace_startup(p, s, cfg, "x_create_server_config()");*/
return (void *) pt_Cfg;
}
/*
* This function gets called to merge two per-server configuration
* records. This is typically done to cope with things like virtual hosts and
* the default server configuration The routine has the responsibility of
* creating a new record and merging the contents of the other two into it
* appropriately. If the module doesn't declare a merge routine, the more
* specific existing record is used exclusively.
*
* The routine MUST NOT modify any of its arguments!
*
* The return value is a pointer to the created module-specific structure
* containing the merged values.
*/
void *cs_merge_server_config(apr_pool_t *p, void *pv_Server1Conf,
void *pv_Server2Conf)
{
cs_cfg *pt_MergedConfig = (cs_cfg *) apr_pcalloc(p, sizeof(cs_cfg));
cs_cfg *pt_S1conf = (cs_cfg *) pv_Server1Conf;
cs_cfg *pt_S2conf = (cs_cfg *) pv_Server2Conf;
char *ps_Note;
/*
* Our inheritance rules are our own, and part of our module's semantics.
* Basically, just note whence we came.
*/
return (void *) pt_MergedConfig;
}
/*--------------------------------------------------------------------------*/
/* */
/* The following pseudo-prototype declarations illustrate the parameters */
/* passed to command handlers for the different types of directive */
/* syntax. If an argument was specified in the directive definition */
/* (look for "command_rec" below), it's available to the command handler */
/* via the (void *) info field in the cmd_parms argument passed to the */
/* handler (cmd->info for the examples below). */
/* */
/*--------------------------------------------------------------------------*/
/*
* Command handler for a NO_ARGS directive. Declared in the command_rec
* list with
* AP_INIT_NO_ARGS("directive", function, mconfig, where, help)
*
* static const char *handle_NO_ARGS(cmd_parms *cmd, void *mconfig);
*/
/*
* Command handler for a RAW_ARGS directive. The "args" argument is the text
* of the commandline following the directive itself. Declared in the
* command_rec list with
* AP_INIT_RAW_ARGS("directive", function, mconfig, where, help)
*
* static const char *handle_RAW_ARGS(cmd_parms *cmd, void *mconfig,
* const char *args);
*/
/*
* Command handler for a FLAG directive. The single parameter is passed in
* "bool", which is either zero or not for Off or On respectively.
* Declared in the command_rec list with
* AP_INIT_FLAG("directive", function, mconfig, where, help)
*
* static const char *handle_FLAG(cmd_parms *cmd, void *mconfig, int bool);
*/
/*
* Command handler for a TAKE1 directive. The single parameter is passed in
* "word1". Declared in the command_rec list with
* AP_INIT_TAKE1("directive", function, mconfig, where, help)
*
* static const char *handle_TAKE1(cmd_parms *cmd, void *mconfig,
* char *word1);
*/
/*
* Command handler for a TAKE2 directive. TAKE2 commands must always have
* exactly two arguments. Declared in the command_rec list with
* AP_INIT_TAKE2("directive", function, mconfig, where, help)
*
* static const char *handle_TAKE2(cmd_parms *cmd, void *mconfig,
* char *word1, char *word2);
*/
/*
* Command handler for a TAKE3 directive. Like TAKE2, these must have exactly
* three arguments, or the parser complains and doesn't bother calling us.
* Declared in the command_rec list with
* AP_INIT_TAKE3("directive", function, mconfig, where, help)
*
* static const char *handle_TAKE3(cmd_parms *cmd, void *mconfig,
* char *word1, char *word2, char *word3);
*/
/*
* Command handler for a TAKE12 directive. These can take either one or two
* arguments.
* - word2 is a NULL pointer if no second argument was specified.
* Declared in the command_rec list with
* AP_INIT_TAKE12("directive", function, mconfig, where, help)
*
* static const char *handle_TAKE12(cmd_parms *cmd, void *mconfig,
* char *word1, char *word2);
*/
/*
* Command handler for a TAKE123 directive. A TAKE123 directive can be given,
* as might be expected, one, two, or three arguments.
* - word2 is a NULL pointer if no second argument was specified.
* - word3 is a NULL pointer if no third argument was specified.
* Declared in the command_rec list with
* AP_INIT_TAKE123("directive", function, mconfig, where, help)
*
* static const char *handle_TAKE123(cmd_parms *cmd, void *mconfig,
* char *word1, char *word2, char *word3);
*/
/*
* Command handler for a TAKE13 directive. Either one or three arguments are
* permitted - no two-parameters-only syntax is allowed.
* - word2 and word3 are NULL pointers if only one argument was specified.
* Declared in the command_rec list with
* AP_INIT_TAKE13("directive", function, mconfig, where, help)
*
* static const char *handle_TAKE13(cmd_parms *cmd, void *mconfig,
* char *word1, char *word2, char *word3);
*/
/*
* Command handler for a TAKE23 directive. At least two and as many as three
* arguments must be specified.
* - word3 is a NULL pointer if no third argument was specified.
* Declared in the command_rec list with
* AP_INIT_TAKE23("directive", function, mconfig, where, help)
*
* static const char *handle_TAKE23(cmd_parms *cmd, void *mconfig,
* char *word1, char *word2, char *word3);
*/
/*
* Command handler for a ITERATE directive.
* - Handler is called once for each of n arguments given to the directive.
* - word1 points to each argument in turn.
* Declared in the command_rec list with
* AP_INIT_ITERATE("directive", function, mconfig, where, help)
*
* static const char *handle_ITERATE(cmd_parms *cmd, void *mconfig,
* char *word1);
*/
/*
* Command handler for a ITERATE2 directive.
* - Handler is called once for each of the second and subsequent arguments
* given to the directive.
* - word1 is the same for each call for a particular directive instance (the
* first argument).
* - word2 points to each of the second and subsequent arguments in turn.
* Declared in the command_rec list with
* AP_INIT_ITERATE2("directive", function, mconfig, where, help)
*
* static const char *handle_ITERATE2(cmd_parms *cmd, void *mconfig,
* char *word1, char *word2);
*/
#if 0
/*--------------------------------------------------------------------------*/
/* We prototyped the various syntax for command handlers (routines that */
/* are called when the configuration parser detects a directive declared */
/* by our module) earlier. Now we actually declare a "real" routine that */
/* will be invoked by the parser when our "real" directive is */
/* encountered. */
/* */
/* If a command handler encounters a problem processing the directive, it */
/* signals this fact by returning a non-NULL pointer to a string */
/* describing the problem. */
/* */
/* The magic return value DECLINE_CMD is used to deal with directives */
/* that might be declared by multiple modules. If the command handler */
/* returns NULL, the directive was processed; if it returns DECLINE_CMD, */
/* the next module (if any) that declares the directive is given a chance */
/* at it. If it returns any other value, it's treated as the text of an */
/* error message. */
/*--------------------------------------------------------------------------*/
/*
* Command handler for the NO_ARGS "Example" directive. All we do is mark the
* call in the trace log, and flag the applicability of the directive to the
* current location in that location's configuration record.
*/
static const char *cmd_example(cmd_parms *cmd, void *mconfig)
{
cs_cfg *cfg = (cs_cfg *) mconfig;
trace_startup(cmd->pool, cmd->server, cfg, "cmd_example()");
return NULL;
}
#endif