aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Green <andy.green@linaro.org>2015-12-18 12:38:04 +0800
committerAndy Green <andy.green@linaro.org>2015-12-18 12:38:04 +0800
commit47fc4790a229f9ba0c3078106e7c3be212e2de7e (patch)
tree542d589260691400691e92d85eeedabab52a75f9
parentc149092806a5daf6935ff4cf1816d3ebccf698dd (diff)
downloadarm-probe-47fc4790a229f9ba0c3078106e7c3be212e2de7e.tar.gz
align to libwebsockets api v1.6.0
Signed-off-by: Andy Green <andy.green@linaro.org>
-rw-r--r--aepd/main.c12
-rw-r--r--aepd/websocket-protocol.c29
2 files changed, 19 insertions, 22 deletions
diff --git a/aepd/main.c b/aepd/main.c
index 91fecd4..d293eed 100644
--- a/aepd/main.c
+++ b/aepd/main.c
@@ -30,7 +30,7 @@ unsigned long max_fifo_extent_seconds = 120;
struct aepd_shared *aepd_shared;
struct aepd_interface *aepd_interface;
static double sam[MAX_PROBES * CHANNELS_PER_PROBE * DOUBLES_PER_CH_SAMPLE];
-extern struct libwebsocket_protocols protocols[];
+extern struct lws_protocols protocols[];
void zero_fifo(void)
{
@@ -109,7 +109,7 @@ int main(int argc, char *argv[])
LOCAL_RESOURCE_PATH"/aepd.key.pem";
int port = 15164;
int use_ssl = 0;
- struct libwebsocket_context *context;
+ struct lws_context *context;
int opts = LWS_SERVER_OPTION_SKIP_SERVER_CANONICAL_NAME;
char interface_name[128] = "";
const char *interface_ptr = NULL;
@@ -218,7 +218,7 @@ int main(int argc, char *argv[])
info.gid = -1;
info.options = opts;
- context = libwebsocket_create_context(&info);
+ context = lws_create_context(&info);
if (context == NULL) {
fprintf(stderr, "libwebsocket init failed\n");
return -1;
@@ -250,7 +250,7 @@ int main(int argc, char *argv[])
/* websockets service process */
while (1) {
- if (libwebsocket_service(context, 100))
+ if (lws_service(context, 100))
break;
if (getppid() == 1)
break;
@@ -261,11 +261,11 @@ int main(int argc, char *argv[])
if (ms10 > last) {
last = ms10;
- libwebsocket_callback_on_writable_all_protocol(&protocols[1]);
+ lws_callback_on_writable_all_protocol(context, &protocols[1]);
}
}
- libwebsocket_context_destroy(context);
+ lws_context_destroy(context);
return 0;
}
diff --git a/aepd/websocket-protocol.c b/aepd/websocket-protocol.c
index 073c211..597838b 100644
--- a/aepd/websocket-protocol.c
+++ b/aepd/websocket-protocol.c
@@ -45,10 +45,9 @@ static const struct serveable whitelist[] = {
/* this protocol server (always the first one) just knows how to do HTTP */
-static int callback_http(struct libwebsocket_context *context,
- struct libwebsocket *wsi,
- enum libwebsocket_callback_reasons reason, void *user,
- void *in, size_t len)
+static int
+callback_http(struct lws *wsi, enum lws_callback_reasons reason, void *user,
+ void *in, size_t len)
{
int n;
char buf[512];
@@ -56,14 +55,14 @@ static int callback_http(struct libwebsocket_context *context,
switch (reason) {
case LWS_CALLBACK_HTTP:
- for (n = 0; n < (sizeof(whitelist) / sizeof(whitelist[0]) - 1); n++)
+ for (n = 0; n < (ARRAY_SIZE(whitelist) - 1); n++)
if (in && strcmp(in, whitelist[n].urlpath) == 0)
break;
sprintf(buf, LOCAL_RESOURCE_PATH"%s", whitelist[n].urlpath);
- if (libwebsockets_serve_http_file(context, wsi, buf,
- whitelist[n].mimetype, NULL, 0))
+ if (lws_serve_http_file(wsi, buf, whitelist[n].mimetype,
+ NULL, 0))
//fprintf(stderr, "Failed to send HTTP file\n");
break;
break;
@@ -80,7 +79,7 @@ static int callback_http(struct libwebsocket_context *context,
/* linaro_aepd_protocol */
struct per_session_data__linaro_aepd {
- struct libwebsocket *wsi;
+ struct lws *wsi;
long ringbuffer_tail;
double sam[MAX_PROBES * CHANNELS_PER_PROBE * 3];
int sam_valid;
@@ -99,10 +98,8 @@ struct per_session_data__linaro_aepd {
extern struct aep_context aep_context;
static int
-callback_linaro_aepd(struct libwebsocket_context *context,
- struct libwebsocket *wsi,
- enum libwebsocket_callback_reasons reason,
- void *user, void *in, size_t len)
+callback_linaro_aepd(struct lws *wsi, enum lws_callback_reasons reason,
+ void *user, void *in, size_t len)
{
int n, m;
struct per_session_data__linaro_aepd *pss = user;
@@ -367,14 +364,14 @@ send:
*/
if (p != &buf[LWS_SEND_BUFFER_PRE_PADDING]) {
- n = libwebsocket_write(wsi, (unsigned char *)
+ n = lws_write(wsi, (unsigned char *)
&buf[LWS_SEND_BUFFER_PRE_PADDING],
p - &buf[LWS_SEND_BUFFER_PRE_PADDING], LWS_WRITE_TEXT);
if (n < 0) {
fprintf(stderr, "ERROR writing to socket");
return 1;
}
- libwebsocket_callback_on_writable(context, wsi);
+ lws_callback_on_writable(wsi);
}
break;
@@ -436,7 +433,7 @@ send:
pss->issue_timestamp = 1;
pss->seen_rate = 1;
pss->sam_valid = 0;
- libwebsocket_callback_on_writable(context, wsi);
+ lws_callback_on_writable(wsi);
} else
fprintf(stderr, "sscanf failed\n");
break;
@@ -452,7 +449,7 @@ send:
/* list of supported protocols and callbacks */
-struct libwebsocket_protocols protocols[] = {
+const struct lws_protocols protocols[] = {
/* first protocol must always be HTTP handler */
{