nufw-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Nufw-devel] [PATCH 6 of 7] libnuclient.c: whitespace cleanup


From: Mikael Berthe
Subject: [Nufw-devel] [PATCH 6 of 7] libnuclient.c: whitespace cleanup
Date: Tue, 25 Oct 2005 20:16:04 +0200

# HG changeset patch
# User Mikael Berthe <address@hidden>
# Node ID eef2d0ab17a005a69ab20c5b96cf078058e79ea2
# Parent  29d7392e29ed5052a745f89c56618ad12ebb22aa
libnuclient.c: whitespace cleanup

diff -r 29d7392e29ed -r eef2d0ab17a0 src/clients/lib/libnuclient.c
--- a/src/clients/lib/libnuclient.c     Sun Oct 23 22:06:32 2005 +0200
+++ b/src/clients/lib/libnuclient.c     Sun Oct 23 22:11:07 2005 +0200
@@ -69,7 +69,7 @@
 /* callbacks we support */
 int nu_getrealm(void *context __attribute__((unused)), int id,
                const char **availrealms __attribute__((unused)),
-               const char **result) 
+               const char **result)
 {
        // NuAuth * session = (NuAuth*)context;
 
@@ -85,7 +85,7 @@
 
 int nu_get_usersecret(sasl_conn_t *conn __attribute__((unused)),
                void *context __attribute__((unused)), int id,
-               sasl_secret_t **psecret) 
+               sasl_secret_t **psecret)
 {
        NuAuth* session=(NuAuth *)context;
        if ((session->password == NULL) && session->passwd_callback) {
@@ -113,7 +113,7 @@
        } else {
                *psecret = (sasl_secret_t*)calloc(sizeof(sasl_secret_t) + 
strlen(session->password)+1,sizeof(char));
                (*psecret)->len = strlen(session->password);
-               strncpy((*psecret)->data, session->password ,(*psecret)->len +1 
);
+               strncpy((*psecret)->data, session->password, (*psecret)->len +1 
);
        }
 
        return SASL_OK;
@@ -148,7 +148,7 @@
 
                        if (session->protocol == 2)
                                *result=session->username;
-                       else { 
+                       else {
                                char number[12];
                                snprintf(number,12,"%lu",session->userid);
                                *result=strdup(number);
@@ -170,7 +170,7 @@
                        }
                        if (session->protocol == 2)
                                *result=session->username;
-                       else { 
+                       else {
                                char number[12];
                                snprintf(number,12,"%lu",session->userid);
                                *result=strdup(number);
@@ -215,7 +215,7 @@
                session=NULL;
        }
        sasl_done();
-       gnutls_global_deinit(); 
+       gnutls_global_deinit();
 }
 
 static void recv_message(NuAuth* session){
@@ -234,7 +234,7 @@
        header.proto=0x2;
        header.msg_type=USER_REQUEST;
        header.option=0;
-#ifdef WORDS_BIGENDIAN 
+#ifdef WORDS_BIGENDIAN
        header.length=swap16(sizeof(struct nuv2_header)++sizeof(struct 
nuv2_authreq)+sizeof(struct nuv2_authfield_hello));
 #else
        header.length=sizeof(struct nuv2_header)+sizeof(struct 
nuv2_authreq)+sizeof(struct nuv2_authfield_hello);
@@ -243,13 +243,13 @@
        memcpy(message,&header,sizeof(struct nuv2_header));
        authreq.packet_id=session->packet_id++;
        authreq.packet_length=sizeof(struct nuv2_authreq)+sizeof(struct 
nuv2_authfield_hello);
-                               
+
        pointer=message+sizeof(struct nuv2_header);
        memcpy(pointer,&authreq,sizeof(struct nuv2_authreq));
        pointer+=sizeof(struct nuv2_authreq);
        hellofield.type=HELLO_FIELD;
        hellofield.option=0;
-#ifdef WORDS_BIGENDIAN 
+#ifdef WORDS_BIGENDIAN
        hellofield.length=swap16(sizeof(struct nuv2_authfield_hello));
 #else
        hellofield.length=sizeof(struct nuv2_authfield_hello);
@@ -282,13 +282,13 @@
                                                                              
)<=0){
 #if DEBUG_ENABLE
                                                                printf("write 
failed at %s:%d\n",__FILE__,__LINE__);
-#endif 
+#endif
                                                                if (conn_on){
                                                                        
nu_exit_clean(session);
                                                                }
                                                                return;
                                                        }
-                                               } 
+                                               }
 
                                                break;
                                        default:
