Репозитории ALT
S: | 1.6b15-alt1 |
5.1: | 1.5p6-alt1 |
4.1: | 1.5p5-alt3 |
4.0: | 1.5p5-alt3 |
3.0: | 1.5p4-alt1 |
Группа :: Система/Серверы
Пакет: mathopd
Главная Изменения Спек Патчи Sources Загрузить Gear Bugs and FR Repocop
Патч: mathopd-alt-dircgi.patch
Скачать
Скачать
--- dir_cgi.c.txt 2005-10-17 15:35:18 +0400
+++ dir_cgi.c 2006-10-31 12:55:52 +0300
@@ -1,6 +1,7 @@
/*
* Copyright 2003, 2004 Michiel Boland.
* All rights reserved.
+ * Little improvements 2006 Ilya Evseev.
*
* Redistribution and use in source and binary forms, with or
* without modification, are permitted provided that the following
@@ -72,6 +73,36 @@ static void escape_html_print(const char
}
}
+static void print_list_header(void) {
+#if defined(FORMAT_V2)
+ printf("<table border='1' cellpadding='3'><tr><th>Size</th><th>Last-Modified</th><th>Name</th></tr>\n");
+#endif
+}
+
+static void print_list_bottom(void) {
+#if defined(FORMAT_V2)
+ printf("</table>\n");
+#endif
+}
+
+static void print_dir_entry(struct cgi_dir_entry *p)
+{
+#if defined(FORMAT_V2)
+ printf("<tr><td align=right><tt> %*ld </tt></td><td> %s </td><td> <a href='",
+ sizeof(off_t)*2, p->size, ctime(&p->last_modified));
+ escape_html_print(p->name);
+ printf("'>");
+ escape_html_print(p->name);
+ printf("</a> </td></tr>\n");
+#else
+ printf("<li><a href=\"");
+ escape_html_print(p->name);
+ printf("/\">");
+ escape_html_print(p->name);
+ printf("</a></li>\n");
+#endif
+}
+
static int sort_and_print(struct cgi_dir_entry *p, size_t n)
{
int notinroot;
@@ -90,32 +121,28 @@ static int sort_and_print(struct cgi_dir
printf(" of %s", script_name);
} else
notinroot = 1;
- printf("</title></head><body><p><b>index");
+ printf("</title></head><body><p><b><h2>Index");
if (script_name)
printf(" of %s", script_name);
- printf("</b></p>\n");
- printf("<p>directories:</p><ul>\n");
+ printf("</h2></b></p>\n");
if (notinroot)
- printf("<li><a href=\"../\">[parent directory]</a></li>\n");
+ printf("<ul><a href=\"../\">[parent directory]</a></ul>\n");
+ printf("<p><h3>Directories:</h3></p><ul>\n");
+ print_list_header();
for (i = 0; i < n; i++) {
if (S_ISDIR(p[i].mode)) {
- printf("<li><a href=\"");
- escape_html_print(p[i].name);
- printf("/\">");
- escape_html_print(p[i].name);
- printf("</a></li>\n");
+ print_dir_entry(&p[i]);
}
}
- printf("</ul><p>files:</p><ul>\n");
+ print_list_bottom();
+ printf("</ul><p><h3>Files:</h3></p><ul>\n");
+ print_list_header();
for (i = 0; i < n; i++) {
if (S_ISREG(p[i].mode)) {
- printf("<li><a href=\"");
- escape_html_print(p[i].name);
- printf("\">");
- escape_html_print(p[i].name);
- printf("</a></li>\n");
+ print_dir_entry(&p[i]);
}
}
+ print_list_bottom();
printf("</ul></body></html>\n");
return 0;
}