void ap_listen_pre_config(void);
int ap_listen_open(process_rec *process, unsigned port);
-const char *ap_set_listenbacklog(cmd_parms *cmd, void *dummy, char *arg);
-const char *ap_set_listener(cmd_parms *cmd, void *dummy, char *ips);
-const char *ap_set_send_buffer_size(cmd_parms *cmd, void *dummy, char *arg);
+const char *ap_set_listenbacklog(cmd_parms *cmd, void *dummy, const char *arg);
+const char *ap_set_listener(cmd_parms *cmd, void *dummy, const char *ips);
+const char *ap_set_send_buffer_size(cmd_parms *cmd, void *dummy,
+ const char *arg);
#define LISTEN_COMMANDS \
-{ "ListenBacklog", ap_set_listenbacklog, NULL, RSRC_CONF, TAKE1, \
- "Maximum length of the queue of pending connections, as used by listen(2)" }, \
-{ "Listen", ap_set_listener, NULL, RSRC_CONF, TAKE1, \
- "A port number or a numeric IP address and a port number"}, \
-{ "SendBufferSize", ap_set_send_buffer_size, NULL, RSRC_CONF, TAKE1, \
- "Send buffer size in bytes"},
+AP_INIT_TAKE1("ListenBacklog", ap_set_listenbacklog, NULL, RSRC_CONF, \
+ "Maximum length of the queue of pending connections, as used by listen(2)"), \
+AP_INIT_TAKE1("Listen", ap_set_listener, NULL, RSRC_CONF, \
+ "A port number or a numeric IP address and a port number"), \
+AP_INIT_TAKE1("SendBufferSize", ap_set_send_buffer_size, NULL, RSRC_CONF, \
+ "Send buffer size in bytes"),
#endif
API_EXPORT(char *) ap_getword_nulls_nc(ap_pool_t *p, char **line, char stop);
API_EXPORT(char *) ap_getword_conf(ap_pool_t *p, const char **line);
API_EXPORT(char *) ap_getword_conf_nc(ap_pool_t *p, char **line);
-API_EXPORT(char *) ap_resolve_env(ap_pool_t *p, const char * word);
+API_EXPORT(const char *) ap_resolve_env(ap_pool_t *p, const char * word);
API_EXPORT(const char *) ap_size_list_item(const char **field, int *len);
API_EXPORT(char *) ap_get_list_item(ap_pool_t *p, const char **field);
*/
#ifdef AP_DEBUG
+# define strchr(s, c) ap_strchr(s,c)
# define strrchr(s, c) ap_strrchr(s,c)
+char *ap_strchr(char *s, int c);
+const char *ap_strchr_c(const char *s, int c);
char *ap_strrchr(char *s, int c);
const char *ap_strrchr_c(const char *s, int c);
#else
+# define ap_strchr(s, c) strchr(s, c)
+# define ap_strchr_c(s, c) strchr(s, c)
# define ap_strrchr(s, c) strrchr(s, c)
# define ap_strrchr_c(s, c) strrchr(s, c)
if (*in == '{') {
++in;
start_of_var_name = in;
- in = strchr(in, '}');
+ in = ap_strchr_c(in, '}');
if (in == NULL) {
ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR,
0, r, "Missing '}' on variable \"%s\"",
char *w;
const char *args = r->args;
- if (!args || !args[0] || strchr(args, '=')) {
+ if (!args || !args[0] || ap_strchr_c(args, '=')) {
numwords = 1;
}
else {
* If the filename includes a path, extract just the name itself
* for the simple matches.
*/
- if ((filename_only = strrchr(filename_full, '/')) == NULL) {
+ if ((filename_only = ap_strrchr_c(filename_full, '/')) == NULL) {
filename_only = filename_full;
}
else {
}
/* Heuristic to determine second argument. */
- if (strchr(msg,' '))
+ if (ap_strchr_c(msg,' '))
what = MSG;
else if (msg[0] == '/')
what = LOCAL_PATH;
return 0;
}
- if (!strchr(range, ',')) {
+ if (!ap_strchr_c(range, ',')) {
/* A single range */
if (!parse_byterange(ap_pstrdup(r->pool, range + 6), r->clength,
&range_start, &range_end))
* not even have to redo access checks.
*/
- if (strchr(new_file, '/') == NULL) {
+ if (ap_strchr_c(new_file, '/') == NULL) {
char *udir = ap_make_dirstr_parent(rnew->pool, r->uri);
rnew->uri = ap_make_full_path(rnew->pool, udir, new_file);
}
-const char *unixd_set_user(cmd_parms *cmd, void *dummy, char *arg)
+const char *unixd_set_user(cmd_parms *cmd, void *dummy, const char *arg)
{
const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
if (err != NULL) {
return NULL;
}
-const char *unixd_set_group(cmd_parms *cmd, void *dummy, char *arg)
+const char *unixd_set_group(cmd_parms *cmd, void *dummy, const char *arg)
{
const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
if (err != NULL) {
void unixd_detach(void);
int unixd_setup_child(void);
void unixd_pre_config(void);
-const char *unixd_set_user(cmd_parms *cmd, void *dummy, char *arg);
-const char *unixd_set_group(cmd_parms *cmd, void *dummy, char *arg);
+const char *unixd_set_user(cmd_parms *cmd, void *dummy, const char *arg);
+const char *unixd_set_group(cmd_parms *cmd, void *dummy, const char *arg);
#if defined(RLIMIT_CPU) || defined(RLIMIT_DATA) || defined(RLIMIT_VMEM) || \
defined(RLIMIT_NPROC) || defined(RLIMIT_AS)
API_EXPORT(void) unixd_set_rlimit(cmd_parms *cmd, struct rlimit **plimit,
#endif /* HAVE_KILLPG */
#define UNIX_DAEMON_COMMANDS \
-{ "User", unixd_set_user, NULL, RSRC_CONF, TAKE1, \
- "Effective user id for this server"}, \
-{ "Group", unixd_set_group, NULL, RSRC_CONF, TAKE1, \
- "Effective group id for this server"}, \
+AP_INIT_TAKE1("User", unixd_set_user, NULL, RSRC_CONF, \
+ "Effective user id for this server"), \
+AP_INIT_TAKE1("Group", unixd_set_group, NULL, RSRC_CONF, \
+ "Effective group id for this server"),
#endif
http_protocol.c http_request.c http_vhost.c util.c util_date.c \
util_script.c util_uri.c util_md5.c util_cfgtree.c util_ebcdic.c \
rfc1413.c http_connection.c iol_file.c listen.c mpm_common.c \
- util_charset.c
+ util_charset.c util_debug.c
include $(top_srcdir)/build/ltlib.mk
gen_uri_delims: $(gen_uri_delims_OBJECTS)
$(LINK) $(EXTRA_LDFLAGS) $(gen_uri_delims_OBJECTS)
-gen_test_char_OBJECTS = gen_test_char.lo
+gen_test_char_OBJECTS = gen_test_char.lo util_debug.lo
gen_test_char: $(gen_test_char_OBJECTS)
$(LINK) $(EXTRA_LDFLAGS) $(gen_test_char_OBJECTS)
int nwildhandlers = 0;
const handler_rec *handp;
fast_handler_rec *ph, *pw;
- char *starp;
+ const char *starp;
for (modp = top_module; modp; modp = modp->next) {
if (!modp->handlers)
continue;
for (handp = modp->handlers; handp->content_type; ++handp) {
- if (strchr(handp->content_type, '*')) {
+ if (ap_strchr_c(handp->content_type, '*')) {
nwildhandlers ++;
} else {
nhandlers ++;
if (!modp->handlers)
continue;
for (handp = modp->handlers; handp->content_type; ++handp) {
- if ((starp = strchr(handp->content_type, '*'))) {
+ if ((starp = ap_strchr_c(handp->content_type, '*'))) {
pw->hr.content_type = handp->content_type;
pw->hr.handler = handp->handler;
pw->len = starp - handp->content_type;
{
fast_handler_rec *handp;
const char *handler;
- char *p;
+ const char *p;
size_t handler_len;
int result = HTTP_INTERNAL_SERVER_ERROR;
}
else {
handler = r->content_type ? r->content_type : ap_default_type(r);
- if ((p = strchr(handler, ';')) != NULL) { /* MIME type arguments */
+ if ((p = ap_strchr_c(handler, ';')) != NULL) {
+ /* MIME type arguments */
while (p > handler && p[-1] == ' ')
--p; /* strip trailing spaces */
handler_len = p - handler;
}
-const char *ap_set_listener(cmd_parms *cmd, void *dummy, char *ips)
+const char *ap_set_listener(cmd_parms *cmd, void *dummy, const char *ips_)
{
+ char *ips=ap_pstrdup(cmd->pool, ips_);
char *ports;
unsigned short port;
return NULL;
}
-const char *ap_set_listenbacklog(cmd_parms *cmd, void *dummy, char *arg)
+const char *ap_set_listenbacklog(cmd_parms *cmd, void *dummy, const char *arg)
{
int b;
return NULL;
}
-const char *ap_set_send_buffer_size(cmd_parms *cmd, void *dummy, char *arg)
+const char *ap_set_send_buffer_size(cmd_parms *cmd, void *dummy, const char *arg)
{
int s = atoi(arg);
const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
int ap_threads_per_child=0; /* Worker threads per child */
int ap_max_requests_per_child=0;
-static char *ap_pid_fname=NULL;
-API_VAR_EXPORT char *ap_scoreboard_fname=NULL;
+static const char *ap_pid_fname=NULL;
+API_VAR_EXPORT const char *ap_scoreboard_fname=NULL;
static int ap_daemons_to_start=0;
static int min_spare_threads=0;
static int max_spare_threads=0;
/* Locks for accept serialization */
static pthread_mutex_t thread_accept_mutex = PTHREAD_MUTEX_INITIALIZER;
static ap_lock_t *process_accept_mutex;
-static char *lock_fname;
+static const char *lock_fname;
#ifdef NO_SERIALIZED_ACCEPT
#define SAFE_ACCEPT(stmt) APR_SUCCESS
}
-static const char *set_pidfile(cmd_parms *cmd, void *dummy, char *arg)
+static const char *set_pidfile(cmd_parms *cmd, void *dummy, const char *arg)
{
const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
if (err != NULL) {
return NULL;
}
-static const char *set_scoreboard(cmd_parms *cmd, void *dummy, char *arg)
+static const char *set_scoreboard(cmd_parms *cmd, void *dummy,
+ const char *arg)
{
const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
if (err != NULL) {
return NULL;
}
-static const char *set_lockfile(cmd_parms *cmd, void *dummy, char *arg)
+static const char *set_lockfile(cmd_parms *cmd, void *dummy, const char *arg)
{
const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
if (err != NULL) {
return NULL;
}
-static const char *set_daemons_to_start(cmd_parms *cmd, void *dummy, char *arg)
+static const char *set_daemons_to_start(cmd_parms *cmd, void *dummy,
+ const char *arg)
{
const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
if (err != NULL) {
return NULL;
}
-static const char *set_min_spare_threads(cmd_parms *cmd, void *dummy, char *arg)
+static const char *set_min_spare_threads(cmd_parms *cmd, void *dummy,
+ const char *arg)
{
const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
if (err != NULL) {
return NULL;
}
-static const char *set_max_spare_threads(cmd_parms *cmd, void *dummy, char *arg)
+static const char *set_max_spare_threads(cmd_parms *cmd, void *dummy,
+ const char *arg)
{
const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
if (err != NULL) {
return NULL;
}
-static const char *set_server_limit (cmd_parms *cmd, void *dummy, char *arg)
+static const char *set_server_limit (cmd_parms *cmd, void *dummy,
+ const char *arg)
{
const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
if (err != NULL) {
return NULL;
}
-static const char *set_threads_per_child (cmd_parms *cmd, void *dummy, char *arg)
+static const char *set_threads_per_child (cmd_parms *cmd, void *dummy,
+ const char *arg)
{
const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
if (err != NULL) {
return NULL;
}
-static const char *set_max_requests(cmd_parms *cmd, void *dummy, char *arg)
+static const char *set_max_requests(cmd_parms *cmd, void *dummy,
+ const char *arg)
{
const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
if (err != NULL) {
return NULL;
}
-static const char *set_coredumpdir (cmd_parms *cmd, void *dummy, char *arg)
+static const char *set_coredumpdir (cmd_parms *cmd, void *dummy,
+ const char *arg)
{
ap_finfo_t finfo;
const char *fname;
static const command_rec mpmt_pthread_cmds[] = {
UNIX_DAEMON_COMMANDS
LISTEN_COMMANDS
-{ "PidFile", set_pidfile, NULL, RSRC_CONF, TAKE1,
- "A file for logging the server process ID"},
-{ "ScoreBoardFile", set_scoreboard, NULL, RSRC_CONF, TAKE1,
- "A file for Apache to maintain runtime process management information"},
-{ "LockFile", set_lockfile, NULL, RSRC_CONF, TAKE1,
- "The lockfile used when Apache needs to lock the accept() call"},
-{ "StartServers", set_daemons_to_start, NULL, RSRC_CONF, TAKE1,
- "Number of child processes launched at server startup" },
-{ "MinSpareThreads", set_min_spare_threads, NULL, RSRC_CONF, TAKE1,
- "Minimum number of idle children, to handle request spikes" },
-{ "MaxSpareThreads", set_max_spare_threads, NULL, RSRC_CONF, TAKE1,
- "Maximum number of idle children" },
-{ "MaxClients", set_server_limit, NULL, RSRC_CONF, TAKE1,
- "Maximum number of children alive at the same time" },
-{ "ThreadsPerChild", set_threads_per_child, NULL, RSRC_CONF, TAKE1,
- "Number of threads each child creates" },
-{ "MaxRequestsPerChild", set_max_requests, NULL, RSRC_CONF, TAKE1,
- "Maximum number of requests a particular child serves before dying." },
-{ "CoreDumpDirectory", set_coredumpdir, NULL, RSRC_CONF, TAKE1,
- "The location of the directory Apache changes to before dumping core" },
+AP_INIT_TAKE1("PidFile", set_pidfile, NULL, RSRC_CONF,
+ "A file for logging the server process ID"),
+AP_INIT_TAKE1("ScoreBoardFile", set_scoreboard, NULL, RSRC_CONF,
+ "A file for Apache to maintain runtime process management information"),
+AP_INIT_TAKE1("LockFile", set_lockfile, NULL, RSRC_CONF,
+ "The lockfile used when Apache needs to lock the accept() call"),
+AP_INIT_TAKE1("StartServers", set_daemons_to_start, NULL, RSRC_CONF,
+ "Number of child processes launched at server startup"),
+AP_INIT_TAKE1("MinSpareThreads", set_min_spare_threads, NULL, RSRC_CONF,
+ "Minimum number of idle children, to handle request spikes"),
+AP_INIT_TAKE1("MaxSpareThreads", set_max_spare_threads, NULL, RSRC_CONF,
+ "Maximum number of idle children"),
+AP_INIT_TAKE1("MaxClients", set_server_limit, NULL, RSRC_CONF,
+ "Maximum number of children alive at the same time"),
+AP_INIT_TAKE1("ThreadsPerChild", set_threads_per_child, NULL, RSRC_CONF,
+ "Number of threads each child creates"),
+AP_INIT_TAKE1("MaxRequestsPerChild", set_max_requests, NULL, RSRC_CONF,
+ "Maximum number of requests a particular child serves before dying."),
+AP_INIT_TAKE1("CoreDumpDirectory", set_coredumpdir, NULL, RSRC_CONF,
+ "The location of the directory Apache changes to before dumping core"),
{ NULL }
};
if (intype == NULL) return NULL;
- semi = strchr(intype, ';');
+ semi = ap_strchr_c(intype, ';');
if (semi == NULL) {
return ap_pstrdup(p, intype);
}
API_EXPORT(char *) ap_getword(ap_pool_t *atrans, const char **line, char stop)
{
- char *pos = strchr(*line, stop);
+ const char *pos = ap_strchr_c(*line, stop);
char *res;
if (!pos) {
API_EXPORT(char *) ap_getword_nulls(ap_pool_t *atrans, const char **line, char stop)
{
- char *pos = strchr(*line, stop);
+ const char *pos = ap_strchr_c(*line, stop);
char *res;
if (!pos) {
* environment value does not exist, leave the ${ENV}
* construct alone; it means something else.
*/
-API_EXPORT(char *) ap_resolve_env(ap_pool_t *p, const char * word)
+API_EXPORT(const char *) ap_resolve_env(ap_pool_t *p, const char * word)
{
char tmp[ MAX_STRING_LEN ];
- char * s, * e;
+ const char *s, *e;
tmp[0] = '\0';
- if (!(s=strchr(word,'$')))
- return (char *)word;
+ if (!(s=ap_strchr_c(word,'$')))
+ return word;
do {
/* XXX - relies on strncat() to add '\0'
*/
strncat(tmp,word,s - word);
- if ((s[1] == '{') && (e=strchr(s,'}'))) {
- *e = '\0';
+ if ((s[1] == '{') && (e=ap_strchr_c(s,'}'))) {
+ const char *e2 = e;
word = e + 1;
e = getenv(s+2);
if (e) {
strcat(tmp,e);
} else {
- strcat(tmp,s);
+ strncat(tmp, s, e2-s);
strcat(tmp,"}");
}
} else {
word = s+1;
strcat(tmp,"$");
};
- } while ((s=strchr(word,'$')));
+ } while ((s=ap_strchr_c(word,'$')));
strcat(tmp,word);
return ap_pstrdup(p,tmp);
unsigned c;
if (!partial) {
- char *colon = strchr(path, ':');
- char *slash = strchr(path, '/');
+ const char *colon = ap_strchr_c(path, ':');
+ const char *slash = ap_strchr_c(path, '/');
if (colon && (!slash || colon < slash)) {
*d++ = '.';
*outchr = '\0';
return outstring;
}
-
-#ifdef AP_DEBUG
-# undef strrchr
-
-char *ap_strrchr(char *s, int c)
-{ return strrchr(s,c); }
-
-const char *ap_strrchr_c(const char *s, int c)
-{ return strrchr(s,c); }
-
-#endif
--- /dev/null
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2000 The Apache Software Foundation. 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. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" must
+ * not be used to endorse or promote products derived from this
+ * software without prior written permission. For written
+ * permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * nor may "Apache" appear in their name, without prior written
+ * permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED 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 APACHE SOFTWARE FOUNDATION OR
+ * ITS 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.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ * Portions of this software are based upon public domain software
+ * originally written at the National Center for Supercomputing Applications,
+ * University of Illinois, Urbana-Champaign.
+ */
+
+#include "httpd.h"
+
+#ifdef AP_DEBUG
+# undef strchr
+
+char *ap_strchr(char *s, int c)
+{ return strchr(s,c); }
+
+const char *ap_strchr_c(const char *s, int c)
+{ return strchr(s,c); }
+
+# undef strrchr
+
+char *ap_strrchr(char *s, int c)
+{ return strrchr(s,c); }
+
+const char *ap_strrchr_c(const char *s, int c)
+{ return strrchr(s,c); }
+
+#endif
}
if (*s == '?') {
++s;
- s1 = strchr(s, '#');
+ s1 = ap_strchr_c(s, '#');
if (s1) {
uptr->fragment = ap_pstrdup(p, s1 + 1);
uptr->query = ap_pstrndup(p, s, s1 - s);
/* We expect hostinfo to point to the first character of
* the hostname. There must be a port, separated by a colon
*/
- s = strchr(hostinfo, ':');
+ s = ap_strchr_c(hostinfo, ':');
if (s == NULL) {
return HTTP_BAD_REQUEST;
}
* *paddr is the variable used to keep track of **paddr between calls
* port is the default port to assume
*/
-static const char *get_addresses(ap_pool_t *p, const char *w,
+static const char *get_addresses(ap_pool_t *p, const char *w_,
server_addr_rec ***paddr, unsigned port)
{
struct hostent *hep;
server_addr_rec *sar;
char *t;
int i, is_an_ip_addr;
+ char *w;
- if (*w == 0)
+ if (*w_ == 0)
return NULL;
+ w=ap_pstrdup(p, w_);
t = strchr(w, ':');
if (t) {
if (strcmp(t + 1, "*") == 0) {
sar->host_addr.s_addr = my_addr;
sar->host_port = port;
sar->virthost = ap_pstrdup(p, w);
- if (t != NULL)
- *t = ':';
return NULL;
}
if ((!hep) || (hep->h_addrtype != AF_INET || !hep->h_addr_list[0])) {
ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, NULL,
"Cannot resolve host name %s --- ignoring!", w);
- if (t != NULL)
- *t = ':';
return NULL;
}
sar->virthost = ap_pstrdup(p, w);
}
- if (t != NULL)
- *t = ':';
return NULL;
}