[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] clean tabs, trailing whitespace



Update of /home/or/cvsroot/src/common
In directory moria.mit.edu:/home2/arma/work/onion/cvs/src/common

Modified Files:
	aes.c fakepoll.c log.c log.h torint.h tortls.c util.c util.h 
Log Message:
clean tabs, trailing whitespace


Index: aes.c
===================================================================
RCS file: /home/or/cvsroot/src/common/aes.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- aes.c	8 Oct 2003 02:04:07 -0000	1.5
+++ aes.c	17 Dec 2003 21:14:13 -0000	1.6
@@ -44,7 +44,7 @@
   u8 pos;
 };
 
-static void 
+static void
 _aes_fill_buf(aes_cnt_cipher_t *cipher)
 {
   u32 counter0 = cipher->counter0;

Index: fakepoll.c
===================================================================
RCS file: /home/or/cvsroot/src/common/fakepoll.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- fakepoll.c	13 Dec 2003 22:52:54 -0000	1.14
+++ fakepoll.c	17 Dec 2003 21:14:13 -0000	1.15
@@ -33,61 +33,61 @@
 poll(struct pollfd *ufds, unsigned int nfds, int timeout)
 {
         int idx, maxfd, fd;
-	int r;
+        int r;
 #ifdef MS_WINDOWS
         int any_fds_set = 0;
 #endif
-	fd_set readfds, writefds, exceptfds;
+        fd_set readfds, writefds, exceptfds;
 #ifdef USING_FAKE_TIMEVAL
 #undef timeval
 #undef tv_sec
 #undef tv_usec
 #endif
-	struct timeval _timeout;
-	_timeout.tv_sec = timeout/1000;
-	_timeout.tv_usec = (timeout%1000)*1000;
-	FD_ZERO(&readfds);
-	FD_ZERO(&writefds);
-	FD_ZERO(&exceptfds);
+        struct timeval _timeout;
+        _timeout.tv_sec = timeout/1000;
+        _timeout.tv_usec = (timeout%1000)*1000;
+        FD_ZERO(&readfds);
+        FD_ZERO(&writefds);
+        FD_ZERO(&exceptfds);
 
-	maxfd = -1;
-	for (idx = 0; idx < nfds; ++idx) {
+        maxfd = -1;
+        for (idx = 0; idx < nfds; ++idx) {
                 ufds[idx].revents = 0;
-		fd = ufds[idx].fd;
+                fd = ufds[idx].fd;
                 if (fd > maxfd) {
                   maxfd = fd;
 #ifdef MS_WINDOWS
                   any_fds_set = 1;
 #endif
                 }
-		if (ufds[idx].events & POLLIN)
-			FD_SET(fd, &readfds);
-		if (ufds[idx].events & POLLOUT)
-			FD_SET(fd, &writefds);
-		FD_SET(fd, &exceptfds);
-	}
+                if (ufds[idx].events & POLLIN)
+                        FD_SET(fd, &readfds);
+                if (ufds[idx].events & POLLOUT)
+                        FD_SET(fd, &writefds);
+                FD_SET(fd, &exceptfds);
+        }
 #ifdef MS_WINDOWS
         if (!any_fds_set) {
                 Sleep(timeout);
                 return 0;
         }
 #endif
-	r = select(maxfd+1, &readfds, &writefds, &exceptfds, 
-		   timeout == -1 ? NULL : &_timeout);
-	if (r <= 0)
-		return r;
-	r = 0;
-	for (idx = 0; idx < nfds; ++idx) {
-		fd = ufds[idx].fd;
-		if (FD_ISSET(fd, &readfds))
-			ufds[idx].revents |= POLLIN;
-		if (FD_ISSET(fd, &writefds))
-			ufds[idx].revents |= POLLOUT;
-		if (FD_ISSET(fd, &exceptfds))
-			ufds[idx].revents |= POLLERR;
-		if (ufds[idx].revents)
-			++r;
-	}
-	return r;
+        r = select(maxfd+1, &readfds, &writefds, &exceptfds,
+                   timeout == -1 ? NULL : &_timeout);
+        if (r <= 0)
+                return r;
+        r = 0;
+        for (idx = 0; idx < nfds; ++idx) {
+                fd = ufds[idx].fd;
+                if (FD_ISSET(fd, &readfds))
+                        ufds[idx].revents |= POLLIN;
+                if (FD_ISSET(fd, &writefds))
+                        ufds[idx].revents |= POLLOUT;
+                if (FD_ISSET(fd, &exceptfds))
+                        ufds[idx].revents |= POLLERR;
+                if (ufds[idx].revents)
+                        ++r;
+        }
+        return r;
 }
 #endif

Index: log.c
===================================================================
RCS file: /home/or/cvsroot/src/common/log.c,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -d -r1.29 -r1.30
--- log.c	14 Dec 2003 09:58:40 -0000	1.29
+++ log.c	17 Dec 2003 21:14:13 -0000	1.30
@@ -30,8 +30,8 @@
  * of 'logv' so that we never format a message more than once.
  */
 static INLINE void format_msg(char *buf, size_t buf_len,
-                              int severity, const char *funcname, 
-                              const char *format, va_list ap) 
+                              int severity, const char *funcname,
+                              const char *format, va_list ap)
 {
   time_t t;
   struct timeval now;
@@ -44,7 +44,7 @@
 
   n = strftime(buf, buf_len, "%b %d %H:%M:%S", localtime(&t));
   n += snprintf(buf+n, buf_len-n,
-                ".%.3ld [%s] ", 
+                ".%.3ld [%s] ",
                 (long)now.tv_usec / 1000, sev_to_string(severity));
   if(n > buf_len)
     n = buf_len-1; /* the *nprintf funcs return how many bytes they
@@ -64,7 +64,7 @@
   buf[n+1]='\0';
 }
 
-static void 
+static void
 logv(int severity, const char *funcname, const char *format, va_list ap)
 {
   char buf[10024];
@@ -145,7 +145,7 @@
  * If opening the logfile fails, -1 is returned and
  * errno is set appropriately (by fopen)
  */
-int add_file_log(int loglevel, const char *filename) 
+int add_file_log(int loglevel, const char *filename)
 {
   FILE *f;
   f = fopen(filename, "a");

Index: log.h
===================================================================
RCS file: /home/or/cvsroot/src/common/log.h,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- log.h	14 Dec 2003 09:58:40 -0000	1.19
+++ log.h	17 Dec 2003 21:14:13 -0000	1.20
@@ -14,13 +14,13 @@
 #define LOG_ERR     4
 #endif
 
-/* magic to make GCC check for proper format strings. */ 
+/* magic to make GCC check for proper format strings. */
 #ifdef __GNUC__
 #define CHECK_PRINTF(formatIdx, firstArg) \
    __attribute__ ((format (printf, formatIdx, firstArg)))
 #else
-#define CHECK_PRINTF(formatIdx, firstArg) 
-#endif 
+#define CHECK_PRINTF(formatIdx, firstArg)
+#endif
 
 void add_stream_log(int loglevel, const char *name, FILE *stream);
 int add_file_log(int severity, const char *filename);

Index: torint.h
===================================================================
RCS file: /home/or/cvsroot/src/common/torint.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- torint.h	11 Aug 2003 23:21:51 -0000	1.4
+++ torint.h	17 Dec 2003 21:14:13 -0000	1.5
@@ -51,7 +51,7 @@
 #endif
 #endif
 
-#if (SIZEOF_SHORT == 2) 
+#if (SIZEOF_SHORT == 2)
 #ifndef HAVE_INT16_T
 typedef signed short int16_t;
 #define HAVE_INT16_T
@@ -63,7 +63,7 @@
 #endif
 
 
-#if (SIZEOF_INT == 2) 
+#if (SIZEOF_INT == 2)
 #ifndef HAVE_INT16_T
 typedef signed int int16_t;
 #define HAVE_INT16_T

Index: tortls.c
===================================================================
RCS file: /home/or/cvsroot/src/common/tortls.c,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -d -r1.32 -r1.33
--- tortls.c	18 Nov 2003 06:52:25 -0000	1.32
+++ tortls.c	17 Dec 2003 21:14:13 -0000	1.33
@@ -34,16 +34,16 @@
 struct tor_tls_st {
   SSL *ssl;
   int socket;
-  enum { 
-    TOR_TLS_ST_HANDSHAKE, TOR_TLS_ST_OPEN, TOR_TLS_ST_GOTCLOSE, 
+  enum {
+    TOR_TLS_ST_HANDSHAKE, TOR_TLS_ST_OPEN, TOR_TLS_ST_GOTCLOSE,
     TOR_TLS_ST_SENTCLOSE, TOR_TLS_ST_CLOSED
   } state;
   int isServer;
   int wantwrite_n; /* 0 normally, >0 if we returned wantwrite last time */
 };
 
-static X509* tor_tls_create_certificate(crypto_pk_env_t *rsa, 
-                                        const char *nickname); 
+static X509* tor_tls_create_certificate(crypto_pk_env_t *rsa,
+                                        const char *nickname);
 
 /* global tls context, keep it here because nobody else needs to touch it */
 static tor_tls_context *global_tls_context = NULL;
@@ -80,7 +80,7 @@
 
 static int
 tor_tls_get_error(tor_tls *tls, int r, int extra,
-		  const char *doing, int severity)
+                  const char *doing, int severity)
 {
   int err = SSL_get_error(tls->ssl, r);
   switch (err) {
@@ -92,13 +92,13 @@
       return TOR_TLS_WANTWRITE;
     case SSL_ERROR_SYSCALL:
       if (extra&CATCH_SYSCALL)
-	return _TOR_TLS_SYSCALL;
+        return _TOR_TLS_SYSCALL;
       log(severity, "TLS error: <syscall error> (errno=%d)",errno);
       tls_log_errors(severity, doing);
       return TOR_TLS_ERROR;
     case SSL_ERROR_ZERO_RETURN:
       if (extra&CATCH_ZERO)
-	return _TOR_TLS_ZERORETURN;
+        return _TOR_TLS_ZERORETURN;
       log(severity, "TLS error: Zero return");
       tls_log_errors(severity, doing);
       return TOR_TLS_ERROR;
@@ -119,7 +119,7 @@
   }
 }
 
-static int always_accept_verify_cb(int preverify_ok, 
+static int always_accept_verify_cb(int preverify_ok,
                                    X509_STORE_CTX *x509_ctx)
 {
   /* We always accept peer certs and complete the handshake.  We don't validate
@@ -132,7 +132,7 @@
  * by 'certfile'.  Return 0 on success, -1 for failure.
  */
 X509 *
-tor_tls_create_certificate(crypto_pk_env_t *rsa, 
+tor_tls_create_certificate(crypto_pk_env_t *rsa,
                            const char *nickname)
 {
   time_t start_time, end_time;
@@ -140,7 +140,7 @@
   X509 *x509 = NULL;
   X509_NAME *name = NULL;
   int nid;
-  
+
   tor_tls_init();
 
   start_time = time(NULL);
@@ -154,7 +154,7 @@
     goto error;
   if (!(ASN1_INTEGER_set(X509_get_serialNumber(x509), (long)start_time)))
     goto error;
-  
+
   if (!(name = X509_NAME_new()))
     goto error;
   if ((nid = OBJ_txt2nid("organizationName")) == NID_undef) goto error;
@@ -163,7 +163,7 @@
   if ((nid = OBJ_txt2nid("commonName")) == NID_undef) goto error;
   if (!(X509_NAME_add_entry_by_NID(name, nid, MBSTRING_ASC,
                                    (char*)nickname, -1, -1, 0))) goto error;
-  
+
   if (!(X509_set_issuer_name(x509, name)))
     goto error;
   if (!(X509_set_subject_name(x509, name)))
@@ -181,7 +181,7 @@
   goto done;
  error:
   if (x509) {
-    X509_free(x509); 
+    X509_free(x509);
     x509 = NULL;
   }
  done:
@@ -198,11 +198,11 @@
  * is needed. */
 #define CIPHER_LIST TLS1_TXT_DHE_RSA_WITH_AES_128_SHA
 #elif defined(TLS1_TXT_DHE_RSA_WITH_AES_128_SHA)
-/* Some people are running OpenSSL before 0.9.7, but we aren't.  
+/* Some people are running OpenSSL before 0.9.7, but we aren't.
  * We can support AES and 3DES.
  */
 #define CIPHER_LIST (TLS1_TXT_DHE_RSA_WITH_AES_128_SHA ":" \
-		     SSL3_TXT_EDH_RSA_DES_192_CBC3_SHA)
+                     SSL3_TXT_EDH_RSA_DES_192_CBC3_SHA)
 #else
 /* We're running OpenSSL before 0.9.7. We only support 3DES. */
 #define CIPHER_LIST SSL3_TXT_EDH_RSA_DES_192_CBC3_SHA
@@ -221,7 +221,7 @@
   EVP_PKEY *pkey = NULL;
   tor_tls_context *result;
   X509 *cert = NULL;
-  
+
   tor_tls_init();
 
   if (rsa) {
@@ -264,10 +264,10 @@
   dh = crypto_dh_new();
   SSL_CTX_set_tmp_dh(result->ctx, dh->dh);
   crypto_dh_free(dh);
-  SSL_CTX_set_verify(result->ctx, SSL_VERIFY_PEER, 
+  SSL_CTX_set_verify(result->ctx, SSL_VERIFY_PEER,
                      always_accept_verify_cb);
   /* let us realloc bufs that we're writing from */
-  SSL_CTX_set_mode(result->ctx, SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER);  
+  SSL_CTX_set_mode(result->ctx, SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER);
 
   /* Free the old context if one exists. */
   if (global_tls_context) {
@@ -292,7 +292,7 @@
   return -1;
 }
 
-/* Create a new TLS object from a TLS context, a filedescriptor, and 
+/* Create a new TLS object from a TLS context, a filedescriptor, and
  * a flag to determine whether it is functioning as a server.
  */
 tor_tls *
@@ -346,7 +346,7 @@
 
 /* Underlying function for TLS writing.  Write up to 'n' characters
  * from 'cp' onto 'tls'.  On success, returns the number of characters
- * written.  On failure, returns TOR_TLS_ERROR, TOR_TLS_WANTREAD, 
+ * written.  On failure, returns TOR_TLS_ERROR, TOR_TLS_WANTREAD,
  * or TOR_TLS_WANTWRITE.
  */
 int
@@ -394,11 +394,11 @@
   }
   r = tor_tls_get_error(tls,r,0, "handshaking", LOG_INFO);
   if (r == TOR_TLS_DONE) {
-    tls->state = TOR_TLS_ST_OPEN; 
+    tls->state = TOR_TLS_ST_OPEN;
   }
   return r;
 }
-  
+
 /* Shut down an open tls connection 'tls'.  When finished, returns
  * TOR_TLS_DONE.  On failure, returns TOR_TLS_ERROR, TOR_TLS_WANTREAD,
  * or TOR_TLS_WANTWRITE.
@@ -416,15 +416,15 @@
        * we read until the other side has closed too.
        */
       do {
-	r = SSL_read(tls->ssl, buf, 128);
+        r = SSL_read(tls->ssl, buf, 128);
       } while (r>0);
-      err = tor_tls_get_error(tls, r, CATCH_ZERO, "reading to shut down", 
-			      LOG_INFO);
+      err = tor_tls_get_error(tls, r, CATCH_ZERO, "reading to shut down",
+                              LOG_INFO);
       if (err == _TOR_TLS_ZERORETURN) {
-	tls->state = TOR_TLS_ST_GOTCLOSE;
-	/* fall through... */
+        tls->state = TOR_TLS_ST_GOTCLOSE;
+        /* fall through... */
       } else {
-	return err;
+        return err;
       }
     }
 
@@ -434,11 +434,11 @@
       tls->state = TOR_TLS_ST_CLOSED;
       return TOR_TLS_DONE;
     }
-    err = tor_tls_get_error(tls, r, CATCH_SYSCALL|CATCH_ZERO, "shutting down", 
-			    LOG_INFO);
+    err = tor_tls_get_error(tls, r, CATCH_SYSCALL|CATCH_ZERO, "shutting down",
+                            LOG_INFO);
     if (err == _TOR_TLS_SYSCALL) {
       /* The underlying TCP connection closed while we were shutting down. */
-      tls->state = TOR_TLS_ST_CLOSED; 
+      tls->state = TOR_TLS_ST_CLOSED;
       return TOR_TLS_DONE;
     } else if (err == _TOR_TLS_ZERORETURN) {
       /* The TLS connection says that it sent a shutdown record, but
@@ -446,11 +446,11 @@
        * happened before, then go back to the start of the function
        * and try to read.
        */
-      if (tls->state == TOR_TLS_ST_GOTCLOSE || 
-	  tls->state == TOR_TLS_ST_SENTCLOSE) {
-	log(LOG_WARN, 
-	    "TLS returned \"half-closed\" value while already half-closed");
-	return TOR_TLS_ERROR;
+      if (tls->state == TOR_TLS_ST_GOTCLOSE ||
+         tls->state == TOR_TLS_ST_SENTCLOSE) {
+        log(LOG_WARN,
+            "TLS returned \"half-closed\" value while already half-closed");
+        return TOR_TLS_ERROR;
       }
       tls->state = TOR_TLS_ST_SENTCLOSE;
       /* fall through ... */
@@ -479,7 +479,7 @@
   X509_NAME *name = NULL;
   int nid;
   int lenout;
-  
+
   if (!(cert = SSL_get_peer_certificate(tls->ssl))) {
     log_fn(LOG_WARN, "Peer has no certificate");
     goto error;
@@ -490,7 +490,7 @@
   }
   if ((nid = OBJ_txt2nid("commonName")) == NID_undef)
     goto error;
-  
+
   lenout = X509_NAME_get_text_by_NID(name, nid, buf, buflen);
   if (lenout == -1)
     goto error;
@@ -521,7 +521,7 @@
   crypto_pk_env_t *r = NULL;
   if (!(cert = SSL_get_peer_certificate(tls->ssl)))
     return NULL;
-  
+
   now = time(NULL);
   t = now + CERT_ALLOW_SKEW;
   if (X509_cmp_time(X509_get_notBefore(cert), &t) > 0) {
@@ -533,7 +533,7 @@
     log_fn(LOG_WARN,"Certificate already expired; possible clock skew.");
     goto done;
   }
-  
+
   /* Get the public key. */
   if (!(pkey = X509_get_pubkey(cert))) {
     log_fn(LOG_WARN,"X509_get_pubkey returned null");
@@ -554,7 +554,7 @@
 
   r = _crypto_new_pk_env_rsa(rsa);
   rsa = NULL;
-  
+
  done:
   if (cert)
     X509_free(cert);
@@ -565,7 +565,7 @@
   return r;
 }
 
-int 
+int
 tor_tls_get_pending_bytes(tor_tls *tls)
 {
   assert(tls);

Index: util.c
===================================================================
RCS file: /home/or/cvsroot/src/common/util.c,v
retrieving revision 1.50
retrieving revision 1.51
diff -u -d -r1.50 -r1.51
--- util.c	15 Dec 2003 21:35:52 -0000	1.50
+++ util.c	17 Dec 2003 21:14:13 -0000	1.51
@@ -164,7 +164,7 @@
 }
 
 const char *eat_whitespace_no_nl(const char *s) {
-  while(*s == ' ' || *s == '\t') 
+  while(*s == ' ' || *s == '\t')
     ++s;
   return s;
 }
@@ -250,11 +250,11 @@
   --y2;
   return (y2/4 - y1/4) - (y2/100 - y1/100) + (y2/400 - y1/400);
 }
-static const int days_per_month[] = 
+static const int days_per_month[] =
   { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
 
 time_t tor_timegm (struct tm *tm) {
-  /* This is a pretty ironclad timegm implementation, snarfed from Python2.2. 
+  /* This is a pretty ironclad timegm implementation, snarfed from Python2.2.
    * It's way more brute-force than fiddling with tzset().
    */
   time_t ret;
@@ -270,7 +270,7 @@
     ++days;
   days += tm->tm_mday - 1;
   hours = days*24 + tm->tm_hour;
-  
+
   minutes = hours*60 + tm->tm_min;
   ret = minutes*60 + tm->tm_sec;
   return ret;
@@ -380,7 +380,7 @@
     struct sockaddr_in listen_addr;
     struct sockaddr_in connect_addr;
     int size;
-    
+
     if (protocol
 #ifdef AF_UNIX
         || family != AF_UNIX
@@ -495,7 +495,7 @@
     }
     return FN_ERROR;
   }
-  if (st.st_mode & S_IFDIR) 
+  if (st.st_mode & S_IFDIR)
     return FN_DIR;
   else if (st.st_mode & S_IFREG)
     return FN_FILE;
@@ -510,17 +510,17 @@
   struct stat st;
   if (stat(dirname, &st)) {
     if (errno != ENOENT) {
-      log(LOG_WARN, "Directory %s cannot be read: %s", dirname, 
+      log(LOG_WARN, "Directory %s cannot be read: %s", dirname,
           strerror(errno));
       return -1;
-    } 
+    }
     if (!create) {
       log(LOG_WARN, "Directory %s does not exist.", dirname);
       return -1;
     }
-    log(LOG_INFO, "Creating directory %s", dirname); 
+    log(LOG_INFO, "Creating directory %s", dirname);
     if (mkdir(dirname, 0700)) {
-      log(LOG_WARN, "Error creating directory %s: %s", dirname, 
+      log(LOG_WARN, "Error creating directory %s: %s", dirname,
           strerror(errno));
       return -1;
     } else {
@@ -538,7 +538,7 @@
   if (st.st_mode & 0077) {
     log(LOG_WARN, "Fixing permissions on directory %s", dirname);
     if (chmod(dirname, 0700)) {
-      log(LOG_WARN, "Could not chmod directory %s: %s", dirname, 
+      log(LOG_WARN, "Could not chmod directory %s: %s", dirname,
           strerror(errno));
       return -1;
     } else {
@@ -561,12 +561,12 @@
   strcpy(tempname,fname);
   strcat(tempname,".tmp");
   if ((fd = open(tempname, O_WRONLY|O_CREAT|O_TRUNC, 0600)) < 0) {
-    log(LOG_WARN, "Couldn't open %s for writing: %s", tempname, 
+    log(LOG_WARN, "Couldn't open %s for writing: %s", tempname,
         strerror(errno));
     return -1;
   }
   if (!(file = fdopen(fd, "w"))) {
-    log(LOG_WARN, "Couldn't fdopen %s for writing: %s", tempname, 
+    log(LOG_WARN, "Couldn't fdopen %s for writing: %s", tempname,
         strerror(errno));
     close(fd); return -1;
   }
@@ -615,7 +615,7 @@
     return NULL;
   }
   close(fd);
-  
+
   string[statbuf.st_size] = 0; /* null terminate it */
   return string;
 }
@@ -686,7 +686,7 @@
       snprintf(uname_result, 255, "%s %s %s %s %s",
                u.sysname, u.nodename, u.release, u.version, u.machine);
       uname_result[255] = '\0';
-    } else 
+    } else
 #endif
       {
         strcpy(uname_result, "Unknown platform");
@@ -780,7 +780,7 @@
   return 0;
 #endif
 
-  log_fn(LOG_ERR, 
+  log_fn(LOG_ERR,
          "User or group specified, but switching users is not supported.");
 
   return -1;

Index: util.h
===================================================================
RCS file: /home/or/cvsroot/src/common/util.h,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -d -r1.28 -r1.29
--- util.h	14 Dec 2003 05:00:09 -0000	1.28
+++ util.h	17 Dec 2003 21:14:13 -0000	1.29
@@ -90,7 +90,7 @@
 void write_pidfile(char *filename);
 int switch_id(char *user, char *group);
 
-/* For stupid historical reasons, windows sockets have an independent set of 
+/* For stupid historical reasons, windows sockets have an independent set of
  * errnos which they use as the fancy strikes them.
  */
 #ifdef MS_WINDOWS