aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2007-01-27 22:22:53 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2007-01-27 22:22:53 +0000
commitbde74b617f0c17921a846a28aac63330951a9cc7 (patch)
treebe9b7dbd208344ee31d51e00e52b4b5bcbf3bf85
parente2473f8c233c96fbcb295aa7a1f758a46f962f66 (diff)
downloadbusybox-w32-bde74b617f0c17921a846a28aac63330951a9cc7.tar.gz
busybox-w32-bde74b617f0c17921a846a28aac63330951a9cc7.tar.bz2
busybox-w32-bde74b617f0c17921a846a28aac63330951a9cc7.zip
runit/* cleanup part 3 (just deleting unused code)
-rw-r--r--runit/runit_lib.c552
-rw-r--r--runit/runit_lib.h240
2 files changed, 4 insertions, 788 deletions
diff --git a/runit/runit_lib.c b/runit/runit_lib.c
index 181d43836..aa1d96002 100644
--- a/runit/runit_lib.c
+++ b/runit/runit_lib.c
@@ -34,207 +34,6 @@ ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34#include "libbb.h" 34#include "libbb.h"
35#include "runit_lib.h" 35#include "runit_lib.h"
36 36
37#if 0
38/*** buffer.c ***/
39
40void buffer_init(buffer *s,int (*op)(int fd,char *buf,unsigned len),int fd,char *buf,unsigned len)
41{
42 s->x = buf;
43 s->fd = fd;
44 s->op = op;
45 s->p = 0;
46 s->n = len;
47}
48
49
50/*** buffer_get.c ***/
51
52static int oneread(int (*op)(int fd,char *buf,unsigned len),int fd,char *buf,unsigned len)
53{
54 int r;
55
56 for (;;) {
57 r = op(fd,buf,len);
58 if (r == -1 && errno == EINTR)
59 continue;
60 return r;
61 }
62}
63
64static int getthis(buffer *s,char *buf,unsigned len)
65{
66 if (len > s->p) len = s->p;
67 s->p -= len;
68 memcpy(buf,s->x + s->n,len);
69 s->n += len;
70 return len;
71}
72
73int buffer_feed(buffer *s)
74{
75 int r;
76
77 if (s->p)
78 return s->p;
79 r = oneread(s->op,s->fd,s->x,s->n);
80 if (r <= 0)
81 return r;
82 s->p = r;
83 s->n -= r;
84 if (s->n > 0)
85 memmove(s->x + s->n,s->x,r);
86 return r;
87}
88
89int buffer_bget(buffer *s,char *buf,unsigned len)
90{
91 int r;
92
93 if (s->p > 0)
94 return getthis(s,buf,len);
95 if (s->n <= len)
96 return oneread(s->op,s->fd,buf,s->n);
97 r = buffer_feed(s);
98 if (r <= 0)
99 return r;
100 return getthis(s,buf,len);
101}
102
103int buffer_get(buffer *s,char *buf,unsigned len)
104{
105 int r;
106
107 if (s->p > 0)
108 return getthis(s,buf,len);
109 if (s->n <= len)
110 return oneread(s->op,s->fd,buf,len);
111 r = buffer_feed(s);
112 if (r <= 0)
113 return r;
114 return getthis(s,buf,len);
115}
116
117char *buffer_peek(buffer *s)
118{
119 return s->x + s->n;
120}
121
122void buffer_seek(buffer *s,unsigned len)
123{
124 s->n += len;
125 s->p -= len;
126}
127
128
129/*** buffer_put.c ***/
130
131static int allwrite(int (*op)(int fd,char *buf,unsigned len),int fd,const char *buf,unsigned len)
132{
133 int w;
134
135 while (len) {
136 w = op(fd,(char*)buf,len);
137 if (w == -1) {
138 if (errno == EINTR)
139 continue;
140 return -1; /* note that some data may have been written */
141 }
142 /* if (w == 0) ; luser's fault */
143 buf += w;
144 len -= w;
145 }
146 return 0;
147}
148
149int buffer_flush(buffer *s)
150{
151 int p;
152
153 p = s->p;
154 if (!p) return 0;
155 s->p = 0;
156 return allwrite(s->op,s->fd,s->x,p);
157}
158
159int buffer_putalign(buffer *s,const char *buf,unsigned len)
160{
161 unsigned n;
162
163 while (len > (n = s->n - s->p)) {
164 memcpy(s->x + s->p,buf,n);
165 s->p += n;
166 buf += n;
167 len -= n;
168 if (buffer_flush(s) == -1) return -1;
169 }
170 /* now len <= s->n - s->p */
171 memcpy(s->x + s->p,buf,len);
172 s->p += len;
173 return 0;
174}
175
176int buffer_put(buffer *s,const char *buf,unsigned len)
177{
178 unsigned n;
179
180 n = s->n;
181 if (len > n - s->p) {
182 if (buffer_flush(s) == -1) return -1;
183 /* now s->p == 0 */
184 if (n < BUFFER_OUTSIZE) n = BUFFER_OUTSIZE;
185 while (len > s->n) {
186 if (n > len) n = len;
187 if (allwrite(s->op,s->fd,buf,n) == -1) return -1;
188 buf += n;
189 len -= n;
190 }
191 }
192 /* now len <= s->n - s->p */
193 memcpy(s->x + s->p,buf,len);
194 s->p += len;
195 return 0;
196}
197
198int buffer_putflush(buffer *s,const char *buf,unsigned len)
199{
200 if (buffer_flush(s) == -1)
201 return -1;
202 return allwrite(s->op,s->fd,buf,len);
203}
204
205int buffer_putsalign(buffer *s,const char *buf)
206{
207 return buffer_putalign(s,buf,strlen(buf));
208}
209
210int buffer_puts(buffer *s,const char *buf)
211{
212 return buffer_put(s,buf,strlen(buf));
213}
214
215int buffer_putsflush(buffer *s,const char *buf)
216{
217 return buffer_putflush(s,buf,strlen(buf));
218}
219
220
221/*** buffer_read.c ***/
222
223int buffer_unixread(int fd,char *buf,unsigned len)
224{
225 return read(fd,buf,len);
226}
227
228
229/*** buffer_write.c ***/
230
231int buffer_unixwrite(int fd,char *buf,unsigned len)
232{
233 return write(fd,buf,len);
234}
235#endif
236
237
238/*** byte_chr.c ***/ 37/*** byte_chr.c ***/
239 38
240unsigned byte_chr(char *s,unsigned n,int c) 39unsigned byte_chr(char *s,unsigned n,int c)
@@ -290,16 +89,6 @@ int fd_move(int to,int from)
290} 89}
291 90
292 91
293#if 0
294/*** fifo.c ***/
295
296int fifo_make(const char *fn,int mode)
297{
298 return mkfifo(fn, mode);
299}
300#endif
301
302
303/*** fmt_ptime.c ***/ 92/*** fmt_ptime.c ***/
304 93
305void fmt_ptime30nul(char *s, struct taia *ta) { 94void fmt_ptime30nul(char *s, struct taia *ta) {
@@ -344,60 +133,6 @@ unsigned fmt_taia25(char *s, struct taia *t) {
344} 133}
345 134
346 135
347#ifdef UNUSED
348/*** fmt_uint.c ***/
349
350unsigned fmt_uint(char *s,unsigned u)
351{
352 return fmt_ulong(s,u);
353}
354
355
356/*** fmt_uint0.c ***/
357
358unsigned fmt_uint0(char *s,unsigned u,unsigned n)
359{
360 unsigned len;
361 len = fmt_uint(FMT_LEN, u);
362 while (len < n) {
363 if (s)
364 *s++ = '0';
365 ++len;
366 }
367 if (s)
368 fmt_uint(s, u);
369 return len;
370}
371#endif
372
373
374#ifdef UNUSED
375/*** fmt_ulong.c ***/
376
377unsigned fmt_ulong(char *s,unsigned long u)
378{
379 unsigned len; unsigned long q;
380 len = 1; q = u;
381 while (q > 9) { ++len; q /= 10; }
382 if (s) {
383 s += len;
384 do { *--s = '0' + (u % 10); u /= 10; } while (u); /* handles u == 0 */
385 }
386 return len;
387}
388#endif
389
390
391#ifdef UNUSED
392/*** tai_now.c ***/
393
394void tai_now(struct tai *t)
395{
396 tai_unix(t, time(NULL));
397}
398#endif
399
400
401/*** tai_pack.c ***/ 136/*** tai_pack.c ***/
402 137
403static /* as it isn't used anywhere else */ 138static /* as it isn't used anywhere else */
@@ -447,8 +182,6 @@ void tai_unpack(const char *s,struct tai *t)
447 182
448/*** taia_add.c ***/ 183/*** taia_add.c ***/
449 184
450/* XXX: breaks tai encapsulation */
451
452void taia_add(struct taia *t,const struct taia *u,const struct taia *v) 185void taia_add(struct taia *t,const struct taia *u,const struct taia *v)
453{ 186{
454 t->sec.x = u->sec.x + v->sec.x; 187 t->sec.x = u->sec.x + v->sec.x;
@@ -465,34 +198,8 @@ void taia_add(struct taia *t,const struct taia *u,const struct taia *v)
465} 198}
466 199
467 200
468#ifdef UNUSED
469/*** taia_frac.c ***/
470
471double taia_frac(const struct taia *t)
472{
473 return (t->atto * 0.000000001 + t->nano) * 0.000000001;
474}
475
476
477/*** taia_approx.c ***/
478
479double taia_approx(const struct taia *t)
480{
481 return t->sec->x + taia_frac(t);
482}
483#endif
484
485static
486uint64_t taia2millisec(const struct taia *t)
487{
488 return (t->sec.x * 1000) + (t->nano / 1000000);
489}
490
491
492/*** taia_less.c ***/ 201/*** taia_less.c ***/
493 202
494/* XXX: breaks tai encapsulation */
495
496int taia_less(const struct taia *t, const struct taia *u) 203int taia_less(const struct taia *t, const struct taia *u)
497{ 204{
498 if (t->sec.x < u->sec.x) return 1; 205 if (t->sec.x < u->sec.x) return 1;
@@ -539,8 +246,6 @@ void taia_pack(char *s, const struct taia *t)
539 246
540/*** taia_sub.c ***/ 247/*** taia_sub.c ***/
541 248
542/* XXX: breaks tai encapsulation */
543
544void taia_sub(struct taia *t, const struct taia *u, const struct taia *v) 249void taia_sub(struct taia *t, const struct taia *u, const struct taia *v)
545{ 250{
546 unsigned long unano = u->nano; 251 unsigned long unano = u->nano;
@@ -572,70 +277,15 @@ void taia_uint(struct taia *t, unsigned s)
572} 277}
573 278
574 279
575/*** stralloc_cat.c ***/ 280/*** iopause.c ***/
576#if 0
577
578int stralloc_cat(stralloc *sato,const stralloc *safrom)
579{
580 return stralloc_catb(sato,safrom->s,safrom->len);
581}
582
583
584/*** stralloc_catb.c ***/
585
586int stralloc_catb(stralloc *sa,const char *s,unsigned n)
587{
588 if (!sa->s) return stralloc_copyb(sa,s,n);
589 if (!stralloc_readyplus(sa,n + 1)) return 0;
590 memcpy(sa->s + sa->len,s,n);
591 sa->len += n;
592 sa->s[sa->len] = 'Z'; /* ``offensive programming'' */
593 return 1;
594}
595
596
597/*** stralloc_cats.c ***/
598
599int stralloc_cats(stralloc *sa,const char *s)
600{
601 return stralloc_catb(sa,s,strlen(s));
602}
603
604
605/*** stralloc_eady.c ***/
606
607GEN_ALLOC_ready(stralloc,char,s,len,a,i,n,x,30,stralloc_ready)
608GEN_ALLOC_readyplus(stralloc,char,s,len,a,i,n,x,30,stralloc_readyplus)
609
610
611/*** stralloc_opyb.c ***/
612
613int stralloc_copyb(stralloc *sa,const char *s,unsigned n)
614{
615 if (!stralloc_ready(sa,n + 1)) return 0;
616 memcpy(sa->s,s,n);
617 sa->len = n;
618 sa->s[n] = 'Z'; /* ``offensive programming'' */
619 return 1;
620}
621
622
623/*** stralloc_opys.c ***/
624 281
625int stralloc_copys(stralloc *sa,const char *s) 282static
283uint64_t taia2millisec(const struct taia *t)
626{ 284{
627 return stralloc_copyb(sa,s,strlen(s)); 285 return (t->sec.x * 1000) + (t->nano / 1000000);
628} 286}
629 287
630 288
631/*** stralloc_pend.c ***/
632
633GEN_ALLOC_append(stralloc,char,s,len,a,i,n,x,30,stralloc_readyplus,stralloc_append)
634
635#endif /* stralloc */
636
637/*** iopause.c ***/
638
639void iopause(iopause_fd *x,unsigned len,struct taia *deadline,struct taia *stamp) 289void iopause(iopause_fd *x,unsigned len,struct taia *deadline,struct taia *stamp)
640{ 290{
641 int millisecs; 291 int millisecs;
@@ -711,130 +361,6 @@ int open_write(const char *fn)
711} 361}
712 362
713 363
714/*** openreadclose.c ***/
715#if 0
716int openreadclose(const char *fn,stralloc *sa,unsigned bufsize)
717{
718 int fd;
719 fd = open_read(fn);
720 if (fd == -1) {
721 if (errno == ENOENT) return 0;
722 return -1;
723 }
724 if (readclose(fd,sa,bufsize) == -1) return -1;
725 return 1;
726}
727#endif
728
729
730/*** pathexec_env.c ***/
731#if 0
732static stralloc plus;
733static stralloc tmp;
734
735int pathexec_env(const char *s,const char *t)
736{
737 if (!s) return 1;
738 if (!stralloc_copys(&tmp,s)) return 0;
739 if (t) {
740 if (!stralloc_cats(&tmp,"=")) return 0;
741 if (!stralloc_cats(&tmp,t)) return 0;
742 }
743 if (!stralloc_0(&tmp)) return 0;
744 return stralloc_cat(&plus,&tmp);
745}
746
747void pathexec(char **argv)
748{
749 char **e;
750 unsigned elen;
751 unsigned i;
752 unsigned j;
753 unsigned split;
754 unsigned t;
755
756 if (!stralloc_cats(&plus,"")) return;
757
758 elen = 0;
759 for (i = 0;environ[i];++i)
760 ++elen;
761 for (i = 0;i < plus.len;++i)
762 if (!plus.s[i])
763 ++elen;
764
765 e = malloc((elen + 1) * sizeof(char *));
766 if (!e) return;
767
768 elen = 0;
769 for (i = 0;environ[i];++i)
770 e[elen++] = environ[i];
771
772 j = 0;
773 for (i = 0;i < plus.len;++i)
774 if (!plus.s[i]) {
775 split = str_chr(plus.s + j,'=');
776 for (t = 0;t < elen;++t)
777 if (memcmp(plus.s + j,e[t],split) == 0)
778 if (e[t][split] == '=') {
779 --elen;
780 e[t] = e[elen];
781 break;
782 }
783 if (plus.s[j + split])
784 e[elen++] = plus.s + j;
785 j = i + 1;
786 }
787 e[elen] = 0;
788
789 pathexec_run(*argv,argv,e);
790 free(e);
791}
792#endif
793
794/*** pathexec_run.c ***/
795#if 0
796static stralloc tmp;
797
798void pathexec_run(const char *file,char *const *argv,char *const *envp)
799{
800 const char *path;
801 unsigned split;
802 int savederrno;
803
804 if (file[str_chr(file,'/')]) {
805 execve(file,argv,envp);
806 return;
807 }
808
809 path = getenv("PATH");
810 if (!path) path = "/bin:/usr/bin";
811
812 savederrno = 0;
813 for (;;) {
814 split = str_chr(path,':');
815 if (!stralloc_copyb(&tmp,path,split)) return;
816 if (!split)
817 if (!stralloc_cats(&tmp,".")) return;
818 if (!stralloc_cats(&tmp,"/")) return;
819 if (!stralloc_cats(&tmp,file)) return;
820 if (!stralloc_0(&tmp)) return;
821
822 execve(tmp.s,argv,envp);
823 if (errno != ENOENT) {
824 savederrno = errno;
825 if ((errno != EACCES) && (errno != EPERM) && (errno != EISDIR)) return;
826 }
827
828 if (!path[split]) {
829 if (savederrno) errno = savederrno;
830 return;
831 }
832 path += split;
833 path += 1;
834 }
835}
836#endif
837
838/*** pmatch.c ***/ 364/*** pmatch.c ***/
839 365
840unsigned pmatch(const char *p, const char *s, unsigned len) { 366unsigned pmatch(const char *p, const char *s, unsigned len) {
@@ -878,62 +404,6 @@ unsigned pmatch(const char *p, const char *s, unsigned len) {
878} 404}
879 405
880 406
881#if 0
882/*** prot.c ***/
883
884int prot_gid(int gid)
885{
886 gid_t x = gid;
887 if (setgroups(1,&x) == -1) return -1;
888 return setgid(gid); /* _should_ be redundant, but on some systems it isn't */
889}
890
891int prot_uid(int uid)
892{
893 return setuid(uid);
894}
895#endif
896
897
898/*** readclose.c ***/
899#if 0
900int readclose_append(int fd,stralloc *sa,unsigned bufsize)
901{
902 int r;
903 for (;;) {
904 if (!stralloc_readyplus(sa,bufsize)) { close(fd); return -1; }
905 r = read(fd,sa->s + sa->len,bufsize);
906 if (r == -1) if (errno == EINTR) continue;
907 if (r <= 0) { close(fd); return r; }
908 sa->len += r;
909 }
910}
911
912int readclose(int fd,stralloc *sa,unsigned bufsize)
913{
914 if (!stralloc_copys(sa,"")) { close(fd); return -1; }
915 return readclose_append(fd,sa,bufsize);
916}
917#endif
918
919#if 0
920/*** scan_ulong.c ***/
921
922unsigned scan_ulong(const char *s,unsigned long *u)
923{
924 unsigned pos = 0;
925 unsigned long result = 0;
926 unsigned long c;
927 while ((c = (unsigned long) (unsigned char) (s[pos] - '0')) < 10) {
928 result = result * 10 + c;
929 ++pos;
930 }
931 *u = result;
932 return pos;
933}
934#endif
935
936
937#ifdef UNUSED 407#ifdef UNUSED
938/*** seek_set.c ***/ 408/*** seek_set.c ***/
939 409
@@ -944,20 +414,6 @@ int seek_set(int fd,seek_pos pos)
944#endif 414#endif
945 415
946 416
947/*** sig.c ***/
948
949//int sig_alarm = SIGALRM;
950//int sig_child = SIGCHLD;
951//int sig_cont = SIGCONT;
952//int sig_hangup = SIGHUP;
953//int sig_int = SIGINT;
954//int sig_pipe = SIGPIPE;
955//int sig_term = SIGTERM;
956
957//void (*sig_defaulthandler)(int) = SIG_DFL;
958//void (*sig_ignorehandler)(int) = SIG_IGN;
959
960
961/*** sig_block.c ***/ 417/*** sig_block.c ***/
962 418
963void sig_block(int sig) 419void sig_block(int sig)
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