chiark / gitweb /
hostside: more length for bavarian
[trains.git] / hostside / daemons.h
index 2fd57d418121d518db108a734211e2520e7b5047..1c1fa0f4d526e19c928b1f1a0375843449c67d4a 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * declarations common to
  *  - realtime daemon
- *  - multiplexer daemon
+ *  - gui-plan-* displayers
  */
 
 #ifndef DAEMONS_H
@@ -21,6 +21,9 @@ typedef struct OutBufferChain OutBufferChain;
 typedef void OutBufferError(OutBufferChain*, const char *e1, const char *e2
                            /* on error: both e1 and e2 non-0. say `$e1: $e2'
                             * on eof: both e1 and e2 =0. */);
+typedef void OutBufferEmpty(OutBufferChain*);
+
+typedef void CopyCallBack(char *m, size_t l, void *u);
 
 struct OutBufferChain {
   /* set by user: */
@@ -28,15 +31,22 @@ struct OutBufferChain {
   int fd;
   int limit; /* 0 means obc_init will set a default */
   OutBufferError *error;
+  OutBufferEmpty *empty; /* may be 0 */
+  /* set/used by obc_... but may be read by user */
+  int total; /* amount buffered */
   /* set/used by obc_..., oprintf, etc., only */
-  int done_of_head, total;
+  int done_of_head; /* -1 = empty and fileevent not registered with liboop */
   struct { OutBuffer *head, *tail; } obs;
 };
 
 void obc_init(OutBufferChain *ch);
+void obc_init_core(OutBufferChain *ch); /* doesn't mess with fd */
 int obc_tryflush(OutBufferChain *ch);
  /* returns 0 for all flushed or errno, including particularly EWOULDBLOCK */
 
+void ovprintf_ccb(OutBufferChain *ch, CopyCallBack *ccb, void *ccbu,
+                  const char *fmt, va_list al)
+     __attribute__((format(printf,4,0)));
 void ovprintf(OutBufferChain *ch, const char *fmt, va_list al)
      __attribute__((format(printf,2,0)));
 void oprintf(OutBufferChain *ch, const char *msg, ...)
@@ -47,6 +57,8 @@ void voerror(OutBufferChain *ch, const char *fmt, va_list al)
 
 /*---------- from cmdinput.c ----------*/
 
+extern oop_source *events;
+
 typedef void CommandInputCallback(ParseState *ps, CommandInput *cmdi);
 
 struct CommandInput {
@@ -59,27 +71,4 @@ void cmdin_new(CommandInput *cmdi, int readfd);
   /* fill in cmdi->out's `set by user' fields before calling cmdin_new,
    * as cmdin_new will call obc_init and will use cmdi->out->fd. */
 
-/*---------- from eventhelp.c ----------*/
-
-extern oop_source *events;
-
-typedef struct TimeoutEvent TimeoutEvent;
-typedef void TimeoutEventFn(TimeoutEvent*);
-struct TimeoutEvent {       /* Undefined   Idle      Running     set by   */
-  int running;              /*  any         0         1           toev_   */
-  int duration; /*ms*/      /*  any         any[1]    any[1]      caller  */
-  TimeoutEventFn *callback; /*  any         any       valid[2]    caller  */
-  struct timeval abs;       /*  any         any       valid       toev_   */
-};  /* [1] duration must be >=0 or -1 when toev_start is called;
-     * [2] callback may be modified while timeout is running;
-     *      value used is that prevailing when timeout happens
-     * when the timeout happens, TimeoutEvent's state goes from R to I
-     * and then callback member is read and the function called
-     */
-
-void toev_init(TimeoutEvent*);    /* U -> I */
-void toev_start(TimeoutEvent*);   /* IR -> R; reads duration */
-  /* if duration is -1 then is same as toev_stop */
-void toev_stop(TimeoutEvent*);    /* IR -> I */
-
 #endif /*DAEMONS_H*/