Annotation of 43BSD/contrib/mh/support/bboards/bbtar.c, revision 1.1.1.1

1.1       root        1: /* bbtar.c - generate the names of archive files to be put to tape */
                      2: 
                      3: /* Usage:
                      4: 
                      5:        % cd ~bboards/archive           # followed by one of:
                      6: 
                      7:        % tar cv `bbtar private`        # to save private BBoard archives
                      8:        % tar cv `bbtar public`         # to save public BBoard archives
                      9:        % tar cv `bbtar`                # to save all BBoard archives
                     10: 
                     11:  */
                     12: 
                     13: 
                     14: #include <pwd.h>
                     15: #include <stdio.h>
                     16: #include <sys/types.h>
                     17: #include <sys/stat.h>
                     18: #include "../zotnet/bboards.h"
                     19: 
                     20: 
                     21: #define        NOTOK   (-1)
                     22: 
                     23: 
                     24: static int  private = 0;
                     25: 
                     26: static char archives[BUFSIZ];
                     27: 
                     28: 
                     29: struct passwd  *getpwnam ();
                     30: 
                     31: /*  */
                     32: 
                     33: /* ARGSUSED */
                     34: 
                     35: main (argc, argv)
                     36: int     argc;
                     37: char  **argv;
                     38: {
                     39:     struct bboard  *bb;
                     40:     struct passwd  *pw;
                     41: 
                     42:     if ((pw = getpwnam (BBOARDS)) == NULL)
                     43:        exit (1);
                     44:     (void) sprintf (archives, "%s/archive/", pw -> pw_dir);
                     45: 
                     46:     if (argc > 1)
                     47:        private = strcmp (argv[1], "private") == 0 ? 1
                     48:            : strcmp (argv[1], "public") == 0 ? -1
                     49:            : 0;
                     50: 
                     51:     (void) setbbent (SB_STAY);
                     52:     while (bb = getbbent ())
                     53:        process (bb);
                     54:     (void) endbbent ();
                     55: 
                     56:     exit (0);
                     57: }
                     58: 
                     59: /*  */
                     60: 
                     61: static  process (bb)
                     62: struct bboard  *bb;
                     63: {
                     64:     struct stat st;
                     65: 
                     66:     if (stat (bb -> bb_archive, &st) == NOTOK)
                     67:        return;
                     68:     if (strncmp (archives, bb -> bb_archive, strlen (archives)) == 0)
                     69:        bb -> bb_archive += strlen (archives);
                     70: 
                     71:     if (private == 0)
                     72:        printf ("%s\n", bb -> bb_archive);
                     73:     else
                     74:        if ((st.st_mode & 0444) != 0444 ? (private > 0) : (private < 0))
                     75:            printf ("%s\n", bb -> bb_archive);
                     76: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.