Skip to content

Commit

Permalink
Premier pas vers la partie 7
Browse files Browse the repository at this point in the history
  • Loading branch information
Edouard CATTEZ committed Feb 9, 2015
1 parent 91b7eba commit 40a9edc
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 0 deletions.
1 change: 1 addition & 0 deletions webserver/http.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#ifndef __HTTP_H__
#define __HTTP_H__

#include <alloca.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
Expand Down
Binary file modified webserver/l7pserv
Binary file not shown.
1 change: 1 addition & 0 deletions webserver/makefile.dep
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
http.o: http.c http.h
main.o: main.c socket.h http.h
socket.o: socket.c socket.h
url.o: url.c url.h
25 changes: 25 additions & 0 deletions webserver/url.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#include "url.h"

char * rewrite_url(char * url)
{
char *rewrited;
int i;

i = 0;
while (url[i] != '\0' && url[i] != '?')
{
i++;
}

rewrited = (char *)malloc(i+1);
strncpy(rewrited, url, i);
rewrited[i+1] = '\0';

return rewrited;
}

int check_and_open(const char * url, const char * document_root)
{

return -1;
}
21 changes: 21 additions & 0 deletions webserver/url.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#ifndef __URL_H__
#define __URL_H__

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

/**
Retourne l'url sans la partie Query succédant le caractère ? (inclus)
*/
char * rewrite_url(char * url);

/**
La fonction doit s’assurer que le fichier est un fichier régulier, ouvrir le fichier en lecture seule et
retourner un descripteur vers ce fichier à l’aide de la fonction open. La fonction doit retourner -1
en cas d’erreur et un descripteur valide en cas de succès.
*/
int check_and_open(const char * url, const char * document_root);


#endif

0 comments on commit 40a9edc

Please sign in to comment.