You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by tr...@apache.org on 2014/01/23 22:29:01 UTC

svn commit: r1560815 - in /qpid/dispatch/trunk: include/qpid/dispatch/config.h src/config.c src/config_private.h src/dispatch.c src/router_config.c

Author: tross
Date: Thu Jan 23 21:29:00 2014
New Revision: 1560815

URL: http://svn.apache.org/r1560815
Log:
QPID-5505 - Updated the configuration API to be usable outside the internals of the Dispatch library.

Modified:
    qpid/dispatch/trunk/include/qpid/dispatch/config.h
    qpid/dispatch/trunk/src/config.c
    qpid/dispatch/trunk/src/config_private.h
    qpid/dispatch/trunk/src/dispatch.c
    qpid/dispatch/trunk/src/router_config.c

Modified: qpid/dispatch/trunk/include/qpid/dispatch/config.h
URL: http://svn.apache.org/viewvc/qpid/dispatch/trunk/include/qpid/dispatch/config.h?rev=1560815&r1=1560814&r2=1560815&view=diff
==============================================================================
--- qpid/dispatch/trunk/include/qpid/dispatch/config.h (original)
+++ qpid/dispatch/trunk/include/qpid/dispatch/config.h Thu Jan 23 21:29:00 2014
@@ -19,13 +19,12 @@
  * under the License.
  */
 
+#include <qpid/dispatch/dispatch.h>
 #include <stdint.h>
 
-typedef struct qd_config_t qd_config_t;
-
-int qd_config_item_count(const qd_config_t *config, const char *section);
-const char *qd_config_item_value_string(const qd_config_t *config, const char *section, int index, const char* key);
-uint32_t qd_config_item_value_int(const qd_config_t *config, const char *section, int index, const char* key);
-int qd_config_item_value_bool(const qd_config_t *config, const char *section, int index, const char* key);
+int qd_config_item_count(const qd_dispatch_t *dispatch, const char *section);
+const char *qd_config_item_value_string(const qd_dispatch_t *dispatch, const char *section, int index, const char* key);
+uint32_t qd_config_item_value_int(const qd_dispatch_t *dispatch, const char *section, int index, const char* key);
+int qd_config_item_value_bool(const qd_dispatch_t *dispatch, const char *section, int index, const char* key);
 
 #endif

Modified: qpid/dispatch/trunk/src/config.c
URL: http://svn.apache.org/viewvc/qpid/dispatch/trunk/src/config.c?rev=1560815&r1=1560814&r2=1560815&view=diff
==============================================================================
--- qpid/dispatch/trunk/src/config.c (original)
+++ qpid/dispatch/trunk/src/config.c Thu Jan 23 21:29:00 2014
@@ -18,7 +18,7 @@
  */
 
 #include <qpid/dispatch/python_embedded.h>
-#include "config_private.h"
+#include "dispatch_private.h"
 #include <qpid/dispatch/alloc.h>
 #include <qpid/dispatch/log.h>
 
@@ -145,8 +145,9 @@ void qd_config_free(qd_config_t *config)
 }
 
 
