Index: trunk/Ohana/src/opihi/include/scheduler.h
===================================================================
--- trunk/Ohana/src/opihi/include/scheduler.h	(revision 3143)
+++ trunk/Ohana/src/opihi/include/scheduler.h	(revision 4450)
@@ -1,4 +1,37 @@
+# include "external.h"
+# include "shell.h"
+# include "dvomath.h"
+# include "convert.h"
+# include "display.h"
+# include <sys/types.h>
+# include <sys/wait.h>
 
-enum {JOB_BUSY, JOB_EXIT, JOB_CRASH};
+typedef enum {
+  JOB_NONE,
+  JOB_BUSY, 
+  JOB_EXIT, 
+  JOB_CRASH,
+  JOB_PENDING,
+} JobStat;
+
+typedef enum {
+  JOB_LOCAL, 
+  JOB_CONTROLLER, 
+} JobMode;
+
+typedef enum {
+  CONTROLLER_HUNG = -1,
+  CONTROLLER_DOWN = 0,
+  CONTROLLER_GOOD = 1,
+} ControllerStat;
+
+/* socket / pipe communication buffer */
+typedef struct {
+  char *buffer;
+  int   Nalloc;
+  int   Nreset;
+  int   Nblock;
+  int   Nbuffer;
+} IOBuffer;
 
 /* a task is a description of the wrapping of a job */
@@ -16,4 +49,5 @@
   char  **argv;
   char   *host;
+  int     host_required;
 
   char   *name;
@@ -28,7 +62,5 @@
 typedef struct {
   int JobID;				/* internal ID for job */
-  int PID;				/* external ID for job */
-
-  Task task;
+  int pid;				/* external ID for job */
 
   struct timeval last;
@@ -36,6 +68,20 @@
   int state;
   int exit_status;
+
+  int     argc;
+  char  **argv;
+  Task   *task;
+
+  IOBuffer    stdout;			/* stdout storage buffer */
+  IOBuffer    stderr;			/* stderr storage buffer */
+  JobMode     mode;			/* local or controller? */
+
+  int         stdout_size;		/* stdout pipe (local only) */
+  int         stderr_size;		/* stderr pipe (local only) */
+  int         stdout_fd;		/* stdout pipe (local only) */
+  int         stderr_fd;		/* stderr pipe (local only) */
 } Job;
 
+# define CONTROLLER_PROMPT "pclient:"
 
 /* scheduler prototypes */
@@ -50,4 +96,5 @@
 int TaskHash (char *input);
 int ShowTask (char *name);
+char *memstr (char *m1, char *m2, int n);
 
 Job *NextJob ();
@@ -65,2 +112,16 @@
 void SetTaskTimer (struct timeval *timer);
 double GetTaskTimer (struct timeval start);
+
+int CheckJobs ();
+int CheckTasks ();
+int CheckSystem ();
+int GetJobOutput (char *channel, int pid, IOBuffer *buffer, int Nbytes);
+int CheckControllerJob (Job *job);
+int CheckControllerJobStatus (Job *job);
+int SubmitControllerJob (Job *job);
+int StartController ();
+int ControllerCommand (char *command, char *response, IOBuffer *buffer);
+int SubmitLocalJob (Job *job);
+int CheckLocalJob (Job *job);
+int CheckLocalJobStatus (Job *job);
+void InitTaskTimers ();
