-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
Copy pathhttp_config.h
1462 lines (1314 loc) · 56.8 KB
/
http_config.h
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
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* 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.
*/
/**
* @file http_config.h
* @brief Apache Configuration
*
* @defgroup APACHE_CORE_CONFIG Configuration
* @ingroup APACHE_CORE
* @{
*/
#ifndef APACHE_HTTP_CONFIG_H
#define APACHE_HTTP_CONFIG_H
#include "util_cfgtree.h"
#include "ap_config.h"
#include "apr_tables.h"
#ifdef __cplusplus
extern "C" {
#endif
/*
* The central data structures around here...
*/
/* Command dispatch structures... */
/**
* How the directives arguments should be parsed.
* @remark Note that for all of these except RAW_ARGS, the config routine is
* passed a freshly allocated string which can be modified or stored
* or whatever...
*/
enum cmd_how {
RAW_ARGS, /**< cmd_func parses command line itself */
TAKE1, /**< one argument only */
TAKE2, /**< two arguments only */
ITERATE, /**< one argument, occurring multiple times
* (e.g., IndexIgnore)
*/
ITERATE2, /**< two arguments, 2nd occurs multiple times
* (e.g., AddIcon)
*/
FLAG, /**< One of 'On' or 'Off' */
NO_ARGS, /**< No args at all, e.g. </Directory> */
TAKE12, /**< one or two arguments */
TAKE3, /**< three arguments only */
TAKE23, /**< two or three arguments */
TAKE123, /**< one, two or three arguments */
TAKE13, /**< one or three arguments */
TAKE_ARGV /**< an argc and argv are passed */
};
/**
* This structure is passed to a command which is being invoked,
* to carry a large variety of miscellaneous data which is all of
* use to *somebody*...
*/
typedef struct cmd_parms_struct cmd_parms;
#if defined(AP_HAVE_DESIGNATED_INITIALIZER) || defined(DOXYGEN)
/**
* All the types of functions that can be used in directives
* @internal
*/
typedef union {
/** function to call for a no-args */
const char *(*no_args) (cmd_parms *parms, void *mconfig);
/** function to call for a raw-args */
const char *(*raw_args) (cmd_parms *parms, void *mconfig,
const char *args);
/** function to call for a argv/argc */
const char *(*take_argv) (cmd_parms *parms, void *mconfig,
int argc, char *const argv[]);
/** function to call for a take1 */
const char *(*take1) (cmd_parms *parms, void *mconfig, const char *w);
/** function to call for a take2 */
const char *(*take2) (cmd_parms *parms, void *mconfig, const char *w,
const char *w2);
/** function to call for a take3 */
const char *(*take3) (cmd_parms *parms, void *mconfig, const char *w,
const char *w2, const char *w3);
/** function to call for a flag */
const char *(*flag) (cmd_parms *parms, void *mconfig, int on);
} cmd_func;
/** This configuration directive does not take any arguments */
# define AP_NO_ARGS func.no_args
/** This configuration directive will handle its own parsing of arguments*/
# define AP_RAW_ARGS func.raw_args
/** This configuration directive will handle its own parsing of arguments*/
# define AP_TAKE_ARGV func.take_argv
/** This configuration directive takes 1 argument*/
# define AP_TAKE1 func.take1
/** This configuration directive takes 2 arguments */
# define AP_TAKE2 func.take2
/** This configuration directive takes 3 arguments */
# define AP_TAKE3 func.take3
/** This configuration directive takes a flag (on/off) as a argument*/
# define AP_FLAG func.flag
/** mechanism for declaring a directive with no arguments */
# define AP_INIT_NO_ARGS(directive, func, mconfig, where, help) \
{ directive, { .no_args=func }, mconfig, where, NO_ARGS, help }
/** mechanism for declaring a directive with raw argument parsing */
# define AP_INIT_RAW_ARGS(directive, func, mconfig, where, help) \
{ directive, { .raw_args=func }, mconfig, where, RAW_ARGS, help }
/** mechanism for declaring a directive with raw argument parsing */
# define AP_INIT_TAKE_ARGV(directive, func, mconfig, where, help) \
{ directive, { .take_argv=func }, mconfig, where, TAKE_ARGV, help }
/** mechanism for declaring a directive which takes 1 argument */
# define AP_INIT_TAKE1(directive, func, mconfig, where, help) \
{ directive, { .take1=func }, mconfig, where, TAKE1, help }
/** mechanism for declaring a directive which takes multiple arguments */
# define AP_INIT_ITERATE(directive, func, mconfig, where, help) \
{ directive, { .take1=func }, mconfig, where, ITERATE, help }
/** mechanism for declaring a directive which takes 2 arguments */
# define AP_INIT_TAKE2(directive, func, mconfig, where, help) \
{ directive, { .take2=func }, mconfig, where, TAKE2, help }
/** mechanism for declaring a directive which takes 1 or 2 arguments */
# define AP_INIT_TAKE12(directive, func, mconfig, where, help) \
{ directive, { .take2=func }, mconfig, where, TAKE12, help }
/** mechanism for declaring a directive which takes multiple 2 arguments */
# define AP_INIT_ITERATE2(directive, func, mconfig, where, help) \
{ directive, { .take2=func }, mconfig, where, ITERATE2, help }
/** mechanism for declaring a directive which takes 1 or 3 arguments */
# define AP_INIT_TAKE13(directive, func, mconfig, where, help) \
{ directive, { .take3=func }, mconfig, where, TAKE13, help }
/** mechanism for declaring a directive which takes 2 or 3 arguments */
# define AP_INIT_TAKE23(directive, func, mconfig, where, help) \
{ directive, { .take3=func }, mconfig, where, TAKE23, help }
/** mechanism for declaring a directive which takes 1 to 3 arguments */
# define AP_INIT_TAKE123(directive, func, mconfig, where, help) \
{ directive, { .take3=func }, mconfig, where, TAKE123, help }
/** mechanism for declaring a directive which takes 3 arguments */
# define AP_INIT_TAKE3(directive, func, mconfig, where, help) \
{ directive, { .take3=func }, mconfig, where, TAKE3, help }
/** mechanism for declaring a directive which takes a flag (on/off) argument */
# define AP_INIT_FLAG(directive, func, mconfig, where, help) \
{ directive, { .flag=func }, mconfig, where, FLAG, help }
#else /* AP_HAVE_DESIGNATED_INITIALIZER */
typedef const char *(*cmd_func) ();
# define AP_NO_ARGS func
# define AP_RAW_ARGS func
# define AP_TAKE_ARGV func
# define AP_TAKE1 func
# define AP_TAKE2 func
# define AP_TAKE3 func
# define AP_FLAG func
# define AP_INIT_NO_ARGS(directive, func, mconfig, where, help) \
{ directive, func, mconfig, where, NO_ARGS, help }
# define AP_INIT_RAW_ARGS(directive, func, mconfig, where, help) \
{ directive, func, mconfig, where, RAW_ARGS, help }
# define AP_INIT_TAKE_ARGV(directive, func, mconfig, where, help) \
{ directive, func, mconfig, where, TAKE_ARGV, help }
# define AP_INIT_TAKE1(directive, func, mconfig, where, help) \
{ directive, func, mconfig, where, TAKE1, help }
# define AP_INIT_ITERATE(directive, func, mconfig, where, help) \
{ directive, func, mconfig, where, ITERATE, help }
# define AP_INIT_TAKE2(directive, func, mconfig, where, help) \
{ directive, func, mconfig, where, TAKE2, help }
# define AP_INIT_TAKE12(directive, func, mconfig, where, help) \
{ directive, func, mconfig, where, TAKE12, help }
# define AP_INIT_ITERATE2(directive, func, mconfig, where, help) \
{ directive, func, mconfig, where, ITERATE2, help }
# define AP_INIT_TAKE13(directive, func, mconfig, where, help) \
{ directive, func, mconfig, where, TAKE13, help }
# define AP_INIT_TAKE23(directive, func, mconfig, where, help) \
{ directive, func, mconfig, where, TAKE23, help }
# define AP_INIT_TAKE123(directive, func, mconfig, where, help) \
{ directive, func, mconfig, where, TAKE123, help }
# define AP_INIT_TAKE3(directive, func, mconfig, where, help) \
{ directive, func, mconfig, where, TAKE3, help }
# define AP_INIT_FLAG(directive, func, mconfig, where, help) \
{ directive, func, mconfig, where, FLAG, help }
#endif /* AP_HAVE_DESIGNATED_INITIALIZER */
/**
* The command record structure. Modules can define a table of these
* to define the directives it will implement.
*/
typedef struct command_struct command_rec;
struct command_struct {
/** Name of this command */
const char *name;
/** The function to be called when this directive is parsed */
cmd_func func;
/** Extra data, for functions which implement multiple commands... */
void *cmd_data;
/** What overrides need to be allowed to enable this command. */
int req_override;
/** What the command expects as arguments */
enum cmd_how args_how;
/** 'usage' message, in case of syntax errors */
const char *errmsg;
};
/**
* @defgroup ConfigDirectives Allowed locations for configuration directives.
*
* The allowed locations for a configuration directive are the union of
* those indicated by each set bit in the req_override mask.
*
* @{
*/
#define OR_NONE 0 /**< *.conf is not available anywhere in this override */
#define OR_LIMIT 1 /**< *.conf inside <Directory> or <Location>
and .htaccess when AllowOverride Limit */
#define OR_OPTIONS 2 /**< *.conf anywhere
and .htaccess when AllowOverride Options */
#define OR_FILEINFO 4 /**< *.conf anywhere
and .htaccess when AllowOverride FileInfo */
#define OR_AUTHCFG 8 /**< *.conf inside <Directory> or <Location>
and .htaccess when AllowOverride AuthConfig */
#define OR_INDEXES 16 /**< *.conf anywhere
and .htaccess when AllowOverride Indexes */
#define OR_UNSET 32 /**< bit to indicate that AllowOverride has not been set */
#define ACCESS_CONF 64 /**< *.conf inside <Directory> or <Location> */
#define RSRC_CONF 128 /**< *.conf outside <Directory> or <Location> */
#define EXEC_ON_READ 256 /**< force directive to execute a command
which would modify the configuration (like including another
file, or IFModule */
/* Flags to determine whether syntax errors in .htaccess should be
* treated as nonfatal (log and ignore errors)
*/
#define NONFATAL_OVERRIDE 512 /* Violation of AllowOverride rule */
#define NONFATAL_UNKNOWN 1024 /* Unrecognised directive */
#define NONFATAL_ALL (NONFATAL_OVERRIDE|NONFATAL_UNKNOWN)
#define PROXY_CONF 2048 /**< *.conf inside <Proxy> only */
/** this directive can be placed anywhere */
#define OR_ALL (OR_LIMIT|OR_OPTIONS|OR_FILEINFO|OR_AUTHCFG|OR_INDEXES)
/** @} */
/**
* This can be returned by a function if they don't wish to handle
* a command. Make it something not likely someone will actually use
* as an error code.
*/
#define DECLINE_CMD "\a\b"
/** Common structure for reading of config files / passwd files etc. */
typedef struct ap_configfile_t ap_configfile_t;
struct ap_configfile_t {
/**< an apr_file_getc()-like function */
apr_status_t (*getch) (char *ch, void *param);
/**< an apr_file_gets()-like function */
apr_status_t (*getstr) (void *buf, apr_size_t bufsiz, void *param);
/**< a close handler function */
apr_status_t (*close) (void *param);
/**< the argument passed to getch/getstr/close */
void *param;
/**< the filename / description */
const char *name;
/**< current line number, starting at 1 */
unsigned line_number;
};
/**
* This structure is passed to a command which is being invoked,
* to carry a large variety of miscellaneous data which is all of
* use to *somebody*...
*/
struct cmd_parms_struct {
/** Argument to command from cmd_table */
void *info;
/** Which allow-override bits are set */
int override;
/** Which allow-override-opts bits are set */
int override_opts;
/** Table of directives allowed per AllowOverrideList */
apr_table_t *override_list;
/** Which methods are <Limit>ed */
ap_method_mask_t limited;
/** methods which are limited */
apr_array_header_t *limited_xmethods;
/** methods which are xlimited */
ap_method_list_t *xlimited;
/** Config file structure. */
ap_configfile_t *config_file;
/** the directive specifying this command */
ap_directive_t *directive;
/** Pool to allocate new storage in */
apr_pool_t *pool;
/** Pool for scratch memory; persists during configuration, but
* wiped before the first request is served... */
apr_pool_t *temp_pool;
/** Server_rec being configured for */
server_rec *server;
/** If configuring for a directory, pathname of that directory. If the
* pathname is a regex, regex will be non-NULL below. If path is NULL,
* the directive is being called from a server context. */
char *path;
/** configuration command */
const command_rec *cmd;
/** per_dir_config vector passed to handle_command */
struct ap_conf_vector_t *context;
/** directive with syntax error */
const ap_directive_t *err_directive;
/** If the current directive is EXEC_ON_READ, this is the last
(non-EXEC_ON_READ) enclosing directive */
ap_directive_t *parent;
/** If the path is a regex, compiled regex will be not NULL. */
ap_regex_t *regex;
};
/**
* Flags associated with a module.
*/
#define AP_MODULE_FLAG_NONE (0)
#define AP_MODULE_FLAG_ALWAYS_MERGE (1 << 0)
/**
* Module structures. Just about everything is dispatched through
* these, directly or indirectly (through the command and handler
* tables).
*/
typedef struct module_struct module;
struct module_struct {
/** API version, *not* module version; check that module is
* compatible with this version of the server.
*/
int version;
/** API minor version. Provides API feature milestones. Not checked
* during module init */
int minor_version;
/** Index to this modules structures in config vectors. */
int module_index;
/** The name of the module's C file */
const char *name;
/** The handle for the DSO. Internal use only */
void *dynamic_load_handle;
/** A pointer to the next module in the list
* @var module_struct *next
*/
struct module_struct *next;
/** Magic Cookie to identify a module structure; It's mainly
* important for the DSO facility (see also mod_so). */
unsigned long magic;
/** Function to allow MPMs to re-write command line arguments. This
* hook is only available to MPMs.
* @param The process that the server is running in.
*/
void (*rewrite_args) (process_rec *process);
/** Function to allow all modules to create per directory configuration
* structures.
* @param p The pool to use for all allocations.
* @param dir The directory currently being processed.
* @return The per-directory structure created
*/
void *(*create_dir_config) (apr_pool_t *p, char *dir);
/** Function to allow all modules to merge the per directory configuration
* structures for two directories.
* @param p The pool to use for all allocations.
* @param base_conf The directory structure created for the parent directory.
* @param new_conf The directory structure currently being processed.
* @return The new per-directory structure created
*/
void *(*merge_dir_config) (apr_pool_t *p, void *base_conf, void *new_conf);
/** Function to allow all modules to create per server configuration
* structures.
* @param p The pool to use for all allocations.
* @param s The server currently being processed.
* @return The per-server structure created
*/
void *(*create_server_config) (apr_pool_t *p, server_rec *s);
/** Function to allow all modules to merge the per server configuration
* structures for two servers.
* @param p The pool to use for all allocations.
* @param base_conf The directory structure created for the parent directory.
* @param new_conf The directory structure currently being processed.
* @return The new per-directory structure created
*/
void *(*merge_server_config) (apr_pool_t *p, void *base_conf,
void *new_conf);
/** A command_rec table that describes all of the directives this module
* defines. */
const command_rec *cmds;
/** A hook to allow modules to hook other points in the request processing.
* In this function, modules should call the ap_hook_*() functions to
* register an interest in a specific step in processing the current
* request.
* @param p the pool to use for all allocations
*/
void (*register_hooks) (apr_pool_t *p);
/** A bitmask of AP_MODULE_FLAG_* */
int flags;
};
/**
* The AP_MAYBE_UNUSED macro is used for variable declarations that
* might potentially exhibit "unused var" warnings on some compilers if
* left untreated.
* Since static initializers are not part of the C language (C89), making
* (void) usage is not possible. However many compiler have proprietary
* mechanism to suppress those warnings.
*/
#ifdef AP_MAYBE_UNUSED
#elif defined(__GNUC__)
# define AP_MAYBE_UNUSED(x) x __attribute__((unused))
#elif defined(__LCLINT__)
# define AP_MAYBE_UNUSED(x) /*@unused@*/ x
#else
# define AP_MAYBE_UNUSED(x) x
#endif
/**
* The APLOG_USE_MODULE macro is used choose which module a file belongs to.
* This is necessary to allow per-module loglevel configuration.
*
* APLOG_USE_MODULE indirectly sets APLOG_MODULE_INDEX and APLOG_MARK.
*
* If a module should be backward compatible with versions before 2.3.6,
* APLOG_USE_MODULE needs to be enclosed in a ifdef APLOG_USE_MODULE block.
*
* @param foo name of the module symbol of the current module, without the
* trailing "_module" part
* @see APLOG_MARK
*/
#define APLOG_USE_MODULE(foo) \
extern module AP_MODULE_DECLARE_DATA foo##_module; \
AP_MAYBE_UNUSED(static int * const aplog_module_index) = &(foo##_module.module_index)
/**
* AP_DECLARE_MODULE is a convenience macro that combines a call of
* APLOG_USE_MODULE with the definition of the module symbol.
*
* If a module should be backward compatible with versions before 2.3.6,
* APLOG_USE_MODULE should be used explicitly instead of AP_DECLARE_MODULE.
*/
#define AP_DECLARE_MODULE(foo) \
APLOG_USE_MODULE(foo); \
module AP_MODULE_DECLARE_DATA foo##_module
/**
* @defgroup ModuleInit Module structure initializers
*
* Initializer for the first few module slots, which are only
* really set up once we start running. Note that the first two slots
* provide a version check; this should allow us to deal with changes to
* the API. The major number should reflect changes to the API handler table
* itself or removal of functionality. The minor number should reflect
* additions of functionality to the existing API. (the server can detect
* an old-format module, and either handle it back-compatibly, or at least
* signal an error). See src/include/ap_mmn.h for MMN version history.
* @{
*/
/** The one used in Apache 1.3, which will deliberately cause an error */
#define STANDARD_MODULE_STUFF this_module_needs_to_be_ported_to_apache_2_0
/** Use this in all standard modules */
#define STANDARD20_MODULE_STUFF MODULE_MAGIC_NUMBER_MAJOR, \
MODULE_MAGIC_NUMBER_MINOR, \
-1, \
__FILE__, \
NULL, \
NULL, \
MODULE_MAGIC_COOKIE, \
NULL /* rewrite args spot */
/** Use this only in MPMs */
#define MPM20_MODULE_STUFF MODULE_MAGIC_NUMBER_MAJOR, \
MODULE_MAGIC_NUMBER_MINOR, \
-1, \
__FILE__, \
NULL, \
NULL, \
MODULE_MAGIC_COOKIE
/** @} */
/* CONFIGURATION VECTOR FUNCTIONS */
/** configuration vector structure */
typedef struct ap_conf_vector_t ap_conf_vector_t;
/**
* Generic accessors for other modules to get at their own module-specific
* data
* @param cv The vector in which the modules configuration is stored.
* usually r->per_dir_config or s->module_config
* @param m The module to get the data for.
* @return The module-specific data
*/
AP_DECLARE(void *) ap_get_module_config(const ap_conf_vector_t *cv,
const module *m);
/**
* Generic accessors for other modules to set their own module-specific
* data
* @param cv The vector in which the modules configuration is stored.
* usually r->per_dir_config or s->module_config
* @param m The module to set the data for.
* @param val The module-specific data to set
*/
AP_DECLARE(void) ap_set_module_config(ap_conf_vector_t *cv, const module *m,
void *val);
/**
* When module flags have been introduced, and a way to check this.
*/
#define AP_MODULE_FLAGS_MMN_MAJOR 20161018
#define AP_MODULE_FLAGS_MMN_MINOR 7
#define AP_MODULE_HAS_FLAGS(m) \
AP_MODULE_MAGIC_AT_LEAST(AP_MODULE_FLAGS_MMN_MAJOR, \
AP_MODULE_FLAGS_MMN_MINOR)
/**
* Generic accessor for the module's flags
* @param m The module to get the flags from.
* @return The module-specific flags
*/
AP_DECLARE(int) ap_get_module_flags(const module *m);
#if !defined(AP_DEBUG)
#define ap_get_module_config(v,m) \
(((void **)(v))[(m)->module_index])
#define ap_set_module_config(v,m,val) \
((((void **)(v))[(m)->module_index]) = (val))
#endif /* AP_DEBUG */
/**
* Generic accessor for modules to get the module-specific loglevel
* @param s The server from which to get the loglevel.
* @param index The module_index of the module to get the loglevel for.
* @return The module-specific loglevel
*/
AP_DECLARE(int) ap_get_server_module_loglevel(const server_rec *s, int index);
/**
* Generic accessor for modules the module-specific loglevel
* @param c The connection from which to get the loglevel.
* @param index The module_index of the module to get the loglevel for.
* @return The module-specific loglevel
*/
AP_DECLARE(int) ap_get_conn_module_loglevel(const conn_rec *c, int index);
/**
* Generic accessor for modules the module-specific loglevel
* @param c The connection from which to get the loglevel.
* @param s The server from which to get the loglevel if c does not have a
* specific loglevel configuration.
* @param index The module_index of the module to get the loglevel for.
* @return The module-specific loglevel
*/
AP_DECLARE(int) ap_get_conn_server_module_loglevel(const conn_rec *c,
const server_rec *s,
int index);
/**
* Generic accessor for modules to get the module-specific loglevel
* @param r The request from which to get the loglevel.
* @param index The module_index of the module to get the loglevel for.
* @return The module-specific loglevel
*/
AP_DECLARE(int) ap_get_request_module_loglevel(const request_rec *r, int index);
/**
* Accessor to set module-specific loglevel
* @param p A pool
* @param l The ap_logconf struct to modify.
* @param index The module_index of the module to set the loglevel for.
* @param level The new log level
*/
AP_DECLARE(void) ap_set_module_loglevel(apr_pool_t *p, struct ap_logconf *l,
int index, int level);
#if !defined(AP_DEBUG)
#define ap_get_conn_logconf(c) \
((c)->log ? (c)->log : \
&(c)->base_server->log)
#define ap_get_conn_server_logconf(c,s) \
( ( (c)->log != &(c)->base_server->log && (c)->log != NULL ) ? \
(c)->log : \
&(s)->log )
#define ap_get_request_logconf(r) \
((r)->log ? (r)->log : \
(r)->connection->log ? (r)->connection->log : \
&(r)->server->log)
#define ap_get_module_loglevel(l,i) \
(((i) < 0 || (l)->module_levels == NULL || (l)->module_levels[i] < 0) ? \
(l)->level : \
(l)->module_levels[i])
#define ap_get_server_module_loglevel(s,i) \
(ap_get_module_loglevel(&(s)->log,i))
#define ap_get_conn_module_loglevel(c,i) \
(ap_get_module_loglevel(ap_get_conn_logconf(c),i))
#define ap_get_conn_server_module_loglevel(c,s,i) \
(ap_get_module_loglevel(ap_get_conn_server_logconf(c,s),i))
#define ap_get_request_module_loglevel(r,i) \
(ap_get_module_loglevel(ap_get_request_logconf(r),i))
#endif /* AP_DEBUG */
/**
* Set all module-specific loglevels to val
* @param l The log config for which to set the loglevels.
* @param val the value to set all loglevels to
*/
AP_DECLARE(void) ap_reset_module_loglevels(struct ap_logconf *l, int val);
/**
* Generic command handling function for strings
* @param cmd The command parameters for this directive
* @param struct_ptr pointer into a given type
* @param arg The argument to the directive
* @return An error string or NULL on success
*/
AP_DECLARE_NONSTD(const char *) ap_set_string_slot(cmd_parms *cmd,
void *struct_ptr,
const char *arg);
/**
* Generic command handling function for integers
* @param cmd The command parameters for this directive
* @param struct_ptr pointer into a given type
* @param arg The argument to the directive
* @return An error string or NULL on success
*/
AP_DECLARE_NONSTD(const char *) ap_set_int_slot(cmd_parms *cmd,
void *struct_ptr,
const char *arg);
/**
* Parsing function for log level
* @param str The string to parse
* @param val The parsed log level
* @return An error string or NULL on success
*/
AP_DECLARE(const char *) ap_parse_log_level(const char *str, int *val);
/**
* Return true if the specified method is limited by being listed in
* a <Limit> container, or by *not* being listed in a <LimitExcept>
* container.
*
* @param method Pointer to a string specifying the method to check.
* @param cmd Pointer to the cmd_parms structure passed to the
* directive handler.
* @return 0 if the method is not limited in the current scope
*/
AP_DECLARE(int) ap_method_is_limited(cmd_parms *cmd, const char *method);
/**
* Generic command handling function for strings, always sets the value
* to a lowercase string
* @param cmd The command parameters for this directive
* @param struct_ptr pointer into a given type
* @param arg The argument to the directive
* @return An error string or NULL on success
*/
AP_DECLARE_NONSTD(const char *) ap_set_string_slot_lower(cmd_parms *cmd,
void *struct_ptr,
const char *arg);
/**
* Generic command handling function for flags stored in an int
* @param cmd The command parameters for this directive
* @param struct_ptr pointer into a given type
* @param arg The argument to the directive (either 1 or 0)
* @return An error string or NULL on success
*/
AP_DECLARE_NONSTD(const char *) ap_set_flag_slot(cmd_parms *cmd,
void *struct_ptr,
int arg);
/**
* Generic command handling function for flags stored in a char
* @param cmd The command parameters for this directive
* @param struct_ptr pointer into a given type
* @param arg The argument to the directive (either 1 or 0)
* @return An error string or NULL on success
*/
AP_DECLARE_NONSTD(const char *) ap_set_flag_slot_char(cmd_parms *cmd,
void *struct_ptr,
int arg);
/**
* Generic command handling function for files
* @param cmd The command parameters for this directive
* @param struct_ptr pointer into a given type
* @param arg The argument to the directive
* @return An error string or NULL on success
*/
AP_DECLARE_NONSTD(const char *) ap_set_file_slot(cmd_parms *cmd,
void *struct_ptr,
const char *arg);
/**
* Generic command handling function to respond with cmd->help as an error
* @param cmd The command parameters for this directive
* @param struct_ptr pointer into a given type
* @param arg The argument to the directive
* @return The cmd->help value as the error string
* @note This allows simple declarations such as:
* @code
* AP_INIT_RAW_ARGS("Foo", ap_set_deprecated, NULL, OR_ALL,
* "The Foo directive is no longer supported, use Bar"),
* @endcode
*/
AP_DECLARE_NONSTD(const char *) ap_set_deprecated(cmd_parms *cmd,
void *struct_ptr,
const char *arg);
/**
* For modules which need to read config files, open logs, etc. this returns
* the canonical form of fname made absolute to ap_server_root.
* @param p pool to allocate data from
* @param fname The file name
*/
AP_DECLARE(char *) ap_server_root_relative(apr_pool_t *p, const char *fname);
/**
* Compute the name of a run-time file (e.g., shared memory "file") relative
* to the appropriate run-time directory. Absolute paths are returned as-is.
* The run-time directory is configured via the DefaultRuntimeDir directive or
* at build time.
*/
AP_DECLARE(char *) ap_runtime_dir_relative(apr_pool_t *p, const char *fname);
/**
* Compute the name of a persistent state file (e.g. a database or
* long-lived cache) relative to the appropriate state directory.
* Absolute paths are returned as-is. The state directory is
* configured via the DefaultStateDir directive or at build time.
*/
AP_DECLARE(char *) ap_state_dir_relative(apr_pool_t *p, const char *fname);
/* Finally, the hook for dynamically loading modules in... */
/**
* Add a module to the server
* @param m The module structure of the module to add
* @param p The pool of the same lifetime as the module
* @param s The module's symbol name (used for logging)
*/
AP_DECLARE(const char *) ap_add_module(module *m, apr_pool_t *p,
const char *s);
/**
* Remove a module from the server. There are some caveats:
* when the module is removed, its slot is lost so all the current
* per-dir and per-server configurations are invalid. So we should
* only ever call this function when you are invalidating almost
* all our current data. I.e. when doing a restart.
* @param m the module structure of the module to remove
*/
AP_DECLARE(void) ap_remove_module(module *m);
/**
* Add a module to the chained modules list and the list of loaded modules
* @param mod The module structure of the module to add
* @param p The pool with the same lifetime as the module
* @param s The module's symbol name (used for logging)
*/
AP_DECLARE(const char *) ap_add_loaded_module(module *mod, apr_pool_t *p,
const char *s);
/**
* Remove a module from the chained modules list and the list of loaded modules
* @param mod the module structure of the module to remove
*/
AP_DECLARE(void) ap_remove_loaded_module(module *mod);
/**
* Find the name of the specified module
* @param m The module to get the name for
* @return the name of the module
*/
AP_DECLARE(const char *) ap_find_module_name(module *m);
/**
* Find the short name of the module identified by the specified module index
* @param module_index The module index to get the name for
* @return the name of the module, NULL if not found
*/
AP_DECLARE(const char *) ap_find_module_short_name(int module_index);
/**
* Find a module based on the name of the module
* @param name the name of the module
* @return the module structure if found, NULL otherwise
*/
AP_DECLARE(module *) ap_find_linked_module(const char *name);
/**
* Open a ap_configfile_t as apr_file_t
* @param ret_cfg open ap_configfile_t struct pointer
* @param p The pool to allocate the structure from
* @param name the name of the file to open
*/
AP_DECLARE(apr_status_t) ap_pcfg_openfile(ap_configfile_t **ret_cfg,
apr_pool_t *p, const char *name);
/**
* Allocate a ap_configfile_t handle with user defined functions and params
* @param p The pool to allocate from
* @param descr The name of the file
* @param param The argument passed to getch/getstr/close
* @param getc_func The getch function
* @param gets_func The getstr function
* @param close_func The close function
*/
AP_DECLARE(ap_configfile_t *) ap_pcfg_open_custom(apr_pool_t *p,
const char *descr,
void *param,
apr_status_t (*getc_func) (char *ch, void *param),
apr_status_t (*gets_func) (void *buf, apr_size_t bufsiz, void *param),
apr_status_t (*close_func) (void *param));
/**
* Read one line from open ap_configfile_t, strip leading and trailing
* whitespace, increase line number
* @param buf place to store the line read
* @param bufsize size of the buffer
* @param cfp File to read from
* @return error status, APR_ENOSPC if bufsize is too small for the line
*/
AP_DECLARE(apr_status_t) ap_cfg_getline(char *buf, apr_size_t bufsize, ap_configfile_t *cfp);
/**
* Read one char from open configfile_t, increase line number upon LF
* @param ch place to store the char read
* @param cfp The file to read from
* @return error status
*/
AP_DECLARE(apr_status_t) ap_cfg_getc(char *ch, ap_configfile_t *cfp);
/**
* Detach from open ap_configfile_t, calling the close handler
* @param cfp The file to close
* @return 1 on success, 0 on failure
*/
AP_DECLARE(int) ap_cfg_closefile(ap_configfile_t *cfp);
/**
* Convert a return value from ap_cfg_getline or ap_cfg_getc to a user friendly
* string.
* @param p The pool to allocate the string from
* @param cfp The config file
* @param rc The return value to convert
* @return The error string, NULL if rc == APR_SUCCESS
*/
AP_DECLARE(const char *) ap_pcfg_strerror(apr_pool_t *p, ap_configfile_t *cfp,
apr_status_t rc);
/**
* Read all data between the current <foo> and the matching </foo>. All
* of this data is forgotten immediately.
* @param cmd The cmd_parms to pass to the directives inside the container
* @param directive The directive name to read until
* @return Error string on failure, NULL on success
* @note If cmd->pool == cmd->temp_pool, ap_soak_end_container() will assume
* .htaccess context and use a lower maximum line length.
*/
AP_DECLARE(const char *) ap_soak_end_container(cmd_parms *cmd, const char *directive);
/**
* Read all data between the current <foo> and the matching </foo> and build
* a config tree from it
* @param p pool to allocate from
* @param temp_pool Temporary pool to allocate from
* @param parms The cmd_parms to pass to all directives read
* @param current The current node in the tree
* @param curr_parent The current parent node
* @param orig_directive The directive to read until hit.
* @return Error string on failure, NULL on success
* @note If p == temp_pool, ap_build_cont_config() will assume .htaccess
* context and use a lower maximum line length.
*/
AP_DECLARE(const char *) ap_build_cont_config(apr_pool_t *p,
apr_pool_t *temp_pool,
cmd_parms *parms,
ap_directive_t **current,
ap_directive_t **curr_parent,
const char *orig_directive);
/**
* Build a config tree from a config file
* @param parms The cmd_parms to pass to all of the directives in the file
* @param conf_pool The pconf pool
* @param temp_pool The temporary pool
* @param conftree Place to store the root node of the config tree
* @return Error string on error, NULL otherwise
* @note If conf_pool == temp_pool, ap_build_config() will assume .htaccess
* context and use a lower maximum line length.
*/
AP_DECLARE(const char *) ap_build_config(cmd_parms *parms,
apr_pool_t *conf_pool,
apr_pool_t *temp_pool,
ap_directive_t **conftree);
/**
* Walk a config tree and setup the server's internal structures
* @param conftree The config tree to walk
* @param parms The cmd_parms to pass to all functions
* @param section_vector The per-section config vector.
* @return Error string on error, NULL otherwise
*/
AP_DECLARE(const char *) ap_walk_config(ap_directive_t *conftree,
cmd_parms *parms,
ap_conf_vector_t *section_vector);
/**
* Convenience function to create a ap_dir_match_t structure from a cmd_parms.
*
* @param cmd The command.
* @param flags Flags to indicate whether optional or recursive.
* @param cb Callback for each file found that matches the wildcard. Return NULL on
* success, an error string on error.
* @param ctx Context for the callback.
* @return Structure ap_dir_match_t with fields populated, allocated from the
* cmd->temp_pool.
*/
AP_DECLARE(ap_dir_match_t *)ap_dir_cfgmatch(cmd_parms *cmd, int flags,
const char *(*cb)(ap_dir_match_t *w, const char *fname), void *ctx)
__attribute__((nonnull(1,3)));
/**
* @defgroup ap_check_cmd_context Check command context
* @{
*/
/**
* Check the context a command is used in.
* @param cmd The command to check
* @param forbidden Where the command is forbidden.
* @return Error string on error, NULL on success
*/
AP_DECLARE(const char *) ap_check_cmd_context(cmd_parms *cmd,
unsigned forbidden);
#define NOT_IN_VIRTUALHOST 0x01 /**< Forbidden in <VirtualHost> */
#define NOT_IN_LIMIT 0x02 /**< Forbidden in <Limit> */
#define NOT_IN_DIRECTORY 0x04 /**< Forbidden in <Directory> */
#define NOT_IN_LOCATION 0x08 /**< Forbidden in <Location> */
#define NOT_IN_FILES 0x10 /**< Forbidden in <Files> or <If>*/
#define NOT_IN_HTACCESS 0x20 /**< Forbidden in .htaccess files */
#define NOT_IN_PROXY 0x40 /**< Forbidden in <Proxy> */
/** Forbidden in <Directory>/<Location>/<Files><If>*/
#define NOT_IN_DIR_LOC_FILE (NOT_IN_DIRECTORY|NOT_IN_LOCATION|NOT_IN_FILES)
/** Forbidden in <Directory>/<Location>/<Files><If><Proxy>*/
#define NOT_IN_DIR_CONTEXT (NOT_IN_LIMIT|NOT_IN_DIR_LOC_FILE|NOT_IN_PROXY)
/** Forbidden in <VirtualHost>/<Limit>/<Directory>/<Location>/<Files>/<If><Proxy>*/
#define GLOBAL_ONLY (NOT_IN_VIRTUALHOST|NOT_IN_DIR_CONTEXT)
/** @} */
/**
* @brief This structure is used to assign symbol names to module pointers
*/
typedef struct {
const char *name;
module *modp;
} ap_module_symbol_t;
/**
* The topmost module in the list
* @var module *ap_top_module
*/
AP_DECLARE_DATA extern module *ap_top_module;
/**
* Array of all statically linked modules