Exemplo n.º 1
0
/* Change to use ap_lua_map_handler */
static int cfg_lua_map_handler(lua_State *L)
{
    ap_lua_dir_cfg *cfg = check_dir_config(L, 1);
    ap_lua_mapped_handler_spec *handler =
        apr_pcalloc(cfg->pool, sizeof(ap_lua_mapped_handler_spec));
    handler->uri_pattern = NULL;
    handler->function_name = NULL;

    luaL_checktype(L, 2, LUA_TTABLE);
    lua_getfield(L, 2, "file");
    if (lua_isstring(L, -1)) {
        const char *file = lua_tostring(L, -1);
        handler->file_name = apr_pstrdup(cfg->pool, file);
    }
    lua_pop(L, 1);

    lua_getfield(L, 2, "pattern");
    if (lua_isstring(L, -1)) {
        const char *pattern = lua_tostring(L, -1);

        ap_regex_t *uri_pattern = apr_palloc(cfg->pool, sizeof(ap_regex_t));
        if (ap_regcomp(uri_pattern, pattern, 0) != OK) {
            return luaL_error(L, "Unable to compile regular expression, '%s'",
                              pattern);
        }
        handler->uri_pattern = uri_pattern;
    }
    lua_pop(L, 1);

    lua_getfield(L, 2, "scope");
    if (lua_isstring(L, -1)) {
        const char *scope = lua_tostring(L, -1);
        handler->scope = apl_toscope(scope);
    }
    else {
        handler->scope = AP_LUA_SCOPE_ONCE;
    }
    lua_pop(L, 1);

    lua_getfield(L, 2, "func");
    if (lua_isstring(L, -1)) {
        const char *value = lua_tostring(L, -1);
        handler->function_name = apr_pstrdup(cfg->pool, value);
    }
    else {
        handler->function_name = "handle";
    }
    lua_pop(L, 1);


    *(const ap_lua_mapped_handler_spec **) apr_array_push(cfg->mapped_handlers) =
        handler;
    return 0;
}
Exemplo n.º 2
0
static int ex_metric_init (apr_pool_t *p)
{
    int i;
    Ganglia_25metric *gmi;

    init_cpu_info ();

    /* Allocate a pool that will be used by this module */
    apr_pool_create(&pool, p);

    metric_info = apr_array_make(pool, 2, sizeof(Ganglia_25metric));

    /* Initialize each metric */
    cpu_user = init_metric (pool, metric_info, cpu_count, "multicpu_user", 
                            "Percentage of CPU utilization that occurred while "
                            "executing at the user level");
    cpu_nice = init_metric (pool, metric_info, cpu_count, "multicpu_nice", 
                            "Percentage of CPU utilization that occurred while "
                            "executing at the nice level");
    cpu_system = init_metric (pool, metric_info, cpu_count, "multicpu_system", 
                            "Percentage of CPU utilization that occurred while "
                            "executing at the system level");
    cpu_idle = init_metric (pool, metric_info, cpu_count, "multicpu_idle", 
                            "Percentage of CPU utilization that occurred while "
                            "executing at the idle level");
    cpu_wio = init_metric (pool, metric_info, cpu_count, "multicpu_wio", 
                            "Percentage of CPU utilization that occurred while "
                            "executing at the wio level");
    cpu_intr = init_metric (pool, metric_info, cpu_count, "multicpu_intr", 
                            "Percentage of CPU utilization that occurred while "
                            "executing at the intr level");
    cpu_sintr = init_metric (pool, metric_info, cpu_count, "multicpu_sintr", 
                            "Percentage of CPU utilization that occurred while "
                            "executing at the sintr level");

    /* Add a terminator to the array and replace the empty static metric definition 
        array with the dynamic array that we just created 
    */
    gmi = apr_array_push(metric_info);
    memset (gmi, 0, sizeof(*gmi));

    multicpu_module.metrics_info = (Ganglia_25metric *)metric_info->elts;

    for (i = 0; multicpu_module.metrics_info[i].name != NULL; i++) {
        /* Initialize the metadata storage for each of the metrics and then
         *  store one or more key/value pairs.  The define MGROUPS defines
         *  the key for the grouping attribute. */
        MMETRIC_INIT_METADATA(&(multicpu_module.metrics_info[i]),p);
        MMETRIC_ADD_METADATA(&(multicpu_module.metrics_info[i]),MGROUP,"cpu");
    }

    return 0;
}
Exemplo n.º 3
0
/** Append name-value pair */
APT_DECLARE(apt_bool_t) apt_pair_array_append(apt_pair_arr_t *arr, const apt_str_t *name, const apt_str_t *value, apr_pool_t *pool)
{
	apt_pair_t *pair = apr_array_push(arr);
	apt_pair_init(pair);
	if(name) {
		apt_string_copy(&pair->name,name,pool);
	}
	if(value) {
		apt_string_copy(&pair->value,value,pool);
	}
	return TRUE;
}
static const char * set_extensions(cmd_parms *cmd, void *mconfig, const char *arg)
{
    process_security_config_t *conf = ap_get_module_config (cmd->server->module_config, &process_security_module);
    const char *err = ap_check_cmd_context (cmd, NOT_IN_FILES | NOT_IN_LIMIT);

    if (err != NULL)
        return err;

    *(const char **)apr_array_push(conf->extensions) = arg;

    return NULL;
}
	static int amx_addPathMappingAction(pool* p,void* userdata,array_header* actions){
		actmap_tmp* ctmp=(actmap_tmp*)userdata;
		path_mapping_xml* pa=(path_mapping_xml*)ctmp->tmp;
		pathmapping_action_xml* action=(pathmapping_action_xml*)ctmp->tmp6, **pos=NULL;	
		if(actions!=NULL){
			pos=(pathmapping_action_xml**)apr_array_push(actions);
			*pos=action;
			printf("matchlist=%s id=%s \r\n",action->matchList, action->id);
		}
		ctmp->tmp6=NULL;
		return 1;
	}
