28 |
/* We don't use printf, as it pulls in >12 kb of code from uclibc (i386). */ |
/* We don't use printf, as it pulls in >12 kb of code from uclibc (i386). */ |
29 |
/* Currently malloc machinery is the biggest part of libc we pull in. */ |
/* Currently malloc machinery is the biggest part of libc we pull in. */ |
30 |
/* We have only one realloc and one strdup, any idea how to do without? */ |
/* We have only one realloc and one strdup, any idea how to do without? */ |
31 |
/* Size (i386, approximate): |
|
32 |
|
/* Size (i386, static uclibc, approximate): |
33 |
* text data bss dec hex filename |
* text data bss dec hex filename |
34 |
* 13036 44 3052 16132 3f04 index.cgi |
* 13036 44 3052 16132 3f04 index.cgi |
35 |
* 2576 4 2048 4628 1214 index.cgi.o |
* 2576 4 2048 4628 1214 index.cgi.o |
149 |
guarantee(3); |
guarantee(3); |
150 |
*dst = c; |
*dst = c; |
151 |
if ((c - '0') > 9 /* not a digit */ |
if ((c - '0') > 9 /* not a digit */ |
152 |
&& ((c|0x20) - 'a') > 26 /* not A-Z or a-z */ |
&& ((c|0x20) - 'a') > ('z' - 'a') /* not A-Z or a-z */ |
153 |
&& !strchr("._-+@", c) |
&& !strchr("._-+@", c) |
154 |
) { |
) { |
155 |
*dst++ = '%'; |
*dst++ = '%'; |
211 |
fmt_02u(n % 100); |
fmt_02u(n % 100); |
212 |
} |
} |
213 |
|
|
214 |
int main(void) |
int main(int argc, char *argv[]) |
215 |
{ |
{ |
216 |
dir_list_t *dir_list; |
dir_list_t *dir_list; |
217 |
dir_list_t *cdir; |
dir_list_t *cdir; |
226 |
QUERY_STRING = getenv("QUERY_STRING"); |
QUERY_STRING = getenv("QUERY_STRING"); |
227 |
if (!QUERY_STRING |
if (!QUERY_STRING |
228 |
|| QUERY_STRING[0] != '/' |
|| QUERY_STRING[0] != '/' |
229 |
|
|| strstr(QUERY_STRING, "//") |
230 |
|| strstr(QUERY_STRING, "/../") |
|| strstr(QUERY_STRING, "/../") |
231 |
|| strcmp(strrchr(QUERY_STRING, '/'), "/..") == 0 |
|| strcmp(strrchr(QUERY_STRING, '/'), "/..") == 0 |
232 |
) { |
) { |
291 |
size_total = 0; |
size_total = 0; |
292 |
cdir = dir_list; |
cdir = dir_list; |
293 |
while (dir_list_count--) { |
while (dir_list_count--) { |
294 |
struct tm *tm; |
struct tm *ptm; |
295 |
|
|
296 |
if (S_ISDIR(cdir->dl_mode)) { |
if (S_ISDIR(cdir->dl_mode)) { |
297 |
count_dirs++; |
count_dirs++; |
316 |
fmt_ull(cdir->dl_size); |
fmt_ull(cdir->dl_size); |
317 |
fmt_str("<td class=dt>"); |
fmt_str("<td class=dt>"); |
318 |
tm = gmtime(&cdir->dl_mtime); |
tm = gmtime(&cdir->dl_mtime); |
319 |
fmt_04u(1900 + tm->tm_year); *dst++ = '-'; |
fmt_04u(1900 + ptm->tm_year); *dst++ = '-'; |
320 |
fmt_02u(tm->tm_mon + 1); *dst++ = '-'; |
fmt_02u(ptm->tm_mon + 1); *dst++ = '-'; |
321 |
fmt_02u(tm->tm_mday); *dst++ = ' '; |
fmt_02u(ptm->tm_mday); *dst++ = ' '; |
322 |
fmt_02u(tm->tm_hour); *dst++ = ':'; |
fmt_02u(ptm->tm_hour); *dst++ = ':'; |
323 |
fmt_02u(tm->tm_min); *dst++ = ':'; |
fmt_02u(ptm->tm_min); *dst++ = ':'; |
324 |
fmt_02u(tm->tm_sec); |
fmt_02u(ptm->tm_sec); |
325 |
*dst++ = '\n'; |
*dst++ = '\n'; |
326 |
|
|
327 |
odd = 1 - odd; |
odd = 1 - odd; |