qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kgiu...@apache.org
Subject qpid-proton git commit: NO-JIRA: fix reactor C examples for VS 10 build
Date Wed, 13 Apr 2016 15:12:59 GMT
Repository: qpid-proton
Updated Branches:
  refs/heads/master b47234bf5 -> 736920c8f


NO-JIRA: fix reactor C examples for VS 10 build


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/736920c8
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/736920c8
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/736920c8

Branch: refs/heads/master
Commit: 736920c8fdc861fc4035c47ceee65317ba599f5f
Parents: b47234b
Author: Ken Giusti <kgiusti@apache.org>
Authored: Wed Apr 13 10:56:08 2016 -0400
Committer: Ken Giusti <kgiusti@apache.org>
Committed: Wed Apr 13 11:08:07 2016 -0400

----------------------------------------------------------------------
 examples/c/reactor/receiver.c | 32 ++++++++++++++++++++------------
 examples/c/reactor/sender.c   | 37 +++++++++++++++++++++++--------------
 2 files changed, 43 insertions(+), 26 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/736920c8/examples/c/reactor/receiver.c
----------------------------------------------------------------------
diff --git a/examples/c/reactor/receiver.c b/examples/c/reactor/receiver.c
index 0948569..b13c5a0 100644
--- a/examples/c/reactor/receiver.c
+++ b/examples/c/reactor/receiver.c
@@ -80,11 +80,15 @@ static void event_handler(pn_handler_t *handler,
     case PN_CONNECTION_INIT: {
         // Create and open all the endpoints needed to send a message
         //
-        pn_connection_t *conn = pn_event_connection(event);
+        pn_connection_t *conn;
+        pn_session_t *ssn;
+        pn_link_t *receiver;
+
+        conn = pn_event_connection(event);
         pn_connection_open(conn);
-        pn_session_t *ssn = pn_session(conn);
+        ssn = pn_session(conn);
         pn_session_open(ssn);
-        pn_link_t *receiver = pn_receiver(ssn, "MyReceiver");
+        receiver = pn_receiver(ssn, "MyReceiver");
         pn_terminus_set_address(pn_link_source(receiver), data->source);
         pn_link_open(receiver);
         // cannot receive without granting credit:
@@ -94,6 +98,7 @@ static void event_handler(pn_handler_t *handler,
     case PN_DELIVERY: {
         // A message has been received
         //
+        pn_link_t *link = NULL;
         pn_delivery_t *dlv = pn_event_delivery(event);
         if (pn_delivery_readable(dlv) && !pn_delivery_partial(dlv)) {
             // A full message has arrived
@@ -122,7 +127,7 @@ static void event_handler(pn_handler_t *handler,
                 }
             }
 
-            pn_link_t *link = pn_delivery_link(dlv);
+            link = pn_delivery_link(dlv);
 
             if (!pn_delivery_settled(dlv)) {
                 // remote has not settled, so it is tracking the delivery.  Ack
@@ -142,8 +147,8 @@ static void event_handler(pn_handler_t *handler,
                 }
             } else if (--data->count == 0) {
                 // done receiving, close the endpoints
-                pn_link_close(link);
                 pn_session_t *ssn = pn_link_session(link);
+				pn_link_close(link);
                 pn_session_close(ssn);
                 pn_connection_close(pn_session_connection(ssn));
             }
@@ -187,6 +192,10 @@ int main(int argc, char** argv)
 {
     char *address = "localhost";
     char *container = "ReceiveExample";
+    int c;
+    pn_reactor_t *reactor = NULL;
+    pn_url_t *url = NULL;
+    pn_connection_t *conn = NULL;
 
     /* create a handler for the connection's events.
      * event_handler will be called for each event.  The handler will allocate
@@ -211,7 +220,6 @@ int main(int argc, char** argv)
 
     /* command line options */
     opterr = 0;
-    int c;
     while((c = getopt(argc, argv, "i:a:c:s:qh")) != -1) {
         switch(c) {
         case 'h': usage(); break;
@@ -229,17 +237,17 @@ int main(int argc, char** argv)
         }
     }
 
-    pn_reactor_t *reactor = pn_reactor();
+    reactor = pn_reactor();
 
-    pn_url_t *url = pn_url_parse(address);
+    url = pn_url_parse(address);
     if (url == NULL) {
         fprintf(stderr, "Invalid host address %s\n", address);
         exit(1);
     }
-    pn_connection_t *conn = pn_reactor_connection_to_host(reactor,
-                                                          pn_url_get_host(url),
-                                                          pn_url_get_port(url),
-                                                          handler);
+    conn = pn_reactor_connection_to_host(reactor,
+                                         pn_url_get_host(url),
+                                         pn_url_get_port(url),
+                                         handler);
     pn_decref(url);
 
     // the container name should be unique for each client

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/736920c8/examples/c/reactor/sender.c
----------------------------------------------------------------------
diff --git a/examples/c/reactor/sender.c b/examples/c/reactor/sender.c
index e1f73dc..02828ac 100644
--- a/examples/c/reactor/sender.c
+++ b/examples/c/reactor/sender.c
@@ -78,11 +78,15 @@ static void event_handler(pn_handler_t *handler,
     case PN_CONNECTION_INIT: {
         // Create and open all the endpoints needed to send a message
         //
-        pn_connection_t *conn = pn_event_connection(event);
+        pn_connection_t *conn;
+        pn_session_t *ssn;
+        pn_link_t *sender;
+
+        conn = pn_event_connection(event);
         pn_connection_open(conn);
-        pn_session_t *ssn = pn_session(conn);
+        ssn = pn_session(conn);
         pn_session_open(ssn);
-        pn_link_t *sender = pn_sender(ssn, "MySender");
+        sender = pn_sender(ssn, "MySender");
         // we do not wait for ack until the last message
         pn_link_set_snd_settle_mode(sender, PN_SND_MIXED);
         if (!data->anon) {
@@ -95,13 +99,13 @@ static void event_handler(pn_handler_t *handler,
         // the remote has given us some credit, now we can send messages
         //
         static long tag = 0;  // a simple tag generator
+        pn_delivery_t *delivery;
         pn_link_t *sender = pn_event_link(event);
         int credit = pn_link_credit(sender);
         while (credit > 0 && data->count > 0) {
             --credit;
             --data->count;
             ++tag;
-            pn_delivery_t *delivery;
             delivery = pn_delivery(sender,
                                    pn_dtag((const char *)&tag, sizeof(tag)));
             pn_link_send(sender, data->msg_data, data->msg_len);
@@ -152,8 +156,8 @@ static void event_handler(pn_handler_t *handler,
             if (done) {
                 // initiate clean shutdown of the endpoints
                 pn_link_t *link = pn_delivery_link(dlv);
-                pn_link_close(link);
                 pn_session_t *ssn = pn_link_session(link);
+                pn_link_close(link);
                 pn_session_close(ssn);
                 pn_connection_close(pn_session_connection(ssn));
             }
@@ -202,6 +206,11 @@ int main(int argc, char** argv)
     char *container = "SendExample";
     int anon = 0;
     int c;
+    pn_message_t *message = NULL;
+    pn_data_t *body = NULL;
+    pn_reactor_t *reactor = NULL;
+    pn_url_t *url = NULL;
+    pn_connection_t *conn = NULL;
 
     /* Create a handler for the connection's events.  event_handler() will be
      * called for each event and delete_handler will be called when the
@@ -249,9 +258,9 @@ int main(int argc, char** argv)
     // once.  All transmits will use the same pre-encoded message simply for
     // speed.
     //
-    pn_message_t *message = pn_message();
+    message = pn_message();
     pn_message_set_address(message, app_data->target);
-    pn_data_t *body = pn_message_body(message);
+    body = pn_message_body(message);
     pn_data_clear(body);
 
     // This message's body contains a single string
@@ -271,7 +280,7 @@ int main(int argc, char** argv)
             if (rc == PN_OVERFLOW) {
                 free(buf);
                 len *= 2;
-                buf = malloc(len);
+                buf = (char *)malloc(len);
             }
         } while (rc == PN_OVERFLOW);
         app_data->msg_len = len;
@@ -279,17 +288,17 @@ int main(int argc, char** argv)
     }
     pn_decref(message);   // message no longer needed
 
-    pn_reactor_t *reactor = pn_reactor();
+    reactor = pn_reactor();
 
-    pn_url_t *url = pn_url_parse(address);
+    url = pn_url_parse(address);
     if (url == NULL) {
         fprintf(stderr, "Invalid host address %s\n", address);
         exit(1);
     }
-    pn_connection_t *conn = pn_reactor_connection_to_host(reactor,
-                                                          pn_url_get_host(url),
-                                                          pn_url_get_port(url),
-                                                          handler);
+    conn = pn_reactor_connection_to_host(reactor,
+                                         pn_url_get_host(url),
+                                         pn_url_get_port(url),
+                                         handler);
     pn_decref(url);
 
     // the container name should be unique for each client


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


Mime
View raw message