mirror of
https://github.com/sigmasternchen/CFloor
synced 2025-03-15 04:18:55 +00:00
some test files
This commit is contained in:
parent
253c2153bd
commit
d6b579cf8c
3 changed files with 41 additions and 7 deletions
7
home/cgi-bin/test.sh
Executable file
7
home/cgi-bin/test.sh
Executable 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
9
home/index.html
Normal file
|
@ -0,0 +1,9 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Test-Page</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Test Page</h1>
|
||||
</body>
|
||||
</html>
|
22
src/main.c
22
src/main.c
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue