From 5b3736682d321cd188c922dd0635b3278937e542 Mon Sep 17 00:00:00 2001
From: Andy Green <andy.green@linaro.org>
Date: Tue, 12 Jan 2016 17:22:06 +0800
Subject: [PATCH] lws_client_connect_via_info

https://github.com/warmcat/libwebsockets/issues/396

Signed-off-by: Andy Green <andy.green@linaro.org>
---
 lib/client-handshake.c    | 47 ++++++++++++++++++++++-----------------
 lib/libwebsockets.h       |  2 +-
 test-server/test-client.c |  4 ++--
 test-server/test-echo.c   |  2 +-
 4 files changed, 31 insertions(+), 24 deletions(-)

diff --git a/lib/client-handshake.c b/lib/client-handshake.c
index eca54830..d6f637bc 100644
--- a/lib/client-handshake.c
+++ b/lib/client-handshake.c
@@ -313,29 +313,16 @@ failed:
 
 	return NULL;
 }
-
 /**
- * lws_client_connect() - Connect to another websocket server
- * @context:	Websocket context
- * @address:	Remote server address, eg, "myserver.com"
- * @port:	Port to connect to on the remote server, eg, 80
- * @ssl_connection:	0 = ws://, 1 = wss:// encrypted, 2 = wss:// allow self
- *			signed certs
- * @path:	Websocket path on server
- * @host:	Hostname on server
- * @origin:	Socket origin name
- * @protocol:	Comma-separated list of protocols being asked for from
- *		the server, or just one.  The server will pick the one it
- *		likes best.  If you don't want to specify a protocol, which is
- *		legal, use NULL here.
- * @ietf_version_or_minus_one: -1 to ask to connect using the default, latest
- *		protocol supported, or the specific protocol ordinal
+ * lws_client_connect_via_info() - Connect to another websocket server
+ * @i:pointer to lws_client_connect_info struct
  *
  *	This function creates a connection to a remote server
  */
 
+
 LWS_VISIBLE struct lws *
-lws_client_connect_info(struct lws_client_connect_info *i)
+lws_client_connect_via_info(struct lws_client_connect_info *i)
 {
 	struct lws *wsi;
 	int v = SPEC_LATEST_SUPPORTED;
@@ -438,7 +425,7 @@ bail:
 
 /**
  * lws_client_connect_extended() - Connect to another websocket server
- * 				DEPRECAATED use lws_client_connect_info
+ * 				DEPRECATED use lws_client_connect_via_info
  * @context:	Websocket context
  * @address:	Remote server address, eg, "myserver.com"
  * @port:	Port to connect to on the remote server, eg, 80
@@ -479,10 +466,30 @@ lws_client_connect_extended(struct lws_context *context, const char *address,
 	i.ietf_version_or_minus_one = ietf_version_or_minus_one;
 	i.userdata = userdata;
 
-	return lws_client_connect_info(&i);
+	return lws_client_connect_via_info(&i);
 }
+/**
+ * lws_client_connect_info() - Connect to another websocket server
+ * 				DEPRECATED use lws_client_connect_via_info
+ * @context:	Websocket context
+ * @address:	Remote server address, eg, "myserver.com"
+ * @port:	Port to connect to on the remote server, eg, 80
+ * @ssl_connection:	0 = ws://, 1 = wss:// encrypted, 2 = wss:// allow self
+ *			signed certs
+ * @path:	Websocket path on server
+ * @host:	Hostname on server
+ * @origin:	Socket origin name
+ * @protocol:	Comma-separated list of protocols being asked for from
+ *		the server, or just one.  The server will pick the one it
+ *		likes best.  If you don't want to specify a protocol, which is
+ *		legal, use NULL here.
+ * @ietf_version_or_minus_one: -1 to ask to connect using the default, latest
+ *		protocol supported, or the specific protocol ordinal
+ *
+ *	This function creates a connection to a remote server
+ */
+
 
-/* deprecated use lws_client_connect_info */
 LWS_VISIBLE struct lws *
 lws_client_connect(struct lws_context *context, const char *address,
 			    int port, int ssl_connection, const char *path,
diff --git a/lib/libwebsockets.h b/lib/libwebsockets.h
index d2a1b1b1..deb38438 100644
--- a/lib/libwebsockets.h
+++ b/lib/libwebsockets.h
@@ -1617,7 +1617,7 @@ lws_client_connect_extended(struct lws_context *clients, const char *address,
 			    void *userdata);
 
 LWS_VISIBLE LWS_EXTERN struct lws *
-lws_client_connect_info(struct lws_client_connect_info * ccinfo);
+lws_client_connect_via_info(struct lws_client_connect_info * ccinfo);
 
 LWS_VISIBLE LWS_EXTERN const char *
 lws_canonical_hostname(struct lws_context *context);
diff --git a/test-server/test-client.c b/test-server/test-client.c
index 38a48793..475b8b14 100644
--- a/test-server/test-client.c
+++ b/test-server/test-client.c
@@ -368,13 +368,13 @@ int main(int argc, char **argv)
 		if (!wsi_dumb && ratelimit_connects(&rl_dumb, 2u)) {
 			lwsl_notice("dumb: connecting\n");
 			i.protocol = protocols[PROTOCOL_DUMB_INCREMENT].name;
-			wsi_dumb = lws_client_connect_info(&i);
+			wsi_dumb = lws_client_connect_via_info(&i);
 		}
 
 		if (!wsi_mirror && ratelimit_connects(&rl_mirror, 2u)) {
 			lwsl_notice("mirror: connecting\n");
 			i.protocol = protocols[PROTOCOL_LWS_MIRROR].name;
-			wsi_mirror = lws_client_connect_info(&i);
+			wsi_mirror = lws_client_connect_via_info(&i);
 		}
 
 		lws_service(context, 500);
diff --git a/test-server/test-echo.c b/test-server/test-echo.c
index 46068608..b72813d0 100644
--- a/test-server/test-echo.c
+++ b/test-server/test-echo.c
@@ -486,7 +486,7 @@ int main(int argc, char **argv)
 			i.protocol = connect_protocol;
 			i.client_exts = exts;
 
-			wsi = lws_client_connect_info(&i);
+			wsi = lws_client_connect_via_info(&i);
 			if (!wsi) {
 				lwsl_err("Client failed to connect to %s:%u\n",
 					 address, port);
-- 
GitLab