Documentation and code base update

This commit is contained in:
2019-03-10 21:53:40 +01:00
parent 3efc86a341
commit 0b05984f85
19 changed files with 5116 additions and 701 deletions
+46 -2
View File
@@ -1,5 +1,5 @@
/*
* <aisl/server.h>
/**
* @file aisl/client.h
*
* Copyright (c) 2017-2019 by Löwenware Ltd.
*
@@ -12,4 +12,48 @@
#include <aisl/types.h>
/**
* @brief Gets #aisl_server_t instance associated with client.
* @param client an #aisl_client_t instance pointer.
* @return an associated #aisl_server_t pointer.
*/
aisl_server_t
aisl_client_get_server(aisl_client_t client);
/**
* @brief Gets security connection status.
* @param client an #aisl_client_t instance pointer.
* @return true if SSL is enabled and false if disabled.
*/
bool
aisl_client_is_secure(aisl_client_t client);
/**
* @brief Gets client's connection state.
* @param client an #aisl_client_t instance pointer.
* @return true if client is online and false if is offline.
*/
bool
aisl_client_is_online(aisl_client_t client);
/**
* @brief Forcefully closes client's connection.
* @param client an #aisl_client_t instance pointer.
*/
void
aisl_client_close(aisl_client_t client);
/**
* @brief Gets HTTP protocol version.
* @param client an #aisl_client_t instance pointer.
* @return HTTP protocol version
*/
aisl_http_version_t
aisl_client_get_http_version(aisl_client_t client);
#endif /* !AISL_CLIENT_H */
+5 -4
View File
@@ -15,12 +15,13 @@
struct aisl_config
{
uint32_t servers_spool_size;
uint32_t clients_spool_size;
uint32_t server_spool_size;
uint32_t client_spool_size;
uint32_t ssl_spool_size;
uint32_t callbacks_spool_size;
uint32_t callback_spool_size;
uint32_t initial_buffer_size;
uint32_t clients_accept_limit;
uint32_t client_accept_limit;
uint32_t client_silence_timeout;
};
typedef struct aisl_config * aisl_config_t;
+89 -15
View File
@@ -1,5 +1,5 @@
/*
* <aisl/instance.h>
/**
* @file aisl/instance.h
*
* Copyright (c) 2017-2019 by Löwenware Ltd.
*
@@ -17,32 +17,70 @@
/* Initialization functions */
/**
* @brief Allocates new AISL instance.
*
* @param config a pointer to #aisl_config structure.
* @return an #aisl_t instance pointer.
*/
aisl_t
aisl_new( aisl_config_t config );
/**
* @brief Frees previously allocated pointer of AISL instance.
* @param instance a pointer to #aisl_t instance.
*/
void
aisl_free( aisl_t instance );
/**
* @brief Allocates and registers HTTP server instance.
* @param instance a pointer to #aisl_t instance.
* @param address a null-terminated ip or hostname string.
* @param port a number of port to listen.
* @return a pointer representing HTTP server.
*/
aisl_server_t
aisl_listen( aisl_t instance, const char * address, uint16_t port );
#ifndef AISL_WITHOUT_SSL
/**
* @brief Sets pair of SSL certificate and key for domain name.
* @param instance a pointer to #aisl_t instance.
* @param domain a null-terminated string with domain name.
* @param key_file a null-terminated string with path to private SSL key file.
* @param crt_file a null-terminated string with path to SSL certificate file.
* @return #aisl_status_t code.
*/
aisl_status_t
aisl_set_ssl( aisl_t instance,
const char * hostname,
const char * domain,
const char * key_file,
const char * crt_file );
#endif
/* Callbacks and Events functions */
/**
* @brief Registers a callback for event and its source.
* If source is NULL, then callback will be executed for all events of specified
* type.
*
* Typical sources are:
* - #aisl_server_t,
* - #aisl_client_t,
* - #aisl_stream_t;
*
* @param instance a pointer to #aisl_t instance.
* @param source a pointer to an event source.
* @param event a code of event.
* @param callback a pointer to function that will be triggered on event.
* @return #aisl_status_t code.
*/
aisl_status_t
aisl_set_callback( aisl_t instance,
void * source,
@@ -50,33 +88,69 @@ aisl_set_callback( aisl_t instance,
aisl_callback_t callback );
aisl_status_t
/**
* @brief Raises event from source.
* @param instance a pointer to #aisl_t instance.
* @param source a pointer to an event source.
* @param event a code of event.
* @param ... a list of arguments specific for event.
* @return true if event was handled by at least one callback, false otherwise.
*/
bool
aisl_raise( aisl_t instance, void * source, aisl_event_t event, ... );
aisl_status_t
/**
* @brief Raises event from source.
* @param instance a pointer to #aisl_t instance.
* @param source a pointer to an event source.
* @param event a code of event.
* @param args a list of arguments specific for event.
* @return true if event was handled by at least one callback, false otherwise.
*/
bool
aisl_raise_vl( aisl_t instance,
void * source,
aisl_event_t event,
va_list args );
/**
* @brief Unsets callbacks for specified source.
* @param instance a pointer to #aisl_t instance.
* @param source a pointer to an event source.
*/
void
aisl_unset_callback_for( aisl_t instance, void * source );
aisl_unset_callbacks_for( aisl_t instance, void * source );
/* Control functions */
/**
* @brief A core function doing all the library routines.
* Designed to be called inside application main loop
* @param instance a pointer to #aisl_t instance.
* @return #aisl_status_t code.
*/
aisl_status_t
aisl_run_cycle( aisl_t instance );
const char *
aisl_get_error( aisl_t instance );
/**
* @brief Function to sleep CPU if nothing to do.
* Calls select on all the opened sockets inside.
* @param instance a pointer to #aisl_t instance.
* @param usec a number of miliseconds to wait for any data on sockets.
* @return #aisl_status_t code.
*/
aisl_status_t
aisl_sleep( aisl_t instance, uint32_t usec );
/**
* @brief Get last error message.
* @param instance a pointer to #aisl_t instance.
* @return a null-terminated string with error message.
*/
const char *
aisl_get_error( aisl_t instance );
#endif /* !AISL_INSTANCE_H */
+38 -6
View File
@@ -1,5 +1,5 @@
/*
* <aisl/server.h>
/**
* @file aisl/server.h
*
* Copyright (c) 2017-2019 by Löwenware Ltd.
*
@@ -10,14 +10,46 @@
#ifndef AISL_SERVER_H_CC564608_7A05_4B31_9E7E_32750BC60768
#define AISL_SERVER_H_CC564608_7A05_4B31_9E7E_32750BC60768
#include <arpa/inet.h>
#include <aisl/types.h>
#ifdef AISL_WITH_SSL
aisl_status_t
/**
* @brief Function to get appropriate AISL instance pointer from server pointer.
* @param server an #aisl_server_t pointer.
* @return an #aisl_t instance pointer.
*/
aisl_t
aisl_server_get_instance( aisl_server_t server );
/**
* @brief Copies server listen address information to sockaddr_in structure.
* @param server an #aisl_server_t pointer.
* @param address a pointer to sockaddr_in structure.
*/
void
aisl_server_get_address( aisl_server_t server, struct sockaddr_in * address);
#ifndef AISL_WITHOUT_SSL
/**
* @brief Function to switch on and off SSL for the #aisl_server_t.
* @param server an #aisl_server_t pointer.
* @param value a boolean value representing SSL enabled/disabled state.
*/
void
aisl_server_set_ssl( aisl_server_t server, bool value );
/**
* @brief Function to get on and off status of SSL for the #aisl_server_t.
* @param server an #aisl_server_t pointer.
* @return a boolean value representing SSL enabled/disabled state.
*/
bool
aisl_server_get_ssl( aisl_server_t server );
#endif
#endif /* !AISL_SERVER_H */
+3
View File
@@ -196,6 +196,9 @@ aisl_event_to_string( aisl_event_t event );
/* real type event callbacks */
typedef bool
(*aisl_on_source_event_t)( void * source );
typedef bool
(*aisl_on_server_open_t)( aisl_server_t server );