Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2003-08-10 05:07:04 +0400
committerChristopher Faylor <me@cgf.cx>2003-08-10 05:07:04 +0400
commite41630b08a5ec7b1c348c6e27f66a236b822c2e9 (patch)
treea3834c9a34a04a1dd40fa1ac79b30a28b2c9d163 /winsup/utils/dump_setup.cc
parent46258d6fb80517c94ea0fb73b601cbf3a9fc9edb (diff)
* dump_setup.cc (dump_setup): Check for the existence of the package list file.
Rework slightly to use static buffer for popen commands.
Diffstat (limited to 'winsup/utils/dump_setup.cc')
-rw-r--r--winsup/utils/dump_setup.cc46
1 files changed, 31 insertions, 15 deletions
diff --git a/winsup/utils/dump_setup.cc b/winsup/utils/dump_setup.cc
index 248e41741..2a64b9021 100644
--- a/winsup/utils/dump_setup.cc
+++ b/winsup/utils/dump_setup.cc
@@ -237,36 +237,52 @@ file_exists (int verbose, char *filename, const char *alt, char *package)
static bool
check_package_files (int verbose, char *package)
{
+ char filelist[MAX_PATH + 1] = "/etc/setup/";
+ strcat (strcat (filelist, package), ".lst.gz");
+ if (!file_exists (false, filelist, NULL, NULL))
+ {
+ 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, '/'))
+ *p = '\\';
+ zcat = (char *) realloc (zcat, strlen (zcat) + sizeof (" -dc ") + 4096);
+ zcat_end = strchr (strcat (zcat, " -dc "), '\0');
+ }
+
+ strcpy (zcat_end, filelist);
+ FILE *fp = popen (zcat, "rt");
+
bool result = true;
- char filelist[4096] = " -dc /etc/setup/";
- strcat(strcat(filelist, package), ".lst.gz");
- char *zcat = cygpath("/bin/gzip.exe", NULL);
- char command[4096];
- while (char *p = strchr (zcat, '/'))
- *p = '\\';
- strcat(strcpy(command, zcat), filelist);
- FILE *fp = popen (command, "rt");
- char buf[4096];
+ char buf[MAX_PATH + 1];
while (fgets (buf, 4096, fp))
{
char *filename = strtok(buf, "\n");
- if (filename[strlen(filename)-1] == '/')
+ if (filename[strlen (filename) - 1] == '/')
{
- if (!directory_exists(verbose, filename, package))
+ if (!directory_exists (verbose, filename, package))
result = false;
}
- else if (!strncmp(filename, "etc/postinstall/", 16))
+ else if (!strncmp (filename, "etc/postinstall/", 16))
{
- if (!file_exists(verbose, filename, ".done", package))
+ if (!file_exists (verbose, filename, ".done", package))
result = false;
}
else
{
- if (!file_exists(verbose, filename, ".lnk", package))
+ if (!file_exists (verbose, filename, ".lnk", package))
result = false;
}
}
- fclose(fp);
+
+ fclose (fp);
return result;
}