changeset 2271:ab05e25d2df2 libavformat

use sscanf to parse address
author benoit
date Thu, 19 Jul 2007 10:48:50 +0000
parents 1d4b38ae5f1b
children 8963d9ed1859
files os_support.c
diffstat 1 files changed, 2 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/os_support.c	Wed Jul 18 11:56:36 2007 +0000
+++ b/os_support.c	Thu Jul 19 10:48:50 2007 +0000
@@ -41,19 +41,10 @@
 
 int inet_aton (const char * str, struct in_addr * add)
 {
-    const char * pch = str;
     unsigned int add1 = 0, add2 = 0, add3 = 0, add4 = 0;
 
-    add1 = atoi(pch);
-    pch = strpbrk(pch,".");
-    if (!pch) return 0;
-    add2 = atoi(pch);
-    pch = strpbrk(pch,".");
-    if (!pch) return 0;
-    add3 = atoi(pch);
-    pch = strpbrk(pch,".");
-    if (!pch) return 0;
-    add4 = atoi(pch);
+    if (sscanf(str, "%d.%d.%d.%d", &add1, &add2, &add3, &add4) != 4)
+        return 0;
 
     if (!add1 || (add1|add2|add3|add4) > 255) return 0;