You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ac...@apache.org on 2017/03/01 15:49:49 UTC
[1/2] qpid-proton git commit: PROTON-1422: c libuv proactor should
not require extras library
Repository: qpid-proton
Updated Branches:
refs/heads/master 49ec466a1 -> 7241e775f
PROTON-1422: c libuv proactor should not require extras library
Move the internal pni_parse_url() to the core library and make it visible for
proactor implementations. It is not part of the public user API and is not
advertised in any public header.
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/9845408e
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/9845408e
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/9845408e
Branch: refs/heads/master
Commit: 9845408edc5a3be23ef26c3e8e66d6bf8ba45b2d
Parents: 49ec466
Author: Alan Conway <ac...@redhat.com>
Authored: Wed Mar 1 09:14:37 2017 -0500
Committer: Alan Conway <ac...@redhat.com>
Committed: Wed Mar 1 10:01:57 2017 -0500
----------------------------------------------------------------------
examples/ProtonConfig.cmake | 2 +
examples/c/proactor/CMakeLists.txt | 2 +-
proton-c/CMakeLists.txt | 16 ++---
proton-c/src/core/url-internal.c | 115 ++++++++++++++++++++++++++++++++
proton-c/src/core/url-internal.h | 32 +++++++++
proton-c/src/extra/url.c | 100 +--------------------------
proton-c/src/proactor/libuv.c | 22 +++---
proton-c/src/tests/proactor.c | 3 -
8 files changed, 173 insertions(+), 119 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/9845408e/examples/ProtonConfig.cmake
----------------------------------------------------------------------
diff --git a/examples/ProtonConfig.cmake b/examples/ProtonConfig.cmake
index e910082..fe8709c 100644
--- a/examples/ProtonConfig.cmake
+++ b/examples/ProtonConfig.cmake
@@ -30,4 +30,6 @@
set (Proton_VERSION ${PN_VERSION})
set (Proton_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/proton-c/include)
set (Proton_LIBRARIES qpid-proton)
+set (ProtonCore_LIBRARIES qpid-proton-core)
+set (ProtonProactor_LIBRARIES qpid-proton-proactor)
set (Proton_FOUND True)
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/9845408e/examples/c/proactor/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/examples/c/proactor/CMakeLists.txt b/examples/c/proactor/CMakeLists.txt
index 2cb7ad9..c87cb21 100644
--- a/examples/c/proactor/CMakeLists.txt
+++ b/examples/c/proactor/CMakeLists.txt
@@ -35,7 +35,7 @@ endif(WIN32)
foreach(name broker send receive direct)
add_executable(proactor-${name} ${name}.c)
- target_link_libraries(proactor-${name} ${Proton_LIBRARIES} ${PLATFORM_LIBS})
+ target_link_libraries(proactor-${name} ${ProtonProactor_LIBRARIES} ${PLATFORM_LIBS})
set_target_properties(proactor-${name} PROPERTIES OUTPUT_NAME ${name})
endforeach()
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/9845408e/proton-c/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/proton-c/CMakeLists.txt b/proton-c/CMakeLists.txt
index c56c03f..1b0aa15 100644
--- a/proton-c/CMakeLists.txt
+++ b/proton-c/CMakeLists.txt
@@ -110,6 +110,10 @@ find_package(Libuv)
if (Libuv_FOUND)
set (qpid-proton-proactor src/proactor/libuv.c)
set (PROACTOR_LIBS ${Libuv_LIBRARIES})
+ set_source_files_properties (${qpid-proton-proactor} PROPERTIES
+ # Skip COMPILE_LANGUAGE_FLAGS, libuv.h won't compile with --std=c99
+ COMPILE_FLAGS "${COMPILE_WARNING_FLAGS} ${LTO} "
+ )
endif()
# Link in SASL if present
@@ -382,6 +386,7 @@ set (qpid-proton-core
src/core/autodetect.c
src/core/transport.c
src/core/message.c
+ src/core/url-internal.c
)
set (qpid-proton-include-generated
@@ -499,11 +504,6 @@ set_source_files_properties (
COMPILE_DEFINITIONS "${PLATFORM_DEFINITIONS}"
)
-set_source_files_properties (${qpid-proton-proactor} PROPERTIES
- # Skip COMPILE_LANGUAGE_FLAGS, libuv.h won't compile with --std=c99
- COMPILE_FLAGS "${COMPILE_WARNING_FLAGS} ${LTO} "
- )
-
if (BUILD_WITH_CXX)
set_source_files_properties (
${qpid-proton-core}
@@ -580,10 +580,8 @@ if (qpid-proton-proactor)
set(HAS_PROACTOR 1)
set(HAS_PROACTOR 1 PARENT_SCOPE) # Visible to examples
add_library (
- qpid-proton-proactor SHARED
- ${qpid-proton-proactor}
- )
- target_link_libraries (qpid-proton-proactor qpid-proton-core ${PROACTOR_LIBS})
+ qpid-proton-proactor SHARED ${qpid-proton-proactor})
+ target_link_libraries (qpid-proton-proactor qpid-proton-core ${PROACTOR_LIBS})
list(APPEND LIB_TARGETS qpid-proton-proactor)
endif()
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/9845408e/proton-c/src/core/url-internal.c
----------------------------------------------------------------------
diff --git a/proton-c/src/core/url-internal.c b/proton-c/src/core/url-internal.c
new file mode 100644
index 0000000..2cfc177
--- /dev/null
+++ b/proton-c/src/core/url-internal.c
@@ -0,0 +1,115 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include "core/url-internal.h"
+#include <string.h>
+#include <stdlib.h>
+
+static void pni_urldecode(const char *src, char *dst)
+{
+ const char *in = src;
+ char *out = dst;
+ while (*in != '\0')
+ {
+ if ('%' == *in)
+ {
+ if ((in[1] != '\0') && (in[2] != '\0'))
+ {
+ char esc[3];
+ esc[0] = in[1];
+ esc[1] = in[2];
+ esc[2] = '\0';
+ unsigned long d = strtoul(esc, NULL, 16);
+ *out = (char)d;
+ in += 3;
+ out++;
+ }
+ else
+ {
+ *out = *in;
+ in++;
+ out++;
+ }
+ }
+ else
+ {
+ *out = *in;
+ in++;
+ out++;
+ }
+ }
+ *out = '\0';
+}
+
+void pni_parse_url(char *url, char **scheme, char **user, char **pass, char **host, char **port, char **path)
+{
+ if (!url) return;
+ *scheme = *user = *pass = *host = *port = *path = '\0';
+
+ char *slash = strchr(url, '/');
+
+ if (slash && slash>url) {
+ char *scheme_end = strstr(slash-1, "://");
+
+ if (scheme_end && scheme_end<slash) {
+ *scheme_end = '\0';
+ *scheme = url;
+ url = scheme_end + 3;
+ slash = strchr(url, '/');
+ }
+ }
+
+ if (slash) {
+ *slash = '\0';
+ *path = slash + 1;
+ }
+
+ char *at = strchr(url, '@');
+ if (at) {
+ *at = '\0';
+ char *up = url;
+ *user = up;
+ url = at + 1;
+ char *colon = strchr(up, ':');
+ if (colon) {
+ *colon = '\0';
+ *pass = colon + 1;
+ }
+ }
+
+ *host = url;
+ char *open = (*url == '[') ? url : 0;
+ if (open) {
+ char *close = strchr(open, ']');
+ if (close) {
+ *host = open + 1;
+ *close = '\0';
+ url = close + 1;
+ }
+ }
+
+ char *colon = strchr(url, ':');
+ if (colon) {
+ *colon = '\0';
+ *port = colon + 1;
+ }
+
+ if (*user) pni_urldecode(*user, *user);
+ if (*pass) pni_urldecode(*pass, *pass);
+}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/9845408e/proton-c/src/core/url-internal.h
----------------------------------------------------------------------
diff --git a/proton-c/src/core/url-internal.h b/proton-c/src/core/url-internal.h
new file mode 100644
index 0000000..4654e55
--- /dev/null
+++ b/proton-c/src/core/url-internal.h
@@ -0,0 +1,32 @@
+#ifndef CORE_URL_INTERNAL_H
+#define CORE_URL_INTERNAL_H
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include <proton/import_export.h>
+
+/**@file Simple URL parser for internal use only */
+
+/** Parse a URL in-place. The field pointers scheme, user and so on are made to point to the
+ * decoded fields, which are stored in the same memory as the original URL.
+ * You must not try to use url as the URL string, but you are still responsible for freeing it.
+ */
+PN_EXTERN void pni_parse_url(char *url, char **scheme, char **user, char **pass, char **host, char **port, char **path);
+
+#endif /*!CORE_URL_INTERNAL_H*/
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/9845408e/proton-c/src/extra/url.c
----------------------------------------------------------------------
diff --git a/proton-c/src/extra/url.c b/proton-c/src/extra/url.c
index c1ce628..2d6d8d1 100644
--- a/proton-c/src/extra/url.c
+++ b/proton-c/src/extra/url.c
@@ -19,15 +19,14 @@
*
*/
+#include "core/util.h"
+#include "core/url-internal.h"
+
#include "proton/url.h"
#include "proton/object.h"
-#include "core/util.h"
-
#include <stdlib.h>
#include <string.h>
-#include <stdio.h>
-
/** URL-encode src and append to dst. */
static void pni_urlencode(pn_string_t *dst, const char* src) {
@@ -45,99 +44,6 @@ static void pni_urlencode(pn_string_t *dst, const char* src) {
pn_string_addf(dst, "%s", i);
}
-// Low level url parser
-static void pni_urldecode(const char *src, char *dst)
-{
- const char *in = src;
- char *out = dst;
- while (*in != '\0')
- {
- if ('%' == *in)
- {
- if ((in[1] != '\0') && (in[2] != '\0'))
- {
- char esc[3];
- esc[0] = in[1];
- esc[1] = in[2];
- esc[2] = '\0';
- unsigned long d = strtoul(esc, NULL, 16);
- *out = (char)d;
- in += 3;
- out++;
- }
- else
- {
- *out = *in;
- in++;
- out++;
- }
- }
- else
- {
- *out = *in;
- in++;
- out++;
- }
- }
- *out = '\0';
-}
-
-void pni_parse_url(char *url, char **scheme, char **user, char **pass, char **host, char **port, char **path)
-{
- if (!url) return;
-
- char *slash = strchr(url, '/');
-
- if (slash && slash>url) {
- char *scheme_end = strstr(slash-1, "://");
-
- if (scheme_end && scheme_end<slash) {
- *scheme_end = '\0';
- *scheme = url;
- url = scheme_end + 3;
- slash = strchr(url, '/');
- }
- }
-
- if (slash) {
- *slash = '\0';
- *path = slash + 1;
- }
-
- char *at = strchr(url, '@');
- if (at) {
- *at = '\0';
- char *up = url;
- *user = up;
- url = at + 1;
- char *colon = strchr(up, ':');
- if (colon) {
- *colon = '\0';
- *pass = colon + 1;
- }
- }
-
- *host = url;
- char *open = (*url == '[') ? url : 0;
- if (open) {
- char *close = strchr(open, ']');
- if (close) {
- *host = open + 1;
- *close = '\0';
- url = close + 1;
- }
- }
-
- char *colon = strchr(url, ':');
- if (colon) {
- *colon = '\0';
- *port = colon + 1;
- }
-
- if (*user) pni_urldecode(*user, *user);
- if (*pass) pni_urldecode(*pass, *pass);
-}
-
struct pn_url_t {
char *scheme;
char *username;
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/9845408e/proton-c/src/proactor/libuv.c
----------------------------------------------------------------------
diff --git a/proton-c/src/proactor/libuv.c b/proton-c/src/proactor/libuv.c
index 393df27..1e80e68 100644
--- a/proton-c/src/proactor/libuv.c
+++ b/proton-c/src/proactor/libuv.c
@@ -20,6 +20,7 @@
*/
#include "../core/log_private.h"
+#include "../core/url-internal.h"
#include <proton/condition.h>
#include <proton/connection_driver.h>
@@ -29,7 +30,6 @@
#include <proton/object.h>
#include <proton/proactor.h>
#include <proton/transport.h>
-#include <proton/url.h>
#include <uv.h>
@@ -813,12 +813,14 @@ void pn_proactor_set_timeout(pn_proactor_t *p, pn_millis_t t) {
}
int pn_proactor_connect(pn_proactor_t *p, pn_connection_t *c, const char *addr) {
- pn_url_t *url = pn_url_parse(addr);
- if (!url) {
+ char *buf = strdup(addr);
+ if (!buf) {
return PN_OUT_OF_MEMORY;
}
- pconnection_t *pc = pconnection(p, c, false, pn_url_get_host(url), pn_url_get_port(url));
- pn_url_free(url);
+ char *scheme, *user, *pass, *host, *port, *path;
+ pni_parse_url(buf, &scheme, &user, &pass, &host, &port, &path);
+ pconnection_t *pc = pconnection(p, c, false, host, port);
+ free(buf);
if (!pc) {
return PN_OUT_OF_MEMORY;
}
@@ -828,12 +830,14 @@ int pn_proactor_connect(pn_proactor_t *p, pn_connection_t *c, const char *addr)
int pn_proactor_listen(pn_proactor_t *p, pn_listener_t *l, const char *addr, int backlog) {
assert(!l->closed);
- pn_url_t *url = pn_url_parse(addr);
- if (!url) {
+ char *buf = strdup(addr);
+ if (!buf) {
return PN_OUT_OF_MEMORY;
}
- psocket_init(&l->psocket, p, false, pn_url_get_host(url), pn_url_get_port(url));
- pn_url_free(url);
+ char *scheme, *user, *pass, *host, *port, *path;
+ pni_parse_url(buf, &scheme, &user, &pass, &host, &port, &path);
+ psocket_init(&l->psocket, p, false, host, port);
+ free(buf);
l->backlog = backlog;
psocket_start(&l->psocket);
return 0;
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/9845408e/proton-c/src/tests/proactor.c
----------------------------------------------------------------------
diff --git a/proton-c/src/tests/proactor.c b/proton-c/src/tests/proactor.c
index 84524b5..beba46e 100644
--- a/proton-c/src/tests/proactor.c
+++ b/proton-c/src/tests/proactor.c
@@ -274,9 +274,6 @@ static void test_errors(test_t *t) {
PROACTOR_TEST_FREE(pts);
}
-/* Tests for use of URLs */
-
-
int main(int argc, char **argv) {
int failed = 0;
RUN_ARGV_TEST(failed, t, test_inactive(&t));
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[2/2] qpid-proton git commit: PROTON-1422: c makefiles including -luv
in too many places
Posted by ac...@apache.org.
PROTON-1422: c makefiles including -luv in too many places
cmake was including un-necessary private dependencies (including -luv but also
sasl & ssl related stuff) on every example etc. linked with liqpid-proton. Added
PRIVATE tags to target_link_libraries to prevent that.
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/7241e775
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/7241e775
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/7241e775
Branch: refs/heads/master
Commit: 7241e775f185f74f3e65c30dcf3a631aba6213ce
Parents: 9845408
Author: Alan Conway <ac...@redhat.com>
Authored: Wed Mar 1 10:16:11 2017 -0500
Committer: Alan Conway <ac...@redhat.com>
Committed: Wed Mar 1 10:31:30 2017 -0500
----------------------------------------------------------------------
proton-c/CMakeLists.txt | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/7241e775/proton-c/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/proton-c/CMakeLists.txt b/proton-c/CMakeLists.txt
index 1b0aa15..a6e9ef1 100644
--- a/proton-c/CMakeLists.txt
+++ b/proton-c/CMakeLists.txt
@@ -561,7 +561,7 @@ if (MSVC)
add_dependencies(qpid-proton qpid-proton-core)
endif (MSVC)
-target_link_libraries (qpid-proton ${UUID_LIB} ${SSL_LIB} ${SASL_LIB} ${TIME_LIB} ${PLATFORM_LIBS} ${PROACTOR_LIBS})
+target_link_libraries (qpid-proton LINK_PRIVATE ${UUID_LIB} ${SSL_LIB} ${SASL_LIB} ${TIME_LIB} ${PLATFORM_LIBS} ${PROACTOR_LIBS})
set_target_properties (
qpid-proton
@@ -581,7 +581,8 @@ if (qpid-proton-proactor)
set(HAS_PROACTOR 1 PARENT_SCOPE) # Visible to examples
add_library (
qpid-proton-proactor SHARED ${qpid-proton-proactor})
- target_link_libraries (qpid-proton-proactor qpid-proton-core ${PROACTOR_LIBS})
+ target_link_libraries (qpid-proton-proactor LINK_PUBLIC qpid-proton-core)
+ target_link_libraries (qpid-proton-proactor LINK_PRIVATE ${PROACTOR_LIBS})
list(APPEND LIB_TARGETS qpid-proton-proactor)
endif()
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org