
enum {JOB_BUSY, JOB_EXIT, JOB_CRASH};

/* a task is a description of the wrapping of a job */
typedef struct {
  Macro  *exec;				/* name is 'exec' */
  Macro  *crash;			/* name is 'crash' */
  Macro  *timeout;
  Macro  *def;

  int     NEXIT;
  int     Nexit;
  Macro **exit;				/* name is exit status */

  int     argc;
  char  **argv;
  char   *host;

  char   *name;

  float   poll_period;
  float   exec_period;
  float   timeout_period;

  struct timeval last;
} Task;

typedef struct {
  int JobID;				/* internal ID for job */
  int PID;				/* external ID for job */

  Task task;

  struct timeval last;
  struct timeval start;
  int state;
  int exit_status;
} Job;


/* scheduler prototypes */
void InitTasks ();
void ListTasks ();
Task *FindTask (char *name);
Task *CreateTask (char *name);
void SetCurrentTask (char *name);
char *GetCurrentTask ();
int DeleteTask (Task *task);
Task *NextTask ();
int TaskHash (char *input);
int ShowTask (char *name);

Job *NextJob ();
void InitJobs ();
int NextJobID ();
void ListJobs ();
Job *FindJob (int JobID);
Job *CreateJob (Task *task);
void SetCurrentJob (char *name);
char *GetCurrentJob ();
int SubmitJob (Job *job);
int CheckJob (Job *job);
int DeleteJob (Job *job);
void FreeJob (Job *job);
