added labels for partial updates.
authorRalph Campbell <ralph@ucbvax.Berkeley.EDU>
Sat, 7 Apr 1984 06:48:45 +0000 (22:48 -0800)
committerRalph Campbell <ralph@ucbvax.Berkeley.EDU>
Sat, 7 Apr 1984 06:48:45 +0000 (22:48 -0800)
SCCS-vsn: usr.bin/rdist/defs.h 4.12
SCCS-vsn: usr.bin/rdist/docmd.c 4.19
SCCS-vsn: usr.bin/rdist/gram.y 4.9
SCCS-vsn: usr.bin/rdist/main.c 4.11

usr/src/usr.bin/rdist/defs.h
usr/src/usr.bin/rdist/docmd.c
usr/src/usr.bin/rdist/gram.y
usr/src/usr.bin/rdist/main.c

index 2d61de8..f163267 100644 (file)
@@ -1,4 +1,4 @@
-/*     defs.h  4.11    84/02/24        */
+/*     defs.h  4.12    84/04/06        */
 
 #include <stdio.h>
 #include <ctype.h>
 
 #include <stdio.h>
 #include <ctype.h>
 #define RP     3
 #define SM     4
 #define ARROW  5
 #define RP     3
 #define SM     4
 #define ARROW  5
-#define DCOLON 6
-#define NAME   7
-#define STRING 8
-#define INSTALL        9
-#define NOTIFY 10
-#define EXCEPT 11
-#define SPECIAL        12
-#define OPTION 13
+#define COLON  6
+#define DCOLON 7
+#define NAME   8
+#define STRING 9
+#define INSTALL        10
+#define NOTIFY 11
+#define EXCEPT 12
+#define SPECIAL        13
+#define OPTION 14
 
        /* lexical definitions */
 #define        QUOTE   0200            /* used internally for quoted characters */
 
        /* lexical definitions */
 #define        QUOTE   0200            /* used internally for quoted characters */
