[pisa-src] r1831 - in trunk/pairing: common.c common.h packet_handler_accept.c

  • From: Diego Biurrun <diego@xxxxxxxxxx>
  • To: pisa-src@xxxxxxxxxxxxx
  • Date: Thu, 26 Nov 2009 17:44:42 +0100

Author: biurrun
Date: Thu Nov 26 17:44:42 2009
New Revision: 1831

Log:
Move itoa() to the only place it is used and mark as static.

Modified:
   trunk/pairing/common.c
   trunk/pairing/common.h
   trunk/pairing/packet_handler_accept.c

Modified: trunk/pairing/common.c
==============================================================================
--- trunk/pairing/common.c      Thu Nov 26 17:41:43 2009        (r1830)
+++ trunk/pairing/common.c      Thu Nov 26 17:44:42 2009        (r1831)
@@ -52,43 +52,6 @@
 }
 
 
-/* Stolen from http://en.wikipedia.org/wiki/Itoa */
-/** Convert an integer to a string
- *
- *  @param n Original integer
- *  @param s String to hold result
-*/
-void itoa(int n, char s[])
-{
-       int i, sign;
-
-       if ((sign = n) < 0)  /* record sign */
-               n = -n;          /* make n positive */
-       i = 0;
-       do
-       {       /* generate digits in reverse order */
-               s[i++] = n % 10 + '0';   /* get next digit */
-       } while ((n /= 10) > 0);     /* delete it */
-
-       if (sign < 0)
-               s[i++] = '-';
-
-       s[i] = '\0';
-
-// reverse(s); // Orignal; inserted code below
-
-       {
-               int c, j;
-               for (i = 0, j = strlen(s)-1; i<j; i++, j--)
-               {
-                       c = s[i];
-                       s[i] = s[j];
-                       s[j] = c;
-               }
-       }
-
-} 
-
 /**
  * Reads default expiration from FILE_SERVER_CONFIG
  *

Modified: trunk/pairing/common.h
==============================================================================
--- trunk/pairing/common.h      Thu Nov 26 17:41:43 2009        (r1830)
+++ trunk/pairing/common.h      Thu Nov 26 17:44:42 2009        (r1831)
@@ -26,7 +26,6 @@
 // Function prototypes
 int valid_addr(char *addr);
 int valid_nickname(char *nickname);
-void itoa(int n, char s[]);
 int get_default_expiration(char *buffer);
 int get_default_expiration_from_config(char *buffer,const char *filename);
 int valid_date_string(const char *expiration_date,struct tm *tm_expiration);

Modified: trunk/pairing/packet_handler_accept.c
==============================================================================
--- trunk/pairing/packet_handler_accept.c       Thu Nov 26 17:41:43 2009        
(r1830)
+++ trunk/pairing/packet_handler_accept.c       Thu Nov 26 17:44:42 2009        
(r1831)
@@ -252,6 +252,44 @@
 }
 
 
+/* Stolen from http://en.wikipedia.org/wiki/Itoa */
+/** Convert an integer to a string
+ *
+ *  @param n Original integer
+ *  @param s String to hold result
+*/
+static void itoa(int n, char s[])
+{
+       int i, sign;
+
+       if ((sign = n) < 0)  /* record sign */
+               n = -n;          /* make n positive */
+       i = 0;
+       do
+       {       /* generate digits in reverse order */
+               s[i++] = n % 10 + '0';   /* get next digit */
+       } while ((n /= 10) > 0);     /* delete it */
+
+       if (sign < 0)
+               s[i++] = '-';
+
+       s[i] = '\0';
+
+// reverse(s); // Orignal; inserted code below
+
+       {
+               int c, j;
+               for (i = 0, j = strlen(s)-1; i<j; i++, j--)
+               {
+                       c = s[i];
+                       s[i] = s[j];
+                       s[j] = c;
+               }
+       }
+
+}
+
+
 /** Creates a new password with the associated information and writes it all
  *      in FILE_AUTHORIZED_HOSTS.
  *

Other related posts:

  • » [pisa-src] r1831 - in trunk/pairing: common.c common.h packet_handler_accept.c - Diego Biurrun