Commit Graph

20 Commits

Author SHA1 Message Date
Xavier Del Campo Romero dbdaac757f
Makefile: Replace -Og with -O1
Only the latter is defined by POSIX.1-2008. Even if there are still some
non-portable flags defined by CFLAGS, it is a good idea to reduce them.
2023-10-25 22:07:11 +02:00
Xavier Del Campo Romero 3e004fa6a1
Adhere to GNU Make directory variables 2023-10-25 21:57:22 +02:00
Xavier Del Campo Romero aaa0ba2755
Makefile: Build libweb also as a shared library 2023-10-25 21:57:10 +02:00
Xavier Del Campo Romero 0222b75e85
Rename project from slweb to libweb
It was found out there was another project of the same name around
(https://git.sr.ht/~strahinja/slweb/), also related to website
generation.

In order to avoid confusion, a new name has been chosen for this
project. Surprisingly, libweb was not in use by any distributions
(according to https://repology.org and AUR index), and it should
reflect well the intention behind this project i.e., being a library
to build web-related stuff.
2023-10-11 00:07:13 +02:00
Xavier Del Campo Romero a89d0e4ae3
Install man pages 2023-09-27 21:55:58 +02:00
Xavier Del Campo Romero 5659eb6439
Add slweb.pc 2023-09-27 21:55:48 +02:00
Xavier Del Campo Romero 9315328983
Makefile, CMakeLists.txt: Add installation targets 2023-09-27 01:05:04 +02:00
Xavier Del Campo Romero 4ee88984fc
Add hello world example 2023-08-09 00:32:13 +02:00
Xavier Del Campo Romero 4dd531b9ed
Makefile: Adapt to slweb
This project was forked off slcl, a "suckless" cloud solution, so that
its HTTP/1.1 server implementation could be reused by other
applications.
2023-07-21 01:28:38 +02:00
Xavier Del Campo Romero 6c6e4c4fec
Makefile: Allow users to define LDFLAGS
This should allow for easier packaging if extra linker flags are
required.
2023-07-20 23:52:56 +02:00
Xavier Del Campo Romero 9cab9431bb
Allow admins to define their own stylesheet
slcl used to provide a hardcoded stylesheet. However, it would be
desirable for some admins to provide a custom stylesheet without having
to rebuild the application.

Now, slcl creates a default stylesheet, namely style.css, into the
target directory, that can be later modified by admins.

While this might contradict the suckless philosophy a bit, hopefully
some admins might find this new feature useful.
2023-07-20 23:52:56 +02:00
Xavier Del Campo Romero 0759122e4c
Split wildcard_cmp into its own component
Future commits will make use of this function outside handler.c.
2023-07-20 23:52:55 +02:00
Xavier Del Campo Romero 3f64235123
Makefile: Use dynstr's own Makefile
dynstr has been recently modified so as to allow building also from
make(1).
2023-07-20 23:52:54 +02:00
Xavier Del Campo Romero 0336d249d6
Makefile: remove .SUFFIXES
According to POSIX.1-2008, .c and .o are already included by the default
.SUFFIX rule, among other suffixes.
2023-07-20 23:52:54 +02:00
Xavier Del Campo Romero 8e40262306
Makefile: make -MF write to .d file instead of stdout
This way, the default rule for .c.o can be used, simplifying the
Makefile a bit more.
2023-07-20 23:52:53 +02:00
Xavier Del Campo Romero af16aa6702
Define _POSIX_C_SOURCE
This allows using the default compiler defined by make(1) (i.e.,
c99(1)), thus improving POSIX compatibility.
2023-07-20 23:52:53 +02:00
Xavier Del Campo Romero fdf6dc2464
Move decode_hex into its own file
- Error detection against strotul(3) has been improved, as done in other
places.
- New function encode_hex has been implemented, which will be used
by future commits.
2023-07-20 23:52:52 +02:00
Xavier Del Campo Romero 7b810b55ab
Implement user quota
This feature allows admins to set a specific quota for each user, in
MiB. This feature is particularly useful for shared instances, where
unlimited user storage might be unfeasible or even dangerous for the
server.

Also, a nice HTML5 <progress> element has been added to the site that
shows how much of the quota has been consumed.

If no quota is set, slcl falls back to the default behaviour i.e.,
assume unlimited storage.

Limitations:

- While HTTP does specify a Content-Length, which determines the length
of the whole request, it does not specify how many files are involved
or their individual sizes.
- Because of this, if multiple files are uploaded simultaneously, the
whole request would be dropped if user quota is exceeded, even if not
all files exceeded it.
- Also, Content-Length adds the length of some HTTP boilerplate
(e.g.: boundaries), but slcl must rely on this before accepting the
whole request. In other words, this means some requests might be
rejected by slcl because of the extra bytes caused by such boilerplate.
- When the quota is exceeded, slcl must close the connection so that
the rest of the transfer is cancelled. Unfortunately, this means no
HTML can be sent back to the customer to inform about the situation.
2023-07-20 23:52:52 +02:00
Xavier Del Campo Romero f5dfbf6e8b
Add cftw
POSIX functions ftw(3) and nftw(3) do not allow passing an opaque
pointer to the callback they call, so it forces the use of statically
allocated data.

ctfw (from "custom ftw") is a custom implementation that solves this,
while also removing unneeded stuff.

This function will be used by future commits.
2023-07-20 23:52:52 +02:00
Xavier Del Campo Romero 37fd5c92ae
Add Makefile 2023-07-20 23:52:51 +02:00