Exemplo n.º 6
0
apr_array_header_t * CTSVNPathList::MakePathArray (apr_pool_t *pool) const
{
    apr_array_header_t *targets = apr_array_make (pool, GetCount(), sizeof(const char *));

    for(int nItem = 0; nItem < GetCount(); nItem++)
    {
        const char * target = m_paths[nItem].GetSVNApiPath(pool);
        (*((const char **) apr_array_push (targets))) = target;
    }

    return targets;
}
	static int amx_addMatchList(pool* p,char* xPath,int type,void* userdata){
		actmap_tmp* ctmp=(actmap_tmp*)userdata;
		oidc_config_xml* amx=(oidc_config_xml*)ctmp->conf;
		mlx_matchlist* mlist=(mlx_matchlist*)ctmp->tmp, **mlistPos=NULL;
		
		if(ctmp!=NULL&&mlist!=NULL&&mlist->name!=NULL){
			mlistPos=(mlx_matchlist**)apr_array_push(amx->match_list_arr);
			*mlistPos=mlist;
		}
		ctmp->tmp=NULL;
		return 1;
	}
Exemplo n.º 8
0
apr_status_t teeterl_add_mod(const char *name, unsigned char *data, unsigned int size)
{
	xmod_bin_t *bin;

	//TODO: check for duplicates?
	bin = (xmod_bin_t *)apr_array_push(module_bins);
	bin->name = (cstr_t *)name;
	bin->data = (apr_byte_t *)data;
	bin->size = (apr_size_t)size;
	bin->is_preloaded = 0;
	return APR_SUCCESS;
}
Exemplo n.º 9
0
static const char *allow_cmd(cmd_parms *cmd, void *dv, const char *from,
                             const char *where_c)
{
    access_compat_dir_conf *d = (access_compat_dir_conf *) dv;
    allowdeny *a;
    char *where = apr_pstrdup(cmd->pool, where_c);
    char *s;
    apr_status_t rv;

    if (strcasecmp(from, "from"))
        return "allow and deny must be followed by 'from'";

    a = (allowdeny *) apr_array_push(cmd->info ? d->allows : d->denys);
    a->x.from = where;
    a->limited = cmd->limited;

    if (!strncasecmp(where, "env=!", 5)) {
        a->type = T_NENV;
        a->x.from += 5;

    }
    else if (!strncasecmp(where, "env=", 4)) {
        a->type = T_ENV;
        a->x.from += 4;

    }
    else if (!strcasecmp(where, "all")) {
        a->type = T_ALL;
    }
    else if ((s = ap_strchr(where, '/'))) {
        *s++ = '\0';
        rv = apr_ipsubnet_create(&a->x.ip, where, s, cmd->pool);
        if(APR_STATUS_IS_EINVAL(rv)) {
            /* looked nothing like an IP address */
            return "An IP address was expected";
        }
        else if (rv != APR_SUCCESS) {
            return apr_psprintf(cmd->pool, "%pm", &rv);
        }
        a->type = T_IP;
    }
    else if (!APR_STATUS_IS_EINVAL(rv = apr_ipsubnet_create(&a->x.ip, where,
                                        NULL, cmd->pool))) {
        if (rv != APR_SUCCESS)
            return apr_psprintf(cmd->pool, "%pm", &rv);
        a->type = T_IP;
    }
    else { /* no slash, didn't look like an IP address => must be a host */
        a->type = T_HOST;
    }

    return NULL;
}
Exemplo n.º 10
0
bool SetParamSession::CreateRequestQueue(mrcp_channel_t* pMrcpChannel)
{
    m_CurrentRequest = 0;
    m_RequestQueue = apr_array_make(GetSessionPool(),5,sizeof(mrcp_message_t*));
    mrcp_message_t* pMrcpMessage;

    pMrcpMessage = CreateSetParams1(pMrcpChannel);
    if(pMrcpMessage)
        *(mrcp_message_t**)apr_array_push(m_RequestQueue) = pMrcpMessage;

    pMrcpMessage = CreateGetParams1(pMrcpChannel);
    if(pMrcpMessage)
        *(mrcp_message_t**)apr_array_push(m_RequestQueue) = pMrcpMessage;

    pMrcpMessage = CreateSetParams2(pMrcpChannel);
    if(pMrcpMessage)
        *(mrcp_message_t**)apr_array_push(m_RequestQueue) = pMrcpMessage;

    pMrcpMessage = CreateGetParams2(pMrcpChannel);
    if(pMrcpMessage)
        *(mrcp_message_t**)apr_array_push(m_RequestQueue) = pMrcpMessage;

    pMrcpMessage = CreateSetParams3(pMrcpChannel);
    if(pMrcpMessage)
        *(mrcp_message_t**)apr_array_push(m_RequestQueue) = pMrcpMessage;

    pMrcpMessage = CreateGetParams3(pMrcpChannel);
    if(pMrcpMessage)
        *(mrcp_message_t**)apr_array_push(m_RequestQueue) = pMrcpMessage;

    return true;
}
Exemplo n.º 11
0
void gpdb_import_alert_log(apr_pool_t *pool)
{
	// Get alert log files to be imported.
	apr_array_header_t* tail_files = apr_array_make(pool, 10, sizeof(char*));
	apr_array_header_t* success_append_files = apr_array_make(pool, 10, sizeof(char*));
	get_alert_log_tail_files(tail_files, pool);

	// Create or truncate stage file.
	char *dst_file = apr_pstrcat(pool, GPMON_LOG, "/", GPMON_ALERT_LOG_STAGE, NULL);
	apr_status_t status = truncate_file(dst_file, pool);
	if (status != APR_SUCCESS)
	{
	    gpmon_warningx(FLINE, 0, "failed truncating stage file:%s", dst_file);
	    return;
	}

	// Append alert log tail file to stage file
	void *tail_file = NULL;
	while ((tail_file = apr_array_pop(tail_files)))
	{
		char *filename = *(char**)tail_file;
		void *success_file_slot = apr_array_push(success_append_files);
		if (!success_file_slot)
		{
			gpmon_warningx(
				FLINE, 0, "failed appending file:%s to stage file:%s due to out of memory",
				filename, dst_file);
			continue;
		}
		(*(char**)success_file_slot) = NULL;

	    status = apr_file_append(filename, dst_file, APR_FILE_SOURCE_PERMS, pool);
	    if (status != APR_SUCCESS)
	    {
			gpmon_warningx(FLINE, status, "failed appending file:%s to stage file:%s", filename, dst_file);
			continue;
		}
	    else
	    {
			(*(char**)success_file_slot) = filename;
	    	TR1(("success appending file:%s to stage file:%s\n", filename, dst_file));
	    }
	}

	// Insert tail file to history table.
	if (gpdb_insert_alert_log())
	{
		// Delete tail file
		gpdb_remove_success_files(success_append_files, pool);
		truncate_file(dst_file, pool);
	}
}
Exemplo n.º 12
0
static int change_remote_ip(request_rec *r) {
    const char *fwdvalue;
    char *val;
    rpaf_server_cfg *cfg = (rpaf_server_cfg *)ap_get_module_config(r->server->module_config,
                                                                   &rpaf_module);

    if (!cfg->enable)
        return DECLINED;

    if (is_in_array(r->connection->remote_ip, cfg->proxy_ips) == 1) {
        /* check if cfg->headername is set and if it is use
           that instead of X-Forwarded-For by default */
        if (cfg->headername && (fwdvalue = apr_table_get(r->headers_in, cfg->headername))) {
            //
        } else if (fwdvalue = apr_table_get(r->headers_in, "X-Forwarded-For")) {
            //
        } else {
            return DECLINED;
        }

        if (fwdvalue) {
            rpaf_cleanup_rec *rcr = (rpaf_cleanup_rec *)apr_pcalloc(r->pool, sizeof(rpaf_cleanup_rec));
            apr_array_header_t *arr = apr_array_make(r->pool, 0, sizeof(char*));
            while (*fwdvalue && (val = ap_get_token(r->pool, &fwdvalue, 1))) {
                *(char **)apr_array_push(arr) = apr_pstrdup(r->pool, val);
                if (*fwdvalue != '\0')
                    ++fwdvalue;
            }
            rcr->old_ip = apr_pstrdup(r->connection->pool, r->connection->remote_ip);
            rcr->r = r;
            apr_pool_cleanup_register(r->pool, (void *)rcr, rpaf_cleanup, apr_pool_cleanup_null);
            r->connection->remote_ip = apr_pstrdup(r->connection->pool, ((char **)arr->elts)[((arr->nelts)-1)]);
            r->connection->remote_addr->sa.sin.sin_addr.s_addr = apr_inet_addr(r->connection->remote_ip);
            if (cfg->sethostname) {
                const char *hostvalue;
                if (hostvalue = apr_table_get(r->headers_in, "X-Forwarded-Host")) {
                    /* 2.0 proxy frontend or 1.3 => 1.3.25 proxy frontend */
                    apr_table_set(r->headers_in, "Host", apr_pstrdup(r->pool, hostvalue));
                    r->hostname = apr_pstrdup(r->pool, hostvalue);
                    ap_update_vhost_from_headers(r);
                } else if (hostvalue = apr_table_get(r->headers_in, "X-Host")) {
                    /* 1.3 proxy frontend with mod_proxy_add_forward */
                    apr_table_set(r->headers_in, "Host", apr_pstrdup(r->pool, hostvalue));
                    r->hostname = apr_pstrdup(r->pool, hostvalue);
                    ap_update_vhost_from_headers(r);
                }
            }

        }
    }
    return DECLINED;
}
Exemplo n.º 13
0
/**
 * Sets which list of DN's are trusted to give directly the user DN, FQAN, ...
 * @param cmd    Lots of information about the configuration contexts (as pool).
 * @param config A pointer to the directory configuration.
 * @param w      The trusted DN.
 * @return       NULL on success. An error string otherwise.
 */
