| 1 |
148 |
jeremybenn |
/* Copyright (C) 1991, 1996, 1997, 2000, 2001 Free Software Foundation, Inc.
|
| 2 |
|
|
This file is part of the GNU C Library.
|
| 3 |
|
|
|
| 4 |
|
|
The GNU C Library is free software; you can redistribute it and/or
|
| 5 |
|
|
modify it under the terms of the GNU Lesser General Public
|
| 6 |
|
|
License as published by the Free Software Foundation; either
|
| 7 |
|
|
version 2.1 of the License, or (at your option) any later version.
|
| 8 |
|
|
|
| 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 |
|
|
Lesser General Public License for more details.
|
| 13 |
|
|
|
| 14 |
|
|
You should have received a copy of the GNU Lesser General Public
|
| 15 |
|
|
License along with the GNU C Library; if not, write to the Free
|
| 16 |
|
|
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
| 17 |
|
|
02111-1307 USA. */
|
| 18 |
|
|
|
| 19 |
|
|
#define _GNU_SOURCE 1
|
| 20 |
|
|
|
| 21 |
|
|
#include <stddef.h>
|
| 22 |
|
|
#include <errno.h>
|
| 23 |
|
|
#include <unistd.h>
|
| 24 |
|
|
#include <string.h>
|
| 25 |
|
|
#include <confstr.h>
|
| 26 |
|
|
|
| 27 |
|
|
/* If BUF is not NULL and LEN > 0, fill in at most LEN - 1 bytes
|
| 28 |
|
|
of BUF with the value corresponding to NAME and zero-terminate BUF.
|
| 29 |
|
|
Return the number of bytes required to hold NAME's entire value. */
|
| 30 |
|
|
size_t
|
| 31 |
|
|
confstr (name, buf, len)
|
| 32 |
|
|
int name;
|
| 33 |
|
|
char *buf;
|
| 34 |
|
|
size_t len;
|
| 35 |
|
|
{
|
| 36 |
|
|
const char *string;
|
| 37 |
|
|
size_t string_len;
|
| 38 |
|
|
|
| 39 |
|
|
switch (name)
|
| 40 |
|
|
{
|
| 41 |
|
|
case _CS_PATH:
|
| 42 |
|
|
{
|
| 43 |
|
|
static const char cs_path[] = CS_PATH;
|
| 44 |
|
|
string = cs_path;
|
| 45 |
|
|
string_len = sizeof (cs_path);
|
| 46 |
|
|
}
|
| 47 |
|
|
break;
|
| 48 |
|
|
|
| 49 |
|
|
case _CS_V6_WIDTH_RESTRICTED_ENVS:
|
| 50 |
|
|
/* We have to return a newline-separated list of named of
|
| 51 |
|
|
programming environements in which the widths of blksize_t,
|
| 52 |
|
|
cc_t, mode_t, nfds_t, pid_t, ptrdiff_t, size_t, speed_t,
|
| 53 |
|
|
ssize_t, suseconds_t, tcflag_t, useconds_t, wchar_t, and
|
| 54 |
|
|
wint_t types are no greater than the width of type long.
|
| 55 |
|
|
|
| 56 |
|
|
Currently this means all environment which the system allows. */
|
| 57 |
|
|
{
|
| 58 |
|
|
static const char restenvs[] =
|
| 59 |
|
|
#if _POSIX_V6_ILP32_OFF32 > 0
|
| 60 |
|
|
"_POSIX_V6_ILP32_OFF32"
|
| 61 |
|
|
#endif
|
| 62 |
|
|
#if _POSIX_V6_ILP32_OFFBIG > 0
|
| 63 |
|
|
# if _POSIX_V6_ILP32_OFF32 > 0
|
| 64 |
|
|
"\n"
|
| 65 |
|
|
# endif
|
| 66 |
|
|
"_POSIX_V6_ILP32_OFFBIG"
|
| 67 |
|
|
#endif
|
| 68 |
|
|
#if _POSIX_V6_LP64_OFF64 > 0
|
| 69 |
|
|
# if _POSIX_V6_ILP32_OFF32 > 0 || _POSIX_V6_ILP32_OFFBIG > 0
|
| 70 |
|
|
"\n"
|
| 71 |
|
|
# endif
|
| 72 |
|
|
"_POSIX_V6_LP64_OFF64"
|
| 73 |
|
|
#endif
|
| 74 |
|
|
#if _POSIX_V6_LPBIG_OFFBIG > 0
|
| 75 |
|
|
# if _POSIX_V6_ILP32_OFF32 > 0 || _POSIX_V6_ILP32_OFFBIG > 0 \
|
| 76 |
|
|
|| _POSIX_V6_LP64_OFF64 > 0
|
| 77 |
|
|
"\n"
|
| 78 |
|
|
# endif
|
| 79 |
|
|
"_POSIX_V6_LPBIG_OFFBIG"
|
| 80 |
|
|
#endif
|
| 81 |
|
|
;
|
| 82 |
|
|
string = restenvs;
|
| 83 |
|
|
string_len = sizeof (restenvs);
|
| 84 |
|
|
}
|
| 85 |
|
|
break;
|
| 86 |
|
|
|
| 87 |
|
|
case _CS_XBS5_ILP32_OFFBIG_CFLAGS:
|
| 88 |
|
|
case _CS_POSIX_V6_ILP32_OFFBIG_CFLAGS:
|
| 89 |
|
|
case _CS_LFS_CFLAGS:
|
| 90 |
|
|
#if _XBS5_LP64_OFF64 == -1 && _XBS5_LPBIG_OFFBIG == -1 && _XBS5_ILP32_OFFBIG == 1
|
| 91 |
|
|
/* Signal that we want the new ABI. */
|
| 92 |
|
|
{
|
| 93 |
|
|
static const char file_offset[] = "-D_FILE_OFFSET_BITS=64";
|
| 94 |
|
|
string = file_offset;
|
| 95 |
|
|
string_len = sizeof (file_offset);
|
| 96 |
|
|
}
|
| 97 |
|
|
break;
|
| 98 |
|
|
#endif
|
| 99 |
|
|
/* FALLTHROUGH */
|
| 100 |
|
|
|
| 101 |
|
|
case _CS_LFS_LINTFLAGS:
|
| 102 |
|
|
case _CS_LFS_LDFLAGS:
|
| 103 |
|
|
case _CS_LFS_LIBS:
|
| 104 |
|
|
case _CS_LFS64_CFLAGS:
|
| 105 |
|
|
case _CS_LFS64_LINTFLAGS:
|
| 106 |
|
|
case _CS_LFS64_LDFLAGS:
|
| 107 |
|
|
case _CS_LFS64_LIBS:
|
| 108 |
|
|
|
| 109 |
|
|
case _CS_XBS5_ILP32_OFF32_CFLAGS:
|
| 110 |
|
|
case _CS_XBS5_ILP32_OFF32_LDFLAGS:
|
| 111 |
|
|
case _CS_XBS5_ILP32_OFF32_LIBS:
|
| 112 |
|
|
case _CS_XBS5_ILP32_OFF32_LINTFLAGS:
|
| 113 |
|
|
case _CS_XBS5_ILP32_OFFBIG_LDFLAGS:
|
| 114 |
|
|
case _CS_XBS5_ILP32_OFFBIG_LIBS:
|
| 115 |
|
|
case _CS_XBS5_ILP32_OFFBIG_LINTFLAGS:
|
| 116 |
|
|
case _CS_XBS5_LP64_OFF64_CFLAGS:
|
| 117 |
|
|
case _CS_XBS5_LP64_OFF64_LDFLAGS:
|
| 118 |
|
|
case _CS_XBS5_LP64_OFF64_LIBS:
|
| 119 |
|
|
case _CS_XBS5_LP64_OFF64_LINTFLAGS:
|
| 120 |
|
|
case _CS_XBS5_LPBIG_OFFBIG_CFLAGS:
|
| 121 |
|
|
case _CS_XBS5_LPBIG_OFFBIG_LDFLAGS:
|
| 122 |
|
|
case _CS_XBS5_LPBIG_OFFBIG_LIBS:
|
| 123 |
|
|
case _CS_XBS5_LPBIG_OFFBIG_LINTFLAGS:
|
| 124 |
|
|
|
| 125 |
|
|
case _CS_POSIX_V6_ILP32_OFF32_CFLAGS:
|
| 126 |
|
|
case _CS_POSIX_V6_ILP32_OFF32_LDFLAGS:
|
| 127 |
|
|
case _CS_POSIX_V6_ILP32_OFF32_LIBS:
|
| 128 |
|
|
case _CS_POSIX_V6_ILP32_OFF32_LINTFLAGS:
|
| 129 |
|
|
case _CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS:
|
| 130 |
|
|
case _CS_POSIX_V6_ILP32_OFFBIG_LIBS:
|
| 131 |
|
|
case _CS_POSIX_V6_ILP32_OFFBIG_LINTFLAGS:
|
| 132 |
|
|
case _CS_POSIX_V6_LP64_OFF64_CFLAGS:
|
| 133 |
|
|
case _CS_POSIX_V6_LP64_OFF64_LDFLAGS:
|
| 134 |
|
|
case _CS_POSIX_V6_LP64_OFF64_LIBS:
|
| 135 |
|
|
case _CS_POSIX_V6_LP64_OFF64_LINTFLAGS:
|
| 136 |
|
|
case _CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS:
|
| 137 |
|
|
case _CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS:
|
| 138 |
|
|
case _CS_POSIX_V6_LPBIG_OFFBIG_LIBS:
|
| 139 |
|
|
case _CS_POSIX_V6_LPBIG_OFFBIG_LINTFLAGS:
|
| 140 |
|
|
/* GNU libc does not require special actions to use LFS functions. */
|
| 141 |
|
|
string = "";
|
| 142 |
|
|
string_len = 1;
|
| 143 |
|
|
break;
|
| 144 |
|
|
|
| 145 |
|
|
default:
|
| 146 |
|
|
__set_errno (EINVAL);
|
| 147 |
|
|
return 0;
|
| 148 |
|
|
}
|
| 149 |
|
|
|
| 150 |
|
|
if (len > 0 && buf != NULL)
|
| 151 |
|
|
{
|
| 152 |
|
|
if (string_len <= len)
|
| 153 |
|
|
memcpy (buf, string, string_len);
|
| 154 |
|
|
else
|
| 155 |
|
|
{
|
| 156 |
|
|
memcpy (buf, string, len - 1);
|
| 157 |
|
|
buf[len - 1] = '\0';
|
| 158 |
|
|
}
|
| 159 |
|
|
}
|
| 160 |
|
|
return string_len;
|
| 161 |
|
|
}
|