some test files

This commit is contained in:
overflowerror 2019-03-07 22:01:15 +01:00
parent 253c2153bd
commit d6b579cf8c
3 changed files with 41 additions and 7 deletions

7
home/cgi-bin/test.sh Executable file
View file

@ -0,0 +1,7 @@
#!/bin/bash
echo Status: 200 OK
echo Content-Type: text/plain
echo
echo Hallo Welt

9
home/index.html Normal file
View file

@ -0,0 +1,9 @@
<!DOCTYPE html>
<html>
<head>
<title>Test-Page</title>
</head>
<body>
<h1>Test Page</h1>
</body>
</html>

View file

@ -1,20 +1,33 @@
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include "networking.h"
#include "logging.h"
#include "headers.h"
#include "files.h"
#include "cgi.h"
struct handlerSettings {
struct fileSettings fileSettings;
struct cgiSettings cgiSettings;
const char* cgiBin;
};
struct handler handlerGetter(struct metaData metaData, const char* host, struct bind* bind) {
struct handlerSettings* settings = (struct handlerSettings*) bind->settings.ptr;
union userData data;
if (strncmp(metaData.path, settings->cgiBin, strlen(settings->cgiBin)) == 0) {
data.ptr = &(settings->cgiSettings);
return (struct handler) {
.handler = &cgiHandler,
.data = data
};
} else {
data.ptr = &(settings->fileSettings);
return (struct handler) {
@ -22,18 +35,23 @@ struct handler handlerGetter(struct metaData metaData, const char* host, struct
.data = data
};
}
}
int main(int argc, char** argv) {
setLogging(stderr, DEBUG, true);
setCriticalHandler(NULL);
char* documentRoot = realpath(".", NULL);
char* documentRoot = realpath("./home/", NULL);
struct handlerSettings handlerSettings = {
.fileSettings = {
.documentRoot = documentRoot,
.index = true
}
},
.cgiSettings = {
.documentRoot = documentRoot
},
.cgiBin = "/cgi-bin/"
};
union userData settingsData;
settingsData.ptr = &handlerSettings;