home *** CD-ROM | disk | FTP | other *** search
/ Oakland CPM Archive / oakcpm.iso / cpm / asmutl / pmake2.lbr / PSET.C < prev    next >
Encoding:
C/C++ Source or Header  |  1986-11-17  |  1.5 KB  |  79 lines

  1. /* set -- set/display file attributes from file                         */
  2. /* copyright 1984  Michael M Rubenstein                                 */
  3.  
  4. #include <sysio.h>
  5. #include <buff.h>
  6.  
  7. #define MAXLINE         32
  8.  
  9. int                        modbit;
  10.  
  11. extern FCB              dfcb_;
  12. extern char             dbuff_[];
  13.  
  14. extern unsigned         c_user;
  15.  
  16. main()
  17. {
  18.   struct FILE           f;
  19.   static char           s[MAXLINE + 1];
  20.   static int            i;
  21.   static int            c;
  22.  
  23.   if (dfcb_.name1.fname[0] == ' ' || dfcb_.name1.fname[0] == '?')
  24.     error("syntax:  pset <setfile>\n");
  25.  
  26.   strncpy(&f, &dfcb_, sizeof(FCB));
  27.  
  28.   if (open(&f) == 0xff)
  29.     error("pset: cannot open input file");
  30.   f.f_buff = dbuff_;
  31.   f.f_bufl = f.f_bufc = 128;
  32.  
  33.   while ((c = getc(&f)) != EOF && c != CPMEOF)
  34.   {
  35.     if (c <= ' ')
  36.     {
  37.       if (i)
  38.       {
  39.         s[i] = '\0';
  40.         setdone(s);
  41.         i = 0;
  42.       }
  43.     }
  44.     else
  45.       if (i < MAXLINE)
  46.         s[i++] = c;
  47.   }
  48.  
  49.   if (i)
  50.   {
  51.     s[i] = '\0';
  52.     setdone(s);
  53.   }
  54.  
  55.   close(&f);
  56. }
  57.  
  58. /* mark a file as done                                                      */
  59. setdone(s)
  60.   char                  *s;
  61. {
  62.   static unsigned       user;
  63.  
  64.   user = getusr();
  65.   setfcb(s, &dfcb_);
  66.   setusr(c_user);
  67.   if (open(&dfcb_) != 0xff)
  68.   {
  69.     close(&dfcb_);
  70.     dfcb_.name1.fname[modbit] |= 0x80;
  71.     filatt(&dfcb_);
  72.   }
  73.   setusr(user);
  74. }
  75.    s[MAXLINE + 1];
  76.   static int            i;
  77.   static int            c;
  78.  
  79.   if (dfcb_.name