ulfius.h File Reference

Ulfius framework. More...

`#include "ulfius-cfg.h"`
`#include <gnutls/gnutls.h>`
`#include <gnutls/x509.h>`
`#include <jansson.h>`
`#include <poll.h>`
`#include <zlib.h>`
`#include <pthread.h>`
`#include <microhttpd.h>`
`#include <orcania.h>`
`#include <yder.h>`
Include dependency graph for ulfius.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

## Data Structures

struct | _u_map
struct | _u_cookie
struct | _u_request
| definition of the parameters available in a struct _u_request More...
struct | _u_response
| definition of the parameters available in a struct _u_response More...
struct | _u_endpoint
| Contains all informations needed for an endpoint. More...
struct | _u_instance
| Contains the needed data for an ulfius instance to work. More...
struct | connection_info_struct

## Macros

#define | _GNU_SOURCE
#define | POLLRDHUP 0x2000
#define | U_DISABLE_WEBSOCKET
#define | ULFIUS_STREAM_BLOCK_SIZE_DEFAULT 1024
#define | U_STREAM_END MHD_CONTENT_READER_END_OF_STREAM
#define | U_STREAM_ERROR MHD_CONTENT_READER_END_WITH_ERROR
#define | U_STREAM_SIZE_UNKNOWN MHD_SIZE_UNKNOWN
#define | U_STREAM_SIZE_UNKOWN U_STREAM_SIZE_UNKNOWN
#define | U_OK 0
| No error.
#define | U_ERROR 1
| Error.
#define | U_ERROR_MEMORY 2
| Error in memory allocation.
#define | U_ERROR_PARAMS 3
| Error in input parameters.
#define | U_ERROR_LIBMHD 4
| Error in libmicrohttpd execution.
#define | U_ERROR_LIBCURL 5
| Error in libcurl execution.
#define | U_ERROR_NOT_FOUND 6
| Something was not found.
#define | U_ERROR_DISCONNECTED 7
| Connection closed.
#define | U_CALLBACK_CONTINUE 0
| Callback exited with success, continue to next callback.
#define | U_CALLBACK_IGNORE 1
| Callback decided to be ignored, request.callback_position will not be incremented, continue to next callback.
#define | U_CALLBACK_COMPLETE 2
| Callback exited with success, exit callback list.
#define | U_CALLBACK_UNAUTHORIZED 3
| Request is unauthorized, exit callback list and return status 401.
#define | U_CALLBACK_ERROR 4
| Error during request process, exit callback list and return status 500.
#define | U_COOKIE_SAME_SITE_EMPTY 0
| Set same_site cookie property not set.
#define | U_COOKIE_SAME_SITE_STRICT 1
| Set same_site cookie property to strict.
#define | U_COOKIE_SAME_SITE_LAX 2
| Set same_site cookie property to lax.
#define | U_COOKIE_SAME_SITE_NONE 3
| Set same_site cookie property to none.
#define | U_USE_IPV4 0x0001
| Use instance in IPV4 mode only.
#define | U_USE_IPV6 0x0010
| Use instance in IPV6 mode only.
#define | U_USE_ALL (U_USE_IPV4|U_USE_IPV6)
| Use instance in both IPV4 and IPV6 mode.
#define | U_SSL_VERIFY_PEER 0x0001
| Verify TLS session with peers.
#define | U_SSL_VERIFY_HOSTNAME 0x0010
| Verify TLS session with hostname.
#define | U_POST_PROCESS_NONE 0x0000
#define | U_POST_PROCESS_URL_ENCODED 0x0001
#define | U_POST_PROCESS_MULTIPART_FORMDATA 0x0010
#define | ULFIUS_URL_SEPARATOR "/"
#define | ULFIUS_HTTP_ENCODING_JSON "application/json"
#define | ULFIUS_HTTP_HEADER_CONTENT "Content-Type"
#define | ULFIUS_HTTP_NOT_FOUND_BODY "Resource not found"
#define | ULFIUS_HTTP_ERROR_BODY "Server Error"
#define | ULFIUS_COOKIE_ATTRIBUTE_EXPIRES "Expires"
#define | ULFIUS_COOKIE_ATTRIBUTE_MAX_AGE "Max-Age"
#define | ULFIUS_COOKIE_ATTRIBUTE_DOMAIN "Domain"
#define | ULFIUS_COOKIE_ATTRIBUTE_PATH "Path"
#define | ULFIUS_COOKIE_ATTRIBUTE_SECURE "Secure"
#define | ULFIUS_COOKIE_ATTRIBUTE_HTTPONLY "HttpOnly"
#define | ULFIUS_POSTBUFFERSIZE 65536
#define | U_STATUS_STOP 0
#define | U_STATUS_RUNNING 1
#define | U_STATUS_ERROR 2

