inet: Adding inet_ntoa()
authorErwan Velu <erwanaliasr1@gmail.com>
Tue, 22 Mar 2011 21:13:10 +0000 (22:13 +0100)
committerErwan Velu <erwanaliasr1@gmail.com>
Tue, 22 Mar 2011 21:13:10 +0000 (22:13 +0100)
Adding inet_ntoa() as it could be useful to print pxe_boot_t structure

com32/include/netinet/in.h
com32/lib/Makefile
com32/lib/inet.c [new file with mode: 0644]

index ccf0475..eae1162 100644 (file)
@@ -53,4 +53,5 @@ struct in_addr {
     in_addr_t s_addr;
 };
 
+char * inet_ntoa (in_addr_t addr);
 #endif /* _NETINET_IN_H */
index 0614cf3..bf0da99 100644 (file)
@@ -30,6 +30,7 @@ LIBOBJS = \
        skipspace.o                                                     \
        chrreplace.o                                                    \
        bufprintf.o                                                     \
+       inet.o                                                          \
        \
        lmalloc.o lstrdup.o                                             \
        \
diff --git a/com32/lib/inet.c b/com32/lib/inet.c
new file mode 100644 (file)
index 0000000..18891e8
--- /dev/null
@@ -0,0 +1,37 @@
+/* ----------------------------------------------------------------------- *
+ *
+ *   Copyright 2011 Erwan Velu - All Rights Reserved
+ *
+ *   Permission is hereby granted, free of charge, to any person
+ *   obtaining a copy of this software and associated documentation
+ *   files (the "Software"), to deal in the Software without
+ *   restriction, including without limitation the rights to use,
+ *   copy, modify, merge, publish, distribute, sublicense, and/or
+ *   sell copies of the Software, and to permit persons to whom
+ *   the Software is furnished to do so, subject to the following
+ *   conditions:
+ *
+ *   The above copyright notice and this permission notice shall
+ *   be included in all copies or substantial portions of the Software.
+ *
+ *   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ *   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ *   OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ *   NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ *   HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ *   WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ *   FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ *   OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * -----------------------------------------------------------------------
+ */
+
+#include <stdio.h>
+#include <netinet/in.h>
+char * inet_ntoa ( in_addr_t addr ) {
+       static char buf[16] = {0}; 
+       uint8_t *bytes = ( uint8_t * ) &addr;
+       
+       sprintf ( buf, "%d.%d.%d.%d", bytes[0], bytes[1], bytes[2], bytes[3] );
+       return buf;
+}