mirror of
https://github.com/warmcat/libwebsockets.git
synced 2025-03-09 00:00:04 +01:00
Apple / iOS build compatability patch
This allows build on iOS platform, thanks Darin! Signed-off-by: Darin Willits <darin@willits.ca>
This commit is contained in:
parent
62c54d2f56
commit
c19456f64a
5 changed files with 41 additions and 16 deletions
|
@ -79,6 +79,8 @@ libwebsocket_client_connect(struct libwebsocket_context *this,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
memset(wsi, 0, sizeof *wsi);
|
||||
|
||||
/* -1 means just use latest supported */
|
||||
|
||||
if (ietf_version_or_minus_one == -1)
|
||||
|
|
|
@ -965,9 +965,14 @@ libwebsocket_create_context(int port,
|
|||
hostname[(sizeof hostname) - 1] = '\0';
|
||||
gethostname(hostname, (sizeof hostname) - 1);
|
||||
he = gethostbyname(hostname);
|
||||
strncpy(this->canonical_hostname, he->h_name,
|
||||
if (he) {
|
||||
strncpy(this->canonical_hostname, he->h_name,
|
||||
sizeof this->canonical_hostname - 1);
|
||||
this->canonical_hostname[sizeof this->canonical_hostname - 1] =
|
||||
'\0';
|
||||
} else
|
||||
strncpy(this->canonical_hostname, hostname,
|
||||
sizeof this->canonical_hostname - 1);
|
||||
this->canonical_hostname[sizeof this->canonical_hostname - 1] = '\0';
|
||||
|
||||
/* split the proxy ads:port if given */
|
||||
|
||||
|
|
|
@ -236,7 +236,7 @@ struct libwebsocket_context;
|
|||
* pollfd struct for this socket descriptor. If you are using the
|
||||
* internal polling loop, you can just ignore it.
|
||||
*/
|
||||
extern int callback(struct libwebsocket_context * this,
|
||||
extern int callback(struct libwebsocket_context * context,
|
||||
struct libwebsocket *wsi,
|
||||
enum libwebsocket_callback_reasons reason, void *user,
|
||||
void *in, size_t len);
|
||||
|
@ -271,7 +271,7 @@ extern int callback(struct libwebsocket_context * this,
|
|||
|
||||
struct libwebsocket_protocols {
|
||||
const char *name;
|
||||
int (*callback)(struct libwebsocket_context * this,
|
||||
int (*callback)(struct libwebsocket_context * context,
|
||||
struct libwebsocket *wsi,
|
||||
enum libwebsocket_callback_reasons reason, void *user,
|
||||
void *in, size_t len);
|
||||
|
@ -296,16 +296,16 @@ libwebsocket_create_context(int port,
|
|||
unsigned int options);
|
||||
|
||||
extern void
|
||||
libwebsocket_context_destroy(struct libwebsocket_context *this);
|
||||
libwebsocket_context_destroy(struct libwebsocket_context *context);
|
||||
|
||||
extern int
|
||||
libwebsockets_fork_service_loop(struct libwebsocket_context *this);
|
||||
libwebsockets_fork_service_loop(struct libwebsocket_context *context);
|
||||
|
||||
extern int
|
||||
libwebsocket_service(struct libwebsocket_context *this, int timeout_ms);
|
||||
libwebsocket_service(struct libwebsocket_context *context, int timeout_ms);
|
||||
|
||||
extern int
|
||||
libwebsocket_service_fd(struct libwebsocket_context *this,
|
||||
libwebsocket_service_fd(struct libwebsocket_context *context,
|
||||
struct pollfd *pollfd);
|
||||
|
||||
/*
|
||||
|
@ -355,7 +355,7 @@ extern const struct libwebsocket_protocols *
|
|||
libwebsockets_get_protocol(struct libwebsocket *wsi);
|
||||
|
||||
extern int
|
||||
libwebsocket_callback_on_writable(struct libwebsocket_context *this,
|
||||
libwebsocket_callback_on_writable(struct libwebsocket_context *context,
|
||||
struct libwebsocket *wsi);
|
||||
|
||||
extern int
|
||||
|
@ -383,7 +383,7 @@ libwebsocket_client_connect(struct libwebsocket_context *clients,
|
|||
int ietf_version_or_minus_one);
|
||||
|
||||
extern const char *
|
||||
libwebsocket_canonical_hostname(struct libwebsocket_context *this);
|
||||
libwebsocket_canonical_hostname(struct libwebsocket_context *context);
|
||||
|
||||
|
||||
extern void
|
||||
|
@ -391,10 +391,10 @@ libwebsockets_get_peer_addresses(int fd, char *name, int name_len,
|
|||
char *rip, int rip_len);
|
||||
|
||||
extern void
|
||||
libwebsockets_hangup_on_client(struct libwebsocket_context *this, int fd);
|
||||
libwebsockets_hangup_on_client(struct libwebsocket_context *context, int fd);
|
||||
|
||||
extern void
|
||||
libwebsocket_close_and_free_session(struct libwebsocket_context *this,
|
||||
libwebsocket_close_and_free_session(struct libwebsocket_context *context,
|
||||
struct libwebsocket *wsi);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -68,6 +68,16 @@ static inline void debug(const char *format, ...)
|
|||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* Mac OSX as well as iOS do not define the MSG_NOSIGNAL flag,
|
||||
* but happily have something equivalent in the SO_NOSIGPIPE flag.
|
||||
*/
|
||||
#ifdef __APPLE__
|
||||
#define MSG_NOSIGNAL SO_NOSIGPIPE
|
||||
#endif
|
||||
|
||||
|
||||
#define FD_HASHTABLE_MODULUS 32
|
||||
#define MAX_CLIENTS 100
|
||||
#define LWS_MAX_HEADER_NAME_LENGTH 64
|
||||
|
@ -262,3 +272,13 @@ insert_wsi(struct libwebsocket_context *this, struct libwebsocket *wsi);
|
|||
|
||||
extern int
|
||||
delete_from_fd(struct libwebsocket_context *this, int fd);
|
||||
|
||||
#ifndef LWS_OPENSSL_SUPPORT
|
||||
|
||||
unsigned char *
|
||||
SHA1(const unsigned char *d, size_t n, unsigned char *md);
|
||||
|
||||
void
|
||||
MD5(const unsigned char *input, int ilen, unsigned char *output);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -440,7 +440,7 @@ This function creates a connection to a remote server
|
|||
<h2>callback - User server actions</h2>
|
||||
<i>int</i>
|
||||
<b>callback</b>
|
||||
(<i>struct libwebsocket_context *</i> <b>this</b>,
|
||||
(<i>struct libwebsocket_context *</i> <b>context</b>,
|
||||
<i>struct libwebsocket *</i> <b>wsi</b>,
|
||||
<i>enum libwebsocket_callback_reasons</i> <b>reason</b>,
|
||||
<i>void *</i> <b>user</b>,
|
||||
|
@ -448,8 +448,6 @@ This function creates a connection to a remote server
|
|||
<i>size_t</i> <b>len</b>)
|
||||
<h3>Arguments</h3>
|
||||
<dl>
|
||||
<dt><b>this</b>
|
||||
<dd>Websockets context
|
||||
<dt><b>wsi</b>
|
||||
<dd>Opaque websocket instance pointer
|
||||
<dt><b>reason</b>
|
||||
|
@ -604,7 +602,7 @@ internal polling loop, you can just ignore it.
|
|||
<h2>struct libwebsocket_protocols - List of protocols and handlers server supports.</h2>
|
||||
<b>struct libwebsocket_protocols</b> {<br>
|
||||
<i>const char *</i> <b>name</b>;<br>
|
||||
<i>int (*</i><b>callback</b>) <i>(struct libwebsocket_context * this,struct libwebsocket *wsi,enum libwebsocket_callback_reasons reason, void *user,void *in, size_t len)</i>;<br>
|
||||
<i>int (*</i><b>callback</b>) <i>(struct libwebsocket_context * context,struct libwebsocket *wsi,enum libwebsocket_callback_reasons reason, void *user,void *in, size_t len)</i>;<br>
|
||||
<i>size_t</i> <b>per_session_data_size</b>;<br>
|
||||
<i>struct libwebsocket_context *</i> <b>owning_server</b>;<br>
|
||||
<i>int</i> <b>broadcast_socket_port</b>;<br>
|
||||
|
|
Loading…
Add table
Reference in a new issue