386 |
memcpy(p, day_tab + t->tm_wday * 4, 4); |
memcpy(p, day_tab + t->tm_wday * 4, 4); |
387 |
} |
} |
388 |
|
|
389 |
void simple_itoa(unsigned long int i, char buf[22]) |
/* Returns the number of digits */ |
390 |
|
int simple_itoa(unsigned long int i, char buf[22]) |
391 |
{ |
{ |
392 |
/* 21 digits plus null terminator, good for 64-bit or smaller ints |
/* 21 digits plus null terminator, good for 64-bit or smaller ints |
393 |
* for bigger ints, use a bigger buffer! |
* for bigger ints, use a bigger buffer! |
408 |
p++; |
p++; |
409 |
if (p!=buf) memmove( buf, p, digits); |
if (p!=buf) memmove( buf, p, digits); |
410 |
|
|
411 |
return; |
return digits - 1; |
412 |
} |
} |
413 |
|
|
414 |
|
/* Generates an Etag, by using the file size, and the modification time |
415 |
|
*/ |
416 |
|
int create_etag(unsigned long int size, unsigned long int mod_time, |
417 |
|
char etag[MAX_ETAG_LENGTH]) |
418 |
|
{ |
419 |
|
char buf[22]; |
420 |
|
int len, len2; |
421 |
|
|
422 |
|
etag[0] = '\"'; |
423 |
|
len = 1; |
424 |
|
|
425 |
|
len2 = simple_itoa( size % 10000, buf); /* up to 4 digits */ |
426 |
|
memcpy( &etag[len], buf, len2); |
427 |
|
len += len2; |
428 |
|
|
429 |
|
etag[len++] = '-'; |
430 |
|
len2 = simple_itoa( mod_time % 10000, buf); /* also 4 digits */ |
431 |
|
memcpy( &etag[len], buf, len2); |
432 |
|
len += len2; |
433 |
|
|
434 |
|
etag[len++] = '\"'; |
435 |
|
etag[len] = 0; /* etag is null terminated */ |
436 |
|
|
437 |
|
return len; |
438 |
|
} |
439 |
|
|
440 |
|
|
441 |
/* I don't "do" negative conversions |
/* I don't "do" negative conversions |
442 |
* Therefore, -1 indicates error |
* Therefore, -1 indicates error |
443 |
*/ |
*/ |