diff src/core/ngx_inet.c @ 57:a499e0d1f16e

nginx-0.0.1-2003-01-30-10:28:09 import
author Igor Sysoev <igor@sysoev.ru>
date Thu, 30 Jan 2003 07:28:09 +0000
parents 53cb81681040
children 7ebc8b7fb816
line wrap: on
line diff
--- a/src/core/ngx_inet.c
+++ b/src/core/ngx_inet.c
@@ -4,10 +4,34 @@
 #include <ngx_inet.h>
 
 
+/* AF_INET only */
+
+size_t ngx_sock_ntop(int family, struct sockaddr *addr, char *text, size_t len)
+{
+    char                *p;
+    struct sockaddr_in  *addr_in;
+
+    if (family != AF_INET) {
+        return 0;
+    }
+
+    addr_in = (struct sockaddr_in *) addr;
+    p = (char *) &addr_in->sin_addr;
+
+    return ngx_snprintf(text, len > INET_ADDRSTRLEN ? INET_ADDRSTRLEN : len,
+                        "%u.%u.%u.%u",
+                        (unsigned char) p[0],
+                        (unsigned char) p[1],
+                        (unsigned char) p[2],
+                        (unsigned char) p[3]);
+}
+
+
 size_t ngx_inet_ntop(int family, char *addr, char *text, size_t len)
 {
-    if (family != AF_INET)
+    if (family != AF_INET) {
         return 0;
+    }
 
     return ngx_snprintf(text, len > INET_ADDRSTRLEN ? INET_ADDRSTRLEN : len,
                         "%u.%u.%u.%u",