home *** CD-ROM | disk | FTP | other *** search
/ Otherware / Otherware_1_SB_Development.iso / amiga / utility / misc / cyber15.lha / CyberCron / Source / CyberCron.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-10-07  |  5.9 KB  |  223 lines

  1. #include <exec/types.h>
  2. #include <exec/nodes.h>
  3.  
  4. #include <exec/execbase.h>
  5. #include <exec/memory.h>
  6. #include <exec/ports.h>
  7. #include <exec/semaphores.h>
  8. #include <dos/rdargs.h>
  9. #include <dos/notify.h>
  10. #include <dos/dostags.h>
  11. #include <dos/datetime.h>
  12. #include <rexx/rxslib.h>
  13. #include <rexx/errors.h>
  14. #include <intuition/intuitionbase.h>
  15. #include <workbench/startup.h>
  16. #include <workbench/workbench.h>
  17. #include <utility/date.h>
  18.  
  19. #include <clib/exec_protos.h>
  20. extern struct ExecBase *SysBase;
  21. #include <pragmas/exec_libcall_lib.h>
  22.  
  23. #include <clib/dos_protos.h>
  24. extern struct DosLibrary *DOSBase;
  25. #include <pragmas/dos_lib.h>
  26.  
  27. #include <clib/rexxsyslib_protos.h>
  28. extern struct RxsLib *RexxSysBase;
  29. #include <pragmas/rexxsyslib_lib.h>
  30.  
  31. /* hack to get the ARexx ErrorMsg() function */
  32. struct NexxStr *ARexxErrorMsg(int);
  33. #pragma libcall RexxSysBase ARexxErrorMsg 60 081
  34.  
  35. #include <clib/icon_protos.h>
  36. extern struct Library *IconBase;
  37. #include <pragmas/icon_lib.h>
  38.  
  39. #include <clib/timer_protos.h>
  40. extern struct timerequest TimerIO;
  41. #define TimerBase (TimerIO.tr_node.io_Device)
  42. #include <pragmas/timer_lib.h>
  43.  
  44. #include <clib/intuition_protos.h>
  45. #include <pragmas/intuition_lib.h>
  46.  
  47. #include <clib/utility_protos.h>
  48. extern struct Library *UtilityBase;
  49. #include <pragmas/utility_lib.h>
  50.  
  51. #include <libraries/locale.h>
  52. #include <clib/locale_protos.h>
  53. #define LocaleBase LocaleInfo.li_LocaleBase
  54. #include <pragmas/locale_lib.h>
  55.  
  56. #include <clib/alib_protos.h>
  57.  
  58. #include <stdio.h>
  59. #include <string.h>
  60. #include <stdlib.h>
  61. #include <stdarg.h>
  62. #include <ctype.h>
  63. #include <dos.h>    /* for __emit() prototype */
  64.  
  65. #define CATCOMP_NUMBERS
  66. #include "CyberCronStrings.h"
  67.  
  68. #include "OwnDevUnit.h"
  69. #include "wb2cli.h"
  70.  
  71. #define SECSINDAY (86400)
  72. #define SECSINHOUR (3600)
  73. #define SECSINMINUTE (60)
  74.  
  75. #define JOB_TABLE_SIZE (256)
  76.  
  77. #define BIG_BUF_SIZE_BASE (1024)
  78. #define BIG_BUF_SIZE_XTRA (16)
  79. #define BIG_BUF_SIZE (BIG_BUF_SIZE_BASE + BIG_BUF_SIZE_XTRA)
  80.  
  81. #define LEAP(yr) (yr % 4 == 0 && yr % 100 != 0 || yr % 400 == 0)
  82.  
  83. /* this struct holds a system time in a way we can easily use it */
  84. typedef struct {
  85.     ULONG st_tvsecs;    /* as returned by the timer device */
  86.     UWORD st_Year;
  87.     UWORD st_Month;
  88.     UWORD st_Day;
  89.     UWORD st_Hour;
  90.     UWORD st_Min;
  91.     UWORD st_Sec;
  92.     UBYTE st_DOW;
  93. } SystemTime_t;
  94.  
  95. struct CyberNode {
  96.     struct Node    cn_Node;
  97. #define cn_Name cn_Node.ln_Name
  98.     STRPTR        cn_Command;
  99.     STRPTR        cn_Args;
  100.     STRPTR        cn_ReDirIn;
  101.     STRPTR        cn_ReDirOut;
  102.     STRPTR        cn_ReDirErr;
  103.     STRPTR        cn_CustomShell;
  104.     STRPTR        cn_SendToUser;
  105.     ULONG        cn_Stack;
  106.     BYTE        cn_Priority;
  107.     UBYTE        cn_DayOfWeek;
  108.     UWORD        cn_Month;
  109.     ULONG        cn_Day;
  110.     ULONG        cn_Hour;
  111.     ULONG        cn_HiMin;
  112.     ULONG        cn_LoMin;
  113.     ULONG        cn_DelayedCount;
  114.     BOOL        cn_CommandHasSpace;
  115.     UBYTE        cn_ObeyQueue;
  116.     UBYTE        cn_Flags;
  117. };
  118.  
  119. /* these are the possible values for the flags in cn_Flags */
  120. #define CNB_NOLOG   0        /* don't do log when running the command */
  121. #define CNB_REXX    1        /* start command as a rexx script */
  122. #define CNB_CRONTAB 2        /* node was generated by an entry in crontab
  123.                  * file */
  124. #define CNB_SYSSH   3        /* use system shell instead of user shell */
  125. #define CNB_OUTAPP  4        /* append to output redirection instead of
  126.                    overwrite */
  127. #define CNB_ERRAPP  5        /* append to error redirection instead of
  128.                    overwrite */
  129. #define CNB_EXECONE 6        /* run job once and then delete it */
  130.  
  131. #define CNF_NOLOG   (1L << CNB_NOLOG)
  132. #define CNF_REXX    (1L << CNB_REXX)
  133. #define CNF_CRONTAB (1L << CNB_CRONTAB)
  134. #define CNF_SYSSH   (1L << CNB_SYSSH)
  135. #define CNF_OUTAPP  (1L << CNB_OUTAPP)
  136. #define CNF_ERRAPP  (1L << CNB_ERRAPP)
  137. #define CNF_EXECONE (1L << CNB_EXECONE)
  138.  
  139. struct JobQueue {
  140.     ULONG    jq_Max;
  141.     ULONG    jq_Cur;
  142.     struct MinList jq_FIFOList;
  143. };
  144.  
  145. struct QueueFIFO {
  146.     struct MinNode qf_Node;
  147.     struct CyberNode *qf_CyberNode;
  148. };
  149.  
  150. struct SystemECdata {
  151.     UWORD    jobNo;
  152.     UBYTE    queueNo;
  153.     UBYTE    flags;
  154. };
  155.  
  156. /* stuff for handling our public semaphores. */
  157. struct MyPublicSema {
  158.     struct SignalSemaphore mps_Sema;
  159.     UBYTE *mps_SemaData;
  160.     ULONG mps_UseCount;
  161.     UBYTE mps_SemaName[4];
  162. };
  163.  
  164. /*
  165.  * here we have prototypes for all functions contained in or used by this
  166.  * file
  167.  */
  168. struct CyberNode *ParseEvent(STRPTR);
  169. void ParseBits(ULONG *, STRPTR);
  170. void UnParseBits(ULONG *, STRPTR, int, int);
  171. UWORD GetJobNum(void);
  172. void FreeJobNum(UWORD);
  173. void __stdargs Log(ULONG fmdId, ...);
  174. int __regargs main(char *cmdptr, int cmdlen, struct WBStartup *WBMsg);
  175. void ReadCronTab(void);
  176. BOOL GetARexxLib(void);
  177. void FreeARexxLib(void);
  178. void __stdargs ErrorMsg(ULONG fmtId, ...);
  179. void MyExit(int);
  180. void FreeEvents(BOOL);
  181. STRPTR WBtoCLIargs(struct WBStartup *WBMsg, STRPTR ArgTemplate);
  182. void StartSystemJob(struct CyberNode *cn);
  183. void StartRexxJob(struct CyberNode *cn);
  184. int __saveds __asm EndSystemJob(register __d0 int rc, register __d1 struct SystemECdata * data);
  185. void GetSystemTime(SystemTime_t *st, BOOL stIsSet);
  186. void ScanForJobs(void);
  187. void HandleRexxEvents(void);
  188. struct CyberNode *FindEvent(STRPTR name);
  189. BPTR SetupSendMail(STRPTR cmdName, STRPTR cmdArgs, STRPTR userName);
  190. struct MyPublicSema *InitMyPublicSemaphore(STRPTR semaName, ULONG semaDataSize);
  191. void FreeMyPublicSemaphore(struct MyPublicSema *mySema);
  192. ULONG EventNextExecutes(struct CyberNode *cn, SystemTime_t *st);
  193. BOOL ProcessQueue(struct CyberNode *cn, BOOL TimeMatch);
  194. void DeleteEvent(struct CyberNode *cn);
  195.  
  196. STRPTR __asm GetString(register __a0 struct LocaleInfo *li, register __d0 ULONG id);
  197.  
  198. extern void DoMsg(struct RexxMsg *, APTR, int, int);
  199.  
  200. void   rx_Shutdown(void);
  201. STRPTR rx_Version(void);
  202. void   rx_Suspend(void);
  203. void   rx_Resume(void);
  204. int    rx_NewEventFile(STRPTR);
  205. void   rx_CloseEventFile(void);
  206. int    rx_AddEvent(STRPTR);
  207. int    rx_DeleteRexxEvent(STRPTR);
  208. int    rx_DeleteEvent(STRPTR);
  209. void   rx_PurgeRexxEvents(void);
  210. STRPTR rx_ShowEvent(STRPTR);
  211. STRPTR rx_ListEvents(void);
  212. STRPTR rx_ShowStatus(void);
  213. int    rx_NewLogFile(STRPTR);
  214. void   rx_CloseLogFile(void);
  215. int    rx_SetQueueMax(STRPTR);
  216. int    rx_GetQueueMax(STRPTR);
  217. STRPTR rx_EventNextExec(STRPTR name);
  218. STRPTR rx_NextEventToExec(void);
  219. STRPTR rx_ExpandSSSC(int SSSC);
  220. STRPTR rx_SSSCtoASCII(int SSSC);
  221.  
  222. void __stdargs kprintf(STRPTR fmt, ...);
  223.