1994-05-27 05:00:24 +00:00
|
|
|
/*-
|
|
|
|
* Copyright (c) 1993
|
|
|
|
* The Regents of the University of California. All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 4. Neither the name of the University nor the names of its contributors
|
|
|
|
* may be used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#if defined(LIBC_SCCS) && !defined(lint)
|
|
|
|
static char sccsid[] = "@(#)confstr.c 8.1 (Berkeley) 6/4/93";
|
|
|
|
#endif /* LIBC_SCCS and not lint */
|
2002-03-22 21:53:29 +00:00
|
|
|
#include <sys/cdefs.h>
|
|
|
|
__FBSDID("$FreeBSD$");
|
1994-05-27 05:00:24 +00:00
|
|
|
|
|
|
|
#include <sys/param.h>
|
2003-05-01 19:03:14 +00:00
|
|
|
|
1994-05-27 05:00:24 +00:00
|
|
|
#include <errno.h>
|
2002-07-15 22:21:33 +00:00
|
|
|
#include <limits.h>
|
1994-05-27 05:00:24 +00:00
|
|
|
#include <paths.h>
|
1995-10-22 14:37:11 +00:00
|
|
|
#include <string.h>
|
2002-07-15 22:21:33 +00:00
|
|
|
#include <unistd.h>
|
|
|
|
|
1994-05-27 05:00:24 +00:00
|
|
|
|
|
|
|
size_t
|
2002-07-15 21:51:19 +00:00
|
|
|
confstr(int name, char *buf, size_t len)
|
1994-05-27 05:00:24 +00:00
|
|
|
{
|
2002-07-15 21:51:19 +00:00
|
|
|
const char *p;
|
2002-07-15 22:21:33 +00:00
|
|
|
const char UPE[] = "unsupported programming environment";
|
1994-05-27 05:00:24 +00:00
|
|
|
|
|
|
|
switch (name) {
|
|
|
|
case _CS_PATH:
|
2002-07-15 21:51:19 +00:00
|
|
|
p = _PATH_STDPATH;
|
|
|
|
goto docopy;
|
|
|
|
|
2002-07-15 22:21:33 +00:00
|
|
|
/*
|
|
|
|
* POSIX/SUS ``Programming Environments'' stuff
|
|
|
|
*
|
|
|
|
* We don't support more than one programming environment
|
|
|
|
* on any platform (yet), so we just return the empty
|
|
|
|
* string for the environment we are compiled for,
|
|
|
|
* and the string "unsupported programming environment"
|
|
|
|
* for anything else. (The Standard says that if these
|
|
|
|
* values are used on a system which does not support
|
|
|
|
* this environment -- determined via sysconf() -- then
|
|
|
|
* the value we return is unspecified. So, we return
|
|
|
|
* something which will cause obvious breakage.)
|
|
|
|
*/
|
|
|
|
case _CS_POSIX_V6_ILP32_OFF32_CFLAGS:
|
|
|
|
case _CS_POSIX_V6_ILP32_OFF32_LDFLAGS:
|
|
|
|
case _CS_POSIX_V6_ILP32_OFF32_LIBS:
|
2002-07-15 22:43:03 +00:00
|
|
|
case _CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS:
|
|
|
|
case _CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS:
|
|
|
|
case _CS_POSIX_V6_LPBIG_OFFBIG_LIBS:
|
2002-07-15 22:21:33 +00:00
|
|
|
/*
|
2002-07-15 22:43:03 +00:00
|
|
|
* These two environments are never supported.
|
2002-07-15 22:21:33 +00:00
|
|
|
*/
|
|
|
|
p = UPE;
|
|
|
|
goto docopy;
|
|
|
|
|
|
|
|
case _CS_POSIX_V6_ILP32_OFFBIG_CFLAGS:
|
|
|
|
case _CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS:
|
|
|
|
case _CS_POSIX_V6_ILP32_OFFBIG_LIBS:
|
|
|
|
if (sizeof(long) * CHAR_BIT == 32 &&
|
|
|
|
sizeof(off_t) > sizeof(long))
|
|
|
|
p = "";
|
|
|
|
else
|
|
|
|
p = UPE;
|
|
|
|
goto docopy;
|
|
|
|
|
2002-07-15 22:43:03 +00:00
|
|
|
case _CS_POSIX_V6_LP64_OFF64_CFLAGS:
|
|
|
|
case _CS_POSIX_V6_LP64_OFF64_LDFLAGS:
|
|
|
|
case _CS_POSIX_V6_LP64_OFF64_LIBS:
|
2002-07-15 22:21:33 +00:00
|
|
|
if (sizeof(long) * CHAR_BIT >= 64 &&
|
|
|
|
sizeof(void *) * CHAR_BIT >= 64 &&
|
|
|
|
sizeof(int) * CHAR_BIT >= 32 &&
|
|
|
|
sizeof(off_t) >= sizeof(long))
|
|
|
|
p = "";
|
|
|
|
else
|
|
|
|
p = UPE;
|
|
|
|
goto docopy;
|
|
|
|
|
|
|
|
case _CS_POSIX_V6_WIDTH_RESTRICTED_ENVS:
|
2002-09-19 03:47:36 +00:00
|
|
|
/* XXX - should have more complete coverage */
|
2002-07-15 22:21:33 +00:00
|
|
|
if (sizeof(long) * CHAR_BIT >= 64)
|
2002-09-19 03:47:36 +00:00
|
|
|
p = "_POSIX_V6_LP64_OFF64";
|
2002-07-15 22:21:33 +00:00
|
|
|
else
|
2002-07-15 22:43:03 +00:00
|
|
|
p = "_POSIX_V6_ILP32_OFFBIG";
|
2002-07-15 22:21:33 +00:00
|
|
|
goto docopy;
|
|
|
|
|
2002-07-15 21:51:19 +00:00
|
|
|
docopy:
|
|
|
|
if (len != 0 && buf != NULL)
|
2003-05-01 19:03:14 +00:00
|
|
|
strlcpy(buf, p, len);
|
2002-07-15 21:51:19 +00:00
|
|
|
return (strlen(p) + 1);
|
|
|
|
|
1994-05-27 05:00:24 +00:00
|
|
|
default:
|
|
|
|
errno = EINVAL;
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
/* NOTREACHED */
|
|
|
|
}
|