Switch to new coding style
This commit is contained in:
+10
-4
@@ -1,10 +1,16 @@
|
||||
/*
|
||||
* <aisl/aisl.h>
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (c) 2017-2019 by Löwenware Ltd.
|
||||
* Copyright (c) 2017-2019 by Löwenware Ltd
|
||||
* Please, refer LICENSE file for legal information
|
||||
*
|
||||
* Project homepage: https://lowenware.com/aisl/
|
||||
******************************************************************************/
|
||||
|
||||
/**
|
||||
* @file aisl/aisl.h
|
||||
* @author Ilja Kartašov <ik@lowenware.com>
|
||||
* @brief Meta header file of AISL
|
||||
*
|
||||
* @see https://lowenware.com/aisl/
|
||||
*/
|
||||
|
||||
#ifndef AISL_H_17EF1616_A00F_49C9_92B6_273AB13BF279
|
||||
|
||||
+25
-19
@@ -1,10 +1,16 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (c) 2017-2019 by Löwenware Ltd
|
||||
* Please, refer LICENSE file for legal information
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/**
|
||||
* @file aisl/client.h
|
||||
* @author Ilja Kartašov <ik@lowenware.com>
|
||||
* @brief Declarations of #AislCLient functions
|
||||
*
|
||||
* Copyright (c) 2017-2019 by Löwenware Ltd.
|
||||
*
|
||||
* Project homepage: https://lowenware.com/aisl/
|
||||
*
|
||||
* @see https://lowenware.com/aisl/
|
||||
*/
|
||||
|
||||
#ifndef AISL_CLIENT_H_A6C37DCF_2183_4F22_A5A0_668311757A08
|
||||
@@ -14,50 +20,50 @@
|
||||
|
||||
|
||||
/**
|
||||
* @brief Gets #aisl_server_t instance associated with client.
|
||||
* @param client an #aisl_client_t instance pointer.
|
||||
* @return an associated #aisl_server_t pointer.
|
||||
* @brief Gets #AislServer instance associated with client.
|
||||
* @param client an #AislClient instance pointer.
|
||||
* @return an associated #AislServer pointer.
|
||||
*/
|
||||
aisl_server_t
|
||||
aisl_client_get_server(aisl_client_t client);
|
||||
AislServer
|
||||
aisl_client_get_server(AislClient client);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Gets security connection status.
|
||||
* @param client an #aisl_client_t instance pointer.
|
||||
* @param client an #AislClient instance pointer.
|
||||
* @return true if SSL is enabled and false if disabled.
|
||||
*/
|
||||
bool
|
||||
aisl_client_is_secure(aisl_client_t client);
|
||||
aisl_client_is_secure(AislClient client);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Gets client's connection state.
|
||||
* @param client an #aisl_client_t instance pointer.
|
||||
* @param client an #AislClient instance pointer.
|
||||
* @return true if client is online and false if is offline.
|
||||
*/
|
||||
bool
|
||||
aisl_client_is_online(aisl_client_t client);
|
||||
aisl_client_is_online(AislClient client);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Forcefully closes client's connection.
|
||||
* @param client an #aisl_client_t instance pointer.
|
||||
* @param client an #AislClient instance pointer.
|
||||
*/
|
||||
void
|
||||
aisl_client_disconnect(aisl_client_t client);
|
||||
aisl_client_disconnect(AislClient client);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Gets HTTP protocol version.
|
||||
* @param client an #aisl_client_t instance pointer.
|
||||
* @param client an #AislClient instance pointer.
|
||||
* @return HTTP protocol version
|
||||
*/
|
||||
aisl_http_version_t
|
||||
aisl_client_get_http_version(aisl_client_t client);
|
||||
AislHttpVersion
|
||||
aisl_client_get_http_version(AislClient client);
|
||||
|
||||
|
||||
void
|
||||
aisl_client_get_address( aisl_client_t client, struct sockaddr_in * address);
|
||||
aisl_client_get_address(AislClient client, struct sockaddr_in *address);
|
||||
|
||||
#endif /* !AISL_CLIENT_H */
|
||||
|
||||
+40
-44
@@ -1,10 +1,16 @@
|
||||
/*
|
||||
* <aisl/config.h>
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (c) 2017-2019 by Löwenware Ltd.
|
||||
* Copyright (c) 2017-2019 by Löwenware Ltd
|
||||
* Please, refer LICENSE file for legal information
|
||||
*
|
||||
* Project homepage: https://lowenware.com/aisl/
|
||||
******************************************************************************/
|
||||
|
||||
/**
|
||||
* @file aisl/config.h
|
||||
* @author Ilja Kartašov <ik@lowenware.com>
|
||||
* @brief Declarations of AISL configuration structures
|
||||
*
|
||||
* @see https://lowenware.com/aisl/
|
||||
*/
|
||||
|
||||
#ifndef AISL_CONFIG_H_DB67A89B_5CAF_4A5F_AEB1_6DB9F84827D6
|
||||
@@ -12,59 +18,49 @@
|
||||
|
||||
#include <aisl/types.h>
|
||||
|
||||
#define AISL_CFG_DEFAULT \
|
||||
{ \
|
||||
.callback = NULL \
|
||||
, .p_ctx = NULL \
|
||||
, .srv = NULL \
|
||||
, .ssl = NULL \
|
||||
, .srv_cnt = 0 \
|
||||
, .ssl_cnt = 0 \
|
||||
, .client_spool_size = 32 \
|
||||
, .initial_buffer_size = 16536 \
|
||||
, .client_accept_limit = 1024 \
|
||||
, .client_silence_timeout = 30 \
|
||||
#define AISL_CFG_DEFAULT { \
|
||||
.callback = NULL \
|
||||
, .p_ctx = NULL \
|
||||
, .srv = NULL \
|
||||
, .ssl = NULL \
|
||||
, .srv_cnt = 0 \
|
||||
, .ssl_cnt = 0 \
|
||||
, .client_spool_size = 32 \
|
||||
, .initial_buffer_size = 16536 \
|
||||
, .client_accept_limit = 1024 \
|
||||
, .client_silence_timeout = 30 \
|
||||
} \
|
||||
|
||||
|
||||
struct aisl_cfg_srv
|
||||
{
|
||||
const char * host;
|
||||
uint16_t port;
|
||||
bool secure;
|
||||
struct aisl_cfg_srv {
|
||||
const char * host;
|
||||
uint16_t port;
|
||||
bool secure;
|
||||
};
|
||||
|
||||
typedef struct aisl_cfg_srv * aisl_cfg_srv_t;
|
||||
|
||||
|
||||
struct aisl_cfg_ssl
|
||||
{
|
||||
const char * host;
|
||||
const char * key_file;
|
||||
const char * crt_file;
|
||||
struct aisl_cfg_ssl {
|
||||
const char * host;
|
||||
const char * key_file;
|
||||
const char * crt_file;
|
||||
};
|
||||
|
||||
typedef struct aisl_cfg_ssl * aisl_cfg_ssl_t;
|
||||
|
||||
|
||||
struct aisl_cfg
|
||||
{
|
||||
/* event handlers */
|
||||
aisl_callback_t callback;
|
||||
void * p_ctx;
|
||||
/* event handlers */
|
||||
AislCallback callback;
|
||||
void *p_ctx;
|
||||
|
||||
aisl_cfg_srv_t srv;
|
||||
aisl_cfg_ssl_t ssl;
|
||||
struct aisl_cfg_srv *srv;
|
||||
struct aisl_cfg_ssl *ssl;
|
||||
|
||||
int srv_cnt;
|
||||
int ssl_cnt;
|
||||
int srv_cnt;
|
||||
int ssl_cnt;
|
||||
|
||||
int client_spool_size;
|
||||
int initial_buffer_size;
|
||||
int client_accept_limit;
|
||||
int client_silence_timeout;
|
||||
int client_spool_size;
|
||||
int initial_buffer_size;
|
||||
int client_accept_limit;
|
||||
int client_silence_timeout;
|
||||
};
|
||||
|
||||
typedef struct aisl_cfg * aisl_cfg_t;
|
||||
|
||||
#endif /* !AISL_CONFIG_H */
|
||||
|
||||
+24
-17
@@ -1,10 +1,17 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (c) 2017-2019 by Löwenware Ltd
|
||||
* Please, refer LICENSE file for legal information
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/**
|
||||
* @file aisl/instance.h
|
||||
* @author Ilja Kartašov <ik@lowenware.com>
|
||||
* @brief Declarations of #AislInstance functions
|
||||
*
|
||||
* Copyright (c) 2017-2019 by Löwenware Ltd.
|
||||
*
|
||||
* Project homepage: https://lowenware.com/aisl/
|
||||
*
|
||||
* @see https://lowenware.com/aisl/
|
||||
|
||||
*/
|
||||
|
||||
#ifndef AISL_INSTANCE_H_60576F41_454C_4189_B91A_F40501132230
|
||||
@@ -21,39 +28,39 @@
|
||||
* @brief Allocates new AISL instance.
|
||||
*
|
||||
* @param cfg a pointer to #aisl_cfg_t structure.
|
||||
* @return an #aisl_t instance pointer.
|
||||
* @return an #AislInstance instance pointer.
|
||||
*/
|
||||
aisl_t
|
||||
aisl_new( aisl_cfg_t cfg );
|
||||
AislInstance
|
||||
aisl_new(const struct aisl_cfg *cfg);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Frees previously allocated pointer of AISL instance.
|
||||
* @param instance a pointer to #aisl_t instance.
|
||||
* @param instance a pointer to #AislInstance instance.
|
||||
*/
|
||||
void
|
||||
aisl_free( aisl_t instance );
|
||||
aisl_free(AislInstance instance);
|
||||
|
||||
|
||||
/**
|
||||
* @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.
|
||||
* @param instance a pointer to #AislInstance instance.
|
||||
* @return #AislStatus code.
|
||||
*/
|
||||
aisl_status_t
|
||||
aisl_run_cycle( aisl_t instance );
|
||||
AislStatus
|
||||
aisl_run_cycle(AislInstance 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 instance a pointer to #AislInstance instance.
|
||||
* @param usec a number of miliseconds to wait for any data on sockets.
|
||||
* @return #aisl_status_t code.
|
||||
* @return #AislStatus code.
|
||||
*/
|
||||
aisl_status_t
|
||||
aisl_sleep( aisl_t instance, uint32_t usec );
|
||||
AislStatus
|
||||
aisl_sleep(AislInstance instance, uint32_t usec);
|
||||
|
||||
|
||||
#endif /* !AISL_INSTANCE_H */
|
||||
|
||||
+19
-13
@@ -1,10 +1,16 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (c) 2017-2019 by Löwenware Ltd
|
||||
* Please, refer LICENSE file for legal information
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/**
|
||||
* @file aisl/server.h
|
||||
* @author Ilja Kartašov <ik@lowenware.com>
|
||||
* @brief Declarations of #AislServer functions
|
||||
*
|
||||
* Copyright (c) 2017-2019 by Löwenware Ltd.
|
||||
*
|
||||
* Project homepage: https://lowenware.com/aisl/
|
||||
*
|
||||
* @see https://lowenware.com/aisl/
|
||||
*/
|
||||
|
||||
#ifndef AISL_SERVER_H_CC564608_7A05_4B31_9E7E_32750BC60768
|
||||
@@ -15,28 +21,28 @@
|
||||
|
||||
/**
|
||||
* @brief Function to get appropriate AISL instance pointer from server pointer.
|
||||
* @param server an #aisl_server_t pointer.
|
||||
* @return an #aisl_t instance pointer.
|
||||
* @param server an #AislServer pointer.
|
||||
* @return an #AislInstance instance pointer.
|
||||
*/
|
||||
aisl_t
|
||||
aisl_server_get_instance( aisl_server_t server );
|
||||
AislInstance
|
||||
aisl_server_get_instance(AislServer server);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Copies server listen address information to sockaddr_in structure.
|
||||
* @param server an #aisl_server_t pointer.
|
||||
* @param server an #AislServer pointer.
|
||||
* @param address a pointer to sockaddr_in structure.
|
||||
*/
|
||||
void
|
||||
aisl_server_get_address( aisl_server_t server, struct sockaddr_in * address);
|
||||
aisl_server_get_address(AislServer server, struct sockaddr_in *address);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Function to get on and off status of SSL for the #aisl_server_t.
|
||||
* @param server an #aisl_server_t pointer.
|
||||
* @brief Function to get on and off status of SSL for the #AislServer.
|
||||
* @param server an #AislServer pointer.
|
||||
* @return a boolean value representing SSL enabled/disabled state.
|
||||
*/
|
||||
bool
|
||||
aisl_server_get_ssl( aisl_server_t server );
|
||||
aisl_server_get_ssl(AislServer server);
|
||||
|
||||
#endif /* !AISL_SERVER_H */
|
||||
|
||||
+44
-48
@@ -1,12 +1,17 @@
|
||||
/*
|
||||
* <aisl/stream.h>
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (c) 2017-2019 by Löwenware Ltd.
|
||||
* Copyright (c) 2017-2019 by Löwenware Ltd
|
||||
* Please, refer LICENSE file for legal information
|
||||
*
|
||||
* Project homepage: https://lowenware.com/aisl/
|
||||
*
|
||||
*/
|
||||
******************************************************************************/
|
||||
|
||||
/**
|
||||
* @file aisl/stream.h
|
||||
* @author Ilja Kartašov <ik@lowenware.com>
|
||||
* @brief Declarations of #AislStream functions
|
||||
*
|
||||
* @see https://lowenware.com/aisl/
|
||||
*/
|
||||
#ifndef AISL_STREAM_H_4D8EB622_3CE0_4F1B_AC1F_B27CCB5C2EDC
|
||||
#define AISL_STREAM_H_4D8EB622_3CE0_4F1B_AC1F_B27CCB5C2EDC
|
||||
|
||||
@@ -15,96 +20,87 @@
|
||||
#include <aisl/types.h>
|
||||
|
||||
|
||||
|
||||
/* Stream helpers */
|
||||
|
||||
bool
|
||||
aisl_is_secure( aisl_stream_t stream );
|
||||
aisl_is_secure(AislStream stream);
|
||||
|
||||
|
||||
aisl_client_t
|
||||
aisl_get_client( aisl_stream_t stream );
|
||||
AislClient
|
||||
aisl_get_client(AislStream stream);
|
||||
|
||||
|
||||
aisl_server_t
|
||||
aisl_get_server( aisl_stream_t stream );
|
||||
AislServer
|
||||
aisl_get_server(AislStream stream);
|
||||
|
||||
|
||||
aisl_http_version_t
|
||||
aisl_get_http_version( aisl_stream_t stream );
|
||||
AislHttpVersion
|
||||
aisl_get_http_version(AislStream stream);
|
||||
|
||||
|
||||
aisl_t
|
||||
aisl_stream_get_instance( aisl_stream_t s );
|
||||
AislInstance
|
||||
aisl_stream_get_instance(AislStream s);
|
||||
|
||||
|
||||
/* Context functions */
|
||||
|
||||
void *
|
||||
aisl_get_context( aisl_stream_t stream );
|
||||
aisl_get_context(AislStream stream);
|
||||
|
||||
|
||||
void
|
||||
aisl_set_context( aisl_stream_t stream, void * context );
|
||||
aisl_set_context(AislStream stream, void *context);
|
||||
|
||||
|
||||
/* Stream control functions */
|
||||
|
||||
aisl_status_t
|
||||
aisl_flush( aisl_stream_t stream );
|
||||
AislStatus
|
||||
aisl_flush(AislStream stream);
|
||||
|
||||
|
||||
void
|
||||
aisl_reject( aisl_stream_t stream );
|
||||
aisl_reject(AislStream stream);
|
||||
|
||||
|
||||
/* Response functions */
|
||||
|
||||
aisl_status_t
|
||||
aisl_response( aisl_stream_t stream,
|
||||
aisl_http_response_t status_code,
|
||||
uint64_t content_length );
|
||||
AislStatus
|
||||
aisl_response(AislStream stream,
|
||||
AislHttpResponse status_code,
|
||||
uint64_t content_length);
|
||||
|
||||
|
||||
int
|
||||
aisl_header( aisl_stream_t stream, const char *key, const char *value );
|
||||
aisl_header(AislStream stream, const char *key, const char *value );
|
||||
|
||||
|
||||
int
|
||||
aisl_header_printf( aisl_stream_t stream,
|
||||
const char * key,
|
||||
const char * format,
|
||||
... );
|
||||
aisl_header_printf(AislStream stream,
|
||||
const char *key,
|
||||
const char *format,
|
||||
... );
|
||||
|
||||
|
||||
int
|
||||
aisl_header_vprintf( aisl_stream_t stream,
|
||||
const char * key,
|
||||
const char * format,
|
||||
va_list args );
|
||||
aisl_header_vprintf(AislStream stream,
|
||||
const char *key,
|
||||
const char *format,
|
||||
va_list args );
|
||||
|
||||
|
||||
int
|
||||
aisl_printf( aisl_stream_t stream, const char * format, ... );
|
||||
aisl_printf(AislStream stream, const char *format, ...);
|
||||
|
||||
|
||||
int
|
||||
aisl_vprintf( aisl_stream_t stream, const char * format, va_list args );
|
||||
aisl_vprintf(AislStream stream, const char *format, va_list args);
|
||||
|
||||
|
||||
int
|
||||
aisl_write( aisl_stream_t stream, const char * data, int d_len );
|
||||
aisl_write(AislStream stream, const char *data, int d_len);
|
||||
|
||||
|
||||
int
|
||||
aisl_puts( const char * str_data, aisl_stream_t stream );
|
||||
aisl_puts(const char *str_data, AislStream stream);
|
||||
|
||||
|
||||
void
|
||||
aisl_set_output_event(aisl_stream_t stream, bool value);
|
||||
aisl_set_output_event(AislStream stream, bool value);
|
||||
|
||||
|
||||
bool
|
||||
aisl_get_output_event(aisl_stream_t stream);
|
||||
aisl_get_output_event(AislStream stream);
|
||||
|
||||
#endif /* !AISL_STREAM_H */
|
||||
|
||||
+128
-146
@@ -1,10 +1,16 @@
|
||||
/*
|
||||
* <aisl/types.h>
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (c) 2017-2019 by Löwenware Ltd.
|
||||
* Copyright (c) 2017-2019 by Löwenware Ltd
|
||||
* Please, refer LICENSE file for legal information
|
||||
*
|
||||
* Project homepage: https://lowenware.com/aisl/
|
||||
******************************************************************************/
|
||||
|
||||
/**
|
||||
* @file aisl/types.h
|
||||
* @author Ilja Kartašov <ik@lowenware.com>
|
||||
* @brief Declarations of AISL types
|
||||
*
|
||||
* @see https://lowenware.com/aisl/
|
||||
*/
|
||||
|
||||
#ifndef AISL_TYPES_H_86A9DBA7_C0E6_4CF4_8A64_DAAD4A81031B
|
||||
@@ -20,206 +26,182 @@
|
||||
|
||||
#define AISL_AUTO_LENGTH (~0)
|
||||
|
||||
/* type casts */
|
||||
#define AISL_CALLBACK(x) ((aisl_callback_t) x)
|
||||
/** type casts */
|
||||
#define AISL_CALLBACK(x) ((AislCallback) x)
|
||||
|
||||
|
||||
/* AISL Instance */
|
||||
typedef struct aisl * aisl_t;
|
||||
/** AISL Instance */
|
||||
typedef struct aisl_instance * AislInstance;
|
||||
|
||||
/* HTTP(s) Server */
|
||||
typedef struct aisl_server * aisl_server_t;
|
||||
/** HTTP(s) Server */
|
||||
typedef struct aisl_server * AislServer;
|
||||
|
||||
/* HTTP(s) Client */
|
||||
typedef struct aisl_client * aisl_client_t;
|
||||
/** HTTP(s) Client */
|
||||
typedef struct aisl_client * AislClient;
|
||||
|
||||
/* Server<->Client Stream */
|
||||
typedef struct aisl_stream * aisl_stream_t;
|
||||
/** Server<->Client Stream */
|
||||
typedef struct aisl_stream * AislStream;
|
||||
|
||||
|
||||
/* status return codes */
|
||||
typedef enum
|
||||
{
|
||||
AISL_INPUT_ERROR = -4
|
||||
, AISL_EXTCALL_ERROR = -3
|
||||
, AISL_SYSCALL_ERROR = -2
|
||||
, AISL_MALLOC_ERROR = -1
|
||||
/** status return codes */
|
||||
typedef enum {
|
||||
AISL_INPUT_ERROR = -4
|
||||
, AISL_EXTCALL_ERROR = -3
|
||||
, AISL_SYSCALL_ERROR = -2
|
||||
, AISL_MALLOC_ERROR = -1
|
||||
|
||||
, AISL_SUCCESS = 0
|
||||
, AISL_IDLE = 1
|
||||
|
||||
} aisl_status_t;
|
||||
, AISL_SUCCESS = 0
|
||||
, AISL_IDLE = 1
|
||||
} AislStatus;
|
||||
|
||||
#ifndef WITHOUT_STRINGIFIERS
|
||||
|
||||
const char *
|
||||
aisl_status_to_string(aisl_status_t status);
|
||||
aisl_status_to_string(AislStatus status);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/* Generic HTTP Enumerations */
|
||||
|
||||
typedef enum
|
||||
{
|
||||
AISL_HTTP_0_9 = 0x0009
|
||||
, AISL_HTTP_1_0 = 0x0100
|
||||
, AISL_HTTP_1_1 = 0x0101
|
||||
, AISL_HTTP_2_0 = 0x0200
|
||||
|
||||
} aisl_http_version_t;
|
||||
/** Generic HTTP Enumerations */
|
||||
typedef enum {
|
||||
AISL_HTTP_0_9 = 0x0009
|
||||
, AISL_HTTP_1_0 = 0x0100
|
||||
, AISL_HTTP_1_1 = 0x0101
|
||||
, AISL_HTTP_2_0 = 0x0200
|
||||
} AislHttpVersion;
|
||||
|
||||
|
||||
const char *
|
||||
aisl_http_version_to_string( aisl_http_version_t version );
|
||||
aisl_http_version_to_string(AislHttpVersion version);
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
AISL_HTTP_METHOD_UNKNOWN
|
||||
, AISL_HTTP_GET
|
||||
, AISL_HTTP_PUT
|
||||
, AISL_HTTP_POST
|
||||
, AISL_HTTP_HEAD
|
||||
, AISL_HTTP_TRACE
|
||||
, AISL_HTTP_DELETE
|
||||
, AISL_HTTP_OPTIONS
|
||||
, AISL_HTTP_CONNECT
|
||||
|
||||
, AISL_HTTP_PRI
|
||||
|
||||
} aisl_http_method_t;
|
||||
typedef enum {
|
||||
AISL_HTTP_METHOD_UNKNOWN
|
||||
, AISL_HTTP_GET
|
||||
, AISL_HTTP_PUT
|
||||
, AISL_HTTP_POST
|
||||
, AISL_HTTP_HEAD
|
||||
, AISL_HTTP_TRACE
|
||||
, AISL_HTTP_DELETE
|
||||
, AISL_HTTP_OPTIONS
|
||||
, AISL_HTTP_CONNECT
|
||||
, AISL_HTTP_PRI
|
||||
} AislHttpMethod;
|
||||
|
||||
|
||||
const char *
|
||||
aisl_http_method_to_string( aisl_http_method_t method );
|
||||
aisl_http_method_to_string( AislHttpMethod method );
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
AISL_HTTP_CONTINUE = 100
|
||||
, AISL_HTTP_SWITCHING_PROTOCOLS
|
||||
typedef enum {
|
||||
AISL_HTTP_CONTINUE = 100
|
||||
, AISL_HTTP_SWITCHING_PROTOCOLS
|
||||
|
||||
, AISL_HTTP_OK = 200
|
||||
, AISL_HTTP_CREATED
|
||||
, AISL_HTTP_ACCEPTED
|
||||
, AISL_HTTP_NON_AUTHORITATIVE_INFORMATION
|
||||
, AISL_HTTP_NO_CONTENT
|
||||
, AISL_HTTP_RESET_CONTENT
|
||||
, AISL_HTTP_PARTIAL_CONTENT
|
||||
, AISL_HTTP_OK = 200
|
||||
, AISL_HTTP_CREATED
|
||||
, AISL_HTTP_ACCEPTED
|
||||
, AISL_HTTP_NON_AUTHORITATIVE_INFORMATION
|
||||
, AISL_HTTP_NO_CONTENT
|
||||
, AISL_HTTP_RESET_CONTENT
|
||||
, AISL_HTTP_PARTIAL_CONTENT
|
||||
|
||||
, AISL_HTTP_MULTIPLE_CHOICES = 300
|
||||
, AISL_HTTP_MOVED_PERMANENTLY
|
||||
, AISL_HTTP_FOUND
|
||||
, AISL_HTTP_SEE_OTHER
|
||||
, AISL_HTTP_NOT_MODIFIED
|
||||
, AISL_HTTP_USE_PROXY
|
||||
, AISL_HTTP_UNUSED
|
||||
, AISL_HTTP_TEMPORARY_REDIRECT
|
||||
, AISL_HTTP_MULTIPLE_CHOICES = 300
|
||||
, AISL_HTTP_MOVED_PERMANENTLY
|
||||
, AISL_HTTP_FOUND
|
||||
, AISL_HTTP_SEE_OTHER
|
||||
, AISL_HTTP_NOT_MODIFIED
|
||||
, AISL_HTTP_USE_PROXY
|
||||
, AISL_HTTP_UNUSED
|
||||
, AISL_HTTP_TEMPORARY_REDIRECT
|
||||
|
||||
, AISL_HTTP_BAD_REQUEST = 400
|
||||
, AISL_HTTP_UNAUTHORIZED
|
||||
, AISL_HTTP_PAYMENT_REQUIRED
|
||||
, AISL_HTTP_FORBIDDEN
|
||||
, AISL_HTTP_NOT_FOUND
|
||||
, AISL_HTTP_METHOD_NOT_ALLOWED
|
||||
, AISL_HTTP_NOT_ACCEPTABLE
|
||||
, AISL_HTTP_PROXY_AUTHENTICATION_REQUIRED
|
||||
, AISL_HTTP_REQUEST_TIMEOUT
|
||||
, AISL_HTTP_CONFLICT
|
||||
, AISL_HTTP_GONE
|
||||
, AISL_HTTP_LENGTH_REQUIRED
|
||||
, AISL_HTTP_PRECONDITION_FAILED
|
||||
, AISL_HTTP_REQUEST_ENTITY_TOO_LARGE
|
||||
, AISL_HTTP_REQUEST_URI_TOO_LONG
|
||||
, AISL_HTTP_UNSUPPORTED_MEDIA_TYPE
|
||||
, AISL_HTTP_REQUESTED_RANGE_NOT_SATISFIABLE
|
||||
, AISL_HTTP_EXPECTATION_FAILED
|
||||
, AISL_HTTP_BAD_REQUEST = 400
|
||||
, AISL_HTTP_UNAUTHORIZED
|
||||
, AISL_HTTP_PAYMENT_REQUIRED
|
||||
, AISL_HTTP_FORBIDDEN
|
||||
, AISL_HTTP_NOT_FOUND
|
||||
, AISL_HTTP_METHOD_NOT_ALLOWED
|
||||
, AISL_HTTP_NOT_ACCEPTABLE
|
||||
, AISL_HTTP_PROXY_AUTHENTICATION_REQUIRED
|
||||
, AISL_HTTP_REQUEST_TIMEOUT
|
||||
, AISL_HTTP_CONFLICT
|
||||
, AISL_HTTP_GONE
|
||||
, AISL_HTTP_LENGTH_REQUIRED
|
||||
, AISL_HTTP_PRECONDITION_FAILED
|
||||
, AISL_HTTP_REQUEST_ENTITY_TOO_LARGE
|
||||
, AISL_HTTP_REQUEST_URI_TOO_LONG
|
||||
, AISL_HTTP_UNSUPPORTED_MEDIA_TYPE
|
||||
, AISL_HTTP_REQUESTED_RANGE_NOT_SATISFIABLE
|
||||
, AISL_HTTP_EXPECTATION_FAILED
|
||||
|
||||
, AISL_HTTP_INTERNAL_SERVER_ERROR = 500
|
||||
, AISL_HTTP_NOT_IMPLEMENTED
|
||||
, AISL_HTTP_BAD_GATEWAY
|
||||
, AISL_HTTP_SERVICE_UNAVAILABLE
|
||||
, AISL_HTTP_GATEWAY_TIMEOUT
|
||||
, AISL_HTTP_VERSION_NOT_SUPPORTED
|
||||
|
||||
} aisl_http_response_t;
|
||||
, AISL_HTTP_INTERNAL_SERVER_ERROR = 500
|
||||
, AISL_HTTP_NOT_IMPLEMENTED
|
||||
, AISL_HTTP_BAD_GATEWAY
|
||||
, AISL_HTTP_SERVICE_UNAVAILABLE
|
||||
, AISL_HTTP_GATEWAY_TIMEOUT
|
||||
, AISL_HTTP_VERSION_NOT_SUPPORTED
|
||||
} AislHttpResponse;
|
||||
|
||||
|
||||
const char *
|
||||
aisl_http_response_to_string( aisl_http_response_t code );
|
||||
aisl_http_response_to_string( AislHttpResponse code );
|
||||
|
||||
|
||||
/* Events */
|
||||
/** Codes of AISL events */
|
||||
typedef enum {
|
||||
AISL_EVENT_SERVER_READY = 100
|
||||
, AISL_EVENT_SERVER_ERROR = 190
|
||||
|
||||
typedef enum
|
||||
{
|
||||
AISL_EVENT_SERVER_OPEN = 100
|
||||
, AISL_EVENT_SERVER_ERROR = 190
|
||||
, AISL_EVENT_CLIENT_CONNECT = 200
|
||||
, AISL_EVENT_CLIENT_DISCONNECT = 210
|
||||
|
||||
, AISL_EVENT_CLIENT_CONNECT = 200
|
||||
, AISL_EVENT_CLIENT_DISCONNECT = 210
|
||||
|
||||
, AISL_EVENT_STREAM_OPEN = 300
|
||||
, AISL_EVENT_STREAM_HEADER = 310
|
||||
, AISL_EVENT_STREAM_INPUT = 320
|
||||
, AISL_EVENT_STREAM_REQUEST = 330
|
||||
, AISL_EVENT_STREAM_OUTPUT = 340
|
||||
, AISL_EVENT_STREAM_CLOSE = 350
|
||||
, AISL_EVENT_STREAM_ERROR = 390
|
||||
|
||||
} aisl_evt_code_t;
|
||||
, AISL_EVENT_STREAM_OPEN = 300
|
||||
, AISL_EVENT_STREAM_HEADER = 310
|
||||
, AISL_EVENT_STREAM_INPUT = 320
|
||||
, AISL_EVENT_STREAM_REQUEST = 330
|
||||
, AISL_EVENT_STREAM_OUTPUT = 340
|
||||
, AISL_EVENT_STREAM_CLOSE = 350
|
||||
, AISL_EVENT_STREAM_ERROR = 390
|
||||
} AislEvent;
|
||||
|
||||
|
||||
struct aisl_evt
|
||||
{
|
||||
void * source;
|
||||
aisl_evt_code_t code;
|
||||
aisl_status_t status;
|
||||
struct aisl_evt {
|
||||
void *source;
|
||||
AislEvent code;
|
||||
AislStatus status;
|
||||
};
|
||||
|
||||
typedef struct aisl_evt * aisl_evt_t;
|
||||
|
||||
|
||||
/* void type event callback */
|
||||
typedef void
|
||||
(* aisl_callback_t) (aisl_evt_t const evt, void * p_ctx);
|
||||
(* AislCallback) (const struct aisl_evt *evt, void *ctx);
|
||||
|
||||
|
||||
struct aisl_evt_stream_open
|
||||
{
|
||||
struct aisl_evt evt;
|
||||
const char * path;
|
||||
const char * query;
|
||||
aisl_http_method_t http_method;
|
||||
struct aisl_evt_open {
|
||||
struct aisl_evt evt;
|
||||
const char *path;
|
||||
const char *query;
|
||||
AislHttpMethod http_method;
|
||||
};
|
||||
|
||||
typedef struct aisl_evt_stream_open * aisl_evt_stream_open_t;
|
||||
|
||||
|
||||
struct aisl_evt_stream_header
|
||||
{
|
||||
struct aisl_evt evt;
|
||||
const char * key;
|
||||
const char * value;
|
||||
struct aisl_evt_header {
|
||||
struct aisl_evt evt;
|
||||
const char *key;
|
||||
const char *value;
|
||||
};
|
||||
|
||||
typedef struct aisl_evt_stream_header * aisl_evt_stream_header_t;
|
||||
|
||||
|
||||
struct aisl_evt_stream_input
|
||||
{
|
||||
struct aisl_evt evt;
|
||||
const char * data;
|
||||
int32_t size;
|
||||
struct aisl_evt_input {
|
||||
struct aisl_evt evt;
|
||||
const char *data;
|
||||
int32_t size;
|
||||
};
|
||||
|
||||
typedef struct aisl_evt_stream_input * aisl_evt_stream_input_t;
|
||||
|
||||
#ifndef WITHOUT_STRINGIFIERS
|
||||
|
||||
const char *
|
||||
aisl_evt_code_to_string( aisl_evt_code_t evt_code );
|
||||
aisl_event_to_string(AislEvent evt);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user