Exemplo n.º 1
0
void
list_loadconf (char *file, GSList ** list, char *defaultconf)
{
	char *filebuf;
	char *ibuf;
	int fd;
	struct stat st;

	filebuf = g_strdup_printf ("%s" G_DIR_SEPARATOR_S "%s", get_xdir (), file);
	fd = g_open (filebuf, O_RDONLY | OFLAGS, 0);
	g_free (filebuf);

	if (fd == -1)
	{
		if (defaultconf)
			list_load_from_data (list, defaultconf, strlen (defaultconf));
		return;
	}
	if (fstat (fd, &st) != 0)
	{
		perror ("fstat");
		abort ();
	}

	ibuf = malloc (st.st_size);
	read (fd, ibuf, st.st_size);
	close (fd);

	list_load_from_data (list, ibuf, st.st_size);

	free (ibuf);
}
Exemplo n.º 2
0
void
list_loadconf (char *file, GSList ** list, char *defaultconf)
{
	char filebuf[256];
	char *ibuf;
	int fh;
	struct stat st;

	snprintf (filebuf, sizeof (filebuf), "%s/%s", get_xdir_fs (), file);
	fh = open (filebuf, O_RDONLY | OFLAGS);
	if (fh == -1)
	{
		if (defaultconf)
			list_load_from_data (list, defaultconf, strlen (defaultconf));
		return;
	}
	if (fstat (fh, &st) != 0)
	{
		perror ("fstat");
		abort ();
	}

	ibuf = malloc (st.st_size);
	read (fh, ibuf, st.st_size);
	close (fh);

	list_load_from_data (list, ibuf, st.st_size);

	free (ibuf);
}