Example #1
0
/******************************************
 Add a parameter to the given event
 return RET_NOK on error
 ***********************************************/
ret_code_t map_add_event_param(const char * map, int layer,
		const char * event_id, const char * param)
{
	char layer_name[SMALL_BUF];

	sprintf(layer_name, "%s%d", MAP_KEY_LAYER, layer);

	// Make sure the param list exists
	entry_list_create(MAP_TABLE, map, layer_name, MAP_ENTRY_EVENT_LIST,
			event_id, MAP_EVENT_PARAM, nullptr);

	return entry_add_to_list(MAP_TABLE, map, param, layer_name,
			MAP_ENTRY_EVENT_LIST, event_id, MAP_EVENT_PARAM, nullptr);
}
Example #2
0
File: misc.c Project: whs1787/ffs
entry_list_t * entry_list_create_by_regex(ffs_t * ffs, const char * name)
{
	assert(ffs != NULL);

	if (name == NULL)
		name = ".*";

	RAII(regex_t*, rx, regex_create(name), regex_free);
	if (rx == NULL)
		return NULL;

	entry_list_t * self = entry_list_create(ffs);
	if (self == NULL)
		return NULL;

	int entry_list(ffs_entry_t * entry)
	{
		assert(entry != NULL);

		char full_name[page_size];
		if (__ffs_entry_name(ffs, entry, full_name,
				     sizeof full_name) < 0)
			return -1;
		if (regexec(rx, full_name, 0, NULL, 0) == REG_NOMATCH)
			return 0;

		entry_node_t * entry_node;
		entry_node = (entry_node_t *)malloc(sizeof(*entry_node));
		if (entry_node == NULL) {
			ERRNO(errno);
			return -1;
		}

		memcpy(&entry_node->entry, entry, sizeof(*entry));
		list_add_tail(&self->list, &entry_node->node);

		return 0;
	}