aboutsummaryrefslogtreecommitdiff
path: root/runit/runit_lib.h
diff options
context:
space:
mode:
Diffstat (limited to 'runit/runit_lib.h')
-rw-r--r--runit/runit_lib.h240
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
25ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*/ 26*/
27 27
28/*** buffer.h ***/
29
30#if 0
31typedef 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
43extern void buffer_init(buffer *,int (*)(int fd,char *buf,unsigned len),int,char *,unsigned);
44
45extern int buffer_flush(buffer *);
46//extern int buffer_put(buffer *,const char *,unsigned);
47extern int buffer_putalign(buffer *,const char *,unsigned);
48extern int buffer_putflush(buffer *,const char *,unsigned);
49//extern int buffer_puts(buffer *,const char *);
50extern int buffer_putsalign(buffer *,const char *);
51extern 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
59extern int buffer_get(buffer *,char *,unsigned);
60extern int buffer_bget(buffer *,char *,unsigned);
61extern int buffer_feed(buffer *);
62
63extern char *buffer_peek(buffer *);
64extern 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
75extern int buffer_copy(buffer *,buffer *);
76
77extern int buffer_unixread(int,char *,unsigned);
78/* Actually, int buffer_unixwrite(int,const char *,unsigned),
79 but that 'const' will produce warnings... oh well */
80extern int buffer_unixwrite(int,char *,unsigned);
81#endif
82
83
84/*** byte.h ***/ 28/*** byte.h ***/
85 29
86extern unsigned byte_chr(char *s,unsigned n,int c); 30extern unsigned byte_chr(char *s,unsigned n,int c);
@@ -102,35 +46,6 @@ extern int fd_copy(int,int);
102extern int fd_move(int,int); 46extern 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
136struct tai { 51struct 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 *);
152extern void tai_unpack(const char *,struct tai *); 59extern void tai_unpack(const char *,struct tai *);
@@ -166,9 +73,6 @@ struct taia {
166 73
167extern void taia_now(struct taia *); 74extern void taia_now(struct taia *);
168 75
169//extern double taia_approx(const struct taia *);
170//extern double taia_frac(const struct taia *);
171
172extern void taia_add(struct taia *,const struct taia *,const struct taia *); 76extern void taia_add(struct taia *,const struct taia *,const struct taia *);
173extern void taia_addsec(struct taia *,const struct taia *,int); 77extern void taia_addsec(struct taia *,const struct taia *,int);
174extern void taia_sub(struct taia *,const struct taia *,const struct taia *); 78extern void taia_sub(struct taia *,const struct taia *,const struct taia *);
@@ -195,73 +99,6 @@ extern void fmt_ptime30nul(char *, struct taia *);
195extern unsigned fmt_taia25(char *, struct taia *); 99extern 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) \
208int 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) \
222int 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) \
236int 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 ***/
241GEN_ALLOC_typedef(stralloc,char,s,len,a)
242
243extern int stralloc_ready(stralloc *,unsigned);
244extern int stralloc_readyplus(stralloc *,unsigned);
245extern int stralloc_copy(stralloc *,const stralloc *);
246extern int stralloc_cat(stralloc *,const stralloc *);
247extern int stralloc_copys(stralloc *,const char *);
248extern int stralloc_cats(stralloc *,const char *);
249extern int stralloc_copyb(stralloc *,const char *,unsigned);
250extern int stralloc_catb(stralloc *,const char *,unsigned);
251extern int stralloc_append(stralloc *,const char *); /* beware: this takes a pointer to 1 char */
252extern int stralloc_starts(stralloc *,const char *);
253
254#define stralloc_0(sa) stralloc_append(sa,"")
255
256extern int stralloc_catulong0(stralloc *,unsigned long,unsigned);
257extern 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
267typedef struct pollfd iopause_fd; 104typedef struct pollfd iopause_fd;
@@ -287,88 +124,13 @@ extern int open_trunc(const char *);
287extern int open_write(const char *); 124extern int open_write(const char *);
288 125
289 126
290/*** openreadclose.h ***/
291#if 0
292extern 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
304extern unsigned pmatch(const char *, const char *, unsigned); 129extern 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
315extern int readclose_append(int,stralloc *,unsigned);
316extern int readclose(int,stralloc *,unsigned);
317#endif
318
319/*** scan.h ***/
320
321#if 0
322extern unsigned scan_uint(const char *,unsigned *);
323extern unsigned scan_xint(const char *,unsigned *);
324extern unsigned scan_nbbint(const char *,unsigned,unsigned,unsigned,unsigned *);
325extern unsigned scan_ushort(const char *,unsigned short *);
326extern unsigned scan_xshort(const char *,unsigned short *);
327extern unsigned scan_nbbshort(const char *,unsigned,unsigned,unsigned,unsigned short *);
328extern unsigned scan_ulong(const char *,unsigned long *);
329extern unsigned scan_xlong(const char *,unsigned long *);
330extern unsigned scan_nbblong(const char *,unsigned,unsigned,unsigned,unsigned long *);
331
332extern unsigned scan_plusminus(const char *,int *);
333extern unsigned scan_0x(const char *,unsigned *);
334
335extern unsigned scan_whitenskip(const char *,unsigned);
336extern unsigned scan_nonwhitenskip(const char *,unsigned);
337extern unsigned scan_charsetnskip(const char *,const char *,unsigned);
338extern unsigned scan_noncharsetnskip(const char *,const char *,unsigned);
339
340extern unsigned scan_strncmp(const char *,const char *,unsigned);
341extern unsigned scan_memcmp(const char *,const char *,unsigned);
342
343extern unsigned scan_long(const char *,long *);
344extern 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
372extern void sig_catch(int,void (*)(int)); 134extern 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);
378extern void sig_blocknone(void); 140extern void sig_blocknone(void);
379extern void sig_pause(void); 141extern void sig_pause(void);
380 142
381extern void sig_dfl(int);
382
383 143
384/*** str.h ***/ 144/*** str.h ***/
385 145