source: branches/libc-0.6/src/libctests/glibc/inet/bug-if1.c

Last change on this file was 2046, checked in by bird, 20 years ago

Porting to FreeBSD 64-bit

  • Property cvs2svn:cvs-rev set to 1.2
  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 1.7 KB
Line 
1/* Copyright (C) 2004 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Ulrich Drepper <drepper@redhat.com>, 2004.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, write to the Free
17 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18 02111-1307 USA. */
19
20#include <errno.h>
21#include <limits.h>
22#include <stdio.h>
23#include <string.h>
24#ifdef __BSD__
25# include <sys/types.h>
26# include <sys/socket.h>
27#endif
28#include <net/if.h>
29
30
31static int
32do_test (void)
33{
34 char buf[IF_NAMESIZE];
35 /* Index 0 is always invalid (see RFC 3493). */
36 char *cp = if_indextoname (0, buf);
37 if (cp != NULL)
38 {
39 printf ("invalid index returned result \"%s\"\n", cp);
40 return 1;
41 }
42 else if (errno != ENXIO)
43 {
44 int err = errno;
45 char errbuf1[256];
46 char errbuf2[256];
47
48 printf ("errno = %d (%s), expected %d (%s)\n",
49 err, strerror_r (err, errbuf1, sizeof (errbuf1)),
50 ENXIO, strerror_r (ENXIO, errbuf2, sizeof (errbuf2)));
51 return 1;
52 }
53
54 return 0;
55}
56
57#define TEST_FUNCTION do_test ()
58#include "../test-skeleton.c"
Note: See TracBrowser for help on using the repository browser.