Document use of CC and CFLAGS in more detail (bug 20980, bug 21234).
[glibc.git] / support / support_format_netent.c
blob0d15e784401005a1bd734c16d1a71f9735c27b67
1 /* Convert a struct netent object to a string.
2 Copyright (C) 2016-2018 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 <support/format_nss.h>
21 #include <arpa/inet.h>
22 #include <stdio.h>
23 #include <stdlib.h>
24 #include <support/support.h>
25 #include <support/xmemstream.h>
27 char *
28 support_format_netent (struct netent *e)
30 if (e == NULL)
32 char *value = support_format_herrno (h_errno);
33 char *result = xasprintf ("error: %s\n", value);
34 free (value);
35 return result;
38 struct xmemstream mem;
39 xopen_memstream (&mem);
41 if (e->n_name != NULL)
42 fprintf (mem.out, "name: %s\n", e->n_name);
43 for (char **ap = e->n_aliases; *ap != NULL; ++ap)
44 fprintf (mem.out, "alias: %s\n", *ap);
45 if (e->n_addrtype != AF_INET)
46 fprintf (mem.out, "addrtype: %d\n", e->n_addrtype);
47 /* On alpha, e->n_net is an unsigned long. */
48 unsigned int n_net = e->n_net;
49 fprintf (mem.out, "net: 0x%08x\n", n_net);
51 xfclose_memstream (&mem);
52 return mem.buffer;