return NULL;
}
+ memset(wsi, 0, sizeof *wsi);
+
/* -1 means just use latest supported */
if (ietf_version_or_minus_one == -1)
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 */
* 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);
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);
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);
/*
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
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
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
}
#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
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
<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>,
<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>
<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>