Skip to content
Snippets Groups Projects
Commit 6c6a3d3c authored by David Brooks's avatar David Brooks Committed by Andy Green
Browse files

improve callback prototypes to use single definition


Not sure all compilers can hack this, but give it a try

Signed-off-by: default avatarDavid Brooks <dave@bcs.co.nz>
Signed-off-by: default avatarAndy Green <andy@warmcat.com>
--
parent ee2213d3
Branches
Tags
No related merge requests found
...@@ -227,9 +227,8 @@ struct libwebsocket; ...@@ -227,9 +227,8 @@ struct libwebsocket;
struct libwebsocket_context; struct libwebsocket_context;
struct libwebsocket_extension; struct libwebsocket_extension;
/* document the generic callback (it's a fake prototype under this) */
/** /**
* callback() - User server actions * callback_function() - User server actions
* @context: Websockets context * @context: Websockets context
* @wsi: Opaque websocket instance pointer * @wsi: Opaque websocket instance pointer
* @reason: The reason for the call * @reason: The reason for the call
...@@ -424,9 +423,14 @@ LWS_EXTERN int callback(struct libwebsocket_context * context, ...@@ -424,9 +423,14 @@ LWS_EXTERN int callback(struct libwebsocket_context * context,
enum libwebsocket_callback_reasons reason, void *user, enum libwebsocket_callback_reasons reason, void *user,
void *in, size_t len); void *in, size_t len);
/* document the generic extension callback (it's a fake prototype under this) */ typedef int (callback_function)(struct libwebsocket_context * context,
struct libwebsocket *wsi,
enum libwebsocket_callback_reasons reason, void *user,
void *in, size_t len);
/** /**
* extension_callback() - Hooks to allow extensions to operate * extension_callback_function() - Hooks to allow extensions to operate
* @context: Websockets context * @context: Websockets context
* @ext: This extension * @ext: This extension
* @wsi: Opaque websocket instance pointer * @wsi: Opaque websocket instance pointer
...@@ -483,13 +487,17 @@ LWS_EXTERN int callback(struct libwebsocket_context * context, ...@@ -483,13 +487,17 @@ LWS_EXTERN int callback(struct libwebsocket_context * context,
* buffer safely, it should copy the data into its own buffer and * buffer safely, it should copy the data into its own buffer and
* set the lws_tokens token pointer to it. * set the lws_tokens token pointer to it.
*/ */
LWS_EXTERN int extension_callback(struct libwebsocket_context * context, LWS_EXTERN int extension_callback(struct libwebsocket_context * context,
struct libwebsocket_extension *ext, struct libwebsocket_extension *ext,
struct libwebsocket *wsi, struct libwebsocket *wsi,
enum libwebsocket_callback_reasons reason, void *user, enum libwebsocket_extension_callback_reasons reason, void *user,
void *in, size_t len); void *in, size_t len);
typedef int (extension_callback_function)(struct libwebsocket_context * context,
struct libwebsocket_extension *ext,
struct libwebsocket *wsi,
enum libwebsocket_extension_callback_reasons reason, void *user,
void *in, size_t len);
/** /**
* struct libwebsocket_protocols - List of protocols and handlers server * struct libwebsocket_protocols - List of protocols and handlers server
...@@ -521,10 +529,7 @@ LWS_EXTERN int extension_callback(struct libwebsocket_context * context, ...@@ -521,10 +529,7 @@ LWS_EXTERN int extension_callback(struct libwebsocket_context * context,
struct libwebsocket_protocols { struct libwebsocket_protocols {
const char *name; const char *name;
int (*callback)(struct libwebsocket_context * context, callback_function *callback;
struct libwebsocket *wsi,
enum libwebsocket_callback_reasons reason, void *user,
void *in, size_t len);
size_t per_session_data_size; size_t per_session_data_size;
/* /*
...@@ -553,11 +558,7 @@ struct libwebsocket_protocols { ...@@ -553,11 +558,7 @@ struct libwebsocket_protocols {
struct libwebsocket_extension { struct libwebsocket_extension {
const char *name; const char *name;
int (*callback)(struct libwebsocket_context *context, extension_callback_function *callback;
struct libwebsocket_extension *ext,
struct libwebsocket *wsi,
enum libwebsocket_extension_callback_reasons reason,
void *user, void *in, size_t len);
size_t per_session_data_size; size_t per_session_data_size;
void * per_context_private_data; void * per_context_private_data;
}; };
......
...@@ -333,6 +333,7 @@ struct libwebsocket { ...@@ -333,6 +333,7 @@ struct libwebsocket {
char *c_host; char *c_host;
char *c_origin; char *c_origin;
char *c_protocol; char *c_protocol;
callback_function *c_callback;
char *c_address; char *c_address;
int c_port; int c_port;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment