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

1.1       root        1: #define        MAINLINE
                      2: #ifdef RCSIDENT
                      3: static char rcsid[] = "$Header: rmnf.c,v 1.7 85/01/18 15:39:00 notes Rel $";
                      4: #endif RCSIDENT
                      5: 
                      6: /*
                      7:  *     rmnf - remove notefiles 
                      8:  *     rmnf removes the notefiles specified on the control card.
                      9:  *     It also goes through and cleans out the sequencer files
                     10:  *     that had entries for that notefile.
                     11:  *
                     12:  *     Since this can sort of destroy a lot of information, we
                     13:  *     ask for confirmation of the removal.
                     14:  *
                     15:  *     Original Coding: Ray Essick     December 1981
                     16:  */
                     17: #include "parms.h"
                     18: #include "structs.h"
                     19: 
                     20: main (argc, argv)
                     21: char  **argv;
                     22: {
                     23:     int     i;
                     24:     int     c;
                     25:     int     start = 1;                                 /* argv to start at */
                     26:     int     forced = 0;                                        /* -f flag */
                     27:     struct nflist_f *nfptr;
                     28: 
                     29:     startup (argc, argv);                              /* common initialization */
                     30: 
                     31:     if (globuid != Notesuid)
                     32:     {
                     33:        printf ("You are not allowed to remove notefiles\n");
                     34:        exit (BAD);
                     35:     }
                     36: 
                     37:     if (argc == 1)
                     38:     {
                     39:        printf ("Usage: %s [-f] notefile [notefile ...]\n", argv[0]);
                     40:        exit (BAD);
                     41:     }
                     42: 
                     43:     if (!strcmp (argv[start], "-f"))                   /* don't ask him */
                     44:     {
                     45:        forced++;
                     46:        start++;
                     47:     }
                     48: 
                     49:     for (i = start; i < argc; i++)
                     50:     {
                     51:        if (argv[i][0] == '/')                          /* explicit names */
                     52:        {
                     53:            printf ("%s: Won't remove %s\n", argv[0], argv[i]);
                     54:            continue;
                     55:        }
                     56:        expand (argv[i]);                               /* expand it */
                     57:     }
                     58: 
                     59:     while ((nfptr = nextgroup ()) != (struct nflist_f *) NULL)
                     60:     {
                     61:        if (chkpath (nfptr -> nf_name) == -1)
                     62:        {
                     63:            printf ("%s: Bad notefile name\n", nfptr -> nf_name);
                     64:            continue;
                     65:        }
                     66:        if (forced == 0)
                     67:        {
                     68:            printf ("Really remove notesfile %s? ", nfptr -> nf_name);
                     69:            c = getchar ();                             /* grab 1 from the tty */
                     70:            if (c != '\n')
                     71:                while (getchar () != '\n');             /* suck to eol */
                     72:            if (c != 'y')
                     73:                continue;                               /* don't delete */
                     74:        }
                     75:        x (chdir (Mstdir) < 0, "rmnf: bad chdir to MSTDIR");
                     76:        if (chdir (nfptr -> nf_name) < 0)
                     77:        {
                     78:            printf ("%s: Can't delete or non-existent\n", nfptr -> nf_name);
                     79:            continue;
                     80:        }
                     81: 
                     82: #ifndef        FASTFORK
                     83:        dounix ("rm -f *", 0, 0);                       /* remove the files */
                     84: #else
                     85:        dounix (0, 0, hisshell, "-c", "rm -f *", 0, 0);
                     86: #endif
                     87: 
                     88:        x (chdir ("..") < 0, "rmnf: bad chdir ..");
                     89: 
                     90: #ifndef        FASTFORK
                     91:        {
                     92:            char    cmdline[CMDLEN];
                     93:            sprintf (cmdline, "rmdir %s", nfptr -> nf_name);/* remove directory */
                     94:            dounix (cmdline, 0, 0);                     /* execute command */
                     95:        }
                     96: #else
                     97:        dounix (0, 0, "/bin/rmdir", nfptr -> nf_name, 0, 0, 0);
                     98: #endif
                     99: 
                    100:        printf ("%s: Deleted\n", nfptr -> nf_name);
                    101: 
                    102: /*     now we get to remove the sequencer entries 
                    103:  *     This is a little complicated for sitting and typing from the tope
                    104:  *     of my head, so I will write it out later and type it in.
                    105:  *     Have to do stuff which include opening the sequencer directory
                    106:  *     and reading all the names from it to get the file names..
                    107:  *     Then have to sequence through each file doing
                    108:  *      while ( more) { read; if (not one deleting) {write;count++} }
                    109:  *     Also if don't write any - unlink the file.
                    110:  *
                    111:  */
                    112:     }
                    113:     exit (GOOD);
                    114: }

unix.superglobalmegacorp.com

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