87 |
* |
* |
88 |
*/ |
*/ |
89 |
|
|
90 |
char *get_commonlog_time(void) |
void get_commonlog_time(char buf[30]) |
91 |
{ |
{ |
92 |
struct tm *t; |
struct tm *t; |
93 |
char *p; |
char *p; |
94 |
unsigned int a; |
unsigned int a; |
|
static char buf[30]; |
|
95 |
int time_offset; |
int time_offset; |
96 |
|
|
97 |
if (use_localtime) { |
if (use_localtime) { |
142 |
*p-- = '0' + a % 10; |
*p-- = '0' + a % 10; |
143 |
*p-- = '0' + a / 10; |
*p-- = '0' + a / 10; |
144 |
*p = '['; |
*p = '['; |
145 |
return p; /* should be same as returning buf */ |
return; /* should be same as returning buf */ |
146 |
} |
} |
147 |
|
|
148 |
/* |
/* |
385 |
memcpy(p, day_tab + t->tm_wday * 4, 4); |
memcpy(p, day_tab + t->tm_wday * 4, 4); |
386 |
} |
} |
387 |
|
|
388 |
char *simple_itoa(unsigned int i) |
void simple_itoa(unsigned int i, char buf[22]) |
389 |
{ |
{ |
390 |
/* 21 digits plus null terminator, good for 64-bit or smaller ints |
/* 21 digits plus null terminator, good for 64-bit or smaller ints |
391 |
* for bigger ints, use a bigger buffer! |
* for bigger ints, use a bigger buffer! |
393 |
* 4294967295 is, incidentally, MAX_UINT (on 32bit systems at this time) |
* 4294967295 is, incidentally, MAX_UINT (on 32bit systems at this time) |
394 |
* and is 10 bytes long |
* and is 10 bytes long |
395 |
*/ |
*/ |
396 |
static char local[22]; |
/* FIXME */ |
397 |
char *p = &local[21]; |
char *p = &buf[21]; |
398 |
*p-- = '\0'; |
*p-- = '\0'; |
399 |
do { |
do { |
400 |
*p-- = '0' + i % 10; |
*p-- = '0' + i % 10; |
401 |
i /= 10; |
i /= 10; |
402 |
} while (i > 0); |
} while (i > 0); |
403 |
return p + 1; |
|
404 |
|
return; |
405 |
} |
} |
406 |
|
|
407 |
/* I don't "do" negative conversions |
/* I don't "do" negative conversions |
411 |
int boa_atoi(char *s) |
int boa_atoi(char *s) |
412 |
{ |
{ |
413 |
int retval; |
int retval; |
414 |
char *reconv; |
char reconv[22]; |
415 |
|
|
416 |
if (!isdigit(*s)) |
if (!isdigit(*s)) |
417 |
return -1; |
return -1; |
420 |
if (retval < 0) |
if (retval < 0) |
421 |
return -1; |
return -1; |
422 |
|
|
423 |
reconv = simple_itoa(retval); |
simple_itoa(retval, reconv); |
424 |
if (memcmp(s,reconv,strlen(s)) != 0) { |
if (memcmp(s,reconv,strlen(s)) != 0) { |
425 |
return -1; |
return -1; |
426 |
} |
} |
429 |
|
|
430 |
int create_temporary_file(short want_unlink, char *storage, int size) |
int create_temporary_file(short want_unlink, char *storage, int size) |
431 |
{ |
{ |
432 |
static char boa_tempfile[MAX_PATH_LENGTH + 1]; |
char boa_tempfile[MAX_PATH_LENGTH + 1]; |
433 |
int fd; |
int fd; |
434 |
|
|
435 |
snprintf(boa_tempfile, MAX_PATH_LENGTH, |
snprintf(boa_tempfile, MAX_PATH_LENGTH, |