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/lib Pull up revision 1.22:



details:   https://anonhg.NetBSD.org/src/rev/64c1b8ed87d7
branches:  netbsd-1-4
changeset: 469395:64c1b8ed87d7
user:      he <he%NetBSD.org@localhost>
date:      Mon Sep 13 22:37:36 1999 +0000

description:
Pull up revision 1.22:
  Bring closer to /usr/share/misc/style with the aid of indent(1).  (hubertf)

diffstat:

 usr.sbin/pkg_install/lib/plist.c |  516 ++++++++++++++++++++------------------
 1 files changed, 267 insertions(+), 249 deletions(-)

diffs (truncated from 688 to 300 lines):

diff -r a927fc0a66bf -r 64c1b8ed87d7 usr.sbin/pkg_install/lib/plist.c
--- a/usr.sbin/pkg_install/lib/plist.c  Mon Sep 13 22:35:32 1999 +0000
+++ b/usr.sbin/pkg_install/lib/plist.c  Mon Sep 13 22:37:36 1999 +0000
@@ -1,11 +1,11 @@
-/*     $NetBSD: plist.c,v 1.18.2.1 1999/08/22 18:18:08 he Exp $        */
+/*     $NetBSD: plist.c,v 1.18.2.2 1999/09/13 22:37:36 he Exp $        */
 
 #include <sys/cdefs.h>
 #ifndef lint
 #if 0
 static const char *rcsid = "from FreeBSD Id: plist.c,v 1.24 1997/10/08 07:48:15 charnier Exp";
 #else
-__RCSID("$NetBSD: plist.c,v 1.18.2.1 1999/08/22 18:18:08 he Exp $");
+__RCSID("$NetBSD: plist.c,v 1.18.2.2 1999/09/13 22:37:36 he Exp $");
 #endif
 #endif
 
@@ -34,37 +34,39 @@
 #include <err.h>
 #include <md5.h>
 
-/* this struct defines a plist command type */
+/* This struct defines a plist command type */
 typedef struct cmd_t {
-       char            *c_s;           /* string to recognise */
-       pl_ent_t        c_type;         /* type of command */
-       int             c_argc;         /* # of arguments */
-} cmd_t;
+       char   *c_s;            /* string to recognise */
+       pl_ent_t c_type;        /* type of command */
+       int     c_argc;         /* # of arguments */
+}       cmd_t;
 
-/* commands to recognise */
-static cmd_t   cmdv[] = {
-       {       "cwd",          PLIST_CWD,              1       },
-       {       "src",          PLIST_SRC,              1       },
-       {       "cd",           PLIST_CWD,              1       },
-       {       "exec",         PLIST_CMD,              1       },
-       {       "unexec",       PLIST_UNEXEC,           1       },
-       {       "mode",         PLIST_CHMOD,            1       },
-       {       "owner",        PLIST_CHOWN,            1       },
-       {       "group",        PLIST_CHGRP,            1       },
-       {       "comment",      PLIST_COMMENT,          1       },
-       {       "ignore",       PLIST_IGNORE,           0       },
-       {       "ignore_inst",  PLIST_IGNORE_INST,      0       },
-       {       "name",         PLIST_NAME,             1       },
-       {       "display",      PLIST_DISPLAY,          1       },
-       {       "pkgdep",       PLIST_PKGDEP,           1       },
-       {       "pkgcfl",       PLIST_PKGCFL,           1       },
-       {       "mtree",        PLIST_MTREE,            1       },
-       {       "dirrm",        PLIST_DIR_RM,           1       },
-       {       "option",       PLIST_OPTION,           1       },
-       {       NULL,           FAIL,                   0       }
+/* Commands to recognise */
+static cmd_t cmdv[] = {
+       {"cwd", PLIST_CWD, 1},
+       {"src", PLIST_SRC, 1},
+       {"cd", PLIST_CWD, 1},
+       {"exec", PLIST_CMD, 1},
+       {"unexec", PLIST_UNEXEC, 1},
+       {"mode", PLIST_CHMOD, 1},
+       {"owner", PLIST_CHOWN, 1},
+       {"group", PLIST_CHGRP, 1},
+       {"comment", PLIST_COMMENT, 1},
+       {"ignore", PLIST_IGNORE, 0},
+       {"ignore_inst", PLIST_IGNORE_INST, 0},
+       {"name", PLIST_NAME, 1},
+       {"display", PLIST_DISPLAY, 1},
+       {"pkgdep", PLIST_PKGDEP, 1},
+       {"pkgcfl", PLIST_PKGCFL, 1},
+       {"mtree", PLIST_MTREE, 1},
+       {"dirrm", PLIST_DIR_RM, 1},
+       {"option", PLIST_OPTION, 1},
+       {NULL, FAIL, 0}
 };
 
-/* Add an item to the end of a packing list */
+/*
+ * Add an item to the end of a packing list
+ */
 void
 add_plist(package_t *p, pl_ent_t type, char *arg)
 {
@@ -82,7 +84,9 @@
        }
 }
 
-/* add an item to the start of a packing list */
+/*
+ * Add an item to the start of a packing list
+ */
 void
 add_plist_top(package_t *p, pl_ent_t type, char *arg)
 {
@@ -100,46 +104,56 @@
        }
 }
 
-/* Return the last (most recent) entry in a packing list */
+/*
+ * Return the last (most recent) entry in a packing list
+ */
 plist_t *
 last_plist(package_t *p)
 {
        return p->tail;
 }
 
