diff options
Diffstat (limited to 'APACHE_1_3_42/src/include')
32 files changed, 6573 insertions, 0 deletions
diff --git a/APACHE_1_3_42/src/include/.indent.pro b/APACHE_1_3_42/src/include/.indent.pro new file mode 100644 index 0000000000..a9fbe9f9a1 --- /dev/null +++ b/APACHE_1_3_42/src/include/.indent.pro @@ -0,0 +1,54 @@ +-i4 -npsl -di0 -br -nce -d0 -cli0 -npcs -nfc1 +-TBUFF +-TFILE +-TTRANS +-TUINT4 +-T_trans +-Tallow_options_t +-Tapache_sfio +-Tarray_header +-Tbool_int +-Tbuf_area +-Tbuff_struct +-Tbuffy +-Tcmd_how +-Tcmd_parms +-Tcommand_rec +-Tcommand_struct +-Tconn_rec +-Tcore_dir_config +-Tcore_server_config +-Tdir_maker_func +-Tevent +-Tglobals_s +-Thandler_func +-Thandler_rec +-Tjoblist_s +-Tlisten_rec +-Tmerger_func +-Tmode_t +-Tmodule +-Tmodule_struct +-Tmutex +-Tn_long +-Tother_child_rec +-Toverrides_t +-Tparent_score +-Tpid_t +-Tpiped_log +-Tpool +-Trequest_rec +-Trequire_line +-Trlim_t +-Tscoreboard +-Tsemaphore +-Tserver_addr_rec +-Tserver_rec +-Tserver_rec_chain +-Tshort_score +-Ttable +-Ttable_entry +-Tthread +-Tu_wide_int +-Tvtime_t +-Twide_int diff --git a/APACHE_1_3_42/src/include/ap.h b/APACHE_1_3_42/src/include/ap.h new file mode 100644 index 0000000000..f29f4b445e --- /dev/null +++ b/APACHE_1_3_42/src/include/ap.h @@ -0,0 +1,160 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * The ap_vsnprintf/ap_snprintf functions are based on, and used with the + * permission of, the SIO stdio-replacement strx_* functions by Panos + * Tsirigotis <panos@alumni.cs.colorado.edu> for xinetd. + */ + +#ifndef APACHE_AP_H +#define APACHE_AP_H + +#ifdef __cplusplus +extern "C" { +#endif + +API_EXPORT(char *) ap_cpystrn(char *, const char *, size_t); +int ap_slack(int, int); +int ap_execle(const char *, const char *, ...); +int ap_execve(const char *, char * const argv[], char * const envp[]); +API_EXPORT(int) ap_getpass(const char *prompt, char *pwbuf, size_t bufsiz); + +#ifndef ap_strtol +API_EXPORT(long) ap_strtol(const char *nptr, char **endptr, int base); +#endif + +/* small utility macros to make things easier to read */ + +#ifdef WIN32 +#define ap_killpg(x, y) +#else +#ifdef NO_KILLPG +#define ap_killpg(x, y) (kill (-(x), (y))) +#else +#define ap_killpg(x, y) (killpg ((x), (y))) +#endif +#endif /* WIN32 */ + +/* ap_vformatter() is a generic printf-style formatting routine + * with some extensions. The extensions are: + * + * %pA takes a struct in_addr *, and prints it as a.b.c.d + * %pI takes a struct sockaddr_in * and prints it as a.b.c.d:port + * %pp takes a void * and outputs it in hex + * + * The %p hacks are to force gcc's printf warning code to skip + * over a pointer argument without complaining. This does + * mean that the ANSI-style %p (output a void * in hex format) won't + * work as expected at all, but that seems to be a fair trade-off + * for the increased robustness of having printf-warnings work. + * + * Additionally, ap_vformatter allows for arbitrary output methods + * using the ap_vformatter_buff and flush_func. + * + * The ap_vformatter_buff has two elements curpos and endpos. + * curpos is where ap_vformatter will write the next byte of output. + * It proceeds writing output to curpos, and updating curpos, until + * either the end of output is reached, or curpos == endpos (i.e. the + * buffer is full). + * + * If the end of output is reached, ap_vformatter returns the + * number of bytes written. + * + * When the buffer is full, the flush_func is called. The flush_func + * can return -1 to indicate that no further output should be attempted, + * and ap_vformatter will return immediately with -1. Otherwise + * the flush_func should flush the buffer in whatever manner is + * appropriate, re-initialize curpos and endpos, and return 0. + * + * Note that flush_func is only invoked as a result of attempting to + * write another byte at curpos when curpos >= endpos. So for + * example, it's possible when the output exactly matches the buffer + * space available that curpos == endpos will be true when + * ap_vformatter returns. + * + * ap_vformatter does not call out to any other code, it is entirely + * self-contained. This allows the callers to do things which are + * otherwise "unsafe". For example, ap_psprintf uses the "scratch" + * space at the unallocated end of a block, and doesn't actually + * complete the allocation until ap_vformatter returns. ap_psprintf + * would be completely broken if ap_vformatter were to call anything + * that used a pool. Similarly http_bprintf() uses the "scratch" + * space at the end of its output buffer, and doesn't actually note + * that the space is in use until it either has to flush the buffer + * or until ap_vformatter returns. + */ + +typedef struct { + char *curpos; + char *endpos; +} ap_vformatter_buff; + +API_EXPORT(int) ap_vformatter(int (*flush_func)(ap_vformatter_buff *), + ap_vformatter_buff *, const char *fmt, va_list ap); + +/* These are snprintf implementations based on ap_vformatter(). + * + * Note that various standards and implementations disagree on the return + * value of snprintf, and side-effects due to %n in the formatting string. + * ap_snprintf behaves as follows: + * + * Process the format string until the entire string is exhausted, or + * the buffer fills. If the buffer fills then stop processing immediately + * (so no further %n arguments are processed), and return the buffer + * length. In all cases the buffer is NUL terminated. The return value + * is the number of characters placed in the buffer, excluding the + * terminating NUL. All this implies that, at most, (len-1) characters + * will be copied over; if the return value is >= len, then truncation + * occured. + * + * In no event does ap_snprintf return a negative number. + */ +API_EXPORT_NONSTD(int) ap_snprintf(char *buf, size_t len, const char *format,...) + __attribute__((format(printf,3,4))); +API_EXPORT(int) ap_vsnprintf(char *buf, size_t len, const char *format, + va_list ap); +/* Simple BASE64 encode/decode functions. + * + * As we might encode binary strings, hence we require the length of + * the incoming plain source. And return the length of what we decoded. + * + * The decoding function takes any non valid char (i.e. whitespace, \0 + * or anything non A-Z,0-9 etc as terminal. + * + * plain strings/binary sequences are not assumed '\0' terminated. Encoded + * strings are neither. But propably should. + * + */ +API_EXPORT(int) ap_base64encode_len(int len); +API_EXPORT(int) ap_base64encode(char * coded_dst, const char *plain_src,int len_plain_src); +API_EXPORT(int) ap_base64encode_binary(char * coded_dst, const unsigned char *plain_src,int len_plain_src); + +API_EXPORT(int) ap_base64decode_len(const char * coded_src); +API_EXPORT(int) ap_base64decode(char * plain_dst, const char *coded_src); +API_EXPORT(int) ap_base64decode_binary(unsigned char * plain_dst, const char *coded_src); + +/* Password validation, as used in AuthType Basic which is able to cope + * (based on the prefix) with the SHA1, Apache's internal MD5 and (depending + * on your platform either plain or crypt(3) passwords. + */ +API_EXPORT(char *) ap_validate_password(const char *passwd, const char *hash); + +#ifdef __cplusplus +} +#endif + +#endif /* !APACHE_AP_H */ diff --git a/APACHE_1_3_42/src/include/ap_alloc.h b/APACHE_1_3_42/src/include/ap_alloc.h new file mode 100644 index 0000000000..2db5077c5f --- /dev/null +++ b/APACHE_1_3_42/src/include/ap_alloc.h @@ -0,0 +1,375 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef APACHE_ALLOC_H +#define APACHE_ALLOC_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Resource allocation routines... + * + * designed so that we don't have to keep track of EVERYTHING so that + * it can be explicitly freed later (a fundamentally unsound strategy --- + * particularly in the presence of die()). + * + * Instead, we maintain pools, and allocate items (both memory and I/O + * handlers) from the pools --- currently there are two, one for per + * transaction info, and one for config info. When a transaction is over, + * we can delete everything in the per-transaction pool without fear, and + * without thinking too hard about it either. + * + * rst + */ + +/* Arenas for configuration info and transaction info + * --- actual layout of the pool structure is private to + * alloc.c. + */ + + /* Need declaration of DIR on Win32 */ +#ifdef WIN32 +#include "readdir.h" +#endif + +typedef struct pool pool; +typedef struct pool ap_pool; + +API_EXPORT(pool *) ap_init_alloc(void); /* Set up everything */ +void ap_cleanup_alloc(void); +API_EXPORT(pool *) ap_make_sub_pool(pool *); /* All pools are subpools of permanent_pool */ +API_EXPORT(void) ap_destroy_pool(pool *); + +/* pools have nested lifetimes -- sub_pools are destroyed when the + * parent pool is cleared. We allow certain liberties with operations + * on things such as tables (and on other structures in a more general + * sense) where we allow the caller to insert values into a table which + * were not allocated from the table's pool. The table's data will + * remain valid as long as all the pools from which its values are + * allocated remain valid. + * + * For example, if B is a sub pool of A, and you build a table T in + * pool B, then it's safe to insert data allocated in A or B into T + * (because B lives at most as long as A does, and T is destroyed when + * B is cleared/destroyed). On the other hand, if S is a table in + * pool A, it is safe to insert data allocated in A into S, but it + * is *not safe* to insert data allocated from B into S... because + * B can be cleared/destroyed before A is (which would leave dangling + * pointers in T's data structures). + * + * In general we say that it is safe to insert data into a table T + * if the data is allocated in any ancestor of T's pool. This is the + * basis on which the POOL_DEBUG code works -- it tests these ancestor + * relationships for all data inserted into tables. POOL_DEBUG also + * provides tools (ap_find_pool, and ap_pool_is_ancestor) for other + * folks to implement similar restrictions for their own data + * structures. + * + * However, sometimes this ancestor requirement is inconvenient -- + * sometimes we're forced to create a sub pool (such as through + * ap_sub_req_lookup_uri), and the sub pool is guaranteed to have + * the same lifetime as the parent pool. This is a guarantee implemented + * by the *caller*, not by the pool code. That is, the caller guarantees + * they won't destroy the sub pool individually prior to destroying the + * parent pool. + * + * In this case the caller must call ap_pool_join() to indicate this + * guarantee to the POOL_DEBUG code. There are a few examples spread + * through the standard modules. + */ +#ifndef POOL_DEBUG +#ifdef ap_pool_join +#undef ap_pool_join +#endif +#define ap_pool_join(a,b) +#else +API_EXPORT(void) ap_pool_join(pool *p, pool *sub); +API_EXPORT(pool *) ap_find_pool(const void *ts); +API_EXPORT(int) ap_pool_is_ancestor(pool *a, pool *b); +#endif + +/* Clearing out EVERYTHING in an pool... destroys any sub-pools */ + +API_EXPORT(void) ap_clear_pool(struct pool *); + +/* Preparing for exec() --- close files, etc., but *don't* flush I/O + * buffers, *don't* wait for subprocesses, and *don't* free any memory. + */ + +API_EXPORT(void) ap_cleanup_for_exec(void); + +/* routines to allocate memory from an pool... */ + +API_EXPORT(void *) ap_palloc(struct pool *, int nbytes); +API_EXPORT(void *) ap_pcalloc(struct pool *, int nbytes); +API_EXPORT(char *) ap_pstrdup(struct pool *, const char *s); +/* make a nul terminated copy of the n characters starting with s */ +API_EXPORT(char *) ap_pstrndup(struct pool *, const char *s, int n); +API_EXPORT_NONSTD(char *) ap_pstrcat(struct pool *,...); /* all '...' must be char* */ +API_EXPORT_NONSTD(char *) ap_psprintf(struct pool *, const char *fmt, ...) + __attribute__((format(printf,2,3))); +API_EXPORT(char *) ap_pvsprintf(struct pool *, const char *fmt, va_list); + +/* array and alist management... keeping lists of things. + * Common enough to want common support code ... + */ + +typedef struct { + ap_pool *pool; + int elt_size; + int nelts; + int nalloc; + char *elts; +} array_header; + +API_EXPORT(array_header *) ap_make_array(pool *p, int nelts, int elt_size); +API_EXPORT(void *) ap_push_array(array_header *); +API_EXPORT(void) ap_array_cat(array_header *dst, const array_header *src); +API_EXPORT(array_header *) ap_append_arrays(pool *, const array_header *, + const array_header *); + +/* ap_array_pstrcat generates a new string from the pool containing + * the concatenated sequence of substrings referenced as elements within + * the array. The string will be empty if all substrings are empty or null, + * or if there are no elements in the array. + * If sep is non-NUL, it will be inserted between elements as a separator. + */ +API_EXPORT(char *) ap_array_pstrcat(pool *p, const array_header *arr, + const char sep); + +/* copy_array copies the *entire* array. copy_array_hdr just copies + * the header, and arranges for the elements to be copied if (and only + * if) the code subsequently does a push or arraycat. + */ + +API_EXPORT(array_header *) ap_copy_array(pool *p, const array_header *src); +API_EXPORT(array_header *) ap_copy_array_hdr(pool *p, const array_header *src); + + +/* Tables. Implemented alist style, for now, though we try to keep + * it so that imposing a hash table structure on top in the future + * wouldn't be *too* hard... + * + * Note that key comparisons for these are case-insensitive, largely + * because that's what's appropriate and convenient everywhere they're + * currently being used... + */ + +typedef struct table table; + +typedef struct { + char *key; /* maybe NULL in future; + * check when iterating thru table_elts + */ + char *val; +} table_entry; + +API_EXPORT(table *) ap_make_table(pool *p, int nelts); +API_EXPORT(table *) ap_copy_table(pool *p, const table *); +API_EXPORT(void) ap_clear_table(table *); +API_EXPORT(const char *) ap_table_get(const table *, const char *); +API_EXPORT(void) ap_table_set(table *, const char *name, const char *val); +API_EXPORT(void) ap_table_setn(table *, const char *name, const char *val); +API_EXPORT(void) ap_table_merge(table *, const char *name, const char *more_val); +API_EXPORT(void) ap_table_mergen(table *, const char *name, const char *more_val); +API_EXPORT(void) ap_table_unset(table *, const char *key); +API_EXPORT(void) ap_table_add(table *, const char *name, const char *val); +API_EXPORT(void) ap_table_addn(table *, const char *name, const char *val); +API_EXPORT_NONSTD(void) ap_table_do(int (*comp) (void *, const char *, const char *), + void *rec, const table *t,...); + +API_EXPORT(table *) ap_overlay_tables(pool *p, const table *overlay, const table *base); + +/* Conceptually, ap_overlap_tables does this: + + array_header *barr = ap_table_elts(b); + table_entry *belt = (table_entry *)barr->elts; + int i; + + for (i = 0; i < barr->nelts; ++i) { + if (flags & AP_OVERLAP_TABLES_MERGE) { + ap_table_mergen(a, belt[i].key, belt[i].val); + } + else { + ap_table_setn(a, belt[i].key, belt[i].val); + } + } + + Except that it is more efficient (less space and cpu-time) especially + when b has many elements. + + Notice the assumptions on the keys and values in b -- they must be + in an ancestor of a's pool. In practice b and a are usually from + the same pool. +*/ +#define AP_OVERLAP_TABLES_SET (0) +#define AP_OVERLAP_TABLES_MERGE (1) +API_EXPORT(void) ap_overlap_tables(table *a, const table *b, unsigned flags); + +/* XXX: these know about the definition of struct table in alloc.c. That + * definition is not here because it is supposed to be private, and by not + * placing it here we are able to get compile-time diagnostics from modules + * written which assume that a table is the same as an array_header. -djg + */ +#define ap_table_elts(t) ((array_header *)(t)) +#define ap_is_empty_table(t) (((t) == NULL)||(((array_header *)(t))->nelts == 0)) + +/* routines to remember allocation of other sorts of things... + * generic interface first. Note that we want to have two separate + * cleanup functions in the general case, one for exec() preparation, + * to keep CGI scripts and the like from inheriting access to things + * they shouldn't be able to touch, and one for actually cleaning up, + * when the actual server process wants to get rid of the thing, + * whatever it is. + * + * kill_cleanup disarms a cleanup, presumably because the resource in + * question has been closed, freed, or whatever, and it's scarce + * enough to want to reclaim (e.g., descriptors). It arranges for the + * resource not to be cleaned up a second time (it might have been + * reallocated). run_cleanup does the same, but runs it first. + * + * Cleanups are identified for purposes of finding & running them off by the + * plain_cleanup and data, which should presumably be unique. + * + * NB any code which invokes register_cleanup or kill_cleanup directly + * is a critical section which should be guarded by block_alarms() and + * unblock_alarms() below... + * + * ap_register_cleanup_ex provided to allow for an optional "cleanup" + * to be run at call-time for things like setting CLOSEXEC flags + * on fd's or whatever else may make sense. + */ + +API_EXPORT(void) ap_register_cleanup(pool *p, void *data, + void (*plain_cleanup) (void *), + void (*child_cleanup) (void *)); +API_EXPORT(void) ap_register_cleanup_ex(pool *p, void *data, + void (*plain_cleanup) (void *), + void (*child_cleanup) (void *), + int (*magic_cleanup) (void *)); + +API_EXPORT(void) ap_kill_cleanup(pool *p, void *data, void (*plain_cleanup) (void *)); +API_EXPORT(void) ap_run_cleanup(pool *p, void *data, void (*cleanup) (void *)); + +/* A "do-nothing" cleanup, for register_cleanup; it's faster to do + * things this way than to test for NULL. */ +API_EXPORT_NONSTD(void) ap_null_cleanup(void *data); + +/* The time between when a resource is actually allocated, and when it + * its cleanup is registered is a critical section, during which the + * resource could leak if we got interrupted or timed out. So, anything + * which registers cleanups should bracket resource allocation and the + * cleanup registry with these. (This is done internally by run_cleanup). + * + * NB they are actually implemented in http_main.c, since they are bound + * up with timeout handling in general... + */ + +API_EXPORT(void) ap_block_alarms(void); +API_EXPORT(void) ap_unblock_alarms(void); + +/* Common cases which want utility support.. + * the note_cleanups_for_foo routines are for + */ + +API_EXPORT(FILE *) ap_pfopen(struct pool *, const char *name, const char *fmode); +API_EXPORT(FILE *) ap_pfdopen(struct pool *, int fd, const char *fmode); +API_EXPORT(int) ap_popenf(struct pool *, const char *name, int flg, int mode); +API_EXPORT(int) ap_popenf_ex(struct pool *, const char *name, int flg, + int mode, int domagic); + +API_EXPORT(void) ap_note_cleanups_for_file(pool *, FILE *); +API_EXPORT(void) ap_note_cleanups_for_file_ex(pool *, FILE *, int); +API_EXPORT(void) ap_note_cleanups_for_fd(pool *, int); +API_EXPORT(void) ap_note_cleanups_for_fd_ex(pool *, int, int); +#ifdef WIN32 +API_EXPORT(void) ap_note_cleanups_for_h(pool *, HANDLE); +#endif +API_EXPORT(void) ap_kill_cleanups_for_fd(pool *p, int fd); + +API_EXPORT(void) ap_note_cleanups_for_socket(pool *, int); +API_EXPORT(void) ap_note_cleanups_for_socket_ex(pool *, int, int); +API_EXPORT(void) ap_kill_cleanups_for_socket(pool *p, int sock); +API_EXPORT(int) ap_psocket(pool *p, int, int, int); +API_EXPORT(int) ap_psocket_ex(pool *p, int, int, int, int); +API_EXPORT(int) ap_pclosesocket(pool *a, int sock); + +API_EXPORT(regex_t *) ap_pregcomp(pool *p, const char *pattern, int cflags); +API_EXPORT(void) ap_pregfree(pool *p, regex_t * reg); + +/* routines to note closes... file descriptors are constrained enough + * on some systems that we want to support this. + */ + +API_EXPORT(int) ap_pfclose(struct pool *, FILE *); +API_EXPORT(int) ap_pclosef(struct pool *, int fd); +#ifdef WIN32 +API_EXPORT(int) ap_pcloseh(struct pool *, HANDLE hDevice); +#endif + +/* routines to deal with directories */ +API_EXPORT(DIR *) ap_popendir(pool *p, const char *name); +API_EXPORT(void) ap_pclosedir(pool *p, DIR * d); + +/* ... even child processes (which we may want to wait for, + * or to kill outright, on unexpected termination). + * + * ap_spawn_child is a utility routine which handles an awful lot of + * the rigamarole associated with spawning a child --- it arranges + * for pipes to the child's stdin and stdout, if desired (if not, + * set the associated args to NULL). It takes as args a function + * to call in the child, and an argument to be passed to the function. + */ + +enum kill_conditions { + kill_never, /* process is never sent any signals */ + kill_always, /* process is sent SIGKILL on pool cleanup */ + kill_after_timeout, /* SIGTERM, wait 3 seconds, SIGKILL */ + just_wait, /* wait forever for the process to complete */ + kill_only_once /* send SIGTERM and then wait */ +}; + +typedef struct child_info child_info; +API_EXPORT(void) ap_note_subprocess(pool *a, pid_t pid, + enum kill_conditions how); +API_EXPORT(int) ap_spawn_child(pool *, int (*)(void *, child_info *), + void *, enum kill_conditions, + FILE **pipe_in, FILE **pipe_out, + FILE **pipe_err); +int ap_close_fd_on_exec(int fd); + +/* magic numbers --- min free bytes to consider a free pool block useable, + * and the min amount to allocate if we have to go to malloc() */ + +#ifndef BLOCK_MINFREE +#define BLOCK_MINFREE 4096 +#endif +#ifndef BLOCK_MINALLOC +#define BLOCK_MINALLOC 8192 +#endif + +/* Finally, some accounting */ + +API_EXPORT(long) ap_bytes_in_pool(pool *p); +API_EXPORT(long) ap_bytes_in_free_blocks(void); + +#ifdef __cplusplus +} +#endif + +#endif /* !APACHE_ALLOC_H */ diff --git a/APACHE_1_3_42/src/include/ap_compat.h b/APACHE_1_3_42/src/include/ap_compat.h new file mode 100644 index 0000000000..fca04fdaf4 --- /dev/null +++ b/APACHE_1_3_42/src/include/ap_compat.h @@ -0,0 +1,444 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* +** ap_compat.h -- Apache Backward Compatibility +** +** INCLUDE THIS HEADER FILE ONLY IF YOU REALLY NEED +** BACKWARD COMPATIBILITY TO OLD APACHE RESOURCES. +*/ + +#ifndef AP_COMPAT_H +#define AP_COMPAT_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Mapping of Apache 1.2 global symbols to the + * namespace conflict free variants used in Apache 1.3 + */ + +#define MD5Final ap_MD5Final +#define MD5Init ap_MD5Init +#define MD5Update ap_MD5Update +#define acquire_mutex ap_acquire_mutex +#define add_cgi_vars ap_add_cgi_vars +#define add_common_vars ap_add_common_vars +#define add_file_conf ap_add_file_conf +#define add_module ap_add_module +#define add_named_module ap_add_named_module +#define add_per_dir_conf ap_add_per_dir_conf +#define add_per_url_conf ap_add_per_url_conf +#define allow_options ap_allow_options +#define allow_overrides ap_allow_overrides +#define apapi_get_server_built ap_get_server_built +#define apapi_get_server_version ap_get_server_version +#define aplog_error ap_log_error +#define append_arrays ap_append_arrays +#define array_cat ap_array_cat +#define auth_name ap_auth_name +#define auth_type ap_auth_type +#define basic_http_header ap_basic_http_header +#define bclose ap_bclose +#define bcreate ap_bcreate +#define bfilbuf ap_bfilbuf +#define bfileno ap_bfileno +#define bflsbuf ap_bflsbuf +#define bflush ap_bflush +#define bgetc ap_bgetc +#define bgetflag ap_bgetflag +#define bgetopt ap_bgetopt +#define bgets ap_bgets +#define bhalfduplex ap_bhalfduplex +#define bind_address ap_bind_address +#define block_alarms ap_block_alarms +#define blookc ap_blookc +#define bnonblock ap_bnonblock +#define bonerror ap_bonerror +#define bprintf ap_bprintf +#define bpushfd ap_bpushfd +#define bputc ap_bputc +#define bputs ap_bputs +#define bread ap_bread +#define bsetflag ap_bsetflag +#define bsetopt ap_bsetopt +#define bskiplf ap_bskiplf +#define bvputs ap_bvputs +#define bwrite ap_bwrite +#define bytes_in_free_blocks ap_bytes_in_free_blocks +#define bytes_in_pool ap_bytes_in_pool +#define call_exec ap_call_exec +#define can_exec ap_can_exec +#define cfg_closefile ap_cfg_closefile +#define cfg_getc ap_cfg_getc +#define cfg_getline ap_cfg_getline +#define chdir_file ap_chdir_file +#define check_access ap_check_access +#define check_alarm ap_check_alarm +#define check_auth ap_check_auth +#define check_cmd_context ap_check_cmd_context +#define check_user_id ap_check_user_id +#define checkmask ap_checkmask +#define child_exit_modules ap_child_exit_modules +#define child_init_modules ap_child_init_modules +#define child_terminate ap_child_terminate +#define cleanup_for_exec ap_cleanup_for_exec +#define clear_module_list ap_clear_module_list +#define clear_pool ap_clear_pool +#define clear_table ap_clear_table +#define close_piped_log ap_close_piped_log +#define construct_server ap_construct_server +#define construct_url ap_construct_url +#define copy_array ap_copy_array +#define copy_array_hdr ap_copy_array_hdr +#define copy_table ap_copy_table +#define core_reorder_directories ap_core_reorder_directories +#define coredump_dir ap_coredump_dir +#define count_dirs ap_count_dirs +#define create_environment ap_create_environment +#define create_mutex ap_create_mutex +#define create_per_dir_config ap_create_per_dir_config +#define create_request_config ap_create_request_config +#define daemons_limit ap_daemons_limit +#define daemons_max_free ap_daemons_max_free +#define daemons_min_free ap_daemons_min_free +#define daemons_to_start ap_daemons_to_start +#define day_snames ap_day_snames +#define default_port ap_default_port +#define default_port_for_request ap_default_port_for_request +#define default_port_for_scheme ap_default_port_for_scheme +#define default_type ap_default_type +#define destroy_mutex ap_destroy_mutex +#define destroy_pool ap_destroy_pool +#define destroy_sub_req ap_destroy_sub_req +#define die ap_die +#define discard_request_body ap_discard_request_body +#define document_root ap_document_root +#define dummy_mutex ap_dummy_mutex +#define each_byterange ap_each_byterange +#define error_log2stderr ap_error_log2stderr +#define escape_html ap_escape_html +#define escape_path_segment ap_escape_path_segment +#define escape_shell_cmd ap_escape_shell_cmd +#define escape_uri ap_escape_uri +#define excess_requests_per_child ap_excess_requests_per_child +#define exists_scoreboard_image ap_exists_scoreboard_image +#define finalize_request_protocol ap_finalize_request_protocol +#define finalize_sub_req_protocol ap_finalize_sub_req_protocol +#define find_command ap_find_command +#define find_command_in_modules ap_find_command_in_modules +#define find_last_token ap_find_last_token +#define find_linked_module ap_find_linked_module +#define find_module_name ap_find_module_name +#define find_path_info ap_find_path_info +#define find_pool ap_find_pool +#define find_token ap_find_token +#define find_types ap_find_types +#define fini_vhost_config ap_fini_vhost_config +#define fnmatch ap_fnmatch +#define force_library_loading ap_force_library_loading +#define get_basic_auth_pw ap_get_basic_auth_pw +#define get_client_block ap_get_client_block +#define get_gmtoff ap_get_gmtoff +#define get_local_host ap_get_local_host +#define get_module_config ap_get_module_config +#define get_remote_host ap_get_remote_host +#define get_remote_logname ap_get_remote_logname +#define get_server_name ap_get_server_name +#define get_server_port ap_get_server_port +#define get_time ap_get_time +#define get_token ap_get_token +#define get_virthost_addr ap_get_virthost_addr +#define getparents ap_getparents +#define getword ap_getword +#define getword_conf ap_getword_conf +#define getword_conf_nc ap_getword_conf_nc +#define getword_nc ap_getword_nc +#define getword_nulls ap_getword_nulls +#define getword_nulls_nc ap_getword_nulls_nc +#define getword_white ap_getword_white +#define getword_white_nc ap_getword_white_nc +#define gm_timestr_822 ap_gm_timestr_822 +#define gname2id ap_gname2id +#define group_id ap_group_id +#define handle_command ap_handle_command +#define hard_timeout ap_hard_timeout +#define header_parse ap_header_parse +#define ht_time ap_ht_time +#define http_method ap_http_method +#define ind ap_ind +#define index_of_response ap_index_of_response +#define init_alloc ap_init_alloc +#define init_modules ap_init_modules +#define init_vhost_config ap_init_vhost_config +#define init_virtual_host ap_init_virtual_host +#define internal_redirect ap_internal_redirect +#define internal_redirect_handler ap_internal_redirect_handler +#define invoke_handler ap_invoke_handler +#define is_default_port ap_is_default_port +#define is_directory ap_is_directory +#define is_empty_table ap_is_empty_table +#define is_fnmatch ap_is_fnmatch +#define is_initial_req ap_is_initial_req +#define is_matchexp ap_is_matchexp +#define is_table_empty ap_is_table_empty +#define is_url ap_is_url +#define keepalive_timeout ap_keepalive_timeout +#define kill_cleanup ap_kill_cleanup +#define kill_cleanups_for_fd ap_kill_cleanups_for_fd +#define kill_cleanups_for_socket ap_kill_cleanups_for_socket +#define kill_timeout ap_kill_timeout +#define limit_section ap_limit_section +#define listenbacklog ap_listenbacklog +#define listeners ap_listeners +#define lock_fname ap_lock_fname +#define log_assert ap_log_assert +#define log_error ap_log_error_old +#define log_pid ap_log_pid +#define log_printf ap_log_printf +#define log_reason ap_log_reason +#define log_transaction ap_log_transaction +#define log_unixerr ap_log_unixerr +#define make_array ap_make_array +#define make_dirstr ap_make_dirstr +#define make_dirstr_parent ap_make_dirstr_parent +#define make_dirstr_prefix ap_make_dirstr_prefix +#define make_full_path ap_make_full_path +#define make_sub_pool ap_make_sub_pool +#define make_table ap_make_table +#define matches_request_vhost ap_matches_request_vhost +#define max_requests_per_child ap_max_requests_per_child +#define md5 ap_md5 +#define meets_conditions ap_meets_conditions +#define merge_per_dir_configs ap_merge_per_dir_configs +#define month_snames ap_month_snames +#define no2slash ap_no2slash +#define note_auth_failure ap_note_auth_failure +#define note_basic_auth_failure ap_note_basic_auth_failure +#define note_cleanups_for_fd ap_note_cleanups_for_fd +#define note_cleanups_for_file ap_note_cleanups_for_file +#define note_cleanups_for_socket ap_note_cleanups_for_socket +#define note_digest_auth_failure ap_note_digest_auth_failure +#define note_subprocess ap_note_subprocess +#define null_cleanup ap_null_cleanup +#define open_logs ap_open_logs +#define open_mutex ap_open_mutex +#define open_piped_log ap_open_piped_log +#define os_canonical_filename ap_os_canonical_filename +#define os_dl_load ap_os_dso_load +#define os_dl_unload ap_os_dso_unload +#define os_dl_sym ap_os_dso_sym +#define os_dl_error ap_os_dso_error +#define os_escape_path ap_os_escape_path +#define os_is_path_absolute ap_os_is_path_absolute +#define overlay_tables ap_overlay_tables +#define palloc ap_palloc +#define parseHTTPdate ap_parseHTTPdate +#define parse_hostinfo_components ap_parse_hostinfo_components +#define parse_htaccess ap_parse_htaccess +#define parse_uri ap_parse_uri +#define parse_uri_components ap_parse_uri_components +#define parse_vhost_addrs ap_parse_vhost_addrs +#define pcalloc ap_pcalloc +#define pcfg_open_custom ap_pcfg_open_custom +#define pcfg_openfile ap_pcfg_openfile +#define pclosedir ap_pclosedir +#define pclosef ap_pclosef +#define pclosesocket ap_pclosesocket +#define pduphostent ap_pduphostent +#define pfclose ap_pfclose +#define pfdopen ap_pfdopen +#define pfopen ap_pfopen +#define pgethostbyname ap_pgethostbyname +#define pid_fname ap_pid_fname +#define piped_log_read_fd ap_piped_log_read_fd +#define piped_log_write_fd ap_piped_log_write_fd +#define pool_is_ancestor ap_pool_is_ancestor +#define pool_join ap_pool_join +#define popendir ap_popendir +#define popenf ap_popenf +#define pregcomp ap_pregcomp +#define pregfree ap_pregfree +#define pregsub ap_pregsub +#define process_request ap_process_request +#define process_resource_config ap_process_resource_config +#define proxy_add_header ap_proxy_add_header +#define proxy_c2hex ap_proxy_c2hex +#define proxy_cache_check ap_proxy_cache_check +#define proxy_cache_error ap_proxy_cache_error +#define proxy_cache_tidy ap_proxy_cache_tidy +#define proxy_cache_update ap_proxy_cache_update +#define proxy_canon_netloc ap_proxy_canon_netloc +#define proxy_canonenc ap_proxy_canonenc +#define proxy_connect_handler ap_proxy_connect_handler +#define proxy_date_canon ap_proxy_date_canon +#define proxy_del_header ap_proxy_del_header +#define proxy_doconnect ap_proxy_doconnect +#define proxy_ftp_canon ap_proxy_ftp_canon +#define proxy_ftp_handler ap_proxy_ftp_handler +#define proxy_garbage_coll ap_proxy_garbage_coll +#define proxy_garbage_init ap_proxy_garbage_init +#define proxy_get_header ap_proxy_get_header +#define proxy_hash ap_proxy_hash +#define proxy_hex2c ap_proxy_hex2c +#define proxy_hex2sec ap_proxy_hex2sec +#define proxy_host2addr ap_proxy_host2addr +#define proxy_http_canon ap_proxy_http_canon +#define proxy_http_handler ap_proxy_http_handler +#define proxy_is_domainname ap_proxy_is_domainname +#define proxy_is_hostname ap_proxy_is_hostname +#define proxy_is_ipaddr ap_proxy_is_ipaddr +#define proxy_is_word ap_proxy_is_word +#define proxy_liststr ap_proxy_liststr +#define proxy_read_headers ap_proxy_read_headers +#define proxy_sec2hex ap_proxy_sec2hex +#define proxy_send_fb ap_proxy_send_fb +#define proxy_send_headers ap_proxy_send_headers +#define proxyerror ap_proxyerror +#define psignature ap_psignature +#define psocket ap_psocket +#define psprintf ap_psprintf +#define pstrcat ap_pstrcat +#define pstrdup ap_pstrdup +#define pstrndup ap_pstrndup +#define push_array ap_push_array +#define pvsprintf ap_pvsprintf +#define rationalize_mtime ap_rationalize_mtime +#define read_config ap_read_config +#define read_request ap_read_request +#define regexec ap_regexec +#define regerror ap_regerror +#define register_cleanup ap_register_cleanup +#define register_other_child ap_register_other_child +#define release_mutex ap_release_mutex +#define remove_module ap_remove_module +#define requires ap_requires +#define reset_timeout ap_reset_timeout +#define response_code_string ap_response_code_string +#define restart_time ap_restart_time +#define rfc1413 ap_rfc1413 +#define rfc1413_timeout ap_rfc1413_timeout +#define rflush ap_rflush +#define rind ap_rind +#define rprintf ap_rprintf +#define rputc ap_rputc +#define rputs ap_rputs +#define run_cleanup ap_run_cleanup +#define run_fixups ap_run_fixups +#define run_post_read_request ap_run_post_read_request +#define run_sub_req ap_run_sub_req +#define rvputs ap_rvputs +#define rwrite ap_rwrite +#define satisfies ap_satisfies +#define scan_script_header(a1,a2) ap_scan_script_header_err(a1,a2,NULL) +#define scan_script_header_err ap_scan_script_header_err +#define scan_script_header_err_buff ap_scan_script_header_err_buff +#define scoreboard_fname ap_scoreboard_fname +#define scoreboard_image ap_scoreboard_image +#define send_error_response ap_send_error_response +#define send_fb ap_send_fb +#define send_fb_length ap_send_fb_length +#define send_fd ap_send_fd +#define send_fd_length ap_send_fd_length +#define send_header_field ap_send_header_field +#define send_http_header ap_send_http_header +#define send_http_options ap_send_http_options +#define send_http_trace ap_send_http_trace +#define send_mmap ap_send_mmap +#define send_size ap_send_size +#define server_argv0 ap_server_argv0 +#define server_confname ap_server_confname +#define server_post_read_config ap_server_post_read_config +#define server_pre_read_config ap_server_pre_read_config +#define server_root ap_server_root +#define server_root_relative ap_server_root_relative +#define set_byterange ap_set_byterange +#define set_callback_and_alarm ap_set_callback_and_alarm +#define set_config_vectors ap_set_config_vectors +#define set_content_length ap_set_content_length +#define set_etag ap_set_etag +#define set_file_slot ap_set_file_slot +#define set_flag_slot ap_set_flag_slot +#define set_keepalive ap_set_keepalive +#define set_last_modified ap_set_last_modified +#define set_module_config ap_set_module_config +#define set_name_virtual_host ap_set_name_virtual_host +#define set_string_slot ap_set_string_slot +#define set_string_slot_lower ap_set_string_slot_lower +#define set_sub_req_protocol ap_set_sub_req_protocol +#define setup_client_block ap_setup_client_block +#define setup_prelinked_modules ap_setup_prelinked_modules +#define should_client_block ap_should_client_block +#define show_directives ap_show_directives +#define show_modules ap_show_modules +#define soft_timeout ap_soft_timeout +#define some_auth_required ap_some_auth_required +#define spawn_child_err ap_spawn_child +#define spawn_child_err_buff ap_bspawn_child +#define srm_command_loop ap_srm_command_loop +#define standalone ap_standalone +#define start_restart ap_start_restart +#define start_shutdown ap_start_shutdown +#define status_drops_connection ap_status_drops_connection +#define str_tolower ap_str_tolower +#define strcasecmp_match ap_strcasecmp_match +#define strcmp_match ap_strcmp_match +#define sub_req_lookup_file ap_sub_req_lookup_file +#define sub_req_lookup_uri ap_sub_req_lookup_uri +#define suexec_enabled ap_suexec_enabled +#define sync_scoreboard_image ap_sync_scoreboard_image +#define table_add ap_table_add +#define table_addn ap_table_addn +#define table_do ap_table_do +#define table_elts ap_table_elts +#define table_get ap_table_get +#define table_merge ap_table_merge +#define table_mergen ap_table_mergen +#define table_set ap_table_set +#define table_setn ap_table_setn +#define table_unset ap_table_unset +#define threads_per_child ap_threads_per_child +#define time_process_request ap_time_process_request +#define tm2sec ap_tm2sec +#define translate_name ap_translate_name +#define uname2id ap_uname2id +#define unblock_alarms ap_unblock_alarms +#define unescape_url ap_unescape_url +#define unparse_uri_components ap_unparse_uri_components +#define unregister_other_child ap_unregister_other_child +#define update_child_status ap_update_child_status +#define update_mtime ap_update_mtime +#define update_vhost_from_headers ap_update_vhost_from_headers +#define update_vhost_given_ip ap_update_vhost_given_ip +#define user_id ap_user_id +#define user_name ap_user_name +#define util_init ap_util_init +#define util_uri_init ap_util_uri_init +#define uudecode ap_uudecode +#define vbprintf ap_vbprintf + +/* + * Macros for routines whose arguments have changed over time. + */ +#define spawn_child(p,f,v,k,in,out) ap_spawn_child(p,f,v,k,in,out,NULL) + +#ifdef __cplusplus +} +#endif + +#endif /* !AP_COMPAT_H */ diff --git a/APACHE_1_3_42/src/include/ap_config.h b/APACHE_1_3_42/src/include/ap_config.h new file mode 100644 index 0000000000..cac8084f1b --- /dev/null +++ b/APACHE_1_3_42/src/include/ap_config.h @@ -0,0 +1,1462 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef AP_CONFIG_H +#define AP_CONFIG_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * ap_config.h: system-dependant #defines and includes... + * See PORTING for a listing of what they mean + */ + +#include "ap_mmn.h" /* MODULE_MAGIC_NUMBER_ */ + +/* + * Support for platform dependent autogenerated defines + */ +#if !defined(WIN32) && !defined(NETWARE) && !defined(TPF) +#include "ap_config_auto.h" +#endif + +#if defined(WIN32) || defined(NETWARE) +/* not available under WIN32, so provide important entries manually */ +#undef HAVE_UNISTD_H +#endif + +/* Have to include sys/stat.h before ../win32/os.h so we can override +stat() properly */ +#ifndef NETWARE +#include <sys/types.h> +#endif +#include <sys/stat.h> + + +/* So that we can use inline on some critical functions, and use + * GNUC attributes (such as to get -Wall warnings for printf-like + * functions). Only do this in gcc 2.7 or later ... it may work + * on earlier stuff, but why chance it. + * + * We've since discovered that the gcc shipped with NeXT systems + * as "cc" is completely broken. It claims to be __GNUC__ and so + * on, but it doesn't implement half of the things that __GNUC__ + * means. In particular it's missing inline and the __attribute__ + * stuff. So we hack around it. PR#1613. -djg + */ +#if !defined(__GNUC__) || __GNUC__ < 2 || \ + (__GNUC__ == 2 && __GNUC_MINOR__ < 7) ||\ + defined(NEXT) +#define ap_inline +#define __attribute__(__x) +#define ENUM_BITFIELD(e,n,w) signed int n : w +#else +#define ap_inline __inline__ +#define USE_GNU_INLINE +#define ENUM_BITFIELD(e,n,w) e n : w +#endif + +#include "os.h" + +/* Define one of these according to your system. */ +#if defined(MINT) +typedef int rlim_t; +#define JMP_BUF sigjmp_buf +#define NO_LONG_DOUBLE +#define HAVE_FLOCK_SERIALIZED_ACCEPT +#define _BSD_SOURCE +#define EAGAIN EWOULDBLOCK +int initgroups (char *, int); +char *crypt (const char *pw, const char *salt); +int gethostname (char *name, int namelen); + +#elif defined(MPE) +#include <sys/times.h> +#define NO_SETSID +#define NO_KILLPG +#define NO_WRITEV +#define HAVE_SHMGET 1 +#define USE_SHMGET_SCOREBOARD +/* + UID/GID isn't a native concept for MPE, and it's definitely not a 100% + Unix implementation. There isn't a traditional superuser concept either, + so we're forced to liberalize SHM security a bit so the parent & children + can communicate when they're running with different UIDs within the same + GID (the GID will *always* be the same on MPE). Thus the weird SHM_R and + SHM_W below. +*/ +#define SHM_R 0440 /* Read permission */ +#define SHM_W 0220 /* Write permission */ +#define NEED_INITGROUPS +#define NEED_STRCASECMP +#define NEED_STRDUP +#define NEED_STRNCASECMP +extern void GETPRIVMODE(); +extern void GETUSERMODE(); +extern char *inet_ntoa(); +#define NO_SLACK +#define S_IEXEC S_IXUSR +#define S_IREAD S_IRUSR +#define S_IWRITE S_IWUSR +#define PF_INET AF_INET +#define HAVE_FCNTL_SERIALIZED_ACCEPT + +#elif defined(SUNOS4) +#define HAVE_GMTOFF 1 +#undef NO_KILLPG +#undef NO_SETSID +char *crypt(const char *pw, const char *salt); +char *mktemp(char *); +#define HAVE_MMAP 1 +#define USE_MMAP_SCOREBOARD +#define USE_MMAP_FILES +#include <sys/time.h> +#define NEED_STRERROR +typedef int rlim_t; +#define memmove(a,b,c) bcopy(b,a,c) +#define NO_LINGCLOSE +#define HAVE_FLOCK_SERIALIZED_ACCEPT +#define NEED_DIFFTIME +#define HAVE_SYSLOG 1 + +#elif defined(SOLARIS2) +#undef HAVE_GMTOFF +#define NO_KILLPG +#undef NO_SETSID +#define bzero(a,b) memset(a,0,b) +#define HAVE_SYSVSEM_SERIALIZED_ACCEPT +#define HAVE_FCNTL_SERIALIZED_ACCEPT +#define HAVE_PTHREAD_SERIALIZED_ACCEPT +#if !defined(USE_SYSVSEM_SERIALIZED_ACCEPT) && \ + !defined(USE_PTHREAD_SERIALIZED_ACCEPT) +#define USE_FCNTL_SERIALIZED_ACCEPT +#endif +#define NEED_UNION_SEMUN +#define HAVE_MMAP 1 +#define USE_MMAP_SCOREBOARD +#define USE_MMAP_FILES +int gethostname(char *name, int namelen); +#define HAVE_SYSLOG 1 +#define SYS_SIGLIST _sys_siglist +#define AP_ENABLE_EXCEPTION_HOOK +#define NONBLOCK_WHEN_MULTI_LISTEN + +#elif defined(IRIX) +#undef HAVE_GMTOFF +/* IRIX has killpg, but it's only in _BSD_COMPAT, so don't use it in case + * there's some weird conflict with non-BSD signals */ +#define NO_KILLPG +#undef NO_SETSID +#define HAVE_FLOCK_SERIALIZED_ACCEPT +#define HAVE_FCNTL_SERIALIZED_ACCEPT +#define HAVE_USLOCK_SERIALIZED_ACCEPT +#define HAVE_SYSVSEM_SERIALIZED_ACCEPT +#if !defined(USE_FLOCK_SERIALIZED_ACCEPT) && \ + !defined(USE_USLOCK_SERIALIZED_ACCEPT) && \ + !defined(USE_SYSVSEM_SERIALIZED_ACCEPT) +#define USE_FCNTL_SERIALIZED_ACCEPT +#endif +#define HAVE_SHMGET 1 +#define USE_SHMGET_SCOREBOARD +#define HAVE_MMAP 1 +#define USE_MMAP_FILES +#define NO_LONG_DOUBLE +#define NO_LINGCLOSE +#define HAVE_SYSLOG 1 +#define NONBLOCK_WHEN_MULTI_LISTEN + +#elif defined(HIUX) +#undef HAVE_GMTOFF +#define NO_KILLPG +#undef NO_SETSID +#ifndef _HIUX_SOURCE +#define _HIUX_SOURCE +#endif +#define HAVE_SHMGET 1 +#define USE_SHMGET_SCOREBOARD +#define SELECT_NEEDS_CAST +#define HAVE_SYSLOG 1 + +#elif defined(HPUX11) +#ifndef _HPUX_SOURCE +#define _HPUX_SOURCE +#endif +#define HAVE_SHMGET +#define USE_SHMGET_SCOREBOARD +#undef HAVE_GMTOFF +#define HAVE_FCNTL_SERIALIZED_ACCEPT +#define HAVE_MMAP +#define USE_MMAP_FILES +#define NO_KILLPG +#undef NO_SETSID +#define HAVE_SYSLOG +#define AP_ENABLE_EXCEPTION_HOOK + +#elif defined(HPUX) || defined(HPUX10) +#undef HAVE_GMTOFF +#define NO_KILLPG +#undef NO_SETSID +#define HAVE_FCNTL_SERIALIZED_ACCEPT +#ifndef _HPUX_SOURCE +#define _HPUX_SOURCE +#endif +#define HAVE_SHMGET 1 +#define USE_SHMGET_SCOREBOARD +#define HAVE_SYSLOG 1 +#ifndef HPUX10 +#define SELECT_NEEDS_CAST +typedef int rlim_t; +#endif + +#elif defined(AIX) +#undef HAVE_GMTOFF +#undef NO_KILLPG +#undef NO_SETSID +#ifndef __ps2__ +#define HAVE_MMAP 1 +#define USE_MMAP_SCOREBOARD +#define USE_MMAP_FILES +#define HAVE_SYSLOG 1 +#ifndef DEFAULT_GROUP +#define DEFAULT_GROUP "nobody" +#endif +#endif +#ifndef DEFAULT_USER +#define DEFAULT_USER "nobody" +#endif +#ifdef NEED_RLIM_T +typedef int rlim_t; +#endif +#define HAVE_FCNTL_SERIALIZED_ACCEPT +#define HAVE_SYSVSEM_SERIALIZED_ACCEPT +#define NEED_UNION_SEMUN +#if AIX >= 430 +#define HAVE_PTHREAD_SERIALIZED_ACCEPT +#endif +#define USE_FCNTL_SERIALIZED_ACCEPT +#if AIX >= 432 +#define SINGLE_LISTEN_UNSERIALIZED_ACCEPT +#endif +#ifdef USEBCOPY +#define memmove(a,b,c) bcopy(b,a,c) +#endif +#if AIX >= 510 +#define NET_SIZE_T socklen_t +#elif AIX >= 420 +#define NET_SIZE_T size_t +#endif +#define AP_ENABLE_EXCEPTION_HOOK +#define NONBLOCK_WHEN_MULTI_LISTEN + +#elif defined(ULTRIX) +/* we don't want to use sys/resource.h under + Ultrix although this header exists. */ +#undef HAVE_SYS_RESOURCE_H +#define HAVE_GMTOFF 1 +#undef NO_KILLPG +#undef NO_SETSID +#define ULTRIX_BRAIN_DEATH +#define NEED_STRDUP +/* If you have Ultrix 4.3, and are using cc, const is broken */ +#ifndef __ultrix__ /* Hack to check for pre-Ultrix 4.4 cc */ +#define const /* Not implemented */ +#endif + +#elif defined(OSF1) +#define HAVE_GMTOFF 1 +#undef NO_KILLPG +#undef NO_SETSID +#define HAVE_MMAP 1 +#define USE_MMAP_SCOREBOARD +#define USE_MMAP_FILES +#define NO_LONG_DOUBLE +#define HAVE_SYSLOG 1 +#define HAVE_FLOCK_SERIALIZED_ACCEPT +#define SINGLE_LISTEN_UNSERIALIZED_ACCEPT +#define NONBLOCK_WHEN_MULTI_LISTEN + +#elif defined(PARAGON) +#define HAVE_GMTOFF 1 +#undef NO_KILLPG +#undef NO_SETSID +#define HAVE_MMAP 1 +#define USE_MMAP_SCOREBOARD +#define USE_MMAP_FILES +#define NO_LONG_DOUBLE +#define HAVE_SYSLOG 1 +typedef int rlim_t; + +#elif defined(SEQUENT) +#define DEFAULT_USER "nobody" +#define DEFAULT_GROUP "nobody" +#define NO_SHMGET 1 +#define HAVE_MMAP 1 +#define HAVE_SYSLOG 1 +#define USE_MMAP_FILES 1 +#define USE_MMAP_SCOREBOARD 1 +#define HAVE_FCNTL_SERIALIZED_ACCEPT 1 +#define JMP_BUF sigjmp_buf +#undef NO_SETSID +#if SEQUENT < 40 +typedef int rlim_t; +#define NO_GETTIMEOFDAY +#undef HAVE_SYS_RESOURCE_H /* exists but does not provide *rlimit funcs */ +#include <sys/times.h> +#endif +#if SEQUENT < 42 +#define NEED_STRCASECMP +#define NEED_STRNCASECMP +#endif +#if SEQUENT < 44 +#define NO_KILLPG 1 +#define NET_SIZE_T int +#endif +#if SEQUENT >= 44 +#undef NO_KILLPG +#define NET_SIZE_T size_t +#endif + +#elif defined(NEXT) +typedef unsigned short mode_t; +typedef int rlim_t; +#define HAVE_GMTOFF 1 +#undef NO_KILLPG +#define NO_SETSID +#define NEED_STRDUP +#define NO_LINGCLOSE +#undef _POSIX_SOURCE +#ifndef FD_CLOEXEC +#define FD_CLOEXEC 1 +#endif +#ifndef S_ISDIR +#define S_ISDIR(m) (((m)&(S_IFMT)) == (S_IFDIR)) +#endif +#ifndef S_ISREG +#define S_ISREG(m) (((m)&(S_IFMT)) == (S_IFREG)) +#endif +#ifndef S_IXUSR +#define S_IXUSR 00100 +#endif +#ifndef S_IRGRP +#define S_IRGRP 00040 +#endif +#ifndef S_IXGRP +#define S_IXGRP 00010 +#endif +#ifndef S_IROTH +#define S_IROTH 00004 +#endif +#ifndef S_IXOTH +#define S_IXOTH 00001 +#endif +#ifndef S_IRUSR +#define S_IRUSR S_IREAD +#endif +#ifndef S_IWUSR +#define S_IWUSR S_IWRITE +#endif +#ifndef S_IWGRP +#define S_IWGRP 000020 +#endif +#ifndef S_IWOTH +#define S_IWOTH 000002 +#endif + +#define STDIN_FILENO 0 +#define STDOUT_FILENO 1 +#define STDERR_FILENO 2 + +/* PR#2293 fix */ +#define ap_wait_t union wait +#define waitpid(a,b,c) wait4((a) == -1 ? 0 : (a),(union wait *)(b),c,NULL) +#define WEXITSTATUS(status) (int)( WIFEXITED(status) ? ( (status).w_retcode ) : -1) +#define WTERMSIG(status) (int)( (status).w_termsig ) + +typedef int pid_t; +#define USE_LONGJMP +#define NO_USE_SIGACTION +#define HAVE_SYSLOG 1 + +#if defined(__DYNAMIC__) +#define HAVE_DYLD +#define DYLD_CANT_UNLOAD +#endif + +#elif defined(DARWIN) /* Darwin (Mac OS) */ +#undef PLATFORM +#define PLATFORM "Darwin" +#define HAVE_DYLD +#define HAVE_GMTOFF +#define HAVE_MMAP +#define USE_MMAP_FILES +#define USE_MMAP_SCOREBOARD +#ifdef MAC_OS_X_SERVER +#define MAP_TMPFILE +#endif /* MAC_OS_X_SERVER */ +#define HAVE_RESOURCE +#define HAVE_SNPRINTF +#define JMP_BUF jmp_buf +#define USE_LONGJMP +#define HAVE_FLOCK_SERIALIZED_ACCEPT +#define HAVE_FCNTL_SERIALIZED_ACCEPT +#define USE_FLOCK_SERIALIZED_ACCEPT +#define SINGLE_LISTEN_UNSERIALIZED_ACCEPT +#define AP_ENABLE_EXCEPTION_HOOK + +#elif defined(LINUX) + +#if LINUX > 1 +#include <features.h> + +/* libc4 systems probably still work, it probably doesn't define + * __GNU_LIBRARY__ + * libc5 systems define __GNU_LIBRARY__ == 1, but don't define __GLIBC__ + * glibc 2.x and later systems define __GNU_LIBRARY__ == 6, but list it as + * "deprecated in favour of __GLIBC__"; the value 6 will never be changed. + * glibc 1.x systems (i.e. redhat 4.x on sparc/alpha) should have + * __GLIBC__ < 2 + * all glibc based systems need crypt.h + */ +#if defined(__GNU_LIBRARY__) && __GNU_LIBRARY__ > 1 +#include <crypt.h> +#endif + +/* glibc 2.0.0 through 2.0.4 need size_t * here, where 2.0.5 needs socklen_t * + * there's no way to discern between these two libraries. But using int should + * be portable because otherwise these libs would be hopelessly broken with + * reams of existing networking code. We'll use socklen_t * for 2.1.x and + * later. + * + * int works for all the earlier libs, and is picked up by default later. + */ +#if defined(__GLIBC__) && (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 0)) +#define NET_SIZE_T socklen_t +#endif + +#define HAVE_SHMGET 1 +#define USE_SHMGET_SCOREBOARD +#define HAVE_MMAP 1 +#define USE_MMAP_FILES + +#if LINUX > 20 +/* see Pine.LNX.4.21.0011041233550.1897-100000@twinlark.arctic.org + * in new-httpd archives for performance numbers indicating these + * are the right choices for linux 2.2.x and later + */ +#define HAVE_SYSVSEM_SERIALIZED_ACCEPT +#define HAVE_FCNTL_SERIALIZED_ACCEPT +#define SINGLE_LISTEN_UNSERIALIZED_ACCEPT +#include <sys/sem.h> +#if _SEM_SEMUN_UNDEFINED +#define NEED_UNION_SEMUN +#endif +#else +#define USE_FCNTL_SERIALIZED_ACCEPT +#endif + +#define SYS_SIGLIST _sys_siglist + +#else +#define USE_FCNTL_SERIALIZED_ACCEPT +#endif + +#undef HAVE_GMTOFF +#undef NO_KILLPG +#undef NO_SETSID +#undef NEED_STRDUP +#include <sys/time.h> +#define HAVE_SYSLOG 1 + +/* glibc 2.1 and later finally define rlim_t */ +#if !defined(__GLIBC__) || __GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 1) +typedef int rlim_t; +#endif +#define AP_ENABLE_EXCEPTION_HOOK + +#elif defined(SCO) +#undef HAVE_GMTOFF +#undef NO_KILLPG +#undef NO_SETSID +#define NEED_INITGROUPS +#define NO_WRITEV +#include <sys/time.h> +#define HAVE_SYSLOG 1 +#undef HAVE_SYS_RESOURCE_H + +#elif defined(ATHEOS) + +#include <features.h> +#include <crypt.h> +#include <sys/time.h> + +#define HAVE_FCNTL_SERIALIZED_ACCEPT +#define USE_FCNTL_SERIALIZED_ACCEPT + +#undef HAVE_GMTOFF +#undef NO_KILLPG +#undef NO_SETSID +#undef NEED_STRDUP +#define HAVE_SYSLOG 1 + +#ifdef PLATFORM +#undef PLATFORM +#endif +#define PLATFORM "AtheOS" + +#elif defined(SCO5) + +#define HAVE_FCNTL_SERIALIZED_ACCEPT +#define HAVE_MMAP 1 +#define USE_MMAP_SCOREBOARD +#define USE_MMAP_FILES +#define SecureWare +#define HAVE_SYSLOG 1 + +/* Although SCO 5 defines these in <strings.h> (note the "s") they don't have + consts. Sigh. */ +extern int strcasecmp(const char *, const char *); +extern int strncasecmp(const char *, const char *, unsigned); + +#elif defined(AUX3) +/* These are to let -Wall compile more cleanly */ +extern int strcasecmp(const char *, const char *); +extern int strncasecmp(const char *, const char *, unsigned); +extern int set42sig(), getopt(), getpeername(), bzero(); +extern int listen(), bind(), socket(), getsockname(); +extern int accept(), gethostname(), connect(), lstat(); +extern int select(), killpg(), shutdown(); +extern int initgroups(), setsockopt(); +extern char *shmat(); +extern int shmctl(); +extern int shmget(); +extern char *sbrk(); +extern char *crypt(); +#include <sys/time.h> +#undef HAVE_GMTOFF +#undef NO_KILLPG +#undef NO_SETSID +#define NEED_STRDUP +/* fcntl() locking is expensive with NFS */ +#define HAVE_FLOCK_SERIALIZED_ACCEPT +#define SINGLE_LISTEN_UNSERIALIZED_ACCEPT +#define HAVE_SHMGET 1 +#define USE_SHMGET_SCOREBOARD +/* + * NOTE: If when you run Apache under A/UX and you get a warning + * that httpd couldn't move break, then the below value for + * MOVEBREAK (64megs) is too large for your setup. Try reducing + * to 0x2000000 which is still PLENTY of space. I doubt if + * even on heavy systems sbrk() would be called at all... + */ +#define MOVEBREAK 0x4000000 +#define NO_LINGCLOSE +#define NO_SLACK +#define HAVE_SYSLOG 1 +#undef HAVE_SYS_RESOURCE_H /* exists but does not provide *rlimit funcs */ + +#elif defined(SVR4) +#define NO_KILLPG +#undef NO_SETSID +#undef NEED_STRDUP +#ifndef MPRAS +#define NEED_STRCASECMP +#ifndef ENCORE +#define NEED_STRNCASECMP +#endif /* ENCORE */ +#endif /* MPRAS */ +#define bzero(a,b) memset(a,0,b) +/* A lot of SVR4 systems need this */ +#define HAVE_FCNTL_SERIALIZED_ACCEPT +#ifdef SNI +#define HAVE_SYSVSEM_SERIALIZED_ACCEPT +#endif +#ifndef USE_SYSVSEM_SERIALIZED_ACCEPT +#define USE_FCNTL_SERIALIZED_ACCEPT +#endif +#define HAVE_SYSLOG 1 +#define NET_SIZE_T size_t +#define HAVE_SHMGET 1 +#define USE_SHMGET_SCOREBOARD +#ifdef _OSD_POSIX /* BS2000-POSIX mainframe needs initgroups */ +#define NEED_HASHBANG_EMUL /* execve() doesn't start shell scripts by default */ +#define _KMEMUSER /* Enable SHM_R/SHM_W defines in <shm.h> */ +#define AP_ENABLE_EXCEPTION_HOOK +#undef NEED_STRCASECMP +#undef NEED_STRNCASECMP +#undef bzero +#endif /*_OSD_POSIX*/ + +#elif defined(UW) +#define HAVE_FCNTL_SERIALIZED_ACCEPT +#if UW < 700 +#define NO_LINGCLOSE +#define NO_KILLPG +#else +#define SINGLE_LISTEN_UNSERIALIZED_ACCEPT +#endif +#undef NO_SETSID +#undef NEED_STRDUP +#define NEED_STRCASECMP +#define NEED_STRNCASECMP +#define bzero(a,b) memset(a,0,b) +#define HAVE_MMAP 1 +#define USE_MMAP_SCOREBOARD +#define USE_MMAP_FILES +#define HAVE_SHMGET 1 +#undef USE_SHMGET_SCOREBOARD /* force use of mmap() scoreboard */ +#include <sys/time.h> +#if UW >= 200 +#define _POSIX_SOURCE +#endif +#define NET_SIZE_T size_t +#define HAVE_SYSLOG 1 + +#elif defined(DGUX) +#define NO_KILLPG +#undef NO_SETSID +#undef NEED_STRDUP +#ifdef _IX86_DG +#undef NEED_STRCASECMP +#undef NEED_STRNCASECMP +#else +#define NEED_STRCASECMP +#define NEED_STRNCASECMP +#endif +#define bzero(a,b) memset(a,0,b) +/* A lot of SVR4 systems need this */ +#define HAVE_FCNTL_SERIALIZED_ACCEPT +#define ap_inet_addr inet_network +#define HAVE_SYSLOG 1 + +#elif defined(__NetBSD__) || defined(__OpenBSD__) || defined(NETBSD) +#define HAVE_GMTOFF 1 +#undef NO_KILLPG +#undef NO_SETSID +#define HAVE_SYSLOG 1 +#ifndef DEFAULT_USER +#define DEFAULT_USER "nobody" +#endif +#ifndef DEFAULT_GROUP +#define DEFAULT_GROUP "nogroup" +#endif +#define HAVE_SHMGET 1 +#define HAVE_MMAP 1 +#define USE_MMAP_SCOREBOARD +#define USE_MMAP_FILES +#define HAVE_FLOCK_SERIALIZED_ACCEPT +#if defined(__OpenBSD__) +#define HAVE_SYSVSEM_SERIALIZED_ACCEPT +#define USE_SYSVSEM_SERIALIZED_ACCEPT +#include <sys/param.h> +#if (OpenBSD >= 199912) +#define NET_SIZE_T socklen_t +#endif +#endif +#define SINGLE_LISTEN_UNSERIALIZED_ACCEPT + +#elif defined(UTS21) +#undef HAVE_GMTOFF +#undef NO_KILLPG +#define NO_SETSID +#define NEED_WAITPID +#define STDIN_FILENO 0 +#define STDOUT_FILENO 1 +#define STDERR_FILENO 2 +#define HAVE_SYSLOG 1 +#define USE_LONGJMP +#define JMP_BUF jmp_buf +#define NO_USE_SIGACTION +#define NEED_STRERROR +#define NEED_STRSTR +#define NEED_HASHBANG_EMUL +#define NDELAY_PIPE_RETURNS_ZERO +#define NO_DATA NO_ADDRESS +#define ap_wait_t union wait +#define WEXITSTATUS(status) (int)((status).w_retcode) +#define WTERMSIG(status) (int)((status).w_termsig) +#define strftime(buf,bufsize,fmt,tm) ascftime(buf,fmt,tm) +#undef HAVE_SYS_RESOURCE_H /* exists but does not provide *rlimit funcs */ +#include <sys/types.h> +#include <sys/time.h> + +#elif defined(APOLLO) +#undef HAVE_GMTOFF +#undef NO_KILLPG +#undef NO_SETSID +#define HAVE_SYSLOG 1 + +#elif defined(__FreeBSD__) || defined(__bsdi__) +#if defined(__FreeBSD__) +#include <osreldate.h> +#endif +#define HAVE_GMTOFF 1 +#undef NO_KILLPG +#undef NO_SETSID +#define HAVE_MMAP 1 +#define USE_MMAP_SCOREBOARD +#define USE_MMAP_FILES +#ifndef DEFAULT_USER +#define DEFAULT_USER "nobody" +#endif +#ifndef DEFAULT_GROUP +#define DEFAULT_GROUP "nogroup" +#endif +#if defined(__bsdi__) || \ +(defined(__FreeBSD_version) && (__FreeBSD_version < 220000)) +typedef quad_t rlim_t; +#endif +#define HAVE_FLOCK_SERIALIZED_ACCEPT +#define SINGLE_LISTEN_UNSERIALIZED_ACCEPT +#define HAVE_SYSLOG 1 +#define SYS_SIGLIST sys_siglist +#if (defined(__FreeBSD_version) && (__FreeBSD_version >= 400000)) +#define NET_SIZE_T socklen_t +#endif + +#elif defined(QNX) +#ifndef crypt +char *crypt(const char *pw, const char *salt); +#endif +#ifndef initgroups +int initgroups(char *, int); +#endif +#ifndef strncasecmp +#define strncasecmp strnicmp +#endif +#undef NO_KILLPG +#undef NO_SETSID +#define NEED_INITGROUPS +#define NEED_SELECT_H +#define NEED_PROCESS_H +#include <unix.h> +#define HAVE_MMAP 1 +#define USE_POSIX_SCOREBOARD +#define HAVE_FLOCK_SERIALIZED_ACCEPT +#define SINGLE_LISTEN_UNSERIALIZED_ACCEPT +#define HAVE_SYSLOG 1 + +#elif defined(LYNXOS) +#undef HAVE_GMTOFF +#undef USE_MMAP_SCOREBOARD +#undef USE_SHMGET_SCOREBOARD +#undef HAVE_FCNTL_SERIALIZED_ACCEPT +#undef HAVE_FLOCK_SERIALIZED_ACCEPT +#define HAVE_NONE_SERIALIZED_ACCEPT +#define USE_LONGJMP +#undef NO_KILLPG +#undef NO_SETSID +#undef NO_USE_SIGACTION +#undef NO_LINGCLOSE +extern char *crypt(char *pw, char *salt); +typedef int rlim_t; +#define HAVE_SYSLOG 1 + +#elif defined(UXPDS) +#undef NEED_STRCASECMP +#undef NEED_STRNCASECMP +#undef NEED_STRDUP +#undef HAVE_GMTOFF +#define NO_KILLPG +#undef NO_SETSID +#define bzero(a,b) memset(a,0,b) +#define HAVE_FCNTL_SERIALIZED_ACCEPT +#define HAVE_MMAP 1 +#define USE_MMAP_SCOREBOARD +#define USE_MMAP_FILES +#define HAVE_SYSLOG 1 + +#elif defined(OS2) +/* Defines required for EMX OS/2 port. */ +#define NO_KILLPG +#define NEED_STRCASECMP +#define NEED_STRNCASECMP +#define NEED_PROCESS_H +#define NO_SETSID +#define NO_TIMES +#define CASE_BLIND_FILESYSTEM +/* Add some drive name support */ +#define chdir _chdir2 +#include <sys/time.h> +#define MAXSOCKETS 2048 +#define USE_OS2_SCOREBOARD +#define NO_RELIABLE_PIPED_LOGS +#define HAVE_OS2SEM_SERIALIZED_ACCEPT +#define SINGLE_LISTEN_UNSERIALIZED_ACCEPT +#define NO_SLACK +#define FOPEN_REQUIRES_T + +#elif defined(__MACHTEN__) +typedef int rlim_t; +#undef NO_KILLPG +#define NO_SETSID +#define HAVE_GMTOFF 1 +#ifndef __MACHTEN_PPC__ +#ifndef __MACHTEN_68K__ +#define __MACHTEN_68K__ +#endif +#define HAVE_FLOCK_SERIALIZED_ACCEPT +#define NO_USE_SIGACTION +#define JMP_BUF sigjmp_buf +#define USE_LONGJMP +#undef NEED_STRDUP +#else +#define HAVE_SHMGET 1 +#define USE_SHMGET_SCOREBOARD +#define HAVE_FCNTL_SERIALIZED_ACCEPT +#endif + +/* Convex OS v11 */ +#elif defined(CONVEXOS11) +#undef HAVE_GMTOFF +#undef NO_KILLPG +#undef NO_SETSID +#undef NEED_STRDUP +#define HAVE_MMAP 1 +#define USE_MMAP_SCOREBOARD +#define USE_MMAP_FILES +#define HAVE_SYSLOG 1 + +#define NO_TIMEZONE +#include <stdio.h> +#include <sys/types.h> +typedef int rlim_t; + +#elif defined(ISC) +#include <net/errno.h> +#define NO_KILLPG +#undef NO_SETSID +#define HAVE_SHMGET 1 +#define USE_SHMGET_SCOREBOARD +#define HAVE_FCNTL_SERIALIZED_ACCEPT +#define HAVE_SYSLOG 1 + +#elif defined(NEWSOS) +#define HAVE_SHMGET 1 +#define USE_SHMGET_SCOREBOARD +#define USE_LONGJMP +#define NO_SETSID +#define NO_USE_SIGACTION +#define NEED_WAITPID +#define NO_OTHER_CHILD +#define HAVE_SYSLOG 1 +#include <sys/time.h> +#include <stdlib.h> +#include <sys/types.h> +typedef int pid_t; +typedef int rlim_t; +typedef int mode_t; + +#elif defined(RISCIX) +#include <sys/time.h> +typedef int rlim_t; +#define NO_USE_SIGACTION +#define USE_LONGJMP +#define NEED_STRCASECMP +#define NEED_STRNCASECMP +#define NEED_STRDUP + +#elif defined(BEOS) +#undef PLATFORM +#define PLATFORM "BeOS" +#include <stddef.h> +#include <kernel/OS.h> + +#define HAVE_BEOS_SERIALIZED_ACCEPT +#define SINGLE_LISTEN_UNSERIALIZED_ACCEPT + +#define NO_WRITEV +#define NO_KILLPG +#define NEED_INITGROUPS +#define PF_INET AF_INET +#define S_IEXEC S_IXUSR + +#elif defined(BONE) +#undef PLATFORM +#define PLATFORM "BeOS BONE" +#include <kernel/OS.h> + +#define NO_KILLPG +#define NEED_INITGROUPS +#define S_IEXEC S_IXUSR +#define HAVE_BEOS_SERIALIZED_ACCEPT +#define SINGLE_LISTEN_UNSERIALIZED_ACCEPT + +#elif defined(_CX_SX) +#define JMP_BUF sigjmp_buf +#include <sys/types.h> +#include <sys/time.h> + +#elif defined(WIN32) + +/* All windows stuff is now in os/win32/os.h */ + +#elif defined(TPF) /* IBM Transaction Processing Facility operating system */ + +/* All TPF definitions are now in os/tpf/os.h */ + +#elif defined(__TANDEM) +#define NO_WRITEV +#define NO_KILLPG +#define NEED_INITGROUPS +#define NO_SLACK + +#elif defined(OS390) /* IBM OS/390 Operating System */ +#define HAVE_MMAP +#define HAVE_SHMGET +#define USE_SHMGET_SCOREBOARD +#define USE_MMAP_FILES +#define NEED_UNION_SEMUN +#define HAVE_SYSVSEM_SERIALIZED_ACCEPT +#define HAVE_FCNTL_SERIALIZED_ACCEPT +#define _POSIX_SOURCE +#include <signal.h> +#ifdef SIGDUMP /* SIGDUMP is not defined by OS/390 v1r2 */ +#define NSIG SIGDUMP+1 +#else +#define NSIG 40 +#endif +#define JMP_BUF sigjmp_buf +#define _XOPEN_SOURCE_EXTENDED 1 +#define _OPEN_MSGQ_EXT +#define _XOPEN_SOURCE +#define SHM_R S_IRUSR +#define SHM_W S_IWUSR +#include <sys/time.h> +#include <sys/types.h> +#include <sys/msg.h> +#include <sys/socket.h> +#define NET_SIZE_T size_t +#define NEED_HASHBANG_EMUL +#define NONBLOCK_WHEN_MULTI_LISTEN + +#elif defined(CYGWIN) /* Cygwin 1.x POSIX layer for Win32 */ +#define SYSTEM_UID 18 +#define JMP_BUF jmp_buf +#define NO_KILLPG +#define NO_SETSID +#define USE_LONGJMP +#define GDBM_STATIC +#define HAVE_MMAP 1 +#define USE_MMAP_SCOREBOARD +#define USE_MMAP_FILES +#define HAVE_SYSLOG 1 +#define HAVE_FCNTL_SERIALIZED_ACCEPT +#define HAVE_PTHREAD_SERIALIZED_ACCEPT +#define SINGLE_LISTEN_UNSERIALIZED_ACCEPT +#if !defined(USE_FCNTL_SERIALIZED_ACCEPT) +#define USE_PTHREAD_SERIALIZED_ACCEPT +#endif + +#elif defined(NETWARE) +#define NONBLOCK_WHEN_MULTI_LISTEN + +#else +/* Unknown system - Edit these to match */ +#ifdef BSD +#define HAVE_GMTOFF 1 +#else +#undef HAVE_GMTOFF +#endif +/* NO_KILLPG is set on systems that don't have killpg */ +#undef NO_KILLPG +/* NO_SETSID is set on systems that don't have setsid */ +#undef NO_SETSID +/* NEED_STRDUP is set on stupid systems that don't have strdup. */ +#undef NEED_STRDUP +#endif + +#ifdef HAVE_SYS_PARAM_H +#include <sys/param.h> +#endif /* HAVE_SYS_PARAM_H */ + +/* stuff marked API_EXPORT is part of the API, and intended for use + * by modules + */ +#ifndef API_EXPORT +#define API_EXPORT(type) type +#endif + +/* Stuff marked API_EXPORT_NONSTD is part of the API, and intended for + * use by modules. The difference between API_EXPORT and + * API_EXPORT_NONSTD is that the latter is required for any functions + * which use varargs or are used via indirect function call. This + * is to accomodate the two calling conventions in windows dlls. + */ +#ifndef API_EXPORT_NONSTD +#define API_EXPORT_NONSTD(type) type +#endif + +#ifndef MODULE_VAR_EXPORT +#define MODULE_VAR_EXPORT +#endif +#ifndef API_VAR_EXPORT +#define API_VAR_EXPORT +#endif + +/* modules should not used functions marked CORE_EXPORT + * or CORE_EXPORT_NONSTD */ +#ifndef CORE_EXPORT +#define CORE_EXPORT API_EXPORT +#endif +#ifndef CORE_EXPORT_NONSTD +#define CORE_EXPORT_NONSTD API_EXPORT_NONSTD +#endif + +/* On Darwin, symbols that conflict with loaded dylibs + * (eg. System framework) need to be declared as private symbols with + * __private_extern__. + * For other systems, make that a no-op. + */ +#if defined(DARWIN) && defined(__DYNAMIC__) +#define ap_private_extern __private_extern__ +#else +#define ap_private_extern +#endif + +/* + * The particular directory style your system supports. If you have dirent.h + * in /usr/include (POSIX) or /usr/include/sys (SYSV), #include + * that file and define DIR_TYPE to be dirent. Otherwise, if you have + * /usr/include/sys/dir.h, define DIR_TYPE to be direct and include that + * file. If you have neither, I'm confused. + */ + +#ifndef NETWARE +#include <sys/types.h> +#endif +#include <stdarg.h> + +#if !defined(NEXT) && !defined(WIN32) +#include <dirent.h> +#define DIR_TYPE dirent +#elif !defined(WIN32) +#include <sys/dir.h> +#define DIR_TYPE direct +#else +#define DIR_TYPE dirent +#endif + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#ifdef __TANDEM +#include <strings.h> +#endif +#include "ap_ctype.h" +#if !defined(MPE) && !defined(WIN32) && !defined(TPF41) && !defined(__TANDEM) && !defined(NETWARE) +#include <sys/file.h> +#endif +#if !defined(WIN32) && !defined(NETWARE) +#include <sys/socket.h> +#ifdef HAVE_SYS_SELECT_H +#include <sys/select.h> +#endif /* HAVE_SYS_SELECT_H */ +#ifndef TPF41 +#include <netinet/in.h> +#endif /* ndef TPF41 */ +#if defined(OS390) && !defined(NO_ADDRESS) +#define NO_ADDRESS NO_DATA /* Not defined properly by OS/390 v1r2 */ +#endif +#include <netdb.h> +#include <sys/ioctl.h> +#if !defined(MPE) && !defined(BEOS) && !defined(TPF41) +#include <arpa/inet.h> /* for inet_ntoa */ +#endif +#include <sys/wait.h> +#include <pwd.h> +#include <grp.h> +#include <fcntl.h> +#ifndef BEOS +#define closesocket(s) close(s) +#endif +#ifndef O_BINARY +#define O_BINARY (0) +#endif +#endif /* ndef WIN32 */ + +#include <limits.h> +#include <time.h> /* for ctime */ +#ifdef WIN32 +#define strftime(s,max,format,tm) os_strftime(s,max,format,tm) +#endif +#include <signal.h> +#ifdef NETWARE +#undef SIGKILL +#undef SA_NOCLDSTOP +#undef SIGALRM +#undef SIGCHILD +#undef SIGCONT +#undef SIGHUP +#undef SIGPIPE +#undef SIGQUIT +#undef SIGSTOP +#undef SIGTSTP +#undef SIGTTIN +#undef SIGTTOU +#undef SIGUSR1 +#undef SIGUSR2 +#undef SIG_BLOCK +#undef SIG_SETMASK +#undef SIG_UNBLOCK +#endif +#if defined(TPF41) && defined(NSIG) +#undef NSIG +#endif +#include <errno.h> +#if !defined(QNX) && !defined(CONVEXOS11) && !defined(NEXT) && !defined(TPF41) && !defined(NETWARE) && !defined(MPE) +#include <memory.h> +#endif + +#ifdef NEED_PROCESS_H +#include <process.h> +#endif + +#if defined(WIN32) || defined(USE_HSREGEX) +#include "hsregex.h" +#else +#include <regex.h> +#endif + +#ifdef HAVE_SYS_RESOURCE_H +#include <sys/resource.h> +#ifdef SUNOS4 +int getrlimit(int, struct rlimit *); +int setrlimit(int, struct rlimit *); +#endif +#endif +#ifdef USE_MMAP_SCOREBOARD +#if !defined(OS2) && !defined(WIN32) +/* This file is not needed for OS/2 */ +#include <sys/mman.h> +#endif +#endif +#if !defined(MAP_ANON) && defined(MAP_ANONYMOUS) +#define MAP_ANON MAP_ANONYMOUS +#endif + +#if defined(USE_MMAP_FILES) && (defined(NO_MMAP) || !defined(HAVE_MMAP)) +#undef USE_MMAP_FILES +#endif + +#if defined(USE_MMAP_SCOREBOARD) && (defined(NO_MMAP) || !defined(HAVE_MMAP)) +#undef USE_MMAP_SCOREBOARD +#endif + +#if defined(USE_SHMGET_SCOREBOARD) && (defined(NO_SHMGET) || !defined(HAVE_SHMGET)) +#undef USE_SHMGET_SCOREBOARD +#endif + +/* A USE_FOO_SERIALIZED_ACCEPT implies a HAVE_FOO_SERIALIZED_ACCEPT */ +#if defined(USE_USLOCK_SERIALIZED_ACCEPT) && !defined(HAVE_USLOCK_SERIALIZED_ACCEPT) +#define HAVE_USLOCK_SERIALIZED_ACCEPT +#endif +#if defined(USE_PTHREAD_SERIALIZED_ACCEPT) && !defined(HAVE_PTHREAD_SERIALIZED_ACCEPT) +#define HAVE_PTHREAD_SERIALIZED_ACCEPT +#endif +#if defined(USE_SYSVSEM_SERIALIZED_ACCEPT) && !defined(HAVE_SYSVSEM_SERIALIZED_ACCEPT) +#define HAVE_SYSVSEM_SERIALIZED_ACCEPT +#endif +#if defined(USE_FCNTL_SERIALIZED_ACCEPT) && !defined(HAVE_FCNTL_SERIALIZED_ACCEPT) +#define HAVE_FCNTL_SERIALIZED_ACCEPT +#endif +#if defined(USE_FLOCK_SERIALIZED_ACCEPT) && !defined(HAVE_FLOCK_SERIALIZED_ACCEPT) +#define HAVE_FLOCK_SERIALIZED_ACCEPT +#endif +#if defined(USE_OS2SEM_SERIALIZED_ACCEPT) && !defined(HAVE_OS2SEM_SERIALIZED_ACCEPT) +#define HAVE_OS2SEM_SERIALIZED_ACCEPT +#endif +#if defined(USE_TPF_CORE_SERIALIZED_ACCEPT) && !defined(HAVE_TPF_CORE_SERIALIZED_ACCEPT) +#define HAVE_TPF_CORE_SERIALIZED_ACCEPT +#endif +#if defined(USE_BEOS_SERIALIZED_ACCEPT) && !defined(HAVE_BEOS_SERIALIZED_ACCEPT) +#define HAVE_BEOS_SERIALIZED_ACCEPT +#endif +#if defined(USE_NONE_SERIALIZED_ACCEPT) && !defined(HAVE_NONE_SERIALIZED_ACCEPT) +#define HAVE_NONE_SERIALIZED_ACCEPT +#endif + +#ifndef LOGNAME_MAX +#define LOGNAME_MAX 25 +#endif + +#ifdef HAVE_UNISTD_H +#include <unistd.h> +#endif + +#ifdef ultrix +#define ULTRIX_BRAIN_DEATH +#endif + +#ifndef S_ISLNK +#define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK) +#endif + +#ifndef INADDR_NONE +#define INADDR_NONE ((unsigned long) -1) +#endif + +/* + * Replace signal function with sigaction equivalent + */ +#ifndef NO_USE_SIGACTION +typedef void Sigfunc(int); + +#if defined(SIG_IGN) && !defined(SIG_ERR) +#define SIG_ERR ((Sigfunc *)-1) +#endif + +/* + * For some strange reason, QNX defines signal to signal. Eliminate it. + */ +#ifdef signal +#undef signal +#endif +#define signal(s,f) ap_signal(s,f) +Sigfunc *signal(int signo, Sigfunc * func); +#endif + +#include <setjmp.h> + +#if defined(USE_LONGJMP) +#define ap_longjmp(x, y) longjmp((x), (y)) +#define ap_setjmp(x) setjmp(x) +#ifndef JMP_BUF +#define JMP_BUF jmp_buf +#endif +#else +#define ap_longjmp(x, y) siglongjmp((x), (y)) +#define ap_setjmp(x) sigsetjmp((x), 1) +#ifndef JMP_BUF +#define JMP_BUF sigjmp_buf +#endif +#endif + +/* Majority of os's want to verify FD_SETSIZE */ +#if !defined(WIN32) && !defined(TPF) && !defined(NETWARE) +#define CHECK_FD_SETSIZE +#endif + +#ifdef USE_TPF_SELECT +#define ap_select(_a, _b, _c, _d, _e) \ + tpf_select(_a, _b, _c, _d, _e) +#elif defined(SELECT_NEEDS_CAST) +#define ap_select(_a, _b, _c, _d, _e) \ + select((_a), (int *)(_b), (int *)(_c), (int *)(_d), (_e)) +#else +#define ap_select(_a, _b, _c, _d, _e) \ + select(_a, _b, _c, _d, _e) +#endif + +#ifdef USE_TPF_ACCEPT +#define ap_accept(_fd, _sa, _ln) tpf_accept(_fd, _sa, _ln) +#else +#define ap_accept(_fd, _sa, _ln) accept(_fd, _sa, _ln) +#endif + +#ifdef NEED_SIGNAL_INTERRUPT +#define ap_check_signals() tpf_process_signals() +#else +#define ap_check_signals() +#endif + +#ifdef ULTRIX_BRAIN_DEATH +#define ap_fdopen(d,m) fdopen((d), (char *)(m)) +#else +#define ap_fdopen(d,m) fdopen((d), (m)) +#endif + +#ifndef ap_inet_addr +#define ap_inet_addr inet_addr +#endif + +#ifdef NO_OTHER_CHILD +#define NO_RELIABLE_PIPED_LOGS +#endif + +/* When the underlying OS doesn't support exec() of scripts which start + * with a HASHBANG (#!) followed by interpreter name and args, define this. + */ +#ifdef NEED_HASHBANG_EMUL +extern int ap_execle(const char *filename, const char *arg,...); +extern int ap_execve(const char *filename, char * const argv[], + char * const envp[]); +/* ap_execle() is a wrapper function around ap_execve(). */ +#define execle ap_execle +#define execve(path,argv,envp) ap_execve(path,argv,envp) +#endif + +/* Finding offsets of elements within structures. + * Taken from the X code... they've sweated portability of this stuff + * so we don't have to. Sigh... + */ + +#if defined(CRAY) || (defined(__arm) && !defined(LINUX)) +#ifdef __STDC__ +#define XtOffset(p_type,field) _Offsetof(p_type,field) +#else +#ifdef CRAY2 +#define XtOffset(p_type,field) \ + (sizeof(int)*((unsigned int)&(((p_type)NULL)->field))) + +#else /* !CRAY2 */ + +#define XtOffset(p_type,field) ((unsigned int)&(((p_type)NULL)->field)) + +#endif /* !CRAY2 */ +#endif /* __STDC__ */ +#else /* ! (CRAY || __arm) */ + +#define XtOffset(p_type,field) \ + ((long) (((char *) (&(((p_type)NULL)->field))) - ((char *) NULL))) + +#endif /* !CRAY */ + +#ifndef XtOffsetOf +#ifdef offsetof +#define XtOffsetOf(s_type,field) offsetof(s_type,field) +#else +#define XtOffsetOf(s_type,field) XtOffset(s_type*,field) +#endif +#endif + +/* + * NET_SIZE_T exists because of shortsightedness on the POSIX committee. BSD + * systems used "int *" as the parameter to accept(), getsockname(), + * getpeername() et al. Consequently many unixes took an int * for that + * parameter. The POSIX committee decided that "int" was just too generic and + * had to be replaced with size_t almost everywhere. There's no problem with + * that when you're passing by value. But when you're passing by reference + * this creates a gross source incompatibility with existing programs. On + * 32-bit architectures it creates only a warning. On 64-bit architectures it + * creates broken code -- because "int *" is a pointer to a 64-bit quantity and + * "size_t *" is frequently a pointer to a 32-bit quantity. + * + * Some Unixes adopted "size_t *" for the sake of POSIX compliance. Others + * ignored it because it was such a broken interface. Chaos ensued. POSIX + * finally woke up and decided that it was wrong and created a new type + * socklen_t. The only useful value for socklen_t is int, and that's how + * everyone who has a clue implements it. It is almost always the case that + * NET_SIZE_T should be defined to be an int, unless the system being compiled + * for was created in the window of POSIX madness. + */ +#ifndef NET_SIZE_T +#define NET_SIZE_T int +#endif + +/* Linux defines __WCOREDUMP, but doesn't define WCOREDUMP unless __USE_BSD + * is in use... we'd prefer to just use WCOREDUMP everywhere. + */ +#if defined(__WCOREDUMP) && !defined(WCOREDUMP) +#define WCOREDUMP __WCOREDUMP +#endif + +#ifdef SUNOS_LIB_PROTOTYPES +/* Prototypes needed to get a clean compile with gcc -Wall. + * Believe it or not, these do have to be declared, at least on SunOS, + * because they aren't mentioned in the relevant system headers. + * Sun Quality Software. Gotta love it. This section is not + * currently (13Nov97) used. + */ + +int getopt(int, char **, char *); + +int strcasecmp(const char *, const char *); +int strncasecmp(const char *, const char *, int); +int toupper(int); +int tolower(int); + +int printf(char *,...); +int fprintf(FILE *, char *,...); +int fputs(char *, FILE *); +int fread(char *, int, int, FILE *); +int fwrite(char *, int, int, FILE *); +int fgetc(FILE *); +char *fgets(char *s, int, FILE*); +int fflush(FILE *); +int fclose(FILE *); +int ungetc(int, FILE *); +int _filbuf(FILE *); /* !!! */ +int _flsbuf(unsigned char, FILE *); /* !!! */ +int sscanf(char *, char *,...); +void setbuf(FILE *, char *); +void perror(char *); + +time_t time(time_t *); +int strftime(char *, int, const char *, struct tm *); + +int initgroups(char *, int); +int wait3(int *, int, void *); /* Close enough for us... */ +int lstat(const char *, struct stat *); +int stat(const char *, struct stat *); +int flock(int, int); +#ifndef NO_KILLPG +int killpg(int, int); +#endif +int socket(int, int, int); +int setsockopt(int, int, int, const char *, int); +int listen(int, int); +int bind(int, struct sockaddr *, int); +int connect(int, struct sockaddr *, int); +int accept(int, struct sockaddr *, int *); +int shutdown(int, int); + +int getsockname(int s, struct sockaddr *name, int *namelen); +int getpeername(int s, struct sockaddr *name, int *namelen); +int gethostname(char *name, int namelen); +void syslog(int, char *,...); +char *mktemp(char *); + +int vfprintf(FILE *, const char *, va_list); + +#endif /* SUNOS_LIB_PROTOTYPES */ + +/* The assumption is that when the functions are missing, + * then there's no matching prototype available either. + * Declare what is needed exactly as the replacement routines implement it. + */ +#ifdef NEED_STRDUP +extern char *strdup (const char *str); +#endif +#ifdef NEED_STRCASECMP +extern int strcasecmp (const char *a, const char *b); +#endif +#ifdef NEED_STRNCASECMP +extern int strncasecmp (const char *a, const char *b, int n); +#endif +#ifdef NEED_INITGROUPS +extern int initgroups(const char *name, gid_t basegid); +#endif +#ifdef NEED_WAITPID +extern int waitpid(pid_t pid, int *statusp, int options); +#endif +#ifdef NEED_STRERROR +extern char *strerror (int err); +#endif +#ifdef NEED_DIFFTIME +extern double difftime(time_t time1, time_t time0); +#endif + +#ifndef ap_wait_t +#define ap_wait_t int +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* !AP_CONFIG_H */ diff --git a/APACHE_1_3_42/src/include/ap_ctype.h b/APACHE_1_3_42/src/include/ap_ctype.h new file mode 100644 index 0000000000..f29eeb5486 --- /dev/null +++ b/APACHE_1_3_42/src/include/ap_ctype.h @@ -0,0 +1,49 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef AP_CTYPE_H +#define AP_CTYPE_H + +#include <ctype.h> + +#ifdef __cplusplus +extern "C" { +#endif + +/* These macros allow correct support of 8-bit characters on systems which + * support 8-bit characters. Pretty dumb how the cast is required, but + * that's legacy libc for ya. These new macros do not support EOF like + * the standard macros do. Tough. + */ +#define ap_isalnum(c) (isalnum(((unsigned char)(c)))) +#define ap_isalpha(c) (isalpha(((unsigned char)(c)))) +#define ap_iscntrl(c) (iscntrl(((unsigned char)(c)))) +#define ap_isdigit(c) (isdigit(((unsigned char)(c)))) +#define ap_isgraph(c) (isgraph(((unsigned char)(c)))) +#define ap_islower(c) (islower(((unsigned char)(c)))) +#define ap_isprint(c) (isprint(((unsigned char)(c)))) +#define ap_ispunct(c) (ispunct(((unsigned char)(c)))) +#define ap_isspace(c) (isspace(((unsigned char)(c)))) +#define ap_isupper(c) (isupper(((unsigned char)(c)))) +#define ap_isxdigit(c) (isxdigit(((unsigned char)(c)))) +#define ap_tolower(c) (tolower(((unsigned char)(c)))) +#define ap_toupper(c) (toupper(((unsigned char)(c)))) + +#ifdef __cplusplus +} +#endif + +#endif /* !AP_CTYPE_H */ diff --git a/APACHE_1_3_42/src/include/ap_ebcdic.h b/APACHE_1_3_42/src/include/ap_ebcdic.h new file mode 100644 index 0000000000..e5e95ec057 --- /dev/null +++ b/APACHE_1_3_42/src/include/ap_ebcdic.h @@ -0,0 +1,27 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef AP_EBCDIC_H +#define AP_EBCDIC_H "$Id$" + +#include <sys/types.h> + +extern const unsigned char os_toascii[256]; +extern const unsigned char os_toebcdic[256]; +API_EXPORT(void *) ebcdic2ascii(void *dest, const void *srce, size_t count); +API_EXPORT(void *) ascii2ebcdic(void *dest, const void *srce, size_t count); + +#endif /*AP_EBCDIC_H*/ diff --git a/APACHE_1_3_42/src/include/ap_md5.h b/APACHE_1_3_42/src/include/ap_md5.h new file mode 100644 index 0000000000..5734185eba --- /dev/null +++ b/APACHE_1_3_42/src/include/ap_md5.h @@ -0,0 +1,89 @@ +/* + * This is work is derived from material Copyright RSA Data Security, Inc. + * + * The RSA copyright statement and Licence for that original material is + * included below. This is followed by the Apache copyright statement and + * licence for the modifications made to that material. + */ + +/* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All + rights reserved. + + License to copy and use this software is granted provided that it + is identified as the "RSA Data Security, Inc. MD5 Message-Digest + Algorithm" in all material mentioning or referencing this software + or this function. + + License is also granted to make and use derivative works provided + that such works are identified as "derived from the RSA Data + Security, Inc. MD5 Message-Digest Algorithm" in all material + mentioning or referencing the derived work. + + RSA Data Security, Inc. makes no representations concerning either + the merchantability of this software or the suitability of this + software for any particular purpose. It is provided "as is" + without express or implied warranty of any kind. + + These notices must be retained in any copies of any part of this + documentation and/or software. + */ + +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef APACHE_MD5_H +#define APACHE_MD5_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* MD5.H - header file for MD5C.C */ + +#define MD5_DIGESTSIZE 16 + +/* UINT4 defines a four byte word */ +typedef unsigned int UINT4; + +/* MD5 context. */ +typedef struct { + UINT4 state[4]; /* state (ABCD) */ + UINT4 count[2]; /* number of bits, modulo 2^64 (lsb first) */ + unsigned char buffer[64]; /* input buffer */ +} AP_MD5_CTX; + +/* + * Define the Magic String prefix that identifies a password as being + * hashed using our algorithm. + */ +#define AP_MD5PW_ID "$apr1$" +#define AP_MD5PW_IDLEN 6 + +API_EXPORT(void) ap_MD5Init(AP_MD5_CTX *context); +API_EXPORT(void) ap_MD5Update(AP_MD5_CTX *context, const unsigned char *input, + unsigned int inputLen); +API_EXPORT(void) ap_MD5Final(unsigned char digest[MD5_DIGESTSIZE], + AP_MD5_CTX *context); +API_EXPORT(void) ap_MD5Encode(const unsigned char *password, + const unsigned char *salt, + char *result, size_t nbytes); +API_EXPORT(void) ap_to64(char *s, unsigned long v, int n); + +#ifdef __cplusplus +} +#endif + +#endif /* !APACHE_MD5_H */ diff --git a/APACHE_1_3_42/src/include/ap_mmn.h b/APACHE_1_3_42/src/include/ap_mmn.h new file mode 100644 index 0000000000..0b8acc199c --- /dev/null +++ b/APACHE_1_3_42/src/include/ap_mmn.h @@ -0,0 +1,239 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef APACHE_AP_MMN_H +#define APACHE_AP_MMN_H + +/* + * MODULE_MAGIC_NUMBER_MAJOR + * Major API changes that could cause compatibility problems for older modules + * such as structure size changes. No binary compatibility is possible across + * a change in the major version. + * + * MODULE_MAGIC_NUMBER_MINOR + * Minor API changes that do not cause binary compatibility problems. + * Should be reset to 0 when upgrading MODULE_MAGIC_NUMBER_MAJOR. + * + * See the MODULE_MAGIC_AT_LEAST macro below for an example. + */ + +/* + * 19950525 - original value + * 19960512 (1.1b2) - updated, 1.1, version. + * 19960526 (1.1b3) - get_token(), table_unset(), pstrndup() + * functions added + * 19960725 (1.2-dev) - HTTP/1.1 compliance + * (new version of read_client_block) + * 19960806 (1.2-dev) - scan_script_header_err() added + * 19961007 (1.2-dev) - replace read_client_block() with get_client_block() + * 19961125 (1.2b1) - change setup_client_block() to Roy's version + * 19961211 (1.2b3) - rwrite() added + * 19970103 (1.2b5-dev) - header parse API + * 19970427 (1.2b9-dev) - port references made unsigned + * 19970526 (1.2) - correct vhost walk for multiple requests on a single + * connect + * 19970623 (1.3-dev) - NT changes + * 19970628 (1.3-dev) - ap_slack (fd fixes) added + * 19970717 (1.3-dev) - child_init API hook added + * 19970719 (1.3-dev) - discard_request_body() added (to clear the decks + * as needed) + * 19970728 (1.3a2-dev) - child_exit API hook added + * 19970818 (1.3a2-dev) - post read-request phase added + * 19970825 (1.3a2-dev) - r->mtime cell added + * 19970831 (1.3a2-dev) - error logging changed to use aplog_error() + * 19970902 (1.3a2-dev) - MD5 routines and structures renamed to ap_* + * 19970912 (1.3b1-dev) - set_last_modified split into set_last_modified, + * set_etag and meets_conditions + * register_other_child API + * piped_log API + * short_score split into parent and child pieces + * os_is_absolute_path + * 19971026 (1.3b3-dev) - custom config hooks in place + * 19980126 (1.3b4-dev) - ap_cpystrn(), table_addn(), table_setn(), + * table_mergen() + * 19980201 (1.3b4-dev) - construct_url() + * prototype server_rec * -> request_rec * + * add get_server_name() and get_server_port() + * 19980207 (1.3b4-dev) - add dynamic_load_handle to module structure as part + * of the STANDARD_MODULE_STUFF header + * 19980304 (1.3b6-dev) - abstraction of SERVER_BUILT and SERVER_VERSION + * 19980305 (1.3b6-dev) - ap_config.h added for use by external modules + * 19980312 (1.3b6-dev) - parse_uri_components() and its ilk + * remove r->hostlen, add r->unparsed_uri + * set_string_slot_lower() + * clarification: non-RAW_ARGS cmd handlers do not + * need to pstrdup() their arguments + * clarification: request_rec members content_type, + * handler, content_encoding, content_language, + * content_languages MUST all be lowercase strings, + * and MAY NOT be modified in place -- modifications + * require pstrdup(). + * 19980317 (1.3b6-dev) - CORE_EXPORTs for win32 and <Perl> + * API export basic_http_header, send_header_field, + * set_keepalive, srm_command_loop, check_cmd_context, + * tm2sec + * spacetoplus(), plustospace(), client_to_stdout() + * removed + * 19980324 (1.3b6-dev) - API_EXPORT(index_of_response) + * 19980413 (1.3b6-dev) - The BIG SYMBOL RENAMING: general ap_ prefix + * (see src/include/compat.h for more details) + * ap_vformatter() API, see src/include/ap.h + * 19980507 (1.3b7-dev) - addition of ap_add_version_component() and + * discontinuation of -DSERVER_SUBVERSION support + * 19980519 (1.3b7-dev) - add child_info * to spawn function (as passed to + * ap_spawn_child_err_buff) and to ap_call_exec to make + * children work correctly on Win32. + * 19980527 (1.3b8-dev) - renamed some more functions to ap_ prefix which were + * missed at the big renaming (they are defines): + * is_default_port, default_port and http_method. + * A new communication method for modules was added: + * they can create customized error messages under the + * "error-notes" key in the request_rec->notes table. + * This string will be printed in place of the canned + * error responses, and will be propagated to + * ErrorDocuments or cgi scripts in the + * (REDIRECT_)ERROR_NOTES variable. + * 19980627 (1.3.1-dev) - More renaming that we forgot/bypassed. In particular: + * table_elts --> ap_table_elts + * is_table_empty --> ap_is_table_empty + * 19980708 (1.3.1-dev) - ap_isalnum(), ap_isalpha(), ... "8-bit safe" ctype + * macros and apctype.h added + * 19980713 (1.3.1-dev) - renaming of C header files: + * 1. conf.h -> ap_config.h + * 2. conf_auto.h -> ap_config_auto.h - now merged + * 3. ap_config.h -> ap_config_auto.h - now merged + * 4. compat.h -> ap_compat.h + * 5. apctype.h -> ap_ctype.h + * 19980806 (1.3.2-dev) - add ap_log_rerror() + * - add ap_scan_script_header_err_core() + * - add ap_uuencode() + * - add ap_custom_response() + * 19980811 (1.3.2-dev) - added limit_req_line, limit_req_fieldsize, and + * limit_req_fields to server_rec. + * added limit_req_body to core_dir_config and + * ap_get_limit_req_body() to get its value. + * 19980812 (1.3.2-dev) - split off MODULE_MAGIC_NUMBER + * 19980812.2 - add ap_overlap_tables() + * 19980816 (1.3.2-dev) - change proxy to use tables for headers, change + * struct cache_req to typedef cache_req. + * Delete ap_proxy_get_header(), ap_proxy_add_header(), + * ap_proxy_del_header(). Change interface of + * ap_proxy_send_fb() and ap_proxy_cache_error(). + * Add ap_proxy_send_hdr_line() and ap_proxy_bputs2(). + * 19980825 (1.3.2-dev) - renamed is_HTTP_xxx() macros to ap_is_HTTP_xxx() + * 19980825.1 - mod_proxy only (minor change): modified interface of + * ap_proxy_read_headers() and rdcache() to use a + * request_rec* instead of pool* + * (for implementing better error reporting). + * 19980906 (1.3.2-dev) - added ap_md5_binary() + * 19980917 (1.3.2-dev) - bs2000: changed os_set_authfile() to os_set_account() + * 19981108 (1.3.4-dev) - added ap_method_number_of() + * - changed value of M_INVALID and added WebDAV methods + * 19981108.1 - ap_exists_config_define() is now public (minor bump) + * 19981204 - scoreboard changes -- added generation, changed + * exit_generation to running_generation. Somewhere + * earlier vhostrec was added, but it's only safe to use + * as of this rev. See scoreboard.h for documentation. + * 19981211 - DSO changes -- added ap_single_module_configure() + * -- added ap_single_module_init() + * 19981229 - mod_negotiation overhaul -- added ap_make_etag() + * and added vlist_validator to request_rec. + * 19990101 - renamed macro escape_uri() to ap_escape_uri() + * - added MODULE_MAGIC_COOKIE to identify module structs + * 19990103 (1.3.4-dev) - added ap_array_pstrcat() + * 19990105 (1.3.4-dev) - added ap_os_is_filename_valid() + * 19990106 (1.3.4-dev) - Move MODULE_MAGIC_COOKIE to the end of the + * STANDARD_MODULE_STUFF macro so the version + * numbers and file name remain at invariant offsets + * 19990108 (1.3.4-dev) - status_drops_connection -> ap_status_drops_connection + * scan_script_header -> ap_scan_script_header_err + * - reordered entries in request_rec that were waiting + * for a non-binary-compatible release. + * (1.3.5-dev) + * 19990108.1 - add ap_MD5Encode() for MD5 password handling. + * 19990108.2 - add ap_validate_password() and change ap_MD5Encode() + * to use a stronger algorithm. + * 19990108.4 - add ap_size_list_item(), ap_get_list_item(), and + * ap_find_list_item() + * 19990108.5 - added ap_sub_req_method_uri() and added const to the + * definition of method in request_rec. + * 19990108.6 - SIGPIPE is now ignored by the core server. + * 19990108.7 - ap_isxdigit added + * 19990320 - METHODS and M_INVALID symbol values modified + * 19990320.1 - add ap_vrprintf() + * 19990320.2 - add cmd_parms.context, ap_set_config_vectors, + * export ap_add_file_conf + * 19990320.3 - add ap_regexec() and ap_regerror() + * 19990320.4 - add ap_field_noparam() + * 19990320.5 - add local_ip/host to conn_rec for mass-vhost + * 19990320.6 - add ap_SHA1Final(), ap_SHA1Init(), + * ap_SHA1Update_binary(), ap_SHA1Update(), + * ap_base64encode(), ap_base64encode_binary(), + * ap_base64encode_len(), ap_base64decode(), + * ap_base64decode_binary(), ap_base64decode_len(), + * ap_pbase64decode(), ap_pbase64encode() + * 19990320.7 - add ap_strcasestr() + * 19990320.8 - add request_rec.case_preserved_filename + * 19990320.9 - renamed alloc.h to ap_alloc.h + * 19990320.10 - add ap_is_rdirectory() and ap_stripprefix() + * 19990320.11 - Add a couple of fields, callback_data and + * filter_callback to the end of buff.h + * 19990320.11 - Add some fields to the end of the core_dir_config + * structure + * 19990320.12 - add ap_getline(), ap_get_chunk_size() + * 19990320.13 - add ap_strtol() + * 19990320.14 - add ap_register_cleanup_ex(), + * ap_note_cleanups_for_fd_ex(), + * ap_note_cleanups_for_socket_ex(), + * ap_note_cleanups_for_file_ex(), + * ap_popenf_ex() and ap_psocket_ex(). + * 19990320.15 - ap_is_recursion_limit_exceeded() + * 19990320.16 - ap_escape_errorlog_item() + * 19990320.17 - ap_auth_nonce() and ap_auth_nonce added + * in core_dir_config. + * 19990320.18 - trace_enable member added to core server_config + */ + +#define MODULE_MAGIC_COOKIE 0x41503133UL /* "AP13" */ + +#ifndef MODULE_MAGIC_NUMBER_MAJOR +#define MODULE_MAGIC_NUMBER_MAJOR 19990320 +#endif +#define MODULE_MAGIC_NUMBER_MINOR 18 /* 0...n */ + +/* Useful for testing for features. */ +#define AP_MODULE_MAGIC_AT_LEAST(major,minor) \ + ((major) < MODULE_MAGIC_NUMBER_MAJOR \ + || ((major) == MODULE_MAGIC_NUMBER_MAJOR \ + && (minor) <= MODULE_MAGIC_NUMBER_MINOR)) + +/* + * For example, suppose you wish to use the ap_overlap_tables + * function. You can do this: + * + * #if AP_MODULE_MAGIC_AT_LEAST(19980812,2) + * ... use ap_overlap_tables() + * #else + * ... alternative code which doesn't use ap_overlap_tables() + * #endif + * + */ + +/* deprecated. present for backwards compatibility */ +#define MODULE_MAGIC_NUMBER MODULE_MAGIC_NUMBER_MAJOR +#define MODULE_MAGIC_AT_LEAST old_broken_macro_we_hope_you_are_not_using + +#endif /* !APACHE_AP_MMN_H */ diff --git a/APACHE_1_3_42/src/include/ap_sha1.h b/APACHE_1_3_42/src/include/ap_sha1.h new file mode 100644 index 0000000000..1f2e13c16f --- /dev/null +++ b/APACHE_1_3_42/src/include/ap_sha1.h @@ -0,0 +1,64 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * NIST Secure Hash Algorithm + * heavily modified by Uwe Hollerbach uh@alumni.caltech edu + * from Peter C. Gutmann's implementation as found in + * Applied Cryptography by Bruce Schneier + * This code is hereby placed in the public domain + */ + +#ifndef APACHE_SHA1_H +#define APACHE_SHA1_H + +#ifdef __cplusplus +extern "C" { +#endif + +#define SHA_DIGESTSIZE 20 + +/* + * Define the Magic String prefix that identifies a password as being + * hashed using our algorithm. + */ +#define AP_SHA1PW_ID "{SHA}" +#define AP_SHA1PW_IDLEN 5 + +typedef unsigned long AP_LONG; /* a 32-bit quantity */ + +typedef struct { + AP_LONG digest[5]; /* message digest */ + AP_LONG count_lo, count_hi; /* 64-bit bit count */ + AP_LONG data[16]; /* SHA data buffer */ + int local; /* unprocessed amount in data */ +} AP_SHA1_CTX; + +API_EXPORT(void) ap_sha1_base64(const char *clear, int len, char *out); +API_EXPORT(void) ap_SHA1Init(AP_SHA1_CTX *context); +API_EXPORT(void) ap_SHA1Update(AP_SHA1_CTX *context, const char *input, + unsigned int inputLen); +API_EXPORT(void) ap_SHA1Update_binary(AP_SHA1_CTX *context, + const unsigned char *input, + unsigned int inputLen); +API_EXPORT(void) ap_SHA1Final(unsigned char digest[SHA_DIGESTSIZE], + AP_SHA1_CTX *context); + +#ifdef __cplusplus +} +#endif + +#endif /* !APACHE_SHA1_H */ diff --git a/APACHE_1_3_42/src/include/buff.h b/APACHE_1_3_42/src/include/buff.h new file mode 100644 index 0000000000..eeb2997fc5 --- /dev/null +++ b/APACHE_1_3_42/src/include/buff.h @@ -0,0 +1,207 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef APACHE_BUFF_H +#define APACHE_BUFF_H + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef B_SFIO +#include "sfio.h" +#endif + +#include <stdarg.h> + +/* Reading is buffered */ +#define B_RD (1) +/* Writing is buffered */ +#define B_WR (2) +#define B_RDWR (3) +/* At end of file, or closed stream; no further input allowed */ +#define B_EOF (4) +/* No further output possible */ +#define B_EOUT (8) +/* A read error has occurred */ +#define B_RDERR (16) +/* A write error has occurred */ +#define B_WRERR (32) +#ifdef B_ERROR /* in SVR4: sometimes defined in /usr/include/sys/buf.h */ +#undef B_ERROR +#endif +#define B_ERROR (48) +/* Use chunked writing */ +#define B_CHUNK (64) +/* bflush() if a read would block */ +#define B_SAFEREAD (128) +/* buffer is a socket */ +#define B_SOCKET (256) +#ifdef CHARSET_EBCDIC +#define B_ASCII2EBCDIC 0x40000000 /* Enable conversion for this buffer */ +#define B_EBCDIC2ASCII 0x80000000 /* Enable conversion for this buffer */ +#endif /*CHARSET_EBCDIC*/ + +typedef struct buff_struct BUFF; + +struct buff_struct { + int flags; /* flags */ + unsigned char *inptr; /* pointer to next location to read */ + int incnt; /* number of bytes left to read from input buffer; + * always 0 if had a read error */ + int outchunk; /* location of chunk header when chunking */ + int outcnt; /* number of byte put in output buffer */ + unsigned char *inbase; + unsigned char *outbase; + int bufsiz; + void (*error) (BUFF *fb, int op, void *data); + void *error_data; + long int bytes_sent; /* number of bytes actually written */ + + ap_pool *pool; + +/* could also put pointers to the basic I/O routines here */ + int fd; /* the file descriptor */ + int fd_in; /* input file descriptor, if different */ +#ifdef WIN32 + HANDLE hFH; /* Windows filehandle */ +#endif + + /* transport handle, for RPC binding handle or some such */ + void *t_handle; + +#ifdef B_SFIO + Sfio_t *sf_in; + Sfio_t *sf_out; +#endif + + void *callback_data; + void (*filter_callback)(BUFF *, const void *, int ); + +}; + +#ifdef B_SFIO +typedef struct { + Sfdisc_t disc; + BUFF *buff; +} apache_sfio; + +extern Sfdisc_t *bsfio_new(pool *p, BUFF *b); +#endif + +/* Options to bset/getopt */ +#define BO_BYTECT (1) + +/* Stream creation and modification */ +API_EXPORT(BUFF *) ap_bcreate(pool *p, int flags); +API_EXPORT(void) ap_bpushfd(BUFF *fb, int fd_in, int fd_out); +#ifdef WIN32 +API_EXPORT(void) ap_bpushh(BUFF *fb, HANDLE hFH); +#endif +API_EXPORT(int) ap_bsetopt(BUFF *fb, int optname, const void *optval); +API_EXPORT(int) ap_bgetopt(BUFF *fb, int optname, void *optval); +API_EXPORT(int) ap_bsetflag(BUFF *fb, int flag, int value); +API_EXPORT(int) ap_bclose(BUFF *fb); + +#define ap_bgetflag(fb, flag) ((fb)->flags & (flag)) + +/* Error handling */ +API_EXPORT(void) ap_bonerror(BUFF *fb, void (*error) (BUFF *, int, void *), + void *data); + +/* I/O */ +API_EXPORT(int) ap_bread(BUFF *fb, void *buf, int nbyte); +API_EXPORT(int) ap_bgets(char *s, int n, BUFF *fb); +API_EXPORT(int) ap_blookc(char *buff, BUFF *fb); +API_EXPORT(int) ap_bskiplf(BUFF *fb); +API_EXPORT(int) ap_bwrite(BUFF *fb, const void *buf, int nbyte); +API_EXPORT(int) ap_bflush(BUFF *fb); +API_EXPORT(int) ap_bputs(const char *x, BUFF *fb); +API_EXPORT_NONSTD(int) ap_bvputs(BUFF *fb,...); +API_EXPORT_NONSTD(int) ap_bprintf(BUFF *fb, const char *fmt,...) + __attribute__((format(printf,2,3))); +API_EXPORT(int) ap_vbprintf(BUFF *fb, const char *fmt, va_list vlist); + +/* Internal routines */ +API_EXPORT(int) ap_bflsbuf(int c, BUFF *fb); +API_EXPORT(int) ap_bfilbuf(BUFF *fb); + +#ifndef CHARSET_EBCDIC + +#define ap_bgetc(fb) ( ((fb)->incnt == 0) ? ap_bfilbuf(fb) : \ + ((fb)->incnt--, *((fb)->inptr++)) ) + +#define ap_bputc(c, fb) ((((fb)->flags & (B_EOUT|B_WRERR|B_WR)) != B_WR || \ + (fb)->outcnt == (fb)->bufsiz) ? ap_bflsbuf(c, (fb)) : \ + ((fb)->outbase[(fb)->outcnt++] = (c), 0)) + +#else /*CHARSET_EBCDIC*/ + +#define ap_bgetc(fb) ( ((fb)->incnt == 0) ? ap_bfilbuf(fb) : \ + ((fb)->incnt--, (fb->flags & B_ASCII2EBCDIC)\ + ?os_toebcdic[(unsigned char)*((fb)->inptr++)]:*((fb)->inptr++)) ) + +#define ap_bputc(c, fb) ((((fb)->flags & (B_EOUT|B_WRERR|B_WR)) != B_WR || \ + (fb)->outcnt == (fb)->bufsiz) ? ap_bflsbuf(c, (fb)) : \ + ((fb)->outbase[(fb)->outcnt++] = (fb->flags & B_EBCDIC2ASCII)\ + ?os_toascii[(unsigned char)c]:(c), 0)) + +#endif /*CHARSET_EBCDIC*/ +struct child_info { +#ifdef WIN32 + /* + * These handles are used by ap_call_exec to call + * create process with pipe handles. + */ + HANDLE hPipeInputRead; + HANDLE hPipeOutputWrite; + HANDLE hPipeErrorWrite; +#else + /* + * We need to put a dummy member in here to avoid compilation + * errors under certain Unix compilers, like SGI's and HPUX's, + * which fail to compile a zero-sized struct. Of course + * it would be much nicer if there was actually a use for this + * structure under Unix. Aah the joys of x-platform code. + */ + int dummy; +#endif +}; +API_EXPORT(int) ap_bspawn_child(pool *, int (*)(void *, child_info *), void *, + enum kill_conditions, BUFF **pipe_in, BUFF **pipe_out, + BUFF **pipe_err); + +/* enable non-blocking operations */ +API_EXPORT(int) ap_bnonblock(BUFF *fb, int direction); +/* and get an fd to select() on */ +API_EXPORT(int) ap_bfileno(BUFF *fb, int direction); + +/* bflush() if a read now would block, but don't actually read anything */ +API_EXPORT(void) ap_bhalfduplex(BUFF *fb); + +#if defined(WIN32) || defined(NETWARE) || defined(CYGWIN_WINSOCK) + +/* ap_recvwithtimeout/ap_sendwithtimeout socket primitives for WinSock */ +API_EXPORT(int) ap_sendwithtimeout(int sock, const char *buf, int len, int flags); +API_EXPORT(int) ap_recvwithtimeout(int sock, char *buf, int len, int flags); + +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* !APACHE_BUFF_H */ diff --git a/APACHE_1_3_42/src/include/compat.h b/APACHE_1_3_42/src/include/compat.h new file mode 100644 index 0000000000..8f360c8933 --- /dev/null +++ b/APACHE_1_3_42/src/include/compat.h @@ -0,0 +1,25 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * compat.h -- backward compatibility header for ap_compat.h + */ + +#ifdef __GNUC__ +#warning "This header is obsolete, use ap_compat.h instead" +#endif + +#include "ap_compat.h" diff --git a/APACHE_1_3_42/src/include/conf.h b/APACHE_1_3_42/src/include/conf.h new file mode 100644 index 0000000000..b669e576f4 --- /dev/null +++ b/APACHE_1_3_42/src/include/conf.h @@ -0,0 +1,25 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * conf.h -- backward compatibility header for ap_config.h + */ + +#ifdef __GNUC__ +#warning "This header is obsolete, use ap_config.h instead" +#endif + +#include "ap_config.h" diff --git a/APACHE_1_3_42/src/include/explain.h b/APACHE_1_3_42/src/include/explain.h new file mode 100644 index 0000000000..e01e48e4bc --- /dev/null +++ b/APACHE_1_3_42/src/include/explain.h @@ -0,0 +1,59 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef EXPLAIN +#define DEF_Explain +#define Explain0(f) +#define Explain1(f,a1) +#define Explain2(f,a1,a2) +#define Explain3(f,a1,a2,a3) +#define Explain4(f,a1,a2,a3,a4) +#define Explain5(f,a1,a2,a3,a4,a5) +#define Explain6(f,a1,a2,a3,a4,a5,a6) +#else +#include "http_log.h" +#define DEF_Explain +#define Explain0(f) \ + ap_log_error(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, NULL, \ + f) +#define Explain1(f,a1) \ + ap_log_error(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, NULL, \ + f,a1) +#define Explain2(f,a1,a2) \ + ap_log_error(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, NULL, \ + f,a1,a2) +#define Explain3(f,a1,a2,a3) \ + ap_log_error(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, NULL, \ + f,a1,a2,a3) +#define Explain4(f,a1,a2,a3,a4) \ + ap_log_error(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, NULL, \ + f,a1,a2,a3,a4) +#define Explain5(f,a1,a2,a3,a4,a5) \ + ap_log_error(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, NULL, \ + f,a1,a2,a3,a4,a5) +#define Explain6(f,a1,a2,a3,a4,a5,a6) \ + ap_log_error(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, NULL, \ + f,a1,a2,a3,a4,a5,a6) + +#endif + +#ifdef __cplusplus +} +#endif diff --git a/APACHE_1_3_42/src/include/fnmatch.h b/APACHE_1_3_42/src/include/fnmatch.h new file mode 100644 index 0000000000..d4fecf6504 --- /dev/null +++ b/APACHE_1_3_42/src/include/fnmatch.h @@ -0,0 +1,64 @@ +/*- + * Copyright (c) 1992, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)fnmatch.h 8.1 (Berkeley) 6/2/93 + */ + +/* This file has been modified by the Apache Group. */ + +#include "ap_config.h" + +#ifndef _FNMATCH_H_ +#define _FNMATCH_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#define FNM_NOMATCH 1 /* Match failed. */ + +#define FNM_NOESCAPE 0x01 /* Disable backslash escaping. */ +#define FNM_PATHNAME 0x02 /* Slash must be matched by slash. */ +#define FNM_PERIOD 0x04 /* Period must be matched by period. */ +/* This flag is an Apache addition */ +#define FNM_CASE_BLIND 0x08 /* Compare characters case-insensitively. */ + +API_EXPORT(int) ap_fnmatch(const char *, const char *, int); + +/* this function is an Apache addition */ +API_EXPORT(extern int) ap_is_fnmatch(const char *); + +#ifdef __cplusplus +} +#endif + +#endif /* !_FNMATCH_H_ */ diff --git a/APACHE_1_3_42/src/include/hsregex.h b/APACHE_1_3_42/src/include/hsregex.h new file mode 100644 index 0000000000..1253758c9f --- /dev/null +++ b/APACHE_1_3_42/src/include/hsregex.h @@ -0,0 +1,89 @@ +/* DON'T EVEN THINK ABOUT EDITING THIS, go see regex/Makefile, + * search for mkh */ +#ifndef _REGEX_H_ +#define _REGEX_H_ /* never again */ +/* ========= begin header generated by ./mkh ========= */ +#ifdef __cplusplus +extern "C" { +#endif + +/* === regex2.h === */ +#ifndef API_EXPORT +#ifdef WIN32 +#define API_EXPORT(type) __declspec(dllexport) type __stdcall +#else +#define API_EXPORT(type) type +#endif +#endif + +#if defined(MAC_OS) || defined(MAC_OS_X_SERVER) || (defined(DARWIN) && defined(__DYNAMIC__)) +#define ap_private_extern __private_extern__ +#else +#define ap_private_extern +#endif + +typedef off_t regoff_t; +typedef struct { + int re_magic; + size_t re_nsub; /* number of parenthesized subexpressions */ + const char *re_endp; /* end pointer for REG_PEND */ + struct re_guts *re_g; /* none of your business :-) */ +} regex_t; +typedef struct { + regoff_t rm_so; /* start of match */ + regoff_t rm_eo; /* end of match */ +} regmatch_t; + + +/* === regcomp.c === */ +API_EXPORT(int) regcomp(regex_t *, const char *, int); +#define REG_BASIC 0000 +#define REG_EXTENDED 0001 +#define REG_ICASE 0002 +#define REG_NOSUB 0004 +#define REG_NEWLINE 0010 +#define REG_NOSPEC 0020 +#define REG_PEND 0040 +#define REG_DUMP 0200 + + +/* === regerror.c === */ +#define REG_NOMATCH 1 +#define REG_BADPAT 2 +#define REG_ECOLLATE 3 +#define REG_ECTYPE 4 +#define REG_EESCAPE 5 +#define REG_ESUBREG 6 +#define REG_EBRACK 7 +#define REG_EPAREN 8 +#define REG_EBRACE 9 +#define REG_BADBR 10 +#define REG_ERANGE 11 +#define REG_ESPACE 12 +#define REG_BADRPT 13 +#define REG_EMPTY 14 +#define REG_ASSERT 15 +#define REG_INVARG 16 +#define REG_ATOI 255 /* convert name to number (!) */ +#define REG_ITOA 0400 /* convert number to name (!) */ +API_EXPORT(size_t) regerror(int, const regex_t *, char *, size_t); + + +/* === regexec.c === */ +API_EXPORT(int) regexec(const regex_t *, const char *, size_t, regmatch_t [], int); +#define REG_NOTBOL 00001 +#define REG_NOTEOL 00002 +#define REG_STARTEND 00004 +#define REG_TRACE 00400 /* tracing of execution */ +#define REG_LARGE 01000 /* force large representation */ +#define REG_BACKR 02000 /* force use of backref code */ + + +/* === regfree.c === */ +API_EXPORT(void) regfree(regex_t *); + +#ifdef __cplusplus +} +#endif +/* ========= end header generated by ./mkh ========= */ +#endif diff --git a/APACHE_1_3_42/src/include/http_conf_globals.h b/APACHE_1_3_42/src/include/http_conf_globals.h new file mode 100644 index 0000000000..ef94b5f48e --- /dev/null +++ b/APACHE_1_3_42/src/include/http_conf_globals.h @@ -0,0 +1,94 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef APACHE_HTTP_CONF_GLOBALS_H +#define APACHE_HTTP_CONF_GLOBALS_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Process config --- what the process ITSELF is doing + */ + +extern API_VAR_EXPORT int ap_standalone; +extern API_VAR_EXPORT int ap_configtestonly; +extern int ap_docrootcheck; +extern API_VAR_EXPORT uid_t ap_user_id; +extern API_VAR_EXPORT char *ap_user_name; +extern API_VAR_EXPORT gid_t ap_group_id; +#ifdef NETWARE +extern unsigned int ap_thread_stack_size; +#endif +#ifdef MULTIPLE_GROUPS +extern gid_t group_id_list[NGROUPS_MAX]; +#endif +extern API_VAR_EXPORT int ap_max_requests_per_child; +extern API_VAR_EXPORT int ap_threads_per_child; +extern API_VAR_EXPORT int ap_excess_requests_per_child; +extern API_VAR_EXPORT struct in_addr ap_bind_address; +extern listen_rec *ap_listeners; +extern API_VAR_EXPORT int ap_daemons_to_start; +extern API_VAR_EXPORT int ap_daemons_min_free; +extern API_VAR_EXPORT int ap_daemons_max_free; +extern API_VAR_EXPORT int ap_daemons_limit; +extern API_VAR_EXPORT int ap_suexec_enabled; +extern API_VAR_EXPORT int ap_listenbacklog; +#ifdef SO_ACCEPTFILTER +extern int ap_acceptfilter; +#endif +extern int ap_dump_settings; +extern API_VAR_EXPORT int ap_extended_status; + +extern API_VAR_EXPORT char *ap_pid_fname; +extern API_VAR_EXPORT char *ap_scoreboard_fname; +extern API_VAR_EXPORT char *ap_lock_fname; +extern API_VAR_EXPORT char *ap_server_argv0; +#ifdef AP_ENABLE_EXCEPTION_HOOK +extern int ap_exception_hook_enabled; +#endif + +extern enum server_token_type ap_server_tokens; + +extern API_VAR_EXPORT int ap_protocol_req_check; +extern API_VAR_EXPORT int ap_change_shmem_uid; + +/* Trying to allocate these in the config pool gets us into some *nasty* + * chicken-and-egg problems in http_main.c --- where do you stick them + * when pconf gets cleared? Better to just allocate a little space + * statically... + */ + +extern API_VAR_EXPORT char ap_server_root[MAX_STRING_LEN]; +extern API_VAR_EXPORT char ap_server_confname[MAX_STRING_LEN]; + +/* for -C, -c and -D switches */ +extern API_VAR_EXPORT array_header *ap_server_pre_read_config; +extern API_VAR_EXPORT array_header *ap_server_post_read_config; +extern API_VAR_EXPORT array_header *ap_server_config_defines; + +/* We want this to have the least chance of being corrupted if there + * is some memory corruption, so we allocate it statically. + */ +extern API_VAR_EXPORT char ap_coredump_dir[MAX_STRING_LEN]; +extern int ap_coredump_dir_configured; + +#ifdef __cplusplus +} +#endif + +#endif /* !APACHE_HTTP_CONF_GLOBALS_H */ diff --git a/APACHE_1_3_42/src/include/http_config.h b/APACHE_1_3_42/src/include/http_config.h new file mode 100644 index 0000000000..0830bef524 --- /dev/null +++ b/APACHE_1_3_42/src/include/http_config.h @@ -0,0 +1,374 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef APACHE_HTTP_CONFIG_H +#define APACHE_HTTP_CONFIG_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * The central data structures around here... + */ + +/* Command dispatch structures... */ + +/* Note that for all of these except RAW_ARGS, the config routine is + * passed a freshly allocated string which can be modified or stored + * or whatever... it's only necessary to do pstrdup() stuff with + * RAW_ARGS. + */ +enum cmd_how { + RAW_ARGS, /* cmd_func parses command line itself */ + TAKE1, /* one argument only */ + TAKE2, /* two arguments only */ + ITERATE, /* one argument, occuring multiple times + * (e.g., IndexIgnore) + */ + ITERATE2, /* two arguments, 2nd occurs multiple times + * (e.g., AddIcon) + */ + FLAG, /* One of 'On' or 'Off' */ + NO_ARGS, /* No args at all, e.g. </Directory> */ + TAKE12, /* one or two arguments */ + TAKE3, /* three arguments only */ + TAKE23, /* two or three arguments */ + TAKE123, /* one, two or three arguments */ + TAKE13 /* one or three arguments */ +}; + +typedef struct command_struct { + const char *name; /* Name of this command */ + const char *(*func) (); /* Function invoked */ + void *cmd_data; /* Extra data, for functions which + * implement multiple commands... + */ + int req_override; /* What overrides need to be allowed to + * enable this command. + */ + enum cmd_how args_how; /* What the command expects as arguments */ + + const char *errmsg; /* 'usage' message, in case of syntax errors */ +} command_rec; + +/* The allowed locations for a configuration directive are the union of + * those indicated by each set bit in the req_override mask. + * + * (req_override & RSRC_CONF) => *.conf outside <Directory> or <Location> + * (req_override & ACCESS_CONF) => *.conf inside <Directory> or <Location> + * (req_override & OR_AUTHCFG) => *.conf inside <Directory> or <Location> + * and .htaccess when AllowOverride AuthConfig + * (req_override & OR_LIMIT) => *.conf inside <Directory> or <Location> + * and .htaccess when AllowOverride Limit + * (req_override & OR_OPTIONS) => *.conf anywhere + * and .htaccess when AllowOverride Options + * (req_override & OR_FILEINFO) => *.conf anywhere + * and .htaccess when AllowOverride FileInfo + * (req_override & OR_INDEXES) => *.conf anywhere + * and .htaccess when AllowOverride Indexes + */ +#define OR_NONE 0 +#define OR_LIMIT 1 +#define OR_OPTIONS 2 +#define OR_FILEINFO 4 +#define OR_AUTHCFG 8 +#define OR_INDEXES 16 +#define OR_UNSET 32 +#define ACCESS_CONF 64 +#define RSRC_CONF 128 +#define OR_ALL (OR_LIMIT|OR_OPTIONS|OR_FILEINFO|OR_AUTHCFG|OR_INDEXES) + +/* This can be returned by a function if they don't wish to handle + * a command. Make it something not likely someone will actually use + * as an error code. + */ + +#define DECLINE_CMD "\a\b" + +/* + * This structure is passed to a command which is being invoked, + * to carry a large variety of miscellaneous data which is all of + * use to *somebody*... + */ + +typedef struct { + void *info; /* Argument to command from cmd_table */ + int override; /* Which allow-override bits are set */ + int limited; /* Which methods are <Limit>ed */ + + configfile_t *config_file; /* Config file structure from pcfg_openfile() */ + + ap_pool *pool; /* Pool to allocate new storage in */ + struct pool *temp_pool; /* Pool for scratch memory; persists during + * configuration, but wiped before the first + * request is served... + */ + server_rec *server; /* Server_rec being configured for */ + char *path; /* If configuring for a directory, + * pathname of that directory. + * NOPE! That's what it meant previous to the + * existance of <Files>, <Location> and regex + * matching. Now the only usefulness that can + * be derived from this field is whether a command + * is being called in a server context (path == NULL) + * or being called in a dir context (path != NULL). + */ + const command_rec *cmd; /* configuration command */ + const char *end_token; /* end token required to end a nested section */ + void *context; /* per_dir_config vector passed + * to handle_command */ +} cmd_parms; + +/* This structure records the existence of handlers in a module... */ + +typedef struct { + const char *content_type; /* MUST be all lower case */ + int (*handler) (request_rec *); +} handler_rec; + +/* + * Module structures. Just about everything is dispatched through + * these, directly or indirectly (through the command and handler + * tables). + */ + +typedef struct module_struct { + int version; /* API version, *not* module version; + * check that module is compatible with this + * version of the server. + */ + int minor_version; /* API minor version. Provides API feature + * milestones. Not checked during module init + */ + int module_index; /* Index to this modules structures in + * config vectors. + */ + + const char *name; + void *dynamic_load_handle; + + struct module_struct *next; + + unsigned long magic; /* Magic Cookie to identify a module structure; + * It's mainly important for the DSO facility + * (see also mod_so). + */ + + /* init() occurs after config parsing, but before any children are + * forked. + * Modules should not rely on the order in which create_server_config + * and create_dir_config are called. + */ +#ifdef ULTRIX_BRAIN_DEATH + void (*init) (); + void *(*create_dir_config) (); + void *(*merge_dir_config) (); + void *(*create_server_config) (); + void *(*merge_server_config) (); +#else + void (*init) (server_rec *, pool *); + void *(*create_dir_config) (pool *p, char *dir); + void *(*merge_dir_config) (pool *p, void *base_conf, void *new_conf); + void *(*create_server_config) (pool *p, server_rec *s); + void *(*merge_server_config) (pool *p, void *base_conf, void *new_conf); +#endif + + const command_rec *cmds; + const handler_rec *handlers; + + /* Hooks for getting into the middle of server ops... + + * translate_handler --- translate URI to filename + * access_checker --- check access by host address, etc. All of these + * run; if all decline, that's still OK. + * check_user_id --- get and validate user id from the HTTP request + * auth_checker --- see if the user (from check_user_id) is OK *here*. + * If all of *these* decline, the request is rejected + * (as a SERVER_ERROR, since the module which was + * supposed to handle this was configured wrong). + * type_checker --- Determine MIME type of the requested entity; + * sets content_type, _encoding and _language fields. + * logger --- log a transaction. + * post_read_request --- run right after read_request or internal_redirect, + * and not run during any subrequests. + */ + + int (*translate_handler) (request_rec *); + int (*ap_check_user_id) (request_rec *); + int (*auth_checker) (request_rec *); + int (*access_checker) (request_rec *); + int (*type_checker) (request_rec *); + int (*fixer_upper) (request_rec *); + int (*logger) (request_rec *); + int (*header_parser) (request_rec *); + + /* Regardless of the model the server uses for managing "units of + * execution", i.e. multi-process, multi-threaded, hybrids of those, + * there is the concept of a "heavy weight process". That is, a + * process with its own memory space, file spaces, etc. This method, + * child_init, is called once for each heavy-weight process before + * any requests are served. Note that no provision is made yet for + * initialization per light-weight process (i.e. thread). The + * parameters passed here are the same as those passed to the global + * init method above. + */ +#ifdef ULTRIX_BRAIN_DEATH + void (*child_init) (); + void (*child_exit) (); +#else + void (*child_init) (server_rec *, pool *); + void (*child_exit) (server_rec *, pool *); +#endif + int (*post_read_request) (request_rec *); +} module; + +/* Initializer for the first few module slots, which are only + * really set up once we start running. Note that the first two slots + * provide a version check; this should allow us to deal with changes to + * the API. The major number should reflect changes to the API handler table + * itself or removal of functionality. The minor number should reflect + * additions of functionality to the existing API. (the server can detect + * an old-format module, and either handle it back-compatibly, or at least + * signal an error). See src/include/ap_mmn.h for MMN version history. + */ + +#define STANDARD_MODULE_STUFF MODULE_MAGIC_NUMBER_MAJOR, \ + MODULE_MAGIC_NUMBER_MINOR, \ + -1, \ + __FILE__, \ + NULL, \ + NULL, \ + MODULE_MAGIC_COOKIE + +/* Generic accessors for other modules to get at their own module-specific + * data + */ + +API_EXPORT(void *) ap_get_module_config(void *conf_vector, module *m); +API_EXPORT(void) ap_set_module_config(void *conf_vector, module *m, void *val); + +#define ap_get_module_config(v,m) \ + (((void **)(v))[(m)->module_index]) +#define ap_set_module_config(v,m,val) \ + ((((void **)(v))[(m)->module_index]) = (val)) + +/* Generic command handling function... */ + +API_EXPORT_NONSTD(const char *) ap_set_string_slot(cmd_parms *, char *, char *); +API_EXPORT_NONSTD(const char *) ap_set_string_slot_lower(cmd_parms *, char *, char *); +API_EXPORT_NONSTD(const char *) ap_set_flag_slot(cmd_parms *, char *, int); +API_EXPORT_NONSTD(const char *) ap_set_file_slot(cmd_parms *, char *, char *); + +/* For modules which need to read config files, open logs, etc. ... + * this returns the fname argument if it begins with '/'; otherwise + * it relativizes it wrt server_root. + */ + +API_EXPORT(char *) ap_server_root_relative(pool *p, char *fname); + +/* Finally, the hook for dynamically loading modules in... */ + +API_EXPORT(void) ap_add_module(module *m); +API_EXPORT(void) ap_remove_module(module *m); +API_EXPORT(void) ap_add_loaded_module(module *mod); +API_EXPORT(void) ap_remove_loaded_module(module *mod); +API_EXPORT(int) ap_add_named_module(const char *name); +API_EXPORT(void) ap_clear_module_list(void); +API_EXPORT(const char *) ap_find_module_name(module *m); +API_EXPORT(module *) ap_find_linked_module(const char *name); + +/* for implementing subconfigs and customized config files */ +API_EXPORT(const char *) ap_srm_command_loop(cmd_parms *parms, void *config); + +#ifdef CORE_PRIVATE + +extern API_VAR_EXPORT module *top_module; + +extern module *ap_prelinked_modules[]; +extern module *ap_preloaded_modules[]; +extern API_VAR_EXPORT module **ap_loaded_modules; + +/* For mod_so.c... */ + +API_EXPORT(void) ap_single_module_configure(pool *p, server_rec *s, module *m); + +/* For http_main.c... */ + +API_EXPORT(server_rec *) ap_read_config(pool *conf_pool, pool *temp_pool, char *config_name); +API_EXPORT(void) ap_init_modules(pool *p, server_rec *s); +API_EXPORT(void) ap_child_init_modules(pool *p, server_rec *s); +API_EXPORT(void) ap_child_exit_modules(pool *p, server_rec *s); +API_EXPORT(void) ap_setup_prelinked_modules(void); +API_EXPORT(void) ap_show_directives(void); +API_EXPORT(void) ap_show_modules(void); +void ap_cleanup_method_ptrs(void); + +/* For http_request.c... */ + +CORE_EXPORT(void *) ap_create_request_config(pool *p); +CORE_EXPORT(void *) ap_create_per_dir_config(pool *p); +CORE_EXPORT(void *) ap_merge_per_dir_configs(pool *p, void *base, void *new); + +/* For http_core.c... (<Directory> command and virtual hosts) */ + +CORE_EXPORT(int) ap_parse_htaccess(void **result, request_rec *r, int override, + const char *path, const char *access_name); + +CORE_EXPORT(const char *) ap_init_virtual_host(pool *p, const char *hostname, + server_rec *main_server, server_rec **); +CORE_EXPORT(void) ap_process_resource_config(server_rec *s, char *fname, pool *p, pool *ptemp); + +/* ap_check_cmd_context() definitions: */ +API_EXPORT(const char *) ap_check_cmd_context(cmd_parms *cmd, unsigned forbidden); + +/* ap_check_cmd_context(): Forbidden in: */ +#define NOT_IN_VIRTUALHOST 0x01 /* <Virtualhost> */ +#define NOT_IN_LIMIT 0x02 /* <Limit> */ +#define NOT_IN_DIRECTORY 0x04 /* <Directory> */ +#define NOT_IN_LOCATION 0x08 /* <Location> */ +#define NOT_IN_FILES 0x10 /* <Files> */ +#define NOT_IN_DIR_LOC_FILE (NOT_IN_DIRECTORY|NOT_IN_LOCATION|NOT_IN_FILES) /* <Directory>/<Location>/<Files>*/ +#define GLOBAL_ONLY (NOT_IN_VIRTUALHOST|NOT_IN_LIMIT|NOT_IN_DIR_LOC_FILE) + + +/* Module-method dispatchers, also for http_request.c */ + +API_EXPORT(int) ap_translate_name(request_rec *); +API_EXPORT(int) ap_check_access(request_rec *); /* check access on non-auth basis */ +API_EXPORT(int) ap_check_user_id(request_rec *); /* obtain valid username from client auth */ +API_EXPORT(int) ap_check_auth(request_rec *); /* check (validated) user is authorized here */ +API_EXPORT(int) ap_find_types(request_rec *); /* identify MIME type */ +API_EXPORT(int) ap_run_fixups(request_rec *); /* poke around for other metainfo, etc.... */ +API_EXPORT(int) ap_invoke_handler(request_rec *); +API_EXPORT(int) ap_log_transaction(request_rec *r); +API_EXPORT(int) ap_header_parse(request_rec *); +API_EXPORT(int) ap_run_post_read_request(request_rec *); + +/* for mod_perl */ + +CORE_EXPORT(const command_rec *) ap_find_command(const char *name, const command_rec *cmds); +CORE_EXPORT(const command_rec *) ap_find_command_in_modules(const char *cmd_name, module **mod); +CORE_EXPORT(void *) ap_set_config_vectors(cmd_parms *parms, void *config, module *mod); +CORE_EXPORT(const char *) ap_handle_command(cmd_parms *parms, void *config, const char *l); + +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* !APACHE_HTTP_CONFIG_H */ diff --git a/APACHE_1_3_42/src/include/http_core.h b/APACHE_1_3_42/src/include/http_core.h new file mode 100644 index 0000000000..bbe2bb6d2f --- /dev/null +++ b/APACHE_1_3_42/src/include/http_core.h @@ -0,0 +1,375 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef APACHE_HTTP_CORE_H +#define APACHE_HTTP_CORE_H + +#ifdef __cplusplus +extern "C" { +#endif + +/***************************************************************** + * + * The most basic server code is encapsulated in a single module + * known as the core, which is just *barely* functional enough to + * serve documents, though not terribly well. + * + * Largely for NCSA back-compatibility reasons, the core needs to + * make pieces of its config structures available to other modules. + * The accessors are declared here, along with the interpretation + * of one of them (allow_options). + */ + +#define OPT_NONE 0 +#define OPT_INDEXES 1 +#define OPT_INCLUDES 2 +#define OPT_SYM_LINKS 4 +#define OPT_EXECCGI 8 +#define OPT_UNSET 16 +#define OPT_INCNOEXEC 32 +#define OPT_SYM_OWNER 64 +#define OPT_MULTI 128 +#define OPT_ALL (OPT_INDEXES|OPT_INCLUDES|OPT_SYM_LINKS|OPT_EXECCGI) + +/* options for get_remote_host() */ +/* REMOTE_HOST returns the hostname, or NULL if the hostname + * lookup fails. It will force a DNS lookup according to the + * HostnameLookups setting. + */ +#define REMOTE_HOST (0) + +/* REMOTE_NAME returns the hostname, or the dotted quad if the + * hostname lookup fails. It will force a DNS lookup according + * to the HostnameLookups setting. + */ +#define REMOTE_NAME (1) + +/* REMOTE_NOLOOKUP is like REMOTE_NAME except that a DNS lookup is + * never forced. + */ +#define REMOTE_NOLOOKUP (2) + +/* REMOTE_DOUBLE_REV will always force a DNS lookup, and also force + * a double reverse lookup, regardless of the HostnameLookups + * setting. The result is the (double reverse checked) hostname, + * or NULL if any of the lookups fail. + */ +#define REMOTE_DOUBLE_REV (3) + +#define SATISFY_ALL 0 +#define SATISFY_ANY 1 +#define SATISFY_NOSPEC 2 + +/* default maximum of internal redirects */ +# define AP_DEFAULT_MAX_INTERNAL_REDIRECTS 20 + +/* default maximum subrequest nesting level */ +# define AP_DEFAULT_MAX_SUBREQ_DEPTH 20 + +API_EXPORT(int) ap_allow_options (request_rec *); +API_EXPORT(int) ap_allow_overrides (request_rec *); +API_EXPORT(const char *) ap_default_type (request_rec *); +API_EXPORT(const char *) ap_document_root (request_rec *); /* Don't use this! If your request went + * through a Userdir, or something like + * that, it'll screw you. But it's + * back-compatible... + */ +API_EXPORT(const char *) ap_get_remote_host(conn_rec *conn, void *dir_config, int type); +API_EXPORT(const char *) ap_get_remote_logname(request_rec *r); + +/* Used for constructing self-referencing URLs, and things like SERVER_PORT, + * and SERVER_NAME. + */ +API_EXPORT(char *) ap_construct_url(pool *p, const char *uri, request_rec *r); +API_EXPORT(const char *) ap_get_server_name(request_rec *r); +API_EXPORT(unsigned) ap_get_server_port(const request_rec *r); +API_EXPORT(unsigned long) ap_get_limit_req_body(const request_rec *r); +API_EXPORT(void) ap_custom_response(request_rec *r, int status, char *string); +API_EXPORT(int) ap_exists_config_define(char *name); + +/* Check if the current request is beyond the configured max. number of redirects or subrequests + * @param r The current request + * @return true (is exceeded) or false + */ +API_EXPORT(int) ap_is_recursion_limit_exceeded(const request_rec *r); + +/* Authentication stuff. This is one of the places where compatibility + * with the old config files *really* hurts; they don't discriminate at + * all between different authentication schemes, meaning that we need + * to maintain common state for all of them in the core, and make it + * available to the other modules through interfaces. + */ + +typedef struct { + int method_mask; + char *requirement; +} require_line; + +API_EXPORT(const char *) ap_auth_type (request_rec *); +API_EXPORT(const char *) ap_auth_name (request_rec *); +API_EXPORT(const char *) ap_auth_nonce (request_rec *); +API_EXPORT(int) ap_satisfies (request_rec *r); +API_EXPORT(const array_header *) ap_requires (request_rec *); + +#ifdef WIN32 +/* + * CGI Script stuff for Win32... + */ +typedef enum { eFileTypeUNKNOWN, eFileTypeBIN, eFileTypeEXE16, eFileTypeEXE32, + eFileTypeSCRIPT, eCommandShell16, eCommandShell32 } file_type_e; +typedef enum { INTERPRETER_SOURCE_UNSET, INTERPRETER_SOURCE_REGISTRY, + INTERPRETER_SOURCE_SHEBANG } interpreter_source_e; +API_EXPORT(file_type_e) ap_get_win32_interpreter(const request_rec *, char **); +#endif + +#ifdef CORE_PRIVATE + +/* + * Core is also unlike other modules in being implemented in more than + * one file... so, data structures are declared here, even though most of + * the code that cares really is in http_core.c. Also, another accessor. + */ + +API_EXPORT(char *) ap_response_code_string (request_rec *r, int error_index); + +extern API_VAR_EXPORT module core_module; + +/* Per-directory configuration */ + +typedef unsigned char allow_options_t; +typedef unsigned char overrides_t; +/* + * Bits of info that go into making an ETag for a file + * document. Why a long? Because char historically + * proved too short for Options, and int can be different + * sizes on different platforms. + */ +typedef unsigned long etag_components_t; + +#define ETAG_UNSET 0 +#define ETAG_NONE (1 << 0) +#define ETAG_MTIME (1 << 1) +#define ETAG_INODE (1 << 2) +#define ETAG_SIZE (1 << 3) +#define ETAG_BACKWARD (ETAG_MTIME | ETAG_INODE | ETAG_SIZE) +#define ETAG_ALL (ETAG_MTIME | ETAG_INODE | ETAG_SIZE) + +typedef enum { + AP_FLAG_UNSET = 0, + AP_FLAG_ON = 1, + AP_FLAG_OFF = 2 +} ap_flag_e; + +typedef struct { + /* path of the directory/regex/etc. see also d_is_fnmatch below */ + char *d; + /* the number of slashes in d */ + unsigned d_components; + + /* If (opts & OPT_UNSET) then no absolute assignment to options has + * been made. + * invariant: (opts_add & opts_remove) == 0 + * Which said another way means that the last relative (options + or -) + * assignment made to each bit is recorded in exactly one of opts_add + * or opts_remove. + */ + allow_options_t opts; + allow_options_t opts_add; + allow_options_t opts_remove; + overrides_t override; + + /* MIME typing --- the core doesn't do anything at all with this, + * but it does know what to slap on a request for a document which + * goes untyped by other mechanisms before it slips out the door... + */ + + char *ap_default_type; + + /* Authentication stuff. Groan... */ + + int satisfy; + char *ap_auth_type; + char *ap_auth_name; + array_header *ap_requires; + + /* Custom response config. These can contain text or a URL to redirect to. + * if response_code_strings is NULL then there are none in the config, + * if it's not null then it's allocated to sizeof(char*)*RESPONSE_CODES. + * This lets us do quick merges in merge_core_dir_configs(). + */ + + char **response_code_strings; /* from ErrorDocument, not from + * ap_custom_response() + */ + + /* Hostname resolution etc */ +#define HOSTNAME_LOOKUP_OFF 0 +#define HOSTNAME_LOOKUP_ON 1 +#define HOSTNAME_LOOKUP_DOUBLE 2 +#define HOSTNAME_LOOKUP_UNSET 3 + unsigned int hostname_lookups : 4; + + signed int do_rfc1413 : 2; /* See if client is advertising a username? */ + + signed int content_md5 : 2; /* calculate Content-MD5? */ + +#define USE_CANONICAL_NAME_OFF (0) +#define USE_CANONICAL_NAME_ON (1) +#define USE_CANONICAL_NAME_DNS (2) +#define USE_CANONICAL_NAME_UNSET (3) + unsigned use_canonical_name : 2; + + /* since is_fnmatch(conf->d) was being called so frequently in + * directory_walk() and its relatives, this field was created and + * is set to the result of that call. + */ + unsigned d_is_fnmatch : 1; + + /* should we force a charset on any outgoing parameterless content-type? + * if so, which charset? + */ +#define ADD_DEFAULT_CHARSET_OFF (0) +#define ADD_DEFAULT_CHARSET_ON (1) +#define ADD_DEFAULT_CHARSET_UNSET (2) + unsigned add_default_charset : 2; + char *add_default_charset_name; + + /* System Resource Control */ +#ifdef RLIMIT_CPU + struct rlimit *limit_cpu; +#endif +#if defined (RLIMIT_DATA) || defined (RLIMIT_VMEM) || defined(RLIMIT_AS) + struct rlimit *limit_mem; +#endif +#ifdef RLIMIT_NPROC + struct rlimit *limit_nproc; +#endif + unsigned long limit_req_body; /* limit on bytes in request msg body */ + + /* logging options */ + enum { srv_sig_unset, srv_sig_off, srv_sig_on, + srv_sig_withmail } server_signature; + int loglevel; + + /* Access control */ + array_header *sec; + regex_t *r; + +#ifdef WIN32 + /* Where to find interpreter to run scripts */ + interpreter_source_e script_interpreter_source; +#endif + +#ifdef CHARSET_EBCDIC + /* Configurable EBCDIC Conversion stuff */ + /* Direction specific conversion: */ +#define dir_Out 0 /* 0utput (returned contents in a GET or POST) */ +#define dir_In 1 /* 1nput (uploaded contents in a PUT / POST) */ + + /* Conversion Enabled/Disabled: */ +#define conv_Unset '?' /* Conversion unconfigured */ +#define conv_Off '0' /* BINARY or ASCII file (no conversion) */ +#define conv_On '1' /* TEXT file (EBCDIC->ASCII for dir_Out; ASCII->EBCDIC for dir_In) */ + + /* The configuration args {On|Off}[={In|Out|InOut}] are currently stored + * as character strings ("0" = conv_Off, "1" = conv_On) + */ + table *ebcdicconversion_by_ext_in; + table *ebcdicconversion_by_ext_out; + table *ebcdicconversion_by_type_in; + table *ebcdicconversion_by_type_out; + +#define LEGACY_KLUDGE 1 /* After a couple of versions this legacy kludge should be set to 0 */ +#ifndef ASCIITEXT_MAGIC_TYPE_PREFIX +#define ASCIITEXT_MAGIC_TYPE_PREFIX "text/x-ascii-" /* Text files whose content-type starts with this are passed thru unconverted */ +#endif + int x_ascii_magic_kludge; /* whether to handle the text/x-ascii- kludge */ + +#if ADD_EBCDICCONVERT_DEBUG_HEADER + int ebcdicconversion_debug_header; /* whether to add an X-EBCDIC-Debug-{In,Out} header to the response */ +#endif +#endif /* CHARSET_EBCDIC */ + + /* + * What attributes/data should be included in ETag generation? + */ + etag_components_t etag_bits; + etag_components_t etag_add; + etag_components_t etag_remove; + + /* + * Do we allow ISINDEX CGI scripts to pass their query argument as + * direct command line parameters or argv elements? + */ + ap_flag_e cgi_command_args; + + /* Digest auth. */ + char *ap_auth_nonce; + +} core_dir_config; + +/* Per-server core configuration */ + +typedef struct { + +#ifdef GPROF + char *gprof_dir; +#endif + + /* Name translations --- we want the core to be able to do *something* + * so it's at least a minimally functional web server on its own (and + * can be tested that way). But let's keep it to the bare minimum: + */ + char *ap_document_root; + + /* Access control */ + + char *access_name; + array_header *sec; + array_header *sec_url; + + /* recursion backstopper */ + int recursion_limit_set; /* boolean */ + int redirect_limit; /* maximum number of internal redirects */ + int subreq_limit; /* maximum nesting level of subrequests */ + + /* TRACE control */ + int trace_enable; /* see AP_TRACE_ below */ + +} core_server_config; + +/* trace_enable options */ +#define AP_TRACE_UNSET -1 +#define AP_TRACE_DISABLE 0 +#define AP_TRACE_ENABLE 1 +#define AP_TRACE_EXTENDED 2 + +/* for http_config.c */ +CORE_EXPORT(void) ap_core_reorder_directories(pool *, server_rec *); + +/* for mod_perl */ +CORE_EXPORT(void) ap_add_per_dir_conf (server_rec *s, void *dir_config); +CORE_EXPORT(void) ap_add_per_url_conf (server_rec *s, void *url_config); +CORE_EXPORT(void) ap_add_file_conf(core_dir_config *conf, void *url_config); +CORE_EXPORT_NONSTD(const char *) ap_limit_section (cmd_parms *cmd, void *dummy, const char *arg); + +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* !APACHE_HTTP_CORE_H */ diff --git a/APACHE_1_3_42/src/include/http_log.h b/APACHE_1_3_42/src/include/http_log.h new file mode 100644 index 0000000000..d1b7c763b9 --- /dev/null +++ b/APACHE_1_3_42/src/include/http_log.h @@ -0,0 +1,121 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef APACHE_HTTP_LOG_H +#define APACHE_HTTP_LOG_H + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef HAVE_SYSLOG +#include <syslog.h> + +#define APLOG_EMERG LOG_EMERG /* system is unusable */ +#define APLOG_ALERT LOG_ALERT /* action must be taken immediately */ +#define APLOG_CRIT LOG_CRIT /* critical conditions */ +#define APLOG_ERR LOG_ERR /* error conditions */ +#define APLOG_WARNING LOG_WARNING /* warning conditions */ +#define APLOG_NOTICE LOG_NOTICE /* normal but significant condition */ +#define APLOG_INFO LOG_INFO /* informational */ +#define APLOG_DEBUG LOG_DEBUG /* debug-level messages */ + +#define APLOG_LEVELMASK LOG_PRIMASK /* mask off the level value */ + +#else + +#define APLOG_EMERG 0 /* system is unusable */ +#define APLOG_ALERT 1 /* action must be taken immediately */ +#define APLOG_CRIT 2 /* critical conditions */ +#define APLOG_ERR 3 /* error conditions */ +#define APLOG_WARNING 4 /* warning conditions */ +#define APLOG_NOTICE 5 /* normal but significant condition */ +#define APLOG_INFO 6 /* informational */ +#define APLOG_DEBUG 7 /* debug-level messages */ + +#define APLOG_LEVELMASK 7 /* mask off the level value */ + +#endif + +#define APLOG_NOERRNO (APLOG_LEVELMASK + 1) +#ifdef WIN32 +/* Set to indicate that error msg should come from Win32's GetLastError(), + * not errno. */ +#define APLOG_WIN32ERROR ((APLOG_LEVELMASK+1) * 2) +#endif + +#ifndef DEFAULT_LOGLEVEL +#define DEFAULT_LOGLEVEL APLOG_WARNING +#endif + +#define APLOG_MARK __FILE__,__LINE__ + +API_EXPORT(void) ap_open_logs (server_rec *, pool *p); + +/* The two primary logging functions, ap_log_error and ap_log_rerror, + * use a printf style format string to build the log message. It is + * VERY IMPORTANT that you not include any raw data from the network, + * such as the request-URI or request header fields, within the format + * string. Doing so makes the server vulnerable to a denial-of-service + * attack and other messy behavior. Instead, use a simple format string + * like "%s", followed by the string containing the untrusted data. + */ +API_EXPORT_NONSTD(void) ap_log_error(const char *file, int line, int level, + const server_rec *s, const char *fmt, ...) + __attribute__((format(printf,5,6))); +API_EXPORT_NONSTD(void) ap_log_rerror(const char *file, int line, int level, + const request_rec *s, const char *fmt, ...) + __attribute__((format(printf,5,6))); +API_EXPORT(void) ap_error_log2stderr (server_rec *); + +API_EXPORT(void) ap_log_pid (pool *p, char *fname); +/* These are for legacy code, new code should use ap_log_error, + * or ap_log_rerror. + */ +API_EXPORT(void) ap_log_error_old(const char *err, server_rec *s); +API_EXPORT(void) ap_log_unixerr(const char *routine, const char *file, + const char *msg, server_rec *s); +API_EXPORT_NONSTD(void) ap_log_printf(const server_rec *s, const char *fmt, ...) + __attribute__((format(printf,2,3))); +API_EXPORT(void) ap_log_reason(const char *reason, const char *fname, + request_rec *r); + +typedef struct piped_log { + pool *p; +#if !defined(NO_RELIABLE_PIPED_LOGS) || defined(TPF) + char *program; + int pid; + int fds[2]; +#else + FILE *write_f; +#endif +} piped_log; + +API_EXPORT(piped_log *) ap_open_piped_log (pool *p, const char *program); +API_EXPORT(void) ap_close_piped_log (piped_log *); +#if !defined(NO_RELIABLE_PIPED_LOGS) || defined(TPF) +#define ap_piped_log_read_fd(pl) ((pl)->fds[0]) +#define ap_piped_log_write_fd(pl) ((pl)->fds[1]) +#else +#define ap_piped_log_read_fd(pl) (-1) +#define ap_piped_log_write_fd(pl) (fileno((pl)->write_f)) +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* !APACHE_HTTP_LOG_H */ diff --git a/APACHE_1_3_42/src/include/http_main.h b/APACHE_1_3_42/src/include/http_main.h new file mode 100644 index 0000000000..b044fb84af --- /dev/null +++ b/APACHE_1_3_42/src/include/http_main.h @@ -0,0 +1,139 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef APACHE_HTTP_MAIN_H +#define APACHE_HTTP_MAIN_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Routines in http_main.c which other code --- in particular modules --- + * may want to call. Right now, that's limited to timeout handling. + * There are two functions which modules can call to trigger a timeout + * (with the per-virtual-server timeout duration); these are hard_timeout + * and soft_timeout. + * + * The difference between the two is what happens when the timeout + * expires (or earlier than that, if the client connection aborts) --- + * a soft_timeout just puts the connection to the client in an + * "aborted" state, which will cause http_protocol.c to stop trying to + * talk to the client, but otherwise allows the code to continue normally. + * hard_timeout(), by contrast, logs the request, and then aborts it + * completely --- longjmp()ing out to the accept() loop in http_main. + * Any resources tied into the request's resource pool will be cleaned up; + * everything that isn't will leak. + * + * soft_timeout() is recommended as a general rule, because it gives your + * code a chance to clean up. However, hard_timeout() may be the most + * convenient way of dealing with timeouts waiting for some external + * resource other than the client, if you can live with the restrictions. + * + * (When a hard timeout is in scope, critical sections can be guarded + * with block_alarms() and unblock_alarms() --- these are declared in + * alloc.c because they are most often used in conjunction with + * routines to allocate something or other, to make sure that the + * cleanup does get registered before any alarm is allowed to happen + * which might require it to be cleaned up; they * are, however, + * implemented in http_main.c). + * + * NOTE! It's not "fair" for a hard_timeout to be in scope through calls + * across modules. Your module code really has no idea what other modules may + * be present in the server, and they may not take too kindly to having a + * longjmp() happen -- it could result in corrupted state. Heck they may not + * even take to kindly to a soft_timeout()... because it can cause EINTR to + * happen on pretty much any syscall, and unless all the libraries and modules + * in use are known to deal well with EINTR it could cause corruption as well. + * But things are likely to do much better with a soft_timeout in scope than a + * hard_timeout. + * + * A module MAY NOT use a hard_timeout() across * sub_req_lookup_xxx() + * functions, or across run_sub_request() functions. A module SHOULD NOT use a + * soft_timeout() in either of these cases, but sometimes there's just no + * choice. + * + * kill_timeout() will disarm either variety of timeout. + * + * reset_timeout() resets the timeout in progress. + */ + +API_EXPORT(void) ap_start_shutdown(void); +API_EXPORT(void) ap_start_restart(int); +API_EXPORT(void) ap_hard_timeout(char *, request_rec *); +API_EXPORT(void) ap_keepalive_timeout(char *, request_rec *); +API_EXPORT(void) ap_soft_timeout(char *, request_rec *); +API_EXPORT(void) ap_kill_timeout(request_rec *); +API_EXPORT(void) ap_reset_timeout(request_rec *); + +API_EXPORT(void) ap_child_terminate(request_rec *r); +API_EXPORT(void) ap_sync_scoreboard_image(void); +API_EXPORT(int) ap_update_child_status(int child_num, int status, request_rec *r); +void ap_time_process_request(int child_num, int status); +API_EXPORT(unsigned int) ap_set_callback_and_alarm(void (*fn) (int), int x); +API_EXPORT(int) ap_check_alarm(void); + +void setup_signal_names(char *prefix); + +/* functions for determination and setting of accept() mutexing */ +char *ap_default_mutex_method(void); +char *ap_init_mutex_method(char *t); + +#ifndef NO_OTHER_CHILD +/* + * register an other_child -- a child which the main loop keeps track of + * and knows it is different than the rest of the scoreboard. + * + * pid is the pid of the child. + * + * maintenance is a function that is invoked with a reason, the data + * pointer passed here, and when appropriate a status result from waitpid(). + * + * write_fd is an fd that is probed for writing by select() if it is ever + * unwritable, then maintenance is invoked with reason OC_REASON_UNWRITABLE. + * This is useful for log pipe children, to know when they've blocked. To + * disable this feature, use -1 for write_fd. + */ +API_EXPORT(void) ap_register_other_child(int pid, + void (*maintenance) (int reason, void *data, ap_wait_t status), void *data, + int write_fd); +#define OC_REASON_DEATH 0 /* child has died, caller must call + * unregister still */ +#define OC_REASON_UNWRITABLE 1 /* write_fd is unwritable */ +#define OC_REASON_RESTART 2 /* a restart is occuring, perform + * any necessary cleanup (including + * sending a special signal to child) + */ +#define OC_REASON_UNREGISTER 3 /* unregister has been called, do + * whatever is necessary (including + * kill the child) */ +#define OC_REASON_LOST 4 /* somehow the child exited without + * us knowing ... buggy os? */ + +/* + * unregister an other_child. Note that the data pointer is used here, and + * is assumed to be unique per other_child. This is because the pid and + * write_fd are possibly killed off separately. + */ +API_EXPORT(void) ap_unregister_other_child(void *data); + +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* !APACHE_HTTP_MAIN_H */ diff --git a/APACHE_1_3_42/src/include/http_protocol.h b/APACHE_1_3_42/src/include/http_protocol.h new file mode 100644 index 0000000000..bf0e3bee50 --- /dev/null +++ b/APACHE_1_3_42/src/include/http_protocol.h @@ -0,0 +1,187 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef APACHE_HTTP_PROTOCOL_H +#define APACHE_HTTP_PROTOCOL_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Prototypes for routines which either talk directly back to the user, + * or control the ones that eventually do. + */ + +/* Read a request and fill in the fields. */ + +API_EXPORT(request_rec *) ap_read_request(conn_rec *c); + +/* Send a single HTTP header field */ + +API_EXPORT_NONSTD(int) ap_send_header_field(request_rec *r, const char *fieldname, + const char *fieldval); + +/* Send the minimal part of an HTTP response header... but modules should be + * very careful about using this, and should prefer ap_send_http_header(). + * Much of the HTTP/1.1 implementation correctness depends on code in + * ap_send_http_header(). + */ +API_EXPORT(void) ap_basic_http_header(request_rec *r); + +/* Send the Status-Line and header fields for HTTP response */ + +API_EXPORT(void) ap_send_http_header(request_rec *l); + +/* Send the response to special method requests */ + +API_EXPORT(int) ap_send_http_trace(request_rec *r); +API_EXPORT(int) ap_send_http_options(request_rec *r); + +/* Finish up stuff after a request */ + +API_EXPORT(void) ap_finalize_request_protocol(request_rec *r); + +/* Send error back to client... last arg indicates error status in case + * we get an error in the process of trying to deal with an ErrorDocument + * to handle some other error. In that case, we print the default report + * for the first thing that went wrong, and more briefly report on the + * problem with the ErrorDocument. + */ + +API_EXPORT(void) ap_send_error_response(request_rec *r, int recursive_error); + +/* Set last modified header line from the lastmod date of the associated file. + * Also, set content length. + * + * May return an error status, typically USE_LOCAL_COPY (that when the + * permit_cache argument is set to one). + */ + +API_EXPORT(int) ap_set_content_length(request_rec *r, long length); +API_EXPORT(int) ap_set_keepalive(request_rec *r); +API_EXPORT(time_t) ap_rationalize_mtime(request_rec *r, time_t mtime); +API_EXPORT(char *) ap_make_etag(request_rec *r, int force_weak); +API_EXPORT(void) ap_set_etag(request_rec *r); +API_EXPORT(void) ap_set_last_modified(request_rec *r); +API_EXPORT(int) ap_meets_conditions(request_rec *r); + +/* Other ways to send stuff at the client. All of these keep track + * of bytes_sent automatically. This indirection is intended to make + * it a little more painless to slide things like HTTP-NG packetization + * underneath the main body of the code later. In the meantime, it lets + * us centralize a bit of accounting (bytes_sent). + * + * These also return the number of bytes written by the call. + * They should only be called with a timeout registered, for obvious reaasons. + * (Ditto the send_header stuff). + */ + +API_EXPORT(long) ap_send_fd(FILE *f, request_rec *r); +API_EXPORT(long) ap_send_fd_length(FILE *f, request_rec *r, long length); + +API_EXPORT(long) ap_send_fb(BUFF *f, request_rec *r); +API_EXPORT(long) ap_send_fb_length(BUFF *f, request_rec *r, long length); + +API_EXPORT(size_t) ap_send_mmap(void *mm, request_rec *r, size_t offset, + size_t length); + +/* Hmmm... could macrofy these for now, and maybe forever, though the + * definitions of the macros would get a whole lot hairier. + */ + +API_EXPORT(int) ap_rputc(int c, request_rec *r); +API_EXPORT(int) ap_rputs(const char *str, request_rec *r); +API_EXPORT(int) ap_rwrite(const void *buf, int nbyte, request_rec *r); +API_EXPORT_NONSTD(int) ap_rvputs(request_rec *r,...); +API_EXPORT(int) ap_vrprintf(request_rec *r, const char *fmt, va_list vlist); +API_EXPORT_NONSTD(int) ap_rprintf(request_rec *r, const char *fmt,...) + __attribute__((format(printf,2,3))); +API_EXPORT(int) ap_rflush(request_rec *r); + +/* + * Index used in custom_responses array for a specific error code + * (only use outside protocol.c is in getting them configured). + */ + +API_EXPORT(int) ap_index_of_response(int status); + +/* Reading a block of data from the client connection (e.g., POST arg) */ + +API_EXPORT(int) ap_setup_client_block(request_rec *r, int read_policy); +API_EXPORT(int) ap_should_client_block(request_rec *r); +API_EXPORT(long) ap_get_client_block(request_rec *r, char *buffer, int bufsiz); +API_EXPORT(int) ap_discard_request_body(request_rec *r); + +/* Sending a byterange */ + +API_EXPORT(int) ap_set_byterange(request_rec *r); +API_EXPORT(int) ap_each_byterange(request_rec *r, long *offset, long *length); + +/* Support for the Basic authentication protocol. Note that there's + * nothing that prevents these from being in mod_auth.c, except that other + * modules which wanted to provide their own variants on finding users and + * passwords for Basic auth (a fairly common request) would then require + * mod_auth to be loaded or they wouldn't work. + * + * get_basic_auth_pw returns 0 (OK) if it set the 'pw' argument (and assured + * a correct value in r->connection->user); otherwise it returns an error + * code, either SERVER_ERROR if things are really confused, AUTH_REQUIRED + * if no authentication at all seemed to be in use, or DECLINED if there + * was authentication but it wasn't Basic (in which case, the caller should + * presumably decline as well). + * + * note_basic_auth_failure arranges for the right stuff to be scribbled on + * the HTTP return so that the client knows how to authenticate itself the + * next time. As does note_digest_auth_failure for Digest auth. + * + * note_auth_failure does the same thing, but will call the correct one + * based on the authentication type in use. + * + */ + +API_EXPORT(void) ap_note_auth_failure(request_rec *r); +API_EXPORT(void) ap_note_basic_auth_failure(request_rec *r); +API_EXPORT(void) ap_note_digest_auth_failure(request_rec *r); +API_EXPORT(int) ap_get_basic_auth_pw(request_rec *r, const char **pw); + +/* + * Setting up the protocol fields for subsidiary requests... + * Also, a wrapup function to keep the internal accounting straight. + */ + +API_EXPORT(void) ap_set_sub_req_protocol(request_rec *rnew, const request_rec *r); +API_EXPORT(void) ap_finalize_sub_req_protocol(request_rec *sub_r); + +/* This is also useful for putting sub_reqs and internal_redirects together */ + +CORE_EXPORT(void) ap_parse_uri(request_rec *r, const char *uri); + +/* Get the method number associated with the given string, assumed to + * contain an HTTP method. Returns M_INVALID if not recognized. + */ +API_EXPORT(int) ap_method_number_of(const char *method); + +API_EXPORT(int) ap_getline(char *s, int n, BUFF *in, int fold); + +API_EXPORT(long) ap_get_chunk_size(char *b); + + +#ifdef __cplusplus +} +#endif + +#endif /* !APACHE_HTTP_PROTOCOL_H */ diff --git a/APACHE_1_3_42/src/include/http_request.h b/APACHE_1_3_42/src/include/http_request.h new file mode 100644 index 0000000000..1982931315 --- /dev/null +++ b/APACHE_1_3_42/src/include/http_request.h @@ -0,0 +1,76 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef APACHE_HTTP_REQUEST_H +#define APACHE_HTTP_REQUEST_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* http_request.c is the code which handles the main line of request + * processing, once a request has been read in (finding the right per- + * directory configuration, building it if necessary, and calling all + * the module dispatch functions in the right order). + * + * The pieces here which are public to the modules, allow them to learn + * how the server would handle some other file or URI, or perhaps even + * direct the server to serve that other file instead of the one the + * client requested directly. + * + * There are two ways to do that. The first is the sub_request mechanism, + * which handles looking up files and URIs as adjuncts to some other + * request (e.g., directory entries for multiviews and directory listings); + * the lookup functions stop short of actually running the request, but + * (e.g., for includes), a module may call for the request to be run + * by calling run_sub_req. The space allocated to create sub_reqs can be + * reclaimed by calling destroy_sub_req --- be sure to copy anything you care + * about which was allocated in its pool elsewhere before doing this. + */ + +API_EXPORT(request_rec *) ap_sub_req_lookup_uri(const char *new_file, + const request_rec *r); +API_EXPORT(request_rec *) ap_sub_req_lookup_file(const char *new_file, + const request_rec *r); +API_EXPORT(request_rec *) ap_sub_req_method_uri(const char *method, + const char *new_file, + const request_rec *r); +API_EXPORT(int) ap_run_sub_req(request_rec *r); +API_EXPORT(void) ap_destroy_sub_req(request_rec *r); + +/* + * Then there's the case that you want some other request to be served + * as the top-level request INSTEAD of what the client requested directly. + * If so, call this from a handler, and then immediately return OK. + */ + +API_EXPORT(void) ap_internal_redirect(const char *new_uri, request_rec *); +API_EXPORT(void) ap_internal_redirect_handler(const char *new_uri, request_rec *); +API_EXPORT(int) ap_some_auth_required(request_rec *r); +API_EXPORT(int) ap_is_initial_req(request_rec *r); +API_EXPORT(time_t) ap_update_mtime(request_rec *r, time_t dependency_mtime); + +#ifdef CORE_PRIVATE +/* Function called by main.c to handle first-level request */ +API_EXPORT(void) ap_process_request(request_rec *); +API_EXPORT(void) ap_die(int type, request_rec *r); +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* !APACHE_HTTP_REQUEST_H */ diff --git a/APACHE_1_3_42/src/include/http_vhost.h b/APACHE_1_3_42/src/include/http_vhost.h new file mode 100644 index 0000000000..d8c99ff4ca --- /dev/null +++ b/APACHE_1_3_42/src/include/http_vhost.h @@ -0,0 +1,54 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef APACHE_HTTP_VHOST_H +#define APACHE_HTTP_VHOST_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* called before any config is read */ +API_EXPORT(void) ap_init_vhost_config(pool *p); + +/* called after the config has been read */ +API_EXPORT(void) ap_fini_vhost_config(pool *p, server_rec *main_server); + +/* handle addresses in <VirtualHost> statement */ +API_EXPORT(const char *) ap_parse_vhost_addrs(pool *p, const char *hostname, server_rec *s); + +/* handle NameVirtualHost directive */ +API_EXPORT_NONSTD(const char *) ap_set_name_virtual_host (cmd_parms *cmd, void *dummy, char *arg); + +/* given an ip address only, give our best guess as to what vhost it is */ +API_EXPORT(void) ap_update_vhost_given_ip(conn_rec *conn); + +/* The above is never enough, and this is always called after the headers + * have been read. It may change r->server. + */ +API_EXPORT(void) ap_update_vhost_from_headers(request_rec *r); + +/* return 1 if the host:port matches any of the aliases of r->server + * return 0 otherwise + */ +API_EXPORT(int) ap_matches_request_vhost(request_rec *r, const char *host, + unsigned port); + +#ifdef __cplusplus +} +#endif + +#endif /* !APACHE_HTTP_VHOST_H */ diff --git a/APACHE_1_3_42/src/include/httpd.h b/APACHE_1_3_42/src/include/httpd.h new file mode 100644 index 0000000000..10d3e397dc --- /dev/null +++ b/APACHE_1_3_42/src/include/httpd.h @@ -0,0 +1,1217 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef APACHE_HTTPD_H +#define APACHE_HTTPD_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * httpd.h: header for simple (ha! not anymore) http daemon + */ + +/* Headers in which EVERYONE has an interest... */ + +#include "ap_config.h" +#include "ap_alloc.h" +#include "buff.h" +#include "ap.h" + +/* ----------------------------- config dir ------------------------------ */ + +/* Define this to be the default server home dir. Most things later in this + * file with a relative pathname will have this added. + */ +#ifndef HTTPD_ROOT +#ifdef OS2 +/* Set default for OS/2 file system */ +#define HTTPD_ROOT "/os2httpd" +#elif defined(WIN32) +/* Set default for Windows file system */ +#define HTTPD_ROOT "/apache" +#elif defined(BEOS) || defined(BONE) +#define HTTPD_ROOT "/boot/home/apache" +#elif defined(NETWARE) +#define HTTPD_ROOT "sys:/apache" +#else +#define HTTPD_ROOT "/usr/local/apache" +#endif +#endif /* HTTPD_ROOT */ + +/* Default location of documents. Can be overridden by the DocumentRoot + * directive. + */ +#ifndef DOCUMENT_LOCATION +#ifdef OS2 +/* Set default for OS/2 file system */ +#define DOCUMENT_LOCATION HTTPD_ROOT "/docs" +#else +#define DOCUMENT_LOCATION HTTPD_ROOT "/htdocs" +#endif +#endif /* DOCUMENT_LOCATION */ + +/* Max. number of dynamically loaded modules */ +#ifndef DYNAMIC_MODULE_LIMIT +#define DYNAMIC_MODULE_LIMIT 64 +#endif + +/* Default administrator's address */ +#define DEFAULT_ADMIN "[no address given]" + +/* The target name of the installed Apache */ +#ifndef TARGET +#define TARGET "httpd" +#endif + +/* + * --------- You shouldn't have to edit anything below this line ---------- + * + * Any modifications to any defaults not defined above should be done in the + * respective config. file. + * + */ + + +/* -- Internal representation for a HTTP protocol number, e.g., HTTP/1.1 -- */ + +#define HTTP_VERSION(major,minor) (1000*(major)+(minor)) +#define HTTP_VERSION_MAJOR(number) ((number)/1000) +#define HTTP_VERSION_MINOR(number) ((number)%1000) + + +/* -------------- Port number for server running standalone --------------- */ + +#define DEFAULT_HTTP_PORT 80 +#define DEFAULT_HTTPS_PORT 443 +#define ap_is_default_port(port,r) ((port) == ap_default_port(r)) +#ifdef NETWARE +#define ap_http_method(r) ap_os_http_method((void*)r) +#define ap_default_port(r) ap_os_default_port((void*)r) +#else +#define ap_http_method(r) "http" +#define ap_default_port(r) DEFAULT_HTTP_PORT +#endif + +/* --------- Default user name and group name running standalone ---------- */ +/* --- These may be specified as numbers by placing a # before a number --- */ + +#ifndef DEFAULT_USER +#define DEFAULT_USER "#-1" +#endif +#ifndef DEFAULT_GROUP +#define DEFAULT_GROUP "#-1" +#endif + +#ifndef DEFAULT_ERRORLOG +#if defined(OS2) || defined(WIN32) +#define DEFAULT_ERRORLOG "logs/error.log" +#else +#define DEFAULT_ERRORLOG "logs/error_log" +#endif +#endif /* DEFAULT_ERRORLOG */ + +#ifndef DEFAULT_PIDLOG +#define DEFAULT_PIDLOG "logs/httpd.pid" +#endif +#ifndef DEFAULT_SCOREBOARD +#define DEFAULT_SCOREBOARD "logs/apache_runtime_status" +#endif +#ifndef DEFAULT_LOCKFILE +#define DEFAULT_LOCKFILE "logs/accept.lock" +#endif + +/* Define this to be what your HTML directory content files are called */ +#ifndef DEFAULT_INDEX +#define DEFAULT_INDEX "index.html" +#endif + +/* Define this to 1 if you want fancy indexing, 0 otherwise */ +#ifndef DEFAULT_INDEXING +#define DEFAULT_INDEXING 0 +#endif + +/* Define this to be what type you'd like returned for files with unknown */ +/* suffixes. MUST be all lower case. */ +#ifndef DEFAULT_CONTENT_TYPE +#define DEFAULT_CONTENT_TYPE "text/plain" +#endif + +/* Define this to be what your per-directory security files are called */ +#ifndef DEFAULT_ACCESS_FNAME +#ifdef OS2 +/* Set default for OS/2 file system */ +#define DEFAULT_ACCESS_FNAME "htaccess" +#else +#define DEFAULT_ACCESS_FNAME ".htaccess" +#endif +#endif /* DEFAULT_ACCESS_FNAME */ + +/* The name of the server config file */ +#ifndef SERVER_CONFIG_FILE +#define SERVER_CONFIG_FILE "conf/httpd.conf" +#endif + +/* The name of the document config file */ +#ifndef RESOURCE_CONFIG_FILE +#define RESOURCE_CONFIG_FILE "conf/srm.conf" +#endif + +/* The name of the MIME types file */ +#ifndef TYPES_CONFIG_FILE +#define TYPES_CONFIG_FILE "conf/mime.types" +#endif + +/* The name of the access file */ +#ifndef ACCESS_CONFIG_FILE +#define ACCESS_CONFIG_FILE "conf/access.conf" +#endif + +/* Whether we should enable rfc1413 identity checking */ +#ifndef DEFAULT_RFC1413 +#define DEFAULT_RFC1413 0 +#endif +/* The default directory in user's home dir */ +#ifndef DEFAULT_USER_DIR +#define DEFAULT_USER_DIR "public_html" +#endif + +/* The default path for CGI scripts if none is currently set */ +#ifndef DEFAULT_PATH +#define DEFAULT_PATH "/bin:/usr/bin:/usr/ucb:/usr/bsd:/usr/local/bin" +#endif + +/* The path to the shell interpreter, for parsed docs */ +#ifndef SHELL_PATH +#if defined(OS2) || defined(WIN32) +/* Set default for OS/2 and Windows file system */ +#define SHELL_PATH "CMD.EXE" +#else +#define SHELL_PATH "/bin/sh" +#endif +#endif /* SHELL_PATH */ + +/* The path to the suExec wrapper, can be overridden in Configuration */ +#ifndef SUEXEC_BIN +#define SUEXEC_BIN HTTPD_ROOT "/bin/suexec" +#endif + +/* The default string lengths */ +#define MAX_STRING_LEN HUGE_STRING_LEN +#define HUGE_STRING_LEN 8192 + +/* The timeout for waiting for messages */ +#ifndef DEFAULT_TIMEOUT +#define DEFAULT_TIMEOUT 300 +#endif + +/* The timeout for waiting for keepalive timeout until next request */ +#ifndef DEFAULT_KEEPALIVE_TIMEOUT +#define DEFAULT_KEEPALIVE_TIMEOUT 15 +#endif + +/* The number of requests to entertain per connection */ +#ifndef DEFAULT_KEEPALIVE +#define DEFAULT_KEEPALIVE 100 +#endif + +/* The size of the server's internal read-write buffers */ +#define IOBUFSIZE 8192 + +/* The max number of regex captures that can be expanded by ap_pregsub */ +#define AP_MAX_REG_MATCH 10 + +/* Number of servers to spawn off by default --- also, if fewer than + * this free when the caretaker checks, it will spawn more. + */ +#ifndef DEFAULT_START_DAEMON +#define DEFAULT_START_DAEMON 5 +#endif + +/* Maximum number of *free* server processes --- more than this, and + * they will die off. + */ + +#ifndef DEFAULT_MAX_FREE_DAEMON +#define DEFAULT_MAX_FREE_DAEMON 10 +#endif + +/* Minimum --- fewer than this, and more will be created */ + +#ifndef DEFAULT_MIN_FREE_DAEMON +#define DEFAULT_MIN_FREE_DAEMON 5 +#endif + +/* Limit on the total --- clients will be locked out if more servers than + * this are needed. It is intended solely to keep the server from crashing + * when things get out of hand. + * + * We keep a hard maximum number of servers, for two reasons --- first off, + * in case something goes seriously wrong, we want to stop the fork bomb + * short of actually crashing the machine we're running on by filling some + * kernel table. Secondly, it keeps the size of the scoreboard file small + * enough that we can read the whole thing without worrying too much about + * the overhead. + */ +#ifndef HARD_SERVER_LIMIT +#ifdef WIN32 +#define HARD_SERVER_LIMIT 1024 +#elif defined(NETWARE) +#define HARD_SERVER_LIMIT 2048 +#else +#define HARD_SERVER_LIMIT 256 +#endif +#endif + +/* + * Special Apache error codes. These are basically used + * in http_main.c so we can keep track of various errors. + * + * APEXIT_OK: + * A normal exit + * APEXIT_INIT: + * A fatal error arising during the server's init sequence + * APEXIT_CHILDINIT: + * The child died during it's init sequence + * APEXIT_CHILDFATAL: + * A fatal error, resulting in the whole server aborting. + * If a child exits with this error, the parent process + * considers this a server-wide fatal error and aborts. + * + */ +#define APEXIT_OK 0x0 +#define APEXIT_INIT 0x2 +#define APEXIT_CHILDINIT 0x3 +#define APEXIT_CHILDFATAL 0xf + +/* + * (Unix, OS/2 only) + * Interval, in microseconds, between scoreboard maintenance. During + * each scoreboard maintenance cycle the parent decides if it needs to + * spawn a new child (to meet MinSpareServers requirements), or kill off + * a child (to meet MaxSpareServers requirements). It will only spawn or + * kill one child per cycle. Setting this too low will chew cpu. The + * default is probably sufficient for everyone. But some people may want + * to raise this on servers which aren't dedicated to httpd and where they + * don't like the httpd waking up each second to see what's going on. + */ +#ifndef SCOREBOARD_MAINTENANCE_INTERVAL +#define SCOREBOARD_MAINTENANCE_INTERVAL 1000000 +#endif + +/* Number of requests to try to handle in a single process. If <= 0, + * the children don't die off. That's the default here, since I'm still + * interested in finding and stanching leaks. + */ + +#ifndef DEFAULT_MAX_REQUESTS_PER_CHILD +#define DEFAULT_MAX_REQUESTS_PER_CHILD 0 +#endif + +#ifndef DEFAULT_THREADS_PER_CHILD +#define DEFAULT_THREADS_PER_CHILD 50 +#endif +#ifndef DEFAULT_EXCESS_REQUESTS_PER_CHILD +#define DEFAULT_EXCESS_REQUESTS_PER_CHILD 0 +#endif + +/* The maximum length of the queue of pending connections, as defined + * by listen(2). Under some systems, it should be increased if you + * are experiencing a heavy TCP SYN flood attack. + * + * It defaults to 511 instead of 512 because some systems store it + * as an 8-bit datatype; 512 truncated to 8-bits is 0, while 511 is + * 255 when truncated. + */ + +#ifndef DEFAULT_LISTENBACKLOG +#define DEFAULT_LISTENBACKLOG 511 +#endif + +/* Limits on the size of various request items. These limits primarily + * exist to prevent simple denial-of-service attacks on a server based + * on misuse of the protocol. The recommended values will depend on the + * nature of the server resources -- CGI scripts and database backends + * might require large values, but most servers could get by with much + * smaller limits than we use below. The request message body size can + * be limited by the per-dir config directive LimitRequestBody. + * + * Internal buffer sizes are two bytes more than the DEFAULT_LIMIT_REQUEST_LINE + * and DEFAULT_LIMIT_REQUEST_FIELDSIZE below, which explains the 8190. + * These two limits can be lowered (but not raised) by the server config + * directives LimitRequestLine and LimitRequestFieldsize, respectively. + * + * DEFAULT_LIMIT_REQUEST_FIELDS can be modified or disabled (set = 0) by + * the server config directive LimitRequestFields. + */ +#ifndef DEFAULT_LIMIT_REQUEST_LINE +#define DEFAULT_LIMIT_REQUEST_LINE 8190 +#endif /* default limit on bytes in Request-Line (Method+URI+HTTP-version) */ +#ifndef DEFAULT_LIMIT_REQUEST_FIELDSIZE +#define DEFAULT_LIMIT_REQUEST_FIELDSIZE 8190 +#endif /* default limit on bytes in any one header field */ +#ifndef DEFAULT_LIMIT_REQUEST_FIELDS +#define DEFAULT_LIMIT_REQUEST_FIELDS 100 +#endif /* default limit on number of request header fields */ + +/* + * The default default character set name to add if AddDefaultCharset is + * enabled. Overridden with AddDefaultCharsetName. + */ +#define DEFAULT_ADD_DEFAULT_CHARSET_NAME "iso-8859-1" + +/* + * The below defines the base string of the Server: header. Additional + * tokens can be added via the ap_add_version_component() API call. + * + * The tokens are listed in order of their significance for identifying the + * application. + * + * "Product tokens should be short and to the point -- use of them for + * advertizing or other non-essential information is explicitly forbidden." + * + * Example: "Apache/1.1.0 MrWidget/0.1-alpha" + */ + +#define SERVER_BASEVENDOR "Apache Group" +#define SERVER_BASEPRODUCT "Apache" +#define SERVER_BASEREVISION "1.3.42" +#define SERVER_BASEVERSION SERVER_BASEPRODUCT "/" SERVER_BASEREVISION + +#define SERVER_PRODUCT SERVER_BASEPRODUCT +#define SERVER_REVISION SERVER_BASEREVISION +#define SERVER_VERSION SERVER_PRODUCT "/" SERVER_REVISION +enum server_token_type { + SrvTk_MIN, /* eg: Apache/1.3.0 */ + SrvTk_OS, /* eg: Apache/1.3.0 (UNIX) */ + SrvTk_FULL, /* eg: Apache/1.3.0 (UNIX) PHP/3.0 FooBar/1.2b */ + SrvTk_PRODUCT_ONLY /* eg: Apache */ +}; + +API_EXPORT(const char *) ap_get_server_version(void); +API_EXPORT(void) ap_add_version_component(const char *component); +API_EXPORT(const char *) ap_get_server_built(void); + +/* Numeric release version identifier: MMNNFFRBB: major minor fix final beta + * Always increases along the same track as the source branch. + * For example, Apache 1.4.2 would be '10402100', 2.5b7 would be '20500007'. + */ +#define APACHE_RELEASE 10342100 + +#define SERVER_PROTOCOL "HTTP/1.1" +#ifndef SERVER_SUPPORT +#define SERVER_SUPPORT "http://www.apache.org/" +#endif + +#define DECLINED -1 /* Module declines to handle */ +#define DONE -2 /* Module has served the response completely + * - it's safe to die() with no more output + */ +#define OK 0 /* Module has handled this stage. */ + + +/* ----------------------- HTTP Status Codes ------------------------- */ + +/* The size of the static array in http_protocol.c for storing + * all of the potential response status-lines (a sparse table). + * A future version should dynamically generate the table at startup. + */ +#define RESPONSE_CODES 55 + +#define HTTP_CONTINUE 100 +#define HTTP_SWITCHING_PROTOCOLS 101 +#define HTTP_PROCESSING 102 +#define HTTP_OK 200 +#define HTTP_CREATED 201 +#define HTTP_ACCEPTED 202 +#define HTTP_NON_AUTHORITATIVE 203 +#define HTTP_NO_CONTENT 204 +#define HTTP_RESET_CONTENT 205 +#define HTTP_PARTIAL_CONTENT 206 +#define HTTP_MULTI_STATUS 207 +#define HTTP_MULTIPLE_CHOICES 300 +#define HTTP_MOVED_PERMANENTLY 301 +#define HTTP_MOVED_TEMPORARILY 302 +#define HTTP_SEE_OTHER 303 +#define HTTP_NOT_MODIFIED 304 +#define HTTP_USE_PROXY 305 +#define HTTP_TEMPORARY_REDIRECT 307 +#define HTTP_BAD_REQUEST 400 +#define HTTP_UNAUTHORIZED 401 +#define HTTP_PAYMENT_REQUIRED 402 +#define HTTP_FORBIDDEN 403 +#define HTTP_NOT_FOUND 404 +#define HTTP_METHOD_NOT_ALLOWED 405 +#define HTTP_NOT_ACCEPTABLE 406 +#define HTTP_PROXY_AUTHENTICATION_REQUIRED 407 +#define HTTP_REQUEST_TIME_OUT 408 +#define HTTP_CONFLICT 409 +#define HTTP_GONE 410 +#define HTTP_LENGTH_REQUIRED 411 +#define HTTP_PRECONDITION_FAILED 412 +#define HTTP_REQUEST_ENTITY_TOO_LARGE 413 +#define HTTP_REQUEST_URI_TOO_LARGE 414 +#define HTTP_UNSUPPORTED_MEDIA_TYPE 415 +#define HTTP_RANGE_NOT_SATISFIABLE 416 +#define HTTP_EXPECTATION_FAILED 417 +#define HTTP_UNPROCESSABLE_ENTITY 422 +#define HTTP_LOCKED 423 +#define HTTP_FAILED_DEPENDENCY 424 +#define HTTP_INTERNAL_SERVER_ERROR 500 +#define HTTP_NOT_IMPLEMENTED 501 +#define HTTP_BAD_GATEWAY 502 +#define HTTP_SERVICE_UNAVAILABLE 503 +#define HTTP_GATEWAY_TIME_OUT 504 +#define HTTP_VERSION_NOT_SUPPORTED 505 +#define HTTP_VARIANT_ALSO_VARIES 506 +#define HTTP_INSUFFICIENT_STORAGE 507 +#define HTTP_NOT_EXTENDED 510 + +#define DOCUMENT_FOLLOWS HTTP_OK +#define PARTIAL_CONTENT HTTP_PARTIAL_CONTENT +#define MULTIPLE_CHOICES HTTP_MULTIPLE_CHOICES +#define MOVED HTTP_MOVED_PERMANENTLY +#define REDIRECT HTTP_MOVED_TEMPORARILY +#define USE_LOCAL_COPY HTTP_NOT_MODIFIED +#define BAD_REQUEST HTTP_BAD_REQUEST +#define AUTH_REQUIRED HTTP_UNAUTHORIZED +#define FORBIDDEN HTTP_FORBIDDEN +#define NOT_FOUND HTTP_NOT_FOUND +#define METHOD_NOT_ALLOWED HTTP_METHOD_NOT_ALLOWED +#define NOT_ACCEPTABLE HTTP_NOT_ACCEPTABLE +#define LENGTH_REQUIRED HTTP_LENGTH_REQUIRED +#define PRECONDITION_FAILED HTTP_PRECONDITION_FAILED +#define SERVER_ERROR HTTP_INTERNAL_SERVER_ERROR +#define NOT_IMPLEMENTED HTTP_NOT_IMPLEMENTED +#define BAD_GATEWAY HTTP_BAD_GATEWAY +#define VARIANT_ALSO_VARIES HTTP_VARIANT_ALSO_VARIES + +#define ap_is_HTTP_INFO(x) (((x) >= 100)&&((x) < 200)) +#define ap_is_HTTP_SUCCESS(x) (((x) >= 200)&&((x) < 300)) +#define ap_is_HTTP_REDIRECT(x) (((x) >= 300)&&((x) < 400)) +#define ap_is_HTTP_ERROR(x) (((x) >= 400)&&((x) < 600)) +#define ap_is_HTTP_CLIENT_ERROR(x) (((x) >= 400)&&((x) < 500)) +#define ap_is_HTTP_SERVER_ERROR(x) (((x) >= 500)&&((x) < 600)) + +#define ap_status_drops_connection(x) \ + (((x) == HTTP_BAD_REQUEST) || \ + ((x) == HTTP_REQUEST_TIME_OUT) || \ + ((x) == HTTP_LENGTH_REQUIRED) || \ + ((x) == HTTP_REQUEST_ENTITY_TOO_LARGE) || \ + ((x) == HTTP_REQUEST_URI_TOO_LARGE) || \ + ((x) == HTTP_INTERNAL_SERVER_ERROR) || \ + ((x) == HTTP_SERVICE_UNAVAILABLE) || \ + ((x) == HTTP_NOT_IMPLEMENTED)) + +/* Methods recognized (but not necessarily handled) by the server. + * These constants are used in bit shifting masks of size int, so it is + * unsafe to have more methods than bits in an int. HEAD == M_GET. + */ +#define M_GET 0 +#define M_PUT 1 +#define M_POST 2 +#define M_DELETE 3 +#define M_CONNECT 4 +#define M_OPTIONS 5 +#define M_TRACE 6 +#define M_PATCH 7 +#define M_PROPFIND 8 +#define M_PROPPATCH 9 +#define M_MKCOL 10 +#define M_COPY 11 +#define M_MOVE 12 +#define M_LOCK 13 +#define M_UNLOCK 14 +#define M_INVALID 15 + +#define METHODS 16 + +#define CGI_MAGIC_TYPE "application/x-httpd-cgi" +#define INCLUDES_MAGIC_TYPE "text/x-server-parsed-html" +#define INCLUDES_MAGIC_TYPE3 "text/x-server-parsed-html3" +#ifdef CHARSET_EBCDIC +#define ASCIITEXT_MAGIC_TYPE_PREFIX "text/x-ascii-" /* Text files whose content-type starts with this are passed thru unconverted */ +#endif /*CHARSET_EBCDIC*/ +#define MAP_FILE_MAGIC_TYPE "application/x-type-map" +#define ASIS_MAGIC_TYPE "httpd/send-as-is" +#define DIR_MAGIC_TYPE "httpd/unix-directory" +#define STATUS_MAGIC_TYPE "application/x-httpd-status" + +/* + * Define the HTML doctype strings centrally. + */ +#define DOCTYPE_HTML_2_0 "<!DOCTYPE HTML PUBLIC \"-//IETF//" \ + "DTD HTML 2.0//EN\">\n" +#define DOCTYPE_HTML_3_2 "<!DOCTYPE HTML PUBLIC \"-//W3C//" \ + "DTD HTML 3.2 Final//EN\">\n" +#define DOCTYPE_HTML_4_0S "<!DOCTYPE HTML PUBLIC \"-//W3C//" \ + "DTD HTML 4.0//EN\"\n" \ + "\"http://www.w3.org/TR/REC-html40/strict.dtd\">\n" +#define DOCTYPE_HTML_4_0T "<!DOCTYPE HTML PUBLIC \"-//W3C//" \ + "DTD HTML 4.0 Transitional//EN\"\n" \ + "\"http://www.w3.org/TR/REC-html40/loose.dtd\">\n" +#define DOCTYPE_HTML_4_0F "<!DOCTYPE HTML PUBLIC \"-//W3C//" \ + "DTD HTML 4.0 Frameset//EN\"\n" \ + "\"http://www.w3.org/TR/REC-html40/frameset.dtd\">\n" + +/* Just in case your linefeed isn't the one the other end is expecting. */ +#ifndef CHARSET_EBCDIC +#define LF 10 +#define CR 13 +#define CRLF "\015\012" +#define OS_ASC(c) (c) +#else /* CHARSET_EBCDIC */ +#include "ap_ebcdic.h" +/* OSD_POSIX uses the EBCDIC charset. The transition ASCII->EBCDIC is done in + * the buff package (bread/bputs/bwrite), so everywhere else, we use + * "native EBCDIC" CR and NL characters. These are therefore defined as + * '\r' and '\n'. + * NB: this is not the whole truth - sometimes \015 and \012 are contained + * in literal (EBCDIC!) strings, so these are not converted but passed. + */ +#define CR '\r' +#define LF '\n' +#define CRLF "\r\n" +#define OS_ASC(c) (os_toascii[c]) +#endif /* CHARSET_EBCDIC */ + +/* Possible values for request_rec.read_body (set by handling module): + * REQUEST_NO_BODY Send 413 error if message has any body + * REQUEST_CHUNKED_ERROR Send 411 error if body without Content-Length + * REQUEST_CHUNKED_DECHUNK If chunked, remove the chunks for me. + * REQUEST_CHUNKED_PASS Pass the chunks to me without removal. + */ +#define REQUEST_NO_BODY 0 +#define REQUEST_CHUNKED_ERROR 1 +#define REQUEST_CHUNKED_DECHUNK 2 +#define REQUEST_CHUNKED_PASS 3 + +/* Things which may vary per file-lookup WITHIN a request --- + * e.g., state of MIME config. Basically, the name of an object, info + * about the object, and any other info we may ahve which may need to + * change as we go poking around looking for it (e.g., overridden by + * .htaccess files). + * + * Note how the default state of almost all these things is properly + * zero, so that allocating it with pcalloc does the right thing without + * a whole lot of hairy initialization... so long as we are willing to + * make the (fairly) portable assumption that the bit pattern of a NULL + * pointer is, in fact, zero. + */ + +/* This represents the result of calling htaccess; these are cached for + * each request. + */ +struct htaccess_result { + char *dir; /* the directory to which this applies */ + int override; /* the overrides allowed for the .htaccess file */ + void *htaccess; /* the configuration directives */ +/* the next one, or NULL if no more; N.B. never change this */ + const struct htaccess_result *next; +}; + +typedef struct conn_rec conn_rec; +typedef struct server_rec server_rec; +typedef struct request_rec request_rec; +typedef struct listen_rec listen_rec; + +#include "util_uri.h" + +enum proxyreqtype { + NOT_PROXY=0, + STD_PROXY, + PROXY_PASS +}; + +struct request_rec { + + ap_pool *pool; + conn_rec *connection; + server_rec *server; + + request_rec *next; /* If we wind up getting redirected, + * pointer to the request we redirected to. + */ + request_rec *prev; /* If this is an internal redirect, + * pointer to where we redirected *from*. + */ + + request_rec *main; /* If this is a sub_request (see request.h) + * pointer back to the main request. + */ + + /* Info about the request itself... we begin with stuff that only + * protocol.c should ever touch... + */ + + char *the_request; /* First line of request, so we can log it */ + int assbackwards; /* HTTP/0.9, "simple" request */ + enum proxyreqtype proxyreq;/* A proxy request (calculated during + * post_read_request or translate_name) */ + int header_only; /* HEAD request, as opposed to GET */ + char *protocol; /* Protocol, as given to us, or HTTP/0.9 */ + int proto_num; /* Number version of protocol; 1.1 = 1001 */ + const char *hostname; /* Host, as set by full URI or Host: */ + + time_t request_time; /* When the request started */ + + const char *status_line; /* Status line, if set by script */ + int status; /* In any case */ + + /* Request method, two ways; also, protocol, etc.. Outside of protocol.c, + * look, but don't touch. + */ + + const char *method; /* GET, HEAD, POST, etc. */ + int method_number; /* M_GET, M_POST, etc. */ + + /* + allowed is a bitvector of the allowed methods. + + A handler must ensure that the request method is one that + it is capable of handling. Generally modules should DECLINE + any request methods they do not handle. Prior to aborting the + handler like this the handler should set r->allowed to the list + of methods that it is willing to handle. This bitvector is used + to construct the "Allow:" header required for OPTIONS requests, + and METHOD_NOT_ALLOWED and NOT_IMPLEMENTED status codes. + + Since the default_handler deals with OPTIONS, all modules can + usually decline to deal with OPTIONS. TRACE is always allowed, + modules don't need to set it explicitly. + + Since the default_handler will always handle a GET, a + module which does *not* implement GET should probably return + METHOD_NOT_ALLOWED. Unfortunately this means that a Script GET + handler can't be installed by mod_actions. + */ + int allowed; /* Allowed methods - for 405, OPTIONS, etc */ + + int sent_bodyct; /* byte count in stream is for body */ + long bytes_sent; /* body byte count, for easy access */ + time_t mtime; /* Time the resource was last modified */ + + /* HTTP/1.1 connection-level features */ + + int chunked; /* sending chunked transfer-coding */ + int byterange; /* number of byte ranges */ + char *boundary; /* multipart/byteranges boundary */ + const char *range; /* The Range: header */ + long clength; /* The "real" content length */ + + long remaining; /* bytes left to read */ + long read_length; /* bytes that have been read */ + int read_body; /* how the request body should be read */ + int read_chunked; /* reading chunked transfer-coding */ + unsigned expecting_100; /* is client waiting for a 100 response? */ + + /* MIME header environments, in and out. Also, an array containing + * environment variables to be passed to subprocesses, so people can + * write modules to add to that environment. + * + * The difference between headers_out and err_headers_out is that the + * latter are printed even on error, and persist across internal redirects + * (so the headers printed for ErrorDocument handlers will have them). + * + * The 'notes' table is for notes from one module to another, with no + * other set purpose in mind... + */ + + table *headers_in; + table *headers_out; + table *err_headers_out; + table *subprocess_env; + table *notes; + + /* content_type, handler, content_encoding, content_language, and all + * content_languages MUST be lowercased strings. They may be pointers + * to static strings; they should not be modified in place. + */ + const char *content_type; /* Break these out --- we dispatch on 'em */ + const char *handler; /* What we *really* dispatch on */ + + const char *content_encoding; + const char *content_language; /* for back-compat. only -- do not use */ + array_header *content_languages; /* array of (char*) */ + + char *vlist_validator; /* variant list validator (if negotiated) */ + + int no_cache; + int no_local_copy; + + /* What object is being requested (either directly, or via include + * or content-negotiation mapping). + */ + + char *unparsed_uri; /* the uri without any parsing performed */ + char *uri; /* the path portion of the URI */ + char *filename; /* filename if found, otherwise NULL */ + char *path_info; + char *args; /* QUERY_ARGS, if any */ + struct stat finfo; /* ST_MODE set to zero if no such file */ + uri_components parsed_uri; /* components of uri, dismantled */ + + /* Various other config info which may change with .htaccess files + * These are config vectors, with one void* pointer for each module + * (the thing pointed to being the module's business). + */ + + void *per_dir_config; /* Options set in config files, etc. */ + void *request_config; /* Notes on *this* request */ + +/* + * a linked list of the configuration directives in the .htaccess files + * accessed by this request. + * N.B. always add to the head of the list, _never_ to the end. + * that way, a sub request's list can (temporarily) point to a parent's list + */ + const struct htaccess_result *htaccess; + + /* On systems with case insensitive file systems (Windows, OS/2, etc.), + * r->filename is case canonicalized (folded to either lower or upper + * case, depending on the specific system) to accomodate file access + * checking. case_preserved_filename is the same as r->filename + * except case is preserved. There is at least one instance where Apache + * needs access to the case preserved filename: Java class files published + * with WebDAV need to preserve filename case to make the Java compiler + * happy. + */ + char *case_preserved_filename; + +#ifdef CHARSET_EBCDIC + /* We don't want subrequests to modify our current conversion flags. + * These flags save the state of the conversion flags when subrequests + * are run. + */ + struct { + unsigned conv_in:1; /* convert ASCII->EBCDIC when read()ing? */ + unsigned conv_out:1; /* convert EBCDIC->ASCII when write()ing? */ + } ebcdic; +#endif + +/* Things placed at the end of the record to avoid breaking binary + * compatibility. It would be nice to remember to reorder the entire + * record to improve 64bit alignment the next time we need to break + * binary compatibility for some other reason. + */ +}; + + +/* Things which are per connection + */ + +struct conn_rec { + + ap_pool *pool; + server_rec *server; + server_rec *base_server; /* Physical vhost this conn come in on */ + void *vhost_lookup_data; /* used by http_vhost.c */ + + /* Information about the connection itself */ + + int child_num; /* The number of the child handling conn_rec */ + BUFF *client; /* Connection to the guy */ + + /* Who is the client? */ + + struct sockaddr_in local_addr; /* local address */ + struct sockaddr_in remote_addr; /* remote address */ + char *remote_ip; /* Client's IP address */ + char *remote_host; /* Client's DNS name, if known. + * NULL if DNS hasn't been checked, + * "" if it has and no address was found. + * N.B. Only access this though + * get_remote_host() */ + char *remote_logname; /* Only ever set if doing rfc1413 lookups. + * N.B. Only access this through + * get_remote_logname() */ + char *user; /* If an authentication check was made, + * this gets set to the user name. We assume + * that there's only one user per connection(!) + */ + char *ap_auth_type; /* Ditto. */ + + unsigned aborted:1; /* Are we still talking? */ + signed int keepalive:2; /* Are we using HTTP Keep-Alive? + * -1 fatal error, 0 undecided, 1 yes */ + unsigned keptalive:1; /* Did we use HTTP Keep-Alive? */ + signed int double_reverse:2;/* have we done double-reverse DNS? + * -1 yes/failure, 0 not yet, 1 yes/success */ + int keepalives; /* How many times have we used it? */ + char *local_ip; /* server IP address */ + char *local_host; /* used for ap_get_server_name when + * UseCanonicalName is set to DNS + * (ignores setting of HostnameLookups) */ +}; + +/* Per-vhost config... */ + +/* The address 255.255.255.255, when used as a virtualhost address, + * will become the "default" server when the ip doesn't match other vhosts. + */ +#define DEFAULT_VHOST_ADDR 0xfffffffful + +typedef struct server_addr_rec server_addr_rec; +struct server_addr_rec { + server_addr_rec *next; + struct in_addr host_addr; /* The bound address, for this server */ + unsigned short host_port; /* The bound port, for this server */ + char *virthost; /* The name given in <VirtualHost> */ +}; + +struct server_rec { + + server_rec *next; + + /* description of where the definition came from */ + const char *defn_name; + unsigned defn_line_number; + + /* Full locations of server config info */ + + char *srm_confname; + char *access_confname; + + /* Contact information */ + + char *server_admin; + char *server_hostname; + unsigned short port; /* for redirects, etc. */ + + /* Log files --- note that transfer log is now in the modules... */ + + char *error_fname; + FILE *error_log; + int loglevel; + + /* Module-specific configuration for server, and defaults... */ + + int is_virtual; /* true if this is the virtual server */ + void *module_config; /* Config vector containing pointers to + * modules' per-server config structures. + */ + void *lookup_defaults; /* MIME type info, etc., before we start + * checking per-directory info. + */ + /* Transaction handling */ + + server_addr_rec *addrs; + int timeout; /* Timeout, in seconds, before we give up */ + int keep_alive_timeout; /* Seconds we'll wait for another request */ + int keep_alive_max; /* Maximum requests per connection */ + int keep_alive; /* Use persistent connections? */ + int send_buffer_size; /* size of TCP send buffer (in bytes) */ + + char *path; /* Pathname for ServerPath */ + int pathlen; /* Length of path */ + + array_header *names; /* Normal names for ServerAlias servers */ + array_header *wild_names; /* Wildcarded names for ServerAlias servers */ + + uid_t server_uid; /* effective user id when calling exec wrapper */ + gid_t server_gid; /* effective group id when calling exec wrapper */ + + int limit_req_line; /* limit on size of the HTTP request line */ + int limit_req_fieldsize; /* limit on size of any request header field */ + int limit_req_fields; /* limit on number of request header fields */ +}; + +/* These are more like real hosts than virtual hosts */ +struct listen_rec { + listen_rec *next; + struct sockaddr_in local_addr; /* local IP address and port */ + int fd; + int used; /* Only used during restart */ +/* more stuff here, like which protocol is bound to the port */ +}; + +/* Prototypes for utilities... util.c. + */ + +extern void ap_util_init(void); + +/* Time */ +extern API_VAR_EXPORT const char ap_month_snames[12][4]; +extern API_VAR_EXPORT const char ap_day_snames[7][4]; + +API_EXPORT(struct tm *) ap_get_gmtoff(int *tz); +API_EXPORT(char *) ap_get_time(void); +API_EXPORT(char *) ap_field_noparam(pool *p, const char *intype); +API_EXPORT(char *) ap_ht_time(pool *p, time_t t, const char *fmt, int gmt); +API_EXPORT(char *) ap_gm_timestr_822(pool *p, time_t t); + +/* String handling. The *_nc variants allow you to use non-const char **s as + arguments (unfortunately C won't automatically convert a char ** to a const + char **) */ + +API_EXPORT(char *) ap_getword(pool *p, const char **line, char stop); +API_EXPORT(char *) ap_getword_nc(pool *p, char **line, char stop); +API_EXPORT(char *) ap_getword_white(pool *p, const char **line); +API_EXPORT(char *) ap_getword_white_nc(pool *p, char **line); +API_EXPORT(char *) ap_getword_nulls(pool *p, const char **line, char stop); +API_EXPORT(char *) ap_getword_nulls_nc(pool *p, char **line, char stop); +API_EXPORT(char *) ap_getword_conf(pool *p, const char **line); +API_EXPORT(char *) ap_getword_conf_nc(pool *p, char **line); + +API_EXPORT(const char *) ap_size_list_item(const char **field, int *len); +API_EXPORT(char *) ap_get_list_item(pool *p, const char **field); +API_EXPORT(int) ap_find_list_item(pool *p, const char *line, const char *tok); + +API_EXPORT(char *) ap_get_token(pool *p, const char **accept_line, int accept_white); +API_EXPORT(int) ap_find_token(pool *p, const char *line, const char *tok); +API_EXPORT(int) ap_find_last_token(pool *p, const char *line, const char *tok); + +API_EXPORT(int) ap_is_url(const char *u); +API_EXPORT(int) ap_unescape_url(char *url); +API_EXPORT(void) ap_no2slash(char *name); +API_EXPORT(void) ap_getparents(char *name); +API_EXPORT(char *) ap_escape_path_segment(pool *p, const char *s); +API_EXPORT(char *) ap_os_escape_path(pool *p, const char *path, int partial); +#define ap_escape_uri(ppool,path) ap_os_escape_path(ppool,path,1) +API_EXPORT(char *) ap_escape_html(pool *p, const char *s); +API_EXPORT(char *) ap_construct_server(pool *p, const char *hostname, + unsigned port, const request_rec *r); +API_EXPORT(char *) ap_escape_logitem(pool *p, const char *str); +API_EXPORT(size_t) ap_escape_errorlog_item(char *dest, const char *source, + size_t buflen); +API_EXPORT(char *) ap_escape_shell_cmd(pool *p, const char *s); + +API_EXPORT(int) ap_count_dirs(const char *path); +API_EXPORT(char *) ap_make_dirstr_prefix(char *d, const char *s, int n); +API_EXPORT(char *) ap_make_dirstr_parent(pool *p, const char *s); +/* deprecated. The previous two routines are preferred. */ +API_EXPORT(char *) ap_make_dirstr(pool *a, const char *s, int n); +API_EXPORT(char *) ap_make_full_path(pool *a, const char *dir, const char *f); + +API_EXPORT(int) ap_is_matchexp(const char *str); +API_EXPORT(int) ap_strcmp_match(const char *str, const char *exp); +API_EXPORT(int) ap_strcasecmp_match(const char *str, const char *exp); +API_EXPORT(char *) ap_stripprefix(const char *bigstring, const char *prefix); +API_EXPORT(char *) ap_strcasestr(const char *s1, const char *s2); +API_EXPORT(char *) ap_pbase64decode(pool *p, const char *bufcoded); +API_EXPORT(char *) ap_pbase64encode(pool *p, char *string); +API_EXPORT(char *) ap_uudecode(pool *p, const char *bufcoded); +API_EXPORT(char *) ap_uuencode(pool *p, char *string); + +#if defined(OS2) || defined(WIN32) +API_EXPORT(char *) ap_double_quotes(pool *p, const char *str); +API_EXPORT(char *) ap_caret_escape_args(pool *p, const char *str); +#endif + +#ifdef OS2 +void os2pathname(char *path); +#endif + +API_EXPORT(int) ap_regexec(const regex_t *preg, const char *string, + size_t nmatch, regmatch_t pmatch[], int eflags); +API_EXPORT(size_t) ap_regerror(int errcode, const regex_t *preg, + char *errbuf, size_t errbuf_size); +API_EXPORT(char *) ap_pregsub(pool *p, const char *input, const char *source, + size_t nmatch, regmatch_t pmatch[]); + +API_EXPORT(void) ap_content_type_tolower(char *); +API_EXPORT(void) ap_str_tolower(char *); +API_EXPORT(int) ap_ind(const char *, char); /* Sigh... */ +API_EXPORT(int) ap_rind(const char *, char); + +API_EXPORT(char *) ap_escape_quotes (pool *p, const char *instring); +API_EXPORT(void) ap_remove_spaces(char *dest, char *src); + +/* Common structure for reading of config files / passwd files etc. */ +typedef struct { + int (*getch) (void *param); /* a getc()-like function */ + void *(*getstr) (void *buf, size_t bufsiz, void *param); /* a fgets()-like function */ + int (*close) (void *param); /* a close hander function */ + void *param; /* the argument passed to getch/getstr/close */ + const char *name; /* the filename / description */ + unsigned line_number; /* current line number, starting at 1 */ +} configfile_t; + +/* Open a configfile_t as FILE, return open configfile_t struct pointer */ +API_EXPORT(configfile_t *) ap_pcfg_openfile(pool *p, const char *name); + +/* Allocate a configfile_t handle with user defined functions and params */ +API_EXPORT(configfile_t *) ap_pcfg_open_custom(pool *p, const char *descr, + void *param, + int(*getc_func)(void*), + void *(*gets_func) (void *buf, size_t bufsiz, void *param), + int(*close_func)(void *param)); + +/* Read one line from open configfile_t, strip LF, increase line number */ +API_EXPORT(int) ap_cfg_getline(char *buf, size_t bufsize, configfile_t *cfp); + +/* Read one char from open configfile_t, increase line number upon LF */ +API_EXPORT(int) ap_cfg_getc(configfile_t *cfp); + +/* Detach from open configfile_t, calling the close handler */ +API_EXPORT(int) ap_cfg_closefile(configfile_t *cfp); + +#ifdef NEED_STRERROR +char *strerror(int err); +#endif + +/* Misc system hackery */ + +API_EXPORT(uid_t) ap_uname2id(const char *name); +API_EXPORT(gid_t) ap_gname2id(const char *name); +API_EXPORT(int) ap_is_directory(const char *name); +API_EXPORT(int) ap_is_rdirectory(const char *name); +API_EXPORT(int) ap_can_exec(const struct stat *); +API_EXPORT(void) ap_chdir_file(const char *file); + +#ifndef HAVE_CANONICAL_FILENAME +/* + * We can't define these in os.h because of dependence on pool pointer. + */ +#define ap_os_canonical_filename(p,f) (f) +#define ap_os_case_canonical_filename(p,f) (f) +#define ap_os_systemcase_filename(p,f) (f) +#else +API_EXPORT(char *) ap_os_canonical_filename(pool *p, const char *file); +#ifdef WIN32 +API_EXPORT(char *) ap_os_case_canonical_filename(pool *pPool, const char *szFile); +API_EXPORT(char *) ap_os_systemcase_filename(pool *pPool, const char *szFile); +#elif defined(OS2) +API_EXPORT(char *) ap_os_case_canonical_filename(pool *pPool, const char *szFile); +API_EXPORT(char *) ap_os_systemcase_filename(pool *pPool, const char *szFile); +#elif defined(NETWARE) +API_EXPORT(char *) ap_os_case_canonical_filename(pool *pPool, const char *szFile); +#define ap_os_systemcase_filename(p,f) ap_os_case_canonical_filename(p,f) +#else +#define ap_os_case_canonical_filename(p,f) ap_os_canonical_filename(p,f) +#define ap_os_systemcase_filename(p,f) ap_os_canonical_filename(p,f) +#endif +#endif + +#ifdef CHARSET_EBCDIC +API_EXPORT(int) ap_checkconv(struct request_rec *r); /* for downloads */ +API_EXPORT(int) ap_checkconv_in(struct request_rec *r); /* for uploads */ +#endif /*#ifdef CHARSET_EBCDIC*/ + +API_EXPORT(char *) ap_get_local_host(pool *); +API_EXPORT(unsigned long) ap_get_virthost_addr(char *hostname, unsigned short *port); + +extern API_VAR_EXPORT time_t ap_restart_time; + +/* + * Apache tries to keep all of its long term filehandles (such as log files, + * and sockets) above this number. This is to workaround problems in many + * third party libraries that are compiled with a small FD_SETSIZE. There + * should be no reason to lower this, because it's only advisory. If a file + * can't be allocated above this number then it will remain in the "slack" + * area. + * + * Only the low slack line is used by default. If HIGH_SLACK_LINE is defined + * then an attempt is also made to keep all non-FILE * files above the high + * slack line. This is to work around a Solaris C library limitation, where it + * uses an unsigned char to store the file descriptor. + */ +#ifndef LOW_SLACK_LINE +#define LOW_SLACK_LINE 15 +#endif +/* #define HIGH_SLACK_LINE 255 */ + +/* + * The ap_slack() function takes a fd, and tries to move it above the indicated + * line. It returns an fd which may or may not have moved above the line, and + * never fails. If the high line was requested and it fails it will also try + * the low line. + */ +#ifdef NO_SLACK +#define ap_slack(fd,line) (fd) +#else +int ap_slack(int fd, int line); +#define AP_SLACK_LOW 1 +#define AP_SLACK_HIGH 2 +#endif + +API_EXPORT(char *) ap_escape_quotes(pool *p, const char *instr); + +/* + * Redefine assert() to something more useful for an Apache... + */ +API_EXPORT(void) ap_log_assert(const char *szExp, const char *szFile, int nLine) + __attribute__((noreturn)); +#define ap_assert(exp) ((exp) ? (void)0 : ap_log_assert(#exp,__FILE__,__LINE__)) + +/* The optimized timeout code only works if we're not MULTITHREAD and we're + * also not using a scoreboard file + */ +#if !defined (MULTITHREAD) && \ + (defined (USE_MMAP_SCOREBOARD) || defined (USE_SHMGET_SCOREBOARD)) +#define OPTIMIZE_TIMEOUTS +#endif + +/* A set of flags which indicate places where the server should raise(SIGSTOP). + * This is useful for debugging, because you can then attach to that process + * with gdb and continue. This is important in cases where one_process + * debugging isn't possible. + */ +#define SIGSTOP_DETACH 1 +#define SIGSTOP_MAKE_CHILD 2 +#define SIGSTOP_SPAWN_CHILD 4 +#define SIGSTOP_PIPED_LOG_SPAWN 8 +#define SIGSTOP_CGI_CHILD 16 + +#ifdef DEBUG_SIGSTOP +extern int raise_sigstop_flags; +#define RAISE_SIGSTOP(x) do { \ + if (raise_sigstop_flags & SIGSTOP_##x) raise(SIGSTOP);\ + } while (0) +#else +#define RAISE_SIGSTOP(x) +#endif + +API_EXPORT(extern const char *) ap_psignature(const char *prefix, request_rec *r); + +/* strtoul does not exist on sunos4. */ +#ifdef strtoul +#undef strtoul +#endif +#define strtoul strtoul_is_not_a_portable_function_use_strtol_instead + +#ifdef AP_ENABLE_EXCEPTION_HOOK +/* The exception hook allows a module to run from the server's signal + * handler, and perform tasks such as logging the current request or + * getting a backtrace or performing other diagnostic functions. All + * operating system requirements for running in a signal handler must + * be respected, or the process may not exit properly. + * + * AP_ENABLE_EXCEPTION_HOOK is already defined for platforms that have + * been tested. It likely will work on other platforms. In order to + * test, define AP_ENABLE_EXCEPTION_HOOK at configure time. + */ +typedef struct ap_exception_info_t { + int sig; + pid_t pid; +} ap_exception_info_t; + +/* Register a function to be called after a fatal exception (on *X systems, a + * "synchronous signal" such as SIGSEGV, SIGILL, etc.). + * + * Returns 0 on success, non-zero on failure. + * If EnableExceptionHook directive is not set to "on", this function will + * report failure and no such hooks will be called. + */ +API_EXPORT(extern int) ap_add_fatal_exception_hook(void (*fn)(ap_exception_info_t *)); +#endif /* AP_ENABLE_EXCEPTION_HOOK */ + +#ifdef __cplusplus +} +#endif + +#endif /* !APACHE_HTTPD_H */ diff --git a/APACHE_1_3_42/src/include/multithread.h b/APACHE_1_3_42/src/include/multithread.h new file mode 100644 index 0000000000..182936ab9b --- /dev/null +++ b/APACHE_1_3_42/src/include/multithread.h @@ -0,0 +1,85 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef APACHE_MULTITHREAD_H +#define APACHE_MULTITHREAD_H + +#ifdef __cplusplus +extern "C" { +#endif + +#define MULTI_OK (0) +#define MULTI_TIMEOUT (1) +#define MULTI_ERR (2) + +typedef void mutex; +typedef void semaphore; +typedef void thread; +typedef void event; + +/* + * Ambarish: Need to do the right stuff on multi-threaded unix + * I believe this is terribly ugly + */ +#ifdef MULTITHREAD +#ifdef NETWARE +#define APACHE_TLS +#else +#define APACHE_TLS __declspec( thread ) +#endif + +thread *create_thread(void (thread_fn) (void *thread_arg), void *thread_arg); +int kill_thread(thread *thread_id); +int await_thread(thread *thread_id, int sec_to_wait); +void exit_thread(int status); +void free_thread(thread *thread_id); + +API_EXPORT(mutex *) ap_create_mutex(char *name); +API_EXPORT(mutex *) ap_open_mutex(char *name); +API_EXPORT(int) ap_acquire_mutex(mutex *mutex_id); +API_EXPORT(int) ap_release_mutex(mutex *mutex_id); +API_EXPORT(void) ap_destroy_mutex(mutex *mutex_id); + +semaphore *create_semaphore(int initial); +int acquire_semaphore(semaphore *semaphore_id); +int release_semaphore(semaphore *semaphore_id); +void destroy_semaphore(semaphore *semaphore_id); + +event *create_event(int manual, int initial, char *name); +event *open_event(char *name); +int acquire_event(event *event_id); +int set_event(event *event_id); +int reset_event(event *event_id); +void destroy_event(event *event_id); + +#else /* ndef MULTITHREAD */ + +#define APACHE_TLS +/* Only define the ones actually used, for now */ +extern void *ap_dummy_mutex; + +#define ap_create_mutex(name) ((mutex *)ap_dummy_mutex) +#define ap_acquire_mutex(mutex_id) ((int)MULTI_OK) +#define ap_release_mutex(mutex_id) ((int)MULTI_OK) +#define ap_destroy_mutex(mutex_id) + +#endif /* ndef MULTITHREAD */ + +#ifdef __cplusplus +} +#endif + +#endif /* !APACHE_MULTITHREAD_H */ diff --git a/APACHE_1_3_42/src/include/rfc1413.h b/APACHE_1_3_42/src/include/rfc1413.h new file mode 100644 index 0000000000..62fbe4d1e7 --- /dev/null +++ b/APACHE_1_3_42/src/include/rfc1413.h @@ -0,0 +1,30 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef APACHE_RFC1413_H +#define APACHE_RFC1413_H + +#ifdef __cplusplus +extern "C" { +#endif + +API_EXPORT(extern char *) ap_rfc1413(conn_rec *conn, server_rec *srv); + +#ifdef __cplusplus +} +#endif + +#endif /* !APACHE_RFC1413_H */ diff --git a/APACHE_1_3_42/src/include/scoreboard.h b/APACHE_1_3_42/src/include/scoreboard.h new file mode 100644 index 0000000000..67b56b6631 --- /dev/null +++ b/APACHE_1_3_42/src/include/scoreboard.h @@ -0,0 +1,162 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef APACHE_SCOREBOARD_H +#define APACHE_SCOREBOARD_H + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef WIN32 +#if defined(TPF41) || defined(NETWARE) +#include <time.h> +#else +#include <sys/times.h> +#endif /* TPF41 || NETWARE */ +#endif + + +/* Scoreboard info on a process is, for now, kept very brief --- + * just status value and pid (the latter so that the caretaker process + * can properly update the scoreboard when a process dies). We may want + * to eventually add a separate set of long_score structures which would + * give, for each process, the number of requests serviced, and info on + * the current, or most recent, request. + * + * Status values: + */ + +#define SERVER_DEAD 0 +#define SERVER_STARTING 1 /* Server Starting up */ +#define SERVER_READY 2 /* Waiting for connection (or accept() lock) */ +#define SERVER_BUSY_READ 3 /* Reading a client request */ +#define SERVER_BUSY_WRITE 4 /* Processing a client request */ +#define SERVER_BUSY_KEEPALIVE 5 /* Waiting for more requests via keepalive */ +#define SERVER_BUSY_LOG 6 /* Logging the request */ +#define SERVER_BUSY_DNS 7 /* Looking up a hostname */ +#define SERVER_GRACEFUL 8 /* server is gracefully finishing request */ +#define SERVER_NUM_STATUS 9 /* number of status settings */ + +/* A "virtual time" is simply a counter that indicates that a child is + * making progress. The parent checks up on each child, and when they have + * made progress it resets the last_rtime element. But when the child hasn't + * made progress in a time that's roughly timeout_len seconds long, it is + * sent a SIGALRM. + * + * vtime is an optimization that is used only when the scoreboard is in + * shared memory (it's not easy/feasible to do it in a scoreboard file). + * The essential observation is that timeouts rarely occur, the vast majority + * of hits finish before any timeout happens. So it really sucks to have to + * ask the operating system to set up and destroy alarms many times during + * a request. + */ +typedef unsigned vtime_t; + +/* Type used for generation indicies. Startup and every restart cause a + * new generation of children to be spawned. Children within the same + * generation share the same configuration information -- pointers to stuff + * created at config time in the parent are valid across children. For + * example, the vhostrec pointer in the scoreboard below is valid in all + * children of the same generation. + * + * The safe way to access the vhost pointer is like this: + * + * short_score *ss = pointer to whichver slot is interesting; + * parent_score *ps = pointer to whichver slot is interesting; + * server_rec *vh = ss->vhostrec; + * + * if (ps->generation != ap_my_generation) { + * vh = NULL; + * } + * + * then if vh is not NULL it's valid in this child. + * + * This avoids various race conditions around restarts. + */ +typedef int ap_generation_t; + +/* stuff which the children generally write, and the parent mainly reads */ +typedef struct { +#ifdef OPTIMIZE_TIMEOUTS + vtime_t cur_vtime; /* the child's current vtime */ + unsigned short timeout_len; /* length of the timeout */ +#endif + unsigned char status; + unsigned long access_count; + unsigned long bytes_served; + unsigned long my_access_count; + unsigned long my_bytes_served; + unsigned long conn_bytes; + unsigned short conn_count; +#if defined(NO_GETTIMEOFDAY) + clock_t start_time; + clock_t stop_time; +#else + struct timeval start_time; + struct timeval stop_time; +#endif +#ifndef NO_TIMES + struct tms times; +#endif +#ifndef OPTIMIZE_TIMEOUTS + time_t last_used; +#endif + char client[32]; /* Keep 'em small... */ + char request[64]; /* We just want an idea... */ + server_rec *vhostrec; /* What virtual host is being accessed? */ + /* SEE ABOVE FOR SAFE USAGE! */ +} short_score; + +typedef struct { + ap_generation_t running_generation; /* the generation of children which + * should still be serving requests. */ +} global_score; + +/* stuff which the parent generally writes and the children rarely read */ +typedef struct { + pid_t pid; +#ifdef OPTIMIZE_TIMEOUTS + time_t last_rtime; /* time(0) of the last change */ + vtime_t last_vtime; /* the last vtime the parent has seen */ +#endif + ap_generation_t generation; /* generation of this child */ +} parent_score; + +typedef struct { + short_score servers[HARD_SERVER_LIMIT]; + parent_score parent[HARD_SERVER_LIMIT]; + global_score global; +} scoreboard; + +#define SCOREBOARD_SIZE sizeof(scoreboard) + +API_EXPORT(void) ap_sync_scoreboard_image(void); +API_EXPORT(int) ap_exists_scoreboard_image(void); + +API_VAR_EXPORT extern scoreboard *ap_scoreboard_image; + +API_VAR_EXPORT extern ap_generation_t volatile ap_my_generation; + +/* for time_process_request() in http_main.c */ +#define START_PREQUEST 1 +#define STOP_PREQUEST 2 + +#ifdef __cplusplus +} +#endif + +#endif /* !APACHE_SCOREBOARD_H */ diff --git a/APACHE_1_3_42/src/include/util_date.h b/APACHE_1_3_42/src/include/util_date.h new file mode 100644 index 0000000000..b7c851520a --- /dev/null +++ b/APACHE_1_3_42/src/include/util_date.h @@ -0,0 +1,44 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef APACHE_UTIL_DATE_H +#define APACHE_UTIL_DATE_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * util_date.h: prototypes for date parsing utility routines + */ + +#ifdef NEWSOS +#include <stdlib.h> +#include <sys/types.h> +#endif +#include <time.h> + +#define BAD_DATE (time_t)0 + +API_EXPORT(int) ap_checkmask(const char *data, const char *mask); +API_EXPORT(time_t) ap_tm2sec(const struct tm *t); +API_EXPORT(time_t) ap_parseHTTPdate(const char *date); + +#ifdef __cplusplus +} +#endif + +#endif /* !APACHE_UTIL_DATE_H */ diff --git a/APACHE_1_3_42/src/include/util_md5.h b/APACHE_1_3_42/src/include/util_md5.h new file mode 100644 index 0000000000..251e28953f --- /dev/null +++ b/APACHE_1_3_42/src/include/util_md5.h @@ -0,0 +1,39 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef APACHE_UTIL_MD5_H +#define APACHE_UTIL_MD5_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include "ap_md5.h" + +API_EXPORT(char *) ap_md5(pool *a, const unsigned char *string); +API_EXPORT(char *) ap_md5_binary(pool *a, const unsigned char *buf, int len); +API_EXPORT(char *) ap_md5contextTo64(pool *p, AP_MD5_CTX * context); +#ifdef CHARSET_EBCDIC +API_EXPORT(char *) ap_md5digest(pool *p, FILE *infile, int convert); +#else +API_EXPORT(char *) ap_md5digest(pool *p, FILE *infile); +#endif /* CHARSET_EBCDIC */ + +#ifdef __cplusplus +} +#endif + +#endif /* !APACHE_UTIL_MD5_H */ diff --git a/APACHE_1_3_42/src/include/util_script.h b/APACHE_1_3_42/src/include/util_script.h new file mode 100644 index 0000000000..8103e8a994 --- /dev/null +++ b/APACHE_1_3_42/src/include/util_script.h @@ -0,0 +1,54 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef APACHE_UTIL_SCRIPT_H +#define APACHE_UTIL_SCRIPT_H + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef APACHE_ARG_MAX +#ifdef _POSIX_ARG_MAX +#define APACHE_ARG_MAX _POSIX_ARG_MAX +#else +#define APACHE_ARG_MAX 512 +#endif +#endif + +API_EXPORT(char **) ap_create_environment(pool *p, table *t); +API_EXPORT(int) ap_find_path_info(const char *uri, const char *path_info); +API_EXPORT(void) ap_add_cgi_vars(request_rec *r); +API_EXPORT(void) ap_add_common_vars(request_rec *r); +API_EXPORT(int) ap_scan_script_header_err(request_rec *r, FILE *f, char *buffer); +API_EXPORT(int) ap_scan_script_header_err_buff(request_rec *r, BUFF *f, + char *buffer); +API_EXPORT(int) ap_scan_script_header_err_core(request_rec *r, char *buffer, + int (*getsfunc) (char *, int, void *), + void *getsfunc_data); +API_EXPORT_NONSTD(int) ap_scan_script_header_err_strs(request_rec *r, + char *buffer, + const char **termch, + int *termarg, ...); +API_EXPORT(void) ap_send_size(size_t size, request_rec *r); +API_EXPORT(int) ap_call_exec(request_rec *r, child_info *pinfo, char *argv0, char **env, + int shellcmd); + +#ifdef __cplusplus +} +#endif + +#endif /* !APACHE_UTIL_SCRIPT_H */ diff --git a/APACHE_1_3_42/src/include/util_uri.h b/APACHE_1_3_42/src/include/util_uri.h new file mode 100644 index 0000000000..247f5d9ddb --- /dev/null +++ b/APACHE_1_3_42/src/include/util_uri.h @@ -0,0 +1,90 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * util_uri.h: External Interface of util_uri.c + */ + +#ifndef UTIL_URI_H +#define UTIL_URI_H + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct { + const char *name; + unsigned short default_port; +} schemes_t; + +#define DEFAULT_FTP_DATA_PORT 20 +#define DEFAULT_FTP_PORT 21 +#define DEFAULT_GOPHER_PORT 70 +#define DEFAULT_NNTP_PORT 119 +#define DEFAULT_WAIS_PORT 210 +#define DEFAULT_SNEWS_PORT 563 +#define DEFAULT_PROSPERO_PORT 1525 /* WARNING: conflict w/Oracle */ + +#define DEFAULT_URI_SCHEME "http" + +/* Flags passed to unparse_uri_components(): */ +#define UNP_OMITSITEPART (1U<<0) /* suppress "scheme://user@site:port" */ +#define UNP_OMITUSER (1U<<1) /* Just omit user */ +#define UNP_OMITPASSWORD (1U<<2) /* Just omit password */ +#define UNP_OMITUSERINFO (UNP_OMITUSER|UNP_OMITPASSWORD) /* omit "user:password@" part */ +#define UNP_REVEALPASSWORD (1U<<3) /* Show plain text password (default: show XXXXXXXX) */ +#define UNP_OMITPATHINFO (1U<<4) /* Show "scheme://user@site:port" only */ +#define UNP_OMITQUERY (1U<<5) /* Omit the "?queryarg" from the path */ + +typedef struct { + char *scheme; /* scheme ("http"/"ftp"/...) */ + char *hostinfo; /* combined [user[:password]@]host[:port] */ + char *user; /* user name, as in http://user:passwd@host:port/ */ + char *password; /* password, as in http://user:passwd@host:port/ */ + char *hostname; /* hostname from URI (or from Host: header) */ + char *port_str; /* port string (integer representation is in "port") */ + char *path; /* the request path (or "/" if only scheme://host was given) */ + char *query; /* Everything after a '?' in the path, if present */ + char *fragment; /* Trailing "#fragment" string, if present */ + + struct hostent *hostent; + + unsigned short port; /* The port number, numeric, valid only if port_str != NULL */ + + unsigned is_initialized:1; + + unsigned dns_looked_up:1; + unsigned dns_resolved:1; + +} uri_components; + +/* util_uri.c */ +API_EXPORT(unsigned short) ap_default_port_for_scheme(const char *scheme_str); +API_EXPORT(unsigned short) ap_default_port_for_request(const request_rec *r); +API_EXPORT(struct hostent *) ap_pduphostent(pool *p, const struct hostent *hp); +API_EXPORT(struct hostent *) ap_pgethostbyname(pool *p, const char *hostname); +API_EXPORT(char *) ap_unparse_uri_components(pool *p, const uri_components *uptr, + unsigned flags); +API_EXPORT(int) ap_parse_uri_components(pool *p, const char *uri, uri_components *uptr); +API_EXPORT(int) ap_parse_hostinfo_components(pool *p, const char *hostinfo, uri_components *uptr); +/* called by the core in main() */ +extern void ap_util_uri_init(void); + +#ifdef __cplusplus +} +#endif + +#endif /*UTIL_URI_H*/ |