diff options
| author | hubertf <hubertf@NetBSD.org> | 1999-03-22 05:02:39 +0000 |
|---|---|---|
| committer | hubertf <hubertf@NetBSD.org> | 1999-03-22 05:02:39 +0000 |
| commit | 04417da1663ee41a9933b1e6bdb0efa1f8896470 (patch) | |
| tree | 4ee9164b79dff77224ff535089e2be208c0e207d /usr.sbin/pkg_install/create/main.c | |
| parent | 6c70403fe8d4617944779e3d9dc3ffd2985dd131 (diff) | |
Replace static array of packages given to pkg_perform() with linear
list, using chopss' list functions (moved to lib/lpkg.c and
lib/lib.h).
Properly handle wildcards in arguments to "pkg_info", "pkg_delete" and
"pkg_admin check".
Some other minor cleanups.
Diffstat (limited to 'usr.sbin/pkg_install/create/main.c')
| -rw-r--r-- | usr.sbin/pkg_install/create/main.c | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/usr.sbin/pkg_install/create/main.c b/usr.sbin/pkg_install/create/main.c index d0924cc401a..534422fa66f 100644 --- a/usr.sbin/pkg_install/create/main.c +++ b/usr.sbin/pkg_install/create/main.c @@ -1,11 +1,11 @@ -/* $NetBSD: main.c,v 1.12 1999/01/19 17:01:59 hubertf Exp $ */ +/* $NetBSD: main.c,v 1.13 1999/03/22 05:02:40 hubertf Exp $ */ #include <sys/cdefs.h> #ifndef lint #if 0 static const char *rcsid = "from FreeBSD Id: main.c,v 1.17 1997/10/08 07:46:23 charnier Exp"; #else -__RCSID("$NetBSD: main.c,v 1.12 1999/01/19 17:01:59 hubertf Exp $"); +__RCSID("$NetBSD: main.c,v 1.13 1999/03/22 05:02:40 hubertf Exp $"); #endif #endif @@ -65,9 +65,9 @@ int main(int argc, char **argv) { int ch; - char **pkgs, **start; + lpkg_head_t pkgs; + lpkg_t *lpp; - pkgs = start = argv; while ((ch = getopt(argc, argv, Options)) != -1) switch(ch) { case 'v': @@ -163,18 +163,25 @@ main(int argc, char **argv) argc -= optind; argv += optind; + TAILQ_INIT(&pkgs); + /* Get all the remaining package names, if any */ - while (*argv) - *pkgs++ = *argv++; + while (*argv) { + lpp = alloc_lpkg(*argv); + TAILQ_INSERT_TAIL(&pkgs, lpp, lp_link); + argv++; + } /* If no packages, yelp */ - if (pkgs == start) + lpp = TAILQ_FIRST(&pkgs); + if (lpp == NULL) warnx("missing package name"), usage(); - *pkgs = NULL; - if (start[1]) - warnx("only one package name allowed ('%s' extraneous)", start[1]), + lpp = TAILQ_NEXT(lpp, lp_link); + if (lpp != NULL) + warnx("only one package name allowed ('%s' extraneous)", + lpp->lp_name), usage(); - if (!pkg_perform(start)) { + if (!pkg_perform(&pkgs)) { if (Verbose) warnx("package creation failed"); return 1; |
