当前位置: 首页>>代码示例>>C++>>正文


C++ rbtree_finddata函数代码示例

本文整理汇总了C++中rbtree_finddata函数的典型用法代码示例。如果您正苦于以下问题:C++ rbtree_finddata函数的具体用法?C++ rbtree_finddata怎么用?C++ rbtree_finddata使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了rbtree_finddata函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: rbtree_finddata

static indexed_modcallable *lookup_by_index(rbtree_t *components,
					    int comp, int idx)
{
	indexed_modcallable myc;
	
	myc.comp = comp;
	myc.idx = idx;

	return rbtree_finddata(components, &myc);
}
开发者ID:claude191,项目名称:freeradius-server,代码行数:10,代码来源:modules.c

示例2: strlcpy

/** Find a map processor by name
 *
 * @param[in] name of map processor.
 * @return
 *	- #map_proc matching name.
 *	- NULL if none was found.
 */
map_proc_t *map_proc_find(char const *name)
{
	map_proc_t find;

	if (!map_proc_root) return NULL;

	strlcpy(find.name, name, sizeof(find.name));
	find.length = strlen(find.name);

	return rbtree_finddata(map_proc_root, &find);
}
开发者ID:K1ngR1chard,项目名称:freeradius-server,代码行数:18,代码来源:map_proc.c

示例3: mod_map_proc

/** Perform a search and map the result of the search to server attributes
 *
 * @param[in] mod_inst #rlm_csv_t
 * @param[in] proc_inst mapping map entries to field numbers.
 * @param[in,out] request The current request.
 * @param[in] key key to look for
 * @param[in] maps Head of the map list.
 * @return
 *	- #RLM_MODULE_NOOP no rows were returned.
 *	- #RLM_MODULE_UPDATED if one or more #VALUE_PAIR were added to the #REQUEST.
 *	- #RLM_MODULE_FAIL if an error occurred.
 */
static rlm_rcode_t mod_map_proc(void *mod_inst, UNUSED void *proc_inst, REQUEST *request,
				char const *key, vp_map_t const *maps)
{
	rlm_csv_t		*inst = mod_inst;
	rlm_csv_entry_t		*e, my_entry;
	vp_map_t const		*map;

	my_entry.key = key;

	e = rbtree_finddata(inst->tree, &my_entry);
	if (!e) return RLM_MODULE_NOOP;

	RINDENT();
	for (map = maps;
	     map != NULL;
	     map = map->next) {
		int field;
		char *field_name;

		/*
		 *	Avoid memory allocations if possible.
		 */
		if (map->rhs->type != TMPL_TYPE_LITERAL) {
			if (tmpl_aexpand(request, &field_name, request, map->rhs, NULL, NULL) < 0) {
				RDEBUG("Failed expanding RHS at %s", map->lhs->name);
				return RLM_MODULE_FAIL;
			}
		} else {
			memcpy(&field_name, &map->rhs->name, sizeof(field_name)); /* const */
		}

		field = fieldname2offset(inst, field_name);

		if (field_name != map->rhs->name) talloc_free(field_name);

		if (field < 0) {
			RDEBUG("No such field name %s", map->rhs->name);
			return RLM_MODULE_FAIL;
		}

		/*
		 *	Pass the raw data to the callback, which will
		 *	create the VP and add it to the map.
		 */
		if (map_to_request(request, map, csv_map_getvalue, e->data[field]) < 0) {
			return RLM_MODULE_FAIL;
		}
	}

	return RLM_MODULE_UPDATED;
}
开发者ID:K1ngR1chard,项目名称:freeradius-server,代码行数:63,代码来源:rlm_csv.c

示例4: fr_network_socket_delete

/** Delete a socket from a network.  MUST be called only by the listener itself!.
 *
 * @param nr		the network
 * @param listen	Functions and context.
 */
int fr_network_socket_delete(fr_network_t *nr, fr_listen_t const *listen)
{
	fr_network_socket_t *s, my_socket;

	my_socket.listen = listen;
	s = rbtree_finddata(nr->sockets, &my_socket);
	if (!s) {
		return -1;
	}

	fr_network_socket_dead(nr, s);

	return 0;
}
开发者ID:bt4,项目名称:freeradius-server,代码行数:19,代码来源:network.c

示例5: _map_proc_unregister

/** Unregister a map processor
 *
 * @param[in] proc to unregister.
 */
static int _map_proc_unregister(map_proc_t *proc)
{
	map_proc_t find;
	map_proc_t *found;

	strlcpy(find.name, proc->name, sizeof(find.name));
	find.length = strlen(find.name);

	found = rbtree_finddata(map_proc_root, &find);
	if (!found) return 0;

	rbtree_deletebydata(map_proc_root, found);

	return 0;
}
开发者ID:K1ngR1chard,项目名称:freeradius-server,代码行数:19,代码来源:map_proc.c

示例6: fr_network_listen_read

/** Signal the network to read from a listener
 *
 * @param nr the network
 * @param listen the listener to read from
 */
