View | Details | Raw Unified
Collapse All | Expand All

(-) portage-utils-0.1.21/applets.h (-19 / +19 lines)
 Lines 29-35   DECLARE_APPLET(qxpak) Link Here 
DECLARE_APPLET(qpkg)
DECLARE_APPLET(qpkg)
DECLARE_APPLET(qgrep)
DECLARE_APPLET(qgrep)
DECLARE_APPLET(qatom)
DECLARE_APPLET(qatom)
DECLARE_APPLET(qmerge)
DECLARE_APPLET(qmerge) 
DECLARE_APPLET(qcache)
DECLARE_APPLET(qcache)
DECLARE_APPLET(qpy)
DECLARE_APPLET(qpy)
DECLARE_APPLET(qglsa) /* disable */
DECLARE_APPLET(qglsa) /* disable */
 Lines 47-70   struct applet_t { Link Here 
	const char *desc;
	const char *desc;
} applets[] = {
} applets[] = {
	/* q must always be the first applet */
	/* q must always be the first applet */
	{"q",         q_main,         "<applet> <args>", "virtual applet"},
	{"q",         q_main,         "<applet> <args>", "virtual applet"		},
	{"qatom",     qatom_main,     "<pkg>",           "split atom strings"},
	{"qatom",     qatom_main,     "<pkg>",           "split atom strings"		},
	{"qcache",    qcache_main,    "<action> <args>", "search the metadata cache"},
	{"qcache",    qcache_main,    "<action> <args>", "search the metadata cache"	},
	{"qcheck",    qcheck_main,    "<pkgname>",       "verify mtimes/digests"},
	{"qcheck",    qcheck_main,    "<pkgname>",       "verify mtimes/digests"	},
	{"qdepends",  qdepends_main,  "<pkgname>",       "show dependency info"},
	{"qdepends",  qdepends_main,  "<pkgname>",       "show dependency info"		},
	{"qfile",     qfile_main,     "<filename>",      "list all pkgs owning files"},
	{"qfile",     qfile_main,     "<filename>",      "list all pkgs owning files"	},
	{"qglsa",     qglsa_main,     "<action> <list>", "check GLSAs against system"},
	{"qgrep",     qgrep_main,     "<misc args>",     "grep in ebuilds"		},
	{"qgrep",     qgrep_main,     "<misc args>",     "grep in ebuilds"},
	{"qlist",     qlist_main,     "<pkgname>",       "list files owned by pkgname"	},
	{"qlist",     qlist_main,     "<pkgname>",       "list files owned by pkgname"},
	{"qlop",      qlop_main,      "<pkgname>",       "paludis log analyzer"		},
	{"qlop",      qlop_main,      "<pkgname>",       "emerge log analyzer"},
	{"qpkg",      qpkg_main,      "<misc args>",     "manipulate Gentoo binpkgs"	},
	{"qmerge",    qmerge_main,    "<pkgnames>",      "fetch and merge binary package"},
	{"qsearch",   qsearch_main,   "<regex>",         "search pkgname/desc"		},
	{"qpkg",      qpkg_main,      "<misc args>",     "manipulate Gentoo binpkgs"},
	{"qsize",     qsize_main,     "<pkgname>",       "calculate size usage"		},
	{"qpy",      qpy_main,      "<misc args>",     "python interface"},
	{"qtbz2",     qtbz2_main,     "<misc args>",     "manipulate tbz2 packages"	},
	{"qsearch",   qsearch_main,   "<regex>",         "search pkgname/desc"},
	{"quse",      quse_main,      "<useflag>",       "find pkgs using useflags"	},
	{"qsize",     qsize_main,     "<pkgname>",       "calculate size usage"},
	{"qxpak",     qxpak_main,     "<misc args>",     "manipulate xpak archives"	},
	{"qtbz2",     qtbz2_main,     "<misc args>",     "manipulate tbz2 packages"},
	{"qmerge",    qmerge_main,    "<pkgnames>",      "fetch and merge binary package"},	
	{"quse",      quse_main,      "<useflag>",       "find pkgs using useflags"},
	{"qglsa",     qglsa_main,     "<action> <list>", NULL				},		/* "check GLSAs against system" */
	{"qxpak",     qxpak_main,     "<misc args>",     "manipulate xpak archives"},
	{"qpy",       qpy_main,       "<misc args>",     NULL				},		/* "python interface" */
	/* aliases for equery capatability */
	/* aliases for equery capatability */
(-) portage-utils-0.1.21/main.c (-89 / +196 lines)
 Lines 71-76   int rematch(const char *, const char *, Link Here 
static char *rmspace(char *);
static char *rmspace(char *);
void initialize_portage_env(void);
void initialize_portage_env(void);
void initialize_overlays (char portdir_overlay[]);
void initialize_ebuild_flat(void);
void initialize_ebuild_flat(void);
void reinitialize_ebuild_flat(void);
void reinitialize_ebuild_flat(void);
void reinitialize_as_needed(void);
void reinitialize_as_needed(void);
 Lines 85-97   static int quiet = 0; Link Here 
static char pretend = 0;
static char pretend = 0;
static char reinitialize = 0;
static char reinitialize = 0;
static char reinitialize_metacache = 0;
static char reinitialize_metacache = 0;
static char portdir[_Q_PATH_MAX] = "/usr/portage";
static char portarch[20] = "";
static char portarch[20] = "";
static char portvdb[] = "var/db/pkg";
static char portvdb[] = "var/db/pkg";
static char portcachedir[] = "metadata/cache";
static char portcachedir[] = "metadata/cache";
static char portroot[_Q_PATH_MAX] = "/";
static char portroot[_Q_PATH_MAX] = "/";
static char config_protect[_Q_PATH_MAX] = "/etc/";
static char config_protect[_Q_PATH_MAX] = "/etc/";
typedef struct overlay_t overlay_t;
struct overlay_t {
	char name[64];
	char path[_Q_PATH_MAX];
	struct overlay_t *next;
};
static overlay_t *overlay_gentoo = NULL;
char pkgdir[512] = "/usr/portage/packages/";
char pkgdir[512] = "/usr/portage/packages/";
char port_tmpdir[512] = "/var/tmp/portage/";
char port_tmpdir[512] = "/var/tmp/portage/";
 Lines 176-182   void no_colors() { Link Here 
	getopt_long(argc, argv, ex A ## _FLAGS, a ## _long_opts, NULL)
	getopt_long(argc, argv, ex A ## _FLAGS, a ## _long_opts, NULL)
/* display usage and exit */
/* display usage and exit */
static void usage(int status, const char *flags, struct option const opts[], 
static void usage(int status, const char *flags, struct option const opts[], 
                  const char *help[], int blabber)
		  const char *help[], int blabber)
{
{
	unsigned long i;
	unsigned long i;
	if (blabber == 0) {
	if (blabber == 0) {
 Lines 199-208   static void usage(int status, const char Link Here 
	for (i = 0; opts[i].name; ++i) {
	for (i = 0; opts[i].name; ++i) {
		assert(help[i] != NULL); /* this assert is a life saver when adding new applets. */
		assert(help[i] != NULL); /* this assert is a life saver when adding new applets. */
		if (opts[i].has_arg == no_argument)
		if (opts[i].has_arg == no_argument)
			printf("  -%c, --%-15s%s*%s %s\n", opts[i].val,
			printf("  -%c, --%-16s%s*%s %s\n", opts[i].val,
				opts[i].name, RED, NORM, _(help[i]));
				opts[i].name, RED, NORM, _(help[i]));
		else
		else
			printf("  -%c, --%-8s %s<arg>%s %s*%s %s\n", opts[i].val,
			printf("  -%c, --%-9s %s<arg>%s %s*%s %s\n", opts[i].val,
				opts[i].name, DKBLUE, NORM, RED, NORM, _(help[i]));
				opts[i].name, DKBLUE, NORM, RED, NORM, _(help[i]));
	}
	}
	exit(status);
	exit(status);
 Lines 213-219   static void version_barf(const char *Id) Link Here 
# define VERSION "cvs"
# define VERSION "cvs"
#endif
#endif
	printf("portage-utils-%s: compiled on %s\n%s\n"
	printf("portage-utils-%s: compiled on %s\n%s\n"
	       "%s written for Gentoo by <solar and vapier @ gentoo.org>\n",
	       "%s written for Gentoo by <solar and vapier @ gentoo.org>\n"
	       "modified for overlay support by samuelethiec @ hotmail.com\n",
	       VERSION, __DATE__, Id, argv0);
	       VERSION, __DATE__, Id, argv0);
	exit(EXIT_SUCCESS);
	exit(EXIT_SUCCESS);
}
}
 Lines 298-336   static char *remove_extra_space(char *st Link Here 
void freeargv(int, char **);
void freeargv(int, char **);
void freeargv(int argc, char **argv) {
void freeargv(int argc, char **argv) {
	int i;
	int i;
        if (argc > 0) {
	if (argc > 0) {
                for (i = 0; i < argc; i++)
		for (i = 0; i < argc; i++)
                        free(argv[i]);
			free(argv[i]);
                free(argv);
		free(argv);
        }
	}
}
}
void makeargv(char *string, int *argc, char ***argv);
void makeargv(char *string, int *argc, char ***argv);
void makeargv(char *string, int *argc, char ***argv) {
void makeargv(char *string, int *argc, char ***argv) {
	int curc = 2;
	int curc = 2;
	char *q, *p, *str;        
	char *q, *p, *str;	
	(*argv) = (char **) malloc(sizeof(char **) * curc);
	(*argv) = (char **) malloc(sizeof(char **) * curc);
	*argc = 1;        
	*argc = 1;	
	(*argv)[0] = xstrdup(argv0);
	(*argv)[0] = xstrdup(argv0);
	q = xstrdup(string);        
	q = xstrdup(string);	
	str = q;
	str = q;
	remove_extra_space(str);        
	remove_extra_space(str);	
	rmspace(str);
	rmspace(str);
	while (str) {
	while (str) {
		if ((p = strchr(str, ' ')) != NULL)
		if ((p = strchr(str, ' ')) != NULL)
			*(p++) = '\0';
			*(p++) = '\0';
                if (*argc == curc) {
		if (*argc == curc) {
			curc *= 2;
			curc *= 2;
			(*argv) = (char **) realloc(*argv, sizeof(char **) * curc);
			(*argv) = (char **) realloc(*argv, sizeof(char **) * curc);
                }
		}
                (*argv)[*argc] = xstrdup(str);
		(*argv)[*argc] = xstrdup(str);
                (*argc)++;
		(*argc)++;
                str = p;
		str = p;
        }
	}
	free(q);
	free(q);
}
}
 Lines 453-469   char *strincr_var(const char *name, char Link Here 
	return (char *) value;
	return (char *) value;
}
}
void initialize_overlays (char portdir_overlay[])
{
	short merror = 0;
	char buf[BUFSIZE], file[_Q_PATH_MAX], *s, *p, *t;
	overlay_t *cur_overlay;
	FILE *repo_nameFP;
	s = portdir_overlay;
	cur_overlay = overlay_gentoo;
	while (*s) {
		cur_overlay->next = (overlay_t *) xmalloc ( sizeof (*cur_overlay->next));
		cur_overlay = cur_overlay->next;
		cur_overlay->next = NULL;
		if ( (p=strchr(s,' ')))
			*p = 0;
		strncpy(cur_overlay->path, s, sizeof(cur_overlay->path));
		/* find the name for the overlay */
		strncpy(file, cur_overlay->path, _Q_PATH_MAX);
		strncat(file, "/profiles/repo_name", _Q_PATH_MAX);
		if (( repo_nameFP = fopen(file, "r") ))
		{
			if ( ! ( fgets(buf, sizeof(buf),repo_nameFP)) )
				merror++;
			rmspace(buf);
			if ( (t = strchr(buf,'\n')))
				*t = 0;
			strncpy(cur_overlay->name, buf, sizeof(cur_overlay->name));
			fclose(repo_nameFP);
		} else 
			merror++;
		if (merror) {
			/* delete trailing '/' */
			t = cur_overlay->path + strlen(cur_overlay->path) - 1;
			if ( *t == '/' )
				*t = 0;
			strncat(cur_overlay->name, basename(cur_overlay->path), sizeof(cur_overlay->name));
			merror=0;
		}
		if (p)
			s = p+1;
		else
			break;
	}
	
}
void initialize_portage_env(void)
void initialize_portage_env(void)
{
{
	char nocolor = 0;
	char nocolor = 0;
	int i, f;
	int i, f;
	struct stat st;
	struct stat st;
	FILE *fp;
	FILE *fp;
	char tmp_portdir[_Q_PATH_MAX];
	char portdir_overlay[2048] = "";
	char buf[BUFSIZE], *s, *p;
	char buf[BUFSIZE], *s, *p;
	char profile[_Q_PATH_MAX], portage_file[_Q_PATH_MAX];
	char profile[_Q_PATH_MAX], portage_file[_Q_PATH_MAX];
	const char *files[] = {portage_file, "/etc/make.globals", "/etc/make.conf"};
	const char *files[] = {portage_file, "/etc/make.globals", "/etc/make.conf"};
	typedef enum { _Q_BOOL, _Q_STR, _Q_ISTR } var_types;
	typedef enum { _Q_BOOL, _Q_STR, _Q_ISTR } var_types;
	
	struct {
	struct {
		const char *name;
		const char *name;
		const size_t name_len;
		const size_t name_len;
 Lines 471-489   void initialize_portage_env(void) Link Here 
		char *value;
		char *value;
		const size_t value_len;
		const size_t value_len;
	} vars_to_read[] = {
	} vars_to_read[] = {
		{"ACCEPT_LICENSE", 14, _Q_STR,  accept_license, sizeof(accept_license)},
		{"ACCEPT_LICENSE",	14, _Q_STR,	accept_license,		 sizeof(accept_license)		},
		{"INSTALL_MASK", 12, _Q_ISTR,  install_mask, sizeof(install_mask)},
		{"INSTALL_MASK",	12, _Q_ISTR,	install_mask,		 sizeof(install_mask)		},
		{"ARCH",    4, _Q_STR,  portarch, sizeof(portarch)},
		{"ARCH",		4, _Q_STR,	portarch,		 sizeof(portarch)		},
		{"CONFIG_PROTECT",    14, _Q_STR,  config_protect, sizeof(config_protect)},
		{"CONFIG_PROTECT",	14, _Q_STR,	config_protect,		 sizeof(config_protect)		},
		{"NOCOLOR", 7, _Q_BOOL, &nocolor, 1},
		{"NOCOLOR",		7, _Q_BOOL,	&nocolor,		 1				},
		{"FEATURES",8, _Q_ISTR,  features, sizeof(features)},
		{"FEATURES",		8, _Q_ISTR,	features,		 sizeof(features)		},
		{"PORTDIR", 7, _Q_STR,  portdir, sizeof(portdir)},
		{"PORTDIR",		7, _Q_STR,	tmp_portdir,		 sizeof(tmp_portdir)		},
		{"PORTAGE_BINHOST",   15, _Q_STR,  binhost, sizeof(binhost)},
		{"PORTDIR_OVERLAY",	15, _Q_ISTR,	portdir_overlay,	 sizeof(portdir_overlay)	},
		{"PORTAGE_TMPDIR",    14, _Q_STR,  port_tmpdir, sizeof(port_tmpdir)},
		{"PORTAGE_BINHOST",	15, _Q_STR,	binhost,		 sizeof(binhost)		},
		{"PKGDIR",  6, _Q_STR,  pkgdir, sizeof(pkgdir)},
		{"PORTAGE_TMP",		9, _Q_STR,	port_tmpdir,		 sizeof(port_tmpdir)		},
		{"ROOT",    4, _Q_STR,  portroot, sizeof(portroot)}
		{"PKGDIR",		6, _Q_STR,	pkgdir,			 sizeof(pkgdir)			},
		{"ROOT",		4, _Q_STR,	portroot,		 sizeof(portroot)		}
	};
	};
	overlay_gentoo = (overlay_t*) xmalloc(sizeof(*overlay_gentoo));
	strcpy(overlay_gentoo->name,"gentoo");
	strcpy(overlay_gentoo->path,"/usr/portage");
	overlay_gentoo->next = NULL;
	if ((p = strchr(portroot, '/')) != NULL)
	if ((p = strchr(portroot, '/')) != NULL)
		if (strlen(p) != 1)
		if (strlen(p) != 1)
			strncat(portroot, "/", sizeof(portroot));
			strncat(portroot, "/", sizeof(portroot));
 Lines 575-580   void initialize_portage_env(void) Link Here 
		no_colors();
		no_colors();
	else
	else
		color_remap();
		color_remap();
	strncpy(overlay_gentoo->path, tmp_portdir, sizeof(overlay_gentoo->path));
	/* now we initiliase the overlay chained list with overlay_gentoo the first 'item'  */
	initialize_overlays(portdir_overlay);
}
}
enum {
enum {
 Lines 603-621   const char *initialize_flat(int cache_ty Link Here 
	int a, b, c, d, e, i;
	int a, b, c, d, e, i;
	int frac, secs, count;
	int frac, secs, count;
	FILE *fp;
	FILE *fp;
	overlay_t *cur_overlay;
	a = b = c = d = e = i = 0;
	a = b = c = d = e = i = 0;
	count = frac = secs = 0;
	count = frac = secs = 0;
	cur_overlay = overlay_gentoo;
	cache_file = (cache_type == CACHE_EBUILD ? CACHE_EBUILD_FILE : CACHE_METADATA_FILE);
	cache_file = (cache_type == CACHE_EBUILD ? CACHE_EBUILD_FILE : CACHE_METADATA_FILE);
	if (chdir(portdir) != 0) {
	if (chdir(overlay_gentoo->path) != 0) {
		warnp("chdir to PORTDIR '%s' failed", portdir);
		warnp("chdir to PORTDIR '%s' failed", overlay_gentoo->path);
		goto ret;
		goto ret;
	}
	}
	if (cache_type == CACHE_METADATA && chdir(portcachedir) != 0) {
	if (cache_type == CACHE_METADATA && chdir(portcachedir) != 0) {
		warnp("chdir to portage cache '%s/%s' failed", portdir, portcachedir);
		warnp("chdir to paludis cache '%s/%s' failed", overlay_gentoo->path, portcachedir);
		goto ret;
		goto ret;
	}
	}
 Lines 631-694   const char *initialize_flat(int cache_ty Link Here 
	unlink(cache_file);
	unlink(cache_file);
	if (errno != ENOENT) {
	if (errno != ENOENT) {
		warnfp("unlinking '%s/%s' failed", portdir, cache_file);
		warnfp("unlinking '%s/%s' failed", overlay_gentoo->path, cache_file);
		goto ret;
		goto ret;
	}
	}
	if ((fp = fopen(cache_file, "w")) == NULL) {
	if ((fp = fopen(cache_file, "w")) == NULL) {
		warnfp("opening '%s/%s' failed", portdir, cache_file);
		warnfp("opening '%s/%s' failed", overlay_gentoo->path, cache_file);
		goto ret;
		goto ret;
	}
	}
	gettimeofday(&start, NULL);
	gettimeofday(&start, NULL);
	if ((a = scandir(".", &category, filter_hidden, alphasort)) < 0)
	do {
		goto ret;
		if ( cur_overlay == overlay_gentoo || chdir(cur_overlay->path) == 0) {
			if ((a = scandir(".", &category, filter_hidden, alphasort)) < 0)
	for (i = 0 ; i < a; i++) {
		stat(category[i]->d_name, &st);
		if (!S_ISDIR(st.st_mode))
			continue;
		if (strchr(category[i]->d_name, '-') == NULL)
			if ((strncmp(category[i]->d_name, "virtual", 7)) != 0)
				continue;
				continue;
		if ((b = scandir(category[i]->d_name, &pn, filter_hidden, alphasort)) < 0)
			for (i = 0 ; i < a; i++) {
			continue;
				stat(category[i]->d_name, &st);
		for (c = 0; c < b; c++) {
				if (!S_ISDIR(st.st_mode))
			char de[_Q_PATH_MAX];
					continue;
				if (strchr(category[i]->d_name, '-') == NULL)
					if ((strncmp(category[i]->d_name, "virtual", 7)) != 0)
						continue;
			snprintf(de, sizeof(de), "%s/%s", category[i]->d_name, pn[c]->d_name);
				if ((b = scandir(category[i]->d_name, &pn, filter_hidden, alphasort)) < 0)
					continue;
				for (c = 0; c < b; c++) {
					char de[_Q_PATH_MAX];
			if (stat(de, &st) < 0)
					snprintf(de, sizeof(de), "%s/%s", category[i]->d_name, pn[c]->d_name);
				continue;
			switch (cache_type) {
					if (stat(de, &st) < 0)
			case CACHE_EBUILD:
						continue;
				if (!S_ISDIR(st.st_mode))
					continue;
					switch (cache_type) {
				break;
					case CACHE_EBUILD:
			case CACHE_METADATA:
						if (!S_ISDIR(st.st_mode))
				if (S_ISREG(st.st_mode))
							continue;
					fprintf(fp, "%s\n", de);
						break;
				continue;
					case CACHE_METADATA:
				break;
						if (S_ISREG(st.st_mode))
			}
							fprintf(fp, "%s\n", de);
			if ((e = scandir(de, &eb, filter_hidden, alphasort)) < 0)
						continue;
				continue;
						break;
			for (d = 0 ; d < e; d++) {
					}
				if ((p = strrchr(eb[d]->d_name, '.')) != NULL)
					if ((e = scandir(de, &eb, filter_hidden, alphasort)) < 0)
					if (strcmp(p, ".ebuild") == 0) {
						continue;
						count++;
					for (d = 0 ; d < e; d++) {
						fprintf(fp, "%s/%s/%s\n", category[i]->d_name, pn[c]->d_name, eb[d]->d_name);
						if ((p = strrchr(eb[d]->d_name, '.')) != NULL)
							if (strcmp(p, ".ebuild") == 0) {
								count++;
								fprintf(fp, "%s::%s/%s/%s\n", cur_overlay->name, category[i]->d_name, pn[c]->d_name, eb[d]->d_name);
							}
					}
					}
					while(d--)
						free(eb[d]);
					free(eb);
				}
				while(b--)
					free(pn[b]);
				free(pn);
			}
			}
			while(d--) free(eb[d]);
		} else
			free(eb);
			warnp("chdir to PORTDIR '%s' failed, skipping the %s repository", cur_overlay->path, cur_overlay->name);
		}
		while(b--) free(pn[b]);
	} while ( (cur_overlay = cur_overlay->next));
		free(pn);
	}
	fclose(fp);
	fclose(fp);
	while(a--) free(category[a]);
	while(a--) free(category[a]);
	free(category);
	free(category);
 Lines 699-705   const char *initialize_flat(int cache_ty Link Here 
	if (start.tv_usec > finish.tv_usec) {
	if (start.tv_usec > finish.tv_usec) {
		finish.tv_usec += 1000000;
		finish.tv_usec += 1000000;
		finish.tv_sec--;
		finish.tv_sec--;
        
	
	}
	}
	frac = (finish.tv_usec - start.tv_usec);
	frac = (finish.tv_usec - start.tv_usec);
	secs = (finish.tv_sec - start.tv_sec);
	secs = (finish.tv_sec - start.tv_sec);
 Lines 708-714   const char *initialize_flat(int cache_ty Link Here 
	warn("Finished %u entries in %d.%06d seconds", count, secs, frac);
	warn("Finished %u entries in %d.%06d seconds", count, secs, frac);
	if (secs > 100)
	if (secs > 100)
		warn("You should consider a faster file system such as reiserfs for PORTDIR='%s'", portdir);
		warn("You should consider a faster file system such as reiserfs for PORTDIR='%s'", overlay_gentoo->path);
ret:
ret:
	return cache_file;
	return cache_file;
}
}
 Lines 717-724   ret: Link Here 
void reinitialize_ebuild_flat(void)
void reinitialize_ebuild_flat(void)
{
{
	if ((chdir(portdir)) != 0) {
	if ((chdir(overlay_gentoo->path)) != 0) {
		warnp("chdir to PORTDIR '%s' failed", portdir);
		warnp("chdir to PORTDIR '%s' failed", overlay_gentoo->path);
		return;
		return;
	}
	}
	unlink(CACHE_EBUILD_FILE);
	unlink(CACHE_EBUILD_FILE);
 Lines 900-918   void cache_free(portage_cache *cache) Link Here 
char *grab_vdb_item(const char *, const char *, const char *);
char *grab_vdb_item(const char *, const char *, const char *);
char *grab_vdb_item(const char *item, const char *CATEGORY, const char *PF) {
char *grab_vdb_item(const char *item, const char *CATEGORY, const char *PF) {
        static char buf[_Q_PATH_MAX];
	static char buf[_Q_PATH_MAX];
        char *p;
	char *p;
        FILE *fp;
	FILE *fp;
	snprintf(buf, sizeof(buf), "%s%s/%s/%s/%s", portroot, portvdb, CATEGORY, PF, item);
	snprintf(buf, sizeof(buf), "%s%s/%s/%s/%s", portroot, portvdb, CATEGORY, PF, item);
	if ((fp = fopen(buf, "r")) == NULL)
	if ((fp = fopen(buf, "r")) == NULL)
		return NULL;        
		return NULL;	
	fgets(buf, sizeof(buf), fp);
	fgets(buf, sizeof(buf), fp);
	if ((p = strchr(buf, '\n')) != NULL)                
	if ((p = strchr(buf, '\n')) != NULL)
		*p = 0;
		*p = 0;
	fclose(fp);
	fclose(fp);
	rmspace(buf);
	rmspace(buf);
        
	
	return buf;
	return buf;
}
}
 Lines 922-928   queue *get_vdb_atoms(void) { Link Here 
	int dfd, i;
	int dfd, i;
	char buf[_Q_PATH_MAX];
	char buf[_Q_PATH_MAX];
        static char savecwd[_POSIX_PATH_MAX];
	static char savecwd[_POSIX_PATH_MAX];
	struct dirent **cat;
	struct dirent **cat;
	struct dirent **pf;
	struct dirent **pf;
 Lines 930-936   queue *get_vdb_atoms(void) { Link Here 
	depend_atom *atom = NULL;
	depend_atom *atom = NULL;
	queue *cpf = NULL;
	queue *cpf = NULL;
        getcwd(savecwd, sizeof(savecwd));
	getcwd(savecwd, sizeof(savecwd));
	assert(chdir(savecwd) == 0);
	assert(chdir(savecwd) == 0);
 Lines 974-980   queue *get_vdb_atoms(void) { Link Here 
				snprintf(buf, sizeof(buf), "%s/%s-%s", atom->CATEGORY, atom->PN, atom->PV);
				snprintf(buf, sizeof(buf), "%s/%s-%s", atom->CATEGORY, atom->PN, atom->PV);
			atom_implode(atom);
			atom_implode(atom);
			cpf = add_set(buf, "0", cpf);
			cpf = add_set(buf, "0", cpf);
			
		}
		}
		chdir("..");
		chdir("..");
		while(dfd--) free(pf[dfd]);
		while(dfd--) free(pf[dfd]);
 Lines 990-998   fuckit: Link Here 
	return cpf;
	return cpf;
}
}
/* free overlays */
void free_overlays(overlay_t *overlay);
void free_overlays(overlay_t *overlay)
{
	if ( overlay->next )
		free_overlays(overlay->next);
	free(overlay);
}
void cleanup() {
void cleanup() {
	reinitialize_as_needed();
	reinitialize_as_needed();
	free_sets(virtuals);
	free_sets(virtuals);
	free_overlays(overlay_gentoo);
	fclose(stderr);
	fclose(stderr);
}
}
(-) portage-utils-0.1.21/q.c (-1 / +13 lines)
 Lines 7-21    Link Here 
 * Copyright 2005-2006 Mike Frysinger  - <vapier@gentoo.org>
 * Copyright 2005-2006 Mike Frysinger  - <vapier@gentoo.org>
 */
 */
#define Q_FLAGS "irm" COMMON_FLAGS
#define Q_FLAGS "ilrm" COMMON_FLAGS
static struct option const q_long_opts[] = {
static struct option const q_long_opts[] = {
	{"install",      no_argument, NULL, 'i'},
	{"install",      no_argument, NULL, 'i'},
	{"ls-overlays",  no_argument, NULL, 'l'},
	{"reinitialize", no_argument, NULL, 'r'},
	{"reinitialize", no_argument, NULL, 'r'},
	{"metacache",    no_argument, NULL, 'm'},
	{"metacache",    no_argument, NULL, 'm'},
	COMMON_LONG_OPTS
	COMMON_LONG_OPTS
};
};
static const char *q_opts_help[] = {
static const char *q_opts_help[] = {
	"Install symlinks for applets",
	"Install symlinks for applets",
	"List configured overlays",
	"Reinitialize ebuild cache",
	"Reinitialize ebuild cache",
	"Reinitialize metadata cache",
	"Reinitialize metadata cache",
	COMMON_OPTS_HELP
	COMMON_OPTS_HELP
 Lines 70-75   int q_main(int argc, char **argv) Link Here 
	int i;
	int i;
	char *p;
	char *p;
	APPLET func;
	APPLET func;
	overlay_t * cur_overlay;
	if (argc == 0)
	if (argc == 0)
		return 1;
		return 1;
 Lines 89-94   int q_main(int argc, char **argv) Link Here 
		COMMON_GETOPTS_CASES(q)
		COMMON_GETOPTS_CASES(q)
		case 'm': reinitialize_metacache = 1; break;
		case 'm': reinitialize_metacache = 1; break;
		case 'r': reinitialize = 1; break;
		case 'r': reinitialize = 1; break;
		case 'l': {
			printf("\n%sOverlay(s) :%s\n\n", GREEN, NORM);
			cur_overlay=overlay_gentoo;
			do {
				printf("   Name : %s%-20.20s%s \tlocation : %s%s%s\n", CYAN, cur_overlay->name, NORM, CYAN, cur_overlay->path, NORM);
			} while ( (cur_overlay=cur_overlay->next));
			fputc('\n', stdout);
			return 0;
			}
		case 'i': {
		case 'i': {
			char buf[_Q_PATH_MAX];
			char buf[_Q_PATH_MAX];
			/* always bzero a buffer before using readlink() */
			/* always bzero a buffer before using readlink() */
(-) portage-utils-0.1.21/qcache.c (-5 / +5 lines)
 Lines 323-331   int traverse_metadata_cache(void (*func) Link Here 
	char *pathcat, *pathpkg, *pathebld, *pathcache, *ebuild, *category;
	char *pathcat, *pathpkg, *pathebld, *pathcache, *ebuild, *category;
	struct direct **categories, **packages, **ebuilds;
	struct direct **categories, **packages, **ebuilds;
	len = strlen(portdir) + strlen(portcachedir) + 3;
	len = strlen(overlay_gentoo->path) + strlen(portcachedir) + 3;
	pathcache = (char *) xmalloc(len);
	pathcache = (char *) xmalloc(len);
	snprintf(pathcache,len,"%s/%s/",portdir,portcachedir);
	snprintf(pathcache,len,"%s/%s/",overlay_gentoo->path,portcachedir);
	qcache_numcat = numcat = scandir(pathcache, &categories, file_select, alphasort);
	qcache_numcat = numcat = scandir(pathcache, &categories, file_select, alphasort);
	if (numcat == (-1))
	if (numcat == (-1))
 Lines 335-343   int traverse_metadata_cache(void (*func) Link Here 
		warn("%s is empty!", pathcache);
		warn("%s is empty!", pathcache);
	for (i = 0; i < numcat; i++) {
	for (i = 0; i < numcat; i++) {
		len = strlen(portdir) + strlen(categories[i]->d_name) + 2;
		len = strlen(overlay_gentoo->path) + strlen(categories[i]->d_name) + 2;
		pathcat = (char *) xmalloc(len);
		pathcat = (char *) xmalloc(len);
		snprintf(pathcat,len,"%s/%s",portdir,categories[i]->d_name);
		snprintf(pathcat,len,"%s/%s",overlay_gentoo->path,categories[i]->d_name);
		current_category = categories[i]->d_name;
		current_category = categories[i]->d_name;
 Lines 538-544   void qcache_not(char *path, char *catego Link Here 
		} while (!isdigit(*temp));
		} while (!isdigit(*temp));
		*(temp-1) = '\0';
		*(temp-1) = '\0';
		printf("%s%s/%s%s%s\n",BOLD,category,BLUE,ebuild,NORM);		
		printf("%s%s/%s%s%s\n",BOLD,category,BLUE,ebuild,NORM);
	}
	}
}
}
(-) portage-utils-0.1.21/qcheck.c (-3 / +3 lines)
 Lines 74-80   int qcheck_main(int argc, char **argv) Link Here 
			if (!search_all) {
			if (!search_all) {
				for (i = optind; i < argc; ++i) {
				for (i = optind; i < argc; ++i) {
					snprintf(buf, sizeof(buf), "%s/%s", dentry->d_name, 
					snprintf(buf, sizeof(buf), "%s/%s", dentry->d_name, 
					         de->d_name);
						 de->d_name);
					if (rematch(argv[i], buf, REG_EXTENDED) == 0)
					if (rematch(argv[i], buf, REG_EXTENDED) == 0)
						break;
						break;
					if (rematch(argv[i], de->d_name, REG_EXTENDED) == 0)
					if (rematch(argv[i], de->d_name, REG_EXTENDED) == 0)
 Lines 85-91   int qcheck_main(int argc, char **argv) Link Here 
			}
			}
			snprintf(buf, sizeof(buf), "%s%s/%s/%s/CONTENTS", portroot, portvdb,
			snprintf(buf, sizeof(buf), "%s%s/%s/%s/CONTENTS", portroot, portvdb,
			         dentry->d_name, de->d_name);
				 dentry->d_name, de->d_name);
			if ((fp = fopen(buf, "r")) == NULL)
			if ((fp = fopen(buf, "r")) == NULL)
				continue;
				continue;
			strncat(buf, "~", sizeof(buf));
			strncat(buf, "~", sizeof(buf));
 Lines 154-160   int qcheck_main(int argc, char **argv) Link Here 
						switch (hash_algo) {
						switch (hash_algo) {
							case HASH_MD5:  digest_disp = "MD5"; break;
							case HASH_MD5:  digest_disp = "MD5"; break;
							case HASH_SHA1: digest_disp = "SHA1"; break;
							case HASH_SHA1: digest_disp = "SHA1"; break;
							default:        digest_disp = "UNK"; break;
							default:	digest_disp = "UNK"; break;
						}
						}
						printf(" %s%s-DIGEST%s: %s", RED, digest_disp, NORM, e->name);
						printf(" %s%s-DIGEST%s: %s", RED, digest_disp, NORM, e->name);
						if (verbose)
						if (verbose)
(-) portage-utils-0.1.21/qdepends.c (-7 / +7 lines)
 Lines 374-380   int qdepends_main_vdb(const char *depend Link Here 
			/* see if this cat/pkg is requested */
			/* see if this cat/pkg is requested */
			for (i = optind; i < argc; ++i) {
			for (i = optind; i < argc; ++i) {
				snprintf(buf, sizeof(buf), "%s/%s", dentry->d_name, 
				snprintf(buf, sizeof(buf), "%s/%s", dentry->d_name, 
				         de->d_name);
					 de->d_name);
				if (rematch(argv[i], buf, REG_EXTENDED) == 0)
				if (rematch(argv[i], buf, REG_EXTENDED) == 0)
					break;
					break;
				if (rematch(argv[i], de->d_name, REG_EXTENDED) == 0)
				if (rematch(argv[i], de->d_name, REG_EXTENDED) == 0)
 Lines 384-390   int qdepends_main_vdb(const char *depend Link Here 
				continue;
				continue;
			snprintf(buf, sizeof(buf), "%s%s/%s/%s/%s", portroot, portvdb,
			snprintf(buf, sizeof(buf), "%s%s/%s/%s/%s", portroot, portvdb,
			         dentry->d_name, de->d_name, depend_file);
				 dentry->d_name, de->d_name, depend_file);
			/* >=portage-2.1_pre3 wont ensure these files always exist. */
			/* >=portage-2.1_pre3 wont ensure these files always exist. */
			/* So we must verify they exist before attempting to eat_file on them. */
			/* So we must verify they exist before attempting to eat_file on them. */
 Lines 413-419   int qdepends_main_vdb(const char *depend Link Here 
			}
			}
			snprintf(buf, sizeof(buf), "%s%s/%s/%s/USE", portroot, portvdb,
			snprintf(buf, sizeof(buf), "%s%s/%s/%s/USE", portroot, portvdb,
			         dentry->d_name, de->d_name);
				 dentry->d_name, de->d_name);
			if (!eat_file(buf, use, sizeof(use))) {
			if (!eat_file(buf, use, sizeof(use))) {
				warn("Could not eat_file(%s), you'll prob have incorrect output", buf);
				warn("Could not eat_file(%s), you'll prob have incorrect output", buf);
			} else {
			} else {
 Lines 471-477   int qdepends_vdb_deep(const char *depend Link Here 
				continue;
				continue;
			snprintf(buf, sizeof(buf), "%s%s/%s/%s/%s", portroot, portvdb,
			snprintf(buf, sizeof(buf), "%s%s/%s/%s/%s", portroot, portvdb,
			         dentry->d_name, de->d_name, depend_file);
				 dentry->d_name, de->d_name, depend_file);
			if (!eat_file(buf, depend, sizeof(depend))) {
			if (!eat_file(buf, depend, sizeof(depend))) {
				warn("i'm such a fatty, could not eat_file(%s)", buf);
				warn("i'm such a fatty, could not eat_file(%s)", buf);
				continue;
				continue;
 Lines 482-488   int qdepends_vdb_deep(const char *depend Link Here 
			if (dep_tree == NULL) continue;
			if (dep_tree == NULL) continue;
			snprintf(buf, sizeof(buf), "%s%s/%s/%s/USE", portroot, portvdb,
			snprintf(buf, sizeof(buf), "%s%s/%s/%s/USE", portroot, portvdb,
			         dentry->d_name, de->d_name);
				 dentry->d_name, de->d_name);
			assert(eat_file(buf, use, sizeof(use)) == 1);
			assert(eat_file(buf, use, sizeof(use)) == 1);
			for (ptr = use; *ptr; ++ptr)
			for (ptr = use; *ptr; ++ptr)
				if (*ptr == '\n' || *ptr == '\t')
				if (*ptr == '\n' || *ptr == '\t')
 Lines 553-565   int qdepends_main(int argc, char **argv) Link Here 
		for (i = 0; depend_files[i]; ++i) {
		for (i = 0; depend_files[i]; ++i) {
			printf(" %s*%s %s\n", GREEN, NORM, depend_files[i]);
			printf(" %s*%s %s\n", GREEN, NORM, depend_files[i]);
			ret += (query ? qdepends_vdb_deep(depend_files[i], query)
			ret += (query ? qdepends_vdb_deep(depend_files[i], query)
			              : qdepends_main_vdb(depend_files[i], argc, argv));
				      : qdepends_main_vdb(depend_files[i], argc, argv));
		}
		}
		return ret;
		return ret;
	}
	}
	return (query ? qdepends_vdb_deep(depend_file, query)
	return (query ? qdepends_vdb_deep(depend_file, query)
	              : qdepends_main_vdb(depend_file, argc, argv));
		      : qdepends_main_vdb(depend_file, argc, argv));
}
}
#else
#else
(-) portage-utils-0.1.21/qfile.c (-1 / +1 lines)
 Lines 76-82   void qfile(char *path, int argc, char* r Link Here 
			// used to cut the number of strcmp() calls
			// used to cut the number of strcmp() calls
			bn_firstchar = entry_basename[0];
			bn_firstchar = entry_basename[0];
			
			for(i = 0; i < argc; i++) {
			for(i = 0; i < argc; i++) {
				if (base_names[i] == NULL)
				if (base_names[i] == NULL)
					continue;
					continue;
(-) portage-utils-0.1.21/qgrep.c (-4 / +49 lines)
 Lines 10-20    Link Here 
#ifdef APPLET_qgrep
#ifdef APPLET_qgrep
#define QGREP_FLAGS "IiHce" COMMON_FLAGS
#define QGREP_FLAGS "IiHo:ce" COMMON_FLAGS
static struct option const qgrep_long_opts[] = {
static struct option const qgrep_long_opts[] = {
	{"invert-match",  no_argument, NULL, 'I'},
	{"invert-match",  no_argument, NULL, 'I'},
	{"ignore-case",   no_argument, NULL, 'i'},
	{"ignore-case",   no_argument, NULL, 'i'},
	{"with-filename", no_argument, NULL, 'H'},
	{"with-filename", no_argument, NULL, 'H'},
	{"overlay",        a_argument, NULL, 'o'},
	{"count",         no_argument, NULL, 'c'},
	{"count",         no_argument, NULL, 'c'},
	{"regexp",        no_argument, NULL, 'e'},
	{"regexp",        no_argument, NULL, 'e'},
	COMMON_LONG_OPTS
	COMMON_LONG_OPTS
 Lines 23-28   static const char *qgrep_opts_help[] = { Link Here 
	"Select non-matching lines",
	"Select non-matching lines",
	"Ignore case distinctions",
	"Ignore case distinctions",
	"Print the filename for each match",
	"Print the filename for each match",
	"Only consider the <arg> overlay",
	"Only print a count of matching lines per FILE",
	"Only print a count of matching lines per FILE",
	"Use PATTERN as a regular expression",
	"Use PATTERN as a regular expression",
	COMMON_OPTS_HELP
	COMMON_OPTS_HELP
 Lines 34-40   int qgrep_main(int argc, char **argv) Link Here 
{
{
	int i;
	int i;
	int count = 0;
	int count = 0;
	char *p;
	short myerror = 0, repo = 0;
	char overlay_name[64], repo_search[64];
	char *p, *str;
	char do_count, do_regex;
	char do_count, do_regex;
	char show_filename;
	char show_filename;
	FILE *fp;
	FILE *fp;
 Lines 42-51   int qgrep_main(int argc, char **argv) Link Here 
	char buf0[BUFSIZ];
	char buf0[BUFSIZ];
	int reflags = REG_NOSUB;
	int reflags = REG_NOSUB;
	char invert_match = 0;
	char invert_match = 0;
	overlay_t *cur_overlay, *overlay_tmp;
	typedef char *(*FUNC) (char *, char *);
	typedef char *(*FUNC) (char *, char *);
	FUNC strfunc = (FUNC) strstr;
	FUNC strfunc = (FUNC) strstr;
	cur_overlay = overlay_gentoo;
	overlay_name[0] = 0;
	repo_search[0] = 0;
	DBG("argc=%d argv[0]=%s argv[1]=%s",
	DBG("argc=%d argv[0]=%s argv[1]=%s",
	    argc, argv[0], argc > 1 ? argv[1] : "NULL?");
	    argc, argv[0], argc > 1 ? argv[1] : "NULL?");
 Lines 58-66   int qgrep_main(int argc, char **argv) Link Here 
			strfunc = (FUNC) strcasestr;
			strfunc = (FUNC) strcasestr;
			reflags |= REG_ICASE;
			reflags |= REG_ICASE;
			break;
			break;
		case 'H': show_filename = 1; break;
		case 'o': 
			repo = 1;
			strncpy(repo_search, optarg, sizeof(repo_search));
			break;
		case 'c': do_count = 1; break;
		case 'c': do_count = 1; break;
		case 'e': do_regex = 1; break;
		case 'e': do_regex = 1; break;
		case 'H': show_filename = 1; break;
		COMMON_GETOPTS_CASES(qgrep)
		COMMON_GETOPTS_CASES(qgrep)
		}
		}
	}
	}
 Lines 73-78   int qgrep_main(int argc, char **argv) Link Here 
		return 1;
		return 1;
	while ((fgets(ebuild, sizeof(ebuild), fp)) != NULL) {
	while ((fgets(ebuild, sizeof(ebuild), fp)) != NULL) {
		FILE *newfp;
		FILE *newfp;
		if ( ( p = strchr(ebuild, ':')))
		{
			*p = 0;
			str = p+2;			/* separator is '::' */
			p = ebuild;
			if ( repo && strncmp(repo_search, p, sizeof( repo_search)))
				continue;
			if ( strcmp(overlay_name, p))
			{
				for ( overlay_tmp=overlay_gentoo ; overlay_tmp->next ; overlay_tmp=overlay_tmp->next )
				{
					if ( ! strncmp(overlay_tmp->name, p, sizeof(overlay_tmp->name)))
						break;
				}
				if ( ! strncmp(overlay_tmp->name, p, sizeof(overlay_tmp->name)))
				{
					cur_overlay = overlay_tmp;
					if (chdir(cur_overlay->path) != 0) {
						warnp("chdir to PORTDIR '%s' failed", cur_overlay->path);
						myerror=1;
					}
				} else 
					myerror=1;
				if ( myerror) {
					myerror=0;
					continue;
				}
				strncpy(overlay_name, cur_overlay->name, sizeof(overlay_name));
			}
			strcpy(ebuild, str) ;
		}
		if ((p = strchr(ebuild, '\n')) != NULL)
		if ((p = strchr(ebuild, '\n')) != NULL)
			*p = 0;
			*p = 0;
		if ((newfp = fopen(ebuild, "r")) != NULL) {
		if ((newfp = fopen(ebuild, "r")) != NULL) {
 Lines 102-108   int qgrep_main(int argc, char **argv) Link Here 
				count++;
				count++;
				if (do_count) continue;
				if (do_count) continue;
				if (verbose || show_filename) {
				if (verbose || show_filename) {
					printf("%s:", ebuild); 
					printf("%s::%s:", cur_overlay->name, ebuild); 
					if (verbose > 1) printf("%d:", lineno);
					if (verbose > 1) printf("%d:", lineno);
					printf(" ");
					printf(" ");
				}
				}
(-) portage-utils-0.1.21/qlist.c (-1 / +1 lines)
 Lines 251-257   int qlist_main(int argc, char **argv) Link Here 
			}
			}
			snprintf(buf, sizeof(buf), "%s%s/%s/%s/CONTENTS", portroot, portvdb,
			snprintf(buf, sizeof(buf), "%s%s/%s/%s/CONTENTS", portroot, portvdb,
			         cat[j]->d_name, de[x]->d_name);
				 cat[j]->d_name, de[x]->d_name);
			if (verbose > 1)
			if (verbose > 1)
				printf("%s%s/%s%s%s\n%sCONTENTS%s:\n", BOLD, cat[j]->d_name, BLUE, de[x]->d_name, NORM, DKBLUE, NORM);
				printf("%s%s/%s%s%s\n%sCONTENTS%s:\n", BOLD, cat[j]->d_name, BLUE, de[x]->d_name, NORM, DKBLUE, NORM);
(-) portage-utils-0.1.21/qmerge.c (-8 / +8 lines)
 Lines 17-24    Link Here 
#endif
#endif
/*
/*
  --nofiles                        don't verify files in package
  --nofiles			don't verify files in package
  --noscript                       don't execute pkg_{pre,post}{inst,rm} (if any)
  --noscript			don't execute pkg_{pre,post}{inst,rm} (if any)
*/
*/
// #define BUSYBOX "/bin/busybox"
// #define BUSYBOX "/bin/busybox"
 Lines 50-56   static const char *qmerge_opts_help[] = Link Here 
	"Don't prompt before overwriting",
	"Don't prompt before overwriting",
	"Don't merge dependencies",
	"Don't merge dependencies",
	"Don't verify MD5 digest of files",
	"Don't verify MD5 digest of files",
        COMMON_OPTS_HELP
	COMMON_OPTS_HELP
};
};
static const char qmerge_rcsid[] = "$Id: qmerge.c,v 1.53 2006/08/21 00:14:57 solar Exp $";
static const char qmerge_rcsid[] = "$Id: qmerge.c,v 1.53 2006/08/21 00:14:57 solar Exp $";
 Lines 700-706   void pkg_merge(int level, depend_atom *a Link Here 
		line[0] = 0;
		line[0] = 0;
		/* portage has code that handes fifo's but it looks unused */
		/* portage has code that handes fifo's but it looks unused */
    
		if ((S_ISCHR(st.st_mode)) || \
		if ((S_ISCHR(st.st_mode)) || \
			(S_ISBLK(st.st_mode))); // block or character device
			(S_ISBLK(st.st_mode))); // block or character device
		if (S_ISFIFO(st.st_mode));	// FIFO (named pipe)
		if (S_ISFIFO(st.st_mode));	// FIFO (named pipe)
 Lines 772-778   void pkg_merge(int level, depend_atom *a Link Here 
			assert(strlen(&buf[1]));
			assert(strlen(&buf[1]));
			readlink(buf, path, sizeof(path));
			readlink(buf, path, sizeof(path));
			assert(strlen(path));;
			assert(strlen(path));;
			
			snprintf(line, sizeof(line), "sym %s -> %s%s%lu", &buf[1], path, " ", st.st_mtime);
			snprintf(line, sizeof(line), "sym %s -> %s%s%lu", &buf[1], path, " ", st.st_mtime);
			// snprintf(line, sizeof(line), "sym %s -> %s", &buf[1], path);
			// snprintf(line, sizeof(line), "sym %s -> %s", &buf[1], path);
			// we better have one byte here to play with
			// we better have one byte here to play with
 Lines 1125-1136   void print_Pkg(int full, struct pkg_t *p Link Here 
			int ret;
			int ret;
			char *icolor = (char *) RED;
			char *icolor = (char *) RED;
			ret = atom_compare_str(buf, p);
			ret = atom_compare_str(buf, p);
			switch(ret) {                                
			switch(ret) {
				case EQUAL: icolor = (char *) RED; break;
				case EQUAL: icolor = (char *) RED; break;
				case NEWER: icolor = (char *) YELLOW; break;                          
				case NEWER: icolor = (char *) YELLOW; break;
				case OLDER: icolor = (char *) BLUE; break;
				case OLDER: icolor = (char *) BLUE; break;
				default: icolor = (char *) NORM; break;
				default: icolor = (char *) NORM; break;
                        }
			}
			printf(" %sInstalled%s:%s %s%s%s\n", DKGREEN, YELLOW, NORM, icolor, p, NORM);
			printf(" %sInstalled%s:%s %s%s%s\n", DKGREEN, YELLOW, NORM, icolor, p, NORM);
		}
		}
	}
	}
(-) portage-utils-0.1.21/qpy.c (-2 / +2 lines)
 Lines 75-84   int import_portage_settings(void) Link Here 
		return 1;
		return 1;
	}
	}
	if (!(portage.settings = PyObject_GetAttrString(portage.interp, (char *) "settings"))) {
	if (!(portage.settings = PyObject_GetAttrString(portage.interp, (char *) "settings"))) {
		Py_DECREF(portage.interp);      
		Py_DECREF(portage.interp);
		fprintf(stderr, "getting settings failed");
		fprintf(stderr, "getting settings failed");
		return 1;
		return 1;
	}   
	}
	return 0;
	return 0;
}
}
(-) portage-utils-0.1.21/qsearch.c (-11 / +78 lines)
 Lines 9-18    Link Here 
#ifdef APPLET_qsearch
#ifdef APPLET_qsearch
#define QSEARCH_FLAGS "acsSNH" COMMON_FLAGS
#define QSEARCH_FLAGS "aco:psSNH" COMMON_FLAGS
static struct option const qsearch_long_opts[] = {
static struct option const qsearch_long_opts[] = {
	{"all",       no_argument, NULL, 'a'},
	{"all",       no_argument, NULL, 'a'},
	{"cache",     no_argument, NULL, 'c'},
	{"cache",     no_argument, NULL, 'c'},
	{"overlay",    a_argument, NULL, 'o'},
	{"show-path", no_argument, NULL, 'p'},
	{"search",    no_argument, NULL, 's'},
	{"search",    no_argument, NULL, 's'},
	{"desc",       a_argument, NULL, 'S'},
	{"desc",       a_argument, NULL, 'S'},
	{"name-only", no_argument, NULL, 'N'},
	{"name-only", no_argument, NULL, 'N'},
 Lines 22-27   static struct option const qsearch_long_ Link Here 
static const char *qsearch_opts_help[] = {
static const char *qsearch_opts_help[] = {
	"List the descriptions of every package in the cache",
	"List the descriptions of every package in the cache",
	"Use the portage cache",
	"Use the portage cache",
	"Search only in the <arg> overlay",
	"Show the path to the ebuild",
	"Regex search package basenames",
	"Regex search package basenames",
	"Regex search package descriptions",
	"Regex search package descriptions",
	"Only show package name",
	"Only show package name",
 Lines 40-52   int qsearch_main(int argc, char **argv) Link Here 
	char last[126] = "";
	char last[126] = "";
	char dp[126] = "";
	char dp[126] = "";
	char bp[126] = "";
	char bp[126] = "";
	char *p, *q, *str;
	short repo = 0;
	char repo_search[64];
	char *p, *q, *str, overlay_name[64];
	char *search_me = NULL;
	char *search_me = NULL;
	char show_homepage = 0, show_name_only = 0;
	char show_homepage = 0, show_name_only = 0, show_path_to_ebuild = 0;
	char search_desc = 0, search_all = 0, search_name = 1, search_cache = CACHE_EBUILD;
	char search_desc = 0, search_all = 0, search_name = 1, search_cache = CACHE_EBUILD;
	const char *search_vars[] = { "DESCRIPTION=", "HOMEPAGE=" };
	const char *search_vars[] = { "DESCRIPTION=", "HOMEPAGE=" };
	size_t search_len;
	size_t search_len;
	int i, idx=0;
	overlay_t *cur_overlay, *overlay_tmp;
	int i, idx=0, myerror=0;
	cur_overlay = overlay_gentoo;
	overlay_name[0] = 0 ;
	repo_search[0] = 0;
	DBG("argc=%d argv[0]=%s argv[1]=%s",
	DBG("argc=%d argv[0]=%s argv[1]=%s",
	    argc, argv[0], argc > 1 ? argv[1] : "NULL?");
	    argc, argv[0], argc > 1 ? argv[1] : "NULL?");
 Lines 56-61   int qsearch_main(int argc, char **argv) Link Here 
		COMMON_GETOPTS_CASES(qsearch)
		COMMON_GETOPTS_CASES(qsearch)
		case 'a': search_all = 1; break;
		case 'a': search_all = 1; break;
		case 'c': search_cache = CACHE_METADATA; break;
		case 'c': search_cache = CACHE_METADATA; break;
		case 'o': repo = 1; strncpy(repo_search, optarg, sizeof(repo_search)); break;
		case 'p': show_path_to_ebuild = 1; break;
		case 's': search_desc = 0; search_name = 1; break;
		case 's': search_desc = 0; search_name = 1; break;
		case 'S': search_desc = 1; search_name = 0; break;
		case 'S': search_desc = 1; search_name = 0; break;
		case 'N': show_name_only = 1; break;
		case 'N': show_name_only = 1; break;
 Lines 93-103   int qsearch_main(int argc, char **argv) Link Here 
			if ((pcache = cache_read_file(ebuild)) != NULL) {
			if ((pcache = cache_read_file(ebuild)) != NULL) {
				if ((strcmp(pcache->atom->PN, last)) != 0) {
				if ((strcmp(pcache->atom->PN, last)) != 0) {
					strncpy(last, pcache->atom->PN, sizeof(last));
					strncpy(last, pcache->atom->PN, sizeof(last));
					if ((rematch(search_me, (search_desc ? pcache->DESCRIPTION : ebuild), REG_EXTENDED | REG_ICASE)) == 0)
					if ((rematch(search_me, (search_desc ? pcache->DESCRIPTION : ebuild), REG_EXTENDED | REG_ICASE)) == 0) {
						printf("%s%s/%s%s%s %s\n", BOLD, pcache->atom->CATEGORY, BLUE,
						if ( show_path_to_ebuild) {
						       pcache->atom->PN, NORM,
							printf("%s%s/%s%s%s::%s\t %s%s/%s/\n",	
						       (show_name_only ? "" :
							BOLD, pcache->atom->CATEGORY,
						        (show_homepage ? pcache->HOMEPAGE : pcache->DESCRIPTION)));
							BLUE, pcache->atom->PN,
							YELLOW,cur_overlay->name, NORM,
							cur_overlay->path, dirname(ebuild));
						} else {
							printf("%s%s/%s%s%s::%s %s%s\n",
							BOLD, pcache->atom->CATEGORY,
							BLUE, pcache->atom->PN,
							YELLOW,cur_overlay->name, NORM,
							(show_name_only ? "" : 
							(show_homepage ? pcache->HOMEPAGE : pcache->DESCRIPTION)));
						}
					}
				}
				}
				cache_free(pcache);
				cache_free(pcache);
			} else {
			} else {
 Lines 110-115   int qsearch_main(int argc, char **argv) Link Here 
		case CACHE_EBUILD: {
		case CACHE_EBUILD: {
			FILE *ebuildfp;
			FILE *ebuildfp;
			if ( ( p = strchr(ebuild, ':')))
			{
				*p = 0;
				str = p+2;			/* separator is '::' */
				p = ebuild;
				if ( repo && strncmp( repo_search, p, sizeof(repo_search)))
					continue;
				if ( strcmp(overlay_name, p))
				{
					for ( overlay_tmp=overlay_gentoo ; overlay_tmp->next ; overlay_tmp=overlay_tmp->next )
					{
						if ( ! strncmp(overlay_tmp->name, p, sizeof(overlay_tmp->name)))
							break;
					}
					if ( ! strncmp(overlay_tmp->name, p, sizeof(overlay_tmp->name)))
					{
						cur_overlay = overlay_tmp;
						if (chdir(cur_overlay->path) != 0) {
							warnp("chdir to PORTDIR '%s' failed", cur_overlay->path);
							myerror=1;
						}
					} else 
						myerror=1;
					if ( myerror) {
						if (!reinitialize)
							warnfp("(cache update pending) %s", ebuild);
						reinitialize = 1;
						break;
					}
					strncpy(overlay_name, cur_overlay->name, sizeof(overlay_name));
				}
				strcpy(ebuild, str) ;		/* separator is '::' */
			}
			str = xstrdup(ebuild);
			str = xstrdup(ebuild);
			p = (char *) dirname(str);
			p = (char *) dirname(str);
 Lines 134-143   int qsearch_main(int argc, char **argv) Link Here 
							// doing operations with them.
							// doing operations with them.
							strncpy(dp, p, sizeof(dp));
							strncpy(dp, p, sizeof(dp));
							strncpy(bp, p, sizeof(bp));
							strncpy(bp, p, sizeof(bp));
							printf("%s%s/%s%s%s %s\n", 
							if ( show_path_to_ebuild) {
								BOLD, dirname(dp), BLUE, basename(bp), NORM,
								printf("%s%s/%s%s%s::%s\t %s%s/%s/\n",
								BOLD, dirname(dp), BLUE, basename(bp),
								YELLOW,cur_overlay->name, NORM,
								cur_overlay->path, dirname(ebuild));
							} else {
								printf("%s%s/%s%s%s::%s %s%s\n",
								BOLD, dirname(dp), BLUE, basename(bp),
								YELLOW,cur_overlay->name, NORM,
								(show_name_only ? "" : q));
								(show_name_only ? "" : q));
							}
							break;
							break;
						}
						}
					}
					}
					fclose(ebuildfp);
					fclose(ebuildfp);
(-) portage-utils-0.1.21/qsize.c (-2 / +2 lines)
 Lines 93-99   int qsize_main(int argc, char **argv) Link Here 
			if (!search_all) {
			if (!search_all) {
				for (i = optind; i < argc; ++i) {
				for (i = optind; i < argc; ++i) {
					snprintf(buf, sizeof(buf), "%s/%s", dentry->d_name, 
					snprintf(buf, sizeof(buf), "%s/%s", dentry->d_name, 
					         de->d_name);
						 de->d_name);
					if (rematch(argv[i], buf, REG_EXTENDED) == 0)
					if (rematch(argv[i], buf, REG_EXTENDED) == 0)
						break;
						break;
					if (rematch(argv[i], de->d_name, REG_EXTENDED) == 0)
					if (rematch(argv[i], de->d_name, REG_EXTENDED) == 0)
 Lines 104-110   int qsize_main(int argc, char **argv) Link Here 
			}
			}
			snprintf(buf, sizeof(buf), "%s%s/%s/%s/CONTENTS", portroot, portvdb,
			snprintf(buf, sizeof(buf), "%s%s/%s/%s/CONTENTS", portroot, portvdb,
			         dentry->d_name, de->d_name);
				 dentry->d_name, de->d_name);
			if ((fp = fopen(buf, "r")) == NULL)
			if ((fp = fopen(buf, "r")) == NULL)
				continue;
				continue;
(-) portage-utils-0.1.21/quse.c (-86 / +176 lines)
 Lines 14-23    Link Here 
 quse -Ke --  nls
 quse -Ke --  nls
*/
*/
#define QUSE_FLAGS "eavKLDF:N" COMMON_FLAGS
#define QUSE_FLAGS "eao:vKLDF:N" COMMON_FLAGS
static struct option const quse_long_opts[] = {
static struct option const quse_long_opts[] = {
	{"exact",     no_argument, NULL, 'e'},
	{"exact",     no_argument, NULL, 'e'},
	{"all",       no_argument, NULL, 'a'},
	{"all",       no_argument, NULL, 'a'},
	{"overlay",    a_argument, NULL, 'o'},
	{"keywords",  no_argument, NULL, 'K'},
	{"keywords",  no_argument, NULL, 'K'},
	{"license",   no_argument, NULL, 'L'},
	{"license",   no_argument, NULL, 'L'},
	{"describe",  no_argument, NULL, 'D'},
	{"describe",  no_argument, NULL, 'D'},
 Lines 28-33   static struct option const quse_long_opt Link Here 
static const char *quse_opts_help[] = {
static const char *quse_opts_help[] = {
	"Show exact non regexp matching using strcmp",
	"Show exact non regexp matching using strcmp",
	"Show annoying things in IUSE",
	"Show annoying things in IUSE",
	"Only consider the <arg> overlay",
	"Use the KEYWORDS vs IUSE",
	"Use the KEYWORDS vs IUSE",
	"Use the LICENSE vs IUSE",
	"Use the LICENSE vs IUSE",
	"Describe the USE flag",
	"Describe the USE flag",
 Lines 38-44   static const char *quse_opts_help[] = { Link Here 
static const char quse_rcsid[] = "$Id: quse.c,v 1.52 2006/06/10 14:01:21 vapier Exp $";
static const char quse_rcsid[] = "$Id: quse.c,v 1.52 2006/06/10 14:01:21 vapier Exp $";
#define quse_usage(ret) usage(ret, QUSE_FLAGS, quse_long_opts, quse_opts_help, lookup_applet_idx("quse"))
#define quse_usage(ret) usage(ret, QUSE_FLAGS, quse_long_opts, quse_opts_help, lookup_applet_idx("quse"))
int quse_describe_flag(int ind, int argc, char **argv);
int quse_describe_flag(int ind, short repo, char repo_search[], int argc, char **argv);
char quse_name_only = 0;
char quse_name_only = 0;
 Lines 80-86   static void print_highlighted_use_flags( Link Here 
	}
	}
}
}
int quse_describe_flag(int ind, int argc, char **argv)
int quse_describe_flag(int ind, short repo, char repo_search[], int argc, char **argv)
{
{
#define NUM_SEARCH_FILES ARR_SIZE(search_files)
#define NUM_SEARCH_FILES ARR_SIZE(search_files)
	char buf[BUFSIZE], *p;
	char buf[BUFSIZE], *p;
 Lines 90-210   int quse_describe_flag(int ind, int argc Link Here 
	FILE *fp[NUM_SEARCH_FILES];
	FILE *fp[NUM_SEARCH_FILES];
	DIR *d;
	DIR *d;
	struct dirent *de;
	struct dirent *de;
	overlay_t *cur_overlay;
	for (i = 0; i < NUM_SEARCH_FILES; ++i) {
	cur_overlay=overlay_gentoo;
		snprintf(buf, sizeof(buf), "%s/profiles/%s", portdir, search_files[i]);
		if ((fp[i] = fopen(buf, "r")) == NULL)
			warnp("skipping %s", search_files[i]);
	}
	for (i = ind; i < argc; i++) {
	do {
		s = strlen(argv[i]);
		if ( repo && strncmp(repo_search, cur_overlay->name, sizeof( repo_search)))
			continue;
		for (i = 0; i < NUM_SEARCH_FILES; ++i) {
			snprintf(buf, sizeof(buf), "%s/profiles/%s", cur_overlay->path, search_files[i]);
			if ((fp[i] = fopen(buf, "r")) == NULL)
				if ( verbose )
					warnp("skipping %s for the %s overlay", search_files[i], cur_overlay->name);
		}
		for (f = 0; f < NUM_SEARCH_FILES; ++f) {
		for (i = ind; i < argc; i++) {
			if (fp[f] == NULL)
			s = strlen(argv[i]);
				continue;
			while (fgets(buf, sizeof(buf), fp[f]) != NULL) {
			for (f = 0; f < NUM_SEARCH_FILES; ++f) {
				if (buf[0] == '#' || buf[0] == '\n')
				if (fp[f] == NULL)
					continue;
					continue;
				if ((p = strrchr(buf, '\n')) != NULL)
				while (fgets(buf, sizeof(buf), fp[f]) != NULL) {
					*p = '\0';
					if (buf[0] == '#' || buf[0] == '\n')
						continue;
				switch (f) {
					if ((p = strrchr(buf, '\n')) != NULL)
					case 0: /* Global use.desc */
						*p = '\0';
						if (!strncmp(buf, argv[i], s))
							if (buf[s] == ' ' && buf[s+1] == '-') {
								printf(" %sglobal%s:%s%s%s: %s\n", BOLD, NORM, BLUE, argv[i], NORM, buf+s+3);
								goto skip_file;
							}
						break;
					case 1: /* Local use.local.desc */
					switch (f) {
						if ((p = strchr(buf, ':')) == NULL)
						case 0: /* Global use.desc */
							if (!strncmp(buf, argv[i], s))
								if (buf[s] == ' ' && buf[s+1] == '-') {
									if ( cur_overlay == overlay_gentoo )
										printf(" %sglobal%s:%s%s%s: %s\n", BOLD, NORM, BLUE, argv[i], NORM, buf+s+3);
									else 
										printf(" (%s) %sglobal%s:%s%s%s: %s\n", cur_overlay->name, BOLD, NORM, BLUE, argv[i], NORM, buf+s+3);
									goto skip_file;
								}
							break;
							break;
						++p;
						if (!strncmp(p, argv[i], s)) {
							if (p[s] == ' ' && p[s+1] == '-') {
								*p = '\0';
								printf(" %slocal%s:%s%s%s:%s%s%s %s\n", BOLD, NORM, BLUE, argv[i], NORM, BOLD, buf, NORM, p+s+3);
							}
						}
						break;
					case 2: /* Architectures arch.list */
						case 1: /* Local use.local.desc */
						if (!strcmp(buf, argv[i])) {
							if ((p = strchr(buf, ':')) == NULL)
							printf(" %sarch%s:%s%s%s: %s architecture\n", BOLD, NORM, BLUE, argv[i], NORM, argv[i]);
								break;
							goto skip_file;
							++p;
						}
							if (!strncmp(p, argv[i], s)) {
						break;
								if (p[s] == ' ' && p[s+1] == '-') {
									*p = '\0';
									if ( cur_overlay == overlay_gentoo )
										printf(" %slocal%s:%s%s%s:%s%s%s %s\n", BOLD, NORM, BLUE, argv[i], NORM, BOLD, buf, NORM, p+s+3);
									else 
										printf(" (%s) %slocal%s:%s%s%s:%s%s%s %s\n", cur_overlay->name, BOLD, NORM, BLUE, argv[i], NORM, BOLD, buf, NORM, p+s+3);
								}
							}
							break;
					case 3: /* Languages lang.desc */
						case 2: /* Architectures arch.list */
						if (!strncmp(buf, argv[i], s))
							if (!strcmp(buf, argv[i])) {
							if (buf[s] == ' ' && buf[s+1] == '-') {
								if ( cur_overlay == overlay_gentoo )
								printf(" %slang%s:%s%s%s: %s lingua\n", BOLD, NORM, BLUE, argv[i], NORM, buf+s+3);
									printf(" %sarch%s:%s%s%s: %s architecture\n", BOLD, NORM, BLUE, argv[i], NORM, argv[i]);
								else 
									printf(" (%s) %sarch%s:%s%s%s: %s architecture\n", cur_overlay->name, BOLD, NORM, BLUE, argv[i], NORM, argv[i]);
								goto skip_file;
								goto skip_file;
							}
							}
						break;
							break;
						case 3: /* Languages lang.desc */
							if (!strncmp(buf, argv[i], s))
								if (buf[s] == ' ' && buf[s+1] == '-') {
									if ( cur_overlay == overlay_gentoo )
										printf(" %slang%s:%s%s%s: %s lingua\n", BOLD, NORM, BLUE, argv[i], NORM, buf+s+3);
									else 
										printf(" (%s) %slang%s:%s%s%s: %s lingua\n", cur_overlay->name, BOLD, NORM, BLUE, argv[i], NORM, buf+s+3);
									goto skip_file;
								}
							break;
					}
				}
				}
			}
skip_file:
skip_file:
			rewind(fp[f]);
				rewind(fp[f]);
			}
			if ( i == (argc - 1) )
				for (f=0; f<NUM_SEARCH_FILES; ++f) 
					if ( fp[f] ) {
						fclose(fp[f]);
						fp[f] = NULL;
					}
		}
		}
	}
	for (f=0; f<NUM_SEARCH_FILES; ++f)
	} while ( (cur_overlay=cur_overlay->next));
		fclose(fp[f]);
	/* now scan the desc dir */
	/* now scan the desc dir */
	snprintf(buf, sizeof(buf), "%s/profiles/desc/", portdir);
	cur_overlay=overlay_gentoo;
	d = opendir(buf);
	do {
	while ((de = readdir(d)) != NULL) {
		if ( repo && strncmp(repo_search, cur_overlay->name, sizeof( repo_search)))
		if (strcmp(de->d_name+strlen(de->d_name)-5, ".desc"))
			continue;
			continue;
		snprintf(buf, sizeof(buf), "%s/profiles/desc/", cur_overlay->path);
		snprintf(buf, sizeof(buf), "%s/profiles/desc/%s", portdir, de->d_name);
		if ( ! (d = opendir(buf))) {
		if ((fp[0]=fopen(buf, "r")) == NULL) {
			if ( verbose ) 
			warn("Could not open '%s' for reading; skipping", de->d_name);
				warn("Could not open %s -> skipping", buf); 
			continue;
			continue;
		}
		}
		while ((de = readdir(d)) != NULL) {
			if (strcmp(de->d_name+strlen(de->d_name)-5, ".desc"))
				continue;
		while (fgets(buf, sizeof(buf), fp[0]) != NULL) {
			snprintf(buf, sizeof(buf), "%s/profiles/desc/%s", cur_overlay->path, de->d_name);
			if (buf[0] == '#' || buf[0] == '\n')
			if ((fp[0]=fopen(buf, "r")) == NULL) {
				warn("Could not open '%s' for reading; skipping", de->d_name);
				continue;
				continue;
			}
			while (fgets(buf, sizeof(buf), fp[0]) != NULL) {
				if (buf[0] == '#' || buf[0] == '\n')
					continue;
			if ((p = strrchr(buf, '\n')) != NULL)
				if ((p = strrchr(buf, '\n')) != NULL)
				*p = '\0';
					*p = '\0';
			if ((p = strchr(buf, '-')) == NULL) {
				if ((p = strchr(buf, '-')) == NULL) {
invalid_line:
invalid_line:
				warn("Invalid line in '%s': %s", de->d_name, buf);
					warn("Invalid line in '%s': %s", de->d_name, buf);
				continue;
					continue;
			}
				}
			while (p[-1] != ' ' && p[1] != ' ') {
				while (p[-1] != ' ' && p[1] != ' ') {
				/* maybe the flag has a '-' in it ... */
					/* maybe the flag has a '-' in it ... */
				if ((p = strchr(p+1, '-')) == NULL)
					if ((p = strchr(p+1, '-')) == NULL)
					goto invalid_line;
						goto invalid_line;
			}
				}
			p[-1] = '\0';
				p[-1] = '\0';
			p += 2;
				p += 2;
			for (i = ind; i < argc; i++)
				for (i = ind; i < argc; i++)
				if (!strcmp(argv[i], buf))
					if (!strcmp(argv[i], buf)) {
					printf(" %s%s%s:%s%s%s: %s\n", BOLD, de->d_name, NORM, BLUE, argv[i], NORM, p);
						if ( cur_overlay == overlay_gentoo )
		}
							printf(" %s%s%s:%s%s%s: %s\n", BOLD, de->d_name, NORM, BLUE, argv[i], NORM, p);
		close(f);
						else
	}
							printf(" (%s) %s%s%s:%s%s%s: %s\n", cur_overlay->name, BOLD, de->d_name, NORM, BLUE, argv[i], NORM, p);
	closedir(d);
					}
			}
			fclose(fp[0]);
		}
		closedir(d);
	} while ( (cur_overlay=cur_overlay->next));
	return 0;
	return 0;
}
}
int quse_main(int argc, char **argv)
int quse_main(int argc, char **argv)
{
{
	FILE *fp;
	FILE *fp;
	char *p;
	char *p, *str;
	short myerror = 0, repo = 0;
	char repo_search[64];
	char overlay_name[64];
	char buf0[_Q_PATH_MAX];
	char buf0[_Q_PATH_MAX];
	char buf1[_Q_PATH_MAX];
	char buf1[_Q_PATH_MAX];
 Lines 217-222   int quse_main(int argc, char **argv) Link Here 
	short quse_all = 0;
	short quse_all = 0;
	int regexp_matching = 1, i, idx = 0;
	int regexp_matching = 1, i, idx = 0;
	size_t search_len;
	size_t search_len;
	overlay_t *cur_overlay, *overlay_tmp;
	cur_overlay = overlay_gentoo;
	overlay_name[0] = 0;
	repo_search[0] = 0;
	DBG("argc=%d argv[0]=%s argv[1]=%s",
	DBG("argc=%d argv[0]=%s argv[1]=%s",
	    argc, argv[0], argc > 1 ? argv[1] : "NULL?");
	    argc, argv[0], argc > 1 ? argv[1] : "NULL?");
 Lines 225-230   int quse_main(int argc, char **argv) Link Here 
		switch (i) {
		switch (i) {
		case 'e': regexp_matching = 0; break;
		case 'e': regexp_matching = 0; break;
		case 'a': quse_all = 1; break;
		case 'a': quse_all = 1; break;
		case 'o': 
			repo = 1;
			strncpy(repo_search, optarg, sizeof(repo_search));
			break;
		case 'K': idx = 1; break;
		case 'K': idx = 1; break;
		case 'L': idx = 2; break;
		case 'L': idx = 2; break;
		case 'D': idx = -1; break;
		case 'D': idx = -1; break;
 Lines 233-243   int quse_main(int argc, char **argv) Link Here 
		COMMON_GETOPTS_CASES(quse)
		COMMON_GETOPTS_CASES(quse)
		}
		}
	}
	}
	if (argc == optind && !quse_all && idx >= 0)
	if (argc == optind && !quse_all && idx >= 0) {
		if ( idx == 3 )
			free(search_vars+idx);
		quse_usage(EXIT_FAILURE);
		quse_usage(EXIT_FAILURE);
	}
	if (idx == -1)
	if (idx == -1)
		return quse_describe_flag(optind, argc, argv);
		return quse_describe_flag(optind, repo, repo_search, argc, argv);
	if (quse_all) optind = argc;
	if (quse_all) optind = argc;
	initialize_ebuild_flat();	/* sets our pwd to $PORTDIR */
	initialize_ebuild_flat();	/* sets our pwd to $PORTDIR */
 Lines 249-254   int quse_main(int argc, char **argv) Link Here 
		return 1;
		return 1;
	while ((fgets(ebuild, sizeof(ebuild), fp)) != NULL) {
	while ((fgets(ebuild, sizeof(ebuild), fp)) != NULL) {
		FILE *newfp;
		FILE *newfp;
		if ( ( p = strchr(ebuild, ':')))
		{
			*p = 0;
			str = p+2;			/* separator is '::' */
			p = ebuild;
			if ( repo && strncmp( repo_search, p, sizeof(repo_search)))
				continue;
			if ( strcmp(overlay_name, p))
			{
				for ( overlay_tmp=overlay_gentoo ; overlay_tmp->next ; overlay_tmp=overlay_tmp->next )
				{
					if ( ! strncmp(overlay_tmp->name, p, sizeof(overlay_tmp->name)))
						break;
				}
				if ( ! strncmp(overlay_tmp->name, p, sizeof(overlay_tmp->name)))
				{
					cur_overlay = overlay_tmp;
					if (chdir(cur_overlay->path) != 0) {
						warnp("chdir to PORTDIR '%s' failed", cur_overlay->path);
						myerror=1;
					}
				} else 
					myerror=1;
				if ( myerror) {
					if (!reinitialize)
						warnf("(cache update pending) %s : %s", ebuild, strerror(errno));
					reinitialize = 1;
					myerror=0;
					continue;
				}
				strncpy(overlay_name, cur_overlay->name, sizeof(overlay_name));
			}
			strcpy(ebuild, str) ;
		}
		if ((p = strchr(ebuild, '\n')) != NULL)
		if ((p = strchr(ebuild, '\n')) != NULL)
			*p = 0;
			*p = 0;
		if ((newfp = fopen(ebuild, "r")) != NULL) {
		if ((newfp = fopen(ebuild, "r")) != NULL) {
 Lines 374-380   int quse_main(int argc, char **argv) Link Here 
					if (verbose > 3)
					if (verbose > 3)
						printf("%s %s %s ", *user ? user : "MISSING", *revision ? revision : "MISSING", *date ? date : "MISSING");
						printf("%s %s %s ", *user ? user : "MISSING", *revision ? revision : "MISSING", *date ? date : "MISSING");
					printf("%s%s%s ", CYAN, ebuild, NORM);
					printf("%s%s::%s%s ", CYAN, cur_overlay->name, ebuild, NORM);
					print_highlighted_use_flags(&buf0[search_len+1], optind, argc, argv);
					print_highlighted_use_flags(&buf0[search_len+1], optind, argc, argv);
					puts(NORM);
					puts(NORM);
					if (verbose > 1) {
					if (verbose > 1) {
 Lines 382-388   int quse_main(int argc, char **argv) Link Here 
						int ARGC = 0;
						int ARGC = 0;
						makeargv(&buf0[search_len+1], &ARGC, &ARGV);
						makeargv(&buf0[search_len+1], &ARGC, &ARGV);
						if (ARGC > 0) {
						if (ARGC > 0) {
							quse_describe_flag(1, ARGC, ARGV);
							quse_describe_flag(1, repo, repo_search, ARGC, ARGV);
							for (i = 0; i < ARGC; i++)
							for (i = 0; i < ARGC; i++)
								free(ARGV[i]);
								free(ARGV[i]);
							free(ARGV);
							free(ARGV);
(-) portage-utils-0.1.21/qxpak.c (-6 / +6 lines)
 Lines 335-348   void xpak_create(const char *file, int a Link Here 
	rewind(fdata);
	rewind(fdata);
	/* "XPAKPACK" + (index_len) + (data_len) + index + data + "XPAKSTOP" */
	/* "XPAKPACK" + (index_len) + (data_len) + index + data + "XPAKSTOP" */
	fwrite(XPAK_START_MSG, 1, XPAK_START_MSG_LEN, fout); /* "XPAKPACK" */
	fwrite(XPAK_START_MSG, 1, XPAK_START_MSG_LEN, fout);	/* "XPAKPACK" */
	p = tbz2_encode_int(index_len);
	p = tbz2_encode_int(index_len);
	fwrite(p, 1, 4, fout);                               /* (index_len) */
	fwrite(p, 1, 4, fout);					/* (index_len) */
	p = tbz2_encode_int(data_len);
	p = tbz2_encode_int(data_len);
	fwrite(p, 1, 4, fout);                               /* (data_len) */
	fwrite(p, 1, 4, fout);			       		/* (data_len) */
	_tbz2_copy_file(findex, fout);                       /* index */
	_tbz2_copy_file(findex, fout);		       		/* index */
	_tbz2_copy_file(fdata, fout);                        /* data */
	_tbz2_copy_file(fdata, fout);				/* data */
	fwrite(XPAK_END_MSG, 1, XPAK_END_MSG_LEN, fout);     /* "XPAKSTOP" */
	fwrite(XPAK_END_MSG, 1, XPAK_END_MSG_LEN, fout);	/* "XPAKSTOP" */
	strcpy(path, file); strcat(path, ".index"); unlink(path);
	strcpy(path, file); strcat(path, ".index"); unlink(path);
	strcpy(path, file); strcat(path, ".dat");   unlink(path);
	strcpy(path, file); strcat(path, ".dat");   unlink(path);