@@ -82,6 +83,7 @@ struct subcmd {
 struct cmd {
        int     c_type;         /* type - ARROW,DCOLON */
        char    *c_name;        /* hostname or time stamp file name */
 struct cmd {
        int     c_type;         /* type - ARROW,DCOLON */
        char    *c_name;        /* hostname or time stamp file name */
+       char    *c_label;       /* label for partial update */
        struct  namelist *c_files;
        struct  subcmd *c_cmds;
        struct  cmd *c_next;
        struct  namelist *c_files;
        struct  subcmd *c_cmds;
        struct  cmd *c_next;
@@ -95,8 +97,6 @@ extern int options;           /* global options */
 extern int nerrs;              /* number of errors seen */
 extern int rem;                        /* remote file descriptor */
 extern int iamremote;          /* acting as remote server */
 extern int nerrs;              /* number of errors seen */
 extern int rem;                        /* remote file descriptor */
 extern int iamremote;          /* acting as remote server */
-extern int filec;              /* number of files to update */
-extern char **filev;           /* list of files/directories to update */
 extern char tmpfile[];         /* file name for logging changes */
 extern struct passwd *pw;      /* pointer to static area used by getpwent */
 extern struct group *gr;       /* pointer to static area used by getgrent */
 extern char tmpfile[];         /* file name for logging changes */
 extern struct passwd *pw;      /* pointer to static area used by getpwent */
 extern struct group *gr;       /* pointer to static area used by getgrent */
index a55a5f0..ae30109 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)docmd.c     4.18 (Berkeley) 84/03/19";
+static char *sccsid = "@(#)docmd.c     4.19 (Berkeley) 84/04/06";
 #endif
 
 #include "defs.h"
 #endif
 
 #include "defs.h"
@@ -20,6 +20,8 @@ docmds(argc, argv)
        char **argv;
 {
        register struct cmd *c;
        char **argv;
 {
        register struct cmd *c;
+       register struct namelist *f;
+       register char **cpp;
        extern struct cmd *cmds;
 
        signal(SIGHUP, cleanup);
        extern struct cmd *cmds;
 
        signal(SIGHUP, cleanup);
@@ -28,12 +30,27 @@ docmds(argc, argv)
        signal(SIGTERM, cleanup);
 
        for (c = cmds; c != NULL; c = c->c_next) {
        signal(SIGTERM, cleanup);
 
        for (c = cmds; c != NULL; c = c->c_next) {
+               if (argc) {
+                       for (cpp = argv; *cpp; cpp++) {
+                               if (c->c_label != NULL &&
+                                   strcmp(c->c_label, (*cpp)+1) == 0) {
+                                       cpp = NULL;
+                                       goto found;
+                               }
+                               for (f = c->c_files; f != NULL; f = f->n_next)
+                                       if (strcmp(f->n_name, *cpp) == 0)
+                                               goto found;
+                       }
+                       continue;
+               } else
+                       cpp = NULL;
+       found:
                switch (c->c_type) {
                case ARROW:
                switch (c->c_type) {
                case ARROW:
-                       doarrow(c->c_files, c->c_name, c->c_cmds);
+                       doarrow(cpp, c->c_files, c->c_name, c->c_cmds);
                        break;
                case DCOLON:
                        break;
                case DCOLON:
-                       dodcolon(c->c_files, c->c_name, c->c_cmds);
+                       dodcolon(cpp, c->c_files, c->c_name, c->c_cmds);
                        break;
                default:
                        fatal("illegal command type %d\n", c->c_type);
                        break;
                default:
                        fatal("illegal command type %d\n", c->c_type);
@@ -45,13 +62,15 @@ docmds(argc, argv)
 /*
  * Process commands for sending files to other machines.
  */
 /*
  * Process commands for sending files to other machines.
  */
-doarrow(files, rhost, cmds)
+doarrow(filev, files, rhost, cmds)
+       char **filev;
        struct namelist *files;
        char *rhost;
        struct subcmd *cmds;
 {
        register struct namelist *f;
        register struct subcmd *sc;
        struct namelist *files;
        char *rhost;
        struct subcmd *cmds;
 {
        register struct namelist *f;
        register struct subcmd *sc;
+       register char **cpp;
        int n, ddir;
 
        if (debug)
        int n, ddir;
 
        if (debug)
@@ -81,19 +100,15 @@ doarrow(files, rhost, cmds)
                }
        }
        for (f = files; f != NULL; f = f->n_next) {
                }
        }
        for (f = files; f != NULL; f = f->n_next) {
-#ifdef notdef
-               if (filec) {
-                       register char **cpp;
-
+               if (filev) {
                        for (cpp = filev; *cpp; cpp++)
                        for (cpp = filev; *cpp; cpp++)
-                               if (!strcmp(f->b_name, *cpp))
+                               if (strcmp(f->n_name, *cpp) == 0)
                                        goto found;
                        if (!nflag)
                                (void) fclose(lfp);
                        continue;
                }
        found:
                                        goto found;
                        if (!nflag)
                                (void) fclose(lfp);
                        continue;
                }
        found:
-#endif
                n = 0;
                for (sc = cmds; sc != NULL; sc = sc->sc_next) {
                        if (sc->sc_type != INSTALL)
                n = 0;
                for (sc = cmds; sc != NULL; sc = sc->sc_next) {
                        if (sc->sc_type != INSTALL)
@@ -230,7 +245,8 @@ extern      char target[], *tp;
 /*
  * Process commands for comparing files to time stamp files.
  */
 /*
  * Process commands for comparing files to time stamp files.
  */
-dodcolon(files, stamp, cmds)
+dodcolon(filev, files, stamp, cmds)
+       char **filev;
        struct namelist *files;
        char *stamp;
        struct subcmd *cmds;
        struct namelist *files;
        char *stamp;
        struct subcmd *cmds;
@@ -273,15 +289,13 @@ dodcolon(files, stamp, cmds)
        }
 
        for (f = files; f != NULL; f = f->n_next) {
        }
 
        for (f = files; f != NULL; f = f->n_next) {
-#ifdef notdef
-               if (filec) {
+               if (filev) {
                        for (cpp = filev; *cpp; cpp++)
                        for (cpp = filev; *cpp; cpp++)
-                               if (!strcmp(b->b_name, *cpp))
+                               if (strcmp(f->n_name, *cpp) == 0)
                                        goto found;
                        continue;
                }
        found:
                                        goto found;
                        continue;
                }
        found:
-#endif
                tp = NULL;
                cmptime(f->n_name);
        }
                tp = NULL;
                cmptime(f->n_name);
        }
index 0920c64..465a2c3 100644 (file)
@@ -1,6 +1,6 @@
 %{
 #ifndef lint
 %{
 #ifndef lint
-static char *sccsid = "@(#)gram.y      4.8 (Berkeley) 84/02/09";
+static char *sccsid = "@(#)gram.y      4.9 (Berkeley) 84/04/06";
 #endif
 
 #include "defs.h"
 #endif
 
 #include "defs.h"
@@ -17,14 +17,15 @@ struct      subcmd *last_sc;
 %term RP       3
 %term SM       4
 %term ARROW    5
 %term RP       3
 %term SM       4
 %term ARROW    5
-%term DCOLON   6
-%term NAME     7
-%term STRING   8
-%term INSTALL  9
-%term NOTIFY   10
-%term EXCEPT   11
-%term SPECIAL  12
-%term OPTION   13
+%term COLON    6
+%term DCOLON   7
+%term NAME     8
+%term STRING   9
+%term INSTALL  10
+%term NOTIFY   11
+%term EXCEPT   12
+%term SPECIAL  13
+%term OPTION   14
 
 %union {
        int intval;
 
 %union {
        int intval;
@@ -48,10 +49,16 @@ command:      NAME EQUAL namelist = {
                        (void) lookup($1, INSERT, $3);
                }
                | namelist ARROW namelist cmdlist = {
                        (void) lookup($1, INSERT, $3);
                }
                | namelist ARROW namelist cmdlist = {
-                       insert($1, $3, $4);
+                       insert(NULL, $1, $3, $4);
+               }
+               | NAME COLON namelist ARROW namelist cmdlist = {
+                       insert($1, $3, $5, $6);
                }
                | namelist DCOLON NAME cmdlist = {
                }
                | namelist DCOLON NAME cmdlist = {
-                       append($1, $3, $4);
+                       append(NULL, $1, $3, $4);
+               }
+               | NAME COLON namelist DCOLON NAME cmdlist = {
+                       append($1, $3, $5, $6);
                }
                | error
                ;
                }
                | error
                ;
@@ -203,8 +210,10 @@ again:
                                        break;
                                }
                        }
                                        break;
                                }
                        }
-                       if (c == '\n')
+                       if (c == '\n') {
+                               yylineno++;
                                c = ' '; /* can't send '\n' */
                                c = ' '; /* can't send '\n' */
+                       }
                        *cp1++ = c;
                }
                if (c != '"')
                        *cp1++ = c;
                }
                if (c != '"')
@@ -213,11 +222,11 @@ again:
                yylval.string = makestr(yytext);
                return(STRING);
 
                yylval.string = makestr(yytext);
                return(STRING);
 
-       case ':':  /* :: */
+       case ':':  /* : or :: */
                if ((c = getc(fin)) == ':')
                        return(DCOLON);
                ungetc(c, fin);
                if ((c = getc(fin)) == ':')
                        return(DCOLON);
                ungetc(c, fin);
-               c = ':';
+               return(COLON);
        }
        cp1 = yytext;
        cp2 = &yytext[INMAX - 1];
        }
        cp1 = yytext;
        cp2 = &yytext[INMAX - 1];
@@ -237,7 +246,7 @@ again:
                }
                *cp1++ = c;
                c = getc(fin);
                }
                *cp1++ = c;
                c = getc(fin);
-               if (c == EOF || any(c, " \t()=;\n")) {
+               if (c == EOF || any(c, " \"'\t()=;:\n")) {
                        ungetc(c, fin);
                        break;
                }
                        ungetc(c, fin);
                        break;
                }
@@ -295,7 +304,8 @@ any(c, str)
 /*
  * Insert or append ARROW command to list of hosts to be updated.
  */
 /*
  * Insert or append ARROW command to list of hosts to be updated.
  */
-insert(files, hosts, subcmds)
+insert(label, files, hosts, subcmds)
+       char *label;
        struct namelist *files, *hosts;
        struct subcmd *subcmds;
 {
        struct namelist *files, *hosts;
        struct subcmd *subcmds;
 {
@@ -326,6 +336,7 @@ insert(files, hosts, subcmds)
                        fatal("ran out of memory\n");
                nc->c_type = ARROW;
                nc->c_name = h->n_name;
                        fatal("ran out of memory\n");
                nc->c_type = ARROW;
                nc->c_name = h->n_name;
+               nc->c_label = label;
                nc->c_files = files;
                nc->c_cmds = subcmds;
                nc->c_next = c;
                nc->c_files = files;
                nc->c_cmds = subcmds;
                nc->c_next = c;
@@ -343,7 +354,8 @@ insert(files, hosts, subcmds)
  * Append DCOLON command to the end of the command list since these are always
  * executed in the order they appear in the distfile.
  */
  * Append DCOLON command to the end of the command list since these are always
  * executed in the order they appear in the distfile.
  */
-append(files, stamp, subcmds)
+append(label, files, stamp, subcmds)
+       char *label;
        struct namelist *files;
        char *stamp;
        struct subcmd *subcmds;
        struct namelist *files;
        char *stamp;
        struct subcmd *subcmds;
@@ -355,6 +367,7 @@ append(files, stamp, subcmds)
                fatal("ran out of memory\n");
        c->c_type = DCOLON;
        c->c_name = stamp;
                fatal("ran out of memory\n");
        c->c_type = DCOLON;
        c->c_name = stamp;
+       c->c_label = label;
        c->c_files = expand(files, E_ALL);
        c->c_cmds = subcmds;
        c->c_next = NULL;
        c->c_files = expand(files, E_ALL);
        c->c_cmds = subcmds;
        c->c_next = NULL;
index 8ab9ba8..d36dcb7 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)main.c      4.10 (Berkeley) 84/02/09";
+static char *sccsid = "@(#)main.c      4.11 (Berkeley) 84/04/06";
 #endif
 
 #include "defs.h"
 #endif
 
 #include "defs.h"