void fr_network_listen_read(fr_network_t *nr, fr_listen_t const *listen)
{
	fr_network_socket_t my_socket, *s;

	(void) talloc_get_type_abort(nr, fr_network_t);
	(void) talloc_get_type_abort_const(listen, fr_listen_t);

	my_socket.listen = listen;
	s = rbtree_finddata(nr->sockets, &my_socket);
	if (!s) return;

	/*
	 *	Go read the socket.
	 */
	fr_network_read(nr->el, s->fd, 0, s);
}
开发者ID:bt4,项目名称:freeradius-server,代码行数:21,代码来源:network.c

示例7: xlat_unregister

/** Unregister an xlat function
 *
 * We can only have one function to call per name, so the passing of "func"
 * here is extraneous.
 *
 * @param[in] name xlat to unregister.
 * @param[in] func unused.
 * @param[in] instance data.
 */
void xlat_unregister(char const *name, UNUSED RAD_XLAT_FUNC func, void *instance)
{
	xlat_t	*c;
	xlat_t		my_xlat;

	if (!name) return;

	strlcpy(my_xlat.name, name, sizeof(my_xlat.name));
	my_xlat.length = strlen(my_xlat.name);

	c = rbtree_finddata(xlat_root, &my_xlat);
	if (!c) return;

	if (c->instance != instance) return;

	rbtree_deletebydata(xlat_root, c);
}
开发者ID:dleo,项目名称:freeradius-server,代码行数:26,代码来源:xlat.c

示例8: fr_heap_peek

/*
 *	Find a cached entry.
 */
