blob: bdc731923e9d83f2a257503292f2f78a069cc88d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
unsigned int s_len(const char * s) {
unsigned int len=0;
while (s[len]) ++len;
return len;
}
char *fmt_ul(unsigned long u) {
static char strnum[48];
char *hex = "0123456789abcdef";
char *s = strnum+44;
*s = 0;
do { *--s = hex[(u % 16)]; u /= 16; } while(u); /* handles u==0 */
*--s = 'x';
*--s = '0';
return s;
}
char *fmt_o(unsigned char c) {
static char x[8];
x[4] = 0;
x[3] = '0' + (c & 7); c >>= 3;
x[2] = '0' + (c & 7); c >>= 3;
x[1] = '0' + (c & 7);
x[0] = '\\';
return x;
}
void w(char *s) { write(1,s,s_len(s)); }
void wn(unsigned long u) { w(fmt_ul(u)); }
|