home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 11 Util / 11-Util.zip / TIMEXSRC.ZIP / TIMEX.H < prev    next >
C/C++ Source or Header  |  1990-03-28  |  6KB  |  181 lines

  1. /* timex.h -- global definitions for timex program.
  2.  
  3.     February 1990    Mark E. Mallett, Personal Workstation Magazine.
  4.  
  5. This file contains definitions that are used in interaction with
  6. the TIMEX program.
  7.  
  8. */
  9.  
  10. #ifndef    H_TIMEX                /* Ordain multiple inclusions */
  11. #define H_TIMEX
  12.  
  13. #ifndef TRUE
  14. #define TRUE    1
  15. #define FALSE   0
  16. #endif  /* TRUE */
  17.  
  18. #ifndef NUL
  19. #define NUL     '\0'
  20. #endif  /* NUL */
  21.  
  22.  
  23. /* Configuration */
  24. #define DBFNAME         "\\TIMEX\\TIMEX.DB"
  25. #define LOGFNAME        "\\TIMEX\\TIMEX.LOG"
  26. #define REQPIPE         "\\PIPE\\TIMEX" /* Name of the request pipe */
  27.  
  28. /* Alignment control. */
  29. #define WORDALIGN       sizeof(WORD)    /* Align words to this many bytes */
  30. #define LONGALIGN       sizeof(LONG)    /*       longs */
  31.  
  32.  
  33. /* Portable type definitions: adjust these to your machine. */
  34.  
  35. typedef unsigned char   UBYTE;
  36. typedef signed char     SBYTE;
  37. typedef short int       WORD;           /* 16 bit */
  38. typedef unsigned short int  UWORD;
  39.  
  40. #ifdef OUT
  41. typedef long int        LONG;           /* 32 bit */
  42. typedef unsigned long int  ULONG;
  43. #endif
  44.  
  45. typedef long int        LONGINT;        /* 32 bit */
  46. typedef unsigned long int  ULONGINT;
  47.  
  48. /* Error and status codes */
  49.  
  50. #define EC_OK           0               /* OK... */
  51. #define EC_NOTOK        1               /* General error */
  52. #define EC_MEMORY       2               /* Memory allocation */
  53. #define EC_OPEN         3               /* File open */
  54.  
  55. #define EC_OTHER        0x100           /* Local error codes start here */
  56.  
  57.  
  58. typedef                                 /* Action classifications */
  59.   enum {
  60.         ACTION_RUN,                     /* Run a program */
  61.   }                     ACTTYPE;
  62.  
  63.  
  64. typedef                                 /* Day-of classifications */
  65.   enum {
  66.         DAYOF_MONTH,
  67.         DAYOF_WEEK
  68.   }                     DAYOF;
  69.  
  70.  
  71. typedef                                 /* Request and response codes */
  72.   enum {
  73.         REQ_ADD=0,                      /* Add an event */
  74.         REQ_MODIFY,                     /* Modify an event */
  75.         REQ_DEL,                        /* Delete an event */
  76.         REQ_GET,                        /* Get an event */
  77.         REQ_GETNEXT,                    /* Get next event */
  78.     
  79.         RSP_OK=0x100,                   /* General OK response */
  80.         RSP_ERROR,                      /* Error happened */
  81.         RSP_EVENT                       /* Body of an event */
  82.   }                     TMXMSGCODE;
  83.  
  84.  
  85. typedef                                 /* Tags for transmitting events */
  86.   enum {
  87.         ETAG_NAME,                      /* Name */
  88.         ETAG_YEARS,                     /* Year list */
  89.         ETAG_MONTHS,                    /* Mask of months */
  90.         ETAG_DAYOF,                     /* Day-of type */
  91.         ETAG_HOURS,                     /* Hours mask */
  92.         ETAG_MINS,                      /* Minutes mask */
  93.         ETAG_PRIO,                      /* Priority class and value */
  94.         ETAG_ACTTYPE,                   /* Action type */
  95.         ETAG_ACTARG,                    /* Action arg */
  96.  
  97.         ETAG_END=0xff                   /* End of packed event */
  98.   }                     ETAG;
  99.  
  100.  
  101. /*
  102.  
  103. *//*    structures */
  104.  
  105.  
  106. typedef                                 /* A year specification */
  107.   struct {
  108.     int         y_first;                /* First (inclusive) */
  109.     int         y_last;                 /* Last (inclusive) */
  110.   }    YEARSPEC;
  111.  
  112. typedef                                 /* Event fields */
  113.   struct {
  114.     char        *ev_nameP;              /* Ptr to event name */
  115.     int         ev_yearC;               /* Number of specified years */
  116.     YEARSPEC    *ev_yearP;              /* Ptr to list of years. */
  117.     UWORD       ev_months;              /* Which months apply (mask) */
  118.     DAYOF       ev_dayof;               /* Day-of classification */
  119.     ULONG       ev_dayofs;              /* Day-of mask */
  120.     ULONG       ev_hours;               /* Hour mask */
  121.     ULONG       ev_mins[2];             /* Minutes mask */
  122.     SBYTE       ev_priclass;            /* Priority class */
  123.     SBYTE       ev_prival;              /* Priority value */
  124.     ACTTYPE     ev_acttype;             /* Action classification */
  125.     char        *ev_actargP;            /* Ptr to action argument */
  126.   }    EVENT;
  127.  
  128.  
  129. typedef                                 /* Format of a message */
  130.   struct {
  131.     TMXMSGCODE  m_code;                 /* Message code */
  132.     int         m_len;                  /* Message length */
  133.   }    TMXMSG;
  134.  
  135.  
  136. typedef                                 /* Format of a REQ_GET request */
  137.   struct {
  138.     TMXMSG      g_msghdr;               /* Message header */
  139.     char        g_evname[1];            /* NUL-terminated event name. */
  140.   }    TMXREQ_GET;
  141.  
  142. typedef                                 /* Format of REQ_GETNEXT request */
  143.   struct {
  144.     TMXMSG      g_msghdr;               /* Message header */
  145.     char        g_evname[1];            /* NUL-terminated event name. */
  146.   }    TMXREQ_GETNEXT;
  147.  
  148. typedef                                 /* Format of REQ_DEL request */
  149.   struct {
  150.     TMXMSG      d_msghdr;               /* Message header */
  151.     char        d_evname[1];            /* Name of event to delete. */
  152.   }    TMXREQ_DEL;
  153.  
  154.  
  155. typedef                                 /* Format of an error response */
  156.   struct {
  157.     TMXMSG      e_msghdr;               /* Message header */
  158.     int         e_code;                 /* Code, if any */
  159.     char        e_msg[1];               /* Error message text */
  160.   }     TMXRSP_ERR;
  161.  
  162.  
  163. /* Prototypes for functions used in TIMEXUA and TIMEXBA */
  164. void *emalloc( char *facP, char *itemP, int size );
  165.  
  166. void *erealloc( char *facP, char *itemP, char *oldP, int size );
  167.  
  168. void error( int errcode, char *fmtP, ... );
  169.  
  170. char *gettoken( char *stringP, char *bufP, int buflen,
  171.                         char *vsepP, char *isepP );
  172.  
  173. char *newstr( char *facP, char *itemP, char *oldP );
  174.  
  175. int tkline( char *bufP, char *tbufP, char **tokv, int tokmax,
  176.                         char *vsepP, char *isepP );
  177.  
  178. void warning( int errcode, char *fmtP, ... );
  179.  
  180. #endif    /* H_TIMEX */
  181.