@@ -349,7 +349,7 @@
 
        newc = (conn_t *) calloc (1,sizeof (conn_t));
        if (!newc) {
-               panic ("memory exhausted");     
+               panic ("memory exhausted");
        }
 
        memcpy (newc, c, sizeof (conn_t));
@@ -363,7 +363,7 @@
 
 /*
  * tcptable_find ()
- * 
+ *
  * Find a connection in a table, return connection if found, NULL otherwise.
  */
 static conn_t* tcptable_find (conntable_t *ct, conn_t *c)
@@ -377,7 +377,7 @@
        while (bucket != NULL) {
                if (
                                (c->rmt == bucket->rmt) && (c->rmtp == 
bucket->rmtp) &&
-                               (c->lcl == bucket->lcl) && (c->lclp == 
bucket->lclp) 
+                               (c->lcl == bucket->lcl) && (c->lclp == 
bucket->lclp)
                   ) {
                        return bucket;
                }
@@ -389,7 +389,7 @@
 
 /*
  * tcptable_read ()
- * 
+ *
  * Read /proc/net/tcp and add all connections to the table if connections
  * of that type are being watched.
  */
@@ -503,7 +503,7 @@
                mech = buf;
 #if MECH_CHOICE
        }
-#endif 
+#endif
 
        r = sasl_client_start(conn, mech, NULL, &data, &len, &chosenmech);
        //r = sasl_client_start(conn, mech, &client_interact, &data, &len, 
&chosenmech);
@@ -576,7 +576,7 @@
        header.proto=0x2;
        header.msg_type=USER_HELLO;
        header.option=0;
-#ifdef WORDS_BIGENDIAN 
+#ifdef WORDS_BIGENDIAN
        header.length=swap16(sizeof(struct nuv2_header));
 #else
        header.length=sizeof(struct nuv2_header);
@@ -587,10 +587,10 @@
                if( gnutls_record_send(*(session->tls),&header,sizeof(struct 
nuv2_header))<=0){
 #if DEBUG_ENABLE
                        printf("write failed at %s:%d\n",__FILE__,__LINE__);
-#endif 
+#endif
                        return 0;
                }
-       } 
+       }
        return 1;
 }
 
@@ -615,7 +615,7 @@
                                struct nuv2_authfield_app appfield;
                                size_t len=0;
                                /* get application name from inode */
-                               const char * appname = prg_cache_get(c->ino); 
+                               const char * appname = prg_cache_get(c->ino);
                                header.proto=0x2;
                                header.msg_type=USER_REQUEST;
                                header.option=0;
@@ -624,13 +624,13 @@
                                authreq.packet_length=sizeof(struct 
nuv2_authreq)+sizeof(struct nuv2_authfield_ipv4);
                                authfield.type=IPV4_FIELD;
                                authfield.option=0;
-#ifdef WORDS_BIGENDIAN 
+#ifdef WORDS_BIGENDIAN
                                authfield.length=swap16(sizeof(struct 
nuv2_authfield_ipv4));
 #else
                                authfield.length=sizeof(struct 
nuv2_authfield_ipv4);
 #endif
 
-#ifdef WORDS_BIGENDIAN 
+#ifdef WORDS_BIGENDIAN
                                authfield.src=swap32(c->lcl);
                                authfield.dst=swap32(c->rmt);
 #else
@@ -640,7 +640,7 @@
                                authfield.proto=6;
                                authfield.flags=0;
                                authfield.FUSE=0;
-#ifdef WORDS_BIGENDIAN 
+#ifdef WORDS_BIGENDIAN
                                authfield.sport=swap16(c->lclp);
                                authfield.dport=swap16(c->rmtp);
 #else
@@ -649,21 +649,21 @@
 #endif
                                /* application field  */
                                appfield.type=APP_FIELD;
-                               if (1) { 
+                               if (1) {
                                        appfield.option=APP_TYPE_NAME;
                                        enc_appname=calloc(128,sizeof(char));
                                        if ( 
sasl_encode64(appname,strlen(appname),
-                                                               enc_appname,128 
,&len) == SASL_BUFOVER ){
+                                                               
enc_appname,128, &len) == SASL_BUFOVER ){
                                                /* realloc */
                                                
enc_appname=realloc(enc_appname,len);
                                                /* encode */
                                                
sasl_encode64(appname,strlen(appname),
-                                                               enc_appname, 
len ,&len);
+                                                               enc_appname, 
len, &len);
                                        }
                                        appfield.length=4+len;
                                        appfield.datas=enc_appname;
                                        authreq.packet_length+=appfield.length;
