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>
|
32
src/main.c
32
src/main.c
|
@ -1,39 +1,57 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#include "networking.h"
|
#include "networking.h"
|
||||||
#include "logging.h"
|
#include "logging.h"
|
||||||
#include "headers.h"
|
#include "headers.h"
|
||||||
#include "files.h"
|
#include "files.h"
|
||||||
|
#include "cgi.h"
|
||||||
|
|
||||||
struct handlerSettings {
|
struct handlerSettings {
|
||||||
struct fileSettings fileSettings;
|
struct fileSettings fileSettings;
|
||||||
|
struct cgiSettings cgiSettings;
|
||||||
|
const char* cgiBin;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct handler handlerGetter(struct metaData metaData, const char* host, struct bind* bind) {
|
struct handler handlerGetter(struct metaData metaData, const char* host, struct bind* bind) {
|
||||||
struct handlerSettings* settings = (struct handlerSettings*) bind->settings.ptr;
|
struct handlerSettings* settings = (struct handlerSettings*) bind->settings.ptr;
|
||||||
|
|
||||||
union userData data;
|
union userData data;
|
||||||
data.ptr = &(settings->fileSettings);
|
|
||||||
|
|
||||||
return (struct handler) {
|
if (strncmp(metaData.path, settings->cgiBin, strlen(settings->cgiBin)) == 0) {
|
||||||
.handler = &fileHandler,
|
data.ptr = &(settings->cgiSettings);
|
||||||
.data = data
|
|
||||||
};
|
return (struct handler) {
|
||||||
|
.handler = &cgiHandler,
|
||||||
|
.data = data
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
data.ptr = &(settings->fileSettings);
|
||||||
|
|
||||||
|
return (struct handler) {
|
||||||
|
.handler = &fileHandler,
|
||||||
|
.data = data
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char** argv) {
|
int main(int argc, char** argv) {
|
||||||
setLogging(stderr, DEBUG, true);
|
setLogging(stderr, DEBUG, true);
|
||||||
setCriticalHandler(NULL);
|
setCriticalHandler(NULL);
|
||||||
|
|
||||||
char* documentRoot = realpath(".", NULL);
|
char* documentRoot = realpath("./home/", NULL);
|
||||||
|
|
||||||
struct handlerSettings handlerSettings = {
|
struct handlerSettings handlerSettings = {
|
||||||
.fileSettings = {
|
.fileSettings = {
|
||||||
.documentRoot = documentRoot,
|
.documentRoot = documentRoot,
|
||||||
.index = true
|
.index = true
|
||||||
}
|
},
|
||||||
|
.cgiSettings = {
|
||||||
|
.documentRoot = documentRoot
|
||||||
|
},
|
||||||
|
.cgiBin = "/cgi-bin/"
|
||||||
};
|
};
|
||||||
union userData settingsData;
|
union userData settingsData;
|
||||||
settingsData.ptr = &handlerSettings;
|
settingsData.ptr = &handlerSettings;
|
||||||
|
|
Loading…
Reference in a new issue