#include "portab.h"
-static char UNUSED id[] = "$Id: tool.c,v 1.5 2006/03/24 23:25:39 fw Exp $";
+static char UNUSED id[] = "$Id: tool.c,v 1.8 2007/11/25 18:42:38 fw Exp $";
#include "imp.h"
#include <assert.h>
#include <stdio.h>
#include <string.h>
+#include <netinet/in.h>
+
#include "exp.h"
#include "tool.h"
start = String;
/* Remove whitespaces at the beginning of the string ... */
- while (*start == ' ' || *start == '\t')
+ while (*start == ' ' || *start == '\t' ||
+ *start == '\n' || *start == '\r')
start++;
if (!*start) {
- *String = 0;
+ *String = '\0';
return;
}
+
/* ... and at the end: */
end = strchr(start, '\0');
end--;
while ((*end == ' ' || *end == '\t' || *end == '\n' || *end == '\r')
- && end > start)
+ && end >= start)
end--;
/* New trailing NULL byte */
} /* ngt_TrimLastChr */
+GLOBAL bool
+ngt_IPStrToBin(const char *ip_str, struct in_addr *inaddr)
+{
+ /* AF is always AF_INET for now */
+#ifdef HAVE_INET_ATON
+ if (inet_aton(ip_str, inaddr) == 0)
+ return false;
+#else
+ inaddr->s_addr = inet_addr(ip_str);
+ if (inaddr->s_addr == (unsigned)-1)
+ return false;
+#endif
+ return true;
+}
+
+
+
+
/* -eof- */