Changed how execResposnes work

This commit is contained in:
Nate Choe
2022-02-10 09:43:23 -06:00
parent e5967f7ead
commit b91bb8614d
2 changed files with 2 additions and 2 deletions

View File

@@ -14,7 +14,7 @@ sitefiles also allow comments with #
* ```set [variable] [value]``` - sets some local variable for the following pages * ```set [variable] [value]``` - sets some local variable for the following pages
* ```define [variable] [value]``` - sets some global variable * ```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. * ```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 ```[file path]```, ```argv[1]``` is a header, ```argv[2]``` is the value for that header, ```argv[3]``` is the next header, and so on. * ```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.
* ```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. * ```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.
##### Other than set, commands should take in a regex as argument 1 and operate on a file specified in argument 2. ##### Other than set, commands should take in a regex as argument 1 and operate on a file specified in argument 2.

View File

@@ -150,7 +150,7 @@ static int execResponse(Connection *conn, char *path) {
close(output[1]); close(output[1]);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
args[0] = path; args[0] = conn->path;
for (int i = 0; i < conn->fieldCount; i++) { for (int i = 0; i < conn->fieldCount; i++) {
args[i * 2 + 1] = conn->fields[i].field; args[i * 2 + 1] = conn->fields[i].field;
args[i * 2 + 2] = conn->fields[i].value; args[i * 2 + 2] = conn->fields[i].value;