-int qd_config_item_count(const qd_config_t *config, const char *section)
+int qd_config_item_count(const qd_dispatch_t *dispatch, const char *section)
 {
+    const qd_config_t *config = dispatch->config;
     PyObject *pSection;
     PyObject *pMethod;
     PyObject *pArgs;
@@ -181,8 +182,9 @@ int qd_config_item_count(const qd_config
 }
 
 
-static PyObject *item_value(const qd_config_t *config, const char *section, int index, const char* key, const char* method)
+static PyObject *item_value(const qd_dispatch_t *dispatch, const char *section, int index, const char* key, const char* method)
 {
+    const qd_config_t *config = dispatch->config;
     PyObject *pSection;
     PyObject *pIndex;
     PyObject *pKey;
@@ -217,9 +219,9 @@ static PyObject *item_value(const qd_con
 }
 
 
-const char *qd_config_item_value_string(const qd_config_t *config, const char *section, int index, const char* key)
+const char *qd_config_item_value_string(const qd_dispatch_t *dispatch, const char *section, int index, const char* key)
 {
-    PyObject *pResult = item_value(config, section, index, key, "value_string");
+    PyObject *pResult = item_value(dispatch, section, index, key, "value_string");
     char     *value   = 0;
 
     if (pResult && PyString_Check(pResult)) {
@@ -236,9 +238,9 @@ const char *qd_config_item_value_string(
 }
 
 
-uint32_t qd_config_item_value_int(const qd_config_t *config, const char *section, int index, const char* key)
+uint32_t qd_config_item_value_int(const qd_dispatch_t *dispatch, const char *section, int index, const char* key)
 {
-    PyObject *pResult = item_value(config, section, index, key, "value_int");
+    PyObject *pResult = item_value(dispatch, section, index, key, "value_int");
     uint32_t  value   = 0;
 
     if (pResult && PyLong_Check(pResult))
@@ -252,9 +254,9 @@ uint32_t qd_config_item_value_int(const 
 }
 
 
-int qd_config_item_value_bool(const qd_config_t *config, const char *section, int index, const char* key)
+int qd_config_item_value_bool(const qd_dispatch_t *dispatch, const char *section, int index, const char* key)
 {
-    PyObject *pResult = item_value(config, section, index, key, "value_bool");
+    PyObject *pResult = item_value(dispatch, section, index, key, "value_bool");
     int       value   = 0;
 
     if (pResult && pResult != Py_None)

Modified: qpid/dispatch/trunk/src/config_private.h
URL: http://svn.apache.org/viewvc/qpid/dispatch/trunk/src/config_private.h?rev=1560815&r1=1560814&r2=1560815&view=diff
==============================================================================
--- qpid/dispatch/trunk/src/config_private.h (original)
+++ qpid/dispatch/trunk/src/config_private.h Thu Jan 23 21:29:00 2014
@@ -21,6 +21,8 @@
 
 #include <qpid/dispatch/config.h>
 
+typedef struct qd_config_t qd_config_t;
+
 void qd_config_initialize(void);
 void qd_config_finalize(void);
 qd_config_t *qd_config(void);

Modified: qpid/dispatch/trunk/src/dispatch.c
URL: http://svn.apache.org/viewvc/qpid/dispatch/trunk/src/dispatch.c?rev=1560815&r1=1560814&r2=1560815&view=diff
==============================================================================
--- qpid/dispatch/trunk/src/dispatch.c (original)
+++ qpid/dispatch/trunk/src/dispatch.c Thu Jan 23 21:29:00 2014
@@ -88,10 +88,10 @@ void qd_dispatch_load_config(qd_dispatch
 void qd_dispatch_configure_container(qd_dispatch_t *qd)
 {
     if (qd->config) {
-        int count = qd_config_item_count(qd->config, CONF_CONTAINER);
+        int count = qd_config_item_count(qd, CONF_CONTAINER);
         if (count == 1) {
-            qd->thread_count   = qd_config_item_value_int(qd->config, CONF_CONTAINER, 0, "worker-threads");
-            qd->container_name = qd_config_item_value_string(qd->config, CONF_CONTAINER, 0, "container-name");
+            qd->thread_count   = qd_config_item_value_int(qd, CONF_CONTAINER, 0, "worker-threads");
+            qd->container_name = qd_config_item_value_string(qd, CONF_CONTAINER, 0, "container-name");
         }
     }
 
@@ -105,13 +105,13 @@ void qd_dispatch_configure_container(qd_
 
 void qd_dispatch_configure_router(qd_dispatch_t *qd)
 {
-    const char *router_mode_str;
+    const char *router_mode_str = 0;
 
     if (qd->config) {
-        int count = qd_config_item_count(qd->config, CONF_ROUTER);
+        int count = qd_config_item_count(qd, CONF_ROUTER);
         if (count == 1) {
-            router_mode_str = qd_config_item_value_string(qd->config, CONF_ROUTER, 0, "mode");
-            qd->router_id   = qd_config_item_value_string(qd->config, CONF_ROUTER, 0, "router-id");
+            router_mode_str = qd_config_item_value_string(qd, CONF_ROUTER, 0, "mode");
+            qd->router_id   = qd_config_item_value_string(qd, CONF_ROUTER, 0, "router-id");
         }
     }
 
@@ -158,27 +158,27 @@ void qd_dispatch_free(qd_dispatch_t *qd)
 
 static void load_server_config(qd_dispatch_t *qd, qd_server_config_t *config, const char *section, int i)
 {
-    config->host = qd_config_item_value_string(qd->config, section, i, "addr");
-    config->port = qd_config_item_value_string(qd->config, section, i, "port");
-    config->role = qd_config_item_value_string(qd->config, section, i, "role");
+    config->host = qd_config_item_value_string(qd, section, i, "addr");
+    config->port = qd_config_item_value_string(qd, section, i, "port");
+    config->role = qd_config_item_value_string(qd, section, i, "role");
     config->sasl_mechanisms =
-        qd_config_item_value_string(qd->config, section, i, "sasl-mechanisms");
+        qd_config_item_value_string(qd, section, i, "sasl-mechanisms");
     config->ssl_enabled =
-        qd_config_item_value_bool(qd->config, section, i, "ssl-profile");
+        qd_config_item_value_bool(qd, section, i, "ssl-profile");
     if (config->ssl_enabled) {
         config->ssl_server = 1;
         config->ssl_allow_unsecured_client =
-            qd_config_item_value_bool(qd->config, section, i, "allow-unsecured");
+            qd_config_item_value_bool(qd, section, i, "allow-unsecured");
         config->ssl_certificate_file =
-            qd_config_item_value_string(qd->config, section, i, "cert-file");
+            qd_config_item_value_string(qd, section, i, "cert-file");
         config->ssl_private_key_file =
-            qd_config_item_value_string(qd->config, section, i, "key-file");
+            qd_config_item_value_string(qd, section, i, "key-file");
         config->ssl_password =
-            qd_config_item_value_string(qd->config, section, i, "password");
+            qd_config_item_value_string(qd, section, i, "password");
         config->ssl_trusted_certificate_db =
-            qd_config_item_value_string(qd->config, section, i, "cert-db");
+            qd_config_item_value_string(qd, section, i, "cert-db");
         config->ssl_require_peer_authentication =
-            qd_config_item_value_bool(qd->config, section, i, "require-peer-auth");
+            qd_config_item_value_bool(qd, section, i, "require-peer-auth");
     }
 }
 
@@ -190,7 +190,7 @@ static void configure_listeners(qd_dispa
     if (!qd->config)
         return;
 
-    count = qd_config_item_count(qd->config, CONF_LISTENER);
+    count = qd_config_item_count(qd, CONF_LISTENER);
     for (int i = 0; i < count; i++) {
         qd_config_listener_t *cl = new_qd_config_listener_t();
         load_server_config(qd, &cl->configuration, CONF_LISTENER, i);
@@ -220,7 +220,7 @@ static void configure_connectors(qd_disp
     if (!qd->config)
         return;
 
-    count = qd_config_item_count(qd->config, CONF_CONNECTOR);
+    count = qd_config_item_count(qd, CONF_CONNECTOR);
     for (int i = 0; i < count; i++) {
         qd_config_connector_t *cc = new_qd_config_connector_t();
         load_server_config(qd, &cc->configuration, CONF_CONNECTOR, i);

Modified: qpid/dispatch/trunk/src/router_config.c
URL: http://svn.apache.org/viewvc/qpid/dispatch/trunk/src/router_config.c?rev=1560815&r1=1560814&r2=1560815&view=diff
==============================================================================
--- qpid/dispatch/trunk/src/router_config.c (original)
+++ qpid/dispatch/trunk/src/router_config.c Thu Jan 23 21:29:00 2014
@@ -29,18 +29,18 @@ static const char *MODULE       = "ROUTE
 
 void qd_router_configure(qd_router_t *router)
 {
-    if (!router->qd->config)
+    if (!router->qd)
         return;
 
-    int count = qd_config_item_count(router->qd->config, CONF_ADDRESS);
+    int count = qd_config_item_count(router->qd, CONF_ADDRESS);
 
     router->config_addr_count = count;
     router->config_addrs      = NEW_ARRAY(qd_config_address_t, count);
 
     for (int idx = 0; idx < count; idx++) {
-        const char *prefix = qd_config_item_value_string(router->qd->config, CONF_ADDRESS, idx, "prefix");
-        const char *fanout = qd_config_item_value_string(router->qd->config, CONF_ADDRESS, idx, "fanout");
-        const char *bias   = qd_config_item_value_string(router->qd->config, CONF_ADDRESS, idx, "bias");
+        const char *prefix = qd_config_item_value_string(router->qd, CONF_ADDRESS, idx, "prefix");
+        const char *fanout = qd_config_item_value_string(router->qd, CONF_ADDRESS, idx, "fanout");
+        const char *bias   = qd_config_item_value_string(router->qd, CONF_ADDRESS, idx, "bias");
         router->config_addrs[idx].prefix = (char*) malloc(strlen(prefix) + 1);
         if (prefix[0] == '/')
             strcpy(router->config_addrs[idx].prefix, &prefix[1]);



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org