## Enumerations

enum

u_option {
U_OPT_NONE = 0 , U_OPT_HTTP_VERB = 1 , U_OPT_HTTP_URL = 2 , U_OPT_HTTP_PROXY = 3 ,
U_OPT_CHECK_SERVER_CERTIFICATE = 5 , U_OPT_CHECK_SERVER_CERTIFICATE_FLAG = 6 , U_OPT_CHECK_PROXY_CERTIFICATE = 7 , U_OPT_CHECK_PROXY_CERTIFICATE_FLAG = 8 ,
U_OPT_FOLLOW_REDIRECT = 9 , U_OPT_CA_PATH = 10 , U_OPT_TIMEOUT = 11 , U_OPT_AUTH_BASIC_USER = 12 ,
U_OPT_AUTH_BASIC_PASSWORD = 13 , U_OPT_AUTH_BASIC = 14 , U_OPT_URL_PARAMETER = 15 , U_OPT_HEADER_PARAMETER = 16 ,
U_OPT_COOKIE_PARAMETER = 17 , U_OPT_POST_BODY_PARAMETER = 18 , U_OPT_URL_PARAMETER_REMOVE = 19 , U_OPT_HEADER_PARAMETER_REMOVE = 20 ,
U_OPT_COOKIE_PARAMETER_REMOVE = 21 , U_OPT_POST_BODY_PARAMETER_REMOVE = 22 , U_OPT_BINARY_BODY = 23 , U_OPT_STRING_BODY = 24 ,
U_OPT_JSON_BODY = 25 , U_OPT_CLIENT_CERT_FILE = 26 , U_OPT_CLIENT_KEY_FILE = 27 , U_OPT_CLIENT_KEY_PASSWORD = 28 ,
U_OPT_STATUS = 29 , U_OPT_AUTH_REALM = 30 , U_OPT_SHARED_DATA = 31 , U_OPT_HTTP_URL_APPEND = 32
}

## Functions

