summaryrefslogtreecommitdiff
path: root/main.h
diff options
context:
space:
mode:
authorMax Christian Pohle2021-11-21 00:10:29 +0100
committerMax Christian Pohle2021-11-21 00:10:29 +0100
commitb7b47e662a75096c7f99881b0d609731d5d6c8ce (patch)
tree113da9bbb5335f6ba48f08029c9e5a050d6304b7 /main.h
parentf5e12f35af533713312f29054ad0ffd00c0fcabd (diff)
downloadohmycgi-b7b47e662a75096c7f99881b0d609731d5d6c8ce.tar.bz2
ohmycgi-b7b47e662a75096c7f99881b0d609731d5d6c8ce.zip
First working version
TODO: needs refactoring
Diffstat (limited to 'main.h')
-rw-r--r--main.h67
1 files changed, 67 insertions, 0 deletions
diff --git a/main.h b/main.h
new file mode 100644
index 0000000..2f66920
--- /dev/null
+++ b/main.h
@@ -0,0 +1,67 @@
1/* __ _
2* ____ / /_ ____ ___ __ ___________ _(_)
3* / __ \/ __ \/ __ `__ \/ / / / ___/ __ `/ /
4* / /_/ / / / / / / / / / /_/ / /__/ /_/ / /
5* \____/_/ /_/_/ /_/ /_/\__, /\___/\__, /_/
6* /____/ /____/
7*
8* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
9*
10* Copyright (c) 2021, Max Christian Pohle <max@coderonline.de>
11*
12* Redistribution and use in source and binary forms, with or without
13* modification, are permitted provided that the following conditions
14* are met:
15*
16* 1. Redistributions of source code must retain the above copyright
17* notice, this list of conditions and the following disclaimer.
18*
19* 2. Redistributions in binary form must reproduce the above copyright
20* notice, this list of conditions and the following disclaimer in the
21* documentation and/or other materials provided with the distribution.
22*
23* {{{ DISCLAIMER
24* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
28* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34* POSSIBILITY OF SUCH DAMAGE.
35* }}}
36*/
37
38// {{{ INCLUDES
39#include <stddef.h>
40#include <stdlib.h>
41#include <stdio.h>
42#include <string.h>
43#include <unistd.h>
44#include <sys/socket.h>
45#include <err.h>
46#include <errno.h>
47#include <arpa/inet.h>
48#include <fcntl.h>
49#include <sys/sendfile.h>
50#include <sys/stat.h>
51// #include <pthread.h> // maybe later
52// }}}
53
54typedef struct {
55 int newline_length; // lenght of one newline in bytes (\n has 1, CR/LF has 2)
56 char * method; // GET/POST or something like that
57 char * url; // request URL (e.g. /index.html)
58 char * boundary; // usually looks similar to ------1234
59 size_t boundary_size; // size in bytes, calculated after first header complete; is an indicator for the first header
60 char * content_type; // sometimes 'text/html', also sometimes 'text/html; boundary=------1234'
61 char * content_disposition; // includes file names of uploaded files or field names with form-data (e.g. curl -F)
62} Http_Header;
63
64void next_part(Http_Header * http_header, const char * content, size_t content_size);
65void send_answer(Http_Header * http_header, int fd_socket);
66
67// modeline for vim: shiftwidth=2 tabstop=2 number foldmethod=marker
..