-#ifdef WORDS_BIGENDIAN 
+#ifdef WORDS_BIGENDIAN
                                        
authreq.packet_length=swap16(authreq.packet_length);
 #endif
                                } else {
@@ -671,12 +671,12 @@
                                        appfield.option=APP_TYPE_SHA1;
                                        enc_appname=calloc(128,sizeof(char));
                                        if ( 
sasl_encode64(appname,strlen(appname),
-                                                               enc_appname,128 
,&len) == SASL_BUFOVER ){
+                                                               
enc_appname,128, &len) == SASL_BUFOVER ){
                                                /* realloc */
                                                
enc_appname=realloc(enc_appname,len);
                                                /* encode */
                                                
sasl_encode64(appname,strlen(appname),
-                                                               enc_appname, 
len ,&len);
+                                                               enc_appname, 
len, &len);
                                        }
                                        appfield.length=4+len;
                                        
appfield.datas=g_strconcat(enc_appname,";",sha1_sig);
@@ -691,7 +691,7 @@
                                fflush(NULL);
                                if (header.length < PACKET_SIZE){
                                        pointer=datas;
-#ifdef WORDS_BIGENDIAN 
+#ifdef WORDS_BIGENDIAN
                                        header.length=swap16(header.length);
                                        appfield.length=swap16(appfield.length);
                                        memcpy(pointer,&header,sizeof(struct 
nuv2_header));
@@ -730,7 +730,7 @@
                        printf("write failed\n");
                        return 0;
                }
-       } 
+       }
        if (enc_appname)
                free(enc_appname);
        return 1;
@@ -815,9 +815,9 @@
        session=(NuAuth*) calloc(1,sizeof(NuAuth));
 
        sasl_callback_t callbacks[] = {
-               { SASL_CB_GETREALM, &nu_getrealm, session }, 
-               { SASL_CB_USER, &nu_get_userdatas, session }, 
-               { SASL_CB_AUTHNAME, &nu_get_userdatas, session } , 
+               { SASL_CB_GETREALM, &nu_getrealm, session },
+               { SASL_CB_USER, &nu_get_userdatas, session },
+               { SASL_CB_AUTHNAME, &nu_get_userdatas, session },
                { SASL_CB_PASS, &nu_get_usersecret, session },
                { SASL_CB_LIST_END, NULL, NULL }
        };
@@ -872,8 +872,8 @@
        }
        /* create socket stuff */
        if (ssl_on){
-               char keyfile[256]; 
-               char certfile[256]; 
+               char keyfile[256];
+               char certfile[256];
                sasl_conn_t *conn;
                /* compute patch keyfile */
                snprintf(keyfile,255,"%s/.nufw/key.pem",getenv("HOME"));
@@ -916,7 +916,7 @@
                gnutls_certificate_set_dh_params( xcred, dh_params);
 
 
-               /* Initialize TLS session 
+               /* Initialize TLS session
                */
                session->tls=(gnutls_session*)calloc(1,sizeof(gnutls_session));
                gnutls_init(session->tls, GNUTLS_CLIENT);
@@ -934,7 +934,7 @@
                /* connect */
                if (session->socket <= 0){
                        nu_exit_clean(session);
-                       errno=EADDRNOTAVAIL;    
+                       errno=EADDRNOTAVAIL;
                        return NULL;
                }
 
@@ -954,7 +954,7 @@
                        nu_exit_clean(session);
                        errno=ECONNRESET;
                        return NULL;
-               } 
+               }
                /* certificate verification */
                ret = gnutls_certificate_verify_peers(*(session->tls));
                if (ret <0){
@@ -1045,7 +1045,7 @@
                        osfield.option=OS_SRV;
                        osfield_length=sizeof(struct nuv2_authfield)+actuallen;
                        buf=alloca(osfield_length);
-#ifdef WORDS_BIGENDIAN 
+#ifdef WORDS_BIGENDIAN
                        osfield.length=swap16(osfield_length);
 #else
                        osfield.length=osfield_length;
@@ -1066,7 +1066,7 @@
                                        session->mode=*(buf+1);
                                } else {
                                        session->mode=SRV_TYPE_POLL;
-                               }       
+                               }
                        }
 
                }
