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 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
| #include <fcgi_stdio.h>
#include <dirent.h>
#include <string.h>
#include <errno.h>
#define DIRECTORY "/home/sst/Desktop/"
#define EQUAL 0
int main (int argc, char **argv)
{
while (FCGI_Accept () >= 0)
{
DIR *repertoire = opendir (DIRECTORY) ;
if (repertoire != NULL)
{
struct dirent *entry ;
puts ("Content-type: text/html\r\n\r\n"
"<html>\n"
"\t<head>\n"
"\t\t<title>Accueil</title>\n"
"\t</head>\n"
"\t<body>\n"
"\t\t<table bgcolor=\"#ebebeb\">\n"
"\t\t\t<tr>\n"
"\t\t\t\t<td>\n"
"\t\t\t\t\t<a href=\"accueil.cgi\">accueil page</a>\n"
"\t\t\t\t</td>\n"
"\t\t\t\t<td>\n"
"\t\t\t\t\t<a href=\"config.cgi\">config page</a>\n"
"\t\t\t\t</td>\n"
"\t\t\t</tr>\n"
"\t\t</table>\n"
"\t\t<p>commencer le test</p>"
"\t\t<table>");
while ((entry = readdir (repertoire)) != NULL)
{
if (strcmp (entry->d_name, ".") != EQUAL &&
strcmp (entry->d_name, "..") != EQUAL)
{
printf ("\t\t\t<tr><td> %s </td></tr>\n", entry->d_name);
}
}
puts ("\t\t</table>"
"\t\t<p> fin du test </p>\n"
"\t</body>\n"
"</html>");
closedir (repertoire), repertoire = NULL;
}
else
{
printf ("Content-type: text/html\r\n\r\n"
"<html><body><h1>erreur : %s</h1></body></html>",
strerror (errno));
}
}
return 0;
} |