From c4a9635cb33ba610e663ebdb23dc01d687476109 Mon Sep 17 00:00:00 2001 From: Nakidai Date: Fri, 13 Dec 2024 04:54:50 +0300 Subject: Add manpages --- man/libhttpc-alloc.3 | 34 ++++++++++ man/libhttpc.3 | 57 ++++++++++++++++ man/libhttpc_header.3 | 173 ++++++++++++++++++++++++++++++++++++++++++++++++ man/libhttpc_method.3 | 59 +++++++++++++++++ man/libhttpc_request.3 | 154 ++++++++++++++++++++++++++++++++++++++++++ man/libhttpc_response.3 | 123 ++++++++++++++++++++++++++++++++++ man/libhttpc_status.3 | 130 ++++++++++++++++++++++++++++++++++++ 7 files changed, 730 insertions(+) create mode 100644 man/libhttpc-alloc.3 create mode 100644 man/libhttpc.3 create mode 100644 man/libhttpc_header.3 create mode 100644 man/libhttpc_method.3 create mode 100644 man/libhttpc_request.3 create mode 100644 man/libhttpc_response.3 create mode 100644 man/libhttpc_status.3 (limited to 'man') diff --git a/man/libhttpc-alloc.3 b/man/libhttpc-alloc.3 new file mode 100644 index 0000000..4fed7e4 --- /dev/null +++ b/man/libhttpc-alloc.3 @@ -0,0 +1,34 @@ +.Dd December 13, 2024 +.Dt LIBHTTPC-ALLOC 3 +.Os +. +.Sh NAME +.Nm LibHTTPC_Malloc , +.Nm LibHTTPC_Realloc , +.Nm LibHTTPC_Free +.Nd types for defining +.Xr malloc 3 +functions +. +.Sh SYNOPSIS +.Vt typedef void *LibHTTPC_Malloc(size_t); +.Vt typedef void *LibHTTPC_Realloc(void *, size_t); +.Vt typedef void LibHTTPC_Free(size_t); +.Vt extern LibHTTPC_Malloc *LibHTTPC_malloc; +.Vt extern LibHTTPC_Realloc *LibHTTPC_realloc; +.Vt extern LibHTTPC_Free *LibHTTPC_free; +. +.Sh DESCRIPTION +These are variables +that are used +for setting own +malloc implementation. +Set them +using +.Ql LibHTTPC +. +.Sh SEE ALSO +.Xr libhttpc 3 +. +.Sh AUTHORS +.An Nakidai Perumenei Aq Mt nakidai@disroot.org diff --git a/man/libhttpc.3 b/man/libhttpc.3 new file mode 100644 index 0000000..243e7b3 --- /dev/null +++ b/man/libhttpc.3 @@ -0,0 +1,57 @@ +.Dd December 13, 2024 +.Dt LIBHTTPC 3 +.Os +. +.Sh NAME +.Nm libhttpc +.Nd HTTP QoL library +.Pp +and also +.Pp +.Nm LibHTTPC +.Nd +.Nm +library initializer +. +.Sh SYNOPSIS +.In libhttpc/libhttpc.h +.Ft "void" +.Fo LibHTTPC +.Fa "LibHTTPC_Malloc *malloc" +.Fa "LibHTTPC_Realloc *realloc" +.Fa "LibHTTPC_Free *free" +.Fc +. +.Sh DESCRIPTION +.Nm +makes it easier +to create +HTTP servers. +It provides +some QoL functions +that you +would write yourself +without this library. +. +.Ss Configuration +If you +want to use +buffer autoallocating +or +.Xr libhttpc_request_ 3 , +then you need +to call +.Fn LibHTTPC +at first. +.Xr +. +.Sh SEE ALSO +.Xr libhttpc-alloc 3 , +.Xr libhttpc_header 3 , +.Xr libhttpc_method 3 , +.Xr libhttpc_request 3 , +.Xr libhttpc_response 3 , +.Xr libhttpc_status 3 +. +.Sh AUTHORS +.An Nakidai Perumenei Aq Mt nakidai@disroot.org diff --git a/man/libhttpc_header.3 b/man/libhttpc_header.3 new file mode 100644 index 0000000..728de22 --- /dev/null +++ b/man/libhttpc_header.3 @@ -0,0 +1,173 @@ +.Dd December 13, 2024 +.Dt LIBHTTPC_HEADER 3 +.Os +. +.Sh NAME +.Nm LibHTTPC_Header +.Nd HTTP header +. +.Sh SYNOPSIS +.In libhttpc/libhttpc.h +.Ft "const char *" +.Fn LibHTTPC_dumpHeader "enum LibHTTPC_HeaderType header" +.Ft "enum LibHTTPC_HeaderType" +.Fn LibHTTPC_loadHeader "const char *header" +. +.Sh DESCRIPTION +HTTP/1.1 +comes with +some headers. +.Xr libhttpc 3 +provides +QoL functions +for converting them +between +user-readable strings +and machine-readable enum. +. +.Sh HEADERS +Headers are declared +as follows: +.Bd -literal -offset indent +struct LibHTTPC_Header +{ + const char *name; + const char *value; +}; +.Ed +. +.Sh HEADER TYPE +In addition +to the structure, +.Xr libhttpc 3 +provides +a list +of HTTP/1.1 headers +as enum. +. +.Ss General headers +.Bl -tag +.It Dv LibHTTPC_Header_CACHE_CONTROL +Cache-Control +.It Dv LibHTTPC_Header_CONNECTION +Connection +.It Dv LibHTTPC_Header_DATE +Date +.It Dv LibHTTPC_Header_PRAGMA +Pragma +.It Dv LibHTTPC_Header_TRAILER +Trailer +.It Dv LibHTTPC_Header_TRANSFER_ENCODING +Transfer-Encoding +.It Dv LibHTTPC_Header_UPGRADE +Upgrade +.It Dv LibHTTPC_Header_VIA +Via +.It Dv LibHTTPC_Header_WARNING +Warning +.El +. +.Ss Request headers +.Bl -tag +.It Dv LibHTTPC_Header_ACCEPT +Accept +.It Dv LibHTTPC_Header_ACCEPT_CHARSET +Accept-Charset +.It Dv LibHTTPC_Header_ACCEPT_ENCODING +Accept-Encoding +.It Dv LibHTTPC_Header_ACCEPT_LANGUAGE +Accept-Language +.It Dv LibHTTPC_Header_AUTHORIZATION +Authorization +.It Dv LibHTTPC_Header_EXPECT +Expect +.It Dv LibHTTPC_Header_FROM +From +.It Dv LibHTTPC_Header_HOST +Host +.It Dv LibHTTPC_Header_IF_MATCH +If-Match +.It Dv LibHTTPC_Header_IF_MODIFIED_SINCE +If-Modified-Since +.It Dv LibHTTPC_Header_IF_NONE_MATCH +If-None-Match +.It Dv LibHTTPC_Header_IF_RANGE +If-Range +.It Dv LibHTTPC_Header_IF_UNMODIFIED_SINCE +If-Unmodified-Since +.It Dv LibHTTPC_Header_MAX_FORWARDS +Max-Forwards +.It Dv LibHTTPC_Header_PROXY_AUTHORIZATION +Proxy-Authorization +.It Dv LibHTTPC_Header_RANGE +Range +.It Dv LibHTTPC_Header_REFERER +Referer +.It Dv LibHTTPC_Header_TE +TE +.It Dv LibHTTPC_Header_USER_AGENT +User-Agent +.El + +.Ss Response headers +.Bl -tag +.It Dv LibHTTPC_Header_ACCEPT_RANGES +Accept-Ranges +.It Dv LibHTTPC_Header_AGE +Age +.It Dv LibHTTPC_Header_ETAG +ETag +.It Dv LibHTTPC_Header_LOCATION +Location +.It Dv LibHTTPC_Header_PROXY_AUTHENTICATE +Proxy-Authorization +.It Dv LibHTTPC_Header_RETRY_AFTER +Retry-After +.It Dv ibHTTPC_Header_SERVER +Server +.It Dv ibHTTPC_Header_VARY +Vary +.It Dv ibHTTPC_Header_WWW_AUTHENTICATE +WWW-Authenticate +.El +. +.Ss Entity headers +.Bl -tag +.It Dv LibHTTPC_Header_ALLOW +Allow +.It Dv LibHTTPC_Header_CONTENT_ENCODING +Content-Encoding +.It Dv LibHTTPC_Header_CONTENT_LANGUAGE +Content-Language +.It Dv LibHTTPC_Header_CONTENT_LENGTH +Content-Length +.It Dv LibHTTPC_Header_CONTENT_LOCATION +Content-Location +.It Dv LibHTTPC_Header_CONTENT_MD5 +Content-MD5 +.It Dv LibHTTPC_Header_CONTENT_RANGE +Content-Range +.It Dv LibHTTPC_Header_CONTENT_TYPE +Content-Type +.It Dv LibHTTPC_Header_EXPIRES +Expires +.It Dv LibHTTPC_Header_LAST_MODIFIED +Last-Modified +.El + +.Ss Other headers +Also, +there's +a special +.Dv LibHTTPC_Header_EXTENSION_HEADER +header type +that means +user-defined +header +(as of HTTP/1.1). +. +.Sh SEE ALSO +.Xr libhttpc 3 +. +.Sh AUTHORS +.An Nakidai Perumenei Aq Mt nakidai@disroot.org diff --git a/man/libhttpc_method.3 b/man/libhttpc_method.3 new file mode 100644 index 0000000..6583416 --- /dev/null +++ b/man/libhttpc_method.3 @@ -0,0 +1,59 @@ +.Dd December 13, 2024 +.Dt LIBHTTPC_METHOD 3 +.Os +. +.Sh NAME +.Nm LibHTTPC_Method +HTTP method +. +.Sh SYNOPSIS +.In libhttpc/libhttpc.h +.Ft "const char *" +.Fn LibHTTPC_dumpMethod "enum LibHTTPC_Method method" +.Ft "enum LibHTTPC_Method" +.Fn LibHTTPC_loadMethod "const char *method" +. +.Sh DESCRIPTION +HTTP/1.1 +comes with +some methods. +.Xr libhttpc 3 +provides +QOL functions +for converting them +between +user-readable strings +and machine-readable enum. +.Ss Methods +These are methods +that are supported +by +.Xr libhttpc 3 : +.Bl -tag +.It Dv LibHTTPC_Method_OPTIONS +OPTIONS +.It Dv LibHTTPC_Method_GET +GET +.It Dv LibHTTPC_Method_HEAD +HEAD +.It Dv LibHTTPC_Method_POST +POST +.It Dv LibHTTPC_Method_PUT +PUT +.It Dv LibHTTPC_Method_DELETE +DELETE +.It Dv LibHTTPC_Method_TRACE +TRACE +.It Dv LibHTTPC_Method_CONNECT +CONNECT +.El +Also, +there's +.Dv LibHTTPC_Method_EXTENSION_METHOD +for user-defined methods. +. +.Sh SEE ALSO +.Xr libhttpc 3 +. +.Sh AUTHORS +.An Nakidai Perumenei Aq Mt nakidai@disroot.org diff --git a/man/libhttpc_request.3 b/man/libhttpc_request.3 new file mode 100644 index 0000000..2fb4a74 --- /dev/null +++ b/man/libhttpc_request.3 @@ -0,0 +1,154 @@ +.Dd December 13, 2024 +.Dt LIBHTTPC_REQUEST 3 +.Os +. +.Sh NAME +.Nm LibHTTPC_Request +.Nd way to store HTTP requests +. +.Sh SYNOPSIS +.In libhttpc/libhttpc.h +.Ft "struct LibHTTPC_Request *" +.Fo LibHTTPC_loadRequest +.Fa "struct LibHTTPC_Request *request_buf" +.Fa "char *buf" +.Fc +.Ft int +.Fo LibHTTPC_Request_ +.Fa "struct LibHTTPC_Request *request" +.Fc +. +.Sh DESCRIPTION +.Xr libhttpc 3 +stores requests +as follows: +.Bd -literal -offset indent +struct LibHTTPC_Request +{ + char *buf; + char *method; + char *uri; + char *version; + struct LibHTTPC_Header *headers; + char *body; + size_t header_count; + int selfalloc; + int header_selfalloc; +}; +.Ed +Let's see +what means +each member: +.Bl -tag +.It Vd char *buf +Pointer to +the buffer +where request +is stored +.It Vd char *method +Pointer to +the method. +It should be equal to +.Ql buf +.It Vd char *uri +Pointer to +the +.Xr uri 7 +.It Vd char *version +Pointer to +the HTTP version number +.It struct LibHTTPC_Header *headers +Array of headers +.It char *body +Pointer to +the entity +.It size_t header_count +Length of +.Ql headers +array +.It int header_selfalloc +Set by the +.Ql LibHTTPC_loadRequest +function if +.Ql NULL +was passed to +request_buf argument. +Used by +.Ql LibHTTPC_Request_ . +.It int selfalloc +Set by the +.Ql LibHTTPC_loadRequest +function if +.Ql headers +array was +allocated +by the function +itself. +Used by +.Ql LibHTTPC_Request_ . +.El +. +.Pp +.Ql LibHTTPC_loadRequest +function parses +.Ql buf +and fills a +.Ql struct LibHTTPC_Request . +If +.Ql request_buf +argument +is +.Ql NULL , +then functon will +allocate buffer +itself. +. +.Pp +.Ql LibHTTPC_Request_ +function +is a destructor. +It frees array +if header_selfalloc is set, +and then frees structure +if selfalloc is set. +. +.Sh ERRORS +If +.Ql LibHTTPC_loadRequest +returned +.Ql NULL , +you should check +.Ql errno . +If +.Ql errno +is 0, +then most likely +you forgot to call +.Ql LibHTTPC +function. +. +.Pp +If +.Ql LibHTTPC_Request_ +returned -1, +you should check +.Ql errno . +. +.Sh SEE ALSO +.Xr libhttpc 3 , +.Xr libhttpc-alloc 3 , +.Xr libhttpc_header 3 +. +.Sh AUTHORS +.An Nakidai Perumenei Aq Mt nakidai@disroot.org +. +.Sh CAVEATS +.Ql LibHTTPC_loadRequest +function will +destroy the buffer +while working. +It sets +0 char +on the end +of every string in +.Ql struct LibHTTPC_Request . diff --git a/man/libhttpc_response.3 b/man/libhttpc_response.3 new file mode 100644 index 0000000..d69c2db --- /dev/null +++ b/man/libhttpc_response.3 @@ -0,0 +1,123 @@ +.Dd December 13, 2024 +.Dt LIBHTTPC_RESPONSE 3 +.Os +. +.Sh NAME +.Nm LibHTTPC_Response +.Nd way to store HTTP responses +. +.Sh SYNOPSIS +.In libhttpc/libhttpc.h +.Ft "char *" +.Fo LibHTTPC_dumpResponse +.Fa "struct LibHTTPC_Response *response" +.Fa "char *buf" +.Fa "size_t buf_len" +.Fc +.Ft int +.Fo "LibHTTPC_writeResponse" +.Fa "int sockfd" +.Fa "struct LibHTTPC_Response *response" +.Fc +. +.Sh DESCRIPTION +.Xr libhttpc 3 +stores responses +as follows: +.Bd -literal -offset indent +struct LibHTTPC_Response +{ + char *buf; + const char *version; + enum LibHTTPC_Status status; + const char *phrase; + struct LibHTTPC_Header *headers; + const char *body; + size_t header_count; +}; +.Ed +Let's see +what means +each member: +.Bl -tag +.It Vd char *buf +Pointer to +the buffer +where response +is stored. +Presented +only for consistence, +doesn't mean anything +for the library. +.It Vd const char *version +Pointer to +the HTTP version number +.It Vd enum LibHTTPC_Status status +Response code +.It Vd const char *phrase +Explanation +of response code +.It Vd struct LibHTTPC_Header *headers +Array of headers +.It Vd const char *body +Pointer to +the entity +.It Vd size_t header_count +Length of +.Ql header_count +array +. +.Pp +.Ql LibHTTPC_dumpResponse +function combines +contents of +.Ql response +in the buffer. +. +.Pp +.Ql LibHTTPC_writeResponse +function writes +.Ql response +to the +.Ql sockfd . +. +.Pp +Both functions can +autocomplete responses. +If +.Ql version +is +.Ql NULL , +then it will +be set to +.Ql "HTTP/1.1" . +If +.Ql status +is 0, +then it will +be set to +200. +If +.Ql phrase +is +.Ql NULL , +then it will +be set to +.Ql LibHTTPC_dumpStatus(status) . +. +.Sh SEE ALSO +.Xr libhttpc 3 , +.Xr libhttpc_header , +.Xr libhttpc_status +. +.Sh AUTHORS +.An Nakidai Perumenei Aq Mt nakidai@disroot.org +. +.Sh CAVEATS +.Ql LibHTTPC_dumpResponse +and +.Ql LibHTTPC_writeResponse +may edit fields of +.Ql response +that are set to +0 diff --git a/man/libhttpc_status.3 b/man/libhttpc_status.3 new file mode 100644 index 0000000..b8d5e7f --- /dev/null +++ b/man/libhttpc_status.3 @@ -0,0 +1,130 @@ +.Dd December 13, 2024 +.Dt LIBHTTPC_STATUS 3 +.Os +. +.Nm LibHTTPC_Status +.Nd HTTP status +. +.Sh SYNOPSIS +.In libhttpc/libhttpc.h +.Ft "const char *" +.Fn LibHTTPC_dumpStatus "enum LibHTTPC_Status status" +. +.Sh DESCRIPTION +HTTP/1.1 +comes with +some statuses. +.Xr libhttpc 3 +provides +QoL function +for getting +usually used +status strings +by code. +. +.Sh STATUSES +.Ss 1xx: Informational +.Bl -tag +.It Dv LibHTTPC_Status_CONTINUE = 100 +Continue +.It Dv LibHTTPC_Status_SWITCHING_PROTOCOLS = 101 +Switching protocols +.El +. +.Ss 2xx: Success +.Bl -tag +.It Dv LibHTTPC_Status_OK = 200 +OK +.It Dv LibHTTPC_Status_CREATED = 201 +Created +.It Dv LibHTTPC_Status_ACCEPTED = 202 +Accepted +.It Dv LibHTTPC_Status_NONAUTHORITATIVE_INFO = 203 +Non-Authoritative Information +.It Dv LibHTTPC_Status_NO_CONTENT = 204 +No Content +.It Dv LibHTTPC_Status_RESET_CONTENT = 205 +Reset Content +.It Dv LibHTTPC_Status_PARTIAL_CONTENT = 206 +Partial Content +.El +. +.Ss 3xx: Redirection +.Bl -tag +.It Dv LibHTTPC_Status_MULTIPLE_CHOICES = 300 +Multiple Choices +.It Dv LibHTTPC_Status_MOVED_PERMANENTLY = 301 +Moved Permanently +.It Dv LibHTTPC_Status_FOUND = 302 +Found +.It Dv LibHTTPC_Status_SEE_OTHER = 303 +See Other +.It Dv LibHTTPC_Status_NOT_MODIFIED = 304 +Not Modified +.It Dv LibHTTPC_Status_USE_PROXY = 305 +Use Proxy +.It Dv LibHTTPC_Status_TEMPORARY_REDIRECT = 307 +Temporary Redirect +.El +. +.Ss 4xx: Client Error +.Bl -tag +.It Dv LibHTTPC_Status_BAD_REQUEST = 400 +Bad Request +.It Dv LibHTTPC_Status_UNAUTHORIZED 401 +Unauthorized +.It Dv LibHTTPC_Status_PAYMENT_REQUIRED 402 +Payment Required +.It Dv LibHTTPC_Status_FORBIDDEN = 403 +Forbidden +.It Dv LibHTTPC_Status_NOT_FOUND = 404 +Not Found +.It Dv LibHTTPC_Status_METHOD_NOT_ALLOWED = 405 +Method Not Allowed +.It Dv LibHTTPC_Status_NOT_ACCEPTABLE = 406 +Not Acceptable +.It Dv LibHTTPC_Status_PROXY_AUTH_REQUIRED = 407 +Proxy Authentication Required +.It Dv LibHTTPC_Status_REQUEST_TIMEOUT = 408 +Request Timeout +.It Dv LibHTTPC_Status_CONFLICT = 409 +Conflict +.It Dv LibHTTPC_Status_GONE = 410 +Gone +.It Dv LibHTTPC_Status_LENGTH_REQUIRED = 411 +Length Required +.It Dv LibHTTPC_Status_PRECONDITION_FAILED = 412 +Precondition Failed +.It Dv LibHTTPC_Status_ENTITY_TOO_LARGE = 413 +Entity Too Large +.It Dv LibHTTPC_Status_URI_TOO_LONG = 414 +Request-URI Too Long +.It Dv LibHTTPC_Status_UNSUPPORTED_MEDIA_TYPE = 415 +Unsupported Media Type +.It Dv LibHTTPC_Status_RANGE_NOT_SATISFIABLE = 416 +Requested Range Not Satisfiable +.It Dv LibHTTPC_Status_EXPECTATION_FAILED = 417 +Expectation Failed +.El +. +.Ss 5xx: Server Error +.Bl -tag +.It Dv LibHTTPC_Status_INTERNAL_SERVER_ERROR = 500 +Internal Server Error +.It Dv LibHTTPC_Status_NOT_IMPLEMENTED = 501 +Not Implemented +.It Dv LibHTTPC_Status_BAD_GATEWAY = 502 +Bad Gateway +.It Dv LibHTTPC_Status_SERVICE_UNAVAILABLE = 503 +Service Unavailable +.It Dv LibHTTPC_Status_GATEWAY_TIMEOUT = 504 +Gateway Timeout +.It Dv LibHTTPC_Status_HTTP_VER_NOT_SUPPORTED = 505 +HTTP Version Not Supported +.El +. +.Sh SEE ALSO +.Xr libhttpc 3 +. +.Sh AUTHORS +.An Nakidai Perumenei Aq Mt nakidai@disroot.org -- cgit 1.4.1