static const char *dav_ns_cmd_trusted(cmd_parms *cmd, void *config,
                                      const char *w)
{
  dav_ns_dir_conf *conf = (dav_ns_dir_conf*)config;
  
  if (conf->trusted_dns == NULL)
    conf->trusted_dns = apr_array_make(cmd->pool, 5, sizeof(char*));

  char **dn = apr_array_push(conf->trusted_dns);
  *dn = apr_pstrdup(cmd->pool, w);
  
  return NULL;
}
Exemplo n.º 14
0
MPF_DECLARE(apt_bool_t) mpf_codec_manager_codec_register(mpf_codec_manager_t *codec_manager, mpf_codec_t *codec)
{
	mpf_codec_t **slot;
	if(!codec || !codec->attribs || !codec->attribs->name.buf) {
		return FALSE;
	}

	apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Register Codec [%s]",codec->attribs->name.buf);

	slot = apr_array_push(codec_manager->codec_arr);
	*slot = codec;
	return TRUE;
}
Exemplo n.º 15
0
/*
 * Processes a 'elseif' element.
 */
static apr_status_t process_elseif (parser_rec *p, const char *element,
		int states, apr_table_t *attrs) {
	block_t *block;
	template_node_t *n;
	apr_status_t status;

	if ((states & TEMPLATE_SOPEN) != 0) {
		if (apr_is_empty_array(p->b)) {
			return parse_error(p, "no 'if' to continue");
		}
		block = ((block_t *) p->b->elts) + p->b->nelts - 1;
		if (block->type != TEMPLATE_TIF || block->if_last == -1) {
			return parse_error(p, "no 'if' to continue");
		}

		n = (template_node_t *) apr_array_push(p->t);
		n->type = TEMPLATE_TJUMP;
		n->jump_next = -1;
		block->if_cnt++;

		n = ((template_node_t *) p->t->elts) + block->if_last;
		n->if_next = p->t->nelts;
		block->if_last = p->t->nelts;

		n = (template_node_t *) apr_array_push(p->t);
		n->type = TEMPLATE_TIF;
		n->if_cond = apr_table_get(attrs, "cond");
		if (n->if_cond == NULL) {
			return parse_error(p, "missing attribute 'cond'");
		}
		if ((status = compile_exp(p, n->if_cond, &n->if_index))
				!= APR_SUCCESS) {
			return status;
		}
		n->if_next = -1;
	}

	return APR_SUCCESS;
}
Exemplo n.º 16
0
static void add_service(struct runtime_data *r, const char *host_name, uint16_t port, const char *location, const char *name, const char *types, int append_host_name, const char *txt_record) {
    struct service_data *d;
    char *w;
    ap_assert(r);

/*     ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->main_server, "add_service: %s %s %s %s", host_name, location, name, txt_record); */

    d = apr_palloc(r->pool, sizeof(struct service_data));
    ap_assert(d);

    d->pool = NULL;
    d->runtime = r;
    d->host_name = apr_pstrdup(r->pool, host_name);
    d->port = port;
    d->location = apr_pstrdup(r->pool, location);
    d->name = apr_pstrdup(r->pool, name);
    d->append_host_name = append_host_name;
    d->chosen_name = NULL;

    d->types = apr_array_make(r->pool, 4, sizeof(char*));

    if (types)
        while (*(w = ap_getword_conf(r->pool, &types)) != 0)
            *(char**) apr_array_push(d->types) = w;

    d->txt_record = apr_array_make(r->pool, 4, sizeof(char*));

    if (txt_record)
        while (*(w = ap_getword_conf(r->pool, &txt_record)) != 0)
            *(char**) apr_array_push(d->txt_record) = w;

    d->group = NULL;

    d->next = r->services;
    r->services = d;

/*     ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->main_server, "done"); */

}
Exemplo n.º 17
0
	static int cc_setCCServiceEnd(pool* p,char* xPath,int type,void* userdata){
		cc_bundle* bundle=(cc_bundle*)userdata;
		cc_service_descriptor* svc=(cc_service_descriptor*)bundle->userdata;
		cc_service_descriptor** svcplace=NULL;
		if(svc->id!=NULL){
			svcplace=(cc_service_descriptor**)apr_array_push(bundle->cc->services);
			*svcplace=svc;
		}
		
		bundle->userdata=NULL;
		bundle->userdata2=NULL;
		return 1;
	}