void | u_free (void *data)
int | ulfius_global_init (void)
void | ulfius_global_close (void)
int | ulfius_init_instance (struct _u_instance *u_instance, unsigned int port, struct sockaddr_in *bind_address, const char *default_auth_realm)
void | ulfius_clean_instance (struct _u_instance *u_instance)
int | ulfius_start_framework (struct _u_instance *u_instance)
int | ulfius_start_secure_framework (struct _u_instance *u_instance, const char *key_pem, const char *cert_pem)
int | ulfius_start_secure_ca_trust_framework (struct _u_instance *u_instance, const char *key_pem, const char *cert_pem, const char *root_ca_pem)
int | ulfius_start_framework_with_mhd_options (struct _u_instance *u_instance, unsigned int mhd_flags, struct MHD_OptionItem *mhd_ops)
void | mhd_request_completed (void *cls, struct MHD_Connection *connection, void **con_cls, enum MHD_RequestTerminationCode toe)
void * | ulfius_uri_logger (void *cls, const char *uri)
int | ulfius_stop_framework (struct _u_instance *u_instance)
int | ulfius_set_upload_file_callback_function (struct _u_instance *u_instance, int(*file_upload_callback)(const struct _u_request *request, const char *key, const char *filename, const char *content_type, const char *transfer_encoding, const char *data, uint64_t off, size_t size, void *cls), void *cls)
int | ulfius_add_endpoint (struct _u_instance *u_instance, const struct _u_endpoint *u_endpoint)
int | ulfius_add_endpoint_by_val (struct _u_instance *u_instance, const char *http_method, const char *url_prefix, const char *url_format, unsigned int priority, int(*callback_function)(const struct _u_request *request, struct _u_response *response, void *user_data), void *user_data)
int | ulfius_add_endpoint_list (struct _u_instance *u_instance, const struct _u_endpoint **u_endpoint_list)
int | ulfius_remove_endpoint (struct _u_instance *u_instance, const struct _u_endpoint *u_endpoint)
int | ulfius_set_default_endpoint (struct _u_instance *u_instance, int(*callback_function)(const struct _u_request *request, struct _u_response *response, void *user_data), void *user_data)
int | ulfius_remove_endpoint_by_val (struct _u_instance *u_instance, const char *http_method, const char *url_prefix, const char *url_format)
const struct _u_endpoint * | ulfius_empty_endpoint (void)
int | ulfius_copy_endpoint (struct _u_endpoint *dest, const struct _u_endpoint *source)
struct _u_endpoint * | ulfius_duplicate_endpoint_list (const struct _u_endpoint *endpoint_list)
void | ulfius_clean_endpoint (struct _u_endpoint *endpoint)
void | ulfius_clean_endpoint_list (struct _u_endpoint *endpoint_list)
int | ulfius_equals_endpoints (const struct _u_endpoint *endpoint1, const struct _u_endpoint *endpoint2)
int | ulfius_send_http_request (const struct _u_request *request, struct _u_response *response)
int | ulfius_send_http_request_with_limit (const struct _u_request *request, struct _u_response *response, size_t response_body_limit, size_t max_header)
int | ulfius_send_http_streaming_request (const struct _u_request *request, struct _u_response *response, size_t(*write_body_function)(void *contents, size_t size, size_t nmemb, void *user_data), void *write_body_data)
int | ulfius_send_http_streaming_request_max_header (const struct _u_request *request, struct _u_response *response, size_t(*write_body_function)(void *contents, size_t size, size_t nmemb, void *user_data), void *write_body_data, size_t max_header)
int | ulfius_send_smtp_email (const char *host, const int port, const int use_tls, const int verify_certificate, const char *user, const char *password, const char *from, const char *to, const char *cc, const char *bcc, const char *subject, const char *mail_body)
int | ulfius_send_smtp_rich_email (const char *host, const int port, const int use_tls, const int verify_certificate, const char *user, const char *password, const char *from, const char *to, const char *cc, const char *bcc, const char *content_type, const char *subject, const char *mail_body)
int | ulfius_add_cookie_to_response (struct _u_response *response, const char *key, const char *value, const char *expires, const unsigned int max_age, const char *domain, const char *path, const int secure, const int http_only)
int | ulfius_add_same_site_cookie_to_response (struct _u_response *response, const char *key, const char *value, const char *expires, const unsigned int max_age, const char *domain, const char *path, const int secure, const int http_only, const int same_site)
int | ulfius_add_header_to_response (struct _u_response *response, const char *key, const char *value)
int | ulfius_set_string_body_request (struct _u_request *request, const char *string_body)
int | ulfius_set_binary_body_request (struct _u_request *request, const char *binary_body, const size_t length)
int | ulfius_set_empty_body_request (struct _u_request *request)
int | ulfius_set_string_body_response (struct _u_response *response, const unsigned int status, const char *body)
int | ulfius_set_binary_body_response (struct _u_response *response, const unsigned int status, const char *body, const size_t length)
int | ulfius_set_empty_body_response (struct _u_response *response, const unsigned int status)
int | ulfius_set_stream_response (struct _u_response *response, const unsigned int status, ssize_t(*stream_callback)(void *stream_user_data, uint64_t offset, char *out_buf, size_t max), void(*stream_callback_free)(void *stream_user_data), uint64_t stream_size, size_t stream_block_size, void *stream_user_data)
int | ulfius_init_request (struct _u_request *request)
int | ulfius_clean_request (struct _u_request *request)
int | ulfius_clean_request_full (struct _u_request *request)
int | ulfius_copy_request (struct _u_request *dest, const struct _u_request *source)
int | ulfius_set_request_properties (struct _u_request *request,...)
struct _u_request * | ulfius_duplicate_request (const struct _u_request *request)
char * | ulfius_export_request_http (const struct _u_request *request)
int | ulfius_init_response (struct _u_response *response)
int | ulfius_clean_response (struct _u_response *response)
int | ulfius_clean_response_full (struct _u_response *response)
int | ulfius_copy_response (struct _u_response *dest, const struct _u_response *source)
int | ulfius_clean_cookie (struct _u_cookie *cookie)
int | ulfius_copy_cookie (struct _u_cookie *dest, const struct _u_cookie *source)
struct _u_response * | ulfius_duplicate_response (const struct _u_response *response)
int | ulfius_set_response_properties (struct _u_response *response,...)
int | ulfius_set_response_shared_data (struct _u_response *response, void *shared_data, void(*free_shared_data)(void *shared_data))
char * | ulfius_export_response_http (const struct _u_response *response)
char * | ulfius_url_decode (const char *str)
char * | ulfius_url_encode (const char *str)
json_t * | ulfius_get_json_body_request (const struct _u_request *request, json_error_t *json_error)
int | ulfius_set_json_body_request (struct _u_request *request, json_t *j_body)
json_t * | ulfius_get_json_body_response (struct _u_response *response, json_error_t *json_error)
int | ulfius_set_json_body_response (struct _u_response *response, const unsigned int status, const json_t *j_body)
int | u_map_init (struct _u_map *u_map)
int | u_map_clean (struct _u_map *u_map)
int | u_map_clean_full (struct _u_map *u_map)
int | u_map_clean_enum (char **array)
const char ** | u_map_enum_keys (const struct _u_map *u_map)
const char ** | u_map_enum_values (const struct _u_map *u_map)
int | u_map_has_key (const struct _u_map *u_map, const char *key)
int | u_map_has_value (const struct _u_map *u_map, const char *value)
int | u_map_has_value_binary (const struct _u_map *u_map, const char *value, size_t length)
int | u_map_has_key_case (const struct _u_map *u_map, const char *key)
int | u_map_has_value_case (const struct _u_map *u_map, const char *value)
int | u_map_put (struct _u_map *u_map, const char *key, const char *value)
int | u_map_put_binary (struct _u_map *u_map, const char *key, const char *value, uint64_t offset, size_t length)
ssize_t | u_map_get_length (const struct _u_map *u_map, const char *key)
ssize_t | u_map_get_case_length (const struct _u_map *u_map, const char *key)
const char * | u_map_get (const struct _u_map *u_map, const char *key)
const char * | u_map_get_case (const struct _u_map *u_map, const char *key)
int | u_map_remove_from_key (struct _u_map *u_map, const char *key)
int | u_map_remove_from_key_case (struct _u_map *u_map, const char *key)
int | u_map_remove_from_value (struct _u_map *u_map, const char *value)
int | u_map_remove_from_value_case (struct _u_map *u_map, const char *value)
int | u_map_remove_from_value_binary (struct _u_map *u_map, const char *key, size_t length)
int | u_map_remove_at (struct _u_map *u_map, const int index)
struct _u_map * | u_map_copy (const struct _u_map *source)
int | u_map_copy_into (struct _u_map *dest, const struct _u_map *source)
int | u_map_count (const struct _u_map *source)
int | u_map_empty (struct _u_map *u_map)
char * | ulfius_export_client_certificate_pem (const struct _u_request *request)
int | ulfius_import_client_certificate_pem (struct _u_request *request, const char *str_cert)

## Detailed Description

Ulfius framework.

REST framework library

ulfius.h: public structures and functions declarations

Copyright 2015-2022 Nicolas Mora mail@.nosp@m.babe.nosp@m.loues.nosp@m.t.or.nosp@m.g

This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; version 2.1 of the License.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU GENERAL PUBLIC LICENSE for more details.

You should have received a copy of the GNU General Public License along with this library. If not, see http://www.gnu.org/licenses/.

## Macro Definition Documentation

## _GNU_SOURCE

#define _GNU_SOURCE

External dependencies

## POLLRDHUP

#define POLLRDHUP 0x2000

## U_DISABLE_WEBSOCKET

#define U_DISABLE_WEBSOCKET