Fix paths, add debug, OpenHTTPD config

FossilOrigin-Name: 1aae905aee3907546c8cbe87a5990a6f09e9c91fb0dbcc064a06be5976fe01bb
This commit is contained in:
nekobit 2023-05-31 22:45:03 +00:00
parent b798501cc3
commit 87586c6060
5 changed files with 31 additions and 2 deletions

View File

@ -0,0 +1,10 @@
server "default" {
listen on * port 80
root "htdocs/treebird"
location "/*\.css" { root "htdocs/treebird" }
location "/*\.png" { root "htdocs/treebird" }
location "/js/*\.js" { root "htdocs/treebird" }
location "/*" {
fastcgi socket tcp localhost 4008
}
}

View File

@ -5,7 +5,9 @@
*/
#include <stdio.h>
#include <stdarg.h>
/* These following two functions use the classic printf to stdout. */
void
print_treebird_logo(void)
{
@ -48,6 +50,19 @@ print_treebird_logo(void)
" Press ^C to quit.\n");
}
int
debug(char const* msg, ...)
{
int res;
va_list ap;
va_start(ap, msg);
printf("[DEBUG] ");
res = vprintf(msg, ap);
puts("");
va_end(ap);
return res;
}
#include "../config.h"
#include "helpers.h"

View File

@ -11,5 +11,6 @@
void set_mstdnt_args(struct mstdnt_args* args, struct session* ssn);
void print_treebird_logo();
int debug(char const* msg, ...);
#endif /* HELPERS_H */

View File

@ -185,6 +185,7 @@ static int application(mastodont_t* api, REQUEST_T req)
// This is a direct page, no requests made, so cleanup now
if (rc == 0)
{
debug("Direct page, cleaning up...");
session_cleanup(ssn);
}

View File

@ -11,6 +11,7 @@
#include "account.h"
#include "error.h"
#include "session.h"
#include "helpers.h"
int parse_path(REQUEST_T req,
struct session* ssn,
@ -125,12 +126,13 @@ int handle_paths(REQUEST_T req,
{
int res;
char* path = GET_ENV("PATH_INFO", req);
// "default" path
if (path == NULL || (path && strcmp(path, "/") == 0))
// "default" path OpenBSD httpd likes to return this one vv
if (path == NULL || (path && (strcmp(path, "/") == 0 || strcmp(path, "") == 0)))
{
return content_index(req, ssn, api);
}
else { // Generic path
debug("Path: %s", path);
for (size_t i = 0; i < paths_len; ++i)
{
if ((res = parse_path(req, ssn, api, paths + i)) != -1)