github.com/krum110487/go-htaccess@v0.0.0-20240316004156-60641c8e7598/tests/data/apache_2_4_58/include/http_config.h (about)

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