http_config.h 57 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431
  1. /* Licensed to the Apache Software Foundation (ASF) under one or more
  2. * contributor license agreements. See the NOTICE file distributed with
  3. * this work for additional information regarding copyright ownership.
  4. * The ASF licenses this file to You under the Apache License, Version 2.0
  5. * (the "License"); you may not use this file except in compliance with
  6. * the License. You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. /**
  17. * @file http_config.h
  18. * @brief Apache Configuration
  19. *
  20. * @defgroup APACHE_CORE_CONFIG Configuration
  21. * @ingroup APACHE_CORE
  22. * @{
  23. */
  24. #ifndef APACHE_HTTP_CONFIG_H
  25. #define APACHE_HTTP_CONFIG_H
  26. #include "util_cfgtree.h"
  27. #include "ap_config.h"
  28. #include "apr_tables.h"
  29. #ifdef __cplusplus
  30. extern "C" {
  31. #endif
  32. /*
  33. * The central data structures around here...
  34. */
  35. /* Command dispatch structures... */
  36. /**
  37. * How the directives arguments should be parsed.
  38. * @remark Note that for all of these except RAW_ARGS, the config routine is
  39. * passed a freshly allocated string which can be modified or stored
  40. * or whatever...
  41. */
  42. enum cmd_how {
  43. RAW_ARGS, /**< cmd_func parses command line itself */
  44. TAKE1, /**< one argument only */
  45. TAKE2, /**< two arguments only */
  46. ITERATE, /**< one argument, occurring multiple times
  47. * (e.g., IndexIgnore)
  48. */
  49. ITERATE2, /**< two arguments, 2nd occurs multiple times
  50. * (e.g., AddIcon)
  51. */
  52. FLAG, /**< One of 'On' or 'Off' */
  53. NO_ARGS, /**< No args at all, e.g. &lt;/Directory&gt; */
  54. TAKE12, /**< one or two arguments */
  55. TAKE3, /**< three arguments only */
  56. TAKE23, /**< two or three arguments */
  57. TAKE123, /**< one, two or three arguments */
  58. TAKE13, /**< one or three arguments */
  59. TAKE_ARGV /**< an argc and argv are passed */
  60. };
  61. /**
  62. * This structure is passed to a command which is being invoked,
  63. * to carry a large variety of miscellaneous data which is all of
  64. * use to *somebody*...
  65. */
  66. typedef struct cmd_parms_struct cmd_parms;
  67. #if defined(AP_HAVE_DESIGNATED_INITIALIZER) || defined(DOXYGEN)
  68. /**
  69. * All the types of functions that can be used in directives
  70. * @internal
  71. */
  72. typedef union {
  73. /** function to call for a no-args */
  74. const char *(*no_args) (cmd_parms *parms, void *mconfig);
  75. /** function to call for a raw-args */
  76. const char *(*raw_args) (cmd_parms *parms, void *mconfig,
  77. const char *args);
  78. /** function to call for a argv/argc */
  79. const char *(*take_argv) (cmd_parms *parms, void *mconfig,
  80. int argc, char *const argv[]);
  81. /** function to call for a take1 */
  82. const char *(*take1) (cmd_parms *parms, void *mconfig, const char *w);
  83. /** function to call for a take2 */
  84. const char *(*take2) (cmd_parms *parms, void *mconfig, const char *w,
  85. const char *w2);
  86. /** function to call for a take3 */
  87. const char *(*take3) (cmd_parms *parms, void *mconfig, const char *w,
  88. const char *w2, const char *w3);
  89. /** function to call for a flag */
  90. const char *(*flag) (cmd_parms *parms, void *mconfig, int on);
  91. } cmd_func;
  92. /** This configuration directive does not take any arguments */
  93. # define AP_NO_ARGS func.no_args
  94. /** This configuration directive will handle its own parsing of arguments*/
  95. # define AP_RAW_ARGS func.raw_args
  96. /** This configuration directive will handle its own parsing of arguments*/
  97. # define AP_TAKE_ARGV func.take_argv
  98. /** This configuration directive takes 1 argument*/
  99. # define AP_TAKE1 func.take1
  100. /** This configuration directive takes 2 arguments */
  101. # define AP_TAKE2 func.take2
  102. /** This configuration directive takes 3 arguments */
  103. # define AP_TAKE3 func.take3
  104. /** This configuration directive takes a flag (on/off) as a argument*/
  105. # define AP_FLAG func.flag
  106. /** mechanism for declaring a directive with no arguments */
  107. # define AP_INIT_NO_ARGS(directive, func, mconfig, where, help) \
  108. { directive, { .no_args=func }, mconfig, where, RAW_ARGS, help }
  109. /** mechanism for declaring a directive with raw argument parsing */
  110. # define AP_INIT_RAW_ARGS(directive, func, mconfig, where, help) \
  111. { directive, { .raw_args=func }, mconfig, where, RAW_ARGS, help }
  112. /** mechanism for declaring a directive with raw argument parsing */
  113. # define AP_INIT_TAKE_ARGV(directive, func, mconfig, where, help) \
  114. { directive, { .take_argv=func }, mconfig, where, TAKE_ARGV, help }
  115. /** mechanism for declaring a directive which takes 1 argument */
  116. # define AP_INIT_TAKE1(directive, func, mconfig, where, help) \
  117. { directive, { .take1=func }, mconfig, where, TAKE1, help }
  118. /** mechanism for declaring a directive which takes multiple arguments */
  119. # define AP_INIT_ITERATE(directive, func, mconfig, where, help) \
  120. { directive, { .take1=func }, mconfig, where, ITERATE, help }
  121. /** mechanism for declaring a directive which takes 2 arguments */
  122. # define AP_INIT_TAKE2(directive, func, mconfig, where, help) \
  123. { directive, { .take2=func }, mconfig, where, TAKE2, help }
  124. /** mechanism for declaring a directive which takes 1 or 2 arguments */
  125. # define AP_INIT_TAKE12(directive, func, mconfig, where, help) \
  126. { directive, { .take2=func }, mconfig, where, TAKE12, help }
  127. /** mechanism for declaring a directive which takes multiple 2 arguments */
  128. # define AP_INIT_ITERATE2(directive, func, mconfig, where, help) \
  129. { directive, { .take2=func }, mconfig, where, ITERATE2, help }
  130. /** mechanism for declaring a directive which takes 1 or 3 arguments */
  131. # define AP_INIT_TAKE13(directive, func, mconfig, where, help) \
  132. { directive, { .take3=func }, mconfig, where, TAKE13, help }
  133. /** mechanism for declaring a directive which takes 2 or 3 arguments */
  134. # define AP_INIT_TAKE23(directive, func, mconfig, where, help) \
  135. { directive, { .take3=func }, mconfig, where, TAKE23, help }
  136. /** mechanism for declaring a directive which takes 1 to 3 arguments */
  137. # define AP_INIT_TAKE123(directive, func, mconfig, where, help) \
  138. { directive, { .take3=func }, mconfig, where, TAKE123, help }
  139. /** mechanism for declaring a directive which takes 3 arguments */
  140. # define AP_INIT_TAKE3(directive, func, mconfig, where, help) \
  141. { directive, { .take3=func }, mconfig, where, TAKE3, help }
  142. /** mechanism for declaring a directive which takes a flag (on/off) argument */
  143. # define AP_INIT_FLAG(directive, func, mconfig, where, help) \
  144. { directive, { .flag=func }, mconfig, where, FLAG, help }
  145. #else /* AP_HAVE_DESIGNATED_INITIALIZER */
  146. typedef const char *(*cmd_func) ();
  147. # define AP_NO_ARGS func
  148. # define AP_RAW_ARGS func
  149. # define AP_TAKE_ARGV func
  150. # define AP_TAKE1 func
  151. # define AP_TAKE2 func
  152. # define AP_TAKE3 func
  153. # define AP_FLAG func
  154. # define AP_INIT_NO_ARGS(directive, func, mconfig, where, help) \
  155. { directive, func, mconfig, where, RAW_ARGS, help }
  156. # define AP_INIT_RAW_ARGS(directive, func, mconfig, where, help) \
  157. { directive, func, mconfig, where, RAW_ARGS, help }
  158. # define AP_INIT_TAKE_ARGV(directive, func, mconfig, where, help) \
  159. { directive, func, mconfig, where, TAKE_ARGV, help }
  160. # define AP_INIT_TAKE1(directive, func, mconfig, where, help) \
  161. { directive, func, mconfig, where, TAKE1, help }
  162. # define AP_INIT_ITERATE(directive, func, mconfig, where, help) \
  163. { directive, func, mconfig, where, ITERATE, help }
  164. # define AP_INIT_TAKE2(directive, func, mconfig, where, help) \
  165. { directive, func, mconfig, where, TAKE2, help }
  166. # define AP_INIT_TAKE12(directive, func, mconfig, where, help) \
  167. { directive, func, mconfig, where, TAKE12, help }
  168. # define AP_INIT_ITERATE2(directive, func, mconfig, where, help) \
  169. { directive, func, mconfig, where, ITERATE2, help }
  170. # define AP_INIT_TAKE13(directive, func, mconfig, where, help) \
  171. { directive, func, mconfig, where, TAKE13, help }
  172. # define AP_INIT_TAKE23(directive, func, mconfig, where, help) \
  173. { directive, func, mconfig, where, TAKE23, help }
  174. # define AP_INIT_TAKE123(directive, func, mconfig, where, help) \
  175. { directive, func, mconfig, where, TAKE123, help }
  176. # define AP_INIT_TAKE3(directive, func, mconfig, where, help) \
  177. { directive, func, mconfig, where, TAKE3, help }
  178. # define AP_INIT_FLAG(directive, func, mconfig, where, help) \
  179. { directive, func, mconfig, where, FLAG, help }
  180. #endif /* AP_HAVE_DESIGNATED_INITIALIZER */
  181. /**
  182. * The command record structure. Modules can define a table of these
  183. * to define the directives it will implement.
  184. */
  185. typedef struct command_struct command_rec;
  186. struct command_struct {
  187. /** Name of this command */
  188. const char *name;
  189. /** The function to be called when this directive is parsed */
  190. cmd_func func;
  191. /** Extra data, for functions which implement multiple commands... */
  192. void *cmd_data;
  193. /** What overrides need to be allowed to enable this command. */
  194. int req_override;
  195. /** What the command expects as arguments */
  196. enum cmd_how args_how;
  197. /** 'usage' message, in case of syntax errors */
  198. const char *errmsg;
  199. };
  200. /**
  201. * @defgroup ConfigDirectives Allowed locations for configuration directives.
  202. *
  203. * The allowed locations for a configuration directive are the union of
  204. * those indicated by each set bit in the req_override mask.
  205. *
  206. * @{
  207. */
  208. #define OR_NONE 0 /**< *.conf is not available anywhere in this override */
  209. #define OR_LIMIT 1 /**< *.conf inside &lt;Directory&gt; or &lt;Location&gt;
  210. and .htaccess when AllowOverride Limit */
  211. #define OR_OPTIONS 2 /**< *.conf anywhere
  212. and .htaccess when AllowOverride Options */
  213. #define OR_FILEINFO 4 /**< *.conf anywhere
  214. and .htaccess when AllowOverride FileInfo */
  215. #define OR_AUTHCFG 8 /**< *.conf inside &lt;Directory&gt; or &lt;Location&gt;
  216. and .htaccess when AllowOverride AuthConfig */
  217. #define OR_INDEXES 16 /**< *.conf anywhere
  218. and .htaccess when AllowOverride Indexes */
  219. #define OR_UNSET 32 /**< bit to indicate that AllowOverride has not been set */
  220. #define ACCESS_CONF 64 /**< *.conf inside &lt;Directory&gt; or &lt;Location&gt; */
  221. #define RSRC_CONF 128 /**< *.conf outside &lt;Directory&gt; or &lt;Location&gt; */
  222. #define EXEC_ON_READ 256 /**< force directive to execute a command
  223. which would modify the configuration (like including another
  224. file, or IFModule */
  225. /* Flags to determine whether syntax errors in .htaccess should be
  226. * treated as nonfatal (log and ignore errors)
  227. */
  228. #define NONFATAL_OVERRIDE 512 /* Violation of AllowOverride rule */
  229. #define NONFATAL_UNKNOWN 1024 /* Unrecognised directive */
  230. #define NONFATAL_ALL (NONFATAL_OVERRIDE|NONFATAL_UNKNOWN)
  231. #define PROXY_CONF 2048 /**< *.conf inside &lt;Proxy&gt; only */
  232. /** this directive can be placed anywhere */
  233. #define OR_ALL (OR_LIMIT|OR_OPTIONS|OR_FILEINFO|OR_AUTHCFG|OR_INDEXES)
  234. /** @} */
  235. /**
  236. * This can be returned by a function if they don't wish to handle
  237. * a command. Make it something not likely someone will actually use
  238. * as an error code.
  239. */
  240. #define DECLINE_CMD "\a\b"
  241. /** Common structure for reading of config files / passwd files etc. */
  242. typedef struct ap_configfile_t ap_configfile_t;
  243. struct ap_configfile_t {
  244. /**< an apr_file_getc()-like function */
  245. apr_status_t (*getch) (char *ch, void *param);
  246. /**< an apr_file_gets()-like function */
  247. apr_status_t (*getstr) (void *buf, apr_size_t bufsiz, void *param);
  248. /**< a close handler function */
  249. apr_status_t (*close) (void *param);
  250. /**< the argument passed to getch/getstr/close */
  251. void *param;
  252. /**< the filename / description */
  253. const char *name;
  254. /**< current line number, starting at 1 */
  255. unsigned line_number;
  256. };
  257. /**
  258. * This structure is passed to a command which is being invoked,
  259. * to carry a large variety of miscellaneous data which is all of
  260. * use to *somebody*...
  261. */
  262. struct cmd_parms_struct {
  263. /** Argument to command from cmd_table */
  264. void *info;
  265. /** Which allow-override bits are set */
  266. int override;
  267. /** Which allow-override-opts bits are set */
  268. int override_opts;
  269. /** Table of directives allowed per AllowOverrideList */
  270. apr_table_t *override_list;
  271. /** Which methods are &lt;Limit&gt;ed */
  272. apr_int64_t limited;
  273. /** methods which are limited */
  274. apr_array_header_t *limited_xmethods;
  275. /** methods which are xlimited */
  276. ap_method_list_t *xlimited;
  277. /** Config file structure. */
  278. ap_configfile_t *config_file;
  279. /** the directive specifying this command */
  280. ap_directive_t *directive;
  281. /** Pool to allocate new storage in */
  282. apr_pool_t *pool;
  283. /** Pool for scratch memory; persists during configuration, but
  284. * wiped before the first request is served... */
  285. apr_pool_t *temp_pool;
  286. /** Server_rec being configured for */
  287. server_rec *server;
  288. /** If configuring for a directory, pathname of that directory.
  289. * NOPE! That's what it meant previous to the existence of &lt;Files&gt;,
  290. * &lt;Location&gt; and regex matching. Now the only usefulness that can be
  291. * derived from this field is whether a command is being called in a
  292. * server context (path == NULL) or being called in a dir context
  293. * (path != NULL). */
  294. char *path;
  295. /** configuration command */
  296. const command_rec *cmd;
  297. /** per_dir_config vector passed to handle_command */
  298. struct ap_conf_vector_t *context;
  299. /** directive with syntax error */
  300. const ap_directive_t *err_directive;
  301. };
  302. /**
  303. * Flags associated with a module.
  304. */
  305. #define AP_MODULE_FLAG_NONE (0)
  306. #define AP_MODULE_FLAG_ALWAYS_MERGE (1 << 0)
  307. /**
  308. * Module structures. Just about everything is dispatched through
  309. * these, directly or indirectly (through the command and handler
  310. * tables).
  311. */
  312. typedef struct module_struct module;
  313. struct module_struct {
  314. /** API version, *not* module version; check that module is
  315. * compatible with this version of the server.
  316. */
  317. int version;
  318. /** API minor version. Provides API feature milestones. Not checked
  319. * during module init */
  320. int minor_version;
  321. /** Index to this modules structures in config vectors. */
  322. int module_index;
  323. /** The name of the module's C file */
  324. const char *name;
  325. /** The handle for the DSO. Internal use only */
  326. void *dynamic_load_handle;
  327. /** A pointer to the next module in the list
  328. * @var module_struct *next
  329. */
  330. struct module_struct *next;
  331. /** Magic Cookie to identify a module structure; It's mainly
  332. * important for the DSO facility (see also mod_so). */
  333. unsigned long magic;
  334. /** Function to allow MPMs to re-write command line arguments. This
  335. * hook is only available to MPMs.
  336. * @param The process that the server is running in.
  337. */
  338. void (*rewrite_args) (process_rec *process);
  339. /** Function to allow all modules to create per directory configuration
  340. * structures.
  341. * @param p The pool to use for all allocations.
  342. * @param dir The directory currently being processed.
  343. * @return The per-directory structure created
  344. */
  345. void *(*create_dir_config) (apr_pool_t *p, char *dir);
  346. /** Function to allow all modules to merge the per directory configuration
  347. * structures for two directories.
  348. * @param p The pool to use for all allocations.
  349. * @param base_conf The directory structure created for the parent directory.
  350. * @param new_conf The directory structure currently being processed.
  351. * @return The new per-directory structure created
  352. */
  353. void *(*merge_dir_config) (apr_pool_t *p, void *base_conf, void *new_conf);
  354. /** Function to allow all modules to create per server configuration
  355. * structures.
  356. * @param p The pool to use for all allocations.
  357. * @param s The server currently being processed.
  358. * @return The per-server structure created
  359. */
  360. void *(*create_server_config) (apr_pool_t *p, server_rec *s);
  361. /** Function to allow all modules to merge the per server configuration
  362. * structures for two servers.
  363. * @param p The pool to use for all allocations.
  364. * @param base_conf The directory structure created for the parent directory.
  365. * @param new_conf The directory structure currently being processed.
  366. * @return The new per-directory structure created
  367. */
  368. void *(*merge_server_config) (apr_pool_t *p, void *base_conf,
  369. void *new_conf);
  370. /** A command_rec table that describes all of the directives this module
  371. * defines. */
  372. const command_rec *cmds;
  373. /** A hook to allow modules to hook other points in the request processing.
  374. * In this function, modules should call the ap_hook_*() functions to
  375. * register an interest in a specific step in processing the current
  376. * request.
  377. * @param p the pool to use for all allocations
  378. */
  379. void (*register_hooks) (apr_pool_t *p);
  380. /** A bitmask of AP_MODULE_FLAG_* */
  381. int flags;
  382. };
  383. /**
  384. * The AP_MAYBE_UNUSED macro is used for variable declarations that
  385. * might potentially exhibit "unused var" warnings on some compilers if
  386. * left untreated.
  387. * Since static intializers are not part of the C language (C89), making
  388. * (void) usage is not possible. However many compiler have proprietary
  389. * mechanism to suppress those warnings.
  390. */
  391. #ifdef AP_MAYBE_UNUSED
  392. #elif defined(__GNUC__)
  393. # define AP_MAYBE_UNUSED(x) x __attribute__((unused))
  394. #elif defined(__LCLINT__)
  395. # define AP_MAYBE_UNUSED(x) /*@unused@*/ x
  396. #else
  397. # define AP_MAYBE_UNUSED(x) x
  398. #endif
  399. /**
  400. * The APLOG_USE_MODULE macro is used choose which module a file belongs to.
  401. * This is necessary to allow per-module loglevel configuration.
  402. *
  403. * APLOG_USE_MODULE indirectly sets APLOG_MODULE_INDEX and APLOG_MARK.
  404. *
  405. * If a module should be backward compatible with versions before 2.3.6,
  406. * APLOG_USE_MODULE needs to be enclosed in a ifdef APLOG_USE_MODULE block.
  407. *
  408. * @param foo name of the module symbol of the current module, without the
  409. * trailing "_module" part
  410. * @see APLOG_MARK
  411. */
  412. #define APLOG_USE_MODULE(foo) \
  413. extern module AP_MODULE_DECLARE_DATA foo##_module; \
  414. AP_MAYBE_UNUSED(static int * const aplog_module_index) = &(foo##_module.module_index)
  415. /**
  416. * AP_DECLARE_MODULE is a convenience macro that combines a call of
  417. * APLOG_USE_MODULE with the definition of the module symbol.
  418. *
  419. * If a module should be backward compatible with versions before 2.3.6,
  420. * APLOG_USE_MODULE should be used explicitly instead of AP_DECLARE_MODULE.
  421. */
  422. #define AP_DECLARE_MODULE(foo) \
  423. APLOG_USE_MODULE(foo); \
  424. module AP_MODULE_DECLARE_DATA foo##_module
  425. /**
  426. * @defgroup ModuleInit Module structure initializers
  427. *
  428. * Initializer for the first few module slots, which are only
  429. * really set up once we start running. Note that the first two slots
  430. * provide a version check; this should allow us to deal with changes to
  431. * the API. The major number should reflect changes to the API handler table
  432. * itself or removal of functionality. The minor number should reflect
  433. * additions of functionality to the existing API. (the server can detect
  434. * an old-format module, and either handle it back-compatibly, or at least
  435. * signal an error). See src/include/ap_mmn.h for MMN version history.
  436. * @{
  437. */
  438. /** The one used in Apache 1.3, which will deliberately cause an error */
  439. #define STANDARD_MODULE_STUFF this_module_needs_to_be_ported_to_apache_2_0
  440. /** Use this in all standard modules */
  441. #define STANDARD20_MODULE_STUFF MODULE_MAGIC_NUMBER_MAJOR, \
  442. MODULE_MAGIC_NUMBER_MINOR, \
  443. -1, \
  444. __FILE__, \
  445. NULL, \
  446. NULL, \
  447. MODULE_MAGIC_COOKIE, \
  448. NULL /* rewrite args spot */
  449. /** Use this only in MPMs */
  450. #define MPM20_MODULE_STUFF MODULE_MAGIC_NUMBER_MAJOR, \
  451. MODULE_MAGIC_NUMBER_MINOR, \
  452. -1, \
  453. __FILE__, \
  454. NULL, \
  455. NULL, \
  456. MODULE_MAGIC_COOKIE
  457. /** @} */
  458. /* CONFIGURATION VECTOR FUNCTIONS */
  459. /** configuration vector structure */
  460. typedef struct ap_conf_vector_t ap_conf_vector_t;
  461. /**
  462. * Generic accessors for other modules to get at their own module-specific
  463. * data
  464. * @param cv The vector in which the modules configuration is stored.
  465. * usually r->per_dir_config or s->module_config
  466. * @param m The module to get the data for.
  467. * @return The module-specific data
  468. */
  469. AP_DECLARE(void *) ap_get_module_config(const ap_conf_vector_t *cv,
  470. const module *m);
  471. /**
  472. * Generic accessors for other modules to set their own module-specific
  473. * data
  474. * @param cv The vector in which the modules configuration is stored.
  475. * usually r->per_dir_config or s->module_config
  476. * @param m The module to set the data for.
  477. * @param val The module-specific data to set
  478. */
  479. AP_DECLARE(void) ap_set_module_config(ap_conf_vector_t *cv, const module *m,
  480. void *val);
  481. /**
  482. * When module flags have been introduced, and a way to check this.
  483. */
  484. #define AP_MODULE_FLAGS_MMN_MAJOR 20120211
  485. #define AP_MODULE_FLAGS_MMN_MINOR 70
  486. #define AP_MODULE_HAS_FLAGS(m) \
  487. AP_MODULE_MAGIC_AT_LEAST(AP_MODULE_FLAGS_MMN_MAJOR, \
  488. AP_MODULE_FLAGS_MMN_MINOR)
  489. /**
  490. * Generic accessor for the module's flags
  491. * @param m The module to get the flags from.
  492. * @return The module-specific flags
  493. */
  494. AP_DECLARE(int) ap_get_module_flags(const module *m);
  495. #if !defined(AP_DEBUG)
  496. #define ap_get_module_config(v,m) \
  497. (((void **)(v))[(m)->module_index])
  498. #define ap_set_module_config(v,m,val) \
  499. ((((void **)(v))[(m)->module_index]) = (val))
  500. #endif /* AP_DEBUG */
  501. /**
  502. * Generic accessor for modules to get the module-specific loglevel
  503. * @param s The server from which to get the loglevel.
  504. * @param index The module_index of the module to get the loglevel for.
  505. * @return The module-specific loglevel
  506. */
  507. AP_DECLARE(int) ap_get_server_module_loglevel(const server_rec *s, int index);
  508. /**
  509. * Generic accessor for modules the module-specific loglevel
  510. * @param c The connection from which to get the loglevel.
  511. * @param index The module_index of the module to get the loglevel for.
  512. * @return The module-specific loglevel
  513. */
  514. AP_DECLARE(int) ap_get_conn_module_loglevel(const conn_rec *c, int index);
  515. /**
  516. * Generic accessor for modules the module-specific loglevel
  517. * @param c The connection from which to get the loglevel.
  518. * @param s The server from which to get the loglevel if c does not have a
  519. * specific loglevel configuration.
  520. * @param index The module_index of the module to get the loglevel for.
  521. * @return The module-specific loglevel
  522. */
  523. AP_DECLARE(int) ap_get_conn_server_module_loglevel(const conn_rec *c,
  524. const server_rec *s,
  525. int index);
  526. /**
  527. * Generic accessor for modules to get the module-specific loglevel
  528. * @param r The request from which to get the loglevel.
  529. * @param index The module_index of the module to get the loglevel for.
  530. * @return The module-specific loglevel
  531. */
  532. AP_DECLARE(int) ap_get_request_module_loglevel(const request_rec *r, int index);
  533. /**
  534. * Accessor to set module-specific loglevel
  535. * @param p A pool
  536. * @param l The ap_logconf struct to modify.
  537. * @param index The module_index of the module to set the loglevel for.
  538. * @param level The new log level
  539. */
  540. AP_DECLARE(void) ap_set_module_loglevel(apr_pool_t *p, struct ap_logconf *l,
  541. int index, int level);
  542. #if !defined(AP_DEBUG)
  543. #define ap_get_conn_logconf(c) \
  544. ((c)->log ? (c)->log : \
  545. &(c)->base_server->log)
  546. #define ap_get_conn_server_logconf(c,s) \
  547. ( ( (c)->log != &(c)->base_server->log && (c)->log != NULL ) ? \
  548. (c)->log : \
  549. &(s)->log )
  550. #define ap_get_request_logconf(r) \
  551. ((r)->log ? (r)->log : \
  552. (r)->connection->log ? (r)->connection->log : \
  553. &(r)->server->log)
  554. #define ap_get_module_loglevel(l,i) \
  555. (((i) < 0 || (l)->module_levels == NULL || (l)->module_levels[i] < 0) ? \
  556. (l)->level : \
  557. (l)->module_levels[i])
  558. #define ap_get_server_module_loglevel(s,i) \
  559. (ap_get_module_loglevel(&(s)->log,i))
  560. #define ap_get_conn_module_loglevel(c,i) \
  561. (ap_get_module_loglevel(ap_get_conn_logconf(c),i))
  562. #define ap_get_conn_server_module_loglevel(c,s,i) \
  563. (ap_get_module_loglevel(ap_get_conn_server_logconf(c,s),i))
  564. #define ap_get_request_module_loglevel(r,i) \
  565. (ap_get_module_loglevel(ap_get_request_logconf(r),i))
  566. #endif /* AP_DEBUG */
  567. /**
  568. * Set all module-specific loglevels to val
  569. * @param l The log config for which to set the loglevels.
  570. * @param val the value to set all loglevels to
  571. */
  572. AP_DECLARE(void) ap_reset_module_loglevels(struct ap_logconf *l, int val);
  573. /**
  574. * Generic command handling function for strings
  575. * @param cmd The command parameters for this directive
  576. * @param struct_ptr pointer into a given type
  577. * @param arg The argument to the directive
  578. * @return An error string or NULL on success
  579. */
  580. AP_DECLARE_NONSTD(const char *) ap_set_string_slot(cmd_parms *cmd,
  581. void *struct_ptr,
  582. const char *arg);
  583. /**
  584. * Generic command handling function for integers
  585. * @param cmd The command parameters for this directive
  586. * @param struct_ptr pointer into a given type
  587. * @param arg The argument to the directive
  588. * @return An error string or NULL on success
  589. */
  590. AP_DECLARE_NONSTD(const char *) ap_set_int_slot(cmd_parms *cmd,
  591. void *struct_ptr,
  592. const char *arg);
  593. /**
  594. * Parsing function for log level
  595. * @param str The string to parse
  596. * @param val The parsed log level
  597. * @return An error string or NULL on success
  598. */
  599. AP_DECLARE(const char *) ap_parse_log_level(const char *str, int *val);
  600. /**
  601. * Return true if the specified method is limited by being listed in
  602. * a &lt;Limit&gt; container, or by *not* being listed in a &lt;LimitExcept&gt;
  603. * container.
  604. *
  605. * @param method Pointer to a string specifying the method to check.
  606. * @param cmd Pointer to the cmd_parms structure passed to the
  607. * directive handler.
  608. * @return 0 if the method is not limited in the current scope
  609. */
  610. AP_DECLARE(int) ap_method_is_limited(cmd_parms *cmd, const char *method);
  611. /**
  612. * Generic command handling function for strings, always sets the value
  613. * to a lowercase string
  614. * @param cmd The command parameters for this directive
  615. * @param struct_ptr pointer into a given type
  616. * @param arg The argument to the directive
  617. * @return An error string or NULL on success
  618. */
  619. AP_DECLARE_NONSTD(const char *) ap_set_string_slot_lower(cmd_parms *cmd,
  620. void *struct_ptr,
  621. const char *arg);
  622. /**
  623. * Generic command handling function for flags stored in an int
  624. * @param cmd The command parameters for this directive
  625. * @param struct_ptr pointer into a given type
  626. * @param arg The argument to the directive (either 1 or 0)
  627. * @return An error string or NULL on success
  628. */
  629. AP_DECLARE_NONSTD(const char *) ap_set_flag_slot(cmd_parms *cmd,
  630. void *struct_ptr,
  631. int arg);
  632. /**
  633. * Generic command handling function for flags stored in a char
  634. * @param cmd The command parameters for this directive
  635. * @param struct_ptr pointer into a given type
  636. * @param arg The argument to the directive (either 1 or 0)
  637. * @return An error string or NULL on success
  638. */
  639. AP_DECLARE_NONSTD(const char *) ap_set_flag_slot_char(cmd_parms *cmd,
  640. void *struct_ptr,
  641. int arg);
  642. /**
  643. * Generic command handling function for files
  644. * @param cmd The command parameters for this directive
  645. * @param struct_ptr pointer into a given type
  646. * @param arg The argument to the directive
  647. * @return An error string or NULL on success
  648. */
  649. AP_DECLARE_NONSTD(const char *) ap_set_file_slot(cmd_parms *cmd,
  650. void *struct_ptr,
  651. const char *arg);
  652. /**
  653. * Generic command handling function to respond with cmd->help as an error
  654. * @param cmd The command parameters for this directive
  655. * @param struct_ptr pointer into a given type
  656. * @param arg The argument to the directive
  657. * @return The cmd->help value as the error string
  658. * @note This allows simple declarations such as:
  659. * @code
  660. * AP_INIT_RAW_ARGS("Foo", ap_set_deprecated, NULL, OR_ALL,
  661. * "The Foo directive is no longer supported, use Bar"),
  662. * @endcode
  663. */
  664. AP_DECLARE_NONSTD(const char *) ap_set_deprecated(cmd_parms *cmd,
  665. void *struct_ptr,
  666. const char *arg);
  667. /**
  668. * For modules which need to read config files, open logs, etc. this returns
  669. * the canonical form of fname made absolute to ap_server_root.
  670. * @param p pool to allocate data from
  671. * @param fname The file name
  672. */
  673. AP_DECLARE(char *) ap_server_root_relative(apr_pool_t *p, const char *fname);
  674. /**
  675. * Compute the name of a run-time file (e.g., shared memory "file") relative
  676. * to the appropriate run-time directory. Absolute paths are returned as-is.
  677. * The run-time directory is configured via the DefaultRuntimeDir directive or
  678. * at build time.
  679. */
  680. AP_DECLARE(char *) ap_runtime_dir_relative(apr_pool_t *p, const char *fname);
  681. /* Finally, the hook for dynamically loading modules in... */
  682. /**
  683. * Add a module to the server
  684. * @param m The module structure of the module to add
  685. * @param p The pool of the same lifetime as the module
  686. * @param s The module's symbol name (used for logging)
  687. */
  688. AP_DECLARE(const char *) ap_add_module(module *m, apr_pool_t *p,
  689. const char *s);
  690. /**
  691. * Remove a module from the server. There are some caveats:
  692. * when the module is removed, its slot is lost so all the current
  693. * per-dir and per-server configurations are invalid. So we should
  694. * only ever call this function when you are invalidating almost
  695. * all our current data. I.e. when doing a restart.
  696. * @param m the module structure of the module to remove
  697. */
  698. AP_DECLARE(void) ap_remove_module(module *m);
  699. /**
  700. * Add a module to the chained modules list and the list of loaded modules
  701. * @param mod The module structure of the module to add
  702. * @param p The pool with the same lifetime as the module
  703. * @param s The module's symbol name (used for logging)
  704. */
  705. AP_DECLARE(const char *) ap_add_loaded_module(module *mod, apr_pool_t *p,
  706. const char *s);
  707. /**
  708. * Remove a module fromthe chained modules list and the list of loaded modules
  709. * @param mod the module structure of the module to remove
  710. */
  711. AP_DECLARE(void) ap_remove_loaded_module(module *mod);
  712. /**
  713. * Find the name of the specified module
  714. * @param m The module to get the name for
  715. * @return the name of the module
  716. */
  717. AP_DECLARE(const char *) ap_find_module_name(module *m);
  718. /**
  719. * Find the short name of the module identified by the specified module index
  720. * @param module_index The module index to get the name for
  721. * @return the name of the module, NULL if not found
  722. */
  723. AP_DECLARE(const char *) ap_find_module_short_name(int module_index);
  724. /**
  725. * Find a module based on the name of the module
  726. * @param name the name of the module
  727. * @return the module structure if found, NULL otherwise
  728. */
  729. AP_DECLARE(module *) ap_find_linked_module(const char *name);
  730. /**
  731. * Open a ap_configfile_t as apr_file_t
  732. * @param ret_cfg open ap_configfile_t struct pointer
  733. * @param p The pool to allocate the structure from
  734. * @param name the name of the file to open
  735. */
  736. AP_DECLARE(apr_status_t) ap_pcfg_openfile(ap_configfile_t **ret_cfg,
  737. apr_pool_t *p, const char *name);
  738. /**
  739. * Allocate a ap_configfile_t handle with user defined functions and params
  740. * @param p The pool to allocate from
  741. * @param descr The name of the file
  742. * @param param The argument passed to getch/getstr/close
  743. * @param getc_func The getch function
  744. * @param gets_func The getstr function
  745. * @param close_func The close function
  746. */
  747. AP_DECLARE(ap_configfile_t *) ap_pcfg_open_custom(apr_pool_t *p,
  748. const char *descr,
  749. void *param,
  750. apr_status_t (*getc_func) (char *ch, void *param),
  751. apr_status_t (*gets_func) (void *buf, apr_size_t bufsiz, void *param),
  752. apr_status_t (*close_func) (void *param));
  753. /**
  754. * Read one line from open ap_configfile_t, strip leading and trailing
  755. * whitespace, increase line number
  756. * @param buf place to store the line read
  757. * @param bufsize size of the buffer
  758. * @param cfp File to read from
  759. * @return error status, APR_ENOSPC if bufsize is too small for the line
  760. */
  761. AP_DECLARE(apr_status_t) ap_cfg_getline(char *buf, apr_size_t bufsize, ap_configfile_t *cfp);
  762. /**
  763. * Read one char from open configfile_t, increase line number upon LF
  764. * @param ch place to store the char read
  765. * @param cfp The file to read from
  766. * @return error status
  767. */
  768. AP_DECLARE(apr_status_t) ap_cfg_getc(char *ch, ap_configfile_t *cfp);
  769. /**
  770. * Detach from open ap_configfile_t, calling the close handler
  771. * @param cfp The file to close
  772. * @return 1 on success, 0 on failure
  773. */
  774. AP_DECLARE(int) ap_cfg_closefile(ap_configfile_t *cfp);
  775. /**
  776. * Convert a return value from ap_cfg_getline or ap_cfg_getc to a user friendly
  777. * string.
  778. * @param p The pool to allocate the string from
  779. * @param cfp The config file
  780. * @param rc The return value to convert
  781. * @return The error string, NULL if rc == APR_SUCCESS
  782. */
  783. AP_DECLARE(const char *) ap_pcfg_strerror(apr_pool_t *p, ap_configfile_t *cfp,
  784. apr_status_t rc);
  785. /**
  786. * Read all data between the current &lt;foo&gt; and the matching &lt;/foo&gt;. All
  787. * of this data is forgotten immediately.
  788. * @param cmd The cmd_parms to pass to the directives inside the container
  789. * @param directive The directive name to read until
  790. * @return Error string on failure, NULL on success
  791. * @note If cmd->pool == cmd->temp_pool, ap_soak_end_container() will assume
  792. * .htaccess context and use a lower maximum line length.
  793. */
  794. AP_DECLARE(const char *) ap_soak_end_container(cmd_parms *cmd, char *directive);
  795. /**
  796. * Read all data between the current &lt;foo&gt; and the matching &lt;/foo&gt; and build
  797. * a config tree from it
  798. * @param p pool to allocate from
  799. * @param temp_pool Temporary pool to allocate from
  800. * @param parms The cmd_parms to pass to all directives read
  801. * @param current The current node in the tree
  802. * @param curr_parent The current parent node
  803. * @param orig_directive The directive to read until hit.
  804. * @return Error string on failure, NULL on success
  805. * @note If p == temp_pool, ap_build_cont_config() will assume .htaccess
  806. * context and use a lower maximum line length.
  807. */
  808. AP_DECLARE(const char *) ap_build_cont_config(apr_pool_t *p,
  809. apr_pool_t *temp_pool,
  810. cmd_parms *parms,
  811. ap_directive_t **current,
  812. ap_directive_t **curr_parent,
  813. char *orig_directive);
  814. /**
  815. * Build a config tree from a config file
  816. * @param parms The cmd_parms to pass to all of the directives in the file
  817. * @param conf_pool The pconf pool
  818. * @param temp_pool The temporary pool
  819. * @param conftree Place to store the root node of the config tree
  820. * @return Error string on erro, NULL otherwise
  821. * @note If conf_pool == temp_pool, ap_build_config() will assume .htaccess
  822. * context and use a lower maximum line length.
  823. */
  824. AP_DECLARE(const char *) ap_build_config(cmd_parms *parms,
  825. apr_pool_t *conf_pool,
  826. apr_pool_t *temp_pool,
  827. ap_directive_t **conftree);
  828. /**
  829. * Walk a config tree and setup the server's internal structures
  830. * @param conftree The config tree to walk
  831. * @param parms The cmd_parms to pass to all functions
  832. * @param section_vector The per-section config vector.
  833. * @return Error string on error, NULL otherwise
  834. */
  835. AP_DECLARE(const char *) ap_walk_config(ap_directive_t *conftree,
  836. cmd_parms *parms,
  837. ap_conf_vector_t *section_vector);
  838. /**
  839. * Convenience function to create a ap_dir_match_t structure from a cmd_parms.
  840. *
  841. * @param cmd The command.
  842. * @param flags Flags to indicate whether optional or recursive.
  843. * @param cb Callback for each file found that matches the wildcard. Return NULL on
  844. * success, an error string on error.
  845. * @param ctx Context for the callback.
  846. * @return Structure ap_dir_match_t with fields populated, allocated from the
  847. * cmd->temp_pool.
  848. */
  849. AP_DECLARE(ap_dir_match_t *)ap_dir_cfgmatch(cmd_parms *cmd, int flags,
  850. const char *(*cb)(ap_dir_match_t *w, const char *fname), void *ctx)
  851. __attribute__((nonnull(1,3)));
  852. /**
  853. * @defgroup ap_check_cmd_context Check command context
  854. * @{
  855. */
  856. /**
  857. * Check the context a command is used in.
  858. * @param cmd The command to check
  859. * @param forbidden Where the command is forbidden.
  860. * @return Error string on error, NULL on success
  861. */
  862. AP_DECLARE(const char *) ap_check_cmd_context(cmd_parms *cmd,
  863. unsigned forbidden);
  864. #define NOT_IN_VIRTUALHOST 0x01 /**< Forbidden in &lt;VirtualHost&gt; */
  865. #define NOT_IN_LIMIT 0x02 /**< Forbidden in &lt;Limit&gt; */
  866. #define NOT_IN_DIRECTORY 0x04 /**< Forbidden in &lt;Directory&gt; */
  867. #define NOT_IN_LOCATION 0x08 /**< Forbidden in &lt;Location&gt; */
  868. #define NOT_IN_FILES 0x10 /**< Forbidden in &lt;Files&gt; or &lt;If&gt;*/
  869. #define NOT_IN_HTACCESS 0x20 /**< Forbidden in .htaccess files */
  870. #define NOT_IN_PROXY 0x40 /**< Forbidden in &lt;Proxy&gt; */
  871. /** Forbidden in &lt;Directory&gt;/&lt;Location&gt;/&lt;Files&gt;&lt;If&gt;*/
  872. #define NOT_IN_DIR_LOC_FILE (NOT_IN_DIRECTORY|NOT_IN_LOCATION|NOT_IN_FILES)
  873. /** Forbidden in &lt;Directory&gt;/&lt;Location&gt;/&lt;Files&gt;&lt;If&gt;&lt;Proxy&gt;*/
  874. #define NOT_IN_DIR_CONTEXT (NOT_IN_LIMIT|NOT_IN_DIR_LOC_FILE|NOT_IN_PROXY)
  875. /** Forbidden in &lt;VirtualHost&gt;/&lt;Limit&gt;/&lt;Directory&gt;/&lt;Location&gt;/&lt;Files&gt;/&lt;If&gt;&lt;Proxy&gt;*/
  876. #define GLOBAL_ONLY (NOT_IN_VIRTUALHOST|NOT_IN_DIR_CONTEXT)
  877. /** @} */
  878. /**
  879. * @brief This structure is used to assign symbol names to module pointers
  880. */
  881. typedef struct {
  882. const char *name;
  883. module *modp;
  884. } ap_module_symbol_t;
  885. /**
  886. * The topmost module in the list
  887. * @var module *ap_top_module
  888. */
  889. AP_DECLARE_DATA extern module *ap_top_module;
  890. /**
  891. * Array of all statically linked modules
  892. * @var module *ap_prelinked_modules[]
  893. */
  894. AP_DECLARE_DATA extern module *ap_prelinked_modules[];
  895. /**
  896. * Array of all statically linked modulenames (symbols)
  897. * @var ap_module_symbol_t ap_prelinked_module_symbols[]
  898. */
  899. AP_DECLARE_DATA extern ap_module_symbol_t ap_prelinked_module_symbols[];
  900. /**
  901. * Array of all preloaded modules
  902. * @var module *ap_preloaded_modules[]
  903. */
  904. AP_DECLARE_DATA extern module *ap_preloaded_modules[];
  905. /**
  906. * Array of all loaded modules
  907. * @var module **ap_loaded_modules
  908. */
  909. AP_DECLARE_DATA extern module **ap_loaded_modules;
  910. /* For mod_so.c... */
  911. /** Run a single module's two create_config hooks
  912. * @param p the pool to allocate from
  913. * @param s The server to configure for.
  914. * @param m The module to configure
  915. */
  916. AP_DECLARE(void) ap_single_module_configure(apr_pool_t *p, server_rec *s,
  917. module *m);
  918. /* For http_main.c... */
  919. /**
  920. * Add all of the prelinked modules into the loaded module list
  921. * @param process The process that is currently running the server
  922. */
  923. AP_DECLARE(const char *) ap_setup_prelinked_modules(process_rec *process);
  924. /**
  925. * Show the preloaded configuration directives, the help string explaining
  926. * the directive arguments, in what module they are handled, and in
  927. * what parts of the configuration they are allowed. Used for httpd -h.
  928. */
  929. AP_DECLARE(void) ap_show_directives(void);
  930. /**
  931. * Returns non-zero if a configuration directive of the given name has
  932. * been registered by a module at the time of calling.
  933. * @param p Pool for temporary allocations
  934. * @param name Directive name
  935. */
  936. AP_DECLARE(int) ap_exists_directive(apr_pool_t *p, const char *name);
  937. /**
  938. * Show the preloaded module names. Used for httpd -l.
  939. */
  940. AP_DECLARE(void) ap_show_modules(void);
  941. /**
  942. * Show the MPM name. Used in reporting modules such as mod_info to
  943. * provide extra information to the user
  944. */
  945. AP_DECLARE(const char *) ap_show_mpm(void);
  946. /**
  947. * Read all config files and setup the server
  948. * @param process The process running the server
  949. * @param temp_pool A pool to allocate temporary data from.
  950. * @param config_name The name of the config file
  951. * @param conftree Place to store the root of the config tree
  952. * @return The setup server_rec list.
  953. */
  954. AP_DECLARE(server_rec *) ap_read_config(process_rec *process,
  955. apr_pool_t *temp_pool,
  956. const char *config_name,
  957. ap_directive_t **conftree);
  958. /**
  959. * Run all rewrite args hooks for loaded modules
  960. * @param process The process currently running the server
  961. */
  962. AP_DECLARE(void) ap_run_rewrite_args(process_rec *process);
  963. /**
  964. * Run the register hooks function for a specified module
  965. * @param m The module to run the register hooks function fo
  966. * @param p The pool valid for the lifetime of the module
  967. */
  968. AP_DECLARE(void) ap_register_hooks(module *m, apr_pool_t *p);
  969. /**
  970. * Setup all virtual hosts
  971. * @param p The pool to allocate from
  972. * @param main_server The head of the server_rec list
  973. */
  974. AP_DECLARE(void) ap_fixup_virtual_hosts(apr_pool_t *p,
  975. server_rec *main_server);
  976. /**
  977. * Reserve some modules slots for modules loaded by other means than
  978. * EXEC_ON_READ directives.
  979. * Relevant modules should call this in the pre_config stage.
  980. * @param count The number of slots to reserve.
  981. */
  982. AP_DECLARE(void) ap_reserve_module_slots(int count);
  983. /**
  984. * Reserve some modules slots for modules loaded by a specific
  985. * non-EXEC_ON_READ config directive.
  986. * This counts how often the given directive is used in the config and calls
  987. * ap_reserve_module_slots() accordingly.
  988. * @param directive The name of the directive
  989. */
  990. AP_DECLARE(void) ap_reserve_module_slots_directive(const char *directive);
  991. /* For http_request.c... */
  992. /**
  993. * Setup the config vector for a request_rec
  994. * @param p The pool to allocate the config vector from
  995. * @return The config vector
  996. */
  997. AP_DECLARE(ap_conf_vector_t*) ap_create_request_config(apr_pool_t *p);
  998. /**
  999. * Setup the config vector for per dir module configs
  1000. * @param p The pool to allocate the config vector from
  1001. * @return The config vector
  1002. */
  1003. AP_CORE_DECLARE(ap_conf_vector_t *) ap_create_per_dir_config(apr_pool_t *p);
  1004. /**
  1005. * Run all of the modules merge per dir config functions
  1006. * @param p The pool to pass to the merge functions
  1007. * @param base The base directory config structure
  1008. * @param new_conf The new directory config structure
  1009. */
  1010. AP_CORE_DECLARE(ap_conf_vector_t*) ap_merge_per_dir_configs(apr_pool_t *p,
  1011. ap_conf_vector_t *base,
  1012. ap_conf_vector_t *new_conf);
  1013. /**
  1014. * Allocate new ap_logconf and make (deep) copy of old ap_logconf
  1015. * @param p The pool to alloc from
  1016. * @param old The ap_logconf to copy (may be NULL)
  1017. * @return The new ap_logconf struct
  1018. */
  1019. AP_DECLARE(struct ap_logconf *) ap_new_log_config(apr_pool_t *p,
  1020. const struct ap_logconf *old);
  1021. /**
  1022. * Merge old ap_logconf into new ap_logconf.
  1023. * old and new must have the same life time.
  1024. * @param old_conf The ap_logconf to merge from
  1025. * @param new_conf The ap_logconf to merge into
  1026. */
  1027. AP_DECLARE(void) ap_merge_log_config(const struct ap_logconf *old_conf,
  1028. struct ap_logconf *new_conf);
  1029. /* For http_connection.c... */
  1030. /**
  1031. * Setup the config vector for a connection_rec
  1032. * @param p The pool to allocate the config vector from
  1033. * @return The config vector
  1034. */
  1035. AP_CORE_DECLARE(ap_conf_vector_t*) ap_create_conn_config(apr_pool_t *p);
  1036. /* For http_core.c... (&lt;Directory&gt; command and virtual hosts) */
  1037. /**
  1038. * parse an htaccess file
  1039. * @param result htaccess_result
  1040. * @param r The request currently being served
  1041. * @param override Which overrides are active
  1042. * @param override_opts Which allow-override-opts bits are set
  1043. * @param override_list Table of directives allowed for override
  1044. * @param path The path to the htaccess file
  1045. * @param access_name The list of possible names for .htaccess files
  1046. * int The status of the current request
  1047. */
  1048. AP_CORE_DECLARE(int) ap_parse_htaccess(ap_conf_vector_t **result,
  1049. request_rec *r,
  1050. int override,
  1051. int override_opts,
  1052. apr_table_t *override_list,
  1053. const char *path,
  1054. const char *access_name);
  1055. /**
  1056. * Setup a virtual host
  1057. * @param p The pool to allocate all memory from
  1058. * @param hostname The hostname of the virtual hsot
  1059. * @param main_server The main server for this Apache configuration
  1060. * @param ps Place to store the new server_rec
  1061. * return Error string on error, NULL on success
  1062. */
  1063. AP_CORE_DECLARE(const char *) ap_init_virtual_host(apr_pool_t *p,
  1064. const char *hostname,
  1065. server_rec *main_server,
  1066. server_rec **ps);
  1067. /**
  1068. * Process a config file for Apache
  1069. * @param s The server rec to use for the command parms
  1070. * @param fname The name of the config file
  1071. * @param conftree The root node of the created config tree
  1072. * @param p Pool for general allocation
  1073. * @param ptemp Pool for temporary allocation
  1074. */
  1075. AP_DECLARE(const char *) ap_process_resource_config(server_rec *s,
  1076. const char *fname,
  1077. ap_directive_t **conftree,
  1078. apr_pool_t *p,
  1079. apr_pool_t *ptemp);
  1080. /**
  1081. * Process all matching files as Apache configs
  1082. * @param s The server rec to use for the command parms
  1083. * @param fname The filename pattern of the config file
  1084. * @param conftree The root node of the created config tree
  1085. * @param p Pool for general allocation
  1086. * @param ptemp Pool for temporary allocation
  1087. * @param optional Whether a no-match wildcard is allowed
  1088. * @see apr_fnmatch for pattern handling
  1089. */
  1090. AP_DECLARE(const char *) ap_process_fnmatch_configs(server_rec *s,
  1091. const char *fname,
  1092. ap_directive_t **conftree,
  1093. apr_pool_t *p,
  1094. apr_pool_t *ptemp,
  1095. int optional);
  1096. /**
  1097. * Process all directives in the config tree
  1098. * @param s The server rec to use in the command parms
  1099. * @param conftree The config tree to process
  1100. * @param p The pool for general allocation
  1101. * @param ptemp The pool for temporary allocations
  1102. * @return OK if no problems
  1103. */
  1104. AP_DECLARE(int) ap_process_config_tree(server_rec *s,
  1105. ap_directive_t *conftree,
  1106. apr_pool_t *p,
  1107. apr_pool_t *ptemp);
  1108. /**
  1109. * Store data which will be retained across unload/load of modules
  1110. * @param key The unique key associated with this module's retained data
  1111. * @param size in bytes of the retained data (to be allocated)
  1112. * @return Address of new retained data structure, initially cleared
  1113. */
  1114. AP_DECLARE(void *) ap_retained_data_create(const char *key, apr_size_t size);
  1115. /**
  1116. * Retrieve data which was stored by ap_retained_data_create()
  1117. * @param key The unique key associated with this module's retained data
  1118. * @return Address of previously retained data structure, or NULL if not yet saved
  1119. */
  1120. AP_DECLARE(void *) ap_retained_data_get(const char *key);
  1121. /* Module-method dispatchers, also for http_request.c */
  1122. /**
  1123. * Run the handler phase of each module until a module accepts the
  1124. * responsibility of serving the request
  1125. * @param r The current request
  1126. * @return The status of the current request
  1127. */
  1128. AP_CORE_DECLARE(int) ap_invoke_handler(request_rec *r);
  1129. /* for mod_perl */
  1130. /**
  1131. * Find a given directive in a command_rec table
  1132. * @param name The directive to search for
  1133. * @param cmds The table to search
  1134. * @return The directive definition of the specified directive
  1135. */
  1136. AP_CORE_DECLARE(const command_rec *) ap_find_command(const char *name,
  1137. const command_rec *cmds);
  1138. /**
  1139. * Find a given directive in a list of modules.
  1140. * @param cmd_name The directive to search for
  1141. * @param mod Pointer to the first module in the linked list; will be set to
  1142. * the module providing cmd_name
  1143. * @return The directive definition of the specified directive.
  1144. * *mod will be changed to point to the module containing the
  1145. * directive.
  1146. */
  1147. AP_CORE_DECLARE(const command_rec *) ap_find_command_in_modules(const char *cmd_name,
  1148. module **mod);
  1149. /**
  1150. * Ask a module to create per-server and per-section (dir/loc/file) configs
  1151. * (if it hasn't happened already). The results are stored in the server's
  1152. * config, and the specified per-section config vector.
  1153. * @param server The server to operate upon.
  1154. * @param section_vector The per-section config vector.
  1155. * @param section Which section to create a config for.
  1156. * @param mod The module which is defining the config data.
  1157. * @param pconf A pool for all configuration allocations.
  1158. * @return The (new) per-section config data.
  1159. */
  1160. AP_CORE_DECLARE(void *) ap_set_config_vectors(server_rec *server,
  1161. ap_conf_vector_t *section_vector,
  1162. const char *section,
  1163. module *mod, apr_pool_t *pconf);
  1164. /* Hooks */
  1165. /**
  1166. * Run the header parser functions for each module
  1167. * @param r The current request
  1168. * @return OK or DECLINED
  1169. */
  1170. AP_DECLARE_HOOK(int,header_parser,(request_rec *r))
  1171. /**
  1172. * Run the pre_config function for each module
  1173. * @param pconf The config pool
  1174. * @param plog The logging streams pool
  1175. * @param ptemp The temporary pool
  1176. * @return OK or DECLINED on success anything else is a error
  1177. */
  1178. AP_DECLARE_HOOK(int,pre_config,(apr_pool_t *pconf,apr_pool_t *plog,
  1179. apr_pool_t *ptemp))
  1180. /**
  1181. * Run the check_config function for each module
  1182. * @param pconf The config pool
  1183. * @param plog The logging streams pool
  1184. * @param ptemp The temporary pool
  1185. * @param s the server to operate upon
  1186. * @return OK or DECLINED on success anything else is a error
  1187. */
  1188. AP_DECLARE_HOOK(int,check_config,(apr_pool_t *pconf, apr_pool_t *plog,
  1189. apr_pool_t *ptemp, server_rec *s))
  1190. /**
  1191. * Run the test_config function for each module; this hook is run
  1192. * only if the server was invoked to test the configuration syntax.
  1193. * @param pconf The config pool
  1194. * @param s The list of server_recs
  1195. * @note To avoid reordering problems due to different buffering, hook
  1196. * functions should only apr_file_*() to print to stdout/stderr and
  1197. * not simple printf()/fprintf().
  1198. *
  1199. */
  1200. AP_DECLARE_HOOK(void,test_config,(apr_pool_t *pconf, server_rec *s))
  1201. /**
  1202. * Run the post_config function for each module
  1203. * @param pconf The config pool
  1204. * @param plog The logging streams pool
  1205. * @param ptemp The temporary pool
  1206. * @param s The list of server_recs
  1207. * @return OK or DECLINED on success anything else is a error
  1208. */
  1209. AP_DECLARE_HOOK(int,post_config,(apr_pool_t *pconf,apr_pool_t *plog,
  1210. apr_pool_t *ptemp,server_rec *s))
  1211. /**
  1212. * Run the open_logs functions for each module
  1213. * @param pconf The config pool
  1214. * @param plog The logging streams pool
  1215. * @param ptemp The temporary pool
  1216. * @param s The list of server_recs
  1217. * @return OK or DECLINED on success anything else is a error
  1218. */
  1219. AP_DECLARE_HOOK(int,open_logs,(apr_pool_t *pconf,apr_pool_t *plog,
  1220. apr_pool_t *ptemp,server_rec *s))
  1221. /**
  1222. * Run the child_init functions for each module
  1223. * @param pchild The child pool
  1224. * @param s The list of server_recs in this server
  1225. */
  1226. AP_DECLARE_HOOK(void,child_init,(apr_pool_t *pchild, server_rec *s))
  1227. /**
  1228. * Run the handler functions for each module
  1229. * @param r The request_rec
  1230. * @remark non-wildcard handlers should HOOK_MIDDLE, wildcard HOOK_LAST
  1231. */
  1232. AP_DECLARE_HOOK(int,handler,(request_rec *r))
  1233. /**
  1234. * Run the quick handler functions for each module. The quick_handler
  1235. * is run before any other requests hooks are called (location_walk,
  1236. * directory_walk, access checking, et. al.). This hook was added
  1237. * to provide a quick way to serve content from a URI keyed cache.
  1238. *
  1239. * @param r The request_rec
  1240. * @param lookup_uri Controls whether the caller actually wants content or not.
  1241. * lookup is set when the quick_handler is called out of
  1242. * ap_sub_req_lookup_uri()
  1243. */
  1244. AP_DECLARE_HOOK(int,quick_handler,(request_rec *r, int lookup_uri))
  1245. /**
  1246. * Retrieve the optional functions for each module.
  1247. * This is run immediately before the server starts. Optional functions should
  1248. * be registered during the hook registration phase.
  1249. */
  1250. AP_DECLARE_HOOK(void,optional_fn_retrieve,(void))
  1251. /**
  1252. * Allow modules to open htaccess files or perform operations before doing so
  1253. * @param r The current request
  1254. * @param dir_name The directory for which the htaccess file should be opened
  1255. * @param access_name The filename for which the htaccess file should be opened
  1256. * @param conffile Where the pointer to the opened ap_configfile_t must be
  1257. * stored
  1258. * @param full_name Where the full file name of the htaccess file must be
  1259. * stored.
  1260. * @return APR_SUCCESS on success,
  1261. * APR_ENOENT or APR_ENOTDIR if no htaccess file exists,
  1262. * AP_DECLINED to let later modules do the opening,
  1263. * any other error code on error.
  1264. */
  1265. AP_DECLARE_HOOK(apr_status_t,open_htaccess,
  1266. (request_rec *r, const char *dir_name, const char *access_name,
  1267. ap_configfile_t **conffile, const char **full_name))
  1268. /**
  1269. * Core internal function, use ap_run_open_htaccess() instead.
  1270. */
  1271. apr_status_t ap_open_htaccess(request_rec *r, const char *dir_name,
  1272. const char *access_name, ap_configfile_t **conffile,
  1273. const char **full_name);
  1274. /**
  1275. * A generic pool cleanup that will reset a pointer to NULL. For use with
  1276. * apr_pool_cleanup_register.
  1277. * @param data The address of the pointer
  1278. * @return APR_SUCCESS
  1279. */
  1280. AP_DECLARE_NONSTD(apr_status_t) ap_pool_cleanup_set_null(void *data);
  1281. #ifdef __cplusplus
  1282. }
  1283. #endif
  1284. #endif /* !APACHE_HTTP_CONFIG_H */
  1285. /** @} */