home *** CD-ROM | disk | FTP | other *** search
/ rtsi.com / 2014.01.www.rtsi.com.tar / www.rtsi.com / OS9 / TOP / USR / SRC / vcron.t.Z / vcron.t / VCRON / cron.h < prev    next >
Text File  |  1988-11-15  |  7KB  |  248 lines

  1. /* cron.h - header for vixie's cron
  2.  *
  3.  * $Header: cron.h,v 1.4 87/05/02 17:33:08 paul Exp $
  4.  * $Source: /usr/src/local/vix/cron/cron.h,v $
  5.  * $Revision: 1.4 $
  6.  * $Log:    cron.h,v $
  7.  * Revision 1.4  87/05/02  17:33:08  paul
  8.  * baseline for mod.sources release
  9.  * 
  10.  * Revision 1.3  87/03/31  12:07:13  paul
  11.  * more and more and more suggestions from rs@mirror
  12.  * 
  13.  * Revision 1.2  87/02/13  00:29:14  paul
  14.  * getting ready for beta test
  15.  * 
  16.  * Revision 1.1  87/02/13  00:26:01  paul
  17.  * Initial revision
  18.  *
  19.  * vix 14jan87 [0 or 7 can be sunday; thanks, mwm@berkeley]
  20.  * vix 30dec86 [written]
  21.  */
  22.  
  23. /* Copyright 1987 by Vixie Enterprises
  24.  * All rights reserved
  25.  *
  26.  * Distribute freely, except: don't sell it, don't remove my name from the
  27.  * source or documentation (don't take credit for my work), mark your changes
  28.  * (don't get me blamed for your possible bugs), don't alter or remove this
  29.  * notice.  Commercial redistribution is negotiable; contact me for details.
  30.  *
  31.  * Send bug reports, bug fixes, enhancements, requests, flames, etc., and
  32.  * I'll try to keep a version up to date.  I can be reached as follows:
  33.  * Paul Vixie, Vixie Enterprises, 329 Noe Street, San Francisco, CA, 94114,
  34.  * (415) 864-7013, {ucbvax!dual,ames,ucsfmis,lll-crg,sun}!ptsfa!vixie!paul.
  35.  */
  36.  
  37. #ifndef    _CRON_FLAG
  38. #define    _CRON_FLAG
  39.  
  40. #include <stdio.h>
  41. #include <ctype.h>
  42. #include "bitstring.h"
  43.  
  44. /*
  45.  * these are site-dependent
  46.  */
  47.             /*
  48.              * choose one of these MAILCMD commands.  I use
  49.              * /bin/mail for speed; it makes 'biff' go but doesn't
  50.              * do aliasing.  /usr/lib/sendmail does aliasing but is
  51.              * a hog for short messages.
  52.              */
  53.  
  54. # define CRONLOG "/dd/cronlog"
  55. # define CONSOLE "/nil"
  56.  
  57.                         /* the members of the user-group CRON_GRP are allowed
  58.                          * to use crontab ....
  59.                          */
  60. # define CRON_GRP "Cron"
  61.  
  62.             /* SPOOLDIR is where the crontabs live
  63.              */
  64. #define    SPOOLDIR    "/h0/SPOOL/VCRON"
  65.  
  66.             /* this lock-entry is used to signal the cron a change
  67.              * in a cron tab; 'cron' sees it and reloads its tables.
  68.              */
  69. # define POKECRON    "lck.cron"
  70.  
  71.             /* this is the name of the environment variable
  72.              * that contains the user name.  it isn't read by
  73.              * cron, but it is SET by crond in the environments
  74.              * it creates for subprocesses.  on BSD, it will
  75.              * always be USER; on SysV it could be LOGNAME or
  76.              * something else.
  77.              */
  78. #define    USERENV        "USER"
  79.  
  80. /*
  81.  * you shouldn't have to change anything after this
  82.  */
  83.  
  84.  
  85.     /* these are really immutable, and are
  86.      *   defined for symbolic convenience only
  87.      * TRUE, FALSE, and ERR must be distinct
  88.      */
  89. #define TRUE        1
  90. #define FALSE        0
  91.     /* system calls return this on success */
  92. #define OK        0
  93.     /*   or this on error */
  94. #define ERR        (-1)
  95.  
  96.     /* turn this on to get '-x' code */
  97. #define DEBUGGING    FALSE
  98.  
  99. #define STDIN        0    /* what is stdin's file descriptor? */
  100. #define STDOUT        1    /*   stdout's? */
  101. #define STDERR        2    /*   stderr's? */
  102. #define ERROR_EXIT    1    /* exit() with this will scare the shell */
  103. #define    OK_EXIT        0    /* exit() with this is considered 'normal' */
  104. #define    MAX_FNAME    100    /* max length of internally generated fn */
  105. #define    MAX_COMMAND    1000    /* max length of internally generated cmd */
  106. #define    MAX_TEMPSTR    100    /* obvious */
  107. #define    MAX_UNAME    20    /* max length of username, should be overkill */
  108. #define    ROOT_UID    0    /* don't change this, it really must be root */
  109. #define    DEXT        0x0001    /* extend flag for other debug masks */
  110. #define    DSCH        0x0002    /* scheduling debug mask */
  111. #define    DPROC        0x0004    /* process control debug mask */
  112. #define    DPARS        0x0008    /* parsing debug mask */
  113. #define    DMISC        0x0010    /* misc debug flag */
  114. #define    DCOUNT        5    /* how many debug bits are in use? */
  115.  
  116. #define    MAILSUBJ    "Subject: One of your commands"
  117. #define    REG        register
  118. #define    PPC_NULL    ((char **)NULL)
  119.  
  120. #define    Skip_Blanks(c, f) \
  121.             while (c == '\t' || c == ' ') \
  122.                 c = get_char(f);
  123.  
  124. #define    Skip_Nonblanks(c, f) \
  125.             while (c!='\t' && c!=' ' && c!='\n' && c != EOF) \
  126.                 c = get_char(f);
  127.  
  128. #define    Skip_Line(c, f) \
  129.             do {c = get_char(f);} while (c != '\n' && c != EOF);
  130.  
  131. #define    MkLower(ch)    (isupper(ch) ? tolower(ch) : ch)
  132. #define    MkUpper(ch)    (islower(ch) ? toupper(ch) : ch)
  133. #if DEBUGGING
  134. #define static
  135. #define    Set_LineNum(ln)    {Debug(DPARS|DEXT,"linenum=%d\n",ln); \
  136.              LINE_NUMBER = ln; \
  137.             }
  138. #else
  139. #define Set_LineNum(ln) LINE_NUMBER = ln;
  140. #endif
  141.  
  142. #define    FIRST_MINUTE    0
  143. #define    LAST_MINUTE    59
  144. #define    MINUTE_COUNT    (LAST_MINUTE - FIRST_MINUTE + 1)
  145.  
  146. #define    FIRST_HOUR    0
  147. #define    LAST_HOUR    23
  148. #define    HOUR_COUNT    (LAST_HOUR - FIRST_HOUR + 1)
  149.  
  150. #define    FIRST_DOM    1
  151. #define    LAST_DOM    31
  152. #define    DOM_COUNT    (LAST_DOM - FIRST_DOM + 1)
  153.  
  154. #define    FIRST_MONTH    1
  155. #define    LAST_MONTH    12
  156. #define    MONTH_COUNT    (LAST_MONTH - FIRST_MONTH + 1)
  157.  
  158. #define    FIRST_DOW    0
  159. #define    LAST_DOW    7
  160. #define    DOW_COUNT    (LAST_DOW - FIRST_DOW + 1)
  161.  
  162.             /* each users' crontab will be held as a list of
  163.              * the following structure.
  164.              */
  165.  
  166. typedef    struct    _entry
  167.     {
  168.         struct _entry    *next;
  169.         char        *cmd;
  170. # ifndef NOBIT
  171.         bit_decl(    minute,    MINUTE_COUNT    )
  172.         bit_decl(    hour,    HOUR_COUNT    )
  173.         bit_decl(    dom,    DOM_COUNT    )
  174.         bit_decl(    month,    MONTH_COUNT    )
  175.         bit_decl(    dow,    DOW_COUNT    )
  176. # else NOBIT
  177.         char minute[MINUTE_COUNT+1];
  178.         char hour[HOUR_COUNT+1];
  179.         char dom[DOM_COUNT+1];
  180.         char month[MONTH_COUNT+1];
  181.         char dow[DOW_COUNT+1];
  182. # endif NOBIT
  183.         int        dom_star, dow_star;
  184.     }
  185.     entry;
  186.  
  187.             /* the crontab database will be a list of the
  188.              * following structure, one element per user.
  189.              */
  190.  
  191. typedef    struct    _user
  192.     {
  193.         struct _user    *next;        /* next item in list */
  194.         int        uid;        /* uid from passwd file */
  195.         int        gid;        /* gid from passwd file */
  196.         char        **envp;        /* environ for commands */
  197.         entry        *crontab;    /* this person's crontab */
  198.     }
  199.     user;
  200.  
  201.                 /* in the C tradition, we only create
  202.                  * variables for the main program, just
  203.                  * extern them elsewhere.
  204.                  */
  205.  
  206. #ifdef MAIN_PROGRAM
  207.  
  208. # if !defined(LINT) && !defined(lint)
  209.         static char *copyright[] = {
  210.             "@(#) Copyright (C) 1987 by Vixie Enterprises",
  211.             "@(#) Copyright (C) 1988 in Parts By ram",
  212.             "@(#) All rights reserved"
  213.         };
  214. # endif
  215.  
  216.         char *MONTH_NAMES[] = {
  217.             "Jan", "Feb", "Mar", "Apr", "May", "Jun",
  218.             "Jul", "Aug", "Sep", "Oct", "Nov", "Dec",
  219.             NULL};
  220.         char *DOW_NAMES[] = {
  221.             "Sun","Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun",
  222.             NULL};
  223.         char *PROGNAME;
  224.         int LINE_NUMBER;
  225.  
  226. # if DEBUGGING
  227.         int DEBUG_FLAGS;
  228.         char *DEBUG_FLAG_NAMES[] = {    /* sync with #defines */
  229.             "ext", "sch", "proc", "pars", "misc",
  230.             NULL};
  231. # endif /* DEBUGGING */
  232.  
  233. #else /* !MAIN_PROGRAM */
  234.  
  235.         extern char    *MONTH_NAMES[];
  236.         extern char    *DOW_NAMES[];
  237.         extern char    *PROGNAME;
  238.         extern int    LINE_NUMBER;
  239. # if DEBUGGING
  240.                 extern void   Debug();
  241.         extern int    DEBUG_FLAGS;
  242.         extern char    *DEBUG_FLAG_NAMES[];
  243. # endif /* DEBUGGING */
  244. #endif /* MAIN_PROGRAM */
  245.  
  246.  
  247. #endif    /* _CRON_FLAG */
  248.