# 2.11BSD#431 - /usr/src/new/notes/src/nftimestamp.c

##### Functions

    main              X
    usage             X

##### Macros

    MAINLINE          X

       1: #define     MAINLINE
       2: #include    "parms.h"
       3: #include    "structs.h"
       4:
       5: #ifdef  RCSIDENT
       6: static char rcsid[] = "$Header: nftimestamp.c,v 1.7.0.1 86/02/12 11:27:13 notes Rel $";
       7: #endif	RCSIDENT
       8:
       9: /*
      10:  *	quickie that sets the specified timestamps to the specified
      11:  *	time.  no time means now.
      12:  *
      13:  *	Ray Essick		February 1986
      14:  */
      15:
      16: static int  Verbose = 0;
      17:
      18:
      19: main (argc, argv)
      20: int     argc;
      21: char  **argv;
      22: {
      23:     struct io_f io;
      24:     int     argn;
      25:     struct nflist_f *nfptr;
      26:     struct when_f   ztime;
      27:     char    buf[128];
      28:
      29:     if (argc == 1)
      30:     usage ();                   /* tell him how */
      31:     startup (argc, argv);               /* common init code */
      32:     gettime (&ztime);                   /* if no -t, use this */
      33:
      34:
      35:     for (argn = 1; argn < argc; argn++)
      36:     {
      37:     if (strcmp (argv[argn], "-v") == 0)     /* be noisy */
      38:     {
      39:         Verbose++;
      40:         continue;
      41:     }
      42:     if (strcmp (argv[argn], "-t") == 0)     /* set time */
      43:     {
      44:         if (++argn >= argc)
      45:         usage ();
      46:         switch (parsetime (argv[argn], &ztime))
      47:         {
      48:         case -1:                /* invalid date */
      49:             fprintf (stderr, "Unable to parse '%s'\n", argv[argn]);
      50:             exit (1);
      51:         case 2:                 /* future */
      52:             sprdate (&ztime, buf);
      53:             fprintf (stderr, "Time '%s' parses to the future as '%s'\n",
      54:                 argv[argn], buf);
      55:             exit (1);
      56:         case 0:                 /* just right */
      57:             sprdate (&ztime, buf);
      58:             fprintf (stderr, "Time parsed as %s\n", buf);
      59:             break;
      60:         }
      61:         continue;
      62:     }
      63:     if (strcmp (argv[argn], "-f") == 0)
      64:     {
      65:         argn++;
      66:         if (argn >= argc)
      67:         {
      68:         usage ();
      69:         }
      70:         readrc (argv[argn]);
      71:         continue;
      72:     }
      73:     if (strcmp (argv[argn], "-u") == 0)     /* specify user */
      74:     {
      75:         if (globuid != Notesuid)
      76:         {
      77:         fprintf (stderr, "Only %s can specify -u user\n", NOTES);
      78:         exit (1);
      79:         }
      80:         argn++;
      81:         if (argn >= argc)
      82:         {
      83:         usage ();
      84:         }
      85:         strcpy (Seqname, argv[argn]);
      86:         continue;
      87:     }
      88:     /*
      89: 	 * must be a notesfile
      90: 	 */
      91:     expand (argv[argn]);                /* load it */
      92:     }
      93:
      94:     while ((nfptr = nextgroup ()) != (struct nflist_f *) NULL)
      95:     {
      96:     /*
      97: 	 * open it to make sure it exists.
      98: 	 */
      99:     if (init (&io, nfptr -> nf_name) < 0)       /* open */
     100:     {
     101:         printf ("%s:	couldn't open\n", nfptr -> nf_name);
     102:         continue;
     103:     }
     104:     if (Verbose)
     105:     {
     106:         fprintf (stdout, "%s\n", nfptr -> nf_name);
     107:         fflush (stdout);
     108:     }
     109:     /*
     110: 	 * go get the timestamp, update, and replace
     111: 	 * only update it if he has read permission in the nf.
     112: 	 * exception -- when notes uses -u, give him whatever he
     113: 	 * wants. (he will have read permission in such a case).
     114: 	 */
     115:     if (allow (&io, READOK))
     116:     {
     117:         fixlast (&ztime, io.nf, NORMSEQ, Seqname);
     118:     }
     119:
     120:     closenf (&io);
     121:     }
     122:     exit (0);                       /* all done */
     123: }
     124:
     125: usage (name)                        /* how to invoke */
     126: char   *name;
     127: {
     128:     fprintf (stderr,
     129:         "Usage: %s [-v] [-u sequencer] [-t timestamp] <nfspec> [<notesfile>...]\n",
     130:         name);
     131:     fprintf (stderr, "<nfspec> ::= <notesfile> | -f <filename>\n");
     132:     exit (1);
     133: }

#### Defined functions

main defined in line 19; never used
usage defined in line 125; used 4 times

- in line 30, 45, 68, 83

#### Defined variables

Verbose defined in line 16; used 2 times

- in line 39, 104

rcsid defined in line 6; never used

#### Defined macros

MAINLINE defined in line 1; never used

Last modified: 1986-02-12 Generated: 2016-12-26 | Generated by src2html V0.67 page hit count: 835 |