marconi
May 25th, 2004, 01:51 PM
Hi all!
I need to add a little code to netdh.h file in the /usr/include/ directory. I dont have write access to it. How can I do it???? Is it not recommended at all to change the contents of this file.
Waiting for your valueable suggestions.
Best Regards
Andreas Masur
May 25th, 2004, 02:26 PM
Originally posted by marconi
I need to add a little code to netdh.h file in the /usr/include/ directory.
Well...I have two questions:
What do you need to add?
Why do you need to add it?
marconi
May 26th, 2004, 11:45 AM
Hi Andreas!
Including netdb.h needs socklen_t declaration.
simply including sys/types.h and sys/socket.h would have too many sideeffects (for example, include file requirement in gethostbyname(3) manpage gets changed).
I found a patch to cater this problem but that patch suggests to add some code in netdb.h I am giving that patch ih the following.
Waiting for your suggestion.
Index: include/netdb.h
===================================================================
RCS file: /cvsroot/basesrc/include/netdb.h,v
retrieving revision 1.17
diff -u -r1.17 netdb.h
--- netdb.h 2000/02/09 12:25:07 1.17
+++ netdb.h 2000/05/21 01:30:54
@@ -242,6 +242,17 @@
#define SCOPE_DELIMITER '%' /*KAME extension*/
#endif /* !_XOPEN_SOURCE */
+/*
+ * Data types
+ */
+#if !defined(_XOPEN_SOURCE)
+#include <sys/ansi.h>
+#ifndef socklen_t
+typedef __socklen_t socklen_t;
+#define socklen_t socklen_t
+#endif
+#endif
+
__BEGIN_DECLS
void endhostent __P((void));
void endnetent __P((void));
@@ -284,7 +295,7 @@
#if !defined(_XOPEN_SOURCE)
int getaddrinfo __P((const char *, const char *,
const struct addrinfo *, struct addrinfo **));
-int getnameinfo __P((const struct sockaddr *, size_t, char *,
+int getnameinfo __P((const struct sockaddr *, socklen_t, char *,
size_t, char *, size_t, int));
void freeaddrinfo __P((struct addrinfo *));
char *gai_strerror __P((int));
Index: sys/sys/Makefile
===================================================================
RCS file: /cvsroot/syssrc/sys/sys/Makefile,v
retrieving revision 1.19
diff -u -r1.19 Makefile
--- Makefile 2000/01/11 10:53:01 1.19
+++ Makefile 2000/05/21 01:30:55
@@ -21,6 +21,7 @@
tprintf.h trace.h tty.h ttychars.h ttycom.h ttydefaults.h ttydev.h \
types.h ucred.h uio.h un.h unistd.h unpcb.h user.h utsname.h \
vadvise.h vmmeter.h vnode.h vnode_if.h vsio.h wait.h
+INCS+= ansi.h
SYMLINKS= sys/exec_elf.h /usr/include/elf.h \
sys/fcntl.h /usr/include/fcntl.h \
Index: sys/sys/ansi.h
===================================================================
RCS file: ansi.h
diff -N ansi.h
--- /dev/null Sat May 20 14:30:01 2000
+++ ansi.h Sat May 20 18:30:55 2000
@@ -0,0 +1,45 @@
+/* $NetBSD$ */
+
+/*-
+ * Copyright (c) 1990, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)ansi.h 8.2 (Berkeley) 1/4/94
+ */
+
+#ifndef _SYS_ANSI_H_
+#define _SYS_ANSI_H_
+
+#include <sys/cdefs.h>
+
+typedef unsigned int __socklen_t;
+
+#endif /* _SYS_ANSI_H_ */
Index: sys/sys/socket.h
===================================================================
RCS file: /cvsroot/syssrc/sys/sys/socket.h,v
retrieving revision 1.54
diff -u -r1.54 socket.h
--- socket.h 2000/04/03 11:49:25 1.54
+++ socket.h 2000/05/21 01:30:57
@@ -74,7 +74,11 @@
/*
* Data types.
*/
-typedef unsigned int socklen_t;
+#include <sys/ansi.h>
+#ifndef socklen_t
+typedef __socklen_t socklen_t;
+#define socklen_t socklen_t
+#endif
/*
* Socket types.