static rlm_cache_entry_t *cache_find(rlm_cache_t *inst, REQUEST *request,
				     char const *key)
{
	int ttl;
	rlm_cache_entry_t *c, my_c;
	VALUE_PAIR *vp;

	/*
	 *	Look at the expiry heap.
	 */
	c = fr_heap_peek(inst->heap);
	if (!c) {
		rad_assert(rbtree_num_elements(inst->cache) == 0);
		return NULL;
	}

	/*
	 *	If it's time to expire an old entry, do so now.
	 */
	if (c->expires < request->timestamp) {
		fr_heap_extract(inst->heap, c);
		rbtree_deletebydata(inst->cache, c);
	}

	/*
	 *	Is there an entry for this key?
	 */
	my_c.key = key;
	c = rbtree_finddata(inst->cache, &my_c);
	if (!c) return NULL;

	/*
	 *	Yes, but it expired, OR the "forget all" epoch has
	 *	passed.  Delete it, and pretend it doesn't exist.
	 */
	if ((c->expires < request->timestamp) ||
	    (c->created < inst->epoch)) {
	delete:
		RDEBUG("Entry has expired, removing");

		fr_heap_extract(inst->heap, c);
		rbtree_deletebydata(inst->cache, c);

		return NULL;
	}
开发者ID:capone1992,项目名称:freeradius-server,代码行数:48,代码来源:rlm_cache.c

示例9: rbtree_finddata

/*
 *	Find a client in the RADCLIENTS list by number.
 *	This is a support function for the statistics code.
 */
RADCLIENT *client_findbynumber(RADCLIENT_LIST const *clients, int number)
{
	if (!clients) clients = root_clients;

	if (!clients) return NULL;

	if (number >= tree_num_max) return NULL;

	if (tree_num) {
		RADCLIENT myclient;

		myclient.number = number;

		return rbtree_finddata(tree_num, &myclient);
	}

	return NULL;
}
开发者ID:arr2036,项目名称:freeradius-server,代码行数:22,代码来源:client.c

示例10: strlcpy

/*
 *	find the appropriate registered xlat function.
 */
static xlat_t *xlat_find(const char *module)
{
	xlat_t my_xlat;

	/*
	 *	Look for dictionary attributes first.
	 */
	if ((dict_attrbyname(module) != NULL) ||
	    (strchr(module, '[') != NULL) ||
	    (strchr(module, '#') != NULL)) {
		module = "request";
	}

	strlcpy(my_xlat.module, module, sizeof(my_xlat.module));
	my_xlat.length = strlen(my_xlat.module);

	return rbtree_finddata(xlat_root, &my_xlat);
}
开发者ID:HAJC,项目名称:freeradius-server,代码行数:21,代码来源:xlat.c

示例11: xlat_unregister

/**
 * @brief Unregister an xlat function.
 *
 *	We can only have one function to call per name, so the
 *	passing of "func" here is extraneous.
 *
 * @param module xlat to unregister
 * @param func Unused
 * @return Void.
 */
void xlat_unregister(const char *module, RAD_XLAT_FUNC func, void *instance)
{
	xlat_t	*c;
	xlat_t		my_xlat;

	func = func;		/* -Wunused */

	if (!module) return;

	strlcpy(my_xlat.module, module, sizeof(my_xlat.module));
	my_xlat.length = strlen(my_xlat.module);

	c = rbtree_finddata(xlat_root, &my_xlat);
	if (!c) return;

	if (c->instance != instance) return;

	rbtree_deletebydata(xlat_root, c);
}
开发者ID:rssh,项目名称:freeradius-server,代码行数:29,代码来源:xlat.c

示例12: rbtree_finddata

/** Retrieve module/thread specific instance data for a module
 *
 * @param[in] mi		to find thread specific data for.
 * @return
 *	- Thread specific instance data on success.
 *	- NULL if module has no thread instance data.
 */
module_thread_instance_t *module_thread_instance_find(module_instance_t *mi)
{
	rbtree_t			*tree = module_thread_inst_tree;
	module_thread_instance_t	find = { .mod_inst = mi->dl_inst->data };

	return rbtree_finddata(tree, &find);
}

/** Retrieve module/thread specific instance data for a module
 *
 * @param[in] mod_inst		Module specific instance to find thread_data for.
 * @return
 *	- Thread specific instance data on success.
 *	- NULL if module has no thread instance data.
 */
void *module_thread_instance_by_data(void *mod_inst)
{
	rbtree_t			*tree = module_thread_inst_tree;
	module_thread_instance_t	find = { .mod_inst = mod_inst }, *found;
开发者ID:alagoutte,项目名称:freeradius-server,代码行数:26,代码来源:module.c

示例13: cmd_stats_socket

static int cmd_stats_socket(FILE *fp, FILE *fp_err, void *ctx, fr_cmd_info_t const *info)
{
	fr_network_t const *nr = ctx;
	fr_network_socket_t *s, my_s;

	my_s.number = info->box[0]->vb_uint32;

	s = rbtree_finddata(nr->sockets_by_num, &my_s);
	if (!s) {
		fprintf(fp_err, "No such socket number '%s'.\n", info->argv[0]);
		return -1;
	}

	fprintf(fp, "count.in\t%" PRIu64 "\n", s->stats.in);
	fprintf(fp, "count.out\t%" PRIu64 "\n", s->stats.out);
	fprintf(fp, "count.dup\t%" PRIu64 "\n", s->stats.dup);
	fprintf(fp, "count.dropped\t%" PRIu64 "\n", s->stats.dropped);

	return 0;
}
开发者ID:bt4,项目名称:freeradius-server,代码行数:20,代码来源:network.c

示例14: policy_evaluate_name

/*
 *	Evaluate a policy, keyed by name.
 */
static int policy_evaluate_name(policy_state_t *state, const char *name)
{
	int rcode;
	const policy_item_t *this;
	policy_named_t mypolicy, *policy;

	mypolicy.name = name;
	policy = rbtree_finddata(state->inst->policies, &mypolicy);
	if (!policy) return RLM_MODULE_FAIL;

	DEBUG2("rlm_policy: Evaluating policy %s", name);

	rad_assert(policy->item.type != POLICY_TYPE_BAD);
	rad_assert(policy->item.type < POLICY_TYPE_NUM_TYPES);

	rcode = policy_stack_push(state, policy->policy);
	if (!rcode) {
		return RLM_MODULE_FAIL;
	}

	/*
	 *	FIXME: Look for magic keywords like "return",
	 *	where the packet gets accepted/rejected/whatever
	 */
	while (policy_stack_pop(state, &this)) {
		rad_assert(this != NULL);
		rad_assert(this->type != POLICY_TYPE_BAD);
		rad_assert(this->type < POLICY_TYPE_NUM_TYPES);

		debug_evaluate("Evaluating at line %d\n",
			       this->lineno);
		rcode = (*evaluate_functions[this->type])(state,
							  this);
		if (!rcode) {
			return RLM_MODULE_FAIL;
		}
	} /* loop until the stack is empty */

	return state->rcode;
}
开发者ID:joyphone,项目名称:freeradius-server,代码行数:43,代码来源:evaluate.c

示例15: switch

/*
 *	Find a client in the RADCLIENTS list.
 */
RADCLIENT *client_find(RADCLIENT_LIST const *clients, fr_ipaddr_t const *ipaddr, int proto)
{
  int32_t i, max_prefix;
	RADCLIENT myclient;

	if (!clients) clients = root_clients;

	if (!clients || !ipaddr) return NULL;

	switch (ipaddr->af) {
	case AF_INET:
		max_prefix = 32;
		break;

	case AF_INET6:
		max_prefix = 128;
		break;

	default :
		return NULL;
	}

	for (i = max_prefix; i >= (int32_t) clients->min_prefix; i--) {
		void *data;

		myclient.ipaddr = *ipaddr;
		myclient.proto = proto;
		fr_ipaddr_mask(&myclient.ipaddr, i);

		if (!clients->trees[i]) continue;

		data = rbtree_finddata(clients->trees[i], &myclient);
		if (data) return data;
	}

	return NULL;
}
开发者ID:arr2036,项目名称:freeradius-server,代码行数:40,代码来源:client.c


注:本文中的rbtree_finddata函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。