Beispiel #1
0
int get_watch_dir_count(dictionary* dict)
{
	char *val = {0};
	char *def = "";
	int count = 0;
	char copy_of_val[FILENAME_MAX];
	char *watch_dir = "folder:watch_dir";
	val = iniparser_getstring(dict, watch_dir, def);
	strcpy(copy_of_val, val);


	char *pch = strtok(copy_of_val, ", ");
	while (pch != NULL )
	{
		count++;
		if (is_recursive(dict))
		{
			int nbrOfRecFolders = count_all_dirs(pch);
			if (nbrOfRecFolders < 0) return -1;
			count += nbrOfRecFolders;
		}
		pch = strtok(NULL, ", ");
	}

	return count;
}
Beispiel #2
0
int load_watch_dir(dictionary *dict, struct conf *config)
{
	char copy_of_val[FILENAME_MAX];
	memset(copy_of_val,'\0',FILENAME_MAX);
	char *def = "";
	char *watch_dir = "folder:watch_dir";
	strcpy(copy_of_val, iniparser_getstring(dict, watch_dir, def));
	char* pch = strtok(copy_of_val, ", ");
	while (pch != NULL )
	{
		if (write_to_watchdir(config,pch))
		{
			return -1;
		}

		if ( is_recursive(dict) )
		{
			load_watch_dir_rec(pch, config);
		}

		pch = strtok(NULL, ", ");
	}

	return 0;
}
Beispiel #3
0
static void
init_keys_info(keys_info_t *keys_info, int mapped)
{
	keys_info->selector = 0;
	keys_info->count = 0;
	keys_info->indexes = NULL;
	keys_info->after_wait = 0;
	keys_info->mapped = mapped;
	keys_info->recursive = is_recursive();
}
Beispiel #4
0
/* Increments counter if we are at the first level of key parsing recursion and
 * the key sequence isn't mapped. */
static void
inc_counter(const keys_info_t *const keys_info, const size_t by)
{
	assert(enters_counter > 0);

	if(!is_recursive())
	{
		counter += keys_info->mapped ? 0 : by;
	}
}