doc(code): Indent fixes and whitespace cleanup 75/75/1
authorE. Scott Daniels <daniels@research.att.com>
Tue, 23 Apr 2019 12:59:28 +0000 (12:59 +0000)
committerE. Scott Daniels <daniels@research.att.com>
Tue, 23 Apr 2019 12:59:28 +0000 (12:59 +0000)
Change-Id: I05a1cd543ba0603446244122337276028e199382
Signed-off-by: E. Scott Daniels <daniels@research.att.com>
38 files changed:
examples/receiver.c
examples/sender.c
src/common/include/rmr.h
src/common/include/rmr_agnostic.h
src/common/include/rmr_symtab.h
src/common/src/mbuf_api.c
src/common/src/ring_static.c
src/common/src/rt_generic_static.c
src/common/src/rtc_static.c
src/common/src/symtab.c
src/common/src/tools_static.c
src/common/src/wormholes.c
src/nanomsg/include/rmr_private.h
src/nanomsg/src/rmr.c
src/nanomsg/src/rtable_static.c
src/nanomsg/src/sr_static.c
src/nng/include/rmr_nng_private.h
src/nng/src/rmr_nng.c
src/nng/src/rtable_nng_static.c
src/nng/src/sr_nng_static.c
test/app_test/receiver.c
test/app_test/sender.c
test/hdr_static_test.c
test/mbuf_api_static_test.c
test/mbuf_api_test.c
test/ring_static_test.c
test/ring_test.c
test/rmr_nng_api_static_test.c
test/rmr_nng_test.c
test/rt_static_test.c
test/sr_nng_static_test.c
test/symtab_static_test.c
test/symtab_test.c
test/test_nng_em.c
test/test_support.c
test/tools_static_test.c
test/tools_test.c
test/wormhole_static_test.c

