bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug-gnulib] inet_r


From: Simon Josefsson
Subject: [Bug-gnulib] inet_r
Date: Fri, 17 Sep 2004 13:31:12 +0200
User-agent: Gnus/5.110003 (No Gnus v0.3) Emacs/21.3.50 (gnu/linux)

2004-09-17  Simon Josefsson  <address@hidden>

        * inet_r.h, inet_r.c: New files.

2004-09-17  Simon Josefsson  <address@hidden>

        * modules/inet_r: New file.

Index: lib/inet_r.h
===================================================================
RCS file: lib/inet_r.h
diff -N lib/inet_r.h
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ lib/inet_r.h        17 Sep 2004 11:29:57 -0000
@@ -0,0 +1,32 @@
+/* inet_r.h -- Thread safe version of arpa/inet.h function inet_ntoa.
+   Copyright (C) 2004 Free Software Foundation, Inc.
+   Written by Simon Josefsson.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software Foundation,
+   Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
+
+#ifndef INET_R_H
+# define INET_R_H
+
+/* Get struct in_addr. */
+#include <arpa/inet.h>
+
+/* Convert the Internet host address IN given in network byte order to
+   a string in standard numbers-and-dots notation.  The string is
+   stored in the provided buffer BUF, which must have room for at
+   least 16 bytes ("ddd.ddd.ddd.ddd\0").  A pointer to BUF is
+   returned. */
+char *inet_ntoa_r (struct in_addr in, char *buf);
+
+#endif /* INET_R_H */
Index: lib/inet_r.c
===================================================================
RCS file: lib/inet_r.c
diff -N lib/inet_r.c
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ lib/inet_r.c        17 Sep 2004 11:29:57 -0000
@@ -0,0 +1,40 @@
+/* inet_r.c -- Thread safe version of arpa/inet.h function inet_ntoa.
+   Copyright (C) 2004 Free Software Foundation, Inc.
+   Written by Simon Josefsson.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software Foundation,
+   Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+/* Specification. */
+#include "inet_r.h"
+
+/* Convert the Internet host address IN given in network byte order to
+   a string in standard numbers-and-dots notation.  The string is
+   stored in the provided buffer BUF, which must have room for at
+   least 16 bytes ("ddd.ddd.ddd.ddd\0").  A pointer to BUF is
+   returned. */
+char *
+inet_ntoa_r (struct in_addr in, char *buf)
+{
+  unsigned char *p;
+
+  p = (unsigned char *) &in.s_addr;
+  snprintf (buf, 16, "%d.%d.%d.%d", p[0], p[1], p[2], p[3]);
+
+  return buf;
+}
Index: modules/inet_r
===================================================================
RCS file: modules/inet_r
diff -N modules/inet_r
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ modules/inet_r      17 Sep 2004 11:29:57 -0000
@@ -0,0 +1,19 @@
+Description:
+Thread safe version of arpa/inet.h function inet_ntoa.
+
+Files:
+lib/inet_r.h
+lib/inet_r.c
+
+Depends-on:
+
+configure.ac:
+
+Makefile.am:
+lib_SOURCES += inet_r.h inet_r.c
+
+Include:
+"inet_r.h"
+
+Maintainer:
+Simon Josefsson




reply via email to

[Prev in Thread] Current Thread [Next in Thread]