### GET /evhttp_start Source: https://libevent.org/doc/http__compat_8h.html Initializes and starts an HTTP server on the specified address and port. ```APIDOC ## [FUNCTION] evhttp_start ### Description Starts an HTTP server on the specified address and port. Note that this function is deprecated as it does not allow an event base to be specified. ### Method N/A (C Function) ### Endpoint evhttp_start(const char *address, ev_uint16_t port) ### Parameters #### Path Parameters - **address** (const char *) - Required - The address to which the HTTP server should be bound - **port** (ev_uint16_t) - Required - The port number on which the HTTP server should listen ### Response #### Success Response (200) - **evhttp** (struct *) - A pointer to a newly initialized evhttp server structure or NULL on error ``` -------------------------------- ### GET /api/libevent/bufferevent_options Source: https://libevent.org/doc/globals_enum.html Describes the options available for configuring bufferevent behavior during initialization. ```APIDOC ## GET /api/libevent/bufferevent_options ### Description Flags used to configure the behavior of bufferevents, such as thread safety and socket closing. ### Method GET ### Endpoint /bufferevent.h/bufferevent_options ### Parameters None ### Request Example N/A ### Response #### Success Response (200) - **BEV_OPT_CLOSE_ON_FREE** (enum) - Close underlying file descriptor on free - **BEV_OPT_THREADSAFE** (enum) - Make bufferevent thread-safe #### Response Example { "enum": "bufferevent_options", "values": ["BEV_OPT_CLOSE_ON_FREE", "BEV_OPT_THREADSAFE"] } ``` -------------------------------- ### Initialize HTTP Server and Connections with Libevent Source: https://libevent.org/doc/http__compat_8h_source.html Provides functions to start an HTTP server and create new HTTP connections. These functions are part of the compatibility layer for managing network communication in libevent applications. ```C /* Start an HTTP server */ struct evhttp *evhttp_start(const char *address, ev_uint16_t port); /* Create a new HTTP connection object */ struct evhttp_connection *evhttp_connection_new(const char *address, ev_uint16_t port); /* Associate an event base with a connection */ void evhttp_connection_set_base(struct evhttp_connection *evcon, struct event_base *base); ``` -------------------------------- ### Initialize and Dispatch Libevent Loop Source: https://libevent.org/doc/event__compat_8h_source.html Functions for initializing the event base and starting the event dispatch loop. These functions are part of the legacy compatibility layer for Libevent. ```C EVENT2_EXPORT_SYMBOL struct event_base *event_init(void); EVENT2_EXPORT_SYMBOL int event_dispatch(void); EVENT2_EXPORT_SYMBOL int event_loop(int flags); ``` -------------------------------- ### GET /evhttp_decode_uri Source: https://libevent.org/doc/globals_e.html Decodes a URI-encoded string. ```APIDOC ## GET /evhttp_decode_uri ### Description Converts a percent-encoded URI string back into its original form. ### Method GET ### Endpoint evhttp_decode_uri ### Parameters #### Query Parameters - **uri** (const char*) - Required - The encoded URI string. ### Response #### Success Response (200) - **char*** (string) - The decoded URI string. ### Response Example { "decoded_uri": "/path/to/resource" } ``` -------------------------------- ### Register and Implement RPC Server Callback Source: https://libevent.org/doc/rpc_8h.html Demonstrates how to initialize an RPC base and register a specific RPC command with a callback function. The callback is responsible for processing the request and sending the reply using EVRPC_REQUEST_DONE. ```C struct evrpc_base *base = evrpc_init(http); EVRPC_REGISTER(base, SendCommand, Request, Reply, FunctionCB, arg); void FunctionCB(EVRPC_STRUCT(SendCommand)* rpc, void *arg) { // Fill in the reply structure EVRPC_REQUEST_DONE(rpc); } ``` -------------------------------- ### evbuffer_get_max_read Source: https://libevent.org/doc/buffer_8h.html Get the maximum read buffer size. ```APIDOC ## evbuffer_get_max_read() ### Description Get maximum read buffer size. ### Method EVENT2_EXPORT_SYMBOL size_t ### Parameters #### Path Parameters - **_buf_** (struct evbuffer *) - Required - Pointer to the evbuffer. ### Returns Current maximum buffer read. ``` -------------------------------- ### POST /evhttp_new Source: https://libevent.org/doc/globals_e.html Initializes a new HTTP server object. ```APIDOC ## POST /evhttp_new ### Description Creates a new HTTP server object that can be used to bind to ports and handle incoming requests. ### Method POST ### Endpoint evhttp_new ### Parameters #### Request Body - **base** (event_base*) - Required - The event base to associate with the HTTP server. ### Response #### Success Response (200) - **evhttp*** (object) - A pointer to the newly created HTTP server object. ### Response Example { "status": "success", "object": "evhttp_ptr" } ``` -------------------------------- ### Initialize and Configure DNS Library Source: https://libevent.org/doc/dns__compat_8h.html Functions for initializing the asynchronous DNS library and managing nameserver addresses. These are deprecated due to global state dependency and lack of thread safety. ```C int evdns_init(void); int evdns_nameserver_add(unsigned long int address); int evdns_nameserver_ip_add(const char *ip_as_string); ``` -------------------------------- ### Initialize and Perform Async DNS Resolution Source: https://libevent.org/doc/dns_8h.html Demonstrates how to parse a resolv.conf file and initiate an asynchronous DNS lookup using evdns_resolve. The callback function processes the result, including IP addresses and TTL information. ```C #include "evdns.h" void callback(int result, char type, int count, int ttl, void *addresses, void *arg) { // Handle DNS resolution results here } evdns_resolv_conf_parse(DNS_OPTIONS_ALL, "/etc/resolv.conf"); evdns_resolve("www.hostname.com", 0, callback, NULL); ``` -------------------------------- ### Search for Data within evbuffer (C) Source: https://libevent.org/doc/buffer_8h_source.html Searches for a specific byte sequence within an evbuffer. `evbuffer_search` starts searching from the beginning or a specified `evbuffer_ptr`, while `evbuffer_search_range` allows specifying both start and end pointers for the search range. Returns an `evbuffer_ptr` to the found location. ```c struct evbuffer_ptr evbuffer_search(struct evbuffer *buffer, const char *what, size_t len, const struct evbuffer_ptr *start); struct evbuffer_ptr evbuffer_search_range(struct evbuffer *buffer, const char *what, size_t len, const struct evbuffer_ptr *start, const struct evbuffer_ptr *end); ``` -------------------------------- ### DNS Configuration and Options Source: https://libevent.org/doc/dns_8h_source.html Functions for loading host files, parsing resolv.conf, setting options, and managing search domains. ```c int evdns_base_load_hosts(struct evdns_base *base, const char *hosts_fname); int evdns_base_resolv_conf_parse(struct evdns_base *base, int flags, const char *const filename); int evdns_base_set_option(struct evdns_base *base, const char *option, const char *val); void evdns_base_search_add(struct evdns_base *base, const char *domain); void evdns_base_search_clear(struct evdns_base *base); void evdns_base_clear_host_addresses(struct evdns_base *base); ``` -------------------------------- ### GET bufferevent_get_priority Source: https://libevent.org/doc/bufferevent_8h.html Retrieves the priority level of a socket bufferevent. ```APIDOC ## GET bufferevent_get_priority ### Description Returns the priority of a bufferevent. This is only supported for socket bufferevents. ### Method GET ### Parameters #### Request Body - **bufev** (struct bufferevent*) - Required - The bufferevent to examine. ### Response #### Success Response (200) - **priority** (int) - The priority level of the bufferevent. ``` -------------------------------- ### Initialize Asynchronous DNS Base (C) Source: https://libevent.org/doc/dns_8h.html Initializes the asynchronous DNS library, associating it with an event base. It handles platform-specific configuration loading for name servers. Parameters include the event base and flags to control initialization behavior. ```c struct evdns_base *evdns_base_new(struct event_base *_event_base, int _flags) ``` -------------------------------- ### GET bufferevent_getcb Source: https://libevent.org/doc/bufferevent_8h.html Retrieves the configured callbacks and arguments for a specific bufferevent. ```APIDOC ## GET bufferevent_getcb ### Description Retrieves the read, write, and event callbacks along with the user-provided argument for a bufferevent. ### Method GET ### Parameters #### Request Body - **bufev** (struct bufferevent*) - Required - The bufferevent to examine. - **readcb_ptr** (bufferevent_data_cb*) - Optional - Pointer to store the read callback. - **writecb_ptr** (bufferevent_data_cb*) - Optional - Pointer to store the write callback. - **eventcb_ptr** (bufferevent_event_cb*) - Optional - Pointer to store the event callback. - **cbarg_ptr** (void**) - Optional - Pointer to store the callback argument. ``` -------------------------------- ### GET /evhttp_uri_parse Source: https://libevent.org/doc/http_8h_source.html Parses a URI string into a structured object. ```APIDOC ## GET /evhttp_uri_parse ### Description Parses a source URI string and returns a structured evhttp_uri object. ### Method GET ### Endpoint /evhttp_uri_parse ### Parameters #### Query Parameters - **source_uri** (string) - Required - The URI string to parse. ### Response #### Success Response (200) - **uri** (struct evhttp_uri*) - The parsed URI structure. ### Response Example { "scheme": "http", "host": "example.com" } ``` -------------------------------- ### Configuration and Options Source: https://libevent.org/doc/dns_8h_source.html Functions for setting options, parsing configuration files, and loading hosts files. ```APIDOC ## evdns_base_set_option ### Description Sets a specific option for the DNS base. ### Method `evdns_base_set_option(struct evdns_base *base, const char *option, const char *val)` ### Parameters - **base** (struct evdns_base *) - The DNS base to configure. - **option** (const char *) - The name of the option to set. - **val** (const char *) - The value to set for the option. ### Response - **int** - 0 on success, -1 on failure. --- ## evdns_base_resolv_conf_parse ### Description Parses a resolv.conf file to configure nameservers and options for the DNS base. ### Method `evdns_base_resolv_conf_parse(struct evdns_base *base, int flags, const char *const filename)` ### Parameters - **base** (struct evdns_base *) - The DNS base to configure. - **flags** (int) - Flags to control parsing behavior (e.g., DNS_OPTION_NAMESERVERS). - **filename** (const char *const) - The path to the resolv.conf file. ### Response - **int** - 0 on success, -1 on failure. --- ## evdns_base_load_hosts ### Description Loads hostnames and IP addresses from a specified hosts file into the DNS base. ### Method `evdns_base_load_hosts(struct evdns_base *base, const char *hosts_fname)` ### Parameters - **base** (struct evdns_base *) - The DNS base to load hosts into. - **hosts_fname** (const char *) - The path to the hosts file. ### Response - **int** - 0 on success, -1 on failure. ``` -------------------------------- ### Initialize RPC Base and Connection Pool Source: https://libevent.org/doc/rpc_8h.html Functions to create and manage the RPC infrastructure. evrpc_init sets up the server-side RPC base, while evrpc_pool_new creates a client-side connection pool for dispatching requests. ```C struct evrpc_base *base = evrpc_init(server); struct evrpc_pool *pool = evrpc_pool_new(event_base); ``` -------------------------------- ### Get Requesting Address Source: https://libevent.org/doc/dns_8h.html Retrieves the network address of the client that made a DNS request. ```APIDOC ## evdns_server_request_get_requesting_addr ### Description Get the address that made a DNS request. ### Method N/A (Function Signature) ### Endpoint N/A ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example N/A ### Response #### Success Response (200) - **return value** (int) - 0 on success, -1 on error. #### Response Example N/A ``` -------------------------------- ### Bufferevent Get Base Source: https://libevent.org/doc/bufferevent_8h_source.html Function to retrieve the event base associated with a bufferevent. ```APIDOC ## Bufferevent Get Base ### Description Function to retrieve the event base associated with a bufferevent. ### Function #### `bufferevent_get_base` - **Method**: (Implicitly called, part of internal management) - **Description**: Returns the `event_base` used by a bufferevent. - **Parameters**: - `bev` (struct bufferevent *) - The bufferevent. - **Returns**: A pointer to the `struct event_base`. ``` -------------------------------- ### Create evconnlistener for TCP Connections Source: https://libevent.org/doc/listener_8h.html Allocates a new evconnlistener object to listen for incoming TCP connections. It can listen on a provided file descriptor or a specified address. The listener can be configured with various flags to control its behavior. ```c struct evconnlistener *evconnlistener_new(struct event_base *base, evconnlistener_cb cb, void *ptr, unsigned flags, int backlog, evutil_socket_t fd); struct evconnlistener *evconnlistener_new_bind(struct event_base *base, evconnlistener_cb cb, void *ptr, unsigned flags, int backlog, const struct sockaddr *sa, int socklen); ``` -------------------------------- ### GET /api/libevent/http_cmd_type Source: https://libevent.org/doc/globals_enum.html Describes the enumeration used for HTTP request methods within the Libevent HTTP server framework. ```APIDOC ## GET /api/libevent/http_cmd_type ### Description Defines the HTTP request methods (GET, POST, etc.) supported by the evhttp server framework. ### Method GET ### Endpoint /http.h/evhttp_cmd_type ### Parameters None ### Request Example N/A ### Response #### Success Response (200) - **EVHTTP_REQ_GET** (enum) - HTTP GET request - **EVHTTP_REQ_POST** (enum) - HTTP POST request - **EVHTTP_REQ_HEAD** (enum) - HTTP HEAD request #### Response Example { "enum": "evhttp_cmd_type", "values": ["EVHTTP_REQ_GET", "EVHTTP_REQ_POST", "EVHTTP_REQ_HEAD"] } ``` -------------------------------- ### HTTP Server Configuration with Libevent Source: https://libevent.org/doc/http_8h.html Functions for configuring an HTTP server. `evhttp_add_server_alias` adds an alias for the server, and `evhttp_add_virtual_host` associates a pattern with a specific virtual host. ```c int evhttp_add_server_alias(struct evhttp *http, const char *alias); int evhttp_add_virtual_host(struct evhttp *http, const char *pattern, struct evhttp *vhost); ``` -------------------------------- ### EVTAG Assignment and Get Operations Source: https://libevent.org/doc/rpc_8h.html Macros for assigning values to message members and retrieving them, with support for values of varying lengths. ```APIDOC ## EVTAG_ASSIGN ### Description Assigns a value to a member in the message. ### Method N/A (Macro definition) ### Endpoint N/A ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example N/A ### Response #### Success Response (200) - **void**: Operation successful. #### Response Example N/A --- ## EVTAG_ASSIGN_WITH_LEN ### Description Assigns a value of a specific length to a member in the message. ### Method N/A (Macro definition) ### Endpoint N/A ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example N/A ### Response #### Success Response (200) - **void**: Operation successful. #### Response Example N/A --- ## EVTAG_GET ### Description Returns the value for a member. The value is placed in the variable pointed to by `pvalue`. ### Method N/A (Macro definition) ### Endpoint N/A ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example N/A ### Response #### Success Response (200) - **int**: 0 on success, -1 otherwise. #### Response Example N/A --- ## EVTAG_GET_WITH_LEN ### Description Returns the value and its length for a member. The value is placed in `pvalue` and its length in `plen`. ### Method N/A (Macro definition) ### Endpoint N/A ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example N/A ### Response #### Success Response (200) - **int**: 0 on success, -1 otherwise. #### Response Example N/A ``` -------------------------------- ### Evconnlistener Functions Source: https://libevent.org/doc/globals_func_e.html Functions for creating and managing connection listeners, enabling servers to accept incoming connections. ```APIDOC ## Evconnlistener Functions ### Description Functions for creating and managing connection listeners to accept incoming network connections. ### Functions - `evconnlistener_disable()` - `evconnlistener_enable()` - `evconnlistener_free()` - `evconnlistener_get_base()` - `evconnlistener_get_fd()` - `evconnlistener_new()` - `evconnlistener_new_bind()` - `evconnlistener_set_cb()` - `evconnlistener_set_error_cb()` ### Header `listener.h` ``` -------------------------------- ### Bufferevent Max Read Size Source: https://libevent.org/doc/bufferevent_8h_source.html Function to get the maximum size for a single read operation on a bufferevent. ```APIDOC ## Bufferevent Max Read Size ### Description Function to get the maximum size for a single read operation on a bufferevent. ### Function #### `bufferevent_get_max_single_read` - **Method**: (Implicitly called, part of internal management) - **Description**: Gets the current size limit for a single read operation on a bufferevent. - **Parameters**: - `bev` (struct bufferevent *) - The bufferevent. - **Returns**: The maximum size for a single read operation. ``` -------------------------------- ### evhttp_new Source: https://libevent.org/doc/http_8h.html Creates a new HTTP server instance. An optional event base can be provided for receiving HTTP events. ```APIDOC ## evhttp_new ### Description Create a new HTTP server. ### Method (Implicitly a function call, not an HTTP method) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```c // Example usage (requires an event_base) struct event_base *base = event_base_new(); struct evhttp *http = evhttp_new(base); if (http) { // HTTP server created successfully // ... use http ... evhttp_free(http); } event_base_free(base); ``` ### Response #### Success Response - **struct evhttp ***: A pointer to a newly initialized evhttp server structure, or NULL on error. #### Response Example ```json { "example": "" } ``` ``` -------------------------------- ### event_base_get_signal_method Source: https://libevent.org/doc/event_8h.html Gets the kernel signal handling mechanism used by Libevent. Returns a string identifying the method. ```APIDOC ## GET /event_base_get_signal_method ### Description Gets the kernel signal handling mechanism used by Libevent. Returns a string identifying the method. ### Method GET ### Endpoint /event_base_get_signal_method ### Parameters #### Path Parameters - **_eb_** (const struct event_base *) - Required - The event base structure returned by event_base_new(). ### Response #### Success Response (200) - **signal_method** (const char *) - A string identifying the kernel signal handling mechanism (e.g., "signal", "kqueue_signal", "signalfd_signal"). ``` -------------------------------- ### evhttp_request_get_command Source: https://libevent.org/doc/http_8h_source.html Retrieves the HTTP command type (e.g., GET, POST) associated with an HTTP request. ```APIDOC ## evhttp_request_get_command ### Description Retrieves the HTTP command type (e.g., GET, POST) associated with an HTTP request. ### Method enum evhttp_cmd_type ### Endpoint N/A (Function) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```c struct evhttp_request *req = /* ... obtain request ... */; enum evhttp_cmd_type cmd = evhttp_request_get_command(req); if (cmd == EVHTTP_REQ_GET) { // It's a GET request } ``` ### Response #### Success Response (enum evhttp_cmd_type) Returns the enumerated type of the HTTP command. #### Response Example N/A ``` -------------------------------- ### Parse resolv.conf File (C) Source: https://libevent.org/doc/dns__compat_8h.html Parses a resolv.conf file to configure DNS settings. The 'flags' parameter controls which information is extracted. This function is deprecated and does not allow specifying an evdns_base. It returns various error codes on failure. ```c int evdns_resolv_conf_parse(int _flags_, const char *const _filename_) ``` -------------------------------- ### Accept Socket for HTTP Server (C) Source: https://libevent.org/doc/http_8h.html Makes an HTTP server accept incoming connections on a specified socket file descriptor. This is useful for scenarios like forking server instances or when a socket is passed via file descriptor passing, especially when the server lacks permissions for low-numbered ports. It can be called multiple times to listen on different sockets. Returns 0 on success and -1 on failure. ```c EVENT2_EXPORT_SYMBOL int evhttp_accept_socket | ( | struct evhttp * | _http_ , | | evutil_socket_t | _fd_ ) ``` -------------------------------- ### Event Information Retrieval Source: https://libevent.org/doc/event_8h_source.html Functions to get details about an event, such as its file descriptor, base, events, callback, and priority. ```APIDOC ## event_get_fd ### Description Retrieves the file descriptor associated with an event. ### Method N/A (Function Signature) ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```c const struct event *ev; // ... event is initialized ... evutil_socket_t fd = event_get_fd(ev); ``` ### Response #### Success Response (200) Returns the file descriptor associated with the event. #### Response Example ```c evutil_socket_t // The file descriptor ``` ## event_get_base ### Description Retrieves the event base associated with an event. ### Method N/A (Function Signature) ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```c const struct event *ev; // ... event is initialized ... struct event_base *base = event_get_base(ev); ``` ### Response #### Success Response (200) Returns the event base associated with the event. #### Response Example ```c struct event_base * // Pointer to the event base ``` ## event_get_events ### Description Retrieves the event flags associated with an event. ### Method N/A (Function Signature) ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```c const struct event *ev; // ... event is initialized ... short events = event_get_events(ev); ``` ### Response #### Success Response (200) Returns the event flags. #### Response Example ```c short // The event flags ``` ## event_get_callback ### Description Retrieves the callback function associated with an event. ### Method N/A (Function Signature) ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```c const struct event *ev; // ... event is initialized ... event_callback_fn callback = event_get_callback(ev); ``` ### Response #### Success Response (200) Returns the callback function pointer. #### Response Example ```c event_callback_fn // Pointer to the callback function ``` ## event_get_callback_arg ### Description Retrieves the callback argument associated with an event. ### Method N/A (Function Signature) ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```c const struct event *ev; // ... event is initialized ... void *arg = event_get_callback_arg(ev); ``` ### Response #### Success Response (200) Returns the callback argument pointer. #### Response Example ```c void * // Pointer to the callback argument ``` ## event_get_priority ### Description Retrieves the priority level of an event. ### Method N/A (Function Signature) ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```c const struct event *ev; // ... event is initialized ... int priority = event_get_priority(ev); ``` ### Response #### Success Response (200) Returns the priority level of the event. #### Response Example ```c int // The priority level ``` ## event_get_assignment ### Description Retrieves all the assignment details of an event (base, fd, events, callback, and argument). ### Method N/A (Function Signature) ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```c const struct event *event; struct event_base *base_out; evutil_socket_t fd_out; short events_out; event_callback_fn callback_out; void *arg_out; // ... event is initialized ... event_get_assignment(event, &base_out, &fd_out, &events_out, &callback_out, &arg_out); ``` ### Response #### Success Response (200) This function does not return a value. The output parameters are populated with the event's assignment details. #### Response Example ```c void ``` ``` -------------------------------- ### EVTAG Array Operations Source: https://libevent.org/doc/rpc_8h.html Macros for managing array members within RPC messages, including adding, getting, and retrieving the length of array elements. ```APIDOC ## EVTAG_ARRAY_ADD ### Description Allocates a new entry in an array member and returns it. ### Method N/A (Macro definition) ### Endpoint N/A ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example N/A ### Response #### Success Response (200) - **Pointer to new array entry**: The newly allocated entry in the array. #### Response Example N/A --- ## EVTAG_ARRAY_ADD_VALUE ### Description Adds a value to an array member. ### Method N/A (Macro definition) ### Endpoint N/A ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example N/A ### Response #### Success Response (200) - **void**: Operation successful. #### Response Example N/A --- ## EVTAG_ARRAY_GET ### Description Gets a variable at the specified offset from an array member. ### Method N/A (Macro definition) ### Endpoint N/A ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example N/A ### Response #### Success Response (200) - **void**: Operation successful. The value is placed in `pvalue`. #### Response Example N/A --- ## EVTAG_ARRAY_LEN ### Description Returns the number of entries in an array member. ### Method N/A (Macro definition) ### Endpoint N/A ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example N/A ### Response #### Success Response (200) - **size_t**: The number of entries in the array. #### Response Example N/A ``` -------------------------------- ### Configure Windows Nameservers (C) Source: https://libevent.org/doc/dns_8h.html Obtains nameserver information using the Windows API. It attempts to configure nameservers based on platform settings, preferring GetNetworkParams and falling back to the registry. Returns 0 on success, -1 on error. ```c int evdns_base_config_windows_nameservers(struct evdns_base *base); ``` -------------------------------- ### Initialize and Configure DNS Resolver Source: https://libevent.org/doc/dns__compat_8h_source.html Functions for initializing the asynchronous DNS library, parsing resolv.conf files, and managing nameserver lists. These functions prepare the environment for DNS resolution operations. ```C int evdns_init(void); int evdns_resolv_conf_parse(int flags, const char *const filename); int evdns_nameserver_add(unsigned long int address); int evdns_nameserver_ip_add(const char *ip_as_string); ``` -------------------------------- ### Get evconnlistener Event Base Source: https://libevent.org/doc/listener_8h_source.html Returns the event_base associated with an evconnlistener. This allows access to the event loop that the listener is integrated with. ```c EVENT2_EXPORT_SYMBOL struct event_base * evconnlistener_get_base(struct evconnlistener *lev) ``` -------------------------------- ### Get evconnlistener File Descriptor Source: https://libevent.org/doc/listener_8h_source.html Returns the socket file descriptor that an evconnlistener is currently listening on. This can be useful for inspecting the underlying socket. ```c EVENT2_EXPORT_SYMBOL evutil_socket_t evconnlistener_get_fd(struct evconnlistener *lev) ``` -------------------------------- ### HTTP Server Configuration Source: https://libevent.org/doc/http_8h.html Functions for configuring the evhttp server, including URI callbacks and allowed methods. ```APIDOC ## POST evhttp_set_cb ### Description Registers a callback function for a specific URI path on the HTTP server. ### Method C Function ### Parameters #### Request Body - **http** (evhttp*) - Required - The evhttp server object - **path** (const char*) - Required - The URI path to match - **cb** (function pointer) - Required - Callback function to execute - **cb_arg** (void*) - Optional - User-defined argument ### Response #### Success Response (200) - **int** - Returns 0 on success, -1 on failure ``` -------------------------------- ### Libevent Get Connection from Request Source: https://libevent.org/doc/http_8h_source.html Retrieves the `evhttp_connection` associated with an `evhttp_request`. This is useful for accessing connection-specific properties or context from a request. ```c struct evhttp_connection *evhttp_request_get_connection(struct evhttp_request *req); ``` -------------------------------- ### Bufferevent Socket Operations Source: https://libevent.org/doc/bufferevent_8h_source.html Functions related to socket operations with bufferevents, including connecting, getting file descriptors, and setting file descriptors. ```APIDOC ## Bufferevent Socket Operations ### Description Functions related to socket operations with bufferevents, including connecting, getting file descriptors, and setting file descriptors. ### Functions #### `bufferevent_getfd` - **Method**: (Implicitly called, part of internal management) - **Description**: Returns the file descriptor associated with a bufferevent. - **Returns**: The socket file descriptor, or -1 if no file descriptor is associated. #### `bufferevent_setfd` - **Method**: (Implicitly called, part of internal management) - **Description**: Changes the file descriptor on which the bufferevent operates. - **Parameters**: - `bufev` (struct bufferevent *) - The bufferevent to modify. - `fd` (evutil_socket_t) - The new file descriptor. - **Returns**: 0 on success, -1 on error. #### `bufferevent_socket_connect_hostname` - **Method**: (Implicitly called, part of internal management) - **Description**: Resolves a hostname and connects the bufferevent to it. - **Parameters**: - `bufev` (struct bufferevent *) - The bufferevent to connect. - `evdns_base` (struct evdns_base *) - The DNS base for hostname resolution. - `family` (int) - The address family (e.g., `AF_INET`, `AF_INET6`). - `hostname` (const char *) - The hostname to resolve and connect to. - `port` (int) - The port number. - **Returns**: 0 on success, -1 on error. ``` -------------------------------- ### evhttp_send_reply_start Source: https://libevent.org/doc/http_8h.html Initiates a reply that uses Transfer-Encoding chunked, allowing for streaming of the reply data. ```APIDOC ## POST /evhttp/send/reply_start ### Description Initiates a reply that uses Transfer-Encoding chunked. This allows the caller to stream the reply back to the client and is useful when not all reply data is immediately available or when sending very large replies. Data chunks should be supplied with evhttp_send_reply_chunk() and the reply completed with evhttp_send_reply_end(). ### Method POST ### Endpoint /evhttp/send/reply_start ### Parameters #### Request Body - **req** (struct evhttp_request *) - Required - The HTTP request object. - **code** (int) - Required - The HTTP response code to send. - **reason** (string) - Required - A brief message to send with the response code. ### Request Example ```json { "req": "", "code": 200, "reason": "Streaming data" } ``` ### Response #### Success Response (200) - **status** (string) - Indicates the operation was successful. #### Response Example ```json { "status": "success" } ``` ``` -------------------------------- ### Manage SSL Dirty Shutdown Flags Source: https://libevent.org/doc/bufferevent__ssl_8h.html Get or set the BUFFEREVENT_SSL_DIRTY_SHUTDOWN flag for SSL bufferevents. Note that these functions are deprecated in favor of the generic bufferevent_ssl_get_flags and bufferevent_ssl_set_flags functions. ```C int bufferevent_mbedtls_get_allow_dirty_shutdown(struct bufferevent *bev); void bufferevent_mbedtls_set_allow_dirty_shutdown(struct bufferevent *bev, int allow_dirty_shutdown); int bufferevent_openssl_get_allow_dirty_shutdown(struct bufferevent *bev); void bufferevent_openssl_set_allow_dirty_shutdown(struct bufferevent *bev, int allow_dirty_shutdown); ``` -------------------------------- ### Define evbuffer configuration and callback macros Source: https://libevent.org/doc/buffer_8h.html Commonly used macros for configuring evbuffer behavior, including file segment flags and callback state management. ```c #define EVBUF_FS_DISABLE_LOCKING 0x08 #define EVBUF_FS_DISABLE_SENDFILE 0x04 #define EVBUFFER_CB_ENABLED 1 #define EVBUFFER_FLAG_DRAINS_TO_FD 1 ``` -------------------------------- ### Initiate Socket Connections with Bufferevent Source: https://libevent.org/doc/bufferevent_8h_source.html Functions to launch socket-based connections, including hostname resolution with DNS hints for bufferevent objects. ```c int bufferevent_socket_connect(struct bufferevent *bufev, const struct sockaddr *addr, int socklen); int bufferevent_socket_connect_hostname_hints(struct bufferevent *bufev, struct evdns_base *evdns_base, const struct evutil_addrinfo *hints_in, const char *hostname, int port); ``` -------------------------------- ### Libevent Get Event Base from Connection Source: https://libevent.org/doc/http_8h_source.html Retrieves the `event_base` associated with an `evhttp_connection`. This provides access to the event loop managing the connection. ```c struct event_base *evhttp_connection_get_base(struct evhttp_connection *req); ``` -------------------------------- ### EVDNS Option and Configuration Source: https://libevent.org/doc/dns_8h_source.html Functions for setting generic options, parsing resolv.conf files, and loading host files. This allows for fine-grained control over DNS resolution behavior. ```c #define DNS_OPTION_SEARCH 1 #define DNS_OPTION_NAMESERVERS 2 #define DNS_OPTION_MISC 4 #define DNS_OPTION_HOSTSFILE 8 #define DNS_OPTIONS_ALL (DNS_OPTION_SEARCH | DNS_OPTION_NAMESERVERS | DNS_OPTION_MISC | DNS_OPTION_HOSTSFILE | 0) int evdns_base_set_option(struct evdns_base *base, const char *option, const char *val); int evdns_base_resolv_conf_parse(struct evdns_base *base, int flags, const char *const filename); int evdns_base_load_hosts(struct evdns_base *base, const char *hosts_fname); void evdns_base_search_clear(struct evdns_base *base); ``` -------------------------------- ### Libevent Get Bufferevent from Connection Source: https://libevent.org/doc/http_8h_source.html Retrieves the `bufferevent` associated with an `evhttp_connection`. This allows for direct manipulation or inspection of the underlying event buffer. ```c struct bufferevent* evhttp_connection_get_bufferevent(struct evhttp_connection *evcon); ``` -------------------------------- ### evconnlistener Configuration Macros Source: https://libevent.org/doc/listener_8h.html Flags used to configure the behavior of an evconnlistener, such as socket reuse, thread safety, and address family binding. ```APIDOC ## Macros for evconnlistener Configuration ### Description These macros define the bitwise flags used when initializing an evconnlistener to control socket behavior and listener properties. ### Available Flags - **LEV_OPT_CLOSE_ON_EXEC** (1u<<2) - Set close-on-exec flag on the listener socket. - **LEV_OPT_CLOSE_ON_FREE** (1u<<1) - Close the underlying socket when the listener is freed. - **LEV_OPT_LEAVE_SOCKETS_BLOCKING** (1u<<0) - Do not force incoming sockets to be non-blocking. - **LEV_OPT_REUSEABLE** (1u<<3) - Enable socket reuse (SO_REUSEADDR). - **LEV_OPT_THREADSAFE** (1u<<4) - Enable internal locking for thread-safe access. - **LEV_OPT_BIND_IPV6ONLY** (1u<<8) - Restrict listener to IPv6 only. - **LEV_OPT_REUSEABLE_PORT** (1u<<7) - Enable SO_REUSEPORT for multi-process/thread load balancing. ``` -------------------------------- ### Get Bufferevent SSL Flags (C) Source: https://libevent.org/doc/bufferevent__ssl_8h_source.html Retrieves the current flags associated with an SSL-enabled bufferevent. This function is useful for inspecting the SSL configuration of a bufferevent. ```c #include EVENT2_EXPORT_SYMBOL ev_uint64_t bufferevent_ssl_get_flags(struct bufferevent *bev); ``` -------------------------------- ### Configure evhttp Connection Settings (C) Source: https://libevent.org/doc/http_8h.html These functions allow for the configuration of various settings for an evhttp connection. This includes setting extended method comparison callbacks, DNS family hints, connection flags, retry delays, local IP addresses and ports, maximum body and header sizes, and timeouts (both general and specific for reading and writing). ```c void evhttp_connection_set_ext_method_cmp (struct evhttp_connection *evcon, evhttp_ext_method_cb cmp); void evhttp_connection_set_family (struct evhttp_connection *evcon, int family); int evhttp_connection_set_flags (struct evhttp_connection *evcon, int flags); void evhttp_connection_set_initial_retry_tv (struct evhttp_connection *evcon, const struct timeval *tv); void evhttp_connection_set_local_address (struct evhttp_connection *evcon, const char *address); void evhttp_connection_set_local_port (struct evhttp_connection *evcon, ev_uint16_t port); void evhttp_connection_set_max_body_size (struct evhttp_connection *evcon, ev_ssize_t new_max_body_size); void evhttp_connection_set_max_headers_size (struct evhttp_connection *evcon, ev_ssize_t new_max_headers_size); void evhttp_connection_set_read_timeout_tv (struct evhttp_connection *evcon, const struct timeval *tv); void evhttp_connection_set_retries (struct evhttp_connection *evcon, int retry_max); void evhttp_connection_set_timeout (struct evhttp_connection *evcon, int timeout); void evhttp_connection_set_timeout_tv (struct evhttp_connection *evcon, const struct timeval *tv); void evhttp_connection_set_write_timeout_tv (struct evhttp_connection *evcon, const struct timeval *tv); ``` -------------------------------- ### Get Nameserver File Descriptor (C) Source: https://libevent.org/doc/dns_8h.html Retrieves the file descriptor (fd) associated with a specific configured nameserver by its index. Returns the fd on success, or -1 if the index is out of bounds. ```c int evdns_base_get_nameserver_fd(struct evdns_base *base, int idx); ``` -------------------------------- ### Get Event Callback Function (C) Source: https://libevent.org/doc/event_8h_source.html Retrieves the callback function that is assigned to a specific event. This function is essential for understanding which code will be executed when the event becomes active. ```c event_callback_fn event_get_callback(const struct event *ev) ``` -------------------------------- ### Macros Source: https://libevent.org/doc/bufferevent__ssl_8h.html Defines constants used for controlling SSL bufferevent behavior. ```APIDOC ## Macros ### Description Constants for controlling SSL bufferevent operations. ### Code ```c #define BUFFEREVENT_SSL_BATCH_WRITE 2 #define BUFFEREVENT_SSL_DIRTY_SHUTDOWN 1 ``` ``` -------------------------------- ### Get Underlying Bufferevent - C Source: https://libevent.org/doc/bufferevent_8h_source.html Returns the underlying bufferevent associated with a given bufferevent. This is useful when dealing with wrapper bufferevents (e.g., filters) to access the original bufferevent. ```c struct bufferevent *bufferevent_get_underlying(struct bufferevent *bufev); ``` -------------------------------- ### Evbuffer Macros Source: https://libevent.org/doc/buffer_8h.html This section lists and explains the macros available for configuring and controlling `evbuffer` behavior, such as flags for file segments and callback enablement. ```APIDOC ## Macros ### `EVBUF_FS_CLOSE_ON_FREE` Flag for creating `evbuffer_file_segment`: If this flag is set, then when the `evbuffer_file_segment` is freed and no longer in use by any `evbuffer`, the underlying fd is closed. ### `EVBUF_FS_DISABLE_LOCKING` Flag for creating `evbuffer_file_segment`: Do not allocate a lock for this segment. ### `EVBUF_FS_DISABLE_MMAP` Flag for creating `evbuffer_file_segment`: Disable memory-map based implementations. ### `EVBUF_FS_DISABLE_SENDFILE` Flag for creating `evbuffer_file_segment`: Disable direct fd-to-fd implementations (sendfile). ### `EVBUFFER_CB_ENABLED` If this flag is not set, then a callback is temporarily disabled, and should not be invoked. ### `EVBUFFER_FLAG_DRAINS_TO_FD` If this flag is set, then we will not use `evbuffer_peek()`, `evbuffer_remove()`, `evbuffer_remove_buffer()`, and so on to read bytes from this buffer: we'll only take bytes out of this buffer by writing them to the network (as with `evbuffer_write_atmost`), by removing them without observing them (as with `evbuffer_drain`), or by copying them all out at once (as with `evbuffer_add_buffer`). ``` -------------------------------- ### Bufferevent SSL Flags Source: https://libevent.org/doc/bufferevent__ssl_8h_source.html Functions to get, set, and clear flags for bufferevent SSL operations. These flags control aspects like dirty shutdown and batch writes. ```APIDOC ## Bufferevent SSL Flags API ### Description Provides functions to manage flags associated with SSL operations on bufferevents. These flags can modify the behavior of SSL handshakes and data transfers. ### Functions #### `bufferevent_ssl_get_flags` * **Description**: Retrieves the current flags set for a given bufferevent. * **Method**: N/A (Function Signature) * **Endpoint**: N/A * **Parameters**: None * **Request Body**: None * **Success Response**: `ev_uint64_t` - The current flags. * **Response Example**: N/A #### `bufferevent_ssl_set_flags` * **Description**: Sets specific flags for a given bufferevent. Existing flags are preserved unless overwritten by the new flags. * **Method**: N/A (Function Signature) * **Endpoint**: N/A * **Parameters**: * `bev` (struct bufferevent*) - The bufferevent to modify. * `flags` (ev_uint64_t) - The flags to set. * **Request Body**: None * **Success Response**: `ev_uint64_t` - The updated flags. * **Response Example**: N/A #### `bufferevent_ssl_clear_flags` * **Description**: Clears specific flags from a given bufferevent. * **Method**: N/A (Function Signature) * **Endpoint**: N/A * **Parameters**: * `bev` (struct bufferevent*) - The bufferevent to modify. * `flags` (ev_uint64_t) - The flags to clear. * **Request Body**: None * **Success Response**: `ev_uint64_t` - The updated flags. * **Response Example**: N/A ### Constants * `BUFFEREVENT_SSL_DIRTY_SHUTDOWN`: Flag to allow a dirty SSL shutdown. * `BUFFEREVENT_SSL_BATCH_WRITE`: Flag to enable batch writing for SSL data. ``` -------------------------------- ### Nameserver Configuration Source: https://libevent.org/doc/dns_8h_source.html Functions for adding, counting, and managing nameservers. ```APIDOC ## evdns_base_nameserver_add ### Description Adds a nameserver to the DNS base using an unsigned long integer representation of the IP address. ### Method `evdns_base_nameserver_add(struct evdns_base *base, unsigned long int address)` ### Parameters - **base** (struct evdns_base *) - The DNS base to modify. - **address** (unsigned long int) - The IP address of the nameserver. ### Response - **int** - 0 on success, -1 on failure. --- ## evdns_base_count_nameservers ### Description Returns the number of nameservers currently configured in the DNS base. ### Method `evdns_base_count_nameservers(struct evdns_base *base)` ### Parameters - **base** (struct evdns_base *) - The DNS base to query. ### Response - **int** - The number of configured nameservers. --- ## evdns_base_nameserver_ip_add ### Description Adds a nameserver to the DNS base using a string representation of the IP address. ### Method `evdns_base_nameserver_ip_add(struct evdns_base *base, const char *ip_as_string)` ### Parameters - **base** (struct evdns_base *) - The DNS base to modify. - **ip_as_string** (const char *) - The IP address of the nameserver as a string. ### Response - **int** - 0 on success, -1 on failure. --- ## evdns_base_nameserver_sockaddr_add ### Description Adds a nameserver to the DNS base using a sockaddr structure. ### Method `evdns_base_nameserver_sockaddr_add(struct evdns_base *base, const struct sockaddr *sa, ev_socklen_t len, unsigned flags)` ### Parameters - **base** (struct evdns_base *) - The DNS base to modify. - **sa** (const struct sockaddr *) - Pointer to the sockaddr structure representing the nameserver. - **len** (ev_socklen_t) - The length of the sockaddr structure. - **flags** (unsigned) - Flags to control the addition of the nameserver. ### Response - **int** - 0 on success, -1 on failure. ```