2 * declarations common to
15 typedef struct CommandInput CommandInput;
17 /*---------- from obc.c ----------*/
19 typedef struct OutBuffer OutBuffer;
20 typedef struct OutBufferChain OutBufferChain;
21 typedef void OutBufferError(OutBufferChain*, const char *e1, const char *e2
22 /* on error: both e1 and e2 non-0. say `$e1: $e2'
23 * on eof: both e1 and e2 =0. */);
25 struct OutBufferChain {
29 int limit; /* 0 means obc_init will set a default */
30 OutBufferError *error;
31 /* set/used by obc_..., oprintf, etc., only */
32 int done_of_head, total;
33 struct { OutBuffer *head, *tail; } obs;
36 void obc_init(OutBufferChain *ch);
37 int obc_tryflush(OutBufferChain *ch);
38 /* returns 0 for all flushed or errno, including particularly EWOULDBLOCK */
40 void ovprintf(OutBufferChain *ch, const char *fmt, va_list al)
41 __attribute__((format(printf,2,0)));
42 void oprintf(OutBufferChain *ch, const char *msg, ...)
43 __attribute__((format(printf,2,3)));
44 void owrite(OutBufferChain *ch, const char *data, int l);
45 void voerror(OutBufferChain *ch, const char *fmt, va_list al)
46 __attribute__((format(printf,2,0)));
48 /*---------- from cmdinput.c ----------*/
50 typedef void CommandInputCallback(ParseState *ps, CommandInput *cmdi);
54 CommandInputCallback *doline;
58 void cmdin_new(CommandInput *cmdi, int readfd);
59 /* fill in cmdi->out's `set by user' fields before calling cmdin_new,
60 * as cmdin_new will call obc_init and will use cmdi->out->fd. */
62 /*---------- from eventhelp.c ----------*/
64 extern oop_source *events;
66 typedef struct TimeoutEvent TimeoutEvent;
67 typedef void TimeoutEventFn(TimeoutEvent*);
68 struct TimeoutEvent { /* Undefined Idle Running set by */
69 int running; /* any 0 1 toev_ */
70 int duration; /*ms*/ /* any any[1] any[1] caller */
71 TimeoutEventFn *callback; /* any any valid[2] caller */
72 struct timeval abs; /* any any valid toev_ */
73 }; /* [1] duration must be >=0 or -1 when toev_start is called;
74 * [2] callback may be modified while timeout is running;
75 * value used is that prevailing when timeout happens
76 * when the timeout happens, TimeoutEvent's state goes from R to I
77 * and then callback member is read and the function called
80 void toev_init(TimeoutEvent*); /* U -> I */
81 void toev_start(TimeoutEvent*); /* IR -> R; reads duration */
82 /* if duration is -1 then is same as toev_stop */
83 void toev_stop(TimeoutEvent*); /* IR -> I */