Add SOL_TLS definition from Linux 4.13.
[glibc.git] / support / support_format_netent.c
blob020f5720d92b052dc649a9e80e5e2622be7170b4
1 /* Convert a struct netent object to a string.
2 Copyright (C) 2016-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 <support/format_nss.h>
21 #include <arpa/inet.h>
22 #include <stdio.h>
23 #include <support/support.h>
24 #include <support/xmemstream.h>
26 char *
27 support_format_netent (struct netent *e)
29 if (e == NULL)
31 char *value = support_format_herrno (h_errno);
32 char *result = xasprintf ("error: %s\n", value);
33 free (value);
34 return result;
37 struct xmemstream mem;
38 xopen_memstream (&mem);
40 if (e->n_name != NULL)
41 fprintf (mem.out, "name: %s\n", e->n_name);
42 for (char **ap = e->n_aliases; *ap != NULL; ++ap)
43 fprintf (mem.out, "alias: %s\n", *ap);
44 if (e->n_addrtype != AF_INET)
45 fprintf (mem.out, "addrtype: %d\n", e->n_addrtype);
46 /* On alpha, e->n_net is an unsigned long. */
47 unsigned int n_net = e->n_net;
48 fprintf (mem.out, "net: 0x%08x\n", n_net);
50 xfclose_memstream (&mem);
51 return mem.buffer;