* dump_setup.cc (dump_setup): Check for the existence of the package list file.

Rework slightly to use static buffer for popen commands.
This commit is contained in:
Christopher Faylor 2003-08-10 01:07:04 +00:00
parent 46258d6fb8
commit e41630b08a
2 changed files with 37 additions and 15 deletions

View File

@ -1,3 +1,9 @@
2003-08-09 Igor Pechtchanski <pechtcha@cs.nyu.edu>
Christopher Faylor <cgf@redhat.com>
* dump_setup.cc (dump_setup): Check for the existence of the package
list file. Rework slightly to use static buffer for popen commands.
2003-08-07 Igor Pechtchanski <pechtcha@cs.nyu.edu> 2003-08-07 Igor Pechtchanski <pechtcha@cs.nyu.edu>
Christopher Faylor <cgf@redhat.com> Christopher Faylor <cgf@redhat.com>

View File

@ -237,16 +237,31 @@ file_exists (int verbose, char *filename, const char *alt, char *package)
static bool static bool
check_package_files (int verbose, char *package) check_package_files (int verbose, char *package)
{ {
bool result = true; char filelist[MAX_PATH + 1] = "/etc/setup/";
char filelist[4096] = " -dc /etc/setup/";
strcat (strcat (filelist, package), ".lst.gz"); strcat (strcat (filelist, package), ".lst.gz");
char *zcat = cygpath("/bin/gzip.exe", NULL); if (!file_exists (false, filelist, NULL, NULL))
char command[4096]; {
if (verbose)
printf ("Missing file list /%s for package %s\n", filelist, package);
return false;
}
static char *zcat;
static char *zcat_end;
if (!zcat)
{
zcat = cygpath ("/bin/gzip.exe", NULL);
while (char *p = strchr (zcat, '/')) while (char *p = strchr (zcat, '/'))
*p = '\\'; *p = '\\';
strcat(strcpy(command, zcat), filelist); zcat = (char *) realloc (zcat, strlen (zcat) + sizeof (" -dc ") + 4096);
FILE *fp = popen (command, "rt"); zcat_end = strchr (strcat (zcat, " -dc "), '\0');
char buf[4096]; }
strcpy (zcat_end, filelist);
FILE *fp = popen (zcat, "rt");
bool result = true;
char buf[MAX_PATH + 1];
while (fgets (buf, 4096, fp)) while (fgets (buf, 4096, fp))
{ {
char *filename = strtok(buf, "\n"); char *filename = strtok(buf, "\n");
@ -266,6 +281,7 @@ check_package_files (int verbose, char *package)
result = false; result = false;
} }
} }
fclose (fp); fclose (fp);
return result; return result;
} }