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 OutBufferError *error;
30 /* set/used by obc_..., oprintf, etc., only */
32 struct { OutBuffer *head, *tail; } obs;
35 void obc_init(OutBufferChain *ch);
36 int obc_tryflush(OutBufferChain *ch);
37 /* returns 0 for all flushed or errno, including particularly EWOULDBLOCK */
39 void ovprintf(OutBufferChain *ch, const char *fmt, va_list al)
40 __attribute__((format(printf,2,0)));
41 void oprintf(OutBufferChain *ch, const char *msg, ...)
42 __attribute__((format(printf,2,3)));
43 void owrite(OutBufferChain *ch, const char *data, int l);
44 void voerror(OutBufferChain *ch, const char *fmt, va_list al)
45 __attribute__((format(printf,2,0)));
47 /*---------- from cmdinput.c ----------*/
49 typedef void CommandInputCallback(ParseState *ps, CommandInput *cmdi);
53 CommandInputCallback *doline;
57 void cmdin_new(CommandInput *cmdi, int readfd);
58 /* fill in cmdi->out's `set by user' fields before calling cmdin_new,
59 * as cmdin_new will call obc_init and will use cmdi->out->fd. */
61 /*---------- from eventhelp.c ----------*/
63 extern oop_source *events;
65 typedef struct TimeoutEvent TimeoutEvent;
66 typedef void TimeoutEventFn(TimeoutEvent*);
67 struct TimeoutEvent { /* Undefined Idle Running set by */
68 int running; /* any 0 1 toev_ */
69 int duration; /*ms*/ /* any any[1] any[1] caller */
70 TimeoutEventFn *callback; /* any any valid[2] caller */
71 struct timeval abs; /* any any valid toev_ */
72 }; /* [1] duration must be >=0 or -1 when toev_start is called;
73 * [2] callback may be modified while timeout is running;
74 * value used is that prevailing when timeout happens
75 * when the timeout happens, TimeoutEvent's state goes from R to I
76 * and then callback member is read and the function called
79 void toev_init(TimeoutEvent*); /* U -> I */
80 void toev_start(TimeoutEvent*); /* IR -> R; reads duration */
81 /* if duration is -1 then is same as toev_stop */
82 void toev_stop(TimeoutEvent*); /* IR -> I */