home *** CD-ROM | disk | FTP | other *** search
/ Otherware / Otherware_1_SB_Development.iso / amiga / utility / misc / cyber14.lha / CyberCron / Source / CyberCron.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-09-29  |  5.9 KB  |  221 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. extern struct LocaleBase *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. #include "CyberCronStrings.h"
  66.  
  67. #include "OwnDevUnit.h"
  68. #include "wb2cli.h"
  69.  
  70. #define SECSINDAY (86400)
  71. #define SECSINHOUR (3600)
  72. #define SECSINMINUTE (60)
  73.  
  74. #define JOB_TABLE_SIZE (256)
  75.  
  76. #define BIG_BUF_SIZE_BASE (1024)
  77. #define BIG_BUF_SIZE_XTRA (16)
  78. #define BIG_BUF_SIZE (BIG_BUF_SIZE_BASE + BIG_BUF_SIZE_XTRA)
  79.  
  80. #define LEAP(yr) (yr % 4 == 0 && yr % 100 != 0 || yr % 400 == 0)
  81.  
  82. /* this struct holds a system time in a way we can easily use it */
  83. typedef struct {
  84.     ULONG st_tvsecs;    /* as returned by the timer device */
  85.     UWORD st_Year;
  86.     UWORD st_Month;
  87.     UWORD st_Day;
  88.     UWORD st_Hour;
  89.     UWORD st_Min;
  90.     UWORD st_Sec;
  91.     UBYTE st_DOW;
  92. } SystemTime_t;
  93.  
  94. struct CyberNode {
  95.     struct Node    cn_Node;
  96. #define cn_Name cn_Node.ln_Name
  97.     STRPTR        cn_Command;
  98.     STRPTR        cn_Args;
  99.     STRPTR        cn_ReDirIn;
  100.     STRPTR        cn_ReDirOut;
  101.     STRPTR        cn_ReDirErr;
  102.     STRPTR        cn_CustomShell;
  103.     STRPTR        cn_SendToUser;
  104.     ULONG        cn_Stack;
  105.     BYTE        cn_Priority;
  106.     UBYTE        cn_DayOfWeek;
  107.     UWORD        cn_Month;
  108.     ULONG        cn_Day;
  109.     ULONG        cn_Hour;
  110.     ULONG        cn_HiMin;
  111.     ULONG        cn_LoMin;
  112.     ULONG        cn_DelayedCount;
  113.     UBYTE        cn_ObeyQueue;
  114.     UBYTE        cn_Flags;
  115. };
  116.  
  117. /* these are the possible values for the flags in cn_Flags */
  118. #define CNB_NOLOG   0        /* don't do log when running the command */
  119. #define CNB_REXX    1        /* start command as a rexx script */
  120. #define CNB_CRONTAB 2        /* node was generated by an entry in crontab
  121.                  * file */
  122. #define CNB_SYSSH   3        /* use system shell instead of user shell */
  123. #define CNB_OUTAPP  4        /* append to output redirection instead of
  124.                    overwrite */
  125. #define CNB_ERRAPP  5        /* append to error redirection instead of
  126.                    overwrite */
  127. #define CNB_EXECONE 6        /* run job once and then delete it */
  128.  
  129. #define CNF_NOLOG   (1L << CNB_NOLOG)
  130. #define CNF_REXX    (1L << CNB_REXX)
  131. #define CNF_CRONTAB (1L << CNB_CRONTAB)
  132. #define CNF_SYSSH   (1L << CNB_SYSSH)
  133. #define CNF_OUTAPP  (1L << CNB_OUTAPP)
  134. #define CNF_ERRAPP  (1L << CNB_ERRAPP)
  135. #define CNF_EXECONE (1L << CNB_EXECONE)
  136.  
  137. struct JobQueue {
  138.     ULONG    jq_Max;
  139.     ULONG    jq_Cur;
  140.     struct MinList jq_FIFOList;
  141. };
  142.  
  143. struct QueueFIFO {
  144.     struct MinNode qf_Node;
  145.     struct CyberNode *qf_CyberNode;
  146. };
  147.  
  148. struct SystemECdata {
  149.     UWORD    jobNo;
  150.     UBYTE    queueNo;
  151.     UBYTE    flags;
  152. };
  153.  
  154. /* stuff for handling our public semaphores. */
  155. struct MyPublicSema {
  156.     struct SignalSemaphore mps_Sema;
  157.     UBYTE *mps_SemaData;
  158.     ULONG mps_UseCount;
  159.     UBYTE mps_SemaName[4];
  160. };
  161.  
  162. /*
  163.  * here we have prototypes for all functions contained in or used by this
  164.  * file
  165.  */
  166. struct CyberNode *ParseEvent(STRPTR);
  167. void ParseBits(ULONG *, STRPTR);
  168. void UnParseBits(ULONG *, STRPTR, int, int);
  169. UWORD GetJobNum(void);
  170. void FreeJobNum(UWORD);
  171. void __stdargs Log(ULONG fmdId, ...);
  172. void __stdargs MySPrintf(STRPTR, STRPTR, ...);
  173. int __regargs main(char *cmdptr, int cmdlen, struct WBStartup *WBMsg);
  174. void ReadCronTab(void);
  175. BOOL GetARexxLib(void);
  176. void FreeARexxLib(void);
  177. void __stdargs ErrorMsg(ULONG fmtId, ...);
  178. void MyExit(int);
  179. void FreeEvents(BOOL);
  180. STRPTR WBtoCLIargs(struct WBStartup *WBMsg, STRPTR ArgTemplate);
  181. void StartSystemJob(struct CyberNode *cn);
  182. void StartRexxJob(struct CyberNode *cn);
  183. int __saveds __asm EndSystemJob(register __d0 int rc, register __d1 struct SystemECdata * data);
  184. void GetSystemTime(SystemTime_t *st, BOOL stIsSet);
  185. void ScanForJobs(void);
  186. void HandleRexxEvents(void);
  187. struct CyberNode *FindEvent(STRPTR name);
  188. BPTR SetupSendMail(STRPTR cmdName, STRPTR cmdArgs, STRPTR userName);
  189. struct MyPublicSema *InitMyPublicSemaphore(STRPTR semaName, ULONG semaDataSize);
  190. void FreeMyPublicSemaphore(struct MyPublicSema *mySema);
  191. STRPTR GetString(ULONG id);
  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. extern void DoMsg(struct RexxMsg *, APTR, int, int);
  197.  
  198. void   rx_Shutdown(void);
  199. STRPTR rx_Version(void);
  200. void   rx_Suspend(void);
  201. void   rx_Resume(void);
  202. int    rx_NewEventFile(STRPTR);
  203. void   rx_CloseEventFile(void);
  204. int    rx_AddEvent(STRPTR);
  205. int    rx_DeleteRexxEvent(STRPTR);
  206. int    rx_DeleteEvent(STRPTR);
  207. void   rx_PurgeRexxEvents(void);
  208. STRPTR rx_ShowEvent(STRPTR);
  209. STRPTR rx_ListEvents(void);
  210. STRPTR rx_ShowStatus(void);
  211. int    rx_NewLogFile(STRPTR);
  212. void   rx_CloseLogFile(void);
  213. int    rx_SetQueueMax(STRPTR);
  214. int    rx_GetQueueMax(STRPTR);
  215. STRPTR rx_EventNextExec(STRPTR name);
  216. STRPTR rx_NextEventToExec(void);
  217. STRPTR rx_ExpandSSSC(int SSSC);
  218. STRPTR rx_SSSCtoASCII(int SSSC);
  219.  
  220. void __stdargs kprintf(STRPTR fmt, ...);
  221.