mirror of
https://github.com/lammertb/libhttp.git
synced 2025-08-09 03:22:45 +03:00
Enhanced documentation and code quality
This commit is contained in:
23
doc/api/httplib_atomic_dec.md
Normal file
23
doc/api/httplib_atomic_dec.md
Normal file
@@ -0,0 +1,23 @@
|
||||
# LibHTTP API Reference
|
||||
|
||||
### `httplib_atomic_dec( addr );`
|
||||
|
||||
### Parameters
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| :--- | :--- | :--- |
|
||||
|**`addr`**|`volatile int *`|The address of the integer to decrement|
|
||||
|
||||
### Return Value
|
||||
|
||||
| Type | Description |
|
||||
| :--- | :--- |
|
||||
|`int`|The value of the integer after the decrement|
|
||||
|
||||
### Description
|
||||
|
||||
The function `httplib_atomic_dec()` performs an atomic decrement if an integer. This function can be used to decrement an integer in a reliable way where multiple processes or threads have simultaneous access to the variable. The function returns the value of the integer after it has been decremented.
|
||||
|
||||
### See Also
|
||||
|
||||
* [`httplib_atomic_inc();`](httplib_atomic_inc.md)
|
23
doc/api/httplib_atomic_inc.md
Normal file
23
doc/api/httplib_atomic_inc.md
Normal file
@@ -0,0 +1,23 @@
|
||||
# LibHTTP API Reference
|
||||
|
||||
### `httplib_atomic_inc( addr );`
|
||||
|
||||
### Parameters
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| :--- | :--- | :--- |
|
||||
|**`addr`**|`volatile int *`|The address of the integer to increment|
|
||||
|
||||
### Return Value
|
||||
|
||||
| Type | Description |
|
||||
| :--- | :--- |
|
||||
|`int`|The value of the integer after the increment|
|
||||
|
||||
### Description
|
||||
|
||||
The function `httplib_atomic_inc()` performs an atomic increment if an integer. This function can be used to increment an integer in a reliable way where multiple processes or threads have simultaneous access to the variable. The function returns the value of the integer after it has been incremented.
|
||||
|
||||
### See Also
|
||||
|
||||
* [`httplib_atomic_dec();`](httplib_atomic_dec.md)
|
27
doc/api/httplib_base64_encode.md
Normal file
27
doc/api/httplib_base64_encode.md
Normal file
@@ -0,0 +1,27 @@
|
||||
# LibHTTP API Reference
|
||||
|
||||
### `httplib_base64_encode( src, src_len, dst, dst_len );`
|
||||
|
||||
### Parameters
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| :--- | :--- | :--- |
|
||||
|**`src`**|`const unsigned char *`|Pointer to binary data to be BASE64 encoded|
|
||||
|**`src_len`**|`int`|The number of bytes of the binary data to encode|
|
||||
|**`dst`**|`char *`|Destination buffer for the encoding string|
|
||||
|**`dst_len`**|`int`|Length of the destination buffer|
|
||||
|
||||
### Return Value
|
||||
|
||||
| Type | Description |
|
||||
| :--- | :--- |
|
||||
|`int`|The size of the destination string or an error|
|
||||
|
||||
### Description
|
||||
|
||||
The function `httplib_base64_encode()` encodes a block of binary data to a BASE64 encoded NUL terminated string. The destination buffer should be large enough to contain the whole string and NUL terminating character. If the function succeeds the actual number of used bytes in the destination buffer is returned. An error is indicated with the return value **-1**.
|
||||
|
||||
### See Also
|
||||
|
||||
* [`httplib_url_decode();`](httplib_url_decode.md)
|
||||
* [`httplib_url_encode();`](httplib_url_encode.md)
|
@@ -19,7 +19,7 @@
|
||||
||**`FORM_FIELD_STORAGE_STORE`** - Store a file as `path` and overwrite that file if it already exists|
|
||||
||**`FORM_FIELD_STORAGE_ABORT`** - Stop parsing the request and ignore all remaining form fields|
|
||||
|**`field_get`**|**`int field_get( const char *key, const char *value, size_t valuelen, void *user_data );`**|
|
||||
|**`field_store`**|**`int field_store( const char *path, long long file_size, void *user_data );`**|
|
||||
|**`field_store`**|**`int field_store( const char *path, int64_t file_size, void *user_data );`**|
|
||||
||If the callback function `field_found()` returned `FORM_FIELD_STORAGE_STORE`, LibHTTP will try to store the received data in a file. If writing the file is successful, the callback function `field_store()` is called. This function is only called after completion of a full upload, not if a file has only partly been uploaded. When only part of a file is received, LibHTTP will delete that partly upload in the background and not inform the main application through this callback. The following parameters are provided in the function call:|
|
||||
||**`path`** -|
|
||||
||**`file_size`** - The path on the server where the file was stored|
|
||||
|
@@ -26,3 +26,4 @@ The `httplib_mkdir()` function returns **0** when it was successful and **-1** w
|
||||
* [`httplib_closedir();`](httplib_closedir.md)
|
||||
* [`httplib_opendir();`](httplib_opendir.md)
|
||||
* [`httplib_readdir();`](httplib_readdir.md)
|
||||
* [`httplib_remove();`](httplib_remove.md)
|
||||
|
25
doc/api/httplib_remove.md
Normal file
25
doc/api/httplib_remove.md
Normal file
@@ -0,0 +1,25 @@
|
||||
# LibHTTP API Reference
|
||||
|
||||
### `httplib_remove( path );`
|
||||
|
||||
### Parameters
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| :--- | :--- | :--- |
|
||||
|**`path`**|`const char *`|The path of the file or directory to remove|
|
||||
|
||||
### Return Value
|
||||
|
||||
| Type | Description |
|
||||
| :--- | :--- |
|
||||
|`int`|An integer which indicates success or failure of the call|
|
||||
|
||||
### Description
|
||||
|
||||
The function `httplib_remove()` provides a platform independent way to remove an entry from a directory. The function can be used to remove both file and directory entries. Remove will only function on directories, if the contents of the directory to remove is empty. In Posix compliant environments this function is a wrapper around the Posix `remove()` function. On other systems the Posix `remove()` functionality is emulated with own code.
|
||||
|
||||
The function returns **0** when successful and **-1** if an error occurs.
|
||||
|
||||
### See Also
|
||||
|
||||
* [`httplib_mkdir();`](httplib_mkdir.md)
|
@@ -14,7 +14,7 @@
|
||||
|**`remote_user`**|`const char *`| The name of the authenticated remote user, or NULL if no authentication was used |
|
||||
|**`remote addr`**|`char[48]`| The IP address of the remote client as a string. This can either represent an IPv4 or an IPv6 address. |
|
||||
|~~`remote_ip`~~|`long`| *Deprecated. Use* `remote_addr` *instead* |
|
||||
|**`content_length`**|`long long`| The content length of the request body. This value can be -1 if no content length was provided. |
|
||||
|**`content_length`**|`int64_t`| The content length of the request body. This value can be -1 if no content length was provided. |
|
||||
|**`remote_port`**|`int`| The port number at the client's side |
|
||||
|**`is_ssl`**|`int`| 1 if the connection is over SSL, and 0 if it is a plain connection |
|
||||
|**`user_data`**|`void *`| A pointer to the `user_data` information which was provided as a parameter to `httplib_start()`. |
|
||||
|
@@ -13,7 +13,7 @@
|
||||
|
||||
| Type | Description |
|
||||
| :--- | :--- |
|
||||
|`long long`|Number of bytes written to the file, or an error code|
|
||||
|`int64_t`|Number of bytes written to the file, or an error code|
|
||||
|
||||
### Description
|
||||
|
||||
|
27
doc/api/httplib_strlcpy.md
Normal file
27
doc/api/httplib_strlcpy.md
Normal file
@@ -0,0 +1,27 @@
|
||||
# LibHTTP API Reference
|
||||
|
||||
### `httplib_strlcpy( dst, src, len );`
|
||||
|
||||
### Parameters
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| :--- | :--- | :--- |
|
||||
|**`dst`**|`const char *`|Pointer to the destination buffer|
|
||||
|**`src`**|`const char *`|Pointer to the source string which must be copied|
|
||||
|**`len`**|`size_t`|The size of the receiving buffer in bytes|
|
||||
|
||||
### Return Value
|
||||
|
||||
*none*
|
||||
|
||||
### Description
|
||||
|
||||
The function `httplib_strlcpy()` provides a platform independent safe way to copy a string from one memory location to another. The size of the receiving buffer is provided as a parameter and the function ensures that no more the number of the characters fitting in the buffer will be copied. The function also ensures that if the destination buffer is not NULL and the size is at least one byte long that the resulting string is terminated with a NUL character.
|
||||
|
||||
If the source string is longer than will fit in the receiving buffer, the remaining characters will be ignored.
|
||||
|
||||
### See Also
|
||||
|
||||
* [`httplib_strcasecmp();`](httplib_strcasecmp.md)
|
||||
* [`httplib_strncasecmp();`](httplib_strncasecmp.md)
|
||||
* [`httplib_strndup()'`](httplib_strndup.md)
|
30
doc/api/httplib_strndup.md
Normal file
30
doc/api/httplib_strndup.md
Normal file
@@ -0,0 +1,30 @@
|
||||
# LibHTTP API Reference
|
||||
|
||||
### `httplib_strndup( str, len );`
|
||||
|
||||
### Parameters
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| :--- | :--- | :--- |
|
||||
|**`str`**|`const char *`|Pointer to the source string which must be duplicated|
|
||||
|**`len`**|`size_t`|The maximum number of string characters to duplicate|
|
||||
|
||||
### Return Value
|
||||
|
||||
| Type | Description |
|
||||
| :--- | :--- |
|
||||
|`char *`|Pointer to the duplicate, or NULL if an error occured|
|
||||
|
||||
### Description
|
||||
|
||||
The function `httplib_strndup()` duplicates a given number of characters of a string to a new string and terminates the result with a NUL character. If less than the specified maximum amount of characters are available, only the available characters are copied. The duplicate is stored in a newly allocated block of memory. The function is equivalent to the Posix `strndup()` function with the difference that the LibHTTP memory allocation functions are used which allow for tracking of allocation requests and memory leaks through a monitor hook. The size of the allocated memory block is the given maximum string length plus one byte for the terminating NUL character.
|
||||
|
||||
If the duplicate of the string is no longer used, the allocated memory should be returned to the heap with a call to [`httplib_free()`](httplib_free.md).
|
||||
|
||||
If the function fails the value `NULL` is returned, otherwise a pointer to the duplicate.
|
||||
|
||||
### See Also
|
||||
|
||||
* [`httplib_free();`](httplib_free.md)
|
||||
* [`httplib_strcasecmp();`](httplib_strcasecmp.md)
|
||||
* [`httplib_strncasecmp();`](httplib_strncasecmp.md)
|
@@ -24,4 +24,5 @@ The function `httplib_url_decode()` Decodes a in input buffer. Both normal URIs
|
||||
|
||||
### See Also
|
||||
|
||||
* [`httplib_base64_encode()`](httplib_base64_encode.md)
|
||||
* [`httplib_url_encode();`](httplib_url_encode.md)
|
||||
|
@@ -22,4 +22,5 @@ The function `httplib_url_encode()` encodes a in input buffer. Both normal URIs
|
||||
|
||||
### See Also
|
||||
|
||||
* [`httplib_base64_encode();`](htptlib_base64_encode.md)
|
||||
* [`httplib_url_decode();`](httplib_url_decode.md)
|
||||
|
Reference in New Issue
Block a user