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/04/27 17:38:33 UTC
[08/10] qpid-dispatch git commit: DISPATCH-390: common AMQP port name
string to integer function
DISPATCH-390: common AMQP port name string to integer function
Project: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/commit/20b06ac3
Tree: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/tree/20b06ac3
Diff: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/diff/20b06ac3
Branch: refs/heads/master
Commit: 20b06ac3452ae4ecdc21b577c164538d454de3a1
Parents: 6d34045
Author: Alan Conway <ac...@redhat.com>
Authored: Wed Apr 12 21:27:06 2017 -0400
Committer: Alan Conway <ac...@redhat.com>
Committed: Thu Apr 27 13:30:17 2017 -0400
----------------------------------------------------------------------
include/qpid/dispatch/amqp.h | 11 ++++++++++-
src/amqp.c | 15 +++++++++++++++
2 files changed, 25 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/20b06ac3/include/qpid/dispatch/amqp.h
----------------------------------------------------------------------
diff --git a/include/qpid/dispatch/amqp.h b/include/qpid/dispatch/amqp.h
index e5c45c6..beb083a 100644
--- a/include/qpid/dispatch/amqp.h
+++ b/include/qpid/dispatch/amqp.h
@@ -33,9 +33,17 @@
* AMQP Constants
*/
typedef enum {
- QD_AMQP_MIN_MAX_FRAME_SIZE = 512
+ QD_AMQP_MIN_MAX_FRAME_SIZE = 512,
+ QD_AMQP_PORT_INT = 5672,
+ QD_AMQPS_PORT_INT = 5671
} qd_amqp_constants_t;
+extern const char * const QD_AMQP_PORT_STR;
+extern const char * const QD_AMQPS_PORT_STR;
+
+/* Returns -1 if string is not a number or recognized symbolic port name */
+int qd_port_int(const char* port_str);
+
/**
* AMQP Performative Tags
*/
@@ -165,4 +173,5 @@ extern const char * const QD_AMQP_COND_ILLEGAL_STATE;
extern const char * const QD_AMQP_COND_FRAME_SIZE_TOO_SMALL;
/// @};
+
#endif
http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/20b06ac3/src/amqp.c
----------------------------------------------------------------------
diff --git a/src/amqp.c b/src/amqp.c
index cf9f775..d2f2cfe 100644
--- a/src/amqp.c
+++ b/src/amqp.c
@@ -18,6 +18,9 @@
*/
#include <qpid/dispatch/amqp.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <string.h>
const char * const QD_MA_PREFIX = "x-opt-qd.";
const char * const QD_MA_INGRESS = "x-opt-qd.ingress";
@@ -63,3 +66,15 @@ const char * const QD_AMQP_COND_PRECONDITION_FAILED = "amqp:precondition-failed"
const char * const QD_AMQP_COND_RESOURCE_DELETED = "amqp:resource-deleted";
const char * const QD_AMQP_COND_ILLEGAL_STATE = "amqp:illegal-state";
const char * const QD_AMQP_COND_FRAME_SIZE_TOO_SMALL = "amqp:frame-size-too-small";
+
+const char * const QD_AMQP_PORT_STR = "5672";
+const char * const QD_AMQPS_PORT_STR = "5671";
+
+int qd_port_int(const char* port_str) {
+ if (!strcmp(port_str, QD_AMQP_PORT_STR)) return QD_AMQP_PORT_INT;
+ if (!strcmp(port_str, QD_AMQPS_PORT_STR)) return QD_AMQPS_PORT_INT;
+ errno = 0;
+ unsigned long n = strtoul(port_str, NULL, 10);
+ if (errno || n > 0xFFFF) return -1;
+ return n;
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org