Added url variables, removed exec pages

This commit is contained in:
Nate Choe
2022-02-20 21:43:19 -06:00
parent 458c0a545d
commit 4366c8ad65
13 changed files with 202 additions and 98 deletions

View File

@@ -38,10 +38,30 @@ typedef enum {
* */
} RequestType;
typedef struct {
char *data;
/* data is guarunteed to be NULL terminated, although not necessarily
* once. */
size_t len;
size_t allocatedLen;
/* The amount of bytes allocated, for internal use. */
} BinaryString;
typedef struct {
BinaryString var;
BinaryString value;
} PathField;
typedef struct {
BinaryString path;
long fieldCount;
PathField *fields;
} Path;
typedef struct {
long fieldCount;
Field *fields;
char *path;
Path path;
RequestType type;
} Request;
/*HTTP request, pretty self explanatory*/

View File

@@ -14,7 +14,6 @@ sitefiles also allow comments with #
* ```set [variable] [value]``` - sets some local variable for the following pages
* ```define [variable] [value]``` - sets some global variable
* ```read [http path] [file path]``` - if the requested path matches ```[http path]```, return the contents of ```[file path]```. If [file path] is a directory, then the http path is appended to [file path] and that is read instead.
* ```exec [http path] [file path]``` - if the requested path matches ```[http path]```, execute ```[file path]``` and send the the contents of stdout. ```argv[0]``` is the requested path, ```argv[1]``` is a header, ```argv[2]``` is the value for that header, ```argv[3]``` is the next header, and so on.
* ```linked``` - Run getResponse() from the library loaded from the library global variable
* ```throw [http path] [error code]``` - If the requested path matches ```[http path]```, send back the http error code ```[error code]```. For standardization purposes, these error codes are just the number.