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/10/12 12:36:01 UTC
qpid-proton git commit: PROTON-1619: c rename/remove/un-export
private functions
Repository: qpid-proton
Updated Branches:
refs/heads/master 485cdbd3f -> 8a891c92b
PROTON-1619: c rename/remove/un-export private functions
renamed as pni_*:
pn_log_enabled, pn_logf_impl, pn_vlogf_impl - still exported for libqpid-proton-proactor
pn_message_get_extra, pn_message_with_extra - still exported for libqpid-proton-cpp
removed: pn_connection_driver_log, pn_connection_driver_logf, pn_connection_driver_vlogf
unexported: pni_parse_url - now private in extras/url.c
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/8a891c92
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/8a891c92
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/8a891c92
Branch: refs/heads/master
Commit: 8a891c92b7a4f56d009e1e437d979c3379fe4a6f
Parents: 485cdbd
Author: Alan Conway <ac...@redhat.com>
Authored: Thu Oct 12 06:56:00 2017 -0400
Committer: Alan Conway <ac...@redhat.com>
Committed: Thu Oct 12 08:20:01 2017 -0400
----------------------------------------------------------------------
proton-c/CMakeLists.txt | 3 +-
proton-c/bindings/cpp/src/message.cpp | 10 +-
proton-c/include/proton/connection_driver.h | 19 +---
proton-c/include/proton/message.h | 11 ---
proton-c/src/core/connection_driver.c | 7 --
proton-c/src/core/log.c | 14 +--
proton-c/src/core/log_private.h | 14 +--
proton-c/src/core/message-internal.h | 43 +++++++++
proton-c/src/core/message.c | 6 +-
proton-c/src/core/url-internal.c | 115 -----------------------
proton-c/src/core/url-internal.h | 32 -------
proton-c/src/extra/url.c | 96 ++++++++++++++++++-
proton-c/src/messenger/messenger.c | 4 +-
13 files changed, 165 insertions(+), 209 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8a891c92/proton-c/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/proton-c/CMakeLists.txt b/proton-c/CMakeLists.txt
index 40d1d2e..6b6cfb4 100644
--- a/proton-c/CMakeLists.txt
+++ b/proton-c/CMakeLists.txt
@@ -412,7 +412,6 @@ 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
@@ -442,7 +441,7 @@ set (qpid-proton-private-includes
src/core/data.h
src/core/decoder.h
src/core/max_align.h
- src/core/url-internal.h
+ src/core/message-internal.h
src/reactor/io/windows/iocp.h
src/reactor/selector.h
src/reactor/io.h
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8a891c92/proton-c/bindings/cpp/src/message.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/message.cpp b/proton-c/bindings/cpp/src/message.cpp
index 1fbdf70..5e9487b 100644
--- a/proton-c/bindings/cpp/src/message.cpp
+++ b/proton-c/bindings/cpp/src/message.cpp
@@ -32,8 +32,8 @@
#include "proton_bits.hpp"
#include "types_internal.hpp"
-#include <proton/delivery.h>
-#include <proton/message.h>
+#include "core/message-internal.h"
+#include "proton/delivery.h"
#include <string>
#include <algorithm>
@@ -94,15 +94,15 @@ void swap(message& x, message& y) {
pn_message_t *message::pn_msg() const {
if (!pn_msg_) {
- pn_msg_ = pn_message_with_extra(sizeof(struct message::impl));
+ pn_msg_ = pni_message_with_extra(sizeof(struct message::impl));
// Construct impl in extra storage allocated with pn_msg_
- new (pn_message_get_extra(pn_msg_)) struct message::impl(pn_msg_);
+ new (pni_message_get_extra(pn_msg_)) struct message::impl(pn_msg_);
}
return pn_msg_;
}
struct message::impl& message::impl() const {
- return *(struct message::impl*)pn_message_get_extra(pn_msg());
+ return *(struct message::impl*)pni_message_get_extra(pn_msg());
}
message& message::operator=(const message& m) {
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8a891c92/proton-c/include/proton/connection_driver.h
----------------------------------------------------------------------
diff --git a/proton-c/include/proton/connection_driver.h b/proton-c/include/proton/connection_driver.h
index 89040af..1ad4469 100644
--- a/proton-c/include/proton/connection_driver.h
+++ b/proton-c/include/proton/connection_driver.h
@@ -218,7 +218,7 @@ PN_EXTERN bool pn_connection_driver_has_event(pn_connection_driver_t *);
PN_EXTERN bool pn_connection_driver_finished(pn_connection_driver_t *);
/**
- * Set IO error information.
+ * Set transport error.
*
* The name and formatted description are set on the transport condition, and
* returned as a PN_TRANSPORT_ERROR event from pn_connection_driver_next_event().
@@ -229,26 +229,11 @@ PN_EXTERN bool pn_connection_driver_finished(pn_connection_driver_t *);
PN_EXTERN void pn_connection_driver_errorf(pn_connection_driver_t *d, const char *name, const char *fmt, ...);
/**
- * Set IO error information via a va_list, see pn_connection_driver_errorf()
+ * Set transport error via a va_list, see pn_connection_driver_errorf()
*/
PN_EXTERN void pn_connection_driver_verrorf(pn_connection_driver_t *d, const char *name, const char *fmt, va_list);
/**
- * Log a string message using the connection's transport log.
- */
-PN_EXTERN void pn_connection_driver_log(pn_connection_driver_t *d, const char *msg);
-
-/**
- * Log a printf formatted message using the connection's transport log.
- */
-PN_EXTERN void pn_connection_driver_logf(pn_connection_driver_t *d, const char *fmt, ...);
-
-/**
- * Log a printf formatted message using the connection's transport log.
- */
-PN_EXTERN void pn_connection_driver_vlogf(pn_connection_driver_t *d, const char *fmt, va_list ap);
-
-/**
* If batch is part of a connection_driver, return the connection_driver address,
* else return NULL
*/
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8a891c92/proton-c/include/proton/message.h
----------------------------------------------------------------------
diff --git a/proton-c/include/proton/message.h b/proton-c/include/proton/message.h
index 2723915..741f3ac 100644
--- a/proton-c/include/proton/message.h
+++ b/proton-c/include/proton/message.h
@@ -748,17 +748,6 @@ PN_EXTERN int pn_message_encode(pn_message_t *msg, char *bytes, size_t *size);
*/
PN_EXTERN int pn_message_data(pn_message_t *msg, pn_data_t *data);
-/** @cond INTERNAL */
-
-/** Construct a message with extra storage */
-PN_EXTERN pn_message_t * pn_message_with_extra(size_t extra);
-
-/** Pointer to extra space allocated by pn_message_with_extra(). */
-PN_EXTERN void* pn_message_get_extra(pn_message_t *msg);
-
-/** @endcond */
-
-
/** @}
*/
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8a891c92/proton-c/src/core/connection_driver.c
----------------------------------------------------------------------
diff --git a/proton-c/src/core/connection_driver.c b/proton-c/src/core/connection_driver.c
index eb2df5f..12d4b28 100644
--- a/proton-c/src/core/connection_driver.c
+++ b/proton-c/src/core/connection_driver.c
@@ -170,13 +170,6 @@ void pn_connection_driver_log(pn_connection_driver_t *d, const char *msg) {
pn_transport_log(d->transport, msg);
}
-void pn_connection_driver_logf(pn_connection_driver_t *d, const char *fmt, ...) {
- va_list ap;
- va_start(ap, fmt);
- pn_transport_vlogf(d->transport, fmt, ap);
- va_end(ap);
-}
-
void pn_connection_driver_vlogf(pn_connection_driver_t *d, const char *fmt, va_list ap) {
pn_transport_vlogf(d->transport, fmt, ap);
}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8a891c92/proton-c/src/core/log.c
----------------------------------------------------------------------
diff --git a/proton-c/src/core/log.c b/proton-c/src/core/log.c
index db83e7e..754eed3 100644
--- a/proton-c/src/core/log.c
+++ b/proton-c/src/core/log.c
@@ -36,7 +36,7 @@ void pn_log_enable(bool value) {
enabled_call = value;
}
-bool pn_log_enabled(void) {
+bool pni_log_enabled(void) {
if (enabled_call != -1) return enabled_call; /* Takes precedence */
if (enabled_env == -1)
enabled_env = pn_env_bool("PN_TRACE_LOG");
@@ -48,23 +48,23 @@ void pn_log_logger(pn_logger_t new_logger) {
if (!logger) pn_log_enable(false);
}
-void pn_vlogf_impl(const char *fmt, va_list ap) {
+void pni_vlogf_impl(const char *fmt, va_list ap) {
vfprintf(stderr, fmt, ap);
fprintf(stderr, "\n");
}
/**@internal
*
- * Note: We check pn_log_enabled() in the pn_logf macro *before* calling
- * pn_logf_impl because evaluating the arguments to that call could have
+ * Note: We check pni_log_enabled() in the pn_logf macro *before* calling
+ * pni_logf_impl because evaluating the arguments to that call could have
* side-effects with performance impact (e.g. calling functions to construct
* complicated messages.) It is important that a disabled log statement results
- * in nothing more than a call to pn_log_enabled().
+ * in nothing more than a call to pni_log_enabled().
*/
-void pn_logf_impl(const char *fmt, ...) {
+void pni_logf_impl(const char *fmt, ...) {
va_list ap;
va_start(ap, fmt);
- pn_vlogf_impl(fmt, ap);
+ pni_vlogf_impl(fmt, ap);
va_end(ap);
}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8a891c92/proton-c/src/core/log_private.h
----------------------------------------------------------------------
diff --git a/proton-c/src/core/log_private.h b/proton-c/src/core/log_private.h
index 828e189..75044ed 100644
--- a/proton-c/src/core/log_private.h
+++ b/proton-c/src/core/log_private.h
@@ -30,24 +30,24 @@
/** Log a printf style message */
#define pn_logf(...) \
do { \
- if (pn_log_enabled()) \
- pn_logf_impl(__VA_ARGS__); \
+ if (pni_log_enabled()) \
+ pni_logf_impl(__VA_ARGS__); \
} while(0)
/** va_list version of pn_logf */
#define pn_vlogf(fmt, ap) \
do { \
- if (pn_log_enabled()) \
- pn_vlogf_impl(fmt, ap); \
+ if (pni_log_enabled()) \
+ pni_vlogf_impl(fmt, ap); \
} while(0)
/** Return true if logging is enabled. */
-PN_EXTERN bool pn_log_enabled(void);
+PN_EXTERN bool pni_log_enabled(void);
/**@internal*/
-PN_EXTERN void pn_logf_impl(const char* fmt, ...);
+PN_EXTERN void pni_logf_impl(const char* fmt, ...);
/**@internal*/
-PN_EXTERN void pn_vlogf_impl(const char *fmt, va_list ap);
+PN_EXTERN void pni_vlogf_impl(const char *fmt, va_list ap);
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8a891c92/proton-c/src/core/message-internal.h
----------------------------------------------------------------------
diff --git a/proton-c/src/core/message-internal.h b/proton-c/src/core/message-internal.h
new file mode 100644
index 0000000..7b59bb7
--- /dev/null
+++ b/proton-c/src/core/message-internal.h
@@ -0,0 +1,43 @@
+#ifndef CORE_MESSAGE_INTERNAL_H
+#define CORE_MESSAGE_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/message.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/** @cond INTERNAL */
+
+/** Construct a message with extra storage */
+PN_EXTERN pn_message_t * pni_message_with_extra(size_t extra);
+
+/** Pointer to extra space allocated by pn_message_with_extra(). */
+PN_EXTERN void* pni_message_get_extra(pn_message_t *msg);
+
+/** @endcond */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // CORE_MESSAGE_INTERNAL_H
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8a891c92/proton-c/src/core/message.c
----------------------------------------------------------------------
diff --git a/proton-c/src/core/message.c b/proton-c/src/core/message.c
index 038c836..e1f235b 100644
--- a/proton-c/src/core/message.c
+++ b/proton-c/src/core/message.c
@@ -22,10 +22,10 @@
#include "platform/platform_fmt.h"
#include "max_align.h"
+#include "message-internal.h"
#include "protocol.h"
#include "util.h"
-#include <proton/message.h>
#include <proton/object.h>
#include <proton/codec.h>
#include <proton/error.h>
@@ -348,11 +348,11 @@ typedef union {
pn_max_align_t a;
} pni_aligned_message_t;
-pn_message_t *pn_message_with_extra(size_t extra) {
+pn_message_t *pni_message_with_extra(size_t extra) {
return pni_message_new(sizeof(pni_aligned_message_t) + extra);
}
-void *pn_message_get_extra(pn_message_t *m) {
+void *pni_message_get_extra(pn_message_t *m) {
return ((char*)m) + sizeof(pni_aligned_message_t);
}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8a891c92/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
deleted file mode 100644
index a7186b1..0000000
--- a/proton-c/src/core/url-internal.c
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * 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 = NULL;
-
- 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 = strrchr(url, ':'); /* Be flexible about unbracketed IPV6 literals like ::1:<port> */
- 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/8a891c92/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
deleted file mode 100644
index 4654e55..0000000
--- a/proton-c/src/core/url-internal.h
+++ /dev/null
@@ -1,32 +0,0 @@
-#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/8a891c92/proton-c/src/extra/url.c
----------------------------------------------------------------------
diff --git a/proton-c/src/extra/url.c b/proton-c/src/extra/url.c
index 2d6d8d1..c4aa48c 100644
--- a/proton-c/src/extra/url.c
+++ b/proton-c/src/extra/url.c
@@ -20,14 +20,106 @@
*/
#include "core/util.h"
-#include "core/url-internal.h"
-
#include "proton/url.h"
#include "proton/object.h"
#include <stdlib.h>
#include <string.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';
+}
+
+/* Not static - used by messenger.c */
+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 = NULL;
+
+ 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 = strrchr(url, ':'); /* Be flexible about unbracketed IPV6 literals like ::1:<port> */
+ if (colon) {
+ *colon = '\0';
+ *port = colon + 1;
+ }
+
+ if (*user) pni_urldecode(*user, *user);
+ if (*pass) pni_urldecode(*pass, *pass);
+}
+
/** URL-encode src and append to dst. */
static void pni_urlencode(pn_string_t *dst, const char* src) {
static const char *bad = "@:/";
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8a891c92/proton-c/src/messenger/messenger.c
----------------------------------------------------------------------
diff --git a/proton-c/src/messenger/messenger.c b/proton-c/src/messenger/messenger.c
index 01d7c99..39c00c6 100644
--- a/proton-c/src/messenger/messenger.c
+++ b/proton-c/src/messenger/messenger.c
@@ -27,6 +27,7 @@
#include <proton/object.h>
#include <proton/sasl.h>
#include <proton/session.h>
+#include <proton/url.h>
#include <assert.h>
#include <ctype.h>
@@ -36,7 +37,6 @@
#include "core/log_private.h"
#include "core/util.h"
-#include "core/url-internal.h"
#include "platform/platform.h" // pn_i_getpid, pn_i_now, pni_snprintf
#include "platform/platform_fmt.h"
#include "store.h"
@@ -1588,6 +1588,8 @@ int pn_messenger_stop(pn_messenger_t *messenger)
return pn_messenger_sync(messenger, pn_messenger_stopped);
}
+void pni_parse_url(char *url, char **scheme, char **user, char **pass, char **host, char **port, char **path);
+
static void pni_parse(pn_address_t *address)
{
address->passive = false;
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org