libasyncd
|
ad_server header file More...
Go to the source code of this file.
Data Structures | |
struct | ad_server_s |
Server info container. More... | |
struct | ad_conn_s |
Connection structure. More... | |
Macros | |
#define | AD_SERVER_OPTIONS |
Server option names and default values. | |
#define | AD_EVENT_INIT (1) |
Event types. | |
#define | AD_EVENT_READ (1 << 1) |
#define | AD_EVENT_WRITE (1 << 2) |
#define | AD_EVENT_CLOSE (1 << 3) |
#define | AD_EVENT_TIMEOUT (1 << 4) |
#define | AD_EVENT_SHUTDOWN (1 << 5) |
#define | AD_NUM_USERDATA (2) |
Defaults. | |
Typedefs | |
typedef struct ad_server_s | ad_server_t |
typedef struct ad_conn_s | ad_conn_t |
typedef enum ad_cb_return_e | ad_cb_return_t |
typedef struct ad_hook_s | ad_hook_t |
typedef int(* | ad_callback )(short event, ad_conn_t *conn, void *userdata) |
User callback(hook) prototype. | |
typedef void(* | ad_userdata_free_cb )(ad_conn_t *conn, void *userdata) |
Enumerations | |
enum | ad_log_e { AD_LOG_DISABLE = 0, AD_LOG_ERROR, AD_LOG_WARN, AD_LOG_INFO, AD_LOG_DEBUG, AD_LOG_DEBUG2 } |
These flags are used for ad_log_level();. More... | |
enum | ad_cb_return_e { AD_OK = 0, AD_TAKEOVER, AD_DONE, AD_CLOSE } |
Return values of user callback. More... | |
Functions | |
enum ad_log_e | ad_log_level (enum ad_log_e log_level) |
Set debug output level. | |
ad_server_t * | ad_server_new (void) |
Create a server object. | |
int | ad_server_start (ad_server_t *server) |
Start server. | |
void | ad_server_stop (ad_server_t *server) |
Stop server. | |
void | ad_server_free (ad_server_t *server) |
Release server object and all the resources. | |
void | ad_server_global_free (void) |
Clean up all the global objects. | |
void | ad_server_set_option (ad_server_t *server, const char *key, const char *value) |
Set server option. | |
char * | ad_server_get_option (ad_server_t *server, const char *key) |
Retrieve server option. | |
int | ad_server_get_option_int (ad_server_t *server, const char *key) |
Retrieve server option in integer format. | |
SSL_CTX * | ad_server_get_ssl_ctx (ad_server_t *server) |
Get OpenSSL SSL_CTX object. | |
qhashtbl_t * | ad_server_get_stats (ad_server_t *server, const char *key) |
Return internal statistic counter map. | |
void | ad_server_register_hook (ad_server_t *server, ad_callback cb, void *userdata) |
Register user hook. | |
void | ad_server_register_hook_on_method (ad_server_t *server, const char *method, ad_callback cb, void *userdata) |
Register user hook on method name. | |
void * | ad_conn_set_userdata (ad_conn_t *conn, const void *userdata, ad_userdata_free_cb free_cb) |
Attach userdata into the connection. | |
void * | ad_conn_get_userdata (ad_conn_t *conn) |
Get userdata attached in the connection. | |
void * | ad_conn_set_extra (ad_conn_t *conn, const void *extra, ad_userdata_free_cb free_cb) |
Set extra userdata into the connection. | |
void * | ad_conn_get_extra (ad_conn_t *conn) |
Get extra userdata attached in this connection. | |
char * | ad_conn_set_method (ad_conn_t *conn, char *method) |
Set method name on this connection. | |
ad_server header file
Definition in file ad_server.h.
#define AD_SERVER_OPTIONS |
Server option names and default values.
Definition at line 75 of file ad_server.h.
#define AD_EVENT_INIT (1) |
#define AD_EVENT_READ (1 << 1) |
Call on read
Definition at line 132 of file ad_server.h.
#define AD_EVENT_WRITE (1 << 2) |
Call on write.
Definition at line 133 of file ad_server.h.
#define AD_EVENT_CLOSE (1 << 3) |
Call before closing.
Definition at line 134 of file ad_server.h.
#define AD_EVENT_TIMEOUT (1 << 4) |
Timeout indicator, this flag will be set with AD_EVENT_CLOSE.
Definition at line 135 of file ad_server.h.
#define AD_EVENT_SHUTDOWN (1 << 5) |
Shutdown indicator, this flag will be set with AD_EVENT_CLOSE.
Definition at line 136 of file ad_server.h.
#define AD_NUM_USERDATA (2) |
Defaults.
Number of userdata. Currently 0 is for userdata, 1 is for extra.
Definition at line 141 of file ad_server.h.
typedef struct ad_server_s ad_server_t |
Definition at line 51 of file ad_server.h.
Definition at line 52 of file ad_server.h.
typedef enum ad_cb_return_e ad_cb_return_t |
Definition at line 53 of file ad_server.h.
typedef struct ad_hook_s ad_hook_t |
Definition at line 54 of file ad_server.h.
typedef int(* ad_callback)(short event, ad_conn_t *conn, void *userdata) |
User callback(hook) prototype.
Definition at line 111 of file ad_server.h.
typedef void(* ad_userdata_free_cb)(ad_conn_t *conn, void *userdata) |
Definition at line 112 of file ad_server.h.
enum ad_log_e |
These flags are used for ad_log_level();.
Definition at line 59 of file ad_server.h.
enum ad_cb_return_e |
Return values of user callback.
Definition at line 117 of file ad_server.h.
Set debug output level.
debug_level | debug output level. 0 to disable. |
Definition at line 93 of file ad_server.c.
ad_server_t* ad_server_new | ( | void | ) |
Create a server object.
Definition at line 102 of file ad_server.c.
int ad_server_start | ( | ad_server_t * | server | ) |
void ad_server_stop | ( | ad_server_t * | server | ) |
Stop server.
This call is be used to stop a server from different thread.
Definition at line 250 of file ad_server.c.
void ad_server_free | ( | ad_server_t * | server | ) |
Release server object and all the resources.
Definition at line 266 of file ad_server.c.
void ad_server_global_free | ( | void | ) |
Clean up all the global objects.
This will make memory-leak checkers happy. There are globally shared resources in libevent and openssl and it's usually not a problem since they don't grow but having these can confuse some debugging tools into thinking as memory leak. If you need to make sure that libasyncd has released all internal library-global data structures, call this.
Definition at line 315 of file ad_server.c.
void ad_server_set_option | ( | ad_server_t * | server, |
const char * | key, | ||
const char * | value | ||
) |
char* ad_server_get_option | ( | ad_server_t * | server, |
const char * | key | ||
) |
Retrieve server option.
Definition at line 340 of file ad_server.c.
int ad_server_get_option_int | ( | ad_server_t * | server, |
const char * | key | ||
) |
Retrieve server option in integer format.
Definition at line 347 of file ad_server.c.
SSL_CTX* ad_server_get_ssl_ctx | ( | ad_server_t * | server | ) |
Get OpenSSL SSL_CTX object.
Definition at line 370 of file ad_server.c.
qhashtbl_t* ad_server_get_stats | ( | ad_server_t * | server, |
const char * | key | ||
) |
Return internal statistic counter map.
Definition at line 377 of file ad_server.c.
void ad_server_register_hook | ( | ad_server_t * | server, |
ad_callback | cb, | ||
void * | userdata | ||
) |
Register user hook.
Definition at line 384 of file ad_server.c.
void ad_server_register_hook_on_method | ( | ad_server_t * | server, |
const char * | method, | ||
ad_callback | cb, | ||
void * | userdata | ||
) |
Register user hook on method name.
Definition at line 391 of file ad_server.c.
void* ad_conn_set_userdata | ( | ad_conn_t * | conn, |
const void * | userdata, | ||
ad_userdata_free_cb | free_cb | ||
) |
Attach userdata into the connection.
Definition at line 406 of file ad_server.c.
void* ad_conn_get_userdata | ( | ad_conn_t * | conn | ) |
Get userdata attached in the connection.
Definition at line 415 of file ad_server.c.
void* ad_conn_set_extra | ( | ad_conn_t * | conn, |
const void * | extra, | ||
ad_userdata_free_cb | free_cb | ||
) |
Set extra userdata into the connection.
Definition at line 429 of file ad_server.c.
void* ad_conn_get_extra | ( | ad_conn_t * | conn | ) |
Get extra userdata attached in this connection.
Definition at line 436 of file ad_server.c.
char* ad_conn_set_method | ( | ad_conn_t * | conn, |
char * | method | ||
) |
Set method name on this connection.
Once the method name is set, hooks registered by ad_server_register_hook_on_method() will be called if method name is matching as registered.
Definition at line 448 of file ad_server.c.