index 1808f33..6d31bb2 100644 (file)
@@ -1,14 +1,14 @@
 // :vim ts=4 sw=4 noet:
 /*
 ==================================================================================
-    Copyright (c) 2019 Nokia
-    Copyright (c) 2018-2019 AT&T Intellectual Property.
+       Copyright (c) 2019 Nokia
+       Copyright (c) 2018-2019 AT&T Intellectual Property.
 
    Licensed 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
+          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,
@@ -49,9 +49,9 @@
 
 
 int main( int argc, char** argv ) {
-    void* mrc;                                         // msg router context
+       void* mrc;                                              // msg router context
        long long total = 0;
-    rmr_mbuf_t* msg = NULL;                            // message received
+       rmr_mbuf_t* msg = NULL;                         // message received
        int stat_freq = 10;                             // write stats after reciving this many messages
        int i;
        char*   listen_port;
@@ -68,7 +68,7 @@ int main( int argc, char** argv ) {
        fprintf( stderr, "<DEMO> listening on port: %s\n", listen_port );
        fprintf( stderr, "<DEMO> stats will be reported every %d messages\n", stat_freq );
 
-    mrc = rmr_init( listen_port, RMR_MAX_RCV_BYTES, RMRFL_NONE );      // start your engines!
+       mrc = rmr_init( listen_port, RMR_MAX_RCV_BYTES, RMRFL_NONE );   // start your engines!
        if( mrc == NULL ) {
                fprintf( stderr, "<DEMO> ABORT:  unable to initialise RMr\n" );
                exit( 1 );
@@ -80,7 +80,7 @@ int main( int argc, char** argv ) {
        }
        fprintf( stderr, "<DEMO> rmr now shows ready\n" );
 
-    while( 1 ) {                                                                                       // forever; ctl-c, kill -15, etc to end
+       while( 1 ) {                                                                                    // forever; ctl-c, kill -15, etc to end
                msg = rmr_rcv_msg( mrc, msg );                                          // block until one arrives
                
                if( msg ) {
@@ -97,6 +97,6 @@ int main( int argc, char** argv ) {
                        fprintf( stderr, "<DEMO> total msg received: %lld  errors: %lld   empty: %lld\n", count, bad, empty );
                }
 
-    }
+       }
 }
 
index 25bba73..dd8a1e0 100644 (file)
@@ -1,14 +1,14 @@
 // :vim ts=4 sw=4 noet:
 /*
 ==================================================================================
-    Copyright (c) 2019 Nokia
-    Copyright (c) 2018-2019 AT&T Intellectual Property.
+       Copyright (c) 2019 Nokia
+       Copyright (c) 2018-2019 AT&T Intellectual Property.
 
    Licensed 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
+          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,
 #include <rmr/rmr.h>
 
 int main( int argc, char** argv ) {
-    void* mrc;                                                 //msg router context
-    struct epoll_event events[1];                      // list of events to give to epoll
-    struct epoll_event epe;                 // event definition for event to listen to
-    int     ep_fd = -1;                                                // epoll's file des (given to epoll_wait)
-    int rcv_fd;                                                // file des that NNG tickles -- give this to epoll to listen on
+       void* mrc;                                                      //msg router context
+       struct epoll_event events[1];                   // list of events to give to epoll
+       struct epoll_event epe;                 // event definition for event to listen to
+       int     ep_fd = -1;                                             // epoll's file des (given to epoll_wait)
+       int rcv_fd;                                                     // file des that NNG tickles -- give this to epoll to listen on
        int nready;                                                             // number of events ready for receive
        rmr_mbuf_t*             sbuf;                                   // send buffer
        rmr_mbuf_t*             rbuf;                                   // received buffer
@@ -74,12 +74,12 @@ int main( int argc, char** argv ) {
 
        fprintf( stderr, "<DEMO> listen port: %s; mtype: %d; delay: %d\n", listen_port, mtype, delay );
 
-    if( (mrc = rmr_init( listen_port, 1400, RMRFL_NONE )) == NULL ) {
+       if( (mrc = rmr_init( listen_port, 1400, RMRFL_NONE )) == NULL ) {
                fprintf( stderr, "<DEMO> unable to initialise RMr\n" );
                exit( 1 );
        }
 
-    rcv_fd = rmr_get_rcvfd( mrc );                                     // set up epoll things, start by getting the FD from MRr
+       rcv_fd = rmr_get_rcvfd( mrc );                                  // set up epoll things, start by getting the FD from MRr
        if( rcv_fd < 0 ) {
                fprintf( stderr, "<DEMO> unable to set up polling fd\n" );
                exit( 1 );
@@ -88,10 +88,10 @@ int main( int argc, char** argv ) {
                fprintf( stderr, "[FAIL] unable to create epoll fd: %d\n", errno );
                exit( 1 );
        }
-    epe.events = EPOLLIN;
-    epe.data.fd = rcv_fd;
+       epe.events = EPOLLIN;
+       epe.data.fd = rcv_fd;
 
-    if( epoll_ctl( ep_fd, EPOLL_CTL_ADD, rcv_fd, &epe ) != 0 )  {
+       if( epoll_ctl( ep_fd, EPOLL_CTL_ADD, rcv_fd, &epe ) != 0 )  {
                fprintf( stderr, "[FAIL] epoll_ctl status not 0 : %s\n", strerror( errno ) );
                exit( 1 );
        }
@@ -105,7 +105,7 @@ int main( int argc, char** argv ) {
        fprintf( stderr, "<DEMO> rmr is ready\n" );
        
 
-    while( 1 ) {                                                                               // send messages until the cows come home
+       while( 1 ) {                                                                            // send messages until the cows come home
                snprintf( sbuf->payload, 200, "count=%d received= %d ts=%lld %d stand up and cheer!",   // create the payload
                        count, rcvd_count, (long long) time( NULL ), rand() );
 
@@ -133,6 +133,6 @@ int main( int argc, char** argv ) {
                }
 
                usleep( delay );
-    }
+       }
 }
 
index 4e662ef..6bfe075 100644 (file)
@@ -1,14 +1,14 @@
 // : vi ts=4 sw=4 noet :
 /*
 ==================================================================================
-       Copyright (c) 2019 Nokia 
+       Copyright (c) 2019 Nokia
        Copyright (c) 2018-2019 AT&T Intellectual Property.
 
    Licensed 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
+          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,
@@ -82,7 +82,7 @@ typedef struct {
        int sub_id;                                     // subscription id
 
                                                                // these things are off limits to the user application
-       void*   tp_buf;                         // underlying transport allocated pointer (e.g. nng message)    
+       void*   tp_buf;                         // underlying transport allocated pointer (e.g. nng message)
        void*   header;                         // internal message header (whole buffer: header+payload)
        unsigned char* id;                      // if we need an ID in the message separate from the xaction id
        int             flags;                          // various MFL_ (private) flags as needed
@@ -141,23 +141,23 @@ extern int rmr_send_to( void* vctx, int time );           // DEPRECATED -- replaced with
 #ifdef UTA_COMPAT
 #pragma message( "use of UTA_COMPAT is deprecated and soon to be removed" )
 
-#define UTA_MAX_XID RMR_MAX_XID 
-#define UTA_MAX_SID    RMR_MAX_SID 
-#define UTA_MAX_SRC RMR_MAX_SRC 
-#define UTA_MAX_RCV_BYTES RMR_MAX_RCV_BYTES 
+#define UTA_MAX_XID RMR_MAX_XID
+#define UTA_MAX_SID    RMR_MAX_SID
+#define UTA_MAX_SRC RMR_MAX_SRC
+#define UTA_MAX_RCV_BYTES RMR_MAX_RCV_BYTES
 
-#define UTAFL_NONE             RMRFL_NONE 
-#define UTAFL_AUTO_ALLOC RMRFL_AUTO_ALLOC 
+#define UTAFL_NONE             RMRFL_NONE
+#define UTAFL_AUTO_ALLOC RMRFL_AUTO_ALLOC
 
-#define UTA_DEF_SIZE   RMRFL_AUTO_ALLOC 
+#define UTA_DEF_SIZE   RMRFL_AUTO_ALLOC
 
-#define UTA_OK                  RMR_OK 
-#define UTA_ERR_BADARG RMR_ERR_BADARG 
-#define UTA_ERR_NOENDPT RMR_ERR_NOENDPT        
+#define UTA_OK                  RMR_OK
+#define UTA_ERR_BADARG RMR_ERR_BADARG
+#define UTA_ERR_NOENDPT RMR_ERR_NOENDPT
 #define UTA_ERR_EMPTY  RMR_ERR_EMPTY
-#define UTA_ERR_NOHDR  RMR_ERR_NOHDR 
-#define UTA_ERR_SENDFAILED RMR_ERR_SENDFAILED 
-#define UTA_ERR_CALLFAILED RMR_ERR_CALLFAILED 
+#define UTA_ERR_NOHDR  RMR_ERR_NOHDR
+#define UTA_ERR_SENDFAILED RMR_ERR_SENDFAILED
+#define UTA_ERR_CALLFAILED RMR_ERR_CALLFAILED
 
 #define uta_mbuf_t rmr_mbuf_t
 
index c25a535..a23cff7 100644 (file)
@@ -1,14 +1,14 @@
 // : vi ts=4 sw=4 noet :
 /*
 ==================================================================================
-       Copyright (c) 2019 Nokia 
+       Copyright (c) 2019 Nokia
        Copyright (c) 2018-2019 AT&T Intellectual Property.
 
    Licensed 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
+          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,
@@ -47,7 +47,7 @@ typedef struct uta_ctx  uta_ctx_t;
 #define RMR_MSG_VER    2                       // message version this code was designed to handle
 
                                                                        // environment variable names we'll suss out
-#define ENV_BIND_IF "RMR_BIND_IF"      // the interface to bind to for both normal comma and RTG (0.0.0.0 if missing) 
+#define ENV_BIND_IF "RMR_BIND_IF"      // the interface to bind to for both normal comma and RTG (0.0.0.0 if missing)
 #define ENV_RTG_PORT "RMR_RTG_SVC"     // the port we'll listen on for rtg connections
 #define ENV_SEED_RT    "RMR_SEED_RT"   // where we expect to find the name of the seed route table
 #define ENV_RTG_RAW "RMR_RTG_ISRAW"    // if > 0 we expect route table gen messages as raw (not sent from an RMr application)
@@ -132,7 +132,7 @@ typedef struct {
        struct timespec ts;                                     // timestamp ???
 
                                                                                // V2 extension
-       int32_t flags;                                          // HFL_* constants      
+       int32_t flags;                                          // HFL_* constants
        int32_t len0;                                           // length of the RMr header data
        int32_t len1;                                           // length of the tracing data
        int32_t len2;                                           // length of data 1 (d1)
@@ -181,7 +181,7 @@ typedef struct {
 } route_table_t;
 
 /*
-       A wormhole is a direct connection between two endpoints that the user app can 
+       A wormhole is a direct connection between two endpoints that the user app can
        send to without message type based routing.
 */
 typedef struct {
index 95fa153..7d4d18c 100644 (file)
@@ -1,14 +1,14 @@
 // : vi ts=4 sw=4 noet :
 /*
 ==================================================================================
-       Copyright (c) 2019 Nokia 
+       Copyright (c) 2019 Nokia
        Copyright (c) 2018-2019 AT&T Intellectual Property.
 
    Licensed 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
+          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,
index 4b6d218..e801ac9 100644 (file)
@@ -1,14 +1,14 @@
 // : vi ts=4 sw=4 noet :
 /*
 ==================================================================================
-       Copyright (c) 2019 Nokia 
+       Copyright (c) 2019 Nokia
        Copyright (c) 2018-2019 AT&T Intellectual Property.
 
    Licensed 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
+          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,
@@ -20,8 +20,8 @@
 
 /*
        Mnemonic:       mbuf_api.c
-       Abstract:       These are common functions which work only on the mbuf and 
-                               thus (because they do not touch an endpoint or context) 
+       Abstract:       These are common functions which work only on the mbuf and
+                               thus (because they do not touch an endpoint or context)
                                can be agnostic to the underlying transport.
 
        Author:         E. Scott Daniels
 // ---------- some wrappers need explicit copy-in functions, also header field setters -----
 
 /*
-       Allow the user programme to set the meid in the header.  The meid is a fixed 
+       Allow the user programme to set the meid in the header.  The meid is a fixed
        length buffer in the header and thus we must ensure it is not overrun. If
        the  user gives a source buffer that is too large, we truncate. The return
        value is the number of bytes copied, or -1 for absolute failure (bad pointer
        etc.).  Errno is set:
                EINVAL id poitner, buf or buf header are bad.
                EOVERFLOW if the bytes given would have overrun
-       
+
 */
 extern int rmr_bytes2meid( rmr_mbuf_t* mbuf, unsigned char const* src, int len ) {
        uta_mhdr_t* hdr;
@@ -91,7 +91,7 @@ extern int rmr_str2meid( rmr_mbuf_t* mbuf, unsigned char const* str ) {
                errno = EOVERFLOW;
                return RMR_ERR_OVERFLOW;
        }
-       
+
        rmr_bytes2meid( mbuf, str, len+1 );
        return RMR_OK;
 }
@@ -100,7 +100,7 @@ extern int rmr_str2meid( rmr_mbuf_t* mbuf, unsigned char const* str ) {
 
 /*
        This will copy n bytes from source into the payload. If len is larger than
-       the payload only the bytes which will fit are copied, The user should 
+       the payload only the bytes which will fit are copied, The user should
        check errno on return to determine success or failure.
 */
 extern void rmr_bytes2payload( rmr_mbuf_t* mbuf, unsigned char const* src, int len ) {
@@ -138,7 +138,7 @@ extern void rmr_str2payload( rmr_mbuf_t* mbuf, unsigned char const* str ) {
        etc.).  Errno is set:
                EINVAL id poitner, buf or buf header are bad.
                EOVERFLOW if the bytes given would have overrun
-       
+
 */
 extern int rmr_bytes2xact( rmr_mbuf_t* mbuf, unsigned char const* src, int len ) {
        uta_mhdr_t* hdr;
@@ -182,7 +182,7 @@ extern int rmr_str2xact( rmr_mbuf_t* mbuf, unsigned char const* str ) {
                errno = EOVERFLOW;
                return RMR_ERR_OVERFLOW;
        }
-       
+
        rmr_bytes2xact( mbuf, str, len+1 );
        return RMR_OK;
 }
@@ -219,7 +219,7 @@ extern unsigned char*  rmr_get_meid( rmr_mbuf_t* mbuf, unsigned char* dest ) {
 
 // ------------------- trace related access functions --------------------------------------
 /*
-       The set_trace function will copy the supplied data for size bytes into the 
+       The set_trace function will copy the supplied data for size bytes into the
        header.  If the header trace area is not large enough, a new one will be allocated
        which will cause a payload copy based on the msg->len value (if 0 no payload
        data is copied).
@@ -244,7 +244,7 @@ extern int rmr_set_trace( rmr_mbuf_t* msg, unsigned const char* data, int size )
        if( size <= 0 ) {
                return 0;
        }
-       
+
        hdr = (uta_mhdr_t *) msg->header;
        len = RMR_TR_LEN( hdr );
 
@@ -268,13 +268,13 @@ extern int rmr_set_trace( rmr_mbuf_t* msg, unsigned const char* data, int size )
        }
 
        memcpy( TRACE_ADDR( hdr ), data, size );
-       
+
        return size;
 }
 
 
 /*
-       Copies the trace bytes from the message header into the buffer provided by 
+       Copies the trace bytes from the message header into the buffer provided by
        the user. If the trace data in the header is less than size, then only
        that number of bytes are copied, else exactly size bytes are copied. The
        number actually copied is returned.
index 2d29dbd..dafc946 100644 (file)
@@ -1,14 +1,14 @@
 // :vi sw=4 ts=4 noet:
 /*
 ==================================================================================
-       Copyright (c) 2019 Nokia 
+       Copyright (c) 2019 Nokia
        Copyright (c) 2018-2019 AT&T Intellectual Property.
 
    Licensed 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
+          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,
@@ -19,7 +19,7 @@
 */
 /*
        Mnemonic:       ring_static.c
-       Abstract:       Implements a ring of information (probably to act as a 
+       Abstract:       Implements a ring of information (probably to act as a
                                message queue).
        Author:         E. Scott Daniels
        Date:           31 August 2017
index 26e907e..4dd9344 100644 (file)
@@ -1,14 +1,14 @@
 // :vi sw=4 ts=4 noet:
 /*
 ==================================================================================
-       Copyright (c) 2019 Nokia 
+       Copyright (c) 2019 Nokia
        Copyright (c) 2018-2019 AT&T Intellectual Property.
 
    Licensed 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
+          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,
 
 /*
        Mnemonic:       rt_generic_static.c
-       Abstract:       These are route table functions which are not specific to the 
+       Abstract:       These are route table functions which are not specific to the
                                underlying protocol.  rtable_static, and rtable_nng_static
                                have transport provider specific code.
 
                                This file must be included before the nng/nano specific file as
-                               it defines types. 
+                               it defines types.
 
        Author:         E. Scott Daniels
        Date:           5  February 2019
@@ -47,7 +47,7 @@
 
 
 /*
-       Passed to a symtab foreach callback to construct a list of pointers from 
+       Passed to a symtab foreach callback to construct a list of pointers from
        a current symtab.
 */
 typedef struct thing_list {
@@ -95,9 +95,9 @@ static rtable_ent_t* uta_add_rte( route_table_t* rt, int mtype, int nrrgroups )
 
 /*
        Parse a single record recevied from the route table generator, or read
-       from a static route table file.  Start records cause a new table to 
+       from a static route table file.  Start records cause a new table to
        be started (if a partial table was received it is discarded. Table
-       entry records are added to the currenly 'in progress' table, and an 
+       entry records are added to the currenly 'in progress' table, and an
        end record causes the in progress table to be finalised and the
        currently active table is replaced.
 */
@@ -144,7 +144,7 @@ static void parse_rt_rec( uta_ctx_t* ctx, char* buf, int vlevel ) {
                                        if( ctx->new_rtable != NULL ) {                                 // one in progress?  this forces it out
                                                if( DEBUG > 1 || (vlevel > 1) ) fprintf( stderr, "[DBUG] new table; dropping incomplete table\n" );
                                                uta_rt_drop( ctx->new_rtable );
-                                       }       
+                                       }
 
                                        if( ctx->rtable )  {
                                                ctx->new_rtable = uta_rt_clone( ctx->rtable );  // create by cloning endpoint entries from active table
@@ -162,10 +162,10 @@ static void parse_rt_rec( uta_ctx_t* ctx, char* buf, int vlevel ) {
 
                                if( ((tok = strchr( tokens[1], ',' )) == NULL ) ||                                      // no sender names
                                        (uta_has_str( tokens[1],  ctx->my_name, ',', 127) >= 0) ||              // our name isn't in the list
-                                       has_myip( tokens[1], ctx->ip_list, ',', 127 ) ) {                               // the list has one of our IP addresses 
+                                       has_myip( tokens[1], ctx->ip_list, ',', 127 ) ) {                               // the list has one of our IP addresses
 
                                        if( DEBUG > 1 || (vlevel > 1) ) fprintf( stderr, "[DBUG] create rte for mtype=%s\n", tokens[1] );
-                                       
+
                                        if( (ngtoks = uta_tokenise( tokens[2], gtokens, 64, ';' )) > 0 ) {                                      // split last field by groups first
                                                rte = uta_add_rte( ctx->new_rtable, atoi( tokens[1] ), ngtoks );                        // get/create entry for message type
                                                for( grp = 0; grp < ngtoks; grp++ ) {
@@ -178,7 +178,7 @@ static void parse_rt_rec( uta_ctx_t* ctx, char* buf, int vlevel ) {
                                                }
                                        }
                                } else {
-                                       if( DEBUG || (vlevel > 2) ) 
+                                       if( DEBUG || (vlevel > 2) )
                                                fprintf( stderr, "entry not included, sender not matched: %s\n", tokens[1] );
                                }
 
@@ -195,9 +195,9 @@ static void parse_rt_rec( uta_ctx_t* ctx, char* buf, int vlevel ) {
        This function attempts to open a static route table in order to create a 'seed'
        table during initialisation.  The environment variable RMR_SEED_RT is expected
        to contain the necessary path to the file. If missing, or if the file is empty,
-       no route table will be available until one is received from the generator. 
+       no route table will be available until one is received from the generator.
 
-       This function is probably most useful for testing situations, or extreme 
+       This function is probably most useful for testing situations, or extreme
        cases where the routes are static.
 */
 static void read_static_rt( uta_ctx_t* ctx, int vlevel ) {
@@ -250,8 +250,8 @@ static void collect_things( void* st, void* entry, char const* name, void* thing
 }
 
 /*
-       Called to delete a route table entry struct. We delete the array of endpoint 
-       pointers, but NOT the endpoints referenced as those are referenced from 
+       Called to delete a route table entry struct. We delete the array of endpoint
+       pointers, but NOT the endpoints referenced as those are referenced from
        multiple entries.
 */
 static void del_rte( void* st, void* entry, char const* name, void* thing, void* data ) {
@@ -291,7 +291,7 @@ static char* uta_fib( char* fname ) {
        off_t           nread;                  // number of bytes read
        int                     fd;
        char*           buf;                    // input buffer
-       
+
        if( (fd = open( fname, O_RDONLY )) >= 0 ) {
                if( fstat( fd, &stats ) >= 0 ) {
                        if( stats.st_size <= 0 ) {                                      // empty file
@@ -362,7 +362,7 @@ static route_table_t* uta_rt_init( ) {
        the context.
 */
 static route_table_t* uta_rt_clone( route_table_t* srt ) {
-       endpoint_t*             ep;             // an endpoint 
+       endpoint_t*             ep;             // an endpoint
        route_table_t*  nrt;    // new route table
        route_table_t*  art;    // active route table
        void*   sst;                    // source symtab
@@ -396,7 +396,7 @@ static route_table_t* uta_rt_clone( route_table_t* srt ) {
        nst = nrt->hash;
 
        rmr_sym_foreach_class( sst, 1, collect_things, &things );               // collect the named endpoints in the active table
-       
+
        for( i = 0; i < things.nused; i++ ) {
                ep = (endpoint_t *) things.things[i];
                rmr_sym_put( nst, ep->name, 1, ep );                                            // slam this one into the new table
index 9f0d1a6..013dc8d 100644 (file)
@@ -8,7 +8,7 @@
    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
+          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,
@@ -84,7 +84,7 @@ static void* rtc( void* vctx ) {
        char*   port;                                           // a port number we listen/connect to
        char*   fport;                                          // pointer to the real buffer to free
        size_t  buf_size;                                       // nng needs var pointer not just size?
-       char*   nextr;                                          // pointer at next record in the message        
+       char*   nextr;                                          // pointer at next record in the message
        char*   curr;                                           // current record
        int     i;
        long    blabber = 0;                            // time of last blabber so we don't flood if rtg goes bad
@@ -106,7 +106,7 @@ static void* rtc( void* vctx ) {
        }
 
        if( (eptr = getenv( ENV_VERBOSE_FILE )) != NULL ) {
-               vfd = open( eptr, O_RDONLY ); 
+               vfd = open( eptr, O_RDONLY );
                if( vfd >= 0 ) {
                        wbuf[0] = 0;
                        lseek( vfd, 0, 0 );
@@ -131,7 +131,7 @@ static void* rtc( void* vctx ) {
 
        ntoks = uta_tokenise( port, tokens, 120, ':' );                 // assume tcp:port, but it could be port or old style host:port
        switch( ntoks ) {
-               case 1: 
+               case 1:
                                port = tokens[0];                       // just the port
                                break;
 
@@ -196,19 +196,19 @@ static void* rtc( void* vctx ) {
                        curr = pbuf;
                        while( curr ) {                                                         // loop over each record in the buffer
                                nextr = strchr( curr, '\n' );                   // allow multiple newline records, find end of current and mark
-       
+
                                if( nextr ) {
                                        *(nextr++) = 0;
                                }
-       
+
                                if( vlevel > 1 ) {
                                        fprintf( stderr, "[DBUG] rmr_rtc: processing (%s)\n", curr );
                                }
                                parse_rt_rec( ctx, curr, vlevel );              // parse record and add to in progress table
-               
+
                                curr = nextr;
                        }
-       
+
                        if( ctx->shutdown ) {           // mostly for testing, but allows user app to close us down if rmr_*() function sets this
                                break;
                        }
index b780d9e..a1a792d 100644 (file)
@@ -1,14 +1,14 @@
 // : vi ts=4 sw=4 noet :
 /*
 ==================================================================================
-       Copyright (c) 2019 Nokia 
+       Copyright (c) 2019 Nokia
        Copyright (c) 2018-2019 AT&T Intellectual Property.
 
    Licensed 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
+          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,
 ------------------------------------------------------------------------------
 Mnemonic:      symtab.c
 Abstract:      Symbol table -- slightly streamlined from it's original 2000 version
-                       (a part of the {X}fm opensource code), though we must retain the 
+                       (a part of the {X}fm opensource code), though we must retain the
                        original copyright.
 
                        Things changed for the Ric Msg implemention (Nov 2018):
                                - no concept of copy/free of the user data (functions removed)
                                - add ability to support an integer key (class 0)
                                - externally visible names given a rmr_ extension as it's being
-                                 incorporated into the RIC msg routing library and will be 
+                                 incorporated into the RIC msg routing library and will be
                                  available to user applications.
 
 Date:          11 Feb 2000
@@ -60,7 +60,7 @@ typedef struct Sym_ele
        void *val;              /* user data associated with name */
        unsigned long mcount;   /* modificaitons to value */
        unsigned long rcount;   /* references to symbol */
-       //unsigned int flags; 
+       //unsigned int flags;
        unsigned int class;             /* helps divide things up and allows for duplicate names */
 } Sym_ele;
 
@@ -68,7 +68,7 @@ typedef struct Sym_tab {
        Sym_ele **symlist;                      /* pointer to list of element pointerss */
        long    inhabitants;            /* number of active residents */
        long    deaths;                         /* number of deletes */
-       long    size;   
+       long    size;
 } Sym_tab;
 
 // -------------------- internal ------------------------------------------------------------------
@@ -107,7 +107,7 @@ static void del_ele( Sym_tab *table, int hv, Sym_ele *eptr )
                        eptr->next->prev = eptr->prev;
 
                if( eptr->class && eptr->name ) {                               // class 0 entries are numeric, so name is NOT a pointer
-                       free( (void *) eptr->name );                    // and if free fails, what?  panic? 
+                       free( (void *) eptr->name );                    // and if free fails, what?  panic?
                }
 
                free( eptr );
@@ -130,14 +130,14 @@ static inline int same( unsigned int c1, unsigned int c2, const char *s1, const
        return 0;
 }
 
-/*     
+/*
        Generic routine to put something into the table
        called by sym_map or sym_put since the logic for each is pretty
        much the same.
 */
 static int putin( Sym_tab *table, const char *name, unsigned int class, void *val ) {
-       Sym_ele *eptr;          /* pointer into hash table */ 
-       Sym_ele **sym_tab;      /* pointer into hash table */ 
+       Sym_ele *eptr;          /* pointer into hash table */
+       Sym_ele **sym_tab;      /* pointer into hash table */
        int hv;                  /* hash value */
        int rc = 0;              /* assume it existed */
        unsigned int    nkey = 0;       // numeric key if class == 0
@@ -156,12 +156,12 @@ static int putin( Sym_tab *table, const char *name, unsigned int class, void *va
        if( ! eptr ) {                  // not found above, so add
                rc++;
                table->inhabitants++;
-       
+
                eptr = (Sym_ele *) malloc( sizeof( Sym_ele) );
                if( ! eptr ) {
                        fprintf( stderr, "[FAIL] symtab/putin: out of memory\n" );
                        return -1;
-               } 
+               }
 
                eptr->prev = NULL;
                eptr->class = class;
@@ -193,13 +193,13 @@ extern void rmr_sym_clear( void *vtable )
 {
        Sym_tab *table;
        Sym_ele **sym_tab;
-       int i; 
+       int i;
 
        table = (Sym_tab *) vtable;
        sym_tab = table->symlist;
 
        for( i = 0; i < table->size; i++ )
-               while( sym_tab[i] ) 
+               while( sym_tab[i] )
                        del_ele( table, i, sym_tab[i] );
 }
 
@@ -222,7 +222,7 @@ extern void rmr_sym_free( void *vtable ) {
 extern void rmr_sym_dump( void *vtable )
 {
        Sym_tab *table;
-       int i; 
+       int i;
        Sym_ele *eptr;
        Sym_ele **sym_tab;
 
@@ -232,7 +232,7 @@ extern void rmr_sym_dump( void *vtable )
        for( i = 0; i < table->size; i++ )
        {
                if( sym_tab[i] )
-               for( eptr = sym_tab[i]; eptr; eptr = eptr->next )  
+               for( eptr = sym_tab[i]; eptr; eptr = eptr->next )
                {
                        if( eptr->val && eptr->class ) {
                                fprintf( stderr, "key=%s val@=%p\n", eptr->name, eptr->val );
@@ -263,7 +263,7 @@ extern void *rmr_sym_alloc( int size )
 
        memset( table, 0, sizeof( *table ) );
 
-       if((table->symlist = (Sym_ele **) malloc( sizeof( Sym_ele *) * size ))) 
+       if((table->symlist = (Sym_ele **) malloc( sizeof( Sym_ele *) * size )))
        {
                memset( table->symlist, 0, sizeof( Sym_ele *) * size );
                table->size = size;
@@ -277,14 +277,14 @@ extern void *rmr_sym_alloc( int size )
        return (void *) table;    /* user might want to know what the size is */
 }
 
-/* 
+/*
        Delete an element given name/class or numeric key (class 0).
 */
 extern void rmr_sym_del( void *vtable, const char *name, unsigned int class )
 {
        Sym_tab *table;
        Sym_ele **sym_tab;
-       Sym_ele *eptr;    /* pointer into hash table */ 
+       Sym_ele *eptr;    /* pointer into hash table */
        int hv;                  /* hash value */
        unsigned int nkey;              // class 0, name points to integer not string
 
@@ -347,7 +347,7 @@ extern void *rmr_sym_pull(  void *vtable, int key ) {
        return rmr_sym_get( vtable, (const char *) &key, 0 );
 }
 
-/* 
+/*
        Put an element with a string key into the table. Replaces the element
        if it was already there.  Class must be >0 and if not 1 will be forced.
        (class 0 keys are numeric).
@@ -365,10 +365,10 @@ extern int rmr_sym_put( void *vtable, const char *name, unsigned int class, void
        return putin( table, name, class, val );
 }
 
-/* 
+/*
        Add a new entry assuming that the key is an unsigned integer.
 
-       Returns 1 if new, 0 if existed 
+       Returns 1 if new, 0 if existed
 */
 extern int rmr_sym_map( void *vtable, unsigned int key, void *val ) {
        Sym_tab *table;
@@ -377,8 +377,8 @@ extern int rmr_sym_map( void *vtable, unsigned int key, void *val ) {
        return putin( table, (const char *) &key, 0, val );
 }
 
-/* 
-       Dump some statistics to stderr dev. Higher level is the more info dumpped 
+/*
+       Dump some statistics to stderr dev. Higher level is the more info dumpped
 */
 extern void rmr_sym_stats( void *vtable, int level )
 {
@@ -400,7 +400,7 @@ extern void rmr_sym_stats( void *vtable, int level )
                ch_count = 0;
                if( sym_tab[i] )
                {
-                       for( eptr = sym_tab[i]; eptr; eptr = eptr->next )  
+                       for( eptr = sym_tab[i]; eptr; eptr = eptr->next )
                        {
                                ch_count++;
                                if( level > 3 ) {
@@ -415,7 +415,7 @@ extern void rmr_sym_stats( void *vtable, int level )
                else
                        empty++;
 
-               if( ch_count > max_chain ) 
+               if( ch_count > max_chain )
                {
                        max_chain = ch_count;
                        maxi = i;
@@ -439,7 +439,7 @@ extern void rmr_sym_stats( void *vtable, int level )
                }
        }
 
-       fprintf( stderr, "sym:%ld(size)  %ld(inhab) %ld(occupied) %ld(dead) %ld(maxch) %d(>2per)\n", 
+       fprintf( stderr, "sym:%ld(size)  %ld(inhab) %ld(occupied) %ld(dead) %ld(maxch) %d(>2per)\n",
                        table->size, table->inhabitants, table->size - empty, table->deaths, max_chain, twoper );
 }
 
index 8d41b09..8e615af 100644 (file)
@@ -1,14 +1,14 @@
 // :vi sw=4 ts=4 noet:
 /*
 ==================================================================================
-       Copyright (c) 2019 Nokia 
+       Copyright (c) 2019 Nokia
        Copyright (c) 2018-2019 AT&T Intellectual Property.
 
    Licensed 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
+          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,
@@ -130,7 +130,7 @@ static char* uta_h2ip( char const* hname ) {
 
 
 /*
-       Looks for the environment variable RMR_RTG_SVC which we assume to be name[:port], and 
+       Looks for the environment variable RMR_RTG_SVC which we assume to be name[:port], and
        does a dns lookup on the name. If the env does not have such a variable, we default to
        "rtg" and a port of 5656.
 
@@ -177,18 +177,18 @@ static int uta_lookup_rtg( uta_ctx_t* ctx ) {
 
        return ctx->rtg_addr != NULL;
 }
-       
+
 
 /*
        Expects a buffer of 'sep' separated tokens and looks to see if
-       the given string is one of those tokens. Returns the token 
+       the given string is one of those tokens. Returns the token
        index (0 - n-1) if the string is found; -1 otherwise. The max
        parameter supplies the maximum number of tokens to search in
        the buffer.
 
        On failure (-1) errno will be set in cases where memory cannot
        be alocated (is this even possible any more?). If errno is 0
-       and failure is returned, then the caller should assume that 
+       and failure is returned, then the caller should assume that
        the token isn't in the list, or the list had no elements.
 */
 static int uta_has_str( char const* buf, char const* str, char sep, int max ) {
@@ -220,7 +220,7 @@ static int uta_has_str( char const* buf, char const* str, char sep, int max ) {
        for( i = 0; rc < 0 && i < ntokens; i++ ) {
                if( tokens[i] ) {
                        if( strcmp( tokens[i], str ) == 0 ) {
-                               rc = i; 
+                               rc = i;
                        }
                }
        }
@@ -250,7 +250,7 @@ if_addrs_t*  mk_ip_list( char* port ) {
        char*   fmt;
        char*   envp;                           // at the environment var if there
 
-       
+
 
        if( (l = (if_addrs_t *) malloc( sizeof( if_addrs_t ) )) == NULL ) {
                return NULL;
@@ -306,7 +306,7 @@ if_addrs_t*  mk_ip_list( char* port ) {
        Check the address:port passed in and return true if it matches
        one of the addresses we saw when we built the list. Right now
        this isn't a speed intensive part of our processing, so we just
-       do a straight search through the list. We don't expect this to 
+       do a straight search through the list. We don't expect this to
        ever be a higly driven functions so not bothering to optimise.
 */
 int is_this_myip( if_addrs_t* l, char* addr ) {
@@ -341,7 +341,7 @@ static int has_myip( char const* buf, if_addrs_t* list, char sep, int max ) {
        if( max < 2 ) {
                return 0;
        }
-       
+
        if( buf == NULL ) {
                return 0;
        }
@@ -369,7 +369,7 @@ static int has_myip( char const* buf, if_addrs_t* list, char sep, int max ) {
        for( i = 0; ! rc  && i < ntokens; i++ ) {
                if( tokens[i] ) {
                        if( is_this_myip( list, tokens[i] ) ) {
-                               rc = 1; 
+                               rc = 1;
                                break;
                        }
                }
index 8011ddc..2518b7a 100644 (file)
@@ -8,7 +8,7 @@
    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
+          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,
@@ -80,7 +80,7 @@
 
 /*
        This function returns true if the current application is permitted to open a wormhole
-       to the desired target. 
+       to the desired target.
 
        This is a place holder for future functionality.
 */
@@ -220,7 +220,7 @@ extern rmr_whid_t rmr_wh_open( void* vctx, char const* target ) {
                }
 
                if( whm->eps[i] == ep ) {
-                       return i;                                                       // we're already pointing to it, just send it back again        
+                       return i;                                                       // we're already pointing to it, just send it back again
                }
        }
 
index 3522e08..dde00ae 100644 (file)
@@ -1,14 +1,14 @@
 // : vi ts=4 sw=4 noet :
 /*
 ==================================================================================
-       Copyright (c) 2019 Nokia 
+       Copyright (c) 2019 Nokia
        Copyright (c) 2018-2019 AT&T Intellectual Property.
 
    Licensed 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
+          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,
@@ -45,7 +45,7 @@ struct endpoint {
 };
 
 /*
-       Context describing our world. Should be returned to user programme on 
+       Context describing our world. Should be returned to user programme on
        call to initialise, and passed as first parm on all calls to other
        visible functions.
 
@@ -68,7 +68,7 @@ struct uta_ctx {
        route_table_t* new_rtable;      // route table under construction
        if_addrs_t*     ip_list;                // list manager of the IP addresses that are on our known interfaces
        void*   mring;                          // ring where msgs are queued while waiting for a call response msg
-       
+
        char*   rtg_addr;                       // addr/port of the route table generation publisher
        int             rtg_port;                       // the port that the rtg listens on
 
index c9bb694..dcf7e67 100644 (file)
@@ -1,14 +1,14 @@
 // :vi sw=4 ts=4 noet:
 /*
 ==================================================================================
-       Copyright (c) 2019 Nokia 
+       Copyright (c) 2019 Nokia
        Copyright (c) 2018-2019 AT&T Intellectual Property.
 
    Licensed 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
+          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,
@@ -24,9 +24,9 @@
                                the older nanomsg messaging transport mehhanism.
 
                                To "hide" internal functions the choice was made to implement them
-                               all as static functions. This means that we include nearly 
+                               all as static functions. This means that we include nearly
                                all of our modules here as 90% of the library is not visible to
-                               the outside world. 
+                               the outside world.
 
        Author:         E. Scott Daniels
        Date:           28 November 2018
@@ -122,10 +122,10 @@ extern int rmr_set_stimeout( void* vctx, int time ) {
        }
 
        if( time > 0 ) {
-               if( time < 1000 ) {     
+               if( time < 1000 ) {
                        time = time * 1000;                     // assume seconds, nn wants ms
                }
-       } 
+       }
 
        return nn_setsockopt( ctx->nn_sock, NN_SOL_SOCKET, NN_SNDTIMEO, &time, sizeof( time ) );
 }
@@ -141,7 +141,7 @@ extern int rmr_send_to( void* vctx, int time ) {
        Returns the size of the payload (bytes) that the msg buffer references.
        Len in a message is the number of bytes which were received, or should
        be transmitted, however, it is possible that the mbuf was allocated
-       with a larger payload space than the payload length indicates; this 
+       with a larger payload space than the payload length indicates; this
        function returns the absolute maximum space that the user has available
        in the payload. On error (bad msg buffer) -1 is returned and errno should
        indicate the rason.
@@ -221,15 +221,15 @@ extern void rmr_free_msg( rmr_mbuf_t* mbuf ) {
                        free( mbuf->header );
                }
        }
-       
+
        free( mbuf );
 }
 
 /*
-       Accept a message and send it to an endpoint based on message type.      
+       Accept a message and send it to an endpoint based on message type.
        Allocates a new message buffer for the next send. If a message type has
        more than one group of endpoints defined, then the message will be sent
-       in round robin fashion to one endpoint in each group. 
+       in round robin fashion to one endpoint in each group.
 
        CAUTION: this is a non-blocking send.  If the message cannot be sent, then
                it will return with an error and errno set to eagain. If the send is
@@ -248,7 +248,7 @@ extern rmr_mbuf_t* rmr_send_msg( void* vctx, rmr_mbuf_t* msg ) {
                if( msg != NULL ) {
                        msg->state = RMR_ERR_BADARG;
                        errno = EINVAL;                                                                                 // must ensure it's not eagain
-               }                       
+               }
                return msg;
        }
 
@@ -265,7 +265,7 @@ extern rmr_mbuf_t* rmr_send_msg( void* vctx, rmr_mbuf_t* msg ) {
 
        while( send_again ) {
                nn_sock = uta_epsock_rr( ctx->rtable, msg->mtype, group, &send_again );         // round robin select endpoint; again set if mult groups
-               if( DEBUG ) fprintf( stderr, "[DBUG] send msg: type=%d again=%d group=%d socket=%d len=%d\n", 
+               if( DEBUG ) fprintf( stderr, "[DBUG] send msg: type=%d again=%d group=%d socket=%d len=%d\n",
                                msg->mtype, send_again, group, nn_sock, msg->len );
                group++;
 
@@ -283,7 +283,7 @@ extern rmr_mbuf_t* rmr_send_msg( void* vctx, rmr_mbuf_t* msg ) {
                        /*
                        if( msg ) {
                                // error do we need to count successes/errors, how to report some success, esp if last fails?
-                       } 
+                       }
                        */
 
                        msg = clone_m;                                                                                  // clone will be the next to send
@@ -296,9 +296,9 @@ extern rmr_mbuf_t* rmr_send_msg( void* vctx, rmr_mbuf_t* msg ) {
 }
 
 /*
-       Return to sender allows a message to be sent back to the endpoint where it originated. 
+       Return to sender allows a message to be sent back to the endpoint where it originated.
        The source information in the message is used to select the socket on which to write
-       the message rather than using the message type and round-robin selection. This 
+       the message rather than using the message type and round-robin selection. This
        should return a message buffer with the state of the send operation set. On success
        (state is RMR_OK, the caller may use the buffer for another receive operation), and on
        error it can be passed back to this function to retry the send if desired. On error,
@@ -330,7 +330,7 @@ extern rmr_mbuf_t*  rmr_rts_msg( void* vctx, rmr_mbuf_t* msg ) {
                errno = EINVAL;                                                                                         // if msg is null, this is their clue
                if( msg != NULL ) {
                        msg->state = RMR_ERR_BADARG;
-               }                       
+               }
                return msg;
        }
 
@@ -368,7 +368,7 @@ extern rmr_mbuf_t*  rmr_rts_msg( void* vctx, rmr_mbuf_t* msg ) {
 
        Normally, a message struct pointer is returned and msg->state must be checked for RMR_OK
        to ensure that no error was encountered. If the state is UTA_BADARG, then the message
-       may be resent (likely the context pointer was nil).  If the message is sent, but no 
+       may be resent (likely the context pointer was nil).  If the message is sent, but no
        response is received, a nil message is returned with errno set to indicate the likley
        issue:
                ETIMEDOUT -- too many messages were queued before reciving the expected response
@@ -387,7 +387,7 @@ extern rmr_mbuf_t* rmr_call( void* vctx, rmr_mbuf_t* msg ) {
        if( (ctx = (uta_ctx_t *) vctx) == NULL || msg == NULL ) {               // bad stuff, bail fast
                if( msg != NULL ) {
                        msg->state = RMR_ERR_BADARG;
-               }                       
+               }
                return msg;
        }
 
@@ -424,7 +424,7 @@ extern rmr_mbuf_t* rmr_rcv_msg( void* vctx, rmr_mbuf_t* old_msg ) {
        if( (ctx = (uta_ctx_t *) vctx) == NULL ) {
                if( old_msg != NULL ) {
                        old_msg->state = RMR_ERR_BADARG;
-               }                       
+               }
                errno = EINVAL;
                return old_msg;
        }
@@ -443,8 +443,8 @@ extern rmr_mbuf_t* rmr_rcv_msg( void* vctx, rmr_mbuf_t* old_msg ) {
 }
 
 /*
-       Receive with a timeout.  This is a convenience function when sitting on top of 
-       nanomsg as it just sets the rcv timeout and calls rmr_rcv_msg(). 
+       Receive with a timeout.  This is a convenience function when sitting on top of
+       nanomsg as it just sets the rcv timeout and calls rmr_rcv_msg().
 */
 extern rmr_mbuf_t* rmr_torcv_msg( void* vctx, rmr_mbuf_t* old_msg, int ms_to ) {
        uta_ctx_t*      ctx;
@@ -461,23 +461,23 @@ extern rmr_mbuf_t* rmr_torcv_msg( void* vctx, rmr_mbuf_t* old_msg, int ms_to ) {
 
 /*
        This blocks until the message with the 'expect' ID is received. Messages which are received
-       before the expected message are queued onto the message ring.  The function will return 
+       before the expected message are queued onto the message ring.  The function will return
        a nil message and set errno to ETIMEDOUT if allow2queue messages are received before the
        expected message is received. If the queued message ring fills a nil pointer is returned
        and errno is set to ENOBUFS.
 
-       Generally this will be invoked only by the call() function as it waits for a response, but 
+       Generally this will be invoked only by the call() function as it waits for a response, but
        it is exposed to the user application as three is no reason not to.
 */
 extern rmr_mbuf_t* rmr_rcv_specific( void* vctx, rmr_mbuf_t* msg, char* expect, int allow2queue ) {
        uta_ctx_t*      ctx;
        int     queued = 0;                             // number we pushed into the ring
        int     exp_len = 0;                    // length of expected ID
-       
+
        if( (ctx = (uta_ctx_t *) vctx) == NULL ) {
                if( msg != NULL ) {
                        msg->state = RMR_ERR_BADARG;
-               }                       
+               }
                errno = EINVAL;
                return msg;
        }
@@ -537,12 +537,12 @@ static void* init( char* uproto_port, int max_msg_size, int flags ) {
        char*   proto = "tcp";                          // pointer into the proto/port string user supplied
        char*   port;
        char*   proto_port;
-       char    wbuf[1024];                                     // work buffer 
+       char    wbuf[1024];                                     // work buffer
        char*   tok;                                            // pointer at token in a buffer
        int             state;
        char*   interface = NULL;                       // interface to bind to pulled from RMR_BIND_IF if set
 
-       fprintf( stderr, "[INFO] ric message routing library on nanomsg (%s %s.%s.%s built: %s)\n", 
+       fprintf( stderr, "[INFO] ric message routing library on nanomsg (%s %s.%s.%s built: %s)\n",
                        QUOTE_DEF(GIT_ID), QUOTE_DEF(MAJOR_VER), QUOTE_DEF(MINOR_VER), QUOTE_DEF(PATCH_VER), __DATE__ );
 
        errno = 0;
@@ -575,7 +575,7 @@ static void* init( char* uproto_port, int max_msg_size, int flags ) {
 
        uta_lookup_rtg( ctx );                                                  // attempt to fill in rtg info; rtc will handle missing values/errors
 
-    ctx->nn_sock = nn_socket( AF_SP, NN_PULL );                // our 'listen' socket should allow multiple senders to connect
+       ctx->nn_sock = nn_socket( AF_SP, NN_PULL );             // our 'listen' socket should allow multiple senders to connect
        if( ctx->nn_sock < 0 ) {
                fprintf( stderr, "[CRIT] rmr_init: unable to initialise nanomsg listen socket: %d\n", errno );
                free_ctx( ctx );
@@ -610,7 +610,7 @@ static void* init( char* uproto_port, int max_msg_size, int flags ) {
                interface = "0.0.0.0";
        }
        snprintf( bind_info, sizeof( bind_info ), "%s://%s:%s", proto, interface, port );
-    if( nn_bind( ctx->nn_sock, bind_info ) < 0) {                      // bind and automatically accept client sessions
+       if( nn_bind( ctx->nn_sock, bind_info ) < 0) {                   // bind and automatically accept client sessions
                fprintf( stderr, "[CRIT] rmr_init: unable to bind nanomsg listen socket for %s: %s\n", bind_info, strerror( errno ) );
                nn_close( ctx->nn_sock );
                free_ctx( ctx );
@@ -630,7 +630,7 @@ static void* init( char* uproto_port, int max_msg_size, int flags ) {
 
 /*
        Publicly facing initialisation function. Wrapper for the init() funcion above
-       as it needs to ensure internal flags are masked off before calling the 
+       as it needs to ensure internal flags are masked off before calling the
        real workhorse.
 */
 extern void* rmr_init( char* uproto_port, int max_msg_size, int flags ) {
@@ -655,7 +655,7 @@ extern int rmr_ready( void* vctx ) {
 }
 
 /*
-       Provides a non-fatal (compile) interface for the nng only function. 
+       Provides a non-fatal (compile) interface for the nng only function.
        Not supported on top of nano, so this always returns -1.
 */
 extern int rmr_get_rcvfd( void* vctx ) {
@@ -672,6 +672,6 @@ extern void rmr_close( void* vctx ) {
        if( (ctx = (uta_ctx_t *) vctx) == NULL ) {
                return;
        }
-       
+
        nn_close( ctx->nn_sock );
 }
index 41ebc61..3ebad2d 100644 (file)
@@ -1,14 +1,14 @@
 // : vi ts=4 sw=4 noet :
 /*
 ==================================================================================
-       Copyright (c) 2019 Nokia 
+       Copyright (c) 2019 Nokia
        Copyright (c) 2018-2019 AT&T Intellectual Property.
 
    Licensed 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
+          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,
@@ -56,14 +56,14 @@ static int uta_link2( char* target ) {
                return -1;
        }
 
-    nn_sock = nn_socket( AF_SP, NN_PUSH );             // the socket we'll use to connect to the target
+       nn_sock = nn_socket( AF_SP, NN_PUSH );          // the socket we'll use to connect to the target
        if( nn_sock < 0 ) {
                fprintf( stderr, "[WARN] rmr: link2: unable to create socket for link to target: %s: %d\n", target, errno );
                return -1;
        }
 
        snprintf( conn_info, sizeof( conn_info ), "tcp://%s", target );
-    if( nn_connect( nn_sock, conn_info ) < 0 ) {                                                       // connect failed
+       if( nn_connect( nn_sock, conn_info ) < 0 ) {                                                    // connect failed
                fprintf( stderr, "[WARN] rmr: link2: unable to create link to target: %s: %d\n", target, errno );
                nn_close( nn_sock );
                return -1;
@@ -91,7 +91,7 @@ static int rt_link2_ep( endpoint_t* ep ) {
 }
 
 /*
-       Add an endpoint to a route table entry for the group given. If the endpoint isn't in the 
+       Add an endpoint to a route table entry for the group given. If the endpoint isn't in the
        hash we add it and create the endpoint struct.
 
        The caller must supply the specific route table (we assume it will be pending, but they
@@ -194,7 +194,7 @@ static int uta_epsock_byname( route_table_t* rt, char* ep_name ) {
        entry. Returns the nanomsg socket number if there is a rte for the message
        type, and group is defined, else returns -1.
 
-       The group is the group number to select from. 
+       The group is the group number to select from.
 
        The user supplied integer 'more' will be set if there are additional groups
        defined to the matching route table entry which have a higher group number.
@@ -248,7 +248,7 @@ static int uta_epsock_rr( route_table_t *rt, int mtype, int group, int* more ) {
                        nn_sock = rrg->epts[0]->nn_sock;
                        ep = rrg->epts[0];
                        break;
-       
+
                default:                                                                                // need to pick one and adjust rr counts
                        ep = rrg->epts[rrg->ep_idx];
                        nn_sock = rrg->epts[rrg->ep_idx++]->nn_sock;
index 1c2bec8..77a0e64 100644 (file)
@@ -1,14 +1,14 @@
 // :vi sw=4 ts=4 noet:
 /*
 ==================================================================================
-       Copyright (c) 2019 Nokia 
+       Copyright (c) 2019 Nokia
        Copyright (c) 2018-2019 AT&T Intellectual Property.
 
    Licensed 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
+          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,
@@ -197,7 +197,7 @@ static inline rmr_mbuf_t* realloc_msg( rmr_mbuf_t* old_msg, int tr_len  ) {
                        memcpy( hdr, old_msg->header, sizeof( uta_mhdr_t ) );           // ONLY copy the header portion; trace and data offsets might have changed
                        if( RMR_D1_LEN( hdr )  ) {
                                memcpy( DATA1_ADDR( hdr ), DATA1_ADDR( old_msg->header ), RMR_D1_LEN( hdr ) );          // copy data1 and data2 if necessary
-                       
+
                        }
                        if( RMR_D2_LEN( hdr )  ) {
                                memcpy( DATA2_ADDR( hdr ), DATA2_ADDR( old_msg->header ), RMR_D2_LEN( hdr ) );          // copy data1 and data2 if necessary
@@ -207,7 +207,7 @@ static inline rmr_mbuf_t* realloc_msg( rmr_mbuf_t* old_msg, int tr_len  ) {
                        nm->payload = PAYLOAD_ADDR( hdr );                                                                      // reference user payload
                        break;
        }
-               
+
        // --- these are all version agnostic -----------------------------------
        nm->mtype = old_msg->mtype;
        nm->sub_id = old_msg->sub_id;
@@ -257,7 +257,7 @@ static rmr_mbuf_t* rcv_msg( uta_ctx_t* ctx, rmr_mbuf_t* old_msg ) {
                msg->flags |= MFL_ADDSRC;                                                                               // turn on so if user app tries to send this buffer we reset src
                msg->payload = PAYLOAD_ADDR( msg->header );
                msg->xaction = &hdr->xid[0];                                                    // provide user with ref to fixed space xaction id
-               if( DEBUG > 1 ) fprintf( stderr, "[DBUG] rcv_msg: got something: type=%d state=%d len=%d diff=%ld\n", 
+               if( DEBUG > 1 ) fprintf( stderr, "[DBUG] rcv_msg: got something: type=%d state=%d len=%d diff=%ld\n",
                                msg->mtype, msg->state, msg->len,  msg->payload - (unsigned char *) msg->header );
        } else {
                msg->len = 0;
@@ -270,7 +270,7 @@ static rmr_mbuf_t* rcv_msg( uta_ctx_t* ctx, rmr_mbuf_t* old_msg ) {
 
 /*
        Receives a 'raw' message from a non-RMr sender (no header expected). The returned
-       message buffer cannot be used to send, and the length information may or may 
+       message buffer cannot be used to send, and the length information may or may
        not be correct (it is set to the length received which might be more than the
        bytes actually in the payload).
 */
@@ -309,8 +309,8 @@ static void* rcv_payload( uta_ctx_t* ctx, rmr_mbuf_t* old_msg ) {
 
 /*
        This does the hard work of actually sending the message to the given socket. On success,
-       a new message struct is returned. On error, the original msg is returned with the state 
-       set to a reasonable value. If the message being sent as MFL_NOALLOC set, then a new 
+       a new message struct is returned. On error, the original msg is returned with the state
+       set to a reasonable value. If the message being sent as MFL_NOALLOC set, then a new
        buffer will not be allocated and returned (mostly for call() interal processing since
        the return message from call() is a received buffer, not a new one).
 
@@ -342,7 +342,7 @@ static rmr_mbuf_t* send_msg( uta_ctx_t* ctx, rmr_mbuf_t* msg, int nn_sock ) {
        } else {
                if( (state = nn_send( nn_sock, msg->header, sizeof( uta_mhdr_t ) + msg->len, NN_DONTWAIT )) < 0 ) {
                        msg->state = state;
-               } 
+               }
        }
 
        // future:  if nano sends bytes, but less than mlen, then what to do?
index a1bba74..b810bdb 100644 (file)
@@ -1,14 +1,14 @@
 // : vi ts=4 sw=4 noet :
 /*
 ==================================================================================
-       Copyright (c) 2019 Nokia 
+       Copyright (c) 2019 Nokia
        Copyright (c) 2018-2019 AT&T Intellectual Property.
 
    Licensed 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
+          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,
@@ -49,14 +49,14 @@ struct endpoint {
        Epoll information needed for the rmr_torcv_msg() funciton
 */
 typedef struct epoll_stuff {
-    struct epoll_event events[1];                              // wait on 10 possible events
-    struct epoll_event epe;                                            // event definition for event to listen to
+       struct epoll_event events[1];                           // wait on 10 possible events
+       struct epoll_event epe;                                         // event definition for event to listen to
        int ep_fd;                                                                      // file des from nng
        int nng_fd;                                                                     // fd from nng
 } epoll_stuff_t;
 
 /*
-       Context describing our world. Should be returned to user programme on 
+       Context describing our world. Should be returned to user programme on
        call to initialise, and passed as first parm on all calls to other
        visible functions.
 
@@ -79,10 +79,10 @@ struct uta_ctx {
        route_table_t* new_rtable;      // route table under construction
        if_addrs_t*     ip_list;                // list manager of the IP addresses that are on our known interfaces
        void*   mring;                          // ring where msgs are queued while waiting for a call response msg
-       
+
        char*   rtg_addr;                       // addr/port of the route table generation publisher
        int             rtg_port;                       // the port that the rtg listens on
-       
+
        wh_mgt_t*       wormholes;              // management of user opened wormholes
        epoll_stuff_t*  eps;            // epoll information needed for the rcv with timeout call
 
@@ -92,7 +92,7 @@ struct uta_ctx {
 
 
 /*
-       Static prototypes for functions located here. All common protos are in the 
+       Static prototypes for functions located here. All common protos are in the
        agnostic header file.
 */
 
index a3fcd89..70542f8 100644 (file)
@@ -1,14 +1,14 @@
 // : vi ts=4 sw=4 noet :
 /*
 ==================================================================================
-       Copyright (c) 2019 Nokia 
+       Copyright (c) 2019 Nokia
        Copyright (c) 2018-2019 AT&T Intellectual Property.
 
    Licensed 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
+          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,
 
 /*
        Mnemonic:       rmr_nng.c
-       Abstract:       This is the compile point for the nng version of the rmr 
+       Abstract:       This is the compile point for the nng version of the rmr
                                library (formarly known as uta, so internal function names
                                are likely still uta_*)
 
-                               With the exception of the symtab portion of the library, 
-                               RMr is built with a single compile so as to "hide" the 
+                               With the exception of the symtab portion of the library,
+                               RMr is built with a single compile so as to "hide" the
                                internal functions as statics.  Because they interdepend
                                on each other, and CMake has issues with generating two
                                different wormhole objects from a single source, we just
                                pull it all together with a centralised comple using
-                               includes.  
+                               includes.
 
                                Future:  the API functions at this point can be separated
                                into a common source module.
@@ -92,7 +92,7 @@ static void free_ctx( uta_ctx_t* ctx ) {
        Returns the size of the payload (bytes) that the msg buffer references.
        Len in a message is the number of bytes which were received, or should
        be transmitted, however, it is possible that the mbuf was allocated
-       with a larger payload space than the payload length indicates; this 
+       with a larger payload space than the payload length indicates; this
        function returns the absolute maximum space that the user has available
        in the payload. On error (bad msg buffer) -1 is returned and errno should
        indicate the rason.
@@ -176,26 +176,26 @@ extern void rmr_free_msg( rmr_mbuf_t* mbuf ) {
                        }
                }
        }
-       
+
        free( mbuf );
 }
 
 /*
        send message with maximum timeout.
-       Accept a message and send it to an endpoint based on message type.      
+       Accept a message and send it to an endpoint based on message type.
        If NNG reports that the send attempt timed out, or should be retried,
        RMr will retry for approximately max_to microseconds; rounded to the next
        higher value of 10.
 
        Allocates a new message buffer for the next send. If a message type has
        more than one group of endpoints defined, then the message will be sent
-       in round robin fashion to one endpoint in each group. 
+       in round robin fashion to one endpoint in each group.
 
        CAUTION: this is a non-blocking send.  If the message cannot be sent, then
                it will return with an error and errno set to eagain. If the send is
                a limited fanout, then the returned status is the status of the last
                send attempt.
-       
+
 */
 extern rmr_mbuf_t* rmr_mtosend_msg( void* vctx, rmr_mbuf_t* msg, int max_to ) {
        nng_socket nn_sock;                     // endpoint socket for send
@@ -210,7 +210,7 @@ extern rmr_mbuf_t* rmr_mtosend_msg( void* vctx, rmr_mbuf_t* msg, int max_to ) {
                if( msg != NULL ) {
                        msg->state = RMR_ERR_BADARG;
                        errno = EINVAL;                                                                                 // must ensure it's not eagain
-               }                       
+               }
                return msg;
        }
 
@@ -231,7 +231,7 @@ extern rmr_mbuf_t* rmr_mtosend_msg( void* vctx, rmr_mbuf_t* msg, int max_to ) {
 
        while( send_again ) {
                sock_ok = uta_epsock_rr( ctx->rtable, msg->mtype, group, &send_again, &nn_sock );               // round robin sel epoint; again set if mult groups
-               if( DEBUG ) fprintf( stderr, "[DBUG] send msg: type=%d again=%d group=%d len=%d sock_ok=%d\n", 
+               if( DEBUG ) fprintf( stderr, "[DBUG] send msg: type=%d again=%d group=%d len=%d sock_ok=%d\n",
                                msg->mtype, send_again, group, msg->len, sock_ok );
                group++;
 
@@ -249,7 +249,7 @@ extern rmr_mbuf_t* rmr_mtosend_msg( void* vctx, rmr_mbuf_t* msg, int max_to ) {
                        /*
                        if( msg ) {
                                // error do we need to count successes/errors, how to report some success, esp if last fails?
-                       } 
+                       }
                        */
 
                        msg = clone_m;                                                                                  // clone will be the next to send
@@ -262,7 +262,7 @@ extern rmr_mbuf_t* rmr_mtosend_msg( void* vctx, rmr_mbuf_t* msg, int max_to ) {
 }
 
 /*
-       Send with default max timeout as is set in the context. 
+       Send with default max timeout as is set in the context.
        See rmr_mtosend_msg() for more details on the parameters.
        See rmr_stimeout() for info on setting the default timeout.
 */
@@ -271,9 +271,9 @@ extern rmr_mbuf_t* rmr_send_msg( void* vctx, rmr_mbuf_t* msg ) {
 }
 
 /*
-       Return to sender allows a message to be sent back to the endpoint where it originated. 
+       Return to sender allows a message to be sent back to the endpoint where it originated.
        The source information in the message is used to select the socket on which to write
-       the message rather than using the message type and round-robin selection. This 
+       the message rather than using the message type and round-robin selection. This
        should return a message buffer with the state of the send operation set. On success
        (state is RMR_OK, the caller may use the buffer for another receive operation), and on
        error it can be passed back to this function to retry the send if desired. On error,
@@ -306,7 +306,7 @@ extern rmr_mbuf_t*  rmr_rts_msg( void* vctx, rmr_mbuf_t* msg ) {
                errno = EINVAL;                                                                                         // if msg is null, this is their clue
                if( msg != NULL ) {
                        msg->state = RMR_ERR_BADARG;
-               }                       
+               }
                return msg;
        }
 
@@ -345,7 +345,7 @@ extern rmr_mbuf_t*  rmr_rts_msg( void* vctx, rmr_mbuf_t* msg ) {
 
        Normally, a message struct pointer is returned and msg->state must be checked for RMR_OK
        to ensure that no error was encountered. If the state is UTA_BADARG, then the message
-       may be resent (likely the context pointer was nil).  If the message is sent, but no 
+       may be resent (likely the context pointer was nil).  If the message is sent, but no
        response is received, a nil message is returned with errno set to indicate the likley
        issue:
                ETIMEDOUT -- too many messages were queued before reciving the expected response
@@ -364,7 +364,7 @@ extern rmr_mbuf_t* rmr_call( void* vctx, rmr_mbuf_t* msg ) {
        if( (ctx = (uta_ctx_t *) vctx) == NULL || msg == NULL ) {               // bad stuff, bail fast
                if( msg != NULL ) {
                        msg->state = RMR_ERR_BADARG;
-               }                       
+               }
                return msg;
        }
 
@@ -401,7 +401,7 @@ extern rmr_mbuf_t* rmr_rcv_msg( void* vctx, rmr_mbuf_t* old_msg ) {
        if( (ctx = (uta_ctx_t *) vctx) == NULL ) {
                if( old_msg != NULL ) {
                        old_msg->state = RMR_ERR_BADARG;
-               }                       
+               }
                errno = EINVAL;
                return old_msg;
        }
@@ -420,8 +420,8 @@ extern rmr_mbuf_t* rmr_rcv_msg( void* vctx, rmr_mbuf_t* old_msg ) {
 }
 
 /*
-       This implements a receive with a timeout via epoll. Mostly this is for 
-       wrappers as native C applications can use epoll directly and will not have 
+       This implements a receive with a timeout via epoll. Mostly this is for
+       wrappers as native C applications can use epoll directly and will not have
        to depend on this.
 */
 extern rmr_mbuf_t* rmr_torcv_msg( void* vctx, rmr_mbuf_t* old_msg, int ms_to ) {
@@ -434,7 +434,7 @@ extern rmr_mbuf_t* rmr_torcv_msg( void* vctx, rmr_mbuf_t* old_msg, int ms_to ) {
        if( (ctx = (uta_ctx_t *) vctx) == NULL ) {
                if( old_msg != NULL ) {
                        old_msg->state = RMR_ERR_BADARG;
-               }                       
+               }
                errno = EINVAL;
                return old_msg;
        }
@@ -449,23 +449,23 @@ extern rmr_mbuf_t* rmr_torcv_msg( void* vctx, rmr_mbuf_t* old_msg, int ms_to ) {
        }
 
        if( (eps = ctx->eps)  == NULL ) {                                       // set up epoll on first call
-               eps = malloc( sizeof *eps );            
+               eps = malloc( sizeof *eps );
 
-       if( (eps->ep_fd = epoll_create1( 0 )) < 0 ) {
-               fprintf( stderr, "[FAIL] unable to create epoll fd: %d\n", errno );
+               if( (eps->ep_fd = epoll_create1( 0 )) < 0 ) {
+               fprintf( stderr, "[FAIL] unable to create epoll fd: %d\n", errno );
                        free( eps );
                        return NULL;
-       }
+               }
 
                eps->nng_fd = rmr_get_rcvfd( ctx );
                eps->epe.events = EPOLLIN;
-       eps->epe.data.fd = eps->nng_fd;
+               eps->epe.data.fd = eps->nng_fd;
 
-       if( epoll_ctl( eps->ep_fd, EPOLL_CTL_ADD, eps->nng_fd, &eps->epe ) != 0 )  {
-               fprintf( stderr, "[FAIL] epoll_ctl status not 0 : %s\n", strerror( errno ) );
+               if( epoll_ctl( eps->ep_fd, EPOLL_CTL_ADD, eps->nng_fd, &eps->epe ) != 0 )  {
+               fprintf( stderr, "[FAIL] epoll_ctl status not 0 : %s\n", strerror( errno ) );
                        free( eps );
                        return NULL;
-       }
+               }
 
                ctx->eps = eps;
        }
@@ -492,23 +492,23 @@ extern rmr_mbuf_t* rmr_torcv_msg( void* vctx, rmr_mbuf_t* old_msg, int ms_to ) {
 
 /*
        This blocks until the message with the 'expect' ID is received. Messages which are received
-       before the expected message are queued onto the message ring.  The function will return 
+       before the expected message are queued onto the message ring.  The function will return
        a nil message and set errno to ETIMEDOUT if allow2queue messages are received before the
        expected message is received. If the queued message ring fills a nil pointer is returned
        and errno is set to ENOBUFS.
 
-       Generally this will be invoked only by the call() function as it waits for a response, but 
+       Generally this will be invoked only by the call() function as it waits for a response, but
        it is exposed to the user application as three is no reason not to.
 */
 extern rmr_mbuf_t* rmr_rcv_specific( void* vctx, rmr_mbuf_t* msg, char* expect, int allow2queue ) {
        uta_ctx_t*      ctx;
        int     queued = 0;                             // number we pushed into the ring
        int     exp_len = 0;                    // length of expected ID
-       
+
        if( (ctx = (uta_ctx_t *) vctx) == NULL ) {
                if( msg != NULL ) {
                        msg->state = RMR_ERR_BADARG;
-               }                       
+               }
                errno = EINVAL;
                return msg;
        }
@@ -553,12 +553,12 @@ extern rmr_mbuf_t* rmr_rcv_specific( void* vctx, rmr_mbuf_t* msg, char* expect,
 //  CAUTION:  these are not supported as they must be set differently (between create and open) in NNG.
 //                             until those details are worked out, these generate a warning.
 /*
-       Set send timeout. The value time is assumed to be microseconds.  The timeout is the 
+       Set send timeout. The value time is assumed to be microseconds.  The timeout is the
        rough maximum amount of time that RMr will block on a send attempt when the underlying
        mechnism indicates eagain or etimeedout.  All other error conditions are reported
        without this delay. Setting a timeout of 0 causes no retries to be attempted in
        RMr code. Setting a timeout of 1 causes RMr to spin up to 10K retries before returning,
-       but without issuing a sleep.  If timeout is > 1, then RMr will issue a sleep (1us) 
+       but without issuing a sleep.  If timeout is > 1, then RMr will issue a sleep (1us)
        after every 10K send attempts until the time value is reached. Retries are abandoned
        if NNG returns anything other than NNG_AGAIN or NNG_TIMEDOUT.
 
@@ -594,9 +594,9 @@ extern int rmr_set_rtimeout( void* vctx, int time ) {
 
 /*
        This is the actual init workhorse. The user visible function meerly ensures that the
-       calling programme does NOT set any internal flags that are supported, and then 
+       calling programme does NOT set any internal flags that are supported, and then
        invokes this.  Internal functions (the route table collector) which need additional
-       open ports without starting additional route table collectors, will invoke this 
+       open ports without starting additional route table collectors, will invoke this
        directly with the proper flag.
 */
 static void* init(  char* uproto_port, int max_msg_size, int flags ) {
@@ -607,12 +607,12 @@ static void* init(  char* uproto_port, int max_msg_size, int flags ) {
        char*   port;
        char*   interface = NULL;                       // interface to bind to (from RMR_BIND_IF, 0.0.0.0 if not defined)
        char*   proto_port;
-       char    wbuf[1024];                                     // work buffer 
+       char    wbuf[1024];                                     // work buffer
        char*   tok;                                            // pointer at token in a buffer
        int             state;
 
        if( ! announced ) {
-               fprintf( stderr, "[INFO] ric message routing library on NNG mv=%d (%s %s.%s.%s built: %s)\n", 
+               fprintf( stderr, "[INFO] ric message routing library on NNG mv=%d (%s %s.%s.%s built: %s)\n",
                        RMR_MSG_VER, QUOTE_DEF(GIT_ID), QUOTE_DEF(MAJOR_VER), QUOTE_DEF(MINOR_VER), QUOTE_DEF(PATCH_VER), __DATE__ );
                announced = 1;
        }
@@ -711,7 +711,7 @@ static void* init(  char* uproto_port, int max_msg_size, int flags ) {
 
        Flags:
                No user flags supported (needed) at the moment, but this provides for extension
-               without drastically changing anything. The user should invoke with RMRFL_NONE to 
+               without drastically changing anything. The user should invoke with RMRFL_NONE to
                avoid any misbehavour as there are internal flags which are suported
 */
 extern void* rmr_init( char* uproto_port, int max_msg_size, int flags ) {
@@ -720,7 +720,7 @@ extern void* rmr_init( char* uproto_port, int max_msg_size, int flags ) {
 
 /*
        This sets the default trace length which will be added to any message buffers
-       allocated.  It can be set at any time, and if rmr_set_trace() is given a 
+       allocated.  It can be set at any time, and if rmr_set_trace() is given a
        trace len that is different than the default allcoated in a message, the message
        will be resized.
 
@@ -757,9 +757,9 @@ extern int rmr_ready( void* vctx ) {
 }
 
 /*
-    Returns a file descriptor which can be used with epoll() to signal a receive
-    pending. The file descriptor should NOT be read from directly, nor closed, as NNG
-    does not support this.
+       Returns a file descriptor which can be used with epoll() to signal a receive
+       pending. The file descriptor should NOT be read from directly, nor closed, as NNG
+       does not support this.
 */
 extern int rmr_get_rcvfd( void* vctx ) {
        uta_ctx_t* ctx;
@@ -783,7 +783,7 @@ extern int rmr_get_rcvfd( void* vctx ) {
        Clean up things.
 
        There isn't an nng_flush() per se, but we can pause, generate
-       a context switch, which should allow the last sent buffer to 
+       a context switch, which should allow the last sent buffer to
        flow. There isn't exactly an nng_term/close either, so there
        isn't much we can do.
 */
index d1e0cbb..d6d3490 100644 (file)
@@ -8,7 +8,7 @@
    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
+          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,
@@ -80,7 +80,7 @@ static int uta_link2( char* target, nng_socket* nn_sock, nng_dialer* dialer ) {
                nng_close( *nn_sock );
                return FALSE;
        }
-               
+
        nng_dialer_setopt_ms( *dialer,  NNG_OPT_RECONNMAXT, 2000 );             // cap backoff on retries to reasonable amount (2s)
        nng_dialer_setopt_ms( *dialer,  NNG_OPT_RECONNMINT, 100 );              // start retry 100m after last failure with 2s cap
 
@@ -114,7 +114,7 @@ static int rt_link2_ep( endpoint_t* ep ) {
 
 
 /*
-       Add an endpoint to a route table entry for the group given. If the endpoint isn't in the 
+       Add an endpoint to a route table entry for the group given. If the endpoint isn't in the
        hash we add it and create the endpoint struct.
 
        The caller must supply the specific route table (we assume it will be pending, but they
@@ -207,7 +207,7 @@ static int uta_epsock_byname( route_table_t* rt, char* ep_name, nng_socket* nn_s
        } else {
                *nn_sock = ep->nn_sock;
                state = TRUE;
-       }       
+       }
 
        return state;
 }
@@ -285,7 +285,7 @@ static int uta_epsock_rr( route_table_t *rt, int mtype, int group, int* more, nn
                        //if( DEBUG ) fprintf( stderr, ">>>> _rr returning socket with one choice in group \n" );
                        state = TRUE;
                        break;
-       
+
                default:                                                                                // need to pick one and adjust rr counts
                        ep = rrg->epts[rrg->ep_idx++];                          // select next endpoint
                        //if( DEBUG ) fprintf( stderr, ">>>> _rr returning socket with multiple choices in group idx=%d \n", rrg->ep_idx );
index c7bd049..e1a2fa5 100644 (file)
@@ -1,14 +1,14 @@
 // : vi ts=4 sw=4 noet :
 /*
 ==================================================================================
-       Copyright (c) 2019 Nokia 
+       Copyright (c) 2019 Nokia
        Copyright (c) 2018-2019 AT&T Intellectual Property.
 
    Licensed 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
+          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,
@@ -20,7 +20,7 @@
 
 /*
        Mnemonic:       sr_nng_static.c
-       Abstract:       These are static send/receive primatives which (sadly) 
+       Abstract:       These are static send/receive primatives which (sadly)
                                differ based on the underlying protocol (nng vs nanomsg).
                                Split from rmr_nng.c  for easier wormhole support.
 
@@ -55,7 +55,7 @@ static inline int xlate_nng_state( int state, int def_state ) {
                        state = RMR_ERR_RETRY;
                        errno = EAGAIN;
                        break;
-                       
+
                case NNG_ETIMEDOUT:
                        state = RMR_ERR_RETRY;
                        errno = EAGAIN;
@@ -85,7 +85,7 @@ static inline int xlate_nng_state( int state, int def_state ) {
                        errno  = EBADFD;                                // file des not in a good state for the operation
                        state = def_state;
                        break;
-               
+
                default:
                        errno = EBADE;
                        state = def_state;
@@ -159,7 +159,7 @@ static rmr_mbuf_t* alloc_zcmsg( uta_ctx_t* ctx, rmr_mbuf_t* msg, int size, int s
 }
 
 /*
-       Allocates only the mbuf and does NOT allocate an underlying transport buffer since 
+       Allocates only the mbuf and does NOT allocate an underlying transport buffer since
        NNG receive must allocate that on its own.
 */
 static rmr_mbuf_t* alloc_mbuf( uta_ctx_t* ctx, int state ) {
@@ -190,7 +190,7 @@ static rmr_mbuf_t* alloc_mbuf( uta_ctx_t* ctx, int state ) {
 /*
        This accepts a message with the assumption that only the tp_buf pointer is valid. It
        sets all of the various header/payload/xaction pointers in the mbuf to the proper
-       spot in the transport layer buffer.  The len in the header is assumed to be the 
+       spot in the transport layer buffer.  The len in the header is assumed to be the
        allocated len (a receive buffer that nng created);
 
        The alen parm is the assumed allocated length; assumed because it's a value likely
@@ -210,7 +210,7 @@ static void ref_tpbuf( rmr_mbuf_t* msg, size_t alen )  {
        msg->header = nng_msg_body( msg->tp_buf );                              // header is the start of the transport buffer
        v1hdr = (uta_v1mhdr_t *) msg->header;                                   // v1 will always allow us to suss out the version
 
-       if( v1hdr->rmr_ver == 1 ) {                     // bug in verion 1 didn't encode the version in network byte order 
+       if( v1hdr->rmr_ver == 1 ) {                     // bug in verion 1 didn't encode the version in network byte order
                ver = 1;
                v1hdr->rmr_ver = htonl( 1 );            // save it correctly in case we clone the message
        } else {
@@ -241,7 +241,7 @@ static void ref_tpbuf( rmr_mbuf_t* msg, size_t alen )  {
                        msg->flags |= MFL_ZEROCOPY;                                                             // this is a zerocopy sendable message
                        msg->mtype = ntohl( hdr->mtype );                                               // capture and convert from network order to local order
                        msg->sub_id = ntohl( hdr->sub_id );
-                       hlen = RMR_HDR_LEN( hdr );                                                              // len to use for truncated check later         
+                       hlen = RMR_HDR_LEN( hdr );                                                              // len to use for truncated check later
                        break;
        }
 
@@ -290,7 +290,7 @@ static inline rmr_mbuf_t* clone_msg( rmr_mbuf_t* old_msg  ) {
                        nm->payload = PAYLOAD_ADDR( hdr );                              // at user payload
                        break;
        }
-               
+
        // --- these are all version agnostic -----------------------------------
        nm->mtype = old_msg->mtype;
        nm->sub_id = old_msg->sub_id;
@@ -351,7 +351,7 @@ static inline rmr_mbuf_t* realloc_msg( rmr_mbuf_t* old_msg, int tr_len  ) {
                        if( RMR_D1_LEN( hdr )  ) {
                                coffset = DATA1_OFFSET( hdr );                                                                                          // offset to d1
                                memcpy( hdr + coffset, old_msg->header + coffset, RMR_D1_LEN( hdr ) );          // copy data1 and data2 if necessary
-                       
+
                        }
                        if( RMR_D2_LEN( hdr )  ) {
                                coffset = DATA2_OFFSET( hdr );                                                                                          // offset to d2
@@ -363,7 +363,7 @@ static inline rmr_mbuf_t* realloc_msg( rmr_mbuf_t* old_msg, int tr_len  ) {
                        SET_HDR_TR_LEN( hdr, tr_len );                                                                          // do NOT copy old trace data, just set the new header
                        break;
        }
-               
+
        // --- these are all version agnostic -----------------------------------
        nm->mtype = old_msg->mtype;
        nm->sub_id = old_msg->sub_id;
@@ -397,10 +397,10 @@ static inline rmr_mbuf_t* realloc_msg( rmr_mbuf_t* old_msg, int tr_len  ) {
 
 
        In the NNG msg world it must allocate the receive buffer rather
-       than accepting one that we allocated from their space and could 
+       than accepting one that we allocated from their space and could
        reuse.  They have their reasons I guess.  Thus, we will free
        the old transport buffer if user passes the message in; at least
-       our mbuf will be reused. 
+       our mbuf will be reused.
 */
 static rmr_mbuf_t* rcv_msg( uta_ctx_t* ctx, rmr_mbuf_t* old_msg ) {
        int state;
@@ -440,7 +440,7 @@ static rmr_mbuf_t* rcv_msg( uta_ctx_t* ctx, rmr_mbuf_t* old_msg ) {
                hdr = (uta_mhdr_t *) msg->header;
                msg->flags |= MFL_ADDSRC;                                       // turn on so if user app tries to send this buffer we reset src
 
-               if( DEBUG > 1 ) fprintf( stderr, "[DBUG] rcv_msg: got something: type=%d state=%d len=%d diff=%ld\n", 
+               if( DEBUG > 1 ) fprintf( stderr, "[DBUG] rcv_msg: got something: type=%d state=%d len=%d diff=%ld\n",
                                msg->mtype, msg->state, msg->len,  msg->payload - (unsigned char *) msg->header );
        } else {
                msg->state = RMR_ERR_EMPTY;
@@ -458,11 +458,11 @@ static rmr_mbuf_t* rcv_msg( uta_ctx_t* ctx, rmr_mbuf_t* old_msg ) {
 
 /*
        Receives a 'raw' message from a non-RMr sender (no header expected). The returned
-       message buffer cannot be used to send, and the length information may or may 
+       message buffer cannot be used to send, and the length information may or may
        not be correct (it is set to the length received which might be more than the
        bytes actually in the payload).
 
-       Mostly this supports the route table collector, but could be extended with an 
+       Mostly this supports the route table collector, but could be extended with an
        API external function.
 */
 static void* rcv_payload( uta_ctx_t* ctx, rmr_mbuf_t* old_msg ) {
@@ -500,8 +500,8 @@ static void* rcv_payload( uta_ctx_t* ctx, rmr_mbuf_t* old_msg ) {
 
 /*
        This does the hard work of actually sending the message to the given socket. On success,
-       a new message struct is returned. On error, the original msg is returned with the state 
-       set to a reasonable value. If the message being sent as MFL_NOALLOC set, then a new 
+       a new message struct is returned. On error, the original msg is returned with the state
+       set to a reasonable value. If the message being sent as MFL_NOALLOC set, then a new
        buffer will not be allocated and returned (mostly for call() interal processing since
        the return message from call() is a received buffer, not a new one).
 
@@ -561,7 +561,7 @@ static rmr_mbuf_t* send_msg( uta_ctx_t* ctx, rmr_mbuf_t* msg, nng_socket nn_sock
                if( (state = nng_send( nn_sock, msg->header, sizeof( uta_mhdr_t ) + msg->len, nng_flags )) != 0 ) {
                        msg->state = state;
                        //if( DEBUG ) fprintf( stderr, ">>>>> copy buffer send failed: %s\n", nng_strerror( state ) );
-               } 
+               }
                */
        }
 
index ade69b3..dd639ce 100644 (file)
@@ -1,14 +1,14 @@
 // :vim ts=4 sw=4 noet:
 /*
 ==================================================================================
-    Copyright (c) 2019 Nokia
-    Copyright (c) 2018-2019 AT&T Intellectual Property.
+       Copyright (c) 2019 Nokia
+       Copyright (c) 2018-2019 AT&T Intellectual Property.
 
    Licensed 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
+          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,
                                        ck1 ck2|<msg text><nil>
 
                                ck1 is a simple checksum of the message text (NOT including the
-                               nil at the end of the string. 
+                               nil at the end of the string.
 
                                ck2 is a simple checksum of the trace data which for the purposes
                                of testing is assumed to have a terminating nil to keep this simple.
 
                                Good messages are messages where both computed checksums match
-                               the ck1 and ck2 values. 
+                               the ck1 and ck2 values.
 
                                The receiver will send an 'ack' message back to the sender for
                                all type 5 messages received.
 
                                The sender and receiver can be run on the same host/container
-                               or on different hosts. The route table is the key to setting 
+                               or on different hosts. The route table is the key to setting
                                things up properly.  See the sender code for rt information.
 
                                Define these environment variables to have some control:
@@ -73,7 +73,7 @@ static int sum( char* str ) {
 
 /*
        Split the message at the first sep and return a pointer to the first
-       character after. 
+       character after.
 */
 static char* split( char* str, char sep ) {
        char*   s;
@@ -89,8 +89,8 @@ static char* split( char* str, char sep ) {
 }
 
 int main( int argc, char** argv ) {
-    void* mrc;                                         // msg router context
-    rmr_mbuf_t* msg = NULL;                            // message received
+       void* mrc;                                              // msg router context
+       rmr_mbuf_t* msg = NULL;                         // message received
        int i;
        int             state;
        int             errors = 0;
@@ -117,10 +117,10 @@ int main( int argc, char** argv ) {
        if( argc > 2 ) {
                listen_port = argv[2];
        }
-       
+
        fprintf( stderr, "<RCVR> listening on port: %s for a max of %d messages\n", listen_port, nmsgs );
 
-    mrc = rmr_init( listen_port, RMR_MAX_RCV_BYTES, RMRFL_NONE );      // start your engines!
+       mrc = rmr_init( listen_port, RMR_MAX_RCV_BYTES, RMRFL_NONE );   // start your engines!
        if( mrc == NULL ) {
                fprintf( stderr, "<RCVR> ABORT:  unable to initialise RMr\n" );
                exit( 1 );
@@ -139,9 +139,9 @@ int main( int argc, char** argv ) {
        fprintf( stderr, "<RCVR> rmr now shows ready, listening begins\n" );
 
        timeout = time( NULL ) + 20;
-    while( count < nmsgs ) {
+       while( count < nmsgs ) {
                msg = rmr_torcv_msg( mrc, msg, 1000 );                          // wait for about 1s so that if sender never starts we eventually escape
-               
+
                if( msg ) {
                        if( msg->state == RMR_OK ) {
                                if( (data = split( msg->payload, '|'  )) != NULL ) {
@@ -187,7 +187,7 @@ int main( int argc, char** argv ) {
                        errors++;
                        break;
                }
-    }
+       }
 
        fprintf( stderr, "<RCVR> [%s] %ld messages;  good=%ld  acked=%ld bad=%ld  bad-trace=%ld\n", !!(errors + bad + bad_tr) ? "FAIL" : "PASS", count, good, ack_count, bad, bad_tr );
        sleep( 2 );                                                                     // let any outbound acks flow before closing
index 89a0afc..3602d4f 100644 (file)
@@ -1,14 +1,14 @@
 // :vim ts=4 sw=4 noet:
 /*
 ==================================================================================
-    Copyright (c) 2019 Nokia
-    Copyright (c) 2018-2019 AT&T Intellectual Property.
+       Copyright (c) 2019 Nokia
+       Copyright (c) 2018-2019 AT&T Intellectual Property.
 
    Licensed 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
+          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,
 
 /*
        Mnemonic:       sender.c
-       Abstract:       This is a simple sender which will send a series of messages. 
+       Abstract:       This is a simple sender which will send a series of messages.
                                It is expected that the first attempt(s) will fail if the receiver
                                is not up and this does not start decrementing the number to
-                               send until it has a good send.  
+                               send until it has a good send.
 
                                The process will check the receive queue and list received messages
                                but pass/fail is not dependent on what comes back.
 
                                If the receiver(s) do not become connectable in 20 sec this process
-                               will give up and fail. 
+                               will give up and fail.
 
 
                                Message types will vary between 1 and 10, so the route table must
-                               be set up to support those message types.  
+                               be set up to support those message types.
 
                                Message format is:
                                        ck1 ck2|<msg-txt><nil>
 
                                Ck1 is the simple check sum of the msg-text (NOT includeing <nil>)
                                Ck2 is the simple check sum of the trace data which is a nil terminated
-                               series of bytes. 
+                               series of bytes.
 
                                Parms:  argv[1] == nmsgs; argv[2] == delay; argv[3] == listen port
 
@@ -74,11 +74,11 @@ static int sum( char* str ) {
 }
 
 int main( int argc, char** argv ) {
-    void* mrc;                                                 // msg router context
-    struct epoll_event events[1];                      // list of events to give to epoll
-    struct epoll_event epe;                 // event definition for event to listen to
-    int     ep_fd = -1;                                                // epoll's file des (given to epoll_wait)
-    int rcv_fd;                                                // file des that NNG tickles -- give this to epoll to listen on
+       void* mrc;                                                      // msg router context
+       struct epoll_event events[1];                   // list of events to give to epoll
+       struct epoll_event epe;                 // event definition for event to listen to
+       int     ep_fd = -1;                                             // epoll's file des (given to epoll_wait)
+       int rcv_fd;                                                     // file des that NNG tickles -- give this to epoll to listen on
        int nready;                                                             // number of events ready for receive
        rmr_mbuf_t*             sbuf;                                   // send buffer
        rmr_mbuf_t*             rbuf;                                   // received buffer
@@ -107,12 +107,12 @@ int main( int argc, char** argv ) {
 
        fprintf( stderr, "<SNDR> listen port: %s; sending %d messages; delay=%d\n", listen_port, nmsgs, delay );
 
-    if( (mrc = rmr_init( listen_port, 1400, RMRFL_NONE )) == NULL ) {
+       if( (mrc = rmr_init( listen_port, 1400, RMRFL_NONE )) == NULL ) {
                fprintf( stderr, "<SNDR> unable to initialise RMr\n" );
                exit( 1 );
        }
 
-    if( (rcv_fd = rmr_get_rcvfd( mrc )) >= 0 ) {                       // epoll only available from NNG -- skip receive later if not NNG
+       if( (rcv_fd = rmr_get_rcvfd( mrc )) >= 0 ) {                    // epoll only available from NNG -- skip receive later if not NNG
                if( rcv_fd < 0 ) {
                        fprintf( stderr, "<SNDR> unable to set up polling fd\n" );
                        exit( 1 );
@@ -121,10 +121,10 @@ int main( int argc, char** argv ) {
                        fprintf( stderr, "<SNDR> [FAIL] unable to create epoll fd: %d\n", errno );
                        exit( 1 );
                }
-       epe.events = EPOLLIN;
-       epe.data.fd = rcv_fd;
+               epe.events = EPOLLIN;
+               epe.data.fd = rcv_fd;
 
-       if( epoll_ctl( ep_fd, EPOLL_CTL_ADD, rcv_fd, &epe ) != 0 )  {
+               if( epoll_ctl( ep_fd, EPOLL_CTL_ADD, rcv_fd, &epe ) != 0 )  {
                        fprintf( stderr, "<SNDR> [FAIL] epoll_ctl status not 0 : %s\n", strerror( errno ) );
                        exit( 1 );
                }
@@ -147,10 +147,10 @@ int main( int argc, char** argv ) {
                }
        }
        fprintf( stderr, "<SNDR> rmr is ready; starting to send\n" );
-       
+
        timeout = time( NULL ) + 20;
 
-    while( count < nmsgs ) {                                                           // we send 10 messages after the first message is successful
+       while( count < nmsgs ) {                                                                // we send 10 messages after the first message is successful
                snprintf( trace, 100, "%lld", (long long) time( NULL ) );
                rmr_set_trace( sbuf, trace, strlen( trace ) + 1 );
                snprintf( wbuf, 200, "count=%d tr=%s %d stand up and cheer!", count, trace, rand() );
@@ -213,9 +213,9 @@ int main( int argc, char** argv ) {
                if( delay > 0 ) {
                        usleep( delay );
                }
-    }
+       }
+
 
-       
        timeout = time( NULL ) + 2;                             // allow 2 seconds for the pipe to drain from the receiver
        while( time( NULL ) < timeout );
                if( rcv_fd >= 0 ) {
index 9d7a38c..1e50390 100644 (file)
@@ -1,14 +1,14 @@
 // : vi ts=4 sw=4 noet :
 /*
 ==================================================================================
-        Copyright (c) 2019 Nokia 
-        Copyright (c) 2018-2019 AT&T Intellectual Property.
+           Copyright (c) 2019 Nokia 
+           Copyright (c) 2018-2019 AT&T Intellectual Property.
 
    Licensed 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
+          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,
index f232b3e..93ab45c 100644 (file)
@@ -1,14 +1,14 @@
 // : vi ts=4 sw=4 noet :
 /*
 ==================================================================================
-        Copyright (c) 2019 Nokia
-        Copyright (c) 2018-2019 AT&T Intellectual Property.
+           Copyright (c) 2019 Nokia
+           Copyright (c) 2018-2019 AT&T Intellectual Property.
 
    Licensed 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
+          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,
@@ -74,7 +74,7 @@ int mbuf_api_test( ) {
        rmr_bytes2payload( mbuf, src_buf, 8192 );                                               // bust the limit
        errors += fail_if( mbuf->state == RMR_OK, "huge buf copy to payload returned good state in mbuf" );
        errors += fail_if( errno == 0, "huge buf copy to payload returned good state in errno" );
-       
+
 
        snprintf( src_buf, sizeof( src_buf ), "This is some text in the buffer" );
        rmr_str2payload( mbuf, src_buf );                                                       // this uses bytes2payload, so only one invocation needed
@@ -133,7 +133,7 @@ int mbuf_api_test( ) {
        c = rmr_get_meid( NULL, NULL );
        errors += fail_if( c != NULL, "get meid with nil message buffer" );
        errors += fail_if( errno == 0, "(errno bad) get meid with nil msg buffer" );
-       
+
        c = rmr_get_meid( mbuf, NULL );                 // should allocate and return c
        errors += fail_if( c == NULL, "get meid with nil dest pointer (did not allocate a buffer)" );
        errors += fail_if( strcmp( c, "test-meid" ) != 0, "did not get expected meid from mbuffer" );
@@ -217,7 +217,7 @@ int mbuf_api_test( ) {
        state = rmr_get_trlen( NULL );                                                          // coverage test on nil check
        errors += fail_not_equal( state, 0, "get trace length with nil msg didn't return expected 0 status" );
 
-       
+
        src_buf[0] = 0;
        state = rmr_set_trace( mbuf, "foo bar was here", 17 );          // should force a realloc
        errors += fail_not_equal( state, 17, "bytes copied to trace (a) did not match expected size (b)" );
@@ -263,7 +263,7 @@ int mbuf_api_test( ) {
 
        buf = rmr_get_src( mbuf, src_buf );
        errors += fail_not_equal( buf, src_buf, "rmr_get_src didn't return expexted buffer pointer" );
-       
+
 
        return errors > 0;                      // overall exit code bad if errors
 }
index 30427b1..b1a1ebd 100644 (file)
@@ -1,14 +1,14 @@
 // : vi ts=4 sw=4 noet :
 /*
 ==================================================================================
-        Copyright (c) 2019 Nokia
-        Copyright (c) 2018-2019 AT&T Intellectual Property.
+           Copyright (c) 2019 Nokia
+           Copyright (c) 2018-2019 AT&T Intellectual Property.
 
    Licensed 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
+          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,
@@ -23,8 +23,8 @@
        Mnemonic:       mbuf_api_test.c
        Abstract:       Unit tests for the mbuf common API functions.
                                To allow the mbuf functions to be tested without the bulk of the
-                               RMr mechanics, we dummy up a couple of functions that are in 
-                               rmr[_nng].c. 
+                               RMr mechanics, we dummy up a couple of functions that are in
+                               rmr[_nng].c.
 
        Author:         E. Scott Daniels
        Date:           2 April 2019
@@ -63,7 +63,7 @@ extern void rmr_free_msg( rmr_mbuf_t* mbuf ) {
        we actually pulled in the sr static set.
 
        WARNING:  this is NOT a complete realloc.  We assume that we are testing
-                       just the trace length adjustment portion of the set_trace() 
+                       just the trace length adjustment portion of the set_trace()
                        API and are not striving to test the real realloc function. That
                        will be tested when the mbuf_api_static_test code is used by the
                        more generic RMr test.  So, not all fields in the realloc'd buffer
index 482244c..e0c9b6e 100644 (file)
@@ -1,14 +1,14 @@
 // : vi ts=4 sw=4 noet :
 /*
 ==================================================================================
-        Copyright (c) 2019 Nokia 
-        Copyright (c) 2018-2019 AT&T Intellectual Property.
+           Copyright (c) 2019 Nokia
+           Copyright (c) 2018-2019 AT&T Intellectual Property.
 
    Licensed 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
+          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,
@@ -21,7 +21,7 @@
 /*
        Mmemonic:       ring_static_test.c
        Abstract:       Test the ring funcitons. These are meant to be included at compile
-                               time by the test driver.  
+                               time by the test driver.
 
        Author:         E. Scott Daniels
        Date:           3 April 2019
@@ -41,9 +41,9 @@
 
 
 /*
-       Conduct a series of interleaved tests inserting i-factor 
+       Conduct a series of interleaved tests inserting i-factor
        values before beginning to pull values (i-factor must be
-       size - 2 smaller than the ring. 
+       size - 2 smaller than the ring.
        Returns 0 on success, 1 on insert failure and 2 on pull failure.
 */
 static int ie_test( void* r, int i_factor, long inserts ) {
@@ -118,7 +118,7 @@ static int ring_test( ) {
                        } else {
                                break;
                        }
-               }       
+               }
 
                if( *dp != i ) {
                        fprintf( stderr, "<FAIL> data at i=% isnt right; expected %d got %d\n", i, i, *dp );
@@ -129,7 +129,7 @@ static int ring_test( ) {
                return 1;
        }
        fprintf( stderr, "<OK>   extracted values were sane, got: %d\n", i-1 );
-               
+
        uta_ring_free( NULL );                                                  // ensure this doesn't blow up
        uta_ring_free( r );
        for( i = 2; i < 15; i++ ) {
@@ -151,7 +151,7 @@ static int ring_test( ) {
                                fprintf( stderr, "<FAIL> ie test for 66K inserts didn't return 0\n" );
                                return 1;
                        }
-       
+
                        uta_ring_free( r );
                }
                fprintf( stderr, "<OK>   all large insert/exctract tests pass ring size=%d\n", size );
index a06668f..5e1a81c 100644 (file)
@@ -1,14 +1,14 @@
 // : vi ts=4 sw=4 noet :
 /*
 ==================================================================================
-        Copyright (c) 2019 Nokia 
-        Copyright (c) 2018-2019 AT&T Intellectual Property.
+           Copyright (c) 2019 Nokia
+           Copyright (c) 2018-2019 AT&T Intellectual Property.
 
    Licensed 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
+          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,
@@ -20,7 +20,7 @@
 
 /*
        Mmemonic:       ring_test.c
-       Abstract:       This is a stand alone test driver for the ring module. It 
+       Abstract:       This is a stand alone test driver for the ring module. It
                                includes the static tests after setting up the environment
                                then invokes it.
 
index 3d09f28..e86c6f5 100644 (file)
@@ -1,14 +1,14 @@
 // : vi ts=4 sw=4 noet :
 /*
 ==================================================================================
-        Copyright (c) 2019 Nokia 
-        Copyright (c) 2018-2019 AT&T Intellectual Property.
+           Copyright (c) 2019 Nokia
+           Copyright (c) 2018-2019 AT&T Intellectual Property.
 
    Licensed 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
+          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,
@@ -23,7 +23,7 @@
        Abstract:       Specific tests related to the API functions in rmr_nng.c/rmr.c.
                                This should be included by a driver, but only the main RMr
                                driver and there likely not be a specific stand alone driver
-                               for just this small set of tests because of the depth of the 
+                               for just this small set of tests because of the depth of the
                                library needed to test at this level.
 
                                The message buffer specific API tests are in a different static
@@ -130,7 +130,7 @@ static int rmr_api_test( ) {
        } else {
                errors += fail_if( v < 0, "rmr_payload_size returned invalid size for good message" );
        }
-       
+
        v = rmr_get_rcvfd( NULL );
        errors += fail_if( v >= 0, "rmr_get_rcvfd returned a valid file descriptor when given nil context" );
        v = rmr_get_rcvfd( rmc );
@@ -221,7 +221,7 @@ static int rmr_api_test( ) {
        }
 
        errors += fail_if( i >= 16, "did not find expected message on queue" );
-               
+
        if( ! msg ) {
                msg = rmr_alloc_msg( rmc, 2048 );                               // something buggered above; get a new one
        }
@@ -270,12 +270,12 @@ static int rmr_api_test( ) {
        errors += fail_not_equal( state, 17, "len of trace data (a) returned after msg allocation was not expected size (b)" );
        state = strcmp( wbuf, "1904308620110417" );
        errors += fail_not_equal( state, 0, "trace data returned after tralloc was not correct" );
-       
+
        em_send_failures = 1;
        send_n_msgs( rmc, 30 );                 // send 30 messages with emulation failures
        em_send_failures = 0;
 
-       
+
        rmr_close( NULL );                      // drive for coverage
        rmr_close( rmc );                       // no return to check; drive for coverage
 
index 0b3068e..5dbeb21 100644 (file)
@@ -8,7 +8,7 @@
    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
+          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,
index 26f81b7..129eec1 100644 (file)
@@ -1,14 +1,14 @@
 // : vi ts=4 sw=4 noet :
 /*
 ==================================================================================
-        Copyright (c) 2019 Nokia 
-        Copyright (c) 2018-2019 AT&T Intellectual Property.
+           Copyright (c) 2019 Nokia 
+           Copyright (c) 2018-2019 AT&T Intellectual Property.
 
    Licensed 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
+          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,
index 9b936cc..d477391 100644 (file)
@@ -1,14 +1,14 @@
 // : vi ts=4 sw=4 noet :
 /*
 ==================================================================================
-        Copyright (c) 2019 Nokia 
-        Copyright (c) 2018-2019 AT&T Intellectual Property.
+           Copyright (c) 2019 Nokia
+           Copyright (c) 2018-2019 AT&T Intellectual Property.
 
    Licensed 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
+          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,
@@ -21,7 +21,7 @@
 /*
        Mmemonic:       sr_nng_static_test.c
        Abstract:       Test the send/receive funcitons. These are meant to be included at compile
-                               time by the test driver.  
+                               time by the test driver.
 
        Author:         E. Scott Daniels
        Date:           3 April 2019
@@ -45,16 +45,16 @@ static void gen_rt( uta_ctx_t* ctx ) {
        int             fd;
        char*   rt_stuff;               // strings for the route table
 
-       rt_stuff = 
-               "newrt|start\n"                                                         // false start to drive detection 
+       rt_stuff =
+               "newrt|start\n"                                                         // false start to drive detection
                "xxx|badentry to drive default case"
                "newrt|start\n"
-        "rte|0|localhost:4560,localhost:4562\n"
-        "rte|1|localhost:4562;localhost:4561,localhost:4569\n"
-        "rte|2|localhost:4562\n"
+           "rte|0|localhost:4560,localhost:4562\n"
+           "rte|1|localhost:4562;localhost:4561,localhost:4569\n"
+           "rte|2|localhost:4562\n"
            "rte|4|localhost:4561\n"
                "rte|5|localhost:4563\n"
-        "rte|6|localhost:4562\n"
+           "rte|6|localhost:4562\n"
                "newrt|end\n";
 
        fd = open( "utesting.rt", O_WRONLY | O_CREAT, 0600 );
@@ -77,7 +77,7 @@ static void gen_rt( uta_ctx_t* ctx ) {
 
        Send and receive functions are indirectly exercised from the rmr_nng_static_test
        module as it tests the user facing send/receive/call/rts functions. These tests
-       should exercise specific cases for the internal functions as they will not 
+       should exercise specific cases for the internal functions as they will not
        specifically be driven elsewhere.
 */
 static int sr_nng_test() {
@@ -121,7 +121,7 @@ static int sr_nng_test() {
        errors += fail_not_equal( mbuf->flags, mb2->flags, "clone did not duplicate flags" );
        errors += fail_not_equal( mbuf->alloc_len, mb2->alloc_len, "clone did not dup alloc-len" );
        errors += fail_not_equal( mbuf->state, mb2->state, "clone did not dup state" );
-       rmr_free_msg( mb2 );    
+       rmr_free_msg( mb2 );
 
        mbuf = rmr_send_msg( NULL, mbuf );
        errors += fail_if_nil( mbuf, "send with nil context but buffere didn't return buffer" );
@@ -184,7 +184,7 @@ static int sr_nng_test() {
        ctx->shutdown = 1;                      // should force rtc to quit on first pass
        rtc( NULL );                            // coverage test with nil pointer
        rtc( ctx );
-       
+
 
        return !!errors;
 }
index 181cd13..f0649c1 100644 (file)
@@ -1,13 +1,13 @@
 /*
 ==================================================================================
-        Copyright (c) 2019 Nokia 
-        Copyright (c) 2018-2019 AT&T Intellectual Property.
+           Copyright (c) 2019 Nokia
+           Copyright (c) 2018-2019 AT&T Intellectual Property.
 
    Licensed 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
+          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,
@@ -20,7 +20,7 @@
 
 /*
        Mnemonic:       symtab_static_test.c
-       Abstract:       This is the static function that should be included by 
+       Abstract:       This is the static function that should be included by
                                any test that wants to test the symbol table. It must
                                be included in the compile, and not built to object.
 
@@ -33,7 +33,7 @@
 
 #include "test_support.c"
 
-#ifndef GOOD 
+#ifndef GOOD
 #define GOOD 0
 #define BAD 1
 #endif
@@ -50,7 +50,7 @@ static void st_fetch( void* st, char* key, int class, int expected ) {
                if( !expected ) {
                        symtab_state = BAD;
                }
-               
+
        } else {
                fprintf( stderr, "<%s> string key st_fetch return nil\n", expected ? "FAIL" : "OK" );
                if( expected ) {
@@ -85,9 +85,9 @@ static void each_counter( void* a, void* b, const char* c, void* d, void* e ) {
 }
 
 static int symtab_test( ) {
-    void*   st;
-    char*   foo = "foo";
-    char*   bar = "bar";
+       void*   st;
+       char*   foo = "foo";
+       char*   bar = "bar";
        char*   goo = "goo";                            // name not in symtab
        int             i;
        int             class = 1;
@@ -95,27 +95,27 @@ static int symtab_test( ) {
        void*   p;
        int             errors = 0;
 
-    st = rmr_sym_alloc( 10 );                                          // alloc with small value to force adjustment inside
+       st = rmr_sym_alloc( 10 );                                               // alloc with small value to force adjustment inside
        errors += fail_if_nil( st, "symtab pointer" );
 
-    s = rmr_sym_put( st, foo, class, bar );                    // add entry with string key; returns 1 if it was inserted
+       s = rmr_sym_put( st, foo, class, bar );                 // add entry with string key; returns 1 if it was inserted
        errors += fail_if_false( s, "insert foo existed" );
 
-    s = rmr_sym_put( st, foo, class+1, bar );          // add to table with a different class
+       s = rmr_sym_put( st, foo, class+1, bar );               // add to table with a different class
        errors += fail_if_false( s, "insert foo existed" );
 
-    s = rmr_sym_put( st, foo, class, bar );                    // inserted above, should return not inserted (0)
+       s = rmr_sym_put( st, foo, class, bar );                 // inserted above, should return not inserted (0)
        errors += fail_if_true( s, "insert foo existed" );
 
        st_fetch( st, foo, class, 1 );
        st_fetch( st, goo, class, 0 );                                  // st_fetch non existant
-    rmr_sym_stats( st, 4 );                                                    // early stats at verbose level 4 so chatter is minimised
+       rmr_sym_stats( st, 4 );                                                 // early stats at verbose level 4 so chatter is minimised
        rmr_sym_dump( st );
 
        for( i = 2000; i < 3000; i++ ) {                        // bunch of dummy things to force chains in the table
                rmr_sym_map( st, i, foo );                                      // add entry with unsigned integer key
        }
-    rmr_sym_stats( st, 0 );                                                    // just the small facts to verify the 1000 we stuffed in
+       rmr_sym_stats( st, 0 );                                                 // just the small facts to verify the 1000 we stuffed in
        rmr_sym_ndel( st, 2001 );                                               // force a numeric key delete
        rmr_sym_ndel( st, 12001 );                                              // delete numeric key not there
 
@@ -131,12 +131,12 @@ static int symtab_test( ) {
        st_nfetch( st, 1234, 1 );
        st_nfetch( st, 2345, 1 );
 
-    rmr_sym_del( st, foo, 0 );         // drive for coverage
-    rmr_sym_stats( st, 0 );
+       rmr_sym_del( st, foo, 0 );              // drive for coverage
+       rmr_sym_stats( st, 0 );
 
        rmr_sym_free( NULL );                   // ensure it doesn't barf when given a nil pointer
        rmr_sym_free( st );
 
-    return !!( errors + symtab_state );
+       return !!( errors + symtab_state );
 }
 
index e2efa2b..f39085c 100644 (file)
@@ -1,13 +1,13 @@
 /*
 ==================================================================================
-        Copyright (c) 2019 Nokia 
-        Copyright (c) 2018-2019 AT&T Intellectual Property.
+           Copyright (c) 2019 Nokia
+           Copyright (c) 2018-2019 AT&T Intellectual Property.
 
    Licensed 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
+          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,
@@ -21,7 +21,7 @@
 /*
        Mnemonic:       symtab_test.c
        Abstract:       This is the unit test module that will drive tests against
-                               the symbol table portion of RMr.  Run with: 
+                               the symbol table portion of RMr.  Run with:
                                        ksh unit_test.ksh symtab_test.c
        Date:           1 April 2019
        Author:         E. Scott Daniels
@@ -48,7 +48,7 @@ static void fetch( void* st, char* key, int class, int expected ) {
                if( !expected ) {
                        state = BAD;
                }
-               
+
        } else {
                fprintf( stderr, "[%s] string key fetch return nil\n", expected ? "FAIL" : "OK" );
                if( expected ) {
@@ -83,36 +83,36 @@ static void each_counter( void* a, void* b, const char* c, void* d, void* e ) {
 }
 
 int main( ) {
-    void*   st;
-    char*   foo = "foo";
-    char*   bar = "bar";
+       void*   st;
+       char*   foo = "foo";
+       char*   bar = "bar";
        char*   goo = "goo";                            // name not in symtab
        int             i;
        int             class = 1;
        int             s;
        void*   p;
 
-    st = rmr_sym_alloc( 10 );                                          // alloc with small value to force adjustment inside
+       st = rmr_sym_alloc( 10 );                                               // alloc with small value to force adjustment inside
        fail_if_nil( st, "symtab pointer" );
 
-    s = rmr_sym_put( st, foo, class, bar );                    // add entry with string key; returns 1 if it was inserted
+       s = rmr_sym_put( st, foo, class, bar );                 // add entry with string key; returns 1 if it was inserted
        fail_if_false( s, "insert foo existed" );
 
-    s = rmr_sym_put( st, foo, class+1, bar );          // add to table with a different class
+       s = rmr_sym_put( st, foo, class+1, bar );               // add to table with a different class
        fail_if_false( s, "insert foo existed" );
 
-    s = rmr_sym_put( st, foo, class, bar );                    // inserted above, should return not inserted (0)
+       s = rmr_sym_put( st, foo, class, bar );                 // inserted above, should return not inserted (0)
        fail_if_true( s, "insert foo existed" );
 
        fetch( st, foo, class, 1 );
        fetch( st, goo, class, 0 );                                     // fetch non existant
-    rmr_sym_stats( st, 4 );                                                    // early stats at verbose level 4 so chatter is minimised
+       rmr_sym_stats( st, 4 );                                                 // early stats at verbose level 4 so chatter is minimised
        rmr_sym_dump( st );
 
        for( i = 2000; i < 3000; i++ ) {                        // bunch of dummy things to force chains in the table
                rmr_sym_map( st, i, foo );                                      // add entry with unsigned integer key
        }
-    rmr_sym_stats( st, 0 );                                                    // just the small facts to verify the 1000 we stuffed in
+       rmr_sym_stats( st, 0 );                                                 // just the small facts to verify the 1000 we stuffed in
        rmr_sym_ndel( st, 2001 );                                               // force a numeric key delete
        rmr_sym_ndel( st, 12001 );                                              // delete numeric key not there
 
@@ -129,13 +129,13 @@ int main( ) {
        nfetch( st, 2345, 1 );
 
 
-    rmr_sym_del( st, foo, 0 );
+       rmr_sym_del( st, foo, 0 );
 
-    rmr_sym_stats( st, 0 );
+       rmr_sym_stats( st, 0 );
 
        rmr_sym_free( NULL );                   // ensure it doesn't barf when given a nil pointer
        rmr_sym_free( st );
 
-    return state;
+       return state;
 }
 
index 76fe72b..685a43c 100644 (file)
@@ -1,13 +1,13 @@
 /*
 ==================================================================================
-       Copyright (c) 2019 Nokia 
+       Copyright (c) 2019 Nokia
        Copyright (c) 2018-2019 AT&T Intellectual Property.
 
    Licensed 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
+          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,
@@ -19,7 +19,7 @@
 
 /*
        Mnemonic:       test_nng_em.c
-       Abstract:       A nano/NNG message emulator for testing without needing to 
+       Abstract:       A nano/NNG message emulator for testing without needing to
                                actually have nanomsg, nng, or external processes.
                                We also emulate the epoll_wait() function for controlled
                                poll related testing.
@@ -39,13 +39,13 @@ static int em_send_failures = 0;    // test programme can set this to emulate eagai
 
 // ----------- epoll emulation ---------------------------------------------
 
-// CAUTION: sys/epoll.h must be included before this define and function will properly compile. 
+// CAUTION: sys/epoll.h must be included before this define and function will properly compile.
 #define epoll_wait em_wait
 /*
-       Every other call returns 1 ready; alternate calls return 0 ready. 
-       Mostly for testing the timeout receive call. First call should return 
+       Every other call returns 1 ready; alternate calls return 0 ready.
+       Mostly for testing the timeout receive call. First call should return
        something ready and the second should return nothing ready so we can
-       drive both cases. 
+       drive both cases.
 */
 static int em_wait( int fd, void* events, int n, int to ) {
        static int ready = 0;
@@ -76,7 +76,7 @@ static void en_set_retur( int rv ) {
 
 static int em_nng_foo() {
        fprintf( stderr, "emulated functions in play" );
-}                              
+}
 
 
 /*
@@ -96,7 +96,7 @@ struct em_msg {
 */
 
 /*
-       v2 message; should be able to use it for everything that is set up here as 
+       v2 message; should be able to use it for everything that is set up here as
        we don't add a payload even if setting a v1 type.
 */
 #define ALT_MSG_VER 1  // alternate every so often
@@ -111,12 +111,12 @@ struct em_msg {
        unsigned char meid[32];                         // managed element id.
        struct timespec ts;                                     // timestamp ???
 
-                                        // V2 extension
-    int32_t flags;                      // HFL_* constants
-    int32_t len0;                       // length of the RMr header data
-    int32_t len1;                       // length of the tracing data
-    int32_t len2;                       // length of data 1 (d1)
-    int32_t len3;                       // length of data 2 (d2)
+                                           // V2 extension
+       int32_t flags;                      // HFL_* constants
+       int32_t len0;                       // length of the RMr header data
+       int32_t len1;                       // length of the tracing data
+       int32_t len2;                       // length of data 1 (d1)
+       int32_t len3;                       // length of data 2 (d2)
 
 };
 
@@ -205,7 +205,7 @@ static int em_nng_send( nng_socket s, void* m, int l, int f ) {
 
 /*
        Emulate sending a message. If the global em_send_failures is set,
-       then every so often we fail with an EAGAIN to drive that part 
+       then every so often we fail with an EAGAIN to drive that part
        of the code in RMr.
 */
 static int em_sendmsg( nng_socket s, nng_msg* m, int i ) {
@@ -277,20 +277,20 @@ static int em_nng_getopt_int( nng_socket s, void* con, int* target ) {
 
 
 // nng redefines some of these to point directly to various 'versions' of the function (ugg, function versions, really?)
-#undef nng_recvmsg 
-#undef nng_free 
-#undef nng_pull_open 
-#undef nng_pull0_open 
-#undef nng_listen 
-#undef nng_close 
-#undef nng_getopt_int 
-#undef nng_push0_open 
-#undef nng_dial 
-#undef nng_setopt 
-#undef nng_sub_open 
-#undef nng_sub0_open 
-#undef nng_recv 
-#undef nng_alloc 
+#undef nng_recvmsg
+#undef nng_free
+#undef nng_pull_open
+#undef nng_pull0_open
+#undef nng_listen
+#undef nng_close
+#undef nng_getopt_int
+#undef nng_push0_open
+#undef nng_dial
+#undef nng_setopt
+#undef nng_sub_open
+#undef nng_sub0_open
+#undef nng_recv
+#undef nng_alloc
 
 #define nng_msg_alloc em_nng_msg_alloc
 #define nng_recvmsg em_nng_recvmsg
@@ -374,7 +374,7 @@ static int em_nn_recvmsg (int s, struct nn_msghdr *msghdr, int flags ) {
        return 1;
 }
 
-// nanomsg 
+// nanomsg
 #define nn_socket  em_nn_socket
 #define nn_close  em_nn_close
 #define nn_setsockopt  em_nn_setsockopt
@@ -387,7 +387,7 @@ static int em_nn_recvmsg (int s, struct nn_msghdr *msghdr, int flags ) {
 #define nn_sendmsg  em_nn_sendmsg
 #define nn_recvmsg  em_nn_recvmsg
 
-#endif 
+#endif
 
 
 #endif
index 49012c4..f036590 100644 (file)
@@ -1,14 +1,14 @@
 // : vi ts=4 sw=4 noet :
 /*
 ==================================================================================
-        Copyright (c) 2019 Nokia 
-        Copyright (c) 2018-2019 AT&T Intellectual Property.
+           Copyright (c) 2019 Nokia
+           Copyright (c) 2018-2019 AT&T Intellectual Property.
 
    Licensed 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
+          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,
@@ -65,7 +65,7 @@ void sig_clean_exit( int sign ) {
        exit( 0 );
 }
 
-/*     
+/*
        Setup all of the signal handling for signals that we want to force a clean exit:
        term, intr, hup, quit, usr1/2 alarm, etc.  All others we'll let default.
 */
@@ -74,7 +74,7 @@ static void set_signals( void ) {
        int     sig_list[] = { SIGINT, SIGQUIT, SIGILL, SIGALRM, SIGTERM, SIGUSR1 , SIGUSR2 };
        int i;
        int nele;               // number of elements in the list
-       
+
        nele = (int) ( sizeof( sig_list )/sizeof( int ) );              // convert raw size to the number of elements
        for( i = 0; i < nele; i ++ ) {
                memset( &sa, 0, sizeof( sa ) );
@@ -162,7 +162,7 @@ static rmr_mbuf_t* test_mk_msg( int len, int tr_len ) {
        new_msg->payload =  new_msg->header + PAYLOAD_OFFSET( hdr );
        new_msg->alloc_len = alen;
        new_msg->len = 0;
-       
+
        return new_msg;
 }
 #endif
index 66ddeb6..b8ea612 100644 (file)
@@ -1,14 +1,14 @@
 // : vi ts=4 sw=4 noet :
 /*
 ==================================================================================
-        Copyright (c) 2019 Nokia 
-        Copyright (c) 2018-2019 AT&T Intellectual Property.
+           Copyright (c) 2019 Nokia
+           Copyright (c) 2018-2019 AT&T Intellectual Property.
 
    Licensed 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
+          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,
@@ -43,7 +43,7 @@ static int tools_test( ) {
        uta_ctx_t ctx;                          // context for uta_lookup test
        void*   if_list;
 
-       
+
        // ------------------ tokenise tests -----------------------------------------------------------
        dbuf = strdup( buf );
        i = uta_tokenise( dbuf, tokens, 127, ',' );
@@ -69,7 +69,7 @@ static int tools_test( ) {
 
        j = uta_has_str( buf, "Mrs. Slate", ',', 27 );
        errors += fail_if_true( j >= 0, "has string not found Mrs. Slate" );
-       
+
        // ------------ host name 2 ip tests ---------------------------------------------------------
        hname = uta_h2ip( "192.168.1.2" );
        errors += fail_not_equal( strcmp( hname, "192.168.1.2" ), 0, "h2ip did not return IP address when given address" );
@@ -84,7 +84,7 @@ static int tools_test( ) {
        // ------------ rtg lookup test -------------------------------------------------------------
        ctx.rtg_port = 0;
        ctx.rtg_addr = NULL;
-       
+
        i = uta_lookup_rtg( NULL );                                             // ensure it handles a nil context
        errors += fail_if_true( i, "rtg lookup returned that it found something when not expected to (nil context)" );
 
index a29c0e2..eac19a6 100644 (file)
@@ -1,14 +1,14 @@
 // : vi ts=4 sw=4 noet :
 /*
 ==================================================================================
-        Copyright (c) 2019 Nokia 
-        Copyright (c) 2018-2019 AT&T Intellectual Property.
+           Copyright (c) 2019 Nokia
+           Copyright (c) 2018-2019 AT&T Intellectual Property.
 
    Licensed 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
+          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,
@@ -55,10 +55,10 @@ struct uta_ctx {
        route_table_t* new_rtable;      // route table under construction
        if_addrs_t*     ip_list;                // list manager of the IP addresses that are on our known interfaces
        void*   mring;                          // ring where msgs are queued while waiting for a call response msg
-       
+
        char*   rtg_addr;                       // addr/port of the route table generation publisher
        int             rtg_port;                       // the port that the rtg listens on
-       
+
        wh_mgt_t*       wormholes;              // management of user opened wormholes
        //epoll_stuff_t*        eps;            // epoll information needed for the rcv with timeout call
 
@@ -80,7 +80,7 @@ int main( ) {
        uta_ctx_t ctx;                          // context for uta_lookup test
        void*   if_list;
 
-       
+
        // ------------------ tokenise tests -----------------------------------------------------------
        dbuf = strdup( buf );
        i = uta_tokenise( dbuf, tokens, 127, ',' );
@@ -106,7 +106,7 @@ int main( ) {
 
        j = uta_has_str( buf, "Mrs. Slate", ',', 27 );
        errors += fail_if_true( j >= 0, "has string not found Mrs. Slate" );
-       
+
        // ------------ host name 2 ip tests ---------------------------------------------------------
        hname = uta_h2ip( "192.168.1.2" );
        errors += fail_not_equal( strcmp( hname, "192.168.1.2" ), 0, "h2ip did not return IP address when given address" );
@@ -121,7 +121,7 @@ int main( ) {
        // ------------ rtg lookup test -------------------------------------------------------------
        ctx.rtg_port = 0;
        ctx.rtg_addr = NULL;
-       
+
        i = uta_lookup_rtg( NULL );                                             // ensure it handles a nil context
        errors += fail_if_true( i, "rtg lookup returned that it found something when not expected to (nil context)" );
 
index 7a4246f..9cb8d82 100644 (file)
@@ -1,14 +1,14 @@
 // : vi ts=4 sw=4 noet :
 /*
 ==================================================================================
-        Copyright (c) 2019 Nokia 
-        Copyright (c) 2018-2019 AT&T Intellectual Property.
+           Copyright (c) 2019 Nokia
+           Copyright (c) 2018-2019 AT&T Intellectual Property.
 
    Licensed 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
+          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,
@@ -41,7 +41,7 @@
 
 /*
        Note that the last tests in this function destroy the context and message so
-       any tests added MUST be ahead of those tests. 
+       any tests added MUST be ahead of those tests.
 */
 static int worm_test( ) {
        uta_ctx_t* ctx;                 // context needed to test load static rt