-/* Mark all items in a packing list to prevent iteration over them */
+/*
+ * Mark all items in a packing list to prevent iteration over them
+ */
 void
 mark_plist(package_t *pkg)
 {
-       plist_t *pp;
+       plist_t *pp;
 
-       for (pp = pkg->head ; pp ; pp = pp->next) {
+       for (pp = pkg->head; pp; pp = pp->next) {
                pp->marked = TRUE;
        }
 }
 
-/* Find a given item in a packing list and, if so, return it (else NULL) */
+/*
+ * Find a given item in a packing list and, if so, return it (else NULL)
+ */
 plist_t *
 find_plist(package_t *pkg, pl_ent_t type)
 {
-       plist_t *pp;
+       plist_t *pp;
 
-       for (pp = pkg->head ; pp && pp->type != type ; pp = pp->next) {
+       for (pp = pkg->head; pp && pp->type != type; pp = pp->next) {
        }
        return pp;
 }
 
-/* Look for a specific boolean option argument in the list */
-char *
+/*
+ * Look for a specific boolean option argument in the list
+ */
+char   *
 find_plist_option(package_t *pkg, char *name)
 {
-       plist_t *p;
+       plist_t *p;
 
-       for (p = pkg->head ; p ; p = p->next) {
-               if (p->type == PLIST_OPTION && strcmp(p->name, name) == 0) {
+       for (p = pkg->head; p; p = p->next) {
+               if (p->type == PLIST_OPTION
+                   && strcmp(p->name, name) == 0) {
                        return p->name;
                }
        }
+       
        return (char *) NULL;
 }
 
@@ -150,77 +164,80 @@
 void
 delete_plist(package_t *pkg, Boolean all, pl_ent_t type, char *name)
 {
-    plist_t *p = pkg->head;
+       plist_t *p = pkg->head;
 
-    while (p) {
-       plist_t *pnext = p->next;
+       while (p) {
+               plist_t *pnext = p->next;
 
-       if (p->type == type && (!name || !strcmp(name, p->name))) {
-           free(p->name);
-           if (p->prev)
-               p->prev->next = pnext;
-           else
-               pkg->head = pnext;
-           if (pnext)
-               pnext->prev = p->prev;
-           else
-               pkg->tail = p->prev;
-           free(p);
-           if (!all)
-               return;
-           p = pnext;
+               if (p->type == type && (!name || !strcmp(name, p->name))) {
+                       free(p->name);
+                       if (p->prev)
+                               p->prev->next = pnext;
+                       else
+                               pkg->head = pnext;
+                       if (pnext)
+                               pnext->prev = p->prev;
+                       else
+                               pkg->tail = p->prev;
+                       free(p);
+                       if (!all)
+                               return;
+                       p = pnext;
+               } else
+                       p = p->next;
        }
-       else
-           p = p->next;
-    }
 }
 
-/* Allocate a new packing list entry */
+/*
+ * Allocate a new packing list entry, and return a pointer to it. 
+ */
 plist_t *
 new_plist_entry(void)
 {
        plist_t *ret;
 
-       if ((ret = (plist_t *)malloc(sizeof(plist_t))) == (plist_t *) NULL) {
+       if ((ret = (plist_t *) malloc(sizeof(plist_t))) == (plist_t *) NULL) {
                err(1, "can't allocate %ld bytes", (long) sizeof(plist_t));
        }
        memset(ret, 0, sizeof(plist_t));
        return ret;
 }
 
-/* Free an entire packing list */
+/*
+ * Free an entire packing list
+ */
 void
 free_plist(package_t *pkg)
 {
-    plist_t *p = pkg->head;
+       plist_t *p = pkg->head;
 
-    while (p) {
-       plist_t *p1 = p->next;
+       while (p) {
+               plist_t *p1 = p->next;
 
-       free(p->name);
-       free(p);
-       p = p1;
-    }
-    pkg->head = pkg->tail = NULL;
+               free(p->name);
+               free(p);
+               p = p1;
+       }
+       pkg->head = pkg->tail = NULL;
 }
 
 /*
- * For an ascii string denoting a plist command, return its code and
+ * For an ASCII string denoting a plist command, return its code and
  * optionally its argument(s)
  */
 int
 plist_cmd(char *s, char **arg)
 {
-       cmd_t   *cmdp;
-       char    cmd[FILENAME_MAX + 20]; /* 20 == fudge for max cmd len */
-       char    *cp;
-       char    *sp;
+       cmd_t  *cmdp;
+       char    cmd[FILENAME_MAX + 20]; /* 20 == fudge for max cmd len */
+       char   *cp;
+       char   *sp;
 
        (void) strcpy(cmd, s);
        str_lowercase(cmd);
-       for (cp = cmd, sp = s ; *cp ; cp++, sp++) {
-               if (isspace((unsigned char)*cp)) {
-                       for (*cp = '\0'; isspace((unsigned char)*sp); sp++) {
+       for (cp = cmd, sp = s; *cp; cp++, sp++) {
+               if (isspace((unsigned char) *cp)) {
+                       for (*cp = '\0'; isspace((unsigned char) *sp); sp++) {
                        }
                        break;
                }
@@ -228,23 +245,25 @@
        if (arg) {
                *arg = sp;
        }
-       for (cmdp = cmdv ; cmdp->c_s && strcmp(cmdp->c_s, cmd) != 0 ; cmdp++) {
+       for (cmdp = cmdv; cmdp->c_s && strcmp(cmdp->c_s, cmd) != 0; cmdp++) {
        }
        return cmdp->c_type;
 }
 
-/* Read a packing list from a file */
+/*
+ * Read a packing list from a file
+ */
 void
-read_plist(package_t *pkg, FILE *fp)



Home | Main Index | Thread Index | Old Index