📄 mod_rewrite.h
字号:
#define MAPFILE_PATTERN "^([^ \t]+)[ \t]+([^ \t]+).*$"#define MAPFILE_OUTPUT "$1,$2"/***** our private data structures we handle with***/ /* the list structures for holding the mapfile information * and the rewrite rules */typedef struct { char *name; /* the name of the map */ char *datafile; /* filename for map data files */ char *checkfile; /* filename to check for map existence */ int type; /* the type of the map */ int fpin; /* in file pointer for program maps */ int fpout; /* out file pointer for program maps */ int fperr; /* err file pointer for program maps */ char *(*func)(request_rec *, /* function pointer for internal maps */ char *);} rewritemap_entry;typedef struct { char *input; /* Input string of RewriteCond */ char *pattern; /* the RegExp pattern string */ regex_t *regexp; int flags; /* Flags which control the match */} rewritecond_entry;typedef struct { array_header *rewriteconds; /* the corresponding RewriteCond entries */ char *pattern; /* the RegExp pattern string */ regex_t *regexp; /* the RegExp pattern compilation */ char *output; /* the Substitution string */ int flags; /* Flags which control the substitution */ char *forced_mimetype; /* forced MIME type of substitution */ int forced_responsecode; /* forced HTTP redirect response status */ char *env[MAX_ENV_FLAGS+1]; /* added environment variables */ int skip; /* number of next rules to skip */} rewriterule_entry; /* the per-server or per-virtual-server configuration * statically generated once on startup for every server */typedef struct { int state; /* the RewriteEngine state */ int options; /* the RewriteOption state */ char *rewritelogfile; /* the RewriteLog filename */ int rewritelogfp; /* the RewriteLog open filepointer */ int rewriteloglevel; /* the RewriteLog level of verbosity */ char *rewritelockfile; /* the RewriteLock filename */ int rewritelockfp; /* the RewriteLock open filepointer */ array_header *rewritemaps; /* the RewriteMap entries */ array_header *rewriteconds; /* the RewriteCond entries (temporary) */ array_header *rewriterules; /* the RewriteRule entries */ server_rec *server; /* the corresponding server indicator */} rewrite_server_conf; /* the per-directory configuration * generated on-the-fly by Apache server for current request */typedef struct { int state; /* the RewriteEngine state */ int options; /* the RewriteOption state */ array_header *rewriteconds; /* the RewriteCond entries (temporary) */ array_header *rewriterules; /* the RewriteRule entries */ char *directory; /* the directory where it applies */ char *baseurl; /* the base-URL where it applies */} rewrite_perdir_conf; /* the cache structures */typedef struct cacheentry { time_t time; char *key; char *value;} cacheentry;typedef struct cachelist { char *resource; array_header *entries;} cachelist;typedef struct cache { pool *pool; array_header *lists;} cache; /* the regex structure for the substitution of backreferences */typedef struct backrefinfo { char *source; int nsub; regmatch_t regmatch[10];} backrefinfo;/***** forward declarations***/ /* config structure handling */static void *config_server_create(pool *p, server_rec *s);static void *config_server_merge (pool *p, void *basev, void *overridesv);static void *config_perdir_create(pool *p, char *path);static void *config_perdir_merge (pool *p, void *basev, void *overridesv); /* config directive handling */static const char *cmd_rewriteengine(cmd_parms *cmd, rewrite_perdir_conf *dconf, int flag);static const char *cmd_rewriteoptions(cmd_parms *cmd, rewrite_perdir_conf *dconf, char *option);static const char *cmd_rewriteoptions_setoption(pool *p, int *options, char *name);static const char *cmd_rewritelog (cmd_parms *cmd, void *dconf, char *a1);static const char *cmd_rewriteloglevel(cmd_parms *cmd, void *dconf, char *a1);static const char *cmd_rewritemap (cmd_parms *cmd, void *dconf, char *a1, char *a2);static const char *cmd_rewritelock(cmd_parms *cmd, void *dconf, char *a1);static const char *cmd_rewritebase(cmd_parms *cmd, rewrite_perdir_conf *dconf, char *a1);static const char *cmd_rewritecond(cmd_parms *cmd, rewrite_perdir_conf *dconf, char *str);static const char *cmd_rewritecond_parseflagfield(pool *p, rewritecond_entry *new, char *str);static const char *cmd_rewritecond_setflag(pool *p, rewritecond_entry *cfg, char *key, char *val);static const char *cmd_rewriterule(cmd_parms *cmd, rewrite_perdir_conf *dconf, char *str);static const char *cmd_rewriterule_parseflagfield(pool *p, rewriterule_entry *new, char *str);static const char *cmd_rewriterule_setflag(pool *p, rewriterule_entry *cfg, char *key, char *val); /* initialisation */static void init_module(server_rec *s, pool *p);static void init_child(server_rec *s, pool *p); /* runtime hooks */static int hook_uri2file (request_rec *r);static int hook_mimetype (request_rec *r);static int hook_fixup (request_rec *r);static int handler_redirect(request_rec *r); /* rewriting engine */static int apply_rewrite_list(request_rec *r, array_header *rewriterules, char *perdir);static int apply_rewrite_rule(request_rec *r, rewriterule_entry *p, char *perdir);static int apply_rewrite_cond(request_rec *r, rewritecond_entry *p, char *perdir, backrefinfo *briRR, backrefinfo *briRC); /* URI transformation function */static void splitout_queryargs(request_rec *r, int qsappend);static void fully_qualify_uri(request_rec *r);static void reduce_uri(request_rec *r);static void expand_backref_inbuffer(pool *p, char *buf, int nbuf, backrefinfo *bri, char c);static char *expand_tildepaths(request_rec *r, char *uri);static void expand_map_lookups(request_rec *r, char *uri, int uri_len); /* rewrite map support functions */static char *lookup_map(request_rec *r, char *name, char *key);static char *lookup_map_txtfile(request_rec *r, char *file, char *key);#ifndef NO_DBM_REWRITEMAPstatic char *lookup_map_dbmfile(request_rec *r, char *file, char *key);#endifstatic char *lookup_map_program(request_rec *r, int fpin, int fpout, char *key);static char *lookup_map_internal(request_rec *r, char *(*func)(request_rec *r, char *key), char *key);static char *rewrite_mapfunc_toupper(request_rec *r, char *key);static char *rewrite_mapfunc_tolower(request_rec *r, char *key);static char *select_random_value_part(request_rec *r, char *value);static void rewrite_rand_init(void);static int rewrite_rand(int l, int h); /* rewriting logfile support */static void open_rewritelog(server_rec *s, pool *p);static void rewritelog(request_rec *r, int level, const char *text, ...) __attribute__((format(printf,3,4)));static char *current_logtime(request_rec *r); /* rewriting lockfile support */static void rewritelock_create(server_rec *s, pool *p);static void rewritelock_open(server_rec *s, pool *p);static void rewritelock_remove(void *data);static void rewritelock_alloc(request_rec *r);static void rewritelock_free(request_rec *r); /* program map support */static void run_rewritemap_programs(server_rec *s, pool *p);static int rewritemap_program_child(void *cmd, child_info *pinfo); /* env variable support */static void expand_variables_inbuffer(request_rec *r, char *buf, int buf_len);static char *expand_variables(request_rec *r, char *str);static char *lookup_variable(request_rec *r, char *var);static char *lookup_header(request_rec *r, const char *name); /* caching functions */static cache *init_cache(pool *p);static char *get_cache_string(cache *c, char *res, int mode, time_t mtime, char *key);static void set_cache_string(cache *c, char *res, int mode, time_t mtime, char *key, char *value);static cacheentry *retrieve_cache_string(cache *c, char *res, char *key);static void store_cache_string(cache *c, char *res, cacheentry *ce); /* misc functions */static char *subst_prefix_path(request_rec *r, char *input, char *match, char *subst);static int parseargline(char *str, char **a1, char **a2, char **a3);static int prefix_stat(const char *path, struct stat *sb);static void add_env_variable(request_rec *r, char *s); /* File locking */static void fd_lock(request_rec *r, int fd);static void fd_unlock(request_rec *r, int fd); /* Lexicographic Comparison */static int compare_lexicography(char *cpNum1, char *cpNum2);#endif /* _MOD_REWRITE_H *//*EOF*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -