6 static stralloc foo
= {0};
9 static struct substdio sserr
= SUBSTDIO_FDBUF(write
,0,errbuf
,1);
11 void logsa(sa
) stralloc
*sa
; {
12 substdio_putflush(&sserr
,sa
->s
,sa
->len
); }
13 void log1(s1
) char *s1
; {
14 substdio_putsflush(&sserr
,s1
); }
15 void log2(s1
,s2
) char *s1
; char *s2
; {
16 substdio_putsflush(&sserr
,s1
);
17 substdio_putsflush(&sserr
,s2
); }
18 void log3(s1
,s2
,s3
) char *s1
; char *s2
; char *s3
; {
19 substdio_putsflush(&sserr
,s1
);
20 substdio_putsflush(&sserr
,s2
);
21 substdio_putsflush(&sserr
,s3
); }
22 void nomem() { log1("alert: out of memory, sleeping...\n"); sleep(10); }
24 void pausedir(dir
) char *dir
;
25 { log3("alert: unable to opendir ",dir
,", sleeping...\n"); sleep(10); }
27 static int issafe(ch
) char ch
;
29 if (ch
== '%') return 0; /* general principle: allman's code is crap */
30 if (ch
< 33) return 0;
31 if (ch
> 126) return 0;
35 void logsafe(s
) char *s
;
38 while (!stralloc_copys(&foo
,s
)) nomem();
39 for (i
= 0;i
< foo
.len
;++i
)
43 if (!issafe(foo
.s
[i
]))