Exemplo n.º 1
0
int
main (int   argc,
      char**argv)
{
	Repository* repository;
	gchar* working_folder;

	g_type_init ();

	working_folder = g_get_current_dir ();

	repository = repository_new (working_folder);
	repository_wait (repository);
	repository_foreach (repository, (GHFunc)print_revs, NULL);
	g_object_unref (repository);
	g_free (working_folder);

	return 0;
}
Exemplo n.º 2
0
repository_t *rsync_get_repository(driver_t * self, char *supfile,
				   list_t * repositories_hierarchy)
{
	FILE *file;
	char *line, *path, *name, *extension;
	repository_t *repository;
	size_t n;
	int nread;

	assert(supfile);
	if (!(extension = rindex(supfile, '.')) || strcmp(extension, ".rsync"))
		return NULL;

	supfile = xstrdup_printf("/etc/ports/%s", supfile);

	file = fopen(supfile, "r");
	if (file == NULL)
		return NULL;

	line = NULL;
	repository = NULL;

	while ((nread = getline(&line, &n, file)) >= 0) {
		*(line + strlen(line) - 1) = 0;
		strtrim(line);
		if (line[0] == '#' || strlen(line) == 0 ||
		    (!strstr(line, "destination") && strchr(line, '=')))
			continue;
		path = strtrim(xstrdup(strchr(line, '=') + 1));
		if (!strncmp("/usr/ports/", path, 11))
			name = xstrdup(path + 11);
		else
			name = xstrdup(strrchr(path, '/') + 1);
		repository = repository_new(name, path, supfile, self,
					    repositories_hierarchy);
		break;
	}
	free(line);
	fclose(file);
	return repository;
}