Exemplo n.º 18
0
static void tokens_to_array(apr_pool_t *p, const char *data,
                            apr_array_header_t *arr)
{
    char *token;

    while ((token = ap_get_list_item(p, &data)) != NULL) {
        *((const char **) apr_array_push(arr)) = token;
    }

    /* Sort it so that "Vary: A, B" and "Vary: B, A" are stored the same. */
    qsort((void *) arr->elts, arr->nelts,
         sizeof(char *), array_alphasort);
}
Exemplo n.º 19
0
static apt_bool_t mrcp_server_resource_offer_process(mrcp_server_session_t *session, mrcp_session_descriptor_t *descriptor)
{
	if(descriptor->resource_state == TRUE) {
		/* setup */
		mrcp_channel_t *channel;
		mrcp_channel_t **slot;
		int count = session->channels->nelts;
		channel = mrcp_server_channel_find(session,&descriptor->resource_name);
		if(channel) {
			/* channel already exists */
			return TRUE;
		}
		/* create new MRCP channel instance */
		channel = mrcp_server_channel_create(session,&descriptor->resource_name,count);
		if(!channel || !channel->resource) {
			return FALSE;
		}
		/* add to channel array */
		apt_log(APT_LOG_MARK,APT_PRIO_DEBUG,"Add Control Channel [%d]",count);
		slot = apr_array_push(session->channels);
		*slot = channel;

		if(channel->engine_channel) {
			/* open resource engine channel */
			if(mrcp_engine_channel_open(channel->engine_channel) == TRUE) {
				mpf_termination_t *termination = channel->engine_channel->termination;
				session->answer_flag_count++;

				if(termination) {
					/* send add termination request (add to media context) */
					if(mrcp_server_mpf_request_send(session,MPF_COMMAND_ADD,session->context,termination,NULL) == TRUE) {
						channel->waiting_for_termination = TRUE;
						session->answer_flag_count++;
					}

					if(termination->audio_stream) {
						mpf_rtp_media_descriptor_t *rtp_media_descriptor = mrcp_session_audio_media_get(descriptor,0);
						if(rtp_media_descriptor) {
							mpf_stream_mode_e mode = termination->audio_stream->mode;
							rtp_media_descriptor->mode |= mode;
						}
					}
				}
			}
		}
	}
	else {
		/* teardown */
	}
	return TRUE;
}
Exemplo n.º 20
0
static int
l_delete (lua_State *L) {

	const char *path = luaL_checkstring (L, 1);
	const char *message = (lua_gettop (L) < 2 || lua_isnil (L, 2)) ? "" : luaL_checkstring (L, 2);

	svn_boolean_t force = FALSE;
	
	int itable = 3;
	if (lua_gettop (L) >= itable && lua_istable (L, itable)) {
		lua_getfield (L, itable, "force");
		if (lua_isboolean (L, -1)) {
			force = lua_toboolean (L, -1);
		}
	} 

	apr_pool_t *pool;
	svn_error_t *err;
	svn_client_ctx_t *ctx;

	init_function (&ctx, &pool, L);

	path = svn_path_canonicalize (path, pool);

	apr_array_header_t *array;
	svn_commit_info_t *commit_info = NULL;

	array = apr_array_make (pool, 1, sizeof (const char *));
	(*((const char **) apr_array_push (array))) = path;

	lua_newtable (L);

	if (svn_path_is_url (path)) {
		make_log_msg_baton (&(ctx->log_msg_baton2), message, NULL, ctx->config, pool, L);
		ctx->log_msg_func2 = log_msg_func2;
	}

	err = svn_client_delete2 (&commit_info, array, force, ctx, pool);
	IF_ERROR_RETURN (err, pool, L);

	if (commit_info == NULL) {
		lua_pushnil (L);
	} else {
		lua_pushinteger (L, commit_info->revision);
	}
	
	svn_pool_destroy (pool);

	return 1;

}
Exemplo n.º 21
0
static int authz_dbd_group_query(request_rec *r, authz_dbd_cfg *cfg,
                                 apr_array_header_t *groups)
{
    /* SELECT group FROM authz WHERE user = %s */
    int rv;
    const char *message;
    ap_dbd_t *dbd = dbd_handle(r);
    apr_dbd_prepared_t *query;
    apr_dbd_results_t *res = NULL;
    apr_dbd_row_t *row = NULL;
    const char **group;

    if (cfg->query == NULL) {
        ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(01649)
                      "No query configured for dbd-group!");
        return HTTP_INTERNAL_SERVER_ERROR;
    }
    query = apr_hash_get(dbd->prepared, cfg->query, APR_HASH_KEY_STRING);
    if (query == NULL) {
        ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(01650)
                      "Error retrieving query for dbd-group!");
        return HTTP_INTERNAL_SERVER_ERROR;
    }
    rv = apr_dbd_pvselect(dbd->driver, r->pool, dbd->handle, &res,
                          query, 0, r->user, NULL);
    if (rv == 0) {
        for (rv = apr_dbd_get_row(dbd->driver, r->pool, res, &row, -1);
             rv != -1;
             rv = apr_dbd_get_row(dbd->driver, r->pool, res, &row, -1)) {
            if (rv == 0) {
                group = apr_array_push(groups);
                *group = apr_dbd_get_entry(dbd->driver, row, 0);
            }
            else {
                message = apr_dbd_error(dbd->driver, dbd->handle, rv);
                ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(01651)
                        "authz_dbd in get_row; group query for user=%s [%s]",
                        r->user, message?message:noerror);
                return HTTP_INTERNAL_SERVER_ERROR;
            }
        }
    }
    else {
        message = apr_dbd_error(dbd->driver, dbd->handle, rv);
        ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(01652)
                      "authz_dbd, in groups query for %s [%s]",
                      r->user, message?message:noerror);
        return HTTP_INTERNAL_SERVER_ERROR;
    }
    return OK;
}
Exemplo n.º 22
0
Arquivo: luasvn.c Projeto: ifzz/luasvn
static int
l_commit (lua_State *L) {
	apr_pool_t *pool;
	svn_error_t *err;
	svn_client_ctx_t *ctx;

	apr_array_header_t *array;

	const char *path = (lua_gettop (L) < 1 || lua_isnil (L, 1)) ? "" : luaL_checkstring (L, 1);
	const char *message = (lua_gettop (L) < 2 || lua_isnil (L, 2)) ? "" : luaL_checkstring (L, 2);
	int itable = 3;
	svn_boolean_t recursive = TRUE;
	svn_boolean_t keep_locks = FALSE;
	svn_commit_info_t *commit_info = NULL;
	
	if (lua_gettop (L) >= itable && lua_istable (L, itable)) {
		lua_getfield (L, itable, "recursive");
		if (lua_isboolean (L, -1)) {
			recursive = lua_toboolean (L, -1);
		}

		lua_getfield (L, itable, "keep_locks");
		if (lua_isboolean (L, -1)) {
			keep_locks = lua_toboolean (L, -1);
		}
	} 

	init_function (&ctx, &pool, L);

	path = svn_path_canonicalize (path, pool);

	array = apr_array_make (pool, 1, sizeof (const char *));
	(*((const char **) apr_array_push (array))) = path;

	make_log_msg_baton (&(ctx->log_msg_baton2), message, path, ctx->config, pool, L);
	
	ctx->log_msg_func2 = log_msg_func2;

	err = svn_client_commit3 (&commit_info, array, recursive, keep_locks, ctx, pool);
	IF_ERROR_RETURN (err, pool, L);	

	if (commit_info == NULL) {
		lua_pushnil (L);
	} else {
		lua_pushinteger (L, commit_info->revision);
	}

	svn_pool_destroy (pool);

	return 1;
}
Exemplo n.º 23
0
void set_view(groupid_t gid, nodeid_t *nids, size_t sz_nids) {
    apr_thread_mutex_lock(mx_view_);
    
    apr_array_header_t *arr = NULL;
    arr = apr_array_make(mp_view_, 10, sizeof(nodeid_t));
    for (int i = 0; i < sz_nids; i++) {
        nodeid_t nid = nids[i];
        *(nodeid_t *)apr_array_push(arr) = nid;
    }
    groupid_t *g = apr_palloc(mp_view_, sizeof(groupid_t));
    apr_hash_set(ht_view_, g, sizeof(groupid_t), arr);
    
    apr_thread_mutex_unlock(mx_view_);
}
Exemplo n.º 24
0
static const char *add_server_string_slot(cmd_parms *cmd,
                                     		 void *struct_ptr,
                                     		 const char *arg)
{
	char **addme;
	void *ptr = ap_get_module_config(cmd->server->module_config,
			&log_sql_module);
	int offset = (int)(long)cmd->info;
	apr_array_header_t *ary = *(apr_array_header_t **)((char *)ptr + offset);
	addme = apr_array_push(ary);
	*addme = apr_pstrdup(ary->pool, arg);

    return NULL;
}
Exemplo n.º 25
0
static const char *set_ctypes(cmd_parms * cmd, void *mconf,
			      const char *line)
{
    triger_ctype_t *ctype;
    apr_pool_t *pool = cmd->pool;
    if (!line)
	return NULL;
    triger_conf_t *cfg = mconf;

    ctype = apr_array_push(cfg->ctypes);
    ctype->data = apr_pstrdup(pool, line);

    return NULL;
}
Exemplo n.º 26
0
	static int amx_setActionRequestHeader(pool* p,char* xPath,int type,const char *body,void* userdata){
		actmap_tmp* ctmp=(actmap_tmp*)userdata;
		page_action_xml* pa=(page_action_xml*)ctmp->tmp;
		action_header_xml* hdr=(action_header_xml*)ctmp->tmp8, **headerPlace;

		if(pa!=NULL&&pa->requestHeaders!=NULL&&hdr!=NULL){
			hdr->value=apr_pstrdup(p,body);
			headerPlace=(action_header_xml**)apr_array_push(pa->requestHeaders);
			*headerPlace=hdr;
			//printf("requestHeaders=%s:%s\n", hdr->name, hdr->value);
			ctmp->tmp8=NULL;
		}
		return 1;
	}
