Ejemplo n.º 1
0
/**
 * returns >0 if one or more token files exist
 */
static int
token_file_exists() {

	int ret = dir_foreach(SCD_TOKEN_DIR, &is_token, NULL);

	if (ret < 0)
		FATAL("Could not open token directory");
	else {
		DEBUG("%d Token files exist", ret);
		return ret;
	}
}
Ejemplo n.º 2
0
pid_t
proc_find(pid_t ppid, const char *name)
{
	struct proc_find data = { ppid, name, 0 };

	if (dir_foreach("/proc", &proc_find_cb, &data) < 0) {
		WARN("Could not traverse /proc");
		return -1;
	}

	return data.match;
}
Ejemplo n.º 3
0
static int 
conf_dir_foreach(const char *s, int (*cb)(const char *, const char *)) {
  int e;
  e = dir_foreach(s, cb);
  if(e < 0) {
    parse_error(s,"unable to open directory",xsyserr());
    return -1;
  }
  else if(e > 0)
    return -1;
  else
    return 0;
}
Ejemplo n.º 4
0
int
proc_killall(pid_t ppid, const char *name, int sig)
{
	struct proc_killall data = { ppid, name, sig };

	DEBUG("Trying to kill %s with ppid %d", name, ppid);
	if (dir_foreach("/proc", &proc_killall_cb, &data) < 0) {
		WARN("Could not traverse /proc");
		return -1;
	}

	return 0;
}
Ejemplo n.º 5
0
static void
scan_skindir(const gchar * path)
{
    GError *error = NULL;

    g_return_if_fail(path != NULL);

    if (path[0] == '.')
        return;

    if (!dir_foreach(path, scan_skindir_func, NULL, &error)) {
        g_warning("Failed to open directory (%s): %s", path, error->message);
        g_error_free(error);
        return;
    }
}
Ejemplo n.º 6
0
static gboolean del_directory_func(const gchar *path, const gchar *basename,
                                   void *params)
{
    if (!strcmp(basename, ".") || !strcmp(path, ".."))
        return FALSE;

    if (g_file_test(path, G_FILE_TEST_IS_DIR))
    {
        dir_foreach(path, del_directory_func, NULL, NULL);
        rmdir(path);
        return FALSE;
    }

    unlink(path);

    return FALSE;
}
void key_assigner_regen_filenames()
{
	char** ptr;

	for(unsigned int i = 0; i < model_nb_filenames; i++)
		free(model_filenames[i]);

	free(model_filenames);
	model_nb_filenames = 0;

	// TODO: That's ugly; use list
	if(!dir_foreach(
		DATA_PATH "/" MODELS,
		foreach_count,
		foreach_process,
		foreach_concat,
		(void*)&ptr))
		model_filenames = NULL;
}
Ejemplo n.º 8
0
int
scd_load_token()
{
	if (scd_token) {
		softtoken_free(scd_token);
		scd_token = NULL;
	}
	if (mkdir(scd_get_token_dir(), 0755) < 0 && errno != EEXIST) {
		ERROR_ERRNO("Cound not mkdir token directory %s", scd_get_token_dir());
		return -1;
	}
	int res = dir_foreach(scd_get_token_dir(), &scd_load_token_cb, NULL);
	if (res < 0) {
		WARN("Error scanning token directory %s.", scd_get_token_dir());
		return -1;
	}
	if (res == 0) {
		ERROR("No token found in %s.", scd_get_token_dir());
		return -1;
	}
	return 0;
}
Ejemplo n.º 9
0
static void scan_plugins(const char * path)
{
    dir_foreach (path, scan_plugin_func, NULL);
}
Ejemplo n.º 10
0
void del_directory(const gchar *path)
{
    dir_foreach(path, del_directory_func, NULL, NULL);
    rmdir(path);
}