diff options
Diffstat (limited to 'runit/runit_lib.h')
-rw-r--r-- | runit/runit_lib.h | 240 |
1 files changed, 0 insertions, 240 deletions
diff --git a/runit/runit_lib.h b/runit/runit_lib.h index ea4b33123..7b268e276 100644 --- a/runit/runit_lib.h +++ b/runit/runit_lib.h | |||
@@ -25,62 +25,6 @@ OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF | |||
25 | ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | /*** buffer.h ***/ | ||
29 | |||
30 | #if 0 | ||
31 | typedef struct buffer { | ||
32 | char *x; | ||
33 | unsigned p; | ||
34 | unsigned n; | ||
35 | int fd; | ||
36 | int (*op)(int fd,char *buf,unsigned len); | ||
37 | } buffer; | ||
38 | |||
39 | //#define BUFFER_INIT(op,fd,buf,len) { (buf), 0, (len), (fd), (op) } | ||
40 | //#define BUFFER_INSIZE 8192 | ||
41 | #define BUFFER_OUTSIZE 8192 | ||
42 | |||
43 | extern void buffer_init(buffer *,int (*)(int fd,char *buf,unsigned len),int,char *,unsigned); | ||
44 | |||
45 | extern int buffer_flush(buffer *); | ||
46 | //extern int buffer_put(buffer *,const char *,unsigned); | ||
47 | extern int buffer_putalign(buffer *,const char *,unsigned); | ||
48 | extern int buffer_putflush(buffer *,const char *,unsigned); | ||
49 | //extern int buffer_puts(buffer *,const char *); | ||
50 | extern int buffer_putsalign(buffer *,const char *); | ||
51 | extern int buffer_putsflush(buffer *,const char *); | ||
52 | |||
53 | #define buffer_PUTC(s,c) \ | ||
54 | ( ((s)->n != (s)->p) \ | ||
55 | ? ( (s)->x[(s)->p++] = (c), 0 ) \ | ||
56 | : buffer_put((s),&(c),1) \ | ||
57 | ) | ||
58 | |||
59 | extern int buffer_get(buffer *,char *,unsigned); | ||
60 | extern int buffer_bget(buffer *,char *,unsigned); | ||
61 | extern int buffer_feed(buffer *); | ||
62 | |||
63 | extern char *buffer_peek(buffer *); | ||
64 | extern void buffer_seek(buffer *,unsigned); | ||
65 | |||
66 | #define buffer_PEEK(s) ( (s)->x + (s)->n ) | ||
67 | #define buffer_SEEK(s,len) ( ( (s)->p -= (len) ) , ( (s)->n += (len) ) ) | ||
68 | |||
69 | #define buffer_GETC(s,c) \ | ||
70 | ( ((s)->p > 0) \ | ||
71 | ? ( *(c) = (s)->x[(s)->n], buffer_SEEK((s),1), 1 ) \ | ||
72 | : buffer_get((s),(c),1) \ | ||
73 | ) | ||
74 | |||
75 | extern int buffer_copy(buffer *,buffer *); | ||
76 | |||
77 | extern int buffer_unixread(int,char *,unsigned); | ||
78 | /* Actually, int buffer_unixwrite(int,const char *,unsigned), | ||
79 | but that 'const' will produce warnings... oh well */ | ||
80 | extern int buffer_unixwrite(int,char *,unsigned); | ||
81 | #endif | ||
82 | |||
83 | |||
84 | /*** byte.h ***/ | 28 | /*** byte.h ***/ |
85 | 29 | ||
86 | extern unsigned byte_chr(char *s,unsigned n,int c); | 30 | extern unsigned byte_chr(char *s,unsigned n,int c); |
@@ -102,35 +46,6 @@ extern int fd_copy(int,int); | |||
102 | extern int fd_move(int,int); | 46 | extern int fd_move(int,int); |
103 | 47 | ||
104 | 48 | ||
105 | /*** fifo.h ***/ | ||
106 | |||
107 | //extern int fifo_make(const char *,int); | ||
108 | |||
109 | |||
110 | /*** fmt.h ***/ | ||
111 | |||
112 | //#define FMT_ULONG 40 /* enough space to hold 2^128 - 1 in decimal, plus \0 */ | ||
113 | //#define FMT_LEN ((char *) 0) /* convenient abbreviation */ | ||
114 | |||
115 | //extern unsigned fmt_uint(char *,unsigned); | ||
116 | //extern unsigned fmt_uint0(char *,unsigned,unsigned); | ||
117 | //extern unsigned fmt_xint(char *,unsigned); | ||
118 | //extern unsigned fmt_nbbint(char *,unsigned,unsigned,unsigned,unsigned); | ||
119 | //extern unsigned fmt_ushort(char *,unsigned short); | ||
120 | //extern unsigned fmt_xshort(char *,unsigned short); | ||
121 | //extern unsigned fmt_nbbshort(char *,unsigned,unsigned,unsigned,unsigned short); | ||
122 | //extern unsigned fmt_ulong(char *,unsigned long); | ||
123 | //extern unsigned fmt_xlong(char *,unsigned long); | ||
124 | //extern unsigned fmt_nbblong(char *,unsigned,unsigned,unsigned,unsigned long); | ||
125 | |||
126 | //extern unsigned fmt_plusminus(char *,int); | ||
127 | //extern unsigned fmt_minus(char *,int); | ||
128 | //extern unsigned fmt_0x(char *,int); | ||
129 | |||
130 | //extern unsigned fmt_str(char *,const char *); | ||
131 | //extern unsigned fmt_strn(char *,const char *,unsigned); | ||
132 | |||
133 | |||
134 | /*** tai.h ***/ | 49 | /*** tai.h ***/ |
135 | 50 | ||
136 | struct tai { | 51 | struct tai { |
@@ -139,14 +54,6 @@ struct tai { | |||
139 | 54 | ||
140 | #define tai_unix(t,u) ((void) ((t)->x = 4611686018427387914ULL + (uint64_t) (u))) | 55 | #define tai_unix(t,u) ((void) ((t)->x = 4611686018427387914ULL + (uint64_t) (u))) |
141 | 56 | ||
142 | //extern void tai_now(struct tai *); | ||
143 | |||
144 | //#define tai_approx(t) ((double) ((t)->x)) | ||
145 | |||
146 | //extern void tai_add(struct tai *,const struct tai *,const struct tai *); | ||
147 | //extern void tai_sub(struct tai *,const struct tai *,const struct tai *); | ||
148 | //#define tai_less(t,u) ((t)->x < (u)->x) | ||
149 | |||
150 | #define TAI_PACK 8 | 57 | #define TAI_PACK 8 |
151 | //extern void tai_pack(char *,const struct tai *); | 58 | //extern void tai_pack(char *,const struct tai *); |
152 | extern void tai_unpack(const char *,struct tai *); | 59 | extern void tai_unpack(const char *,struct tai *); |
@@ -166,9 +73,6 @@ struct taia { | |||
166 | 73 | ||
167 | extern void taia_now(struct taia *); | 74 | extern void taia_now(struct taia *); |
168 | 75 | ||
169 | //extern double taia_approx(const struct taia *); | ||
170 | //extern double taia_frac(const struct taia *); | ||
171 | |||
172 | extern void taia_add(struct taia *,const struct taia *,const struct taia *); | 76 | extern void taia_add(struct taia *,const struct taia *,const struct taia *); |
173 | extern void taia_addsec(struct taia *,const struct taia *,int); | 77 | extern void taia_addsec(struct taia *,const struct taia *,int); |
174 | extern void taia_sub(struct taia *,const struct taia *,const struct taia *); | 78 | extern void taia_sub(struct taia *,const struct taia *,const struct taia *); |
@@ -195,73 +99,6 @@ extern void fmt_ptime30nul(char *, struct taia *); | |||
195 | extern unsigned fmt_taia25(char *, struct taia *); | 99 | extern unsigned fmt_taia25(char *, struct taia *); |
196 | 100 | ||
197 | 101 | ||
198 | #ifdef UNUSED | ||
199 | /*** gen_alloc.h ***/ | ||
200 | |||
201 | #define GEN_ALLOC_typedef(ta,type,field,len,a) \ | ||
202 | typedef struct ta { type *field; unsigned len; unsigned a; } ta; | ||
203 | |||
204 | |||
205 | /*** gen_allocdefs.h ***/ | ||
206 | |||
207 | #define GEN_ALLOC_ready(ta,type,field,len,a,i,n,x,base,ta_ready) \ | ||
208 | int ta_ready(ta *x,unsigned n) \ | ||
209 | { unsigned i; \ | ||
210 | if (x->field) { \ | ||
211 | i = x->a; \ | ||
212 | if (n > i) { \ | ||
213 | x->a = base + n + (n >> 3); \ | ||
214 | x->field = realloc(x->field,x->a * sizeof(type)); \ | ||
215 | if (x->field) return 1; \ | ||
216 | x->a = i; return 0; } \ | ||
217 | return 1; } \ | ||
218 | x->len = 0; \ | ||
219 | return !!(x->field = malloc((x->a = n) * sizeof(type))); } | ||
220 | |||
221 | #define GEN_ALLOC_readyplus(ta,type,field,len,a,i,n,x,base,ta_rplus) \ | ||
222 | int ta_rplus(ta *x,unsigned n) \ | ||
223 | { unsigned i; \ | ||
224 | if (x->field) { \ | ||
225 | i = x->a; n += x->len; \ | ||
226 | if (n > i) { \ | ||
227 | x->a = base + n + (n >> 3); \ | ||
228 | x->field = realloc(x->field,x->a * sizeof(type)); \ | ||
229 | if (x->field) return 1; \ | ||
230 | x->a = i; return 0; } \ | ||
231 | return 1; } \ | ||
232 | x->len = 0; \ | ||
233 | return !!(x->field = malloc((x->a = n) * sizeof(type))); } | ||
234 | |||
235 | #define GEN_ALLOC_append(ta,type,field,len,a,i,n,x,base,ta_rplus,ta_append) \ | ||
236 | int ta_append(ta *x,const type *i) \ | ||
237 | { if (!ta_rplus(x,1)) return 0; x->field[x->len++] = *i; return 1; } | ||
238 | |||
239 | |||
240 | /*** stralloc.h ***/ | ||
241 | GEN_ALLOC_typedef(stralloc,char,s,len,a) | ||
242 | |||
243 | extern int stralloc_ready(stralloc *,unsigned); | ||
244 | extern int stralloc_readyplus(stralloc *,unsigned); | ||
245 | extern int stralloc_copy(stralloc *,const stralloc *); | ||
246 | extern int stralloc_cat(stralloc *,const stralloc *); | ||
247 | extern int stralloc_copys(stralloc *,const char *); | ||
248 | extern int stralloc_cats(stralloc *,const char *); | ||
249 | extern int stralloc_copyb(stralloc *,const char *,unsigned); | ||
250 | extern int stralloc_catb(stralloc *,const char *,unsigned); | ||
251 | extern int stralloc_append(stralloc *,const char *); /* beware: this takes a pointer to 1 char */ | ||
252 | extern int stralloc_starts(stralloc *,const char *); | ||
253 | |||
254 | #define stralloc_0(sa) stralloc_append(sa,"") | ||
255 | |||
256 | extern int stralloc_catulong0(stralloc *,unsigned long,unsigned); | ||
257 | extern int stralloc_catlong0(stralloc *,long,unsigned); | ||
258 | |||
259 | #define stralloc_catlong(sa,l) (stralloc_catlong0((sa),(l),0)) | ||
260 | #define stralloc_catuint0(sa,i,n) (stralloc_catulong0((sa),(i),(n))) | ||
261 | #define stralloc_catint0(sa,i,n) (stralloc_catlong0((sa),(i),(n))) | ||
262 | #define stralloc_catint(sa,i) (stralloc_catlong0((sa),(i),0)) | ||
263 | #endif | ||
264 | |||
265 | /*** iopause.h ***/ | 102 | /*** iopause.h ***/ |
266 | 103 | ||
267 | typedef struct pollfd iopause_fd; | 104 | typedef struct pollfd iopause_fd; |
@@ -287,88 +124,13 @@ extern int open_trunc(const char *); | |||
287 | extern int open_write(const char *); | 124 | extern int open_write(const char *); |
288 | 125 | ||
289 | 126 | ||
290 | /*** openreadclose.h ***/ | ||
291 | #if 0 | ||
292 | extern int openreadclose(const char *,stralloc *,unsigned); | ||
293 | #endif | ||
294 | |||
295 | /*** pathexec.h ***/ | ||
296 | |||
297 | //extern void pathexec_run(const char *,char *const *,char *const *); | ||
298 | //extern int pathexec_env(const char *,const char *); | ||
299 | //extern void pathexec(char **); | ||
300 | |||
301 | |||
302 | /*** pmatch.h ***/ | 127 | /*** pmatch.h ***/ |
303 | 128 | ||
304 | extern unsigned pmatch(const char *, const char *, unsigned); | 129 | extern unsigned pmatch(const char *, const char *, unsigned); |
305 | 130 | ||
306 | 131 | ||
307 | /*** prot.h ***/ | ||
308 | |||
309 | //extern int prot_gid(int); | ||
310 | //extern int prot_uid(int); | ||
311 | |||
312 | |||
313 | /*** readclose.h ***/ | ||
314 | #if 0 | ||
315 | extern int readclose_append(int,stralloc *,unsigned); | ||
316 | extern int readclose(int,stralloc *,unsigned); | ||
317 | #endif | ||
318 | |||
319 | /*** scan.h ***/ | ||
320 | |||
321 | #if 0 | ||
322 | extern unsigned scan_uint(const char *,unsigned *); | ||
323 | extern unsigned scan_xint(const char *,unsigned *); | ||
324 | extern unsigned scan_nbbint(const char *,unsigned,unsigned,unsigned,unsigned *); | ||
325 | extern unsigned scan_ushort(const char *,unsigned short *); | ||
326 | extern unsigned scan_xshort(const char *,unsigned short *); | ||
327 | extern unsigned scan_nbbshort(const char *,unsigned,unsigned,unsigned,unsigned short *); | ||
328 | extern unsigned scan_ulong(const char *,unsigned long *); | ||
329 | extern unsigned scan_xlong(const char *,unsigned long *); | ||
330 | extern unsigned scan_nbblong(const char *,unsigned,unsigned,unsigned,unsigned long *); | ||
331 | |||
332 | extern unsigned scan_plusminus(const char *,int *); | ||
333 | extern unsigned scan_0x(const char *,unsigned *); | ||
334 | |||
335 | extern unsigned scan_whitenskip(const char *,unsigned); | ||
336 | extern unsigned scan_nonwhitenskip(const char *,unsigned); | ||
337 | extern unsigned scan_charsetnskip(const char *,const char *,unsigned); | ||
338 | extern unsigned scan_noncharsetnskip(const char *,const char *,unsigned); | ||
339 | |||
340 | extern unsigned scan_strncmp(const char *,const char *,unsigned); | ||
341 | extern unsigned scan_memcmp(const char *,const char *,unsigned); | ||
342 | |||
343 | extern unsigned scan_long(const char *,long *); | ||
344 | extern unsigned scan_8long(const char *,unsigned long *); | ||
345 | #endif | ||
346 | |||
347 | |||
348 | /*** seek.h ***/ | ||
349 | |||
350 | //typedef unsigned long seek_pos; | ||
351 | |||
352 | //extern seek_pos seek_cur(int); | ||
353 | |||
354 | //extern int seek_set(int,seek_pos); | ||
355 | //extern int seek_end(int); | ||
356 | |||
357 | //extern int seek_trunc(int,seek_pos); | ||
358 | |||
359 | //#define seek_begin(fd) (seek_set((fd),(seek_pos) 0)) | ||
360 | |||
361 | |||
362 | /*** sig.h ***/ | 132 | /*** sig.h ***/ |
363 | 133 | ||
364 | //extern int sig_alarm; | ||
365 | //extern int sig_child; | ||
366 | //extern int sig_cont; | ||
367 | //extern int sig_hangup; | ||
368 | //extern int sig_int; | ||
369 | //extern int sig_pipe; | ||
370 | //extern int sig_term; | ||
371 | |||
372 | extern void sig_catch(int,void (*)(int)); | 134 | extern void sig_catch(int,void (*)(int)); |
373 | #define sig_ignore(s) (sig_catch((s), SIG_IGN)) | 135 | #define sig_ignore(s) (sig_catch((s), SIG_IGN)) |
374 | #define sig_uncatch(s) (sig_catch((s), SIG_DFL)) | 136 | #define sig_uncatch(s) (sig_catch((s), SIG_DFL)) |
@@ -378,8 +140,6 @@ extern void sig_unblock(int); | |||
378 | extern void sig_blocknone(void); | 140 | extern void sig_blocknone(void); |
379 | extern void sig_pause(void); | 141 | extern void sig_pause(void); |
380 | 142 | ||
381 | extern void sig_dfl(int); | ||
382 | |||
383 | 143 | ||
384 | /*** str.h ***/ | 144 | /*** str.h ***/ |
385 | 145 | ||