Compare commits

...

3 Commits

Author SHA1 Message Date
Xavier Del Campo Romero 32af8ddd3d
README.md: Fix CMake build instructions
The previous instructions were simply wrong because `cmake ..` would
attempt to configure the project from the parent directory, instead of
the build directory.
2024-05-05 01:07:01 +02:00
Xavier Del Campo Romero b4572c6217
page.c: Do not get filename on previews
This change should provide the same behaviour, but would avoid
unnecessary calls to dynstr_append and basename(3) when a preview is to
be served.
2024-03-01 00:06:03 +01:00
Xavier Del Campo Romero fb8896bccd
README.md: Update dependencies list
- jq is required by usergen.
- Despite being part of a POSIX.1-2008 environment, m4 is not provided
by Debian or Ubuntu by default.
2024-02-24 08:39:25 +01:00
2 changed files with 13 additions and 14 deletions

View File

@ -59,13 +59,13 @@ to `slcl`. If required, encryption should be done before uploading e.g.: using
#### Mandatory packages #### Mandatory packages
```sh ```sh
sudo apt install build-essential libcjson-dev libssl-dev sudo apt install build-essential libcjson-dev libssl-dev m4 jq
``` ```
#### Optional packages #### Optional packages
```sh ```sh
sudo apt install cmake xxd jq sudo apt install cmake
``` ```
## How to use ## How to use
@ -90,9 +90,8 @@ $ make
#### CMake #### CMake
```sh ```sh
$ mkdir build/ $ cmake -B build
$ cmake .. $ cmake --build build/
$ cmake --build .
``` ```
### Setting up ### Setting up

18
page.c
View File

@ -1305,7 +1305,15 @@ static int serve_file(struct http_response *const r,
dynstr_init(&b); dynstr_init(&b);
dynstr_init(&d); dynstr_init(&d);
if (dynstr_append(&b, "%s", res)) if (preview)
{
if (dynstr_append(&d, "inline"))
{
fprintf(stderr, "%s: dynstr_append inline failed\n", __func__);
goto end;
}
}
else if (dynstr_append(&b, "%s", res))
{ {
fprintf(stderr, "%s: dynstr_append res failed\n", __func__); fprintf(stderr, "%s: dynstr_append res failed\n", __func__);
goto end; goto end;
@ -1315,14 +1323,6 @@ static int serve_file(struct http_response *const r,
fprintf(stderr, "%s: basename(3) failed\n", __func__); fprintf(stderr, "%s: basename(3) failed\n", __func__);
goto end; goto end;
} }
else if (preview)
{
if (dynstr_append(&d, "inline"))
{
fprintf(stderr, "%s: dynstr_append inline failed\n", __func__);
goto end;
}
}
else if (dynstr_append(&d, "attachment; filename=\"%s\"", bn)) else if (dynstr_append(&d, "attachment; filename=\"%s\"", bn))
{ {
fprintf(stderr, "%s: dynstr_append attachment failed\n", __func__); fprintf(stderr, "%s: dynstr_append attachment failed\n", __func__);