rename check_request to read_request

This commit is contained in:
prx 2022-08-18 10:54:13 +02:00
parent f388d2a57a
commit 504dd3f759
3 changed files with 17 additions and 17 deletions

30
main.c
View File

@ -3,16 +3,16 @@
int int
main(int argc, char **argv) main(int argc, char **argv)
{ {
char request[GEMINI_REQUEST_MAX] = {'\0'}; char request[GEMINI_REQUEST_MAX] = {'\0'};
char user[_SC_LOGIN_NAME_MAX] = {'\0'}; char user[_SC_LOGIN_NAME_MAX] = {'\0'};
char hostname[GEMINI_REQUEST_MAX] = {'\0'}; char hostname[GEMINI_REQUEST_MAX] = {'\0'};
char query[PATH_MAX] = {'\0'}; char path[GEMINI_REQUEST_MAX] = {'\0'};
char path[PATH_MAX] = {'\0'}; char query[GEMINI_REQUEST_MAX] = {'\0'};
char chroot_dir[PATH_MAX] = DEFAULT_CHROOT; char chroot_dir[PATH_MAX] = DEFAULT_CHROOT;
char file[FILENAME_MAX] = DEFAULT_INDEX; char file[FILENAME_MAX] = DEFAULT_INDEX;
char dir[PATH_MAX] = {'\0'}; char dir[PATH_MAX] = {'\0'};
int option = 0; int option = 0;
int virtualhost = 0; int virtualhost = 0;
/* /*
* request : contain the whole request from client : gemini://...\r\n * request : contain the whole request from client : gemini://...\r\n
@ -21,7 +21,6 @@ main(int argc, char **argv)
* query : file requested in cgi : gemini://...?query * query : file requested in cgi : gemini://...?query
* file : file basename to display. Emtpy is a directory has been requested * file : file basename to display. Emtpy is a directory has been requested
* dir : directory requested. vger will chdir() in to find file * dir : directory requested. vger will chdir() in to find file
* pos : used to parse request and split into interesting parts
*/ */
while ((option = getopt(argc, argv, ":d:l:m:u:c:vi")) != -1) { while ((option = getopt(argc, argv, ":d:l:m:u:c:vi")) != -1) {
@ -56,10 +55,11 @@ main(int argc, char **argv)
*/ */
drop_privileges(user, chroot_dir, cgi_dir); drop_privileges(user, chroot_dir, cgi_dir);
check_request(request); read_request(request);
get_hostname(request, hostname, sizeof(hostname)); split_request(request, hostname, path, query);
get_path(request, path, sizeof(path), virtualhost, hostname); //get_hostname(request, hostname, sizeof(hostname));
get_query(path, query, sizeof(query)); //get_path(request, path, sizeof(path), virtualhost, hostname);
//get_query(path, query, sizeof(query));
/* percent decode */ /* percent decode */
uridecode(query); uridecode(query);

2
vger.c
View File

@ -338,7 +338,7 @@ strip_trailing_slash(char *path)
} }
char * char *
check_request(char *request) read_request(char *request)
{ {
/* /*
* read the request, check for errors and sanitize the input * read the request, check for errors and sanitize the input

2
vger.h
View File

@ -41,7 +41,7 @@ static char _request[GEMINI_REQUEST_MAX] = {'\0'};
/* functions */ /* functions */
ssize_t autoindex(const char *); ssize_t autoindex(const char *);
void cgi(const char *); void cgi(const char *);
char * check_request(char *); char * read_request(char *);
void check_path(char *, size_t, const char *, int); void check_path(char *, size_t, const char *, int);
ssize_t display_file(const char *); ssize_t display_file(const char *);
int do_cgi(const char *, const char *, const char *, const char *, const char *); int do_cgi(const char *, const char *, const char *, const char *, const char *);