summaryrefslogtreecommitdiff
path: root/dev.c
diff options
context:
space:
mode:
Diffstat (limited to 'dev.c')
-rw-r--r--dev.c82
1 files changed, 82 insertions, 0 deletions
diff --git a/dev.c b/dev.c
new file mode 100644
index 0000000..2b96e2c
--- /dev/null
+++ b/dev.c
@@ -0,0 +1,82 @@
+#include <fcgiapp.h>
+#include <stdlib.h>
+#include "main.h"
+
+
+#define printf(...) FCGX_FPrintF(req->out, __VA_ARGS__)
+#define putsF(b) FCGX_FPrintF(req.out,"%s\n", b)
+#define get_param(KEY) FCGX_GetParam(KEY, req->envp)
+
+
+void handle_req(FCGX_Request *req) {
+ char *value;
+ printf("Content-Type: text/html\r\n\r\n");
+ /*
+ if ((value = get_param("req_METHOD")) != NULL) {
+ printf("%s ", value);
+ }
+ if ((value = get_param("req_URI")) != NULL) {
+ printf("%s", value);
+ }
+ if ((value = get_param("QUERY_STRING")) != NULL) {
+ printf("?%s", value);
+ }
+ if ((value = get_param("SERVER_PROTOCOL")) != NULL) {
+ printf(" %s", value);
+ }*/
+ printf("\n");
+}
+int main(void) {
+ int count = 0;
+ char article[50] = "...", *env;
+ char* tmp_h = NULL;
+ int num = 0, i;
+ int sock;
+
+
+ FCGX_Request req;
+ FCGX_Init();
+ sock = FCGX_OpenSocket(":1337", 5);
+ FCGX_InitRequest(&req, sock, 0);
+
+ while(FCGX_Accept_r(&req) >= 0 ) {
+ handle_req(&req);
+ env = FCGX_GetParam("QUERY_STRING",req.envp);
+ if(!env || sscanf(env, "article=%d", &num) != 1)
+ num = 0;
+
+ if( num >= 0)
+ {
+ int nb_CR = 0, c;
+ FILE* fichier = fopen("article/_liste", "r");
+ if(!fichier)
+ erreur("Impossible de charger la page. Veuillez reessayer ult&eacute;rieurement.", &req);
+
+ for(nb_CR=-1;nb_CR < num && fgets(article, 50, fichier);++nb_CR);
+
+ if(nb_CR != num)
+ erreur("Article introuvable", &req);
+ for(tmp_h=article;*tmp_h;tmp_h++)
+ if( isspace(*tmp_h) )
+ *tmp_h = '\0';
+ char date[20], titre[50] = "Vive la lettre H !", ident[50];
+ int type = getinfo(article, titre, date, ident);
+ if( titre )
+ start(titre, "Site d'ache : Articles et présentation de mes projets", &req);
+ else
+ start("Ache", "Site d'ache : Articles et présentation de mes projets", &req);
+ }
+
+
+ ++count;
+ puts("Try");
+ fflush(NULL);
+ sideBar(&req);
+ //sommaire();
+ slideContenu(article, num,&req);
+ voirAussi(&req);
+ end(&req);
+ FCGX_Finish_r(&req);
+ }
+ return 0;
+}