@@ -1085,7 +1085,7 @@
        /* alloc ct */
        if (tcptable_init (&new) == 0) panic ("tcptable_init failed");
        session->ct=new;
-       /* set init variable */ 
+       /* set init variable */
        conn_on =1;
        recv_started=0;
        return session;
@@ -1125,7 +1125,7 @@
        /* TODO : use less ressource be clever */
        if (recv_started == 0){
                pthread_t recvthread;
-               pthread_create(&recvthread,NULL ,recv_message,session );
+               pthread_create(&recvthread, NULL, recv_message, session);
                recv_started =1;
        }
 
@@ -1135,7 +1135,7 @@
        else {
                if ((time(NULL) - timestamp_last_sent) > SENT_TEST_INTERVAL){
                        if (! send_hello_pckt(session)){
-                               nu_exit_clean(session); 
+                               nu_exit_clean(session);
                        }
                        timestamp_last_sent=time(NULL);
                }
@@ -1172,9 +1172,9 @@
        session->tls_passwd_callback=tlscred_callback;
 
        sasl_callback_t callbacks[] = {
-               { SASL_CB_GETREALM, &nu_getrealm, session }, 
-               { SASL_CB_USER, &nu_get_userdatas, session }, 
-               { SASL_CB_AUTHNAME, &nu_get_userdatas, session } , 
+               { SASL_CB_GETREALM, &nu_getrealm, session },
+               { SASL_CB_USER, &nu_get_userdatas, session },
+               { SASL_CB_AUTHNAME, &nu_get_userdatas, session },
                { SASL_CB_PASS, &nu_get_usersecret, session },
                { SASL_CB_LIST_END, NULL, NULL }
        };
@@ -1252,7 +1252,7 @@
        gnutls_certificate_set_dh_params( xcred, dh_params);
 
 
-       /* Initialize TLS session 
+       /* Initialize TLS session
        */
        session->tls=(gnutls_session*)calloc(1,sizeof(gnutls_session));
        gnutls_init(session->tls, GNUTLS_CLIENT);
@@ -1265,7 +1265,7 @@
        no_action.sa_handler = SIG_IGN;
        sigemptyset( & (no_action.sa_mask));
        no_action.sa_flags = 0;
-       if ( sigaction( SIGPIPE, & no_action , NULL ) != 0) {
+       if ( sigaction( SIGPIPE, & no_action, NULL ) != 0) {
                printf("Error setting \n");
                exit(1);
        }
@@ -1275,7 +1275,7 @@
        /* connect */
        if (session->socket <= 0){
                nu_exit_clean(session);
-               errno=EADDRNOTAVAIL;    
+               errno=EADDRNOTAVAIL;
                return NULL;
        }
        option_value=1;
@@ -1303,7 +1303,7 @@
                nu_exit_clean(session);
                errno=ECONNRESET;
                return NULL;
-       } 
+       }
        /* certificate verification */
        ret = gnutls_certificate_verify_peers(*(session->tls));
        if (ret <0){
@@ -1340,7 +1340,7 @@
 
        if (! session->username){
                if (session->username_callback){
-                       session->username=session->username_callback(); 
+                       session->username=session->username_callback();
                } else {
                        printf("can't call username callback\n");
                }
@@ -1388,7 +1388,7 @@
                osfield.length=4+actuallen;
                buf=alloca(osfield.length);
                osfield_length=osfield.length;
-#ifdef WORDS_BIGENDIAN 
+#ifdef WORDS_BIGENDIAN
                osfield.length=swap16(osfield.length);
 #endif
                pointer = buf ;
@@ -1408,7 +1408,7 @@
                                session->mode=*(buf+1);
                        } else {
                                session->mode=SRV_TYPE_POLL;
-                       }       
+                       }
                }
 
        }
@@ -1421,7 +1421,7 @@
        /* alloc ct */
        if (tcptable_init (&new) == 0) panic ("tcptable_init failed");
        session->ct=new;
-       /* set init variable */ 
+       /* set init variable */
        conn_on =1;
        recv_started=0;
        timestamp_last_sent=time(NULL);




reply via email to

[Prev in Thread] Current Thread [Next in Thread]