コード例 #1
0
ファイル: filetype.c プロジェクト: ackeack/workenv
assoc_records_t
get_all_programs_for_file(const char *file)
{
    int i;
    assoc_records_t result = {};

    for(i = 0; i < active_filetypes.count; i++)
    {
        assoc_records_t progs;
        int j;

        if(!global_matches(active_filetypes.list[i].pattern, file))
        {
            continue;
        }

        progs = active_filetypes.list[i].records;
        for(j = 0; j < progs.count; j++)
        {
            assoc_record_t prog = progs.list[j];
            add_assoc_record(&result, prog.command, prog.description);
        }
    }

    return result;
}
コード例 #2
0
ファイル: filetype.c プロジェクト: ackeack/workenv
static int
get_filetype_number(const char *file, assoc_list_t assoc_list)
{
    int i;
    for(i = 0; i < assoc_list.count; i++)
    {
        if(global_matches(assoc_list.list[i].pattern, file))
        {
            return i;
        }
    }
    return -1;
}
コード例 #3
0
ファイル: filetype.c プロジェクト: sklnd/vifm
static int
matches_assoc(const char *file, const assoc_t *assoc)
{
	char *exptr;

	/* Only one extension */
	if((exptr = strchr(assoc->ext, ',')) == NULL)
	{
		if(global_matches(assoc->ext, file))
			return 1;
	}
	else
	{
		char *ex_copy = strdup(assoc->ext);
		char *free_this = ex_copy;
		while((exptr = strchr(ex_copy, ',')) != NULL)
		{
			*exptr++ = '\0';

			if(global_matches(ex_copy, file))
			{
				free(free_this);
				return 1;
			}

			ex_copy = exptr;
		}
		if(global_matches(ex_copy, file))
		{
			free(free_this);
			return 1;
		}
		free(free_this);
	}
	return 0;
}