Obsolete pow10 functions.
[glibc.git] / nss / nss_files / files-service.c
blobb6ae51082ffb03982f113d0cfb897f5833ac2033
1 /* Services file parser in nss_files module.
2 Copyright (C) 1996-2017 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
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.
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.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
19 #include <netinet/in.h>
20 #include <netdb.h>
23 #define ENTNAME servent
24 #define DATABASE "services"
26 struct servent_data {};
28 #define TRAILING_LIST_MEMBER s_aliases
29 #define TRAILING_LIST_SEPARATOR_P isspace
30 #include "files-parse.c"
31 #define ISSLASH(c) ((c) == '/')
32 LINE_PARSER
33 ("#",
34 STRING_FIELD (result->s_name, isspace, 1);
35 INT_FIELD (result->s_port, ISSLASH, 10, 0, htons);
36 STRING_FIELD (result->s_proto, isspace, 1);
39 #include GENERIC
41 DB_LOOKUP (servbyname, ':',
42 strlen (name) + 2 + (proto == NULL ? 0 : strlen (proto)),
43 ("%s/%s", name, proto ?: ""),
45 /* Must match both protocol (if specified) and name. */
46 if (proto != NULL && strcmp (result->s_proto, proto))
47 /* A continue statement here breaks nss_db, because it
48 bypasses advancing to the next db entry, and it
49 doesn't make nss_files any more efficient. */;
50 else
51 LOOKUP_NAME (s_name, s_aliases)
53 const char *name, const char *proto)
55 DB_LOOKUP (servbyport, '=', 21 + (proto ? strlen (proto) : 0),
56 ("%zd/%s", (ssize_t) ntohs (port), proto ?: ""),
58 /* Must match both port and protocol. */
59 if (result->s_port == port
60 && (proto == NULL
61 || strcmp (result->s_proto, proto) == 0))
62 break;
63 }, int port, const char *proto)