Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-1-4]: src/usr.sbin/pkg_install/add Pull up revisions 1.11-1.12:
details: https://anonhg.NetBSD.org/src/rev/8bc0621825ff
branches: netbsd-1-4
changeset: 469374:8bc0621825ff
user: he <he%NetBSD.org@localhost>
date: Mon Sep 13 21:36:28 1999 +0000
description:
Pull up revisions 1.11-1.12:
Hide test for URLlength()>0 behind a macro (IS_URL()).
Bring closer to /usr/share/misc/style with the aid of indent(1).
(hubertf)
diffstat:
usr.sbin/pkg_install/add/main.c | 205 +++++++++++++++++++--------------------
1 files changed, 102 insertions(+), 103 deletions(-)
diffs (248 lines):
diff -r a5f8c45f4c0a -r 8bc0621825ff usr.sbin/pkg_install/add/main.c
--- a/usr.sbin/pkg_install/add/main.c Mon Sep 13 21:22:26 1999 +0000
+++ b/usr.sbin/pkg_install/add/main.c Mon Sep 13 21:36:28 1999 +0000
@@ -1,11 +1,11 @@
-/* $NetBSD: main.c,v 1.9.2.1 1999/08/22 17:27:23 he Exp $ */
+/* $NetBSD: main.c,v 1.9.2.2 1999/09/13 21:36:28 he Exp $ */
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char *rcsid = "from FreeBSD Id: main.c,v 1.16 1997/10/08 07:45:43 charnier Exp";
#else
-__RCSID("$NetBSD: main.c,v 1.9.2.1 1999/08/22 17:27:23 he Exp $");
+__RCSID("$NetBSD: main.c,v 1.9.2.2 1999/09/13 21:36:28 he Exp $");
#endif
#endif
@@ -37,130 +37,129 @@
static char Options[] = "hvIRfnp:SMt:";
-char *Prefix = NULL;
-Boolean NoInstall = FALSE;
-Boolean NoRecord = FALSE;
+char *Prefix = NULL;
+Boolean NoInstall = FALSE;
+Boolean NoRecord = FALSE;
-char *Mode = NULL;
-char *Owner = NULL;
-char *Group = NULL;
-char *PkgName = NULL;
-char *Directory = NULL;
-char FirstPen[FILENAME_MAX];
-add_mode_t AddMode = NORMAL;
+char *Mode = NULL;
+char *Owner = NULL;
+char *Group = NULL;
+char *PkgName = NULL;
+char *Directory = NULL;
+char FirstPen[FILENAME_MAX];
+add_mode_t AddMode = NORMAL;
static void
usage(void)
{
- fprintf(stderr, "%s\n%s\n",
- "usage: pkg_add [-vInfRMS] [-t template] [-p prefix]",
- " pkg-name [pkg-name ...]");
- exit(1);
+ fprintf(stderr, "%s\n%s\n",
+ "usage: pkg_add [-vInfRMS] [-t template] [-p prefix]",
+ " pkg-name [pkg-name ...]");
+ exit(1);
}
int
main(int argc, char **argv)
{
- int ch, error;
- lpkg_head_t pkgs;
- lpkg_t *lpp;
- char *cp;
- char pkgname[MAXPATHLEN];
+ int ch, error;
+ lpkg_head_t pkgs;
+ lpkg_t *lpp;
+ char *cp;
+ char pkgname[MAXPATHLEN];
- while ((ch = getopt(argc, argv, Options)) != -1) {
- switch(ch) {
- case 'v':
- Verbose = TRUE;
- break;
+ while ((ch = getopt(argc, argv, Options)) != -1) {
+ switch (ch) {
+ case 'v':
+ Verbose = TRUE;
+ break;
- case 'p':
- Prefix = optarg;
- break;
+ case 'p':
+ Prefix = optarg;
+ break;
- case 'I':
- NoInstall = TRUE;
- break;
+ case 'I':
+ NoInstall = TRUE;
+ break;
- case 'R':
- NoRecord = TRUE;
- break;
+ case 'R':
+ NoRecord = TRUE;
+ break;
- case 'f':
- Force = TRUE;
- break;
+ case 'f':
+ Force = TRUE;
+ break;
- case 'n':
- Fake = TRUE;
- Verbose = TRUE;
- break;
+ case 'n':
+ Fake = TRUE;
+ Verbose = TRUE;
+ break;
- case 't':
- strcpy(FirstPen, optarg);
- break;
+ case 't':
+ strcpy(FirstPen, optarg);
+ break;
- case 'S':
- AddMode = SLAVE;
- break;
+ case 'S':
+ AddMode = SLAVE;
+ break;
- case 'M':
- AddMode = MASTER;
- break;
+ case 'M':
+ AddMode = MASTER;
+ break;
- case 'h':
- case '?':
- default:
- usage();
- break;
+ case 'h':
+ case '?':
+ default:
+ usage();
+ break;
+ }
}
- }
- argc -= optind;
- argv += optind;
+ argc -= optind;
+ argv += optind;
+
+ TAILQ_INIT(&pkgs);
- TAILQ_INIT(&pkgs);
-
- if (AddMode != SLAVE) {
- /* Get all the remaining package names, if any */
- for (ch = 0; *argv; ch++, argv++) {
- if (!strcmp(*argv, "-")) /* stdin? */
- lpp = alloc_lpkg("-");
- else if (URLlength(*argv) > 0) /* preserve URLs */
- lpp = alloc_lpkg(*argv);
- else { /* expand all pathnames to fullnames */
- char *s;
-
- if (fexists(*argv)) { /* refers to a file directly */
- lpp = alloc_lpkg(realpath(*argv, pkgname));
- } else if (ispkgpattern(*argv)
- && (s=findbestmatchingname(dirname_of(*argv),
- basename_of(*argv))) != NULL) {
- if (Verbose)
- printf("Using %s for %s\n",s, *argv);
+ if (AddMode != SLAVE) {
+ /* Get all the remaining package names, if any */
+ for (ch = 0; *argv; ch++, argv++) {
+ if (!strcmp(*argv, "-")) /* stdin? */
+ lpp = alloc_lpkg("-");
+ else if (IS_URL(*argv)) /* preserve URLs */
+ lpp = alloc_lpkg(*argv);
+ else { /* expand all pathnames to fullnames */
+ char *s;
+
+ if (fexists(*argv)) { /* refers to a file directly */
+ lpp = alloc_lpkg(realpath(*argv, pkgname));
+ } else if (ispkgpattern(*argv)
+ && (s = findbestmatchingname(dirname_of(*argv),
+ basename_of(*argv))) != NULL) {
+ if (Verbose)
+ printf("Using %s for %s\n", s, *argv);
- lpp = alloc_lpkg(realpath(s, pkgname));
- } else {
- /* look for the file(pattern) in the expected places */
- if (!(cp = fileFindByPath(NULL, *argv))) {
- lpp = NULL;
- warnx("can't find package '%s'", *argv);
- } else
- lpp = alloc_lpkg(cp);
+ lpp = alloc_lpkg(realpath(s, pkgname));
+ } else {
+ /* look for the file(pattern) in the expected places */
+ if (!(cp = fileFindByPath(NULL, *argv))) {
+ lpp = NULL;
+ warnx("can't find package '%s'", *argv);
+ } else
+ lpp = alloc_lpkg(cp);
+ }
+ }
+ if (lpp)
+ TAILQ_INSERT_TAIL(&pkgs, lpp, lp_link);
}
- }
- if (lpp)
- TAILQ_INSERT_TAIL(&pkgs, lpp, lp_link);
}
- }
- /* If no packages, yelp */
- else if (!ch)
- warnx("missing package name(s)"), usage();
- else if (ch > 1 && AddMode == MASTER)
- warnx("only one package name may be specified with master mode"),
- usage();
- if ((error = pkg_perform(&pkgs)) != 0) {
- if (Verbose)
- warnx("%d package addition(s) failed", error);
- return error;
- }
- else
- return 0;
+ /* If no packages, yelp */
+ else if (!ch)
+ warnx("missing package name(s)"), usage();
+ else if (ch > 1 && AddMode == MASTER)
+ warnx("only one package name may be specified with master mode"),
+ usage();
+ if ((error = pkg_perform(&pkgs)) != 0) {
+ if (Verbose)
+ warnx("%d package addition(s) failed", error);
+ return error;
+ } else
+ return 0;
}
Home |
Main Index |
Thread Index |
Old Index