Update.
[glibc.git] / nss / nss_files / files-ethers.c
blob17e02decadbade6e8b999afc2657801578dd4436
1 /* Copyright (C) 1996, 1997 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public License as
6 published by the Free Software Foundation; either version 2 of the
7 License, or (at your option) any later version.
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
14 You should have received a copy of the GNU Library General Public
15 License along with the GNU C Library; see the file COPYING.LIB. If not,
16 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 Boston, MA 02111-1307, USA. */
19 #include <string.h>
20 #include <netinet/if_ether.h>
22 /* Because the `ethers' lookup does not fit so well in the scheme so
23 we define a dummy struct here which helps us to use the available
24 functions. */
25 struct etherent
27 const char *e_name;
28 struct ether_addr e_addr;
30 struct etherent_data {};
32 #define ENTNAME etherent
33 #define DATABASE "ethers"
34 #include "files-parse.c"
35 LINE_PARSER
36 ("#",
37 /* Read the ethernet address: 6 x 8bit hexadecimal number. */
39 size_t cnt;
41 for (cnt = 0; cnt < 6; ++cnt)
43 unsigned int number;
45 if (cnt < 5)
46 INT_FIELD (number, ISCOLON , 0, 16, (unsigned int))
47 else
48 INT_FIELD (number, isspace, 0, 16, (unsigned int))
50 if (number > 0xff)
51 return 0;
52 result->e_addr.ether_addr_octet[cnt] = number;
55 STRING_FIELD (result->e_name, isspace, 1);
59 #include GENERIC
61 DB_LOOKUP (hostton, 1 + strlen (name), (".%s", name),
63 if (strcmp (result->e_name, name) == 0)
64 break;
65 }, const char *name)
67 DB_LOOKUP (ntohost, 18, ("=%x:%x:%x:%x:%x:%x",
68 addr->ether_addr_octet[0], addr->ether_addr_octet[1],
69 addr->ether_addr_octet[2], addr->ether_addr_octet[3],
70 addr->ether_addr_octet[4], addr->ether_addr_octet[5]),
72 if (memcmp (&result->e_addr, addr,
73 sizeof (struct ether_addr)) == 0)
74 break;
75 }, struct ether_addr *addr)