Exemplo n.º 27
0
	static int amx_addPathMappingMatchList(pool* p,char* xPath,int type,const char *body,void* userdata){
		actmap_tmp* ctmp=(actmap_tmp*)userdata;
		path_mapping_xml* pa=(path_mapping_xml*)ctmp->tmp;
		char** pos=NULL, *tmp;
		if(pa!=NULL){
			pos=apr_array_push(pa->matchLists);
			tmp=apr_pstrdup(p,body);
			if(ctmp->conf->uid!=0){
				tmp=apr_psprintf(p,"%s_%d",tmp,ctmp->conf->uid);
			}
			*pos=tmp;
		}
		return 1;
	}
Exemplo n.º 28
0
static void *ap_buffered_log_writer_init(apr_pool_t *p, server_rec *s,
                                        const char* name)
{
    buffered_log *b;
    b = apr_pcalloc(p, sizeof(buffered_log));
    b->handle = ap_default_log_writer_init(p, s, name);

    if (b->handle) {
        *(buffered_log **)apr_array_push(all_buffered_logs) = b;
        return b;
    }
    else
        return NULL;
}
Exemplo n.º 29
0
	static int amx_addPathMapping(pool* p,char* xPath,int type,void* userdata){
		oidc_config_xml* amx=NULL;
		path_mapping_xml* pm=NULL, **placepm=NULL;
		actmap_tmp* ctmp=(actmap_tmp*)userdata;
		
		amx=(oidc_config_xml*)ctmp->conf;
		if(amx!=NULL&&ctmp->tmp!=NULL){
			pm=(path_mapping_xml*)ctmp->tmp;
			placepm=(path_mapping_xml**)apr_array_push (amx->path_mappings_arr);
			*placepm=pm;
		}
		ctmp->tmp=NULL;
		return 1;
	}
Exemplo n.º 30
0
static const char *compile_command_remove_extension(cmd_parms *cmd, void *overrides, const char *extension) {
  COMPILE_FIND_CONFIG;
  compile_attribute_config_t *attribute;
  if (*extension == '.') {
    ++ extension;
  }
  if ( ! config->removed_commands) {
    config->removed_commands = apr_array_make(cmd->pool, 4, sizeof (*attribute));
  }
  attribute = (compile_attribute_config_t*) apr_array_push(config->removed_commands);
  attribute->name = apr_pstrdup(cmd->pool, extension);
  ap_str_tolower(attribute->name);
  return NULL;
}