Some minor KNF.
Lots more to be done.
This commit is contained in:
parent
228a8f9869
commit
16ae233008
@ -1,11 +1,11 @@
|
||||
/* $NetBSD: extract.c,v 1.9 1998/10/08 12:57:58 agc Exp $ */
|
||||
/* $NetBSD: extract.c,v 1.10 1998/10/09 11:16:57 agc Exp $ */
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static const char *rcsid = "FreeBSD - Id: extract.c,v 1.17 1997/10/08 07:45:35 charnier Exp";
|
||||
#else
|
||||
__RCSID("$NetBSD: extract.c,v 1.9 1998/10/08 12:57:58 agc Exp $");
|
||||
__RCSID("$NetBSD: extract.c,v 1.10 1998/10/09 11:16:57 agc Exp $");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@ -38,20 +38,22 @@ __RCSID("$NetBSD: extract.c,v 1.9 1998/10/08 12:57:58 agc Exp $");
|
||||
#define TOOBIG(str) ((strlen(str) + 22 + strlen(home) + where_count > maxargs) \
|
||||
|| (strlen(str) + 6 + strlen(home) + perm_count > maxargs))
|
||||
|
||||
#define PUSHOUT(todir) /* push out string */ \
|
||||
if (where_count > sizeof(STARTSTRING)-1) { \
|
||||
strcat(where_args, "|tar xf - -C "); \
|
||||
strcat(where_args, todir); \
|
||||
if (system(where_args)) \
|
||||
cleanup(0), errx(2, "can not invoke %lu byte tar pipeline: %s", \
|
||||
(u_long)strlen(where_args), where_args); \
|
||||
strcpy(where_args, STARTSTRING); \
|
||||
where_count = sizeof(STARTSTRING)-1; \
|
||||
} \
|
||||
if (perm_count) { \
|
||||
apply_perms(todir, perm_args); \
|
||||
perm_args[0] = 0;\
|
||||
perm_count = 0; \
|
||||
#define PUSHOUT(todir) /* push out string */ \
|
||||
if (where_count > sizeof(STARTSTRING)-1) { \
|
||||
strcat(where_args, "|tar xf - -C "); \
|
||||
strcat(where_args, todir); \
|
||||
if (system(where_args)) { \
|
||||
cleanup(0); \
|
||||
errx(2, "can not invoke %lu byte tar pipeline: %s", \
|
||||
(u_long)strlen(where_args), where_args); \
|
||||
} \
|
||||
strcpy(where_args, STARTSTRING); \
|
||||
where_count = sizeof(STARTSTRING)-1; \
|
||||
} \
|
||||
if (perm_count) { \
|
||||
apply_perms(todir, perm_args); \
|
||||
perm_args[0] = 0; \
|
||||
perm_count = 0; \
|
||||
}
|
||||
|
||||
static void
|
||||
@ -91,12 +93,15 @@ extract_plist(char *home, Package *pkg)
|
||||
|
||||
maxargs = sysconf(_SC_ARG_MAX) / 2; /* Just use half the argument space */
|
||||
where_args = alloca(maxargs);
|
||||
if (!where_args)
|
||||
cleanup(0), errx(2, "can't get argument list space");
|
||||
if (!where_args) {
|
||||
cleanup(0);
|
||||
errx(2, "can't get argument list space");
|
||||
}
|
||||
perm_args = alloca(maxargs);
|
||||
if (!perm_args)
|
||||
cleanup(0), errx(2, "can't get argument list space");
|
||||
|
||||
if (!perm_args) {
|
||||
cleanup(0);
|
||||
errx(2, "can't get argument list space");
|
||||
}
|
||||
strcpy(where_args, STARTSTRING);
|
||||
where_count = sizeof(STARTSTRING)-1;
|
||||
perm_args[0] = 0;
|
||||
@ -129,8 +134,10 @@ extract_plist(char *home, Package *pkg)
|
||||
if (!Fake) {
|
||||
char try[FILENAME_MAX];
|
||||
|
||||
if (strrchr(p->name,'\''))
|
||||
cleanup(0), errx(2, "Bogus filename \"%s\"", p->name);
|
||||
if (strrchr(p->name,'\'')) {
|
||||
cleanup(0);
|
||||
errx(2, "Bogus filename \"%s\"", p->name);
|
||||
}
|
||||
|
||||
/* first try to rename it into place */
|
||||
snprintf(try, FILENAME_MAX, "%s/%s", Directory, p->name);
|
||||
@ -156,11 +163,12 @@ extract_plist(char *home, Package *pkg)
|
||||
PUSHOUT(Directory);
|
||||
}
|
||||
add_count = snprintf(&perm_args[perm_count], maxargs - perm_count, "'%s' ", p->name);
|
||||
if (add_count > maxargs - perm_count)
|
||||
cleanup(0), errx(2, "oops, miscounted strings!");
|
||||
if (add_count > maxargs - perm_count) {
|
||||
cleanup(0);
|
||||
errx(2, "oops, miscounted strings!");
|
||||
}
|
||||
perm_count += add_count;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
/* rename failed, try copying with a big tar command */
|
||||
if (last_chdir != Directory) {
|
||||
PUSHOUT(last_chdir);
|
||||
@ -170,14 +178,18 @@ extract_plist(char *home, Package *pkg)
|
||||
PUSHOUT(Directory);
|
||||
}
|
||||
add_count = snprintf(&where_args[where_count], maxargs - where_count, " '%s'", p->name);
|
||||
if (add_count > maxargs - where_count)
|
||||
cleanup(0), errx(2, "oops, miscounted strings!");
|
||||
if (add_count > maxargs - where_count) {
|
||||
cleanup(0);
|
||||
errx(2, "oops, miscounted strings!");
|
||||
}
|
||||
where_count += add_count;
|
||||
add_count = snprintf(&perm_args[perm_count],
|
||||
maxargs - perm_count,
|
||||
"'%s' ", p->name);
|
||||
if (add_count > maxargs - perm_count)
|
||||
cleanup(0), errx(2, "oops, miscounted strings!");
|
||||
if (add_count > maxargs - perm_count) {
|
||||
cleanup(0);
|
||||
errx(2, "oops, miscounted strings!");
|
||||
}
|
||||
perm_count += add_count;
|
||||
}
|
||||
}
|
||||
@ -188,19 +200,20 @@ extract_plist(char *home, Package *pkg)
|
||||
printf("extract: CWD to %s\n", p->name);
|
||||
PUSHOUT(Directory);
|
||||
if (strcmp(p->name, ".")) {
|
||||
if (!Fake && make_hierarchy(p->name) == FAIL)
|
||||
cleanup(0), errx(2, "unable to make directory '%s'",
|
||||
p->name);
|
||||
if (!Fake && make_hierarchy(p->name) == FAIL) {
|
||||
cleanup(0);
|
||||
errx(2, "unable to make directory '%s'", p->name);
|
||||
}
|
||||
Directory = p->name;
|
||||
}
|
||||
else
|
||||
} else
|
||||
Directory = home;
|
||||
break;
|
||||
|
||||
case PLIST_CMD:
|
||||
if (last_file == NULL)
|
||||
cleanup(0), errx(2, "no last file specified for '%s' command",
|
||||
p->name);
|
||||
if (last_file == NULL) {
|
||||
cleanup(0);
|
||||
errx(2, "no last file specified for '%s' command", p->name);
|
||||
}
|
||||
format_cmd(cmd, sizeof(cmd), p->name, Directory, last_file);
|
||||
PUSHOUT(Directory);
|
||||
if (Verbose)
|
||||
|
@ -1,11 +1,11 @@
|
||||
/* $NetBSD: perform.c,v 1.10 1998/10/08 12:57:59 agc Exp $ */
|
||||
/* $NetBSD: perform.c,v 1.11 1998/10/09 11:16:58 agc Exp $ */
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static const char *rcsid = "from FreeBSD Id: perform.c,v 1.38 1997/10/13 15:03:51 jkh Exp";
|
||||
#else
|
||||
__RCSID("$NetBSD: perform.c,v 1.10 1998/10/08 12:57:59 agc Exp $");
|
||||
__RCSID("$NetBSD: perform.c,v 1.11 1998/10/09 11:16:58 agc Exp $");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@ -62,9 +62,10 @@ pkg_perform(char **pkgs)
|
||||
pkg_in = stdin;
|
||||
else {
|
||||
pkg_in = fopen(Contents, "r");
|
||||
if (!pkg_in)
|
||||
cleanup(0), errx(2, "unable to open contents file '%s' for input",
|
||||
Contents);
|
||||
if (!pkg_in) {
|
||||
cleanup(0);
|
||||
errx(2, "unable to open contents file '%s' for input", Contents);
|
||||
}
|
||||
}
|
||||
plist.head = plist.tail = NULL;
|
||||
|
||||
@ -191,11 +192,15 @@ pkg_perform(char **pkgs)
|
||||
|
||||
/* Finally, write out the packing list */
|
||||
fp = fopen(CONTENTS_FNAME, "w");
|
||||
if (!fp)
|
||||
cleanup(0), errx(2, "can't open file %s for writing", CONTENTS_FNAME);
|
||||
if (!fp) {
|
||||
cleanup(0);
|
||||
errx(2, "can't open file %s for writing", CONTENTS_FNAME);
|
||||
}
|
||||
write_plist(&plist, fp);
|
||||
if (fclose(fp))
|
||||
cleanup(0), errx(2, "error while closing %s", CONTENTS_FNAME);
|
||||
if (fclose(fp)) {
|
||||
cleanup(0);
|
||||
errx(2, "error while closing %s", CONTENTS_FNAME);
|
||||
}
|
||||
|
||||
/* And stick it into a tar ball */
|
||||
make_dist(home, pkg, suffix, &plist);
|
||||
@ -246,10 +251,14 @@ make_dist(char *home, char *pkg, char *suffix, Package *plist)
|
||||
printf("Creating gzip'd tar ball in '%s'\n", tball);
|
||||
|
||||
/* Set up a pipe for passing the filenames, and fork off a tar process. */
|
||||
if (pipe(pipefds) == -1)
|
||||
cleanup(0), errx(2, "cannot create pipe");
|
||||
if ((pid = fork()) == -1)
|
||||
cleanup(0), errx(2, "cannot fork process for tar");
|
||||
if (pipe(pipefds) == -1) {
|
||||
cleanup(0);
|
||||
errx(2, "cannot create pipe");
|
||||
}
|
||||
if ((pid = fork()) == -1) {
|
||||
cleanup(0);
|
||||
errx(2, "cannot fork process for tar");
|
||||
}
|
||||
if (pid == 0) { /* The child */
|
||||
dup2(pipefds[0], 0);
|
||||
close(pipefds[0]);
|
||||
@ -261,8 +270,10 @@ make_dist(char *home, char *pkg, char *suffix, Package *plist)
|
||||
|
||||
/* Meanwhile, back in the parent process ... */
|
||||
close(pipefds[0]);
|
||||
if ((totar = fdopen(pipefds[1], "w")) == NULL)
|
||||
cleanup(0), errx(2, "fdopen failed");
|
||||
if ((totar = fdopen(pipefds[1], "w")) == NULL) {
|
||||
cleanup(0);
|
||||
errx(2, "fdopen failed");
|
||||
}
|
||||
|
||||
fprintf(totar, "%s\n", CONTENTS_FNAME);
|
||||
fprintf(totar, "%s\n", COMMENT_FNAME);
|
||||
@ -291,22 +302,27 @@ make_dist(char *home, char *pkg, char *suffix, Package *plist)
|
||||
fclose(totar);
|
||||
wait(&ret);
|
||||
/* assume either signal or bad exit is enough for us */
|
||||
if (ret)
|
||||
cleanup(0), errx(2, "tar command failed with code %d", ret);
|
||||
if (ret) {
|
||||
cleanup(0);
|
||||
errx(2, "tar command failed with code %d", ret);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
sanity_check()
|
||||
{
|
||||
if (!Comment)
|
||||
cleanup(0), errx(2,
|
||||
"required package comment string is missing (-c comment)");
|
||||
if (!Desc)
|
||||
cleanup(0), errx(2,
|
||||
"required package description string is missing (-d desc)");
|
||||
if (!Contents)
|
||||
cleanup(0), errx(2,
|
||||
"required package contents list is missing (-f [-]file)");
|
||||
if (!Comment) {
|
||||
cleanup(0);
|
||||
errx(2, "required package comment string is missing (-c comment)");
|
||||
}
|
||||
if (!Desc) {
|
||||
cleanup(0);
|
||||
errx(2, "required package description string is missing (-d desc)");
|
||||
}
|
||||
if (!Contents) {
|
||||
cleanup(0);
|
||||
errx(2, "required package contents list is missing (-f [-]file)");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,11 +1,11 @@
|
||||
/* $NetBSD: pl.c,v 1.5 1998/10/08 12:57:59 agc Exp $ */
|
||||
/* $NetBSD: pl.c,v 1.6 1998/10/09 11:16:58 agc Exp $ */
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static const char *rcsid = "from FreeBSD Id: pl.c,v 1.11 1997/10/08 07:46:35 charnier Exp";
|
||||
#else
|
||||
__RCSID("$NetBSD: pl.c,v 1.5 1998/10/08 12:57:59 agc Exp $");
|
||||
__RCSID("$NetBSD: pl.c,v 1.6 1998/10/09 11:16:58 agc Exp $");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@ -91,8 +91,10 @@ trylink(const char *from, const char *to)
|
||||
#define PUSHOUT() /* push out string */ \
|
||||
if (where_count > sizeof(STARTSTRING)-1) { \
|
||||
strcat(where_args, "|tar xpf -"); \
|
||||
if (system(where_args)) \
|
||||
cleanup(0), errx(2, "can't invoke tar pipeline"); \
|
||||
if (system(where_args)) { \
|
||||
cleanup(0); \
|
||||
errx(2, "can't invoke tar pipeline"); \
|
||||
} \
|
||||
memset(where_args, 0, maxargs); \
|
||||
last_chdir = NULL; \
|
||||
strcpy(where_args, STARTSTRING); \
|
||||
@ -118,8 +120,10 @@ copy_plist(char *home, Package *plist)
|
||||
maxargs -= 64; /* some slop for the tar cmd text,
|
||||
and sh -c */
|
||||
where_args = malloc(maxargs);
|
||||
if (!where_args)
|
||||
cleanup(0), errx(2, "can't get argument list space");
|
||||
if (!where_args) {
|
||||
cleanup(0);
|
||||
errx(2, "can't get argument list space");
|
||||
}
|
||||
|
||||
memset(where_args, 0, maxargs);
|
||||
strcpy(where_args, STARTSTRING);
|
||||
@ -179,8 +183,10 @@ copy_plist(char *home, Package *plist)
|
||||
p->name);
|
||||
last_chdir = home;
|
||||
}
|
||||
if (add_count > maxargs - where_count)
|
||||
cleanup(0), errx(2, "oops, miscounted strings!");
|
||||
if (add_count > maxargs - where_count) {
|
||||
cleanup(0);
|
||||
errx(2, "oops, miscounted strings!");
|
||||
}
|
||||
where_count += add_count;
|
||||
}
|
||||
/*
|
||||
@ -213,8 +219,10 @@ copy_plist(char *home, Package *plist)
|
||||
" -C %s %s",
|
||||
mythere ? mythere : where,
|
||||
p->name);
|
||||
if (add_count > maxargs - where_count)
|
||||
cleanup(0), errx(2, "oops, miscounted strings!");
|
||||
if (add_count > maxargs - where_count) {
|
||||
cleanup(0);
|
||||
errx(2, "oops, miscounted strings!");
|
||||
}
|
||||
where_count += add_count;
|
||||
last_chdir = (mythere ? mythere : where);
|
||||
}
|
||||
|
@ -1,11 +1,11 @@
|
||||
/* $NetBSD: perform.c,v 1.8 1998/10/08 12:57:59 agc Exp $ */
|
||||
/* $NetBSD: perform.c,v 1.9 1998/10/09 11:16:59 agc Exp $ */
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static const char *rcsid = "from FreeBSD Id: perform.c,v 1.15 1997/10/13 15:03:52 jkh Exp";
|
||||
#else
|
||||
__RCSID("$NetBSD: perform.c,v 1.8 1998/10/08 12:57:59 agc Exp $");
|
||||
__RCSID("$NetBSD: perform.c,v 1.9 1998/10/09 11:16:59 agc Exp $");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@ -70,8 +70,10 @@ pkg_do(char *pkg)
|
||||
warnx("no such package '%s' installed", pkg);
|
||||
return 1;
|
||||
}
|
||||
if (!getcwd(home, FILENAME_MAX))
|
||||
cleanup(0), errx(2, "unable to get current working directory!");
|
||||
if (!getcwd(home, FILENAME_MAX)) {
|
||||
cleanup(0);
|
||||
errx(2, "unable to get current working directory!");
|
||||
}
|
||||
if (chdir(LogDir) == FAIL) {
|
||||
warnx("unable to change directory to %s! deinstall failed", LogDir);
|
||||
return 1;
|
||||
@ -131,8 +133,10 @@ pkg_do(char *pkg)
|
||||
}
|
||||
}
|
||||
}
|
||||
if (chdir(home) == FAIL)
|
||||
cleanup(0), errx(2, "Toto! This doesn't look like Kansas anymore!");
|
||||
if (chdir(home) == FAIL) {
|
||||
cleanup(0);
|
||||
errx(2, "Toto! This doesn't look like Kansas anymore!");
|
||||
}
|
||||
if (!Fake) {
|
||||
/* Some packages aren't packed right, so we need to just ignore delete_package()'s status. Ugh! :-( */
|
||||
if (delete_package(FALSE, CleanDirs, &Plist) == FAIL)
|
||||
@ -161,9 +165,10 @@ pkg_do(char *pkg)
|
||||
static void
|
||||
sanity_check(char *pkg)
|
||||
{
|
||||
if (!fexists(CONTENTS_FNAME))
|
||||
cleanup(0), errx(2, "installed package %s has no %s file!",
|
||||
pkg, CONTENTS_FNAME);
|
||||
if (!fexists(CONTENTS_FNAME)) {
|
||||
cleanup(0);
|
||||
errx(2, "installed package %s has no %s file!", pkg, CONTENTS_FNAME);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
Loading…
Reference in New Issue
Block a user