Annotation of 43BSD/contrib/notes/src/nfarchive.c, revision 1.1.1.1

1.1       root        1: #define        MAINLINE
                      2: #include "parms.h"
                      3: #include "structs.h"
                      4: 
                      5: #ifdef RCSIDENT
                      6: static char rcsid[] = "$Header: nfarchive.c,v 1.7 85/01/18 15:25:22 notes Rel $";
                      7: #endif RCSIDENT
                      8: 
                      9: /*
                     10:  *     nfarchive - will archive the specified notesfiles. All notes that
                     11:  *     have not been modofied in the last n days (default 14, settable
                     12:  *     by option on command line) will be archived and placed in
                     13:  *     the archive directory.
                     14:  *
                     15:  *     Ray Essick                      March 1982
                     16:  */
                     17: 
                     18: int     deleteonly;
                     19: int     dirmsgflag;                                    /* key on dir msg */
                     20: int     daysold = ARCHTIME;                            /* eligibility age */
                     21: int     worksetsize;                                   /* minimum to keep */
                     22: 
                     23: archone (nfname)
                     24: char   *nfname;
                     25: {
                     26:     return archiver (nfname, daysold, worksetsize, deleteonly, dirmsgflag);
                     27: }
                     28: 
                     29: 
                     30: main (argc, argv)
                     31: char  **argv;
                     32: {
                     33:     struct nflist_f *nfptr;
                     34:     int     i;
                     35: 
                     36:     startup (argc, argv);                              /* common init */
                     37: 
                     38:     if (argc == 1)
                     39:     {
                     40:        printf ("Usage: %s [-d] [-m+ or -m-] [-#] [-w#] [-f file] topic1 [topic2 ...]\n", argv[0]);
                     41:        exit (BAD);
                     42:     }
                     43: 
                     44:     if (globuid != Notesuid)
                     45:     {
                     46:        printf ("Sorry, only notes 'owner' can archive notes\n");
                     47:        exit (BAD);
                     48:     }
                     49: 
                     50:     deleteonly = 0;                                    /* default to archiving */
                     51:     dirmsgflag = DIRNOCARE;                            /* don't consider dirmessage */
                     52:     daysold = ARCHTIME;                                        /* default threshold */
                     53:     worksetsize = WORKSETSIZE;                         /* default to leave */
                     54: 
                     55:     for (i = 1; i < argc; i++)
                     56:     {
                     57:        if (argv[i][0] == '-')
                     58:            switch (argv[i][1])
                     59:            {
                     60:                case 'd':                               /* delete only, no archiving */
                     61:                    deleteonly = 1;
                     62:                    break;
                     63: 
                     64:                case 'm':                               /* director message status */
                     65:                    if (argv[i][2] == '-')
                     66:                        dirmsgflag = DIROFF;            /* delete when off */
                     67:                    else
                     68:                        dirmsgflag = DIRON;             /* only when on */
                     69:                                                        /* also if just "-m" */
                     70:                    break;
                     71: 
                     72:                case 'w':                               /* change workset size */
                     73:                    if (argv[i][2] == '\0')
                     74:                        worksetsize = WORKSETSIZE;      /* default */
                     75:                    else
                     76:                        worksetsize = atoi (&argv[i][2]);/* specified */
                     77:                    break;
                     78: 
                     79:                case '0':                               /* allow 0 days */
                     80:                case '1':                               /* change days old parameter */
                     81:                case '2': 
                     82:                case '3': 
                     83:                case '4': 
                     84:                case '5': 
                     85:                case '6': 
                     86:                case '7': 
                     87:                case '8': 
                     88:                case '9': 
                     89:                    daysold = atoi (&argv[i][1]);
                     90:                    break;
                     91: 
                     92:                case 'f':                               /* process a file */
                     93:                    if (++i == argc)                    /* no filename */
                     94:                    {
                     95:                        fprintf (stderr, "-f must be followed by filename\n");
                     96:                        exit (BAD);
                     97:                    }
                     98:                    readrc (argv[i]);
                     99:                    break;
                    100: 
                    101:                default: 
                    102:                    printf ("Bad switch: %c\n", argv[i][1]);
                    103:                    exit (BAD);
                    104:            }
                    105:        else
                    106:            expand (argv[i]);                           /* load it */
                    107:     }
                    108: 
                    109: /*
                    110:  *     now process things
                    111:  */
                    112: 
                    113:     while ((nfptr = nextgroup ()) != (struct nflist_f *) NULL)
                    114:        archone (nfptr -> nf_name);
                    115: 
                    116:     exit (GOOD);
                    117: }

unix.superglobalmegacorp.com

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