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.
This commit is contained in:
parent
832e198f8c
commit
0222b75e85
|
@ -1,6 +1,6 @@
|
||||||
cmake_minimum_required(VERSION 3.13.5)
|
cmake_minimum_required(VERSION 3.13.5)
|
||||||
option(BUILD_EXAMPLES "Build examples" ON)
|
option(BUILD_EXAMPLES "Build examples" ON)
|
||||||
project(slweb C)
|
project(web C)
|
||||||
add_library(${PROJECT_NAME}
|
add_library(${PROJECT_NAME}
|
||||||
handler.c
|
handler.c
|
||||||
html.c
|
html.c
|
||||||
|
@ -11,12 +11,12 @@ add_subdirectory(dynstr)
|
||||||
target_include_directories(${PROJECT_NAME} PUBLIC include)
|
target_include_directories(${PROJECT_NAME} PUBLIC include)
|
||||||
target_link_libraries(${PROJECT_NAME} PUBLIC dynstr)
|
target_link_libraries(${PROJECT_NAME} PUBLIC dynstr)
|
||||||
install(TARGETS ${PROJECT_NAME})
|
install(TARGETS ${PROJECT_NAME})
|
||||||
install(DIRECTORY include/slweb TYPE INCLUDE)
|
install(DIRECTORY include/libweb TYPE INCLUDE)
|
||||||
file(READ ${CMAKE_CURRENT_LIST_DIR}/slweb.pc slweb_pc)
|
file(READ ${CMAKE_CURRENT_LIST_DIR}/libweb.pc libweb_pc)
|
||||||
string(REPLACE /usr/local ${CMAKE_INSTALL_PREFIX} slweb_repl_pc ${slweb_pc})
|
string(REPLACE /usr/local ${CMAKE_INSTALL_PREFIX} libweb_repl_pc ${libweb_pc})
|
||||||
file(WRITE ${CMAKE_BINARY_DIR}/slweb.pc ${slweb_repl_pc})
|
file(WRITE ${CMAKE_BINARY_DIR}/libweb.pc ${libweb_repl_pc})
|
||||||
include(GNUInstallDirs)
|
include(GNUInstallDirs)
|
||||||
install(FILES ${CMAKE_BINARY_DIR}/slweb.pc
|
install(FILES ${CMAKE_BINARY_DIR}/libweb.pc
|
||||||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
|
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
|
||||||
add_subdirectory(doc)
|
add_subdirectory(doc)
|
||||||
|
|
||||||
|
|
10
Makefile
10
Makefile
|
@ -1,6 +1,6 @@
|
||||||
.POSIX:
|
.POSIX:
|
||||||
|
|
||||||
PROJECT = libslweb.a
|
PROJECT = libweb.a
|
||||||
PREFIX = /usr/local
|
PREFIX = /usr/local
|
||||||
DST = $(PREFIX)/lib
|
DST = $(PREFIX)/lib
|
||||||
PC_DST = $(DST)/pkgconfig
|
PC_DST = $(DST)/pkgconfig
|
||||||
|
@ -17,10 +17,10 @@ OBJECTS = \
|
||||||
|
|
||||||
all: $(PROJECT)
|
all: $(PROJECT)
|
||||||
|
|
||||||
install: all $(PC_DST)/slweb.pc
|
install: all $(PC_DST)/libweb.pc
|
||||||
mkdir -p $(PREFIX)/include
|
mkdir -p $(PREFIX)/include
|
||||||
cp -R include/slweb $(PREFIX)/include
|
cp -R include/libweb $(PREFIX)/include
|
||||||
chmod 0644 $(PREFIX)/include/slweb/*.h
|
chmod 0644 $(PREFIX)/include/libweb/*.h
|
||||||
mkdir -p $(DST)
|
mkdir -p $(DST)
|
||||||
cp $(PROJECT) $(DST)
|
cp $(PROJECT) $(DST)
|
||||||
chmod 0755 $(DST)/$(PROJECT)
|
chmod 0755 $(DST)/$(PROJECT)
|
||||||
|
@ -38,7 +38,7 @@ examples: FORCE
|
||||||
$(PROJECT): $(OBJECTS)
|
$(PROJECT): $(OBJECTS)
|
||||||
$(AR) $(ARFLAGS) $@ $(OBJECTS)
|
$(AR) $(ARFLAGS) $@ $(OBJECTS)
|
||||||
|
|
||||||
$(PC_DST)/slweb.pc: slweb.pc
|
$(PC_DST)/libweb.pc: libweb.pc
|
||||||
mkdir -p $(PC_DST)
|
mkdir -p $(PC_DST)
|
||||||
sed -e 's,/usr/local,$(PREFIX),' $< > $@
|
sed -e 's,/usr/local,$(PREFIX),' $< > $@
|
||||||
chmod 0644 $@
|
chmod 0644 $@
|
||||||
|
|
50
README.md
50
README.md
|
@ -1,11 +1,11 @@
|
||||||
# slweb, a simple and lightweight web framework
|
# libweb, a simple and lightweight web framework
|
||||||
|
|
||||||
`slweb` is a simple and lightweight implementation of a web server, written in
|
`libweb` is a simple and lightweight implementation of a web server, written in
|
||||||
C99 plus POSIX.1-2008 extensions, that can be integrated into applications.
|
C99 plus POSIX.1-2008 extensions, that can be integrated into applications.
|
||||||
|
|
||||||
## Disclaimer
|
## Disclaimer
|
||||||
|
|
||||||
Intentionally, `slweb` does not share some of the philosophical views from the
|
Intentionally, `libweb` does not share some of the philosophical views from the
|
||||||
[suckless project](https://suckless.org). However, it still strives towards
|
[suckless project](https://suckless.org). However, it still strives towards
|
||||||
portability, minimalism, simplicity and efficiency.
|
portability, minimalism, simplicity and efficiency.
|
||||||
|
|
||||||
|
@ -22,18 +22,18 @@ the operation (see example below).
|
||||||
- Supports [`multiform/form-data`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/POST)
|
- Supports [`multiform/form-data`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/POST)
|
||||||
, which makes it useful to transfer large amounts of data, such as
|
, which makes it useful to transfer large amounts of data, such as
|
||||||
binary files.
|
binary files.
|
||||||
- [A library](include/slweb/html.h) to write HTML programmatically.
|
- [A library](include/libweb/html.h) to write HTML programmatically.
|
||||||
|
|
||||||
### TLS
|
### TLS
|
||||||
|
|
||||||
In order to maintain simplicity and reduce the risk for security bugs, `slweb`
|
In order to maintain simplicity and reduce the risk for security bugs, `libweb`
|
||||||
does **not** implement TLS support. Instead, this should be provided by a
|
does **not** implement TLS support. Instead, this should be provided by a
|
||||||
reverse proxy, such as [`caddy`](https://caddyserver.com/).
|
reverse proxy, such as [`caddy`](https://caddyserver.com/).
|
||||||
|
|
||||||
### Root permissions
|
### Root permissions
|
||||||
|
|
||||||
`slweb` does not require root permissions. So, in order to avoid the
|
`libweb` does not require root permissions. So, in order to avoid the
|
||||||
risk for security bugs, **please do not run `slweb` as `root`**.
|
risk for security bugs, **please do not run `libweb` as `root`**.
|
||||||
|
|
||||||
## Requirements
|
## Requirements
|
||||||
|
|
||||||
|
@ -59,13 +59,13 @@ sudo apt install cmake
|
||||||
## How to use
|
## How to use
|
||||||
### Build
|
### Build
|
||||||
|
|
||||||
Two build environments are provided for `slweb` - feel free to choose any of
|
Two build environments are provided for `libweb` - feel free to choose any of
|
||||||
them:
|
them:
|
||||||
|
|
||||||
- A mostly POSIX-compliant [`Makefile`](Makefile).
|
- A mostly POSIX-compliant [`Makefile`](Makefile).
|
||||||
- A [`CMakeLists.txt`](CMakeLists.txt).
|
- A [`CMakeLists.txt`](CMakeLists.txt).
|
||||||
|
|
||||||
`slweb` can be built using the standard build process:
|
`libweb` can be built using the standard build process:
|
||||||
|
|
||||||
#### Make
|
#### Make
|
||||||
|
|
||||||
|
@ -73,21 +73,21 @@ them:
|
||||||
$ make
|
$ make
|
||||||
```
|
```
|
||||||
|
|
||||||
This would generate a static library, namely `libslweb.a`, on the project
|
This would generate a static library, namely `libweb.a`, on the project
|
||||||
top-level directory. Applications can then call the top-level `Makefile` by
|
top-level directory. Applications can then call the top-level `Makefile` by
|
||||||
the use of recursive `make`. For example, assuming `slweb` is contained on a
|
the use of recursive `make`. For example, assuming `libweb` is contained on a
|
||||||
subdirectory:
|
subdirectory:
|
||||||
|
|
||||||
```make
|
```make
|
||||||
slweb/libslweb.a:
|
libweb/libweb.a:
|
||||||
+cd slweb && $(MAKE)
|
+cd libweb && $(MAKE)
|
||||||
```
|
```
|
||||||
|
|
||||||
Additionally, `slweb` can be installed using the `install` target. A
|
Additionally, `libweb` can be installed using the `install` target. A
|
||||||
custom prefix can be assigned via the `PREFIX` variable:
|
custom prefix can be assigned via the `PREFIX` variable:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
$ make PREFIX=$HOME/slweb-prefix install
|
$ make PREFIX=$HOME/libweb-prefix install
|
||||||
```
|
```
|
||||||
|
|
||||||
By default, `PREFIX` is assigned to `/usr/local`.
|
By default, `PREFIX` is assigned to `/usr/local`.
|
||||||
|
@ -101,28 +101,28 @@ $ cmake ..
|
||||||
$ cmake --build .
|
$ cmake --build .
|
||||||
```
|
```
|
||||||
|
|
||||||
A CMake target, also called `slweb`, is created. This makes it possible
|
A CMake target, also called `libweb`, is created. This makes it possible
|
||||||
to integrate `slweb` into CMake projects via `add_subdirectory` and
|
to integrate `libweb` into CMake projects via `add_subdirectory` and
|
||||||
`target_link_libraries`. For example:
|
`target_link_libraries`. For example:
|
||||||
|
|
||||||
```cmake
|
```cmake
|
||||||
project(example)
|
project(example)
|
||||||
add_executable(${PROJECT_NAME} main.c)
|
add_executable(${PROJECT_NAME} main.c)
|
||||||
add_subdirectory(slweb)
|
add_subdirectory(libweb)
|
||||||
target_link_libraries(${PROJECT_NAME} PRIVATE slweb)
|
target_link_libraries(${PROJECT_NAME} PRIVATE libweb)
|
||||||
```
|
```
|
||||||
|
|
||||||
Additionally, `slweb` can be installed using the standard procedure
|
Additionally, `libweb` can be installed using the standard procedure
|
||||||
in CMake. As usual, a custom prefix can be assigned via the
|
in CMake. As usual, a custom prefix can be assigned via the
|
||||||
`CMAKE_INSTALL_PREFIX` variable:
|
`CMAKE_INSTALL_PREFIX` variable:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
$ cmake --install build/ -DCMAKE_INSTALL_PREFIX=$HOME/slweb-prefix
|
$ cmake --install build/ -DCMAKE_INSTALL_PREFIX=$HOME/libweb-prefix
|
||||||
```
|
```
|
||||||
|
|
||||||
### Examples
|
### Examples
|
||||||
|
|
||||||
[A directory](examples) with examples shows how `slweb` can be used by
|
[A directory](examples) with examples shows how `libweb` can be used by
|
||||||
applications. These can be built from the top-level directory with:
|
applications. These can be built from the top-level directory with:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
|
@ -141,7 +141,7 @@ $ cmake --build .
|
||||||
|
|
||||||
## Why this project?
|
## Why this project?
|
||||||
|
|
||||||
Originally, `slweb` was part of the
|
Originally, `libweb` was part of the
|
||||||
[`slcl`](https://gitea.privatedns.org/xavi92/slcl) project, a lightweight
|
[`slcl`](https://gitea.privatedns.org/xavi92/slcl) project, a lightweight
|
||||||
cloud solution also written in C99 plus POSIX extensions. However, there
|
cloud solution also written in C99 plus POSIX extensions. However, there
|
||||||
always was a clear separation between application logic and the underlying
|
always was a clear separation between application logic and the underlying
|
||||||
|
@ -170,14 +170,14 @@ interface called
|
||||||
simple as possible for administrators.
|
simple as possible for administrators.
|
||||||
- The [`onion`](https://github.com/davidmoreno/onion) project, which
|
- The [`onion`](https://github.com/davidmoreno/onion) project, which
|
||||||
does follow the HTTP library concept, was initially considered for
|
does follow the HTTP library concept, was initially considered for
|
||||||
`slcl`, but has a larger scope than `slweb`, and again simplicity was
|
`slcl`, but has a larger scope than `libweb`, and again simplicity was
|
||||||
essential for `slcl`.
|
essential for `slcl`.
|
||||||
- And, after all, it was a good excuse to learn about HTTP/1.1.
|
- And, after all, it was a good excuse to learn about HTTP/1.1.
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
```
|
```
|
||||||
slweb, a simple and lightweight web framework.
|
libweb, a simple and lightweight web framework.
|
||||||
Copyright (C) 2023 Xavier Del Campo Romero
|
Copyright (C) 2023 Xavier Del Campo Romero
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
.TH HANDLER_ADD 3 2023-09-13 0.1.0 "slweb Library Reference"
|
.TH HANDLER_ADD 3 2023-09-13 0.1.0 "libweb Library Reference"
|
||||||
|
|
||||||
.SH NAME
|
.SH NAME
|
||||||
handler_add \- add an endpoint to a web server handler object
|
handler_add \- add an endpoint to a web server handler object
|
||||||
|
@ -6,7 +6,7 @@ handler_add \- add an endpoint to a web server handler object
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
.LP
|
.LP
|
||||||
.nf
|
.nf
|
||||||
#include <slweb/handler.h>
|
#include <libweb/handler.h>
|
||||||
.P
|
.P
|
||||||
int handler_add(struct handler *\fIh\fP, const char *\fIurl\fP, enum http_op \fIop\fP, handler_fn \fIf\fP, void *\fIuser\fP);
|
int handler_add(struct handler *\fIh\fP, const char *\fIurl\fP, enum http_op \fIop\fP, handler_fn \fIf\fP, void *\fIuser\fP);
|
||||||
.fi
|
.fi
|
||||||
|
@ -40,13 +40,13 @@ for an exhaustive list of supported operations.
|
||||||
|
|
||||||
.I f
|
.I f
|
||||||
is a function pointer that shall be executed by
|
is a function pointer that shall be executed by
|
||||||
.I slweb
|
.I libweb
|
||||||
if an incoming request matches the resource and operation defined by
|
if an incoming request matches the resource and operation defined by
|
||||||
.I url
|
.I url
|
||||||
and
|
and
|
||||||
.IR op ,
|
.IR op ,
|
||||||
respectively. See
|
respectively. See
|
||||||
.IR slweb_handler (7)
|
.IR libweb_handler (7)
|
||||||
for the definition for
|
for the definition for
|
||||||
.IR handler_fn .
|
.IR handler_fn .
|
||||||
|
|
||||||
|
@ -77,7 +77,7 @@ for a list of possible errors.
|
||||||
.BR handler_alloc (3),
|
.BR handler_alloc (3),
|
||||||
.BR handler_free (3),
|
.BR handler_free (3),
|
||||||
.BR handler_listen (3),
|
.BR handler_listen (3),
|
||||||
.BR slweb_handler (7).
|
.BR libweb_handler (7).
|
||||||
|
|
||||||
.SH COPYRIGHT
|
.SH COPYRIGHT
|
||||||
Copyright (C) 2023 Xavier Del Campo Romero.
|
Copyright (C) 2023 Xavier Del Campo Romero.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
.TH HANDLER_ALLOC 3 2023-09-13 0.1.0 "slweb Library Reference"
|
.TH HANDLER_ALLOC 3 2023-09-13 0.1.0 "libweb Library Reference"
|
||||||
|
|
||||||
.SH NAME
|
.SH NAME
|
||||||
handler_alloc \- allocate a web server handler object
|
handler_alloc \- allocate a web server handler object
|
||||||
|
@ -6,7 +6,7 @@ handler_alloc \- allocate a web server handler object
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
.LP
|
.LP
|
||||||
.nf
|
.nf
|
||||||
#include <slweb/handler.h>
|
#include <libweb/handler.h>
|
||||||
.P
|
.P
|
||||||
struct handler *handler_alloc(const struct handler_cfg *\fIcfg\fP);
|
struct handler *handler_alloc(const struct handler_cfg *\fIcfg\fP);
|
||||||
.fi
|
.fi
|
||||||
|
@ -17,17 +17,17 @@ The
|
||||||
function allocates a
|
function allocates a
|
||||||
.I "struct handler"
|
.I "struct handler"
|
||||||
object, containing the required data by
|
object, containing the required data by
|
||||||
.I slweb
|
.I libweb
|
||||||
to handle a web server. This object is meant to be consumed by
|
to handle a web server. This object is meant to be consumed by
|
||||||
other functions from
|
other functions from
|
||||||
.IR slweb_handler (7).
|
.IR libweb_handler (7).
|
||||||
.I cfg
|
.I cfg
|
||||||
defines the initial configuration, whose structure is defined by
|
defines the initial configuration, whose structure is defined by
|
||||||
.IR slweb_handler (7).
|
.IR libweb_handler (7).
|
||||||
|
|
||||||
.I "struct handler"
|
.I "struct handler"
|
||||||
is an opaque object internal to
|
is an opaque object internal to
|
||||||
.I slweb
|
.I libweb
|
||||||
and therefore is not accessible to callers.
|
and therefore is not accessible to callers.
|
||||||
|
|
||||||
.SH RETURN VALUE
|
.SH RETURN VALUE
|
||||||
|
@ -48,7 +48,7 @@ for a list of possible errors.
|
||||||
.BR handler_free (3),
|
.BR handler_free (3),
|
||||||
.BR handler_add (3),
|
.BR handler_add (3),
|
||||||
.BR handler_listen (3),
|
.BR handler_listen (3),
|
||||||
.BR slweb_handler (7).
|
.BR libweb_handler (7).
|
||||||
|
|
||||||
.SH COPYRIGHT
|
.SH COPYRIGHT
|
||||||
Copyright (C) 2023 Xavier Del Campo Romero.
|
Copyright (C) 2023 Xavier Del Campo Romero.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
.TH HANDLER_FREE 3 2023-09-14 0.1.0 "slweb Library Reference"
|
.TH HANDLER_FREE 3 2023-09-14 0.1.0 "libweb Library Reference"
|
||||||
|
|
||||||
.SH NAME
|
.SH NAME
|
||||||
handler_free \- free a web server handler object
|
handler_free \- free a web server handler object
|
||||||
|
@ -6,7 +6,7 @@ handler_free \- free a web server handler object
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
.LP
|
.LP
|
||||||
.nf
|
.nf
|
||||||
#include <slweb/handler.h>
|
#include <libweb/handler.h>
|
||||||
.P
|
.P
|
||||||
void handler_free(struct handler *\fIh\fP);
|
void handler_free(struct handler *\fIh\fP);
|
||||||
.fi
|
.fi
|
||||||
|
@ -29,7 +29,7 @@ No errors are defined.
|
||||||
|
|
||||||
.SH SEE ALSO
|
.SH SEE ALSO
|
||||||
.BR handler_alloc (3),
|
.BR handler_alloc (3),
|
||||||
.BR slweb_handler (7).
|
.BR libweb_handler (7).
|
||||||
|
|
||||||
.SH COPYRIGHT
|
.SH COPYRIGHT
|
||||||
Copyright (C) 2023 Xavier Del Campo Romero.
|
Copyright (C) 2023 Xavier Del Campo Romero.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
.TH HANDLER_LISTEN 3 2023-09-14 0.1.0 "slweb Library Reference"
|
.TH HANDLER_LISTEN 3 2023-09-14 0.1.0 "libweb Library Reference"
|
||||||
|
|
||||||
.SH NAME
|
.SH NAME
|
||||||
handler_listen \- listen to and handle incoming connections on a web
|
handler_listen \- listen to and handle incoming connections on a web
|
||||||
|
@ -7,7 +7,7 @@ server
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
.LP
|
.LP
|
||||||
.nf
|
.nf
|
||||||
#include <slweb/handler.h>
|
#include <libweb/handler.h>
|
||||||
.P
|
.P
|
||||||
int handler_listen(struct handler *\fIh\fP, unsigned short \fIport\fP);
|
int handler_listen(struct handler *\fIh\fP, unsigned short \fIport\fP);
|
||||||
.fi
|
.fi
|
||||||
|
@ -46,7 +46,7 @@ No errors are defined.
|
||||||
|
|
||||||
.SH FUTURE DIRECTIONS
|
.SH FUTURE DIRECTIONS
|
||||||
When no configured endpoint matches the incoming request,
|
When no configured endpoint matches the incoming request,
|
||||||
.I slweb
|
.I libweb
|
||||||
shall respond with a
|
shall respond with a
|
||||||
.B 404 Not Found
|
.B 404 Not Found
|
||||||
HTTP status code with no payload. Since some library users might want
|
HTTP status code with no payload. Since some library users might want
|
||||||
|
@ -61,7 +61,7 @@ similarly to its member
|
||||||
.BR handler_alloc (3),
|
.BR handler_alloc (3),
|
||||||
.BR handler_free (3),
|
.BR handler_free (3),
|
||||||
.BR handler_add (3),
|
.BR handler_add (3),
|
||||||
.BR slweb_handler (7),
|
.BR libweb_handler (7),
|
||||||
.BR signal (7).
|
.BR signal (7).
|
||||||
|
|
||||||
.SH COPYRIGHT
|
.SH COPYRIGHT
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
.TH HTML_NODE_ADD_ATTR 3 2023-09-24 0.1.0 "slweb Library Reference"
|
.TH HTML_NODE_ADD_ATTR 3 2023-09-24 0.1.0 "libweb Library Reference"
|
||||||
|
|
||||||
.SH NAME
|
.SH NAME
|
||||||
html_node_add_attr \- add attribute to a HTML node
|
html_node_add_attr \- add attribute to a HTML node
|
||||||
|
@ -6,7 +6,7 @@ html_node_add_attr \- add attribute to a HTML node
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
.LP
|
.LP
|
||||||
.nf
|
.nf
|
||||||
#include <slweb/html.h>
|
#include <libweb/html.h>
|
||||||
.P
|
.P
|
||||||
int html_node_add_attr(struct html_node *\fIn\fP, const char *\fIattr\fP, const char *\fIval\fP);
|
int html_node_add_attr(struct html_node *\fIn\fP, const char *\fIattr\fP, const char *\fIval\fP);
|
||||||
.fi
|
.fi
|
||||||
|
@ -27,7 +27,7 @@ is a null-terminated string with the name of the attribute.
|
||||||
.I val
|
.I val
|
||||||
is a null-terminated string with the value for the attribute.
|
is a null-terminated string with the value for the attribute.
|
||||||
|
|
||||||
.I slweb
|
.I libweb
|
||||||
allocates copies of the null-terminated strings defined by
|
allocates copies of the null-terminated strings defined by
|
||||||
.I attr
|
.I attr
|
||||||
and
|
and
|
||||||
|
@ -66,7 +66,7 @@ No errors are defined.
|
||||||
.BR html_node_free (3),
|
.BR html_node_free (3),
|
||||||
.BR html_node_set_value (3),
|
.BR html_node_set_value (3),
|
||||||
.BR html_node_set_value_unescaped (3),
|
.BR html_node_set_value_unescaped (3),
|
||||||
.BR slweb_http (7).
|
.BR libweb_http (7).
|
||||||
|
|
||||||
.SH COPYRIGHT
|
.SH COPYRIGHT
|
||||||
Copyright (C) 2023 Xavier Del Campo Romero.
|
Copyright (C) 2023 Xavier Del Campo Romero.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
.TH HTML_NODE_ADD_CHILD 3 2023-09-25 0.1.0 "slweb Library Reference"
|
.TH HTML_NODE_ADD_CHILD 3 2023-09-25 0.1.0 "libweb Library Reference"
|
||||||
|
|
||||||
.SH NAME
|
.SH NAME
|
||||||
html_node_add_child \- add child to a HTML node
|
html_node_add_child \- add child to a HTML node
|
||||||
|
@ -6,7 +6,7 @@ html_node_add_child \- add child to a HTML node
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
.LP
|
.LP
|
||||||
.nf
|
.nf
|
||||||
#include <slweb/html.h>
|
#include <libweb/html.h>
|
||||||
.P
|
.P
|
||||||
struct html_node *html_node_add_child(struct html_node *\fIn\fP, const char *\fIelem\fP);
|
struct html_node *html_node_add_child(struct html_node *\fIn\fP, const char *\fIelem\fP);
|
||||||
.fi
|
.fi
|
||||||
|
@ -41,7 +41,7 @@ and one child node:
|
||||||
.in +4n
|
.in +4n
|
||||||
.EX
|
.EX
|
||||||
#include <dynstr.h>
|
#include <dynstr.h>
|
||||||
#include <slweb/html.h>
|
#include <libweb/html.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
@ -105,7 +105,7 @@ if
|
||||||
fails.
|
fails.
|
||||||
|
|
||||||
Internally,
|
Internally,
|
||||||
.I slweb
|
.I libweb
|
||||||
calls
|
calls
|
||||||
.IR html_node_add_sibling (3)
|
.IR html_node_add_sibling (3)
|
||||||
from a child node when a node already has one.
|
from a child node when a node already has one.
|
||||||
|
@ -113,7 +113,7 @@ from a child node when a node already has one.
|
||||||
.SH SEE ALSO
|
.SH SEE ALSO
|
||||||
.BR html_node_alloc (3),
|
.BR html_node_alloc (3),
|
||||||
.BR html_node_add_sibling (3),
|
.BR html_node_add_sibling (3),
|
||||||
.BR slweb_http (7).
|
.BR libweb_http (7).
|
||||||
|
|
||||||
.SH COPYRIGHT
|
.SH COPYRIGHT
|
||||||
Copyright (C) 2023 Xavier Del Campo Romero.
|
Copyright (C) 2023 Xavier Del Campo Romero.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
.TH HTML_NODE_ADD_SIBLING 3 2023-09-25 0.1.0 "slweb Library Reference"
|
.TH HTML_NODE_ADD_SIBLING 3 2023-09-25 0.1.0 "libweb Library Reference"
|
||||||
|
|
||||||
.SH NAME
|
.SH NAME
|
||||||
html_node_add_sibling \- add sibling to a HTML node
|
html_node_add_sibling \- add sibling to a HTML node
|
||||||
|
@ -6,7 +6,7 @@ html_node_add_sibling \- add sibling to a HTML node
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
.LP
|
.LP
|
||||||
.nf
|
.nf
|
||||||
#include <slweb/html.h>
|
#include <libweb/html.h>
|
||||||
.P
|
.P
|
||||||
void html_node_add_sibling(struct html_node *\fIn\fP, struct html_node *\fIsibling\fP);
|
void html_node_add_sibling(struct html_node *\fIn\fP, struct html_node *\fIsibling\fP);
|
||||||
.fi
|
.fi
|
||||||
|
@ -44,7 +44,7 @@ was still made public so as to cover possibly less common use cases.
|
||||||
.SH SEE ALSO
|
.SH SEE ALSO
|
||||||
.BR html_node_alloc (3),
|
.BR html_node_alloc (3),
|
||||||
.BR html_node_add_child (3),
|
.BR html_node_add_child (3),
|
||||||
.BR slweb_http (7).
|
.BR libweb_http (7).
|
||||||
|
|
||||||
.SH COPYRIGHT
|
.SH COPYRIGHT
|
||||||
Copyright (C) 2023 Xavier Del Campo Romero.
|
Copyright (C) 2023 Xavier Del Campo Romero.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
.TH HTML_NODE_ALLOC 3 2023-09-15 0.1.0 "slweb Library Reference"
|
.TH HTML_NODE_ALLOC 3 2023-09-15 0.1.0 "libweb Library Reference"
|
||||||
|
|
||||||
.SH NAME
|
.SH NAME
|
||||||
html_node_alloc \- allocate a HTML node
|
html_node_alloc \- allocate a HTML node
|
||||||
|
@ -6,7 +6,7 @@ html_node_alloc \- allocate a HTML node
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
.LP
|
.LP
|
||||||
.nf
|
.nf
|
||||||
#include <slweb/html.h>
|
#include <libweb/html.h>
|
||||||
.P
|
.P
|
||||||
struct html_node *html_node_alloc(const char *\fIelement\fP);
|
struct html_node *html_node_alloc(const char *\fIelement\fP);
|
||||||
.fi
|
.fi
|
||||||
|
@ -22,7 +22,7 @@ is the name of the HTML tag.
|
||||||
|
|
||||||
.I "struct html_node"
|
.I "struct html_node"
|
||||||
is an opaque object internal to
|
is an opaque object internal to
|
||||||
.I slweb
|
.I libweb
|
||||||
and therefore is not accessible to callers.
|
and therefore is not accessible to callers.
|
||||||
|
|
||||||
.SH RETURN VALUE
|
.SH RETURN VALUE
|
||||||
|
@ -64,7 +64,7 @@ it via
|
||||||
.BR html_node_add_attr (3),
|
.BR html_node_add_attr (3),
|
||||||
.BR html_node_add_child (3),
|
.BR html_node_add_child (3),
|
||||||
.BR html_node_add_sibling (3),
|
.BR html_node_add_sibling (3),
|
||||||
.BR slweb_html (7).
|
.BR libweb_html (7).
|
||||||
|
|
||||||
.SH COPYRIGHT
|
.SH COPYRIGHT
|
||||||
Copyright (C) 2023 Xavier Del Campo Romero.
|
Copyright (C) 2023 Xavier Del Campo Romero.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
.TH HTML_NODE_FREE 3 2023-09-16 0.1.0 "slweb Library Reference"
|
.TH HTML_NODE_FREE 3 2023-09-16 0.1.0 "libweb Library Reference"
|
||||||
|
|
||||||
.SH NAME
|
.SH NAME
|
||||||
html_node_free \- free a HTML node and its children
|
html_node_free \- free a HTML node and its children
|
||||||
|
@ -6,7 +6,7 @@ html_node_free \- free a HTML node and its children
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
.LP
|
.LP
|
||||||
.nf
|
.nf
|
||||||
#include <slweb/html.h>
|
#include <libweb/html.h>
|
||||||
.P
|
.P
|
||||||
void html_node_free(struct html_node *\fIn\fP);
|
void html_node_free(struct html_node *\fIn\fP);
|
||||||
.fi
|
.fi
|
||||||
|
@ -37,7 +37,7 @@ for a child node.
|
||||||
|
|
||||||
.SH SEE ALSO
|
.SH SEE ALSO
|
||||||
.BR html_node_alloc (3),
|
.BR html_node_alloc (3),
|
||||||
.BR slweb_html (7).
|
.BR libweb_html (7).
|
||||||
|
|
||||||
.SH COPYRIGHT
|
.SH COPYRIGHT
|
||||||
Copyright (C) 2023 Xavier Del Campo Romero.
|
Copyright (C) 2023 Xavier Del Campo Romero.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
.TH HTML_NODE_SET_VALUE 3 2023-09-24 0.1.0 "slweb Library Reference"
|
.TH HTML_NODE_SET_VALUE 3 2023-09-24 0.1.0 "libweb Library Reference"
|
||||||
|
|
||||||
.SH NAME
|
.SH NAME
|
||||||
html_node_set_value \- set value to a HTML node
|
html_node_set_value \- set value to a HTML node
|
||||||
|
@ -6,7 +6,7 @@ html_node_set_value \- set value to a HTML node
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
.LP
|
.LP
|
||||||
.nf
|
.nf
|
||||||
#include <slweb/html.h>
|
#include <libweb/html.h>
|
||||||
.P
|
.P
|
||||||
int html_node_set_value(struct html_node *\fIn\fP, const char *\fIval\fP);
|
int html_node_set_value(struct html_node *\fIn\fP, const char *\fIval\fP);
|
||||||
.fi
|
.fi
|
||||||
|
@ -25,7 +25,7 @@ or
|
||||||
.I val
|
.I val
|
||||||
is a null-terminated string with the value to be assigned to the node.
|
is a null-terminated string with the value to be assigned to the node.
|
||||||
|
|
||||||
.I slweb
|
.I libweb
|
||||||
allocates a copy of the null-terminated string defined by
|
allocates a copy of the null-terminated string defined by
|
||||||
.IR val .
|
.IR val .
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@ No errors are defined.
|
||||||
.BR html_node_free (3),
|
.BR html_node_free (3),
|
||||||
.BR html_node_set_value_unescaped (3),
|
.BR html_node_set_value_unescaped (3),
|
||||||
.BR html_node_add_attr (3),
|
.BR html_node_add_attr (3),
|
||||||
.BR slweb_http (7).
|
.BR libweb_http (7).
|
||||||
|
|
||||||
.SH COPYRIGHT
|
.SH COPYRIGHT
|
||||||
Copyright (C) 2023 Xavier Del Campo Romero.
|
Copyright (C) 2023 Xavier Del Campo Romero.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
.TH HTML_NODE_SET_VALUE_UNESCAPED 3 2023-09-24 0.1.0 "slweb Library Reference"
|
.TH HTML_NODE_SET_VALUE_UNESCAPED 3 2023-09-24 0.1.0 "libweb Library Reference"
|
||||||
|
|
||||||
.SH NAME
|
.SH NAME
|
||||||
html_node_set_value_unescaped \- set value to a HTML node
|
html_node_set_value_unescaped \- set value to a HTML node
|
||||||
|
@ -6,7 +6,7 @@ html_node_set_value_unescaped \- set value to a HTML node
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
.LP
|
.LP
|
||||||
.nf
|
.nf
|
||||||
#include <slweb/html.h>
|
#include <libweb/html.h>
|
||||||
.P
|
.P
|
||||||
int html_node_set_value_unescaped(struct html_node *\fIn\fP, const char *\fIval\fP);
|
int html_node_set_value_unescaped(struct html_node *\fIn\fP, const char *\fIval\fP);
|
||||||
.fi
|
.fi
|
||||||
|
@ -25,7 +25,7 @@ or
|
||||||
.I val
|
.I val
|
||||||
is a null-terminated string with the value to be assigned to the node.
|
is a null-terminated string with the value to be assigned to the node.
|
||||||
|
|
||||||
.I slweb
|
.I libweb
|
||||||
allocates a copy of the null-terminated string defined by
|
allocates a copy of the null-terminated string defined by
|
||||||
.IR val .
|
.IR val .
|
||||||
|
|
||||||
|
@ -70,7 +70,7 @@ No errors are defined.
|
||||||
.BR html_node_free (3),
|
.BR html_node_free (3),
|
||||||
.BR html_node_set_value (3),
|
.BR html_node_set_value (3),
|
||||||
.BR html_node_add_attr (3),
|
.BR html_node_add_attr (3),
|
||||||
.BR slweb_http (7).
|
.BR libweb_http (7).
|
||||||
|
|
||||||
.SH COPYRIGHT
|
.SH COPYRIGHT
|
||||||
Copyright (C) 2023 Xavier Del Campo Romero.
|
Copyright (C) 2023 Xavier Del Campo Romero.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
.TH HTML_SERIALIZE 3 2023-09-24 0.1.0 "slweb Library Reference"
|
.TH HTML_SERIALIZE 3 2023-09-24 0.1.0 "libweb Library Reference"
|
||||||
|
|
||||||
.SH NAME
|
.SH NAME
|
||||||
html_serialize \- add attribute to a HTML node
|
html_serialize \- add attribute to a HTML node
|
||||||
|
@ -6,7 +6,7 @@ html_serialize \- add attribute to a HTML node
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
.LP
|
.LP
|
||||||
.nf
|
.nf
|
||||||
#include <slweb/html.h>
|
#include <libweb/html.h>
|
||||||
.P
|
.P
|
||||||
int html_serialize(const struct html_node *\fIn\fP, struct dynstr *\fId\fP);
|
int html_serialize(const struct html_node *\fIn\fP, struct dynstr *\fId\fP);
|
||||||
.fi
|
.fi
|
||||||
|
@ -41,7 +41,7 @@ No errors are defined.
|
||||||
.BR html_node_add_attr (3),
|
.BR html_node_add_attr (3),
|
||||||
.BR html_node_set_value (3),
|
.BR html_node_set_value (3),
|
||||||
.BR html_node_set_value_unescaped (3),
|
.BR html_node_set_value_unescaped (3),
|
||||||
.BR slweb_http (7).
|
.BR libweb_http (7).
|
||||||
|
|
||||||
.SH COPYRIGHT
|
.SH COPYRIGHT
|
||||||
Copyright (C) 2023 Xavier Del Campo Romero.
|
Copyright (C) 2023 Xavier Del Campo Romero.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
.TH HTTP_ALLOC 3 2023-09-06 0.1.0 "slweb Library Reference"
|
.TH HTTP_ALLOC 3 2023-09-06 0.1.0 "libweb Library Reference"
|
||||||
|
|
||||||
.SH NAME
|
.SH NAME
|
||||||
http_alloc \- allocate a HTTP context object
|
http_alloc \- allocate a HTTP context object
|
||||||
|
@ -6,7 +6,7 @@ http_alloc \- allocate a HTTP context object
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
.LP
|
.LP
|
||||||
.nf
|
.nf
|
||||||
#include <slweb/http.h>
|
#include <libweb/http.h>
|
||||||
.P
|
.P
|
||||||
struct http *http_alloc(const struct http_cfg *\fIcfg\fP);
|
struct http *http_alloc(const struct http_cfg *\fIcfg\fP);
|
||||||
.fi
|
.fi
|
||||||
|
@ -17,17 +17,17 @@ The
|
||||||
function allocates a
|
function allocates a
|
||||||
.I "struct http_ctx"
|
.I "struct http_ctx"
|
||||||
object, containing the required data by
|
object, containing the required data by
|
||||||
.I slweb
|
.I libweb
|
||||||
to handle a HTTP connection. This object is meant to be consumed by
|
to handle a HTTP connection. This object is meant to be consumed by
|
||||||
other functions from
|
other functions from
|
||||||
.IR slweb .
|
.IR libweb .
|
||||||
.I cfg
|
.I cfg
|
||||||
defines the configuration for the HTTP context, whose structure is defined by
|
defines the configuration for the HTTP context, whose structure is defined by
|
||||||
.IR slweb_http (7).
|
.IR libweb_http (7).
|
||||||
|
|
||||||
.I "struct http_ctx"
|
.I "struct http_ctx"
|
||||||
is an opaque object internal to
|
is an opaque object internal to
|
||||||
.I slweb
|
.I libweb
|
||||||
and therefore is not accessible to callers.
|
and therefore is not accessible to callers.
|
||||||
|
|
||||||
.SH RETURN VALUE
|
.SH RETURN VALUE
|
||||||
|
@ -46,12 +46,12 @@ for a list of possible errors.
|
||||||
|
|
||||||
.SH NOTES
|
.SH NOTES
|
||||||
This function is designed for internal use by
|
This function is designed for internal use by
|
||||||
\fIslweb\fR.
|
\fIlibweb\fR.
|
||||||
|
|
||||||
.SH SEE ALSO
|
.SH SEE ALSO
|
||||||
.BR http_free (3),
|
.BR http_free (3),
|
||||||
.BR http_update (3),
|
.BR http_update (3),
|
||||||
.BR slweb_http (7).
|
.BR libweb_http (7).
|
||||||
|
|
||||||
.SH COPYRIGHT
|
.SH COPYRIGHT
|
||||||
Copyright (C) 2023 Xavier Del Campo Romero.
|
Copyright (C) 2023 Xavier Del Campo Romero.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
.TH HTTP_COOKIE_CREATE 3 2023-09-07 0.1.0 "slweb Library Reference"
|
.TH HTTP_COOKIE_CREATE 3 2023-09-07 0.1.0 "libweb Library Reference"
|
||||||
|
|
||||||
.SH NAME
|
.SH NAME
|
||||||
http_cookie_create \- creates a HTTP/1.1 cookie
|
http_cookie_create \- creates a HTTP/1.1 cookie
|
||||||
|
@ -6,7 +6,7 @@ http_cookie_create \- creates a HTTP/1.1 cookie
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
.LP
|
.LP
|
||||||
.nf
|
.nf
|
||||||
#include <slweb/http.h>
|
#include <libweb/http.h>
|
||||||
.P
|
.P
|
||||||
char *http_cookie_create(const char *\fIkey\fP, const char *\fIvalue\fP);
|
char *http_cookie_create(const char *\fIkey\fP, const char *\fIvalue\fP);
|
||||||
.fi
|
.fi
|
||||||
|
@ -50,14 +50,14 @@ ExampleHeader=ExampleValue; HttpOnly; Expires Wed, 07 Sep 2023 00:00:00 GMT
|
||||||
|
|
||||||
.SH FUTURE DIRECTIONS
|
.SH FUTURE DIRECTIONS
|
||||||
|
|
||||||
.I slweb
|
.I libweb
|
||||||
sets a 1-year expiration date for HTTP cookies due to arbitrary design
|
sets a 1-year expiration date for HTTP cookies due to arbitrary design
|
||||||
limitations. Future versions of this library shall allow a custom
|
limitations. Future versions of this library shall allow a custom
|
||||||
expiration date as an additional parameter to
|
expiration date as an additional parameter to
|
||||||
.IR http_cookie_create (3).
|
.IR http_cookie_create (3).
|
||||||
|
|
||||||
.SH SEE ALSO
|
.SH SEE ALSO
|
||||||
.BR slweb_http (7).
|
.BR libweb_http (7).
|
||||||
|
|
||||||
.SH COPYRIGHT
|
.SH COPYRIGHT
|
||||||
Copyright (C) 2023 Xavier Del Campo Romero.
|
Copyright (C) 2023 Xavier Del Campo Romero.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
.TH HTTP_ENCODE_URL 3 2023-09-07 0.1.0 "slweb Library Reference"
|
.TH HTTP_ENCODE_URL 3 2023-09-07 0.1.0 "libweb Library Reference"
|
||||||
|
|
||||||
.SH NAME
|
.SH NAME
|
||||||
http_encode_url \- allocates a percent-encoded null-terminated string
|
http_encode_url \- allocates a percent-encoded null-terminated string
|
||||||
|
@ -6,7 +6,7 @@ http_encode_url \- allocates a percent-encoded null-terminated string
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
.LP
|
.LP
|
||||||
.nf
|
.nf
|
||||||
#include <slweb/http.h>
|
#include <libweb/http.h>
|
||||||
.P
|
.P
|
||||||
char *http_encode_url(const char *\fIurl\fP);
|
char *http_encode_url(const char *\fIurl\fP);
|
||||||
.fi
|
.fi
|
||||||
|
@ -27,7 +27,7 @@ No errors are defined.
|
||||||
|
|
||||||
.SH SEE ALSO
|
.SH SEE ALSO
|
||||||
.BR http_decode_url (3),
|
.BR http_decode_url (3),
|
||||||
.BR slweb_http (7).
|
.BR libweb_http (7).
|
||||||
|
|
||||||
.SH COPYRIGHT
|
.SH COPYRIGHT
|
||||||
Copyright (C) 2023 Xavier Del Campo Romero.
|
Copyright (C) 2023 Xavier Del Campo Romero.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
.TH HTTP_FREE 3 2023-09-06 0.1.0 "slweb Library Reference"
|
.TH HTTP_FREE 3 2023-09-06 0.1.0 "libweb Library Reference"
|
||||||
|
|
||||||
.SH NAME
|
.SH NAME
|
||||||
http_free \- free a HTTP context object
|
http_free \- free a HTTP context object
|
||||||
|
@ -6,7 +6,7 @@ http_free \- free a HTTP context object
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
.LP
|
.LP
|
||||||
.nf
|
.nf
|
||||||
#include <slweb/http.h>
|
#include <libweb/http.h>
|
||||||
.P
|
.P
|
||||||
void http_free(struct http_ctx *\fIh\fP);
|
void http_free(struct http_ctx *\fIh\fP);
|
||||||
.fi
|
.fi
|
||||||
|
@ -30,7 +30,7 @@ No errors are defined.
|
||||||
.SH SEE ALSO
|
.SH SEE ALSO
|
||||||
.BR http_alloc (3),
|
.BR http_alloc (3),
|
||||||
.BR http_update (3),
|
.BR http_update (3),
|
||||||
.BR slweb_http (7).
|
.BR libweb_http (7).
|
||||||
|
|
||||||
.SH COPYRIGHT
|
.SH COPYRIGHT
|
||||||
Copyright (C) 2023 Xavier Del Campo Romero.
|
Copyright (C) 2023 Xavier Del Campo Romero.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
.TH HTTP_RESPONSE_ADD_HEADER 3 2023-09-07 0.1.0 "slweb Library Reference"
|
.TH HTTP_RESPONSE_ADD_HEADER 3 2023-09-07 0.1.0 "libweb Library Reference"
|
||||||
|
|
||||||
.SH NAME
|
.SH NAME
|
||||||
http_response_add_header \- adds a HTTP/1.1 header to a response
|
http_response_add_header \- adds a HTTP/1.1 header to a response
|
||||||
|
@ -6,7 +6,7 @@ http_response_add_header \- adds a HTTP/1.1 header to a response
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
.LP
|
.LP
|
||||||
.nf
|
.nf
|
||||||
#include <slweb/http.h>
|
#include <libweb/http.h>
|
||||||
.P
|
.P
|
||||||
int http_response_add_header(struct http_response *\fIr\fP, const char *\fIheader\fP, const char *\fIvalue\fP);
|
int http_response_add_header(struct http_response *\fIr\fP, const char *\fIheader\fP, const char *\fIvalue\fP);
|
||||||
.fi
|
.fi
|
||||||
|
@ -42,7 +42,7 @@ and
|
||||||
for a list of possible errors.
|
for a list of possible errors.
|
||||||
|
|
||||||
.SH SEE ALSO
|
.SH SEE ALSO
|
||||||
.BR slweb_http (7).
|
.BR libweb_http (7).
|
||||||
|
|
||||||
.SH COPYRIGHT
|
.SH COPYRIGHT
|
||||||
Copyright (C) 2023 Xavier Del Campo Romero.
|
Copyright (C) 2023 Xavier Del Campo Romero.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
.TH HTTP_UPDATE 3 2023-09-06 0.1.0 "slweb Library Reference"
|
.TH HTTP_UPDATE 3 2023-09-06 0.1.0 "libweb Library Reference"
|
||||||
|
|
||||||
.SH NAME
|
.SH NAME
|
||||||
http_update \- updates a HTTP context object
|
http_update \- updates a HTTP context object
|
||||||
|
@ -6,7 +6,7 @@ http_update \- updates a HTTP context object
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
.LP
|
.LP
|
||||||
.nf
|
.nf
|
||||||
#include <slweb/http.h>
|
#include <libweb/http.h>
|
||||||
.P
|
.P
|
||||||
int http_update(struct http_ctx *\fIh\fP, bool *\fIwrite\fP, bool *\fIclose\fP);
|
int http_update(struct http_ctx *\fIh\fP, bool *\fIwrite\fP, bool *\fIclose\fP);
|
||||||
.fi
|
.fi
|
||||||
|
@ -60,12 +60,12 @@ No errors are defined.
|
||||||
|
|
||||||
.SH NOTES
|
.SH NOTES
|
||||||
This function is designed for internal use by
|
This function is designed for internal use by
|
||||||
.IR slweb .
|
.IR libweb .
|
||||||
|
|
||||||
.SH SEE ALSO
|
.SH SEE ALSO
|
||||||
.BR http_free (3),
|
.BR http_free (3),
|
||||||
.BR http_update (3),
|
.BR http_update (3),
|
||||||
.BR slweb_http (7).
|
.BR libweb_http (7).
|
||||||
|
|
||||||
.SH COPYRIGHT
|
.SH COPYRIGHT
|
||||||
Copyright (C) 2023 Xavier Del Campo Romero.
|
Copyright (C) 2023 Xavier Del Campo Romero.
|
||||||
|
|
|
@ -3,9 +3,9 @@
|
||||||
PREFIX = /usr/local
|
PREFIX = /usr/local
|
||||||
DST = $(PREFIX)/share/man/man7
|
DST = $(PREFIX)/share/man/man7
|
||||||
OBJECTS = \
|
OBJECTS = \
|
||||||
$(DST)/slweb_handler.7 \
|
$(DST)/libweb_handler.7 \
|
||||||
$(DST)/slweb_html.7 \
|
$(DST)/libweb_html.7 \
|
||||||
$(DST)/slweb_http.7
|
$(DST)/libweb_http.7
|
||||||
|
|
||||||
all:
|
all:
|
||||||
|
|
||||||
|
|
|
@ -1,36 +1,36 @@
|
||||||
.TH SLWEB_HANDLER 7 2023-09-15 0.1.0 "slweb Library Reference"
|
.TH LIBWEB_HANDLER 7 2023-09-15 0.1.0 "libweb Library Reference"
|
||||||
|
|
||||||
.SH NAME
|
.SH NAME
|
||||||
slweb_handler \- slweb high-level website configuration
|
libweb_handler \- libweb high-level website configuration
|
||||||
|
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
.LP
|
.LP
|
||||||
.nf
|
.nf
|
||||||
#include <slweb/handler.h>
|
#include <libweb/handler.h>
|
||||||
.fi
|
.fi
|
||||||
|
|
||||||
.SH DESCRIPTION
|
.SH DESCRIPTION
|
||||||
This component provides abstractions that allow library users to
|
This component provides abstractions that allow library users to
|
||||||
define the behaviour of a web server. Whereas
|
define the behaviour of a web server. Whereas
|
||||||
.IR slweb_http (7)
|
.IR libweb_http (7)
|
||||||
defines the HTTP/1.1 server implementation and provides a data type
|
defines the HTTP/1.1 server implementation and provides a data type
|
||||||
(namely
|
(namely
|
||||||
.IR "struct http_ctx" )
|
.IR "struct http_ctx" )
|
||||||
to handle an incoming connection,
|
to handle an incoming connection,
|
||||||
.IR slweb_handler (7):
|
.IR libweb_handler (7):
|
||||||
|
|
||||||
.IP \(bu 2
|
.IP \(bu 2
|
||||||
Defines the list of endpoints and supported operations.
|
Defines the list of endpoints and supported operations.
|
||||||
.IP \(bu 2
|
.IP \(bu 2
|
||||||
Defines the port
|
Defines the port
|
||||||
.I slweb
|
.I libweb
|
||||||
must listen to.
|
must listen to.
|
||||||
.IP \(bu 2
|
.IP \(bu 2
|
||||||
Keeps track of all
|
Keeps track of all
|
||||||
.I struct http_ctx
|
.I struct http_ctx
|
||||||
objects.
|
objects.
|
||||||
|
|
||||||
.IR slweb_handler (7)
|
.IR libweb_handler (7)
|
||||||
provides the following functions:
|
provides the following functions:
|
||||||
|
|
||||||
.IP \(bu 2
|
.IP \(bu 2
|
||||||
|
@ -83,7 +83,7 @@ are passed directly to the
|
||||||
object used to initialize a
|
object used to initialize a
|
||||||
.I struct http_ctx
|
.I struct http_ctx
|
||||||
object. See
|
object. See
|
||||||
.IR slweb_http (7)
|
.IR libweb_http (7)
|
||||||
for further reference about these members.
|
for further reference about these members.
|
||||||
|
|
||||||
However, a
|
However, a
|
||||||
|
@ -104,7 +104,7 @@ typedef int (*\fIhandler_fn\fP)(const struct http_payload *\fIp\fP, struct http_
|
||||||
.PP
|
.PP
|
||||||
|
|
||||||
Please read
|
Please read
|
||||||
.IR slweb_http (7)
|
.IR libweb_http (7)
|
||||||
for further refence on
|
for further refence on
|
||||||
.I "struct http_payload"
|
.I "struct http_payload"
|
||||||
and
|
and
|
||||||
|
@ -124,16 +124,16 @@ and
|
||||||
\fI/index.html\fP
|
\fI/index.html\fP
|
||||||
as its endpoints. For the sake of simplicity, a static response body is
|
as its endpoints. For the sake of simplicity, a static response body is
|
||||||
returned, instead of using
|
returned, instead of using
|
||||||
.IR slweb_html (7)
|
.IR libweb_html (7)
|
||||||
to generate HTML data. Please read
|
to generate HTML data. Please read
|
||||||
.IR slweb_html (7)
|
.IR libweb_html (7)
|
||||||
for further reference on how to generate dynamic content.
|
for further reference on how to generate dynamic content.
|
||||||
|
|
||||||
.PP
|
.PP
|
||||||
.in +4n
|
.in +4n
|
||||||
.EX
|
.EX
|
||||||
#include <slweb/handler.h>
|
#include <libweb/handler.h>
|
||||||
#include <slweb/http.h>
|
#include <libweb/http.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
@ -142,7 +142,7 @@ static int hello(const struct http_payload *const pl,
|
||||||
{
|
{
|
||||||
static const char page[] =
|
static const char page[] =
|
||||||
{
|
{
|
||||||
"<html><body><p>Hello from slweb!</p></body></html>"
|
"<html><body><p>Hello from libweb!</p></body></html>"
|
||||||
};
|
};
|
||||||
|
|
||||||
*r = (const struct http_response)
|
*r = (const struct http_response)
|
||||||
|
@ -218,7 +218,7 @@ end:
|
||||||
.BR handler_alloc (3),
|
.BR handler_alloc (3),
|
||||||
.BR handler_add (3),
|
.BR handler_add (3),
|
||||||
.BR handler_free (3),
|
.BR handler_free (3),
|
||||||
.BR slweb_http (7).
|
.BR libweb_http (7).
|
||||||
|
|
||||||
.SH COPYRIGHT
|
.SH COPYRIGHT
|
||||||
Copyright (C) 2023 Xavier Del Campo Romero.
|
Copyright (C) 2023 Xavier Del Campo Romero.
|
|
@ -1,12 +1,12 @@
|
||||||
.TH SLWEB_HTML 7 2023-09-15 0.1.0 "slweb Library Reference"
|
.TH LIBWEB_HTML 7 2023-09-15 0.1.0 "libweb Library Reference"
|
||||||
|
|
||||||
.SH NAME
|
.SH NAME
|
||||||
slweb_html \- slweb HTML serializer
|
libweb_html \- libweb HTML serializer
|
||||||
|
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
.LP
|
.LP
|
||||||
.nf
|
.nf
|
||||||
#include <slweb/html.h>
|
#include <libweb/html.h>
|
||||||
.fi
|
.fi
|
||||||
|
|
||||||
.SH DESCRIPTION
|
.SH DESCRIPTION
|
||||||
|
@ -14,7 +14,7 @@ This component allows library users to serialize HTML text from a tree
|
||||||
structure composed by one or more
|
structure composed by one or more
|
||||||
.I struct html_node
|
.I struct html_node
|
||||||
objects.
|
objects.
|
||||||
.IR slweb_html (7)
|
.IR libweb_html (7)
|
||||||
provides the following functions:
|
provides the following functions:
|
||||||
|
|
||||||
.IP \(bu 2
|
.IP \(bu 2
|
||||||
|
@ -94,13 +94,13 @@ shall free the memory used by the root node and all of its children.
|
||||||
.SH EXAMPLE
|
.SH EXAMPLE
|
||||||
The example below is a minimal showcase of some of the features
|
The example below is a minimal showcase of some of the features
|
||||||
provided by
|
provided by
|
||||||
.IR slweb_html (7),
|
.IR libweb_html (7),
|
||||||
which prints a minimal HTML file to standard output:
|
which prints a minimal HTML file to standard output:
|
||||||
|
|
||||||
.PP
|
.PP
|
||||||
.in +4n
|
.in +4n
|
||||||
.EX
|
.EX
|
||||||
#include <slweb/html.h>
|
#include <libweb/html.h>
|
||||||
#include <dynstr.h>
|
#include <dynstr.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
@ -110,7 +110,7 @@ int main()
|
||||||
int ret = EXIT_FAILURE;
|
int ret = EXIT_FAILURE;
|
||||||
struct dynstr d;
|
struct dynstr d;
|
||||||
struct html_node *const html = html_node_alloc("html"), *body;
|
struct html_node *const html = html_node_alloc("html"), *body;
|
||||||
static const char text[] = "testing slweb";
|
static const char text[] = "testing libweb";
|
||||||
|
|
||||||
dynstr_init(&d);
|
dynstr_init(&d);
|
||||||
|
|
||||||
|
@ -152,7 +152,7 @@ This program should write the following data over standard output:
|
||||||
.in +4n
|
.in +4n
|
||||||
.EX
|
.EX
|
||||||
<html>
|
<html>
|
||||||
<body>testing slweb</body>
|
<body>testing libweb</body>
|
||||||
</html>
|
</html>
|
||||||
.EE
|
.EE
|
||||||
.in
|
.in
|
||||||
|
@ -167,7 +167,7 @@ This program should write the following data over standard output:
|
||||||
.BR html_node_add_child (3),
|
.BR html_node_add_child (3),
|
||||||
.BR html_node_add_sibling (3),
|
.BR html_node_add_sibling (3),
|
||||||
.BR html_serialize (3),
|
.BR html_serialize (3),
|
||||||
.BR slweb_html (7).
|
.BR libweb_html (7).
|
||||||
|
|
||||||
.SH COPYRIGHT
|
.SH COPYRIGHT
|
||||||
Copyright (C) 2023 Xavier Del Campo Romero.
|
Copyright (C) 2023 Xavier Del Campo Romero.
|
|
@ -1,17 +1,17 @@
|
||||||
.TH SLWEB_HTTP 7 2023-09-15 0.1.0 "slweb Library Reference"
|
.TH LIBWEB_HTTP 7 2023-09-15 0.1.0 "libweb Library Reference"
|
||||||
|
|
||||||
.SH NAME
|
.SH NAME
|
||||||
slweb_http \- slweb HTTP connection handling and utilities
|
libweb_http \- libweb HTTP connection handling and utilities
|
||||||
|
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
.LP
|
.LP
|
||||||
.nf
|
.nf
|
||||||
#include <slweb/http.h>
|
#include <libweb/http.h>
|
||||||
.fi
|
.fi
|
||||||
|
|
||||||
.SH DESCRIPTION
|
.SH DESCRIPTION
|
||||||
As one of its key features,
|
As one of its key features,
|
||||||
\fIslweb\fR
|
\fIlibweb\fR
|
||||||
provides a HTTP/1.1-compatible server implementation that can be
|
provides a HTTP/1.1-compatible server implementation that can be
|
||||||
embedded into applications as a library. While not a complete HTTP/1.1
|
embedded into applications as a library. While not a complete HTTP/1.1
|
||||||
server implementation, the following features are supported:
|
server implementation, the following features are supported:
|
||||||
|
@ -42,7 +42,7 @@ The functions listed below are meant for library users:
|
||||||
.SS HTTP connection-related functions
|
.SS HTTP connection-related functions
|
||||||
|
|
||||||
The functions listed below are meant for internal use by
|
The functions listed below are meant for internal use by
|
||||||
.IR slweb :
|
.IR libweb :
|
||||||
|
|
||||||
.IP \(bu 2
|
.IP \(bu 2
|
||||||
.IR http_alloc (3).
|
.IR http_alloc (3).
|
||||||
|
@ -56,7 +56,7 @@ For example, a list of endpoints is required to define its behaviour,
|
||||||
and
|
and
|
||||||
.I struct http
|
.I struct http
|
||||||
objects must be stored somewhere as long as the connections are active.
|
objects must be stored somewhere as long as the connections are active.
|
||||||
.IR slweb_handler (7)
|
.IR libweb_handler (7)
|
||||||
is the component meant to provide the missing pieces that conform a
|
is the component meant to provide the missing pieces that conform a
|
||||||
working web server.
|
working web server.
|
||||||
|
|
||||||
|
@ -127,7 +127,7 @@ On error, a negative integer is returned.
|
||||||
|
|
||||||
.I payload
|
.I payload
|
||||||
is a function pointer called by
|
is a function pointer called by
|
||||||
.I slweb
|
.I libweb
|
||||||
when a new HTTP request has been received.
|
when a new HTTP request has been received.
|
||||||
.I p
|
.I p
|
||||||
is a read-only pointer to a
|
is a read-only pointer to a
|
||||||
|
@ -151,7 +151,7 @@ returned.
|
||||||
|
|
||||||
.I length
|
.I length
|
||||||
is a function pointer called by
|
is a function pointer called by
|
||||||
.I slweb
|
.I libweb
|
||||||
when an incoming HTTP request from a client requires to store one or
|
when an incoming HTTP request from a client requires to store one or
|
||||||
more files on the server, encoded as
|
more files on the server, encoded as
|
||||||
.IR multipart/form-data .
|
.IR multipart/form-data .
|
||||||
|
@ -198,7 +198,7 @@ can be a null pointer.
|
||||||
.SS HTTP payload
|
.SS HTTP payload
|
||||||
|
|
||||||
When a client submits a request to the server,
|
When a client submits a request to the server,
|
||||||
.I slweb
|
.I libweb
|
||||||
prepares a high-level data structure, called
|
prepares a high-level data structure, called
|
||||||
.IR "struct http_payload" ,
|
.IR "struct http_payload" ,
|
||||||
and passes it to the function pointer defined by
|
and passes it to the function pointer defined by
|
||||||
|
@ -273,19 +273,19 @@ handles differently:
|
||||||
.IP \(bu 2
|
.IP \(bu 2
|
||||||
.IR application/x-www-form-urlencoded :
|
.IR application/x-www-form-urlencoded :
|
||||||
suggested for smaller payloads.
|
suggested for smaller payloads.
|
||||||
.I slweb
|
.I libweb
|
||||||
shall store the payload in memory, limiting its maximum size to
|
shall store the payload in memory, limiting its maximum size to
|
||||||
.BR "7999 octets" .
|
.BR "7999 octets" .
|
||||||
|
|
||||||
.IP \(bu 2
|
.IP \(bu 2
|
||||||
.IR multipart/form-data :
|
.IR multipart/form-data :
|
||||||
suggested for larger and/or binary payloads.
|
suggested for larger and/or binary payloads.
|
||||||
.I slweb
|
.I libweb
|
||||||
shall store each non-file name-value pair in memory, limiting the value
|
shall store each non-file name-value pair in memory, limiting the value
|
||||||
length to
|
length to
|
||||||
.BR "8000 octets" .
|
.BR "8000 octets" .
|
||||||
On the other hand,
|
On the other hand,
|
||||||
.I slweb
|
.I libweb
|
||||||
shall store each file into the temporary directory defined by
|
shall store each file into the temporary directory defined by
|
||||||
.I struct http_cfg
|
.I struct http_cfg
|
||||||
member
|
member
|
||||||
|
@ -377,7 +377,7 @@ shall be a null pointer.
|
||||||
.SS HTTP responses
|
.SS HTTP responses
|
||||||
|
|
||||||
Some function pointers used by
|
Some function pointers used by
|
||||||
.I slweb
|
.I libweb
|
||||||
require to initialize a
|
require to initialize a
|
||||||
.I "struct http_response"
|
.I "struct http_response"
|
||||||
object that defines the response that must be sent to the client.
|
object that defines the response that must be sent to the client.
|
||||||
|
@ -437,7 +437,7 @@ is a read-only opaque pointer to a buffer in memory, whose length is
|
||||||
defined by
|
defined by
|
||||||
.I n
|
.I n
|
||||||
(see definition below).
|
(see definition below).
|
||||||
.I slweb
|
.I libweb
|
||||||
shall select
|
shall select
|
||||||
.I ro
|
.I ro
|
||||||
as the output payload if both
|
as the output payload if both
|
||||||
|
@ -452,7 +452,7 @@ is non-zero.
|
||||||
is an opaque pointer to a buffer in memory, whose length is defined by
|
is an opaque pointer to a buffer in memory, whose length is defined by
|
||||||
.I n
|
.I n
|
||||||
(see definition below).
|
(see definition below).
|
||||||
.I slweb
|
.I libweb
|
||||||
shall select
|
shall select
|
||||||
.I rw
|
.I rw
|
||||||
as the output payload if both
|
as the output payload if both
|
||||||
|
@ -471,7 +471,7 @@ is a
|
||||||
pointer opened for reading that defines the payload to be sent to the
|
pointer opened for reading that defines the payload to be sent to the
|
||||||
client, whose length is defined by
|
client, whose length is defined by
|
||||||
.IR n .
|
.IR n .
|
||||||
.I slweb
|
.I libweb
|
||||||
shall select
|
shall select
|
||||||
.I f
|
.I f
|
||||||
as the output payload if
|
as the output payload if
|
||||||
|
@ -514,20 +514,20 @@ must be a null pointer.
|
||||||
|
|
||||||
.SS Transport Layer Security (TLS)
|
.SS Transport Layer Security (TLS)
|
||||||
By design,
|
By design,
|
||||||
.I slweb
|
.I libweb
|
||||||
does
|
does
|
||||||
.BI not
|
.BI not
|
||||||
implement TLS (Transport Layer Security). It is assumed this should
|
implement TLS (Transport Layer Security). It is assumed this should
|
||||||
be provided by a reverse proxy instead, a kind of project that is
|
be provided by a reverse proxy instead, a kind of project that is
|
||||||
usually maintained by a larger community than
|
usually maintained by a larger community than
|
||||||
.I slweb
|
.I libweb
|
||||||
and audited for security vulnerabilities.
|
and audited for security vulnerabilities.
|
||||||
|
|
||||||
.SH NOTES
|
.SH NOTES
|
||||||
.SS Comparing against other HTTP server implementations
|
.SS Comparing against other HTTP server implementations
|
||||||
While it is well understood that other solutions provide fully-fledged
|
While it is well understood that other solutions provide fully-fledged
|
||||||
server implementations as standalone executables,
|
server implementations as standalone executables,
|
||||||
.I slweb
|
.I libweb
|
||||||
strives to be as small and easy to use as possible, intentionally
|
strives to be as small and easy to use as possible, intentionally
|
||||||
limiting its scope while covering a good range of use cases.
|
limiting its scope while covering a good range of use cases.
|
||||||
|
|
||||||
|
@ -550,13 +550,13 @@ or
|
||||||
.BR -- .
|
.BR -- .
|
||||||
|
|
||||||
This means it is not possible for
|
This means it is not possible for
|
||||||
.I slweb
|
.I libweb
|
||||||
to determine the number of files or their lengths in a HTTP request
|
to determine the number of files or their lengths in a HTTP request
|
||||||
unless the whole request is read, which not might be possible for large
|
unless the whole request is read, which not might be possible for large
|
||||||
requests. Therefore, the
|
requests. Therefore, the
|
||||||
.B Content-Length
|
.B Content-Length
|
||||||
is the only rough estimation
|
is the only rough estimation
|
||||||
.I slweb
|
.I libweb
|
||||||
can rely on, and therefore is the value passed to the
|
can rely on, and therefore is the value passed to the
|
||||||
.I length
|
.I length
|
||||||
function pointer in
|
function pointer in
|
||||||
|
@ -568,7 +568,7 @@ function pointer in
|
||||||
The handling of
|
The handling of
|
||||||
.B 100-continue
|
.B 100-continue
|
||||||
requests is not done correctly:
|
requests is not done correctly:
|
||||||
.I slweb
|
.I libweb
|
||||||
calls the function pointed to by
|
calls the function pointed to by
|
||||||
.I "struct http_cfg"
|
.I "struct http_cfg"
|
||||||
member
|
member
|
||||||
|
@ -581,7 +581,7 @@ headers are processed.
|
||||||
.SH FUTURE DIRECTIONS
|
.SH FUTURE DIRECTIONS
|
||||||
.SS Limitations on the number of HTTP cookies
|
.SS Limitations on the number of HTTP cookies
|
||||||
So far,
|
So far,
|
||||||
.I slweb
|
.I libweb
|
||||||
shall only append at most
|
shall only append at most
|
||||||
.B one
|
.B one
|
||||||
HTTP cookie to a
|
HTTP cookie to a
|
||||||
|
@ -599,12 +599,12 @@ object containing the number of HTTP cookies in the request.
|
||||||
|
|
||||||
.SS Handling application/x-www-form-urlencoded data
|
.SS Handling application/x-www-form-urlencoded data
|
||||||
Due to historical reasons,
|
Due to historical reasons,
|
||||||
.I slweb
|
.I libweb
|
||||||
treated
|
treated
|
||||||
.IR application/x-www-form-urlencoded -data
|
.IR application/x-www-form-urlencoded -data
|
||||||
as a binary blob. While this was changed to a null-terminated string in
|
as a binary blob. While this was changed to a null-terminated string in
|
||||||
order to allow applications to avoid unnecessary memory allocations,
|
order to allow applications to avoid unnecessary memory allocations,
|
||||||
.I slweb
|
.I libweb
|
||||||
still does not decode the data, instead forcing applications to do so.
|
still does not decode the data, instead forcing applications to do so.
|
||||||
Future versions of this library shall replace
|
Future versions of this library shall replace
|
||||||
.I "struct http_post"
|
.I "struct http_post"
|
||||||
|
@ -622,7 +622,7 @@ as a union that only holds one possible data type. While this might
|
||||||
look counterintuitive, this is because
|
look counterintuitive, this is because
|
||||||
.B POST
|
.B POST
|
||||||
is the only HTTP/1.1 operation
|
is the only HTTP/1.1 operation
|
||||||
.I slweb
|
.I libweb
|
||||||
supports that requires to store a payload. However, future versions of
|
supports that requires to store a payload. However, future versions of
|
||||||
this library might extend its support for other HTTP/1.1 operations
|
this library might extend its support for other HTTP/1.1 operations
|
||||||
that could require to store a payload, while keeping the memory
|
that could require to store a payload, while keeping the memory
|
|
@ -1,4 +1,4 @@
|
||||||
cmake_minimum_required(VERSION 3.13)
|
cmake_minimum_required(VERSION 3.13)
|
||||||
project(hello C)
|
project(hello C)
|
||||||
add_executable(hello main.c)
|
add_executable(hello main.c)
|
||||||
target_link_libraries(${PROJECT_NAME} PRIVATE slweb dynstr)
|
target_link_libraries(${PROJECT_NAME} PRIVATE web dynstr)
|
||||||
|
|
|
@ -3,10 +3,10 @@
|
||||||
PROJECT = hello
|
PROJECT = hello
|
||||||
DEPS = \
|
DEPS = \
|
||||||
main.o
|
main.o
|
||||||
SLWEB = ../../libslweb.a
|
LIBWEB = ../../libweb.a
|
||||||
DYNSTR = ../../dynstr/libdynstr.a
|
DYNSTR = ../../dynstr/libdynstr.a
|
||||||
CFLAGS = -I ../../include -I ../../dynstr/include
|
CFLAGS = -I ../../include -I ../../dynstr/include
|
||||||
SLWEB_FLAGS = -L ../../ -l slweb
|
LIBWEB_FLAGS = -L ../../ -l libweb
|
||||||
DYNSTR_FLAGS = -L ../../dynstr -l dynstr
|
DYNSTR_FLAGS = -L ../../dynstr -l dynstr
|
||||||
|
|
||||||
all: $(PROJECT)
|
all: $(PROJECT)
|
||||||
|
@ -16,10 +16,10 @@ clean:
|
||||||
|
|
||||||
FORCE:
|
FORCE:
|
||||||
|
|
||||||
$(PROJECT): $(DEPS) $(SLWEB) $(DYNSTR)
|
$(PROJECT): $(DEPS) $(LIBWEB) $(DYNSTR)
|
||||||
$(CC) $(LDFLAGS) $(DEPS) $(SLWEB_FLAGS) $(DYNSTR_FLAGS) -o $@
|
$(CC) $(LDFLAGS) $(DEPS) $(LIBWEB_FLAGS) $(DYNSTR_FLAGS) -o $@
|
||||||
|
|
||||||
$(SLWEB): FORCE
|
$(LIBWEB): FORCE
|
||||||
+cd ../../ && $(MAKE)
|
+cd ../../ && $(MAKE)
|
||||||
|
|
||||||
$(DYNSTR): FORCE
|
$(DYNSTR): FORCE
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
# "Hello world" example
|
# "Hello world" example
|
||||||
|
|
||||||
This example shows a minimal setup for an application using `slweb`. When
|
This example shows a minimal setup for an application using `libweb`. When
|
||||||
executed, it starts a HTTP/1.1 server on port `8080` and returns an example
|
executed, it starts a HTTP/1.1 server on port `8080` and returns an example
|
||||||
website reading "Hello from slweb!" when either `/` or `/index.html` are
|
website reading "Hello from libweb!" when either `/` or `/index.html` are
|
||||||
accessed by clients.
|
accessed by clients.
|
||||||
|
|
||||||
## How to build
|
## How to build
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#include <dynstr.h>
|
#include <dynstr.h>
|
||||||
#include <slweb/handler.h>
|
#include <libweb/handler.h>
|
||||||
#include <slweb/html.h>
|
#include <libweb/html.h>
|
||||||
#include <slweb/http.h>
|
#include <libweb/http.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
@ -30,7 +30,7 @@ static int hello(const struct http_payload *const pl,
|
||||||
fprintf(stderr, "%s: html_node_add_child p failed\n", __func__);
|
fprintf(stderr, "%s: html_node_add_child p failed\n", __func__);
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
else if (html_node_set_value(p, "Hello from slweb!"))
|
else if (html_node_set_value(p, "Hello from libweb!"))
|
||||||
{
|
{
|
||||||
fprintf(stderr, "%s: html_node_set_value p failed\n", __func__);
|
fprintf(stderr, "%s: html_node_set_value p failed\n", __func__);
|
||||||
goto end;
|
goto end;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
cmake_minimum_required(VERSION 3.13)
|
cmake_minimum_required(VERSION 3.13)
|
||||||
project(html C)
|
project(html C)
|
||||||
add_executable(html main.c)
|
add_executable(html main.c)
|
||||||
target_link_libraries(${PROJECT_NAME} PRIVATE slweb dynstr)
|
target_link_libraries(${PROJECT_NAME} PRIVATE web dynstr)
|
||||||
|
|
|
@ -3,10 +3,10 @@
|
||||||
PROJECT = html
|
PROJECT = html
|
||||||
DEPS = \
|
DEPS = \
|
||||||
main.o
|
main.o
|
||||||
SLWEB = ../../libslweb.a
|
LIBWEB = ../../libweb.a
|
||||||
DYNSTR = ../../dynstr/libdynstr.a
|
DYNSTR = ../../dynstr/libdynstr.a
|
||||||
CFLAGS = -I ../../include -I ../../dynstr/include
|
CFLAGS = -I ../../include -I ../../dynstr/include
|
||||||
SLWEB_FLAGS = -L ../../ -l slweb
|
LIBWEB_FLAGS = -L ../../ -l libweb
|
||||||
DYNSTR_FLAGS = -L ../../dynstr -l dynstr
|
DYNSTR_FLAGS = -L ../../dynstr -l dynstr
|
||||||
|
|
||||||
all: $(PROJECT)
|
all: $(PROJECT)
|
||||||
|
@ -16,10 +16,10 @@ clean:
|
||||||
|
|
||||||
FORCE:
|
FORCE:
|
||||||
|
|
||||||
$(PROJECT): $(DEPS) $(SLWEB) $(DYNSTR)
|
$(PROJECT): $(DEPS) $(LIBWEB) $(DYNSTR)
|
||||||
$(CC) $(LDFLAGS) $(DEPS) $(SLWEB_FLAGS) $(DYNSTR_FLAGS) -o $@
|
$(CC) $(LDFLAGS) $(DEPS) $(LIBWEB_FLAGS) $(DYNSTR_FLAGS) -o $@
|
||||||
|
|
||||||
$(SLWEB): FORCE
|
$(LIBWEB): FORCE
|
||||||
+cd ../../ && $(MAKE)
|
+cd ../../ && $(MAKE)
|
||||||
|
|
||||||
$(DYNSTR): FORCE
|
$(DYNSTR): FORCE
|
||||||
|
|
|
@ -20,6 +20,6 @@ should be written to the standard output:
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8"/>
|
<meta charset="UTF-8"/>
|
||||||
</head>
|
</head>
|
||||||
<body>testing slweb</body>
|
<body>testing libweb</body>
|
||||||
</html>
|
</html>
|
||||||
```
|
```
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#include <slweb/html.h>
|
#include <libweb/html.h>
|
||||||
#include <dynstr.h>
|
#include <dynstr.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
@ -9,7 +9,7 @@ int main()
|
||||||
struct dynstr d;
|
struct dynstr d;
|
||||||
struct html_node *const html = html_node_alloc("html"), *head,
|
struct html_node *const html = html_node_alloc("html"), *head,
|
||||||
*meta, *body;
|
*meta, *body;
|
||||||
static const char text[] = "testing slweb";
|
static const char text[] = "testing libweb";
|
||||||
|
|
||||||
dynstr_init(&d);
|
dynstr_init(&d);
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
#define _POSIX_C_SOURCE 200809L
|
#define _POSIX_C_SOURCE 200809L
|
||||||
|
|
||||||
#include "slweb/handler.h"
|
#include "libweb/handler.h"
|
||||||
#include "slweb/http.h"
|
#include "libweb/http.h"
|
||||||
#include "slweb/server.h"
|
#include "libweb/server.h"
|
||||||
#include "slweb/wildcard_cmp.h"
|
#include "libweb/wildcard_cmp.h"
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
|
2
html.c
2
html.c
|
@ -1,6 +1,6 @@
|
||||||
#define _POSIX_C_SOURCE 200809L
|
#define _POSIX_C_SOURCE 200809L
|
||||||
|
|
||||||
#include "slweb/html.h"
|
#include "libweb/html.h"
|
||||||
#include <dynstr.h>
|
#include <dynstr.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
|
2
http.c
2
http.c
|
@ -1,6 +1,6 @@
|
||||||
#define _POSIX_C_SOURCE 200809L
|
#define _POSIX_C_SOURCE 200809L
|
||||||
|
|
||||||
#include "slweb/http.h"
|
#include "libweb/http.h"
|
||||||
#include <dynstr.h>
|
#include <dynstr.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#ifndef HANDLER_H
|
#ifndef HANDLER_H
|
||||||
#define HANDLER_H
|
#define HANDLER_H
|
||||||
|
|
||||||
#include "slweb/http.h"
|
#include "libweb/http.h"
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
|
||||||
typedef int (*handler_fn)(const struct http_payload *p,
|
typedef int (*handler_fn)(const struct http_payload *p,
|
|
@ -3,9 +3,9 @@ exec_prefix=${prefix}
|
||||||
includedir=${prefix}/include
|
includedir=${prefix}/include
|
||||||
libdir=${exec_prefix}/lib
|
libdir=${exec_prefix}/lib
|
||||||
|
|
||||||
Name: slweb
|
Name: libweb
|
||||||
Url: https://gitea.privatedns.org/xavi/slweb
|
Url: https://gitea.privatedns.org/xavi/libweb
|
||||||
Description: A simple and lightweight web framework
|
Description: A simple and lightweight web framework
|
||||||
Version: 0.1.0
|
Version: 0.1.0
|
||||||
Cflags: -I${includedir}
|
Cflags: -I${includedir}
|
||||||
Libs: -L${libdir} -lslweb
|
Libs: -L${libdir} -llibweb
|
2
server.c
2
server.c
|
@ -6,7 +6,7 @@
|
||||||
#define _POSIX_C_SOURCE 200809L
|
#define _POSIX_C_SOURCE 200809L
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "slweb/server.h"
|
#include "libweb/server.h"
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#include "slweb/wildcard_cmp.h"
|
#include "libweb/wildcard_cmp.h"
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
Loading…
Reference in New Issue