home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume6 / newbatcha / main.c < prev    next >
Encoding:
C/C++ Source or Header  |  1986-11-30  |  699 b   |  48 lines

  1. /*
  2.  *
  3.  *    main.c - for nbatcher
  4.  *
  5.  *    R.J. Esposito
  6.  *    Bell of Penna.
  7.  *    June 1986
  8.  *
  9.  */
  10.  
  11. #include <stdio.h>
  12. #include "nbatcher.h"
  13.  
  14. main()
  15. {
  16.     int    uid;
  17.     FILE    *cfp;
  18.     char    fbuf[BUFSIZ];
  19.  
  20.     uid = getuid();
  21.  
  22.     if (uid && uid != NEWSUID)
  23.         xerror ("permission denied - not NEWSUSER\n");
  24.  
  25.     if (chdir(LIBDIR) < 0)
  26.         xerror ("can't chdir to %s\n", LIBDIR);
  27.  
  28.     if ((cfp=fopen("nbatcher.ctl", "r")) == NULL)
  29.         xerror ("no `batcher.ctl' file found\n");
  30.  
  31.     if (isatty(0))
  32.         vflg = TRUE;
  33.  
  34.     while ((fgets(fbuf, sizeof(fbuf), cfp)) != NULL) {
  35.         if (fbuf[0] == '*' || fbuf[0] == '\n')
  36.             continue;
  37.         parse_entry (fbuf);
  38.         if (!work_to_do())
  39.             continue;
  40.         batch_it ();
  41.     }
  42.  
  43.     fclose (cfp);
  44.     unlink (tfile);
  45.     exit (0);
  46. }
  47.     
  48.