/* * This function gets called to merge two per-server configuration * records. This is typically done to cope with things like virtual hosts and * the default server configuration The routine has the responsibility of * creating a new record and merging the contents of the other two into it * appropriately. If the module doesn't declare a merge routine, the more * specific existing record is used exclusively. * * The routine MUST NOT modify any of its arguments! * * The return value is a pointer to the created module-specific structure * containing the merged values. */ static void *example_merge_server_config(pool *p, void *server1_conf, void *server2_conf) { excfg *merged_config = (excfg *) ap_pcalloc(p, sizeof(excfg)); excfg *s1conf = (excfg *) server1_conf; excfg *s2conf = (excfg *) server2_conf; char *note; /* * Our inheritance rules are our own, and part of our module's semantics. * Basically, just note whence we came. */ merged_config->cmode = (s1conf->cmode == s2conf->cmode) ? s1conf->cmode : CONFIG_MODE_COMBO; merged_config->local = s2conf->local; merged_config->congenital = (s1conf->congenital | s1conf->local); merged_config->loc = ap_pstrdup(p, s2conf->loc); /* * Trace our call, including what we were asked to merge. */ note = ap_pstrcat(p, "example_merge_server_config(\"", s1conf->loc, "\",\"", s2conf->loc, "\")", NULL); trace_add(NULL, NULL, merged_config, note); return (void *) merged_config; }
static void *create_dir_mconfig(pool *p, char *dir) { /* So why -1, 0, and 1? You see, C lacks an arithmatic if. We need to know three states at any point. We need to know if something is unset, off or on. Hence we use these values. Apache already understands Off as 0 and 1 as on. */ kewl_conf *cfg; cfg = ap_pcalloc(p, sizeof(kewl_conf)); cfg->proxy = UNSET; cfg->comment = UNSET; cfg->glob = UNSET; cfg->http_header_enabled = UNSET; cfg->http_header = NULL; cfg->header = NULL; cfg->footer = NULL; cfg->request_header = OFF; cfg->time_format = NULL; cfg->types = ap_make_table(p, 8); cfg->uris_ignore = ap_make_table(p, 8); ap_table_set(cfg->types, INCLUDES_MAGIC_TYPE, "1"); ap_table_set(cfg->types, INCLUDES_MAGIC_TYPE3, "1"); ap_table_set(cfg->types, "server-parsed", "1"); ap_table_set(cfg->types, "text/html", "1"); ap_table_set(cfg->types, "text/plain", "1"); ap_table_set(cfg->types, "perl-script", "1"); ap_table_set(cfg->types, "cgi-script", "1"); ap_table_set(cfg->types, "application/x-httpd-cgi", "1"); return (void *) cfg; }
/* * This function gets called to create a per-directory configuration * record. This will be called for the "default" server environment, and for * each directory for which the parser finds any of our directives applicable. * If a directory doesn't have any of our directives involved (i.e., they * aren't in the .htaccess file, or a <Location>, <Directory>, or related * block), this routine will *not* be called - the configuration for the * closest ancestor is used. * * The return value is a pointer to the created module-specific * structure. */ static void *example_create_dir_config(pool *p, char *dirspec) { excfg *cfg; char *dname = dirspec; /* * Allocate the space for our record from the pool supplied. */ cfg = (excfg *) ap_pcalloc(p, sizeof(excfg)); /* * Now fill in the defaults. If there are any `parent' configuration * records, they'll get merged as part of a separate callback. */ cfg->local = 0; cfg->congenital = 0; cfg->cmode = CONFIG_MODE_DIRECTORY; /* * Finally, add our trace to the callback list. */ dname = (dname != NULL) ? dname : ""; cfg->loc = ap_pstrcat(p, "DIR(", dname, ")", NULL); trace_add(NULL, NULL, cfg, "example_create_dir_config()"); return (void *) cfg; }
static char* expand_memory(WFILE* p, long add) { char* newptr; long currsize; long newsize = 0; //log_message("Expanding Memory",p->r); currsize = p->end - p->str; if (add == 0) add = 4096; newsize = currsize + add; //sprintf(log_msg,"Expanding Memory from %i to %i", currsize, newsize); //log_message(log_msg, p->r); newptr = ap_pcalloc(p->r->pool, newsize); //if (!newptr) -- need a check here memcpy(newptr, p->str, currsize); p->end = newptr + newsize; p->ptr = newptr + (p->ptr - p->str); p->str = newptr; //log_message("Memory Expanded", p->r); return newptr; }
/******************************************************************************* * Allocate a new FastCGI server record from pool p with default values. */ fcgi_server * fcgi_util_fs_new(pool *p) { fcgi_server *s = (fcgi_server *) ap_pcalloc(p, sizeof(fcgi_server)); /* Initialize anything who's init state is not zeroizzzzed */ s->listenQueueDepth = FCGI_DEFAULT_LISTEN_Q; s->appConnectTimeout = FCGI_DEFAULT_APP_CONN_TIMEOUT; s->idle_timeout = FCGI_DEFAULT_IDLE_TIMEOUT; s->initStartDelay = DEFAULT_INIT_START_DELAY; s->restartDelay = FCGI_DEFAULT_RESTART_DELAY; s->minServerLife = FCGI_DEFAULT_MIN_SERVER_LIFE; s->maxFailedStarts = FCGI_DEFAULT_MAX_FAILED_STARTS; s->restartOnExit = FALSE; s->directive = APP_CLASS_UNKNOWN; s->processPriority = FCGI_DEFAULT_PRIORITY; s->envp = &fcgi_empty_env; #ifdef WIN32 s->listenFd = (int) INVALID_HANDLE_VALUE; #else s->listenFd = -2; #endif return s; }
/******************************************************************************* * Build an Inet Socket Address structure, and calculate its size. * The error message is allocated from the pool p. If you don't want the * struct sockaddr_in also allocated from p, pass it preallocated (!=NULL). */ const char * fcgi_util_socket_make_inet_addr(pool *p, struct sockaddr_in **socket_addr, int *socket_addr_len, const char *host, unsigned short port) { if (*socket_addr == NULL) *socket_addr = ap_pcalloc(p, sizeof(struct sockaddr_in)); else memset(*socket_addr, 0, sizeof(struct sockaddr_in)); (*socket_addr)->sin_family = AF_INET; (*socket_addr)->sin_port = htons(port); /* Get an in_addr represention of the host */ if (host != NULL) { if (convert_string_to_in_addr(host, &(*socket_addr)->sin_addr) != 1) { return ap_pstrcat(p, "failed to resolve \"", host, "\" to exactly one IP address", NULL); } } else { (*socket_addr)->sin_addr.s_addr = htonl(INADDR_ANY); } *socket_addr_len = sizeof(struct sockaddr_in); return NULL; }
static void *suphp_merge_server_config(pool *p, void *base, void *overrides) { suphp_conf *parent = (suphp_conf *) base; suphp_conf *child = (suphp_conf *) overrides; suphp_conf *merged = (suphp_conf *) ap_pcalloc(p, sizeof(suphp_conf)); if (child->engine != SUPHP_ENGINE_UNDEFINED) merged->engine = child->engine; else merged->engine = parent->engine; if (child->php_path != NULL) merged->php_path = ap_pstrdup(p, child->php_path); else merged->php_path = ap_pstrdup(p, parent->php_path); #ifdef SUPHP_USE_USERGROUP if (child->target_user) merged->target_user = ap_pstrdup(p, child->target_user); else if (parent->target_user) merged->target_user = ap_pstrdup(p, parent->target_user); else merged->target_user = NULL; if (child->target_group) merged->target_group = ap_pstrdup(p, child->target_group); else if (parent->target_group) merged->target_group = ap_pstrdup(p, parent->target_group); else merged->target_group = NULL; #endif merged->handlers = ap_overlay_tables(p, child->handlers, parent->handlers); return (void *) merged; }
/* ==================================================================== * This function gets called to create a per-directory configuration * record. This will be called for the "default" server environment, and for * each directory for which the parser finds any of our directives applicable. * If a directory doesn't have any of our directives involved (i.e., they * aren't in the .htaccess file, or a <Location>, <Directory>, or related * block), this routine will *not* be called - the configuration for the * closest ancestor is used. * * The return value is a pointer to the created module-specific structure. * ==================================================================== */ static void *wk_create_dir_config(pool *p, char *dirspec) { wkcfg *cfg; char **header; /* * Allocate the space for our record from the pool supplied. */ cfg = (wkcfg *)ap_pcalloc(p, sizeof(wkcfg)); /* * Now fill in the defaults. If there are any `parent' configuration * records, they'll get merged as part of a separate callback. */ cfg->port = 8086; cfg->host = "localhost"; cfg->addr = resolve_host(cfg->host); cfg->retryattempts = 10; cfg->retrydelay = 1; cfg->passheaders = ap_make_array(p, 1, sizeof(char *)); /* * Pass the "If-Modified-Since" HTTP header through. * Servlets may inspect this value and, if the object has not changed, * return "Status: 304" and no body. */ header = (char **)ap_push_array(cfg->passheaders); *header = "If-Modified-Since"; return (void *)cfg; }
/** * gets content if this is notification. */ static int content_read(request_rec *r, char **rbuf) { int rc; int rsize, len_read, rpos = 0; if ((rc = ap_setup_client_block(r, REQUEST_CHUNKED_ERROR)) != OK) { return -1; } if (ap_should_client_block(r)) { char argsbuffer[HUGE_STRING_LEN]; long length = r->remaining; *rbuf = ap_pcalloc(r->pool, length+1); ap_hard_timeout("content_read", r); while ((len_read = ap_get_client_block(r, argsbuffer, sizeof(argsbuffer))) > 0) { ap_reset_timeout(r); if ((rpos + len_read) > length) { rsize = length -rpos; } else { rsize = len_read; } memcpy((char*) *rbuf + rpos, argsbuffer, rsize); rpos = rpos + rsize; } ap_kill_timeout(r); } am_web_log_debug("in content_read: rpos=%d", rpos); return rpos; }
/* ** dav_fs_open_lockdb: ** ** "open" the lock database, as specified in the global server configuration. ** If force is TRUE, then the database is opened now, rather than lazily. ** ** Note that only one can be open read/write. */ static dav_error * dav_fs_open_lockdb(request_rec *r, int ro, int force, dav_lockdb **lockdb) { dav_lockdb_combined *comb; comb = ap_pcalloc(r->pool, sizeof(*comb)); comb->pub.hooks = &dav_hooks_locks_fs; comb->pub.ro = ro; comb->pub.info = &comb->priv; comb->priv.r = r; comb->priv.pool = r->pool; comb->priv.lockdb_path = dav_get_lockdb_path(r); if (comb->priv.lockdb_path == NULL) { return dav_new_error(r->pool, HTTP_INTERNAL_SERVER_ERROR, DAV_ERR_LOCK_NO_DB, "A lock database was not specified with the " "DAVLockDB directive. One must be specified " "to use the locking functionality."); } /* done initializing. return it. */ *lockdb = &comb->pub; if (force) { /* ### add a higher-level comment? */ return dav_fs_really_open_lockdb(*lockdb); } return NULL; }
static void *aurora_directory_init(pool *p, char *path) { aurora_server_dir *daurora; daurora = (aurora_server_dir *) ap_pcalloc(p, sizeof(aurora_server_dir)); daurora->state = ENGINE_INHERIT; daurora->path = path; return (void *) daurora; }
/*ARGSUSED1*/ static void * create_ipp_dir_config( #ifndef APACHE2 pool *p, #else apr_pool_t *p, #endif char *dirspec) { IPPListenerConfig *config = #ifndef APACHE2 ap_pcalloc(p, sizeof (*config)); #else apr_pcalloc(p, sizeof (*config)); #endif if (config != NULL) { (void) memset(config, 0, sizeof (*config)); config->conformance = IPP_PARSE_CONFORMANCE_RASH; config->default_user = NULL; config->default_svc = NULL; (void) ipp_configure_operation(&config->operations, "required", "enable"); } return (config); }
static void *create_info_config(pool *p, server_rec *s) { info_svr_conf *conf = (info_svr_conf *) ap_pcalloc(p, sizeof(info_svr_conf)); conf->more_info = ap_make_array(p, 20, sizeof(info_entry)); return conf; }
static int authenticate_digest_user(request_rec *r) { digest_config_rec *sec = (digest_config_rec *) ap_get_module_config(r->per_dir_config, &digest_module); digest_header_rec *response = ap_pcalloc(r->pool, sizeof(digest_header_rec)); conn_rec *c = r->connection; char *a1; int res; if ((res = get_digest_rec(r, response))) return res; if (!sec->pwfile) return DECLINED; if (!(a1 = get_hash(r, c->user, sec->pwfile))) { ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r->server, "user %s not found: %s", c->user, r->uri); ap_note_digest_auth_failure(r); return AUTH_REQUIRED; } if (strcmp(response->digest, find_digest(r, response, a1))) { ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r->server, "user %s: password mismatch: %s", c->user, r->uri); ap_note_digest_auth_failure(r); return AUTH_REQUIRED; } return OK; }
/* ** dav_fs_parse_locktoken ** ** Parse an opaquelocktoken URI into a locktoken. */ static dav_error * dav_fs_parse_locktoken( pool *p, const char *char_token, dav_locktoken **locktoken_p) { dav_locktoken *locktoken; if (strstr(char_token, "opaquelocktoken:") != char_token) { return dav_new_error(p, HTTP_BAD_REQUEST, DAV_ERR_LOCK_UNK_STATE_TOKEN, "The lock token uses an unknown State-token " "format and could not be parsed."); } char_token += 16; locktoken = ap_pcalloc(p, sizeof(*locktoken)); if (dav_parse_opaquelocktoken(char_token, &locktoken->uuid)) { return dav_new_error(p, HTTP_BAD_REQUEST, DAV_ERR_LOCK_PARSE_TOKEN, "The opaquelocktoken has an incorrect format " "and could not be parsed."); } *locktoken_p = locktoken; return NULL; }
static void *mva_merge_server_config(pool *p, void *parentv, void *childv) { mva_sconf_t *parent = (mva_sconf_t *) parentv; mva_sconf_t *child = (mva_sconf_t *) childv; mva_sconf_t *conf; conf = (mva_sconf_t *) ap_pcalloc(p, sizeof(*conf)); if (child->doc_root_mode == VHOST_ALIAS_UNSET) { conf->doc_root_mode = parent->doc_root_mode; conf->doc_root = parent->doc_root; } else { conf->doc_root_mode = child->doc_root_mode; conf->doc_root = child->doc_root; } if (child->cgi_root_mode == VHOST_ALIAS_UNSET) { conf->cgi_root_mode = parent->cgi_root_mode; conf->cgi_root = parent->cgi_root; } else { conf->cgi_root_mode = child->cgi_root_mode; conf->cgi_root = child->cgi_root; } return conf; }
/*! * This function gets called to create a per-server configuration * record. It will always be called for the "default" server. *\return * Указатель на созданную структуру конфигурации модуля (module-specific structure). */ void* mod_create_server_config(pool* p, server_rec* s) { #ifdef _DEBUG function func(MOD_NAME ":" __FUNCTION__); #endif //excfg *cfg; //char *sname = s->server_hostname; /* * As with the example_create_dir_config() reoutine, we allocate and fill * in an empty record. */ //mod_cfg_rec* cfg = 0;//(mod_cfg_rec*)ap_pcalloc( p, sizeof(mod_cfg_rec) ); //cfg->local = 0; //cfg->congenital = 0; //cfg->cmode = CONFIG_MODE_SERVER; /* * Note that we were called in the trace list. sname = (sname != NULL) ? sname : ""; cfg->loc = ap_pstrcat(p, "SVR(", sname, ")", NULL); trace_add(s, NULL, cfg, "example_create_server_config()");*/ void** cfg = (void**)ap_pcalloc( p, sizeof(void*) ); *cfg = 0; // DPRINTF("%s ... return cfg_ptr = 0x%08x s->path = %s, s->defn_name = %s, s->defn_line_number = %i\r\n",__FUNCTION__,cfg,s->path,s->defn_name,s->defn_line_number); //return (void*) cfg; return cfg; }
static void *mkconfig(pool *p) { spconfig *cfg = ap_pcalloc(p, sizeof(spconfig)); cfg->enabled = 0; return cfg; }
static void *create_auth_dir_config(pool *p, char *d) { auth_config_rec *sec = (auth_config_rec *) ap_pcalloc(p, sizeof(auth_config_rec)); sec->auth_pwfile = NULL; /* just to illustrate the default really */ sec->auth_grpfile = NULL; /* unless you have a broken HP cc */ sec->auth_authoritative = 1; /* keep the fortress secure by default */ return sec; }
static void *removeip_create_server_cfg(pool *p, server_rec *s) { removeip_server_cfg *cfg = (removeip_server_cfg *)ap_pcalloc(p, sizeof(removeip_server_cfg)); if (!cfg) return NULL; cfg->enable = 0; return (void *)cfg; }
static void *create_rangelim_config(apr_pool_t *p, server_rec *s) { ranges_server_conf *cfg = (ranges_server_conf *) apr_pcalloc(p, sizeof(ranges_server_conf)); #else static void *create_rangelim_config(pool *p, server_rec *s) { ranges_server_conf *cfg = (ranges_server_conf *) ap_pcalloc(p, sizeof(ranges_server_conf)); #endif cfg->max_ranges = 20; cfg->max_overlaps = 5; return cfg; }
void *fcgi_config_create_dir_config(pool *p, char *dummy) { fcgi_dir_config *dir_config = ap_pcalloc(p, sizeof(fcgi_dir_config)); dir_config->authenticator_options = FCGI_AUTHORITATIVE; dir_config->authorizer_options = FCGI_AUTHORITATIVE; dir_config->access_checker_options = FCGI_AUTHORITATIVE; return dir_config; }
/* * ic_serverbackup_cmd() * --------------------- * Handle the "InterchangeServerBackup" module configuration directive */ static const char *ic_serverbackup_cmd(cmd_parms *parms,void *mconfig,const char *arg) { ic_conf_rec *conf_rec = (ic_conf_rec *)mconfig; conf_rec->server[1] = (ic_socket_rec *)ap_pcalloc(parms->pool,sizeof(ic_socket_rec)); if (conf_rec->server[1] == NULL) return "not enough memory for backup socket record"; return ic_server_setup(parms,mconfig,1,arg); }
static void *create_userdir_config(pool *p, server_rec *s) { userdir_config *newcfg; newcfg = (userdir_config *) ap_pcalloc(p, sizeof(userdir_config)); newcfg->globally_disabled = 0; newcfg->userdir = DEFAULT_USER_DIR; newcfg->enabled_users = ap_make_table(p, 4); newcfg->disabled_users = ap_make_table(p, 4); return (void *) newcfg; }
static void *so_sconf_create(pool *p, server_rec *s) { so_server_conf *soc; soc = (so_server_conf *)ap_pcalloc(p, sizeof(so_server_conf)); soc->loaded_modules = ap_make_array(p, DYNAMIC_MODULE_LIMIT, sizeof(moduleinfo)); ap_os_dso_init(); return (void *)soc; }
static void *create_dbm_auth_dir_config(pool *p, char *d) { dbm_auth_config_rec *sec = (dbm_auth_config_rec *) ap_pcalloc(p, sizeof(dbm_auth_config_rec)); sec->auth_dbmpwfile = NULL; sec->auth_dbmgrpfile = NULL; sec->auth_dbmauthoritative = 1; /* fortress is secure by default */ return sec; }
static void *mva_create_server_config(pool *p, server_rec *s) { mva_sconf_t *conf; conf = (mva_sconf_t *) ap_pcalloc(p, sizeof(mva_sconf_t)); conf->doc_root = NULL; conf->cgi_root = NULL; conf->doc_root_mode = VHOST_ALIAS_UNSET; conf->cgi_root_mode = VHOST_ALIAS_UNSET; return conf; }
/* ==================================================================== * Initialize the WFILE structure * This is used by the marshalling functions. * ==================================================================== */ static WFILE* setup_WFILE(request_rec* r) { WFILE* wf = NULL; wf = ap_pcalloc(r->pool, sizeof(WFILE)); if (wf == NULL) { log_error("Failed to get WFILE structure", r->server); return wf; } wf->str = NULL; wf->ptr = NULL; wf->end = NULL; wf->str = ap_pcalloc(r->pool, 4096); if (wf->str == NULL) { log_error("Couldn't allocate memory", r->server); return NULL; } wf->end = wf->str + 4096; wf->ptr = wf->str; wf->appool = r->pool; wf->r = r; return wf; }
static void *create_access_dir_config(pool *p, char *dummy) { access_dir_conf *conf = (access_dir_conf *) ap_pcalloc(p, sizeof(access_dir_conf)); int i; for (i = 0; i < METHODS; ++i) conf->order[i] = DENY_THEN_ALLOW; conf->allows = ap_make_array(p, 1, sizeof(allowdeny)); conf->denys = ap_make_array(p, 1, sizeof(allowdeny)); return (void *) conf; }
ApacheUpload *ApacheUpload_new(ApacheRequest *req) { ApacheUpload *upload = (ApacheUpload *) ap_pcalloc(req->r->pool, sizeof(ApacheUpload)); upload->next = NULL; upload->name = NULL; upload->info = NULL; upload->fp = NULL; upload->size = 0; upload->req = req; return upload; }