10Sstevel@tonic-gate /*
20Sstevel@tonic-gate * CDDL HEADER START
30Sstevel@tonic-gate *
40Sstevel@tonic-gate * The contents of this file are subject to the terms of the
52552Scraigm * Common Development and Distribution License (the "License").
62552Scraigm * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate *
80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate * See the License for the specific language governing permissions
110Sstevel@tonic-gate * and limitations under the License.
120Sstevel@tonic-gate *
130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate *
190Sstevel@tonic-gate * CDDL HEADER END
200Sstevel@tonic-gate */
21*6812Sraf
220Sstevel@tonic-gate /*
23*6812Sraf * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
240Sstevel@tonic-gate * Use is subject to license terms.
250Sstevel@tonic-gate */
260Sstevel@tonic-gate
270Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI"
280Sstevel@tonic-gate
29*6812Sraf #pragma weak _confstr = confstr
302552Scraigm
31*6812Sraf #include "lint.h"
320Sstevel@tonic-gate #include "xpg6.h"
330Sstevel@tonic-gate #include <sys/types.h>
340Sstevel@tonic-gate #include <unistd.h>
350Sstevel@tonic-gate #include <errno.h>
360Sstevel@tonic-gate #include <string.h>
370Sstevel@tonic-gate
380Sstevel@tonic-gate typedef struct {
390Sstevel@tonic-gate int config_value;
400Sstevel@tonic-gate char *value;
410Sstevel@tonic-gate } config;
420Sstevel@tonic-gate
430Sstevel@tonic-gate /*
440Sstevel@tonic-gate * keep these in the same order as in sys/unistd.h
450Sstevel@tonic-gate */
460Sstevel@tonic-gate static const config default_conf[] = {
470Sstevel@tonic-gate { _CS_LFS_CFLAGS, "-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64" },
480Sstevel@tonic-gate { _CS_LFS_LDFLAGS, "" },
490Sstevel@tonic-gate { _CS_LFS_LIBS, "" },
500Sstevel@tonic-gate { _CS_LFS_LINTFLAGS, "-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64" },
510Sstevel@tonic-gate { _CS_LFS64_CFLAGS, "-D_LARGEFILE64_SOURCE" },
520Sstevel@tonic-gate { _CS_LFS64_LDFLAGS, "" },
530Sstevel@tonic-gate { _CS_LFS64_LIBS, "" },
540Sstevel@tonic-gate { _CS_LFS64_LINTFLAGS, "-D_LARGEFILE64_SOURCE" },
550Sstevel@tonic-gate { _CS_XBS5_ILP32_OFF32_CFLAGS, "" },
560Sstevel@tonic-gate { _CS_XBS5_ILP32_OFF32_LDFLAGS, "" },
570Sstevel@tonic-gate { _CS_XBS5_ILP32_OFF32_LIBS, "" },
580Sstevel@tonic-gate { _CS_XBS5_ILP32_OFF32_LINTFLAGS, "" },
590Sstevel@tonic-gate { _CS_XBS5_ILP32_OFFBIG_CFLAGS,
600Sstevel@tonic-gate "-Xa -Usun -Usparc -Uunix -Ui386 -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64" },
610Sstevel@tonic-gate { _CS_XBS5_ILP32_OFFBIG_LDFLAGS, "" },
620Sstevel@tonic-gate { _CS_XBS5_ILP32_OFFBIG_LIBS, "" },
630Sstevel@tonic-gate { _CS_XBS5_ILP32_OFFBIG_LINTFLAGS,
640Sstevel@tonic-gate "-Xa -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"},
650Sstevel@tonic-gate { _CS_POSIX_V6_ILP32_OFF32_CFLAGS, "" },
660Sstevel@tonic-gate { _CS_POSIX_V6_ILP32_OFF32_LDFLAGS, "" },
670Sstevel@tonic-gate { _CS_POSIX_V6_ILP32_OFF32_LIBS, "" },
680Sstevel@tonic-gate { _CS_POSIX_V6_ILP32_OFFBIG_CFLAGS,
690Sstevel@tonic-gate "-Xa -Usun -Usparc -Uunix -Ui386 -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64" },
700Sstevel@tonic-gate { _CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS, "" },
710Sstevel@tonic-gate { _CS_POSIX_V6_ILP32_OFFBIG_LIBS, "" },
720Sstevel@tonic-gate { _CS_POSIX_V6_WIDTH_RESTRICTED_ENVS,
730Sstevel@tonic-gate "POSIX_V6_ILP32_OFF32\nPOSIX_V6_ILP32_OFFBIG\n"
740Sstevel@tonic-gate "POSIX_V6_LP64_OFF64\nPOSIX_V6_LPBIG_OFFBIG" },
750Sstevel@tonic-gate { _CS_XBS5_LP64_OFF64_CFLAGS, "-xarch=generic64" },
760Sstevel@tonic-gate { _CS_XBS5_LP64_OFF64_LDFLAGS, "-xarch=generic64" },
770Sstevel@tonic-gate { _CS_XBS5_LP64_OFF64_LIBS, "" },
780Sstevel@tonic-gate { _CS_XBS5_LP64_OFF64_LINTFLAGS, "-xarch=generic64" },
790Sstevel@tonic-gate { _CS_XBS5_LPBIG_OFFBIG_CFLAGS, "-xarch=generic64" },
800Sstevel@tonic-gate { _CS_XBS5_LPBIG_OFFBIG_LDFLAGS, "-xarch=generic64" },
810Sstevel@tonic-gate { _CS_XBS5_LPBIG_OFFBIG_LIBS, "" },
820Sstevel@tonic-gate { _CS_XBS5_LPBIG_OFFBIG_LINTFLAGS, "-xarch=generic64" },
830Sstevel@tonic-gate { _CS_POSIX_V6_LP64_OFF64_CFLAGS, "-xarch=generic64" },
840Sstevel@tonic-gate { _CS_POSIX_V6_LP64_OFF64_LDFLAGS, "-xarch=generic64" },
850Sstevel@tonic-gate { _CS_POSIX_V6_LP64_OFF64_LIBS, "" },
860Sstevel@tonic-gate { _CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS, "-xarch=generic64" },
870Sstevel@tonic-gate { _CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS, "-xarch=generic64" },
880Sstevel@tonic-gate { _CS_POSIX_V6_LPBIG_OFFBIG_LIBS, "" },
890Sstevel@tonic-gate };
900Sstevel@tonic-gate
910Sstevel@tonic-gate #define CS_ENTRY_COUNT (sizeof (default_conf) / sizeof (config))
920Sstevel@tonic-gate
930Sstevel@tonic-gate size_t
confstr(int name,char * buf,size_t length)940Sstevel@tonic-gate confstr(int name, char *buf, size_t length)
950Sstevel@tonic-gate {
960Sstevel@tonic-gate size_t conf_length;
970Sstevel@tonic-gate config *entry;
980Sstevel@tonic-gate int i;
990Sstevel@tonic-gate char *path;
1000Sstevel@tonic-gate
1010Sstevel@tonic-gate /* Keep _CS_PATH in sync with execvp.c */
1020Sstevel@tonic-gate
1030Sstevel@tonic-gate if (name == _CS_PATH) {
1040Sstevel@tonic-gate if (__xpg6 & _C99SUSv3_XPG6_sysconf_version)
105*6812Sraf path = "/usr/xpg6/bin:/usr/xpg4/bin:/usr/ccs/bin:"
106*6812Sraf "/usr/bin:/opt/SUNWspro/bin";
1070Sstevel@tonic-gate else
108*6812Sraf path = "/usr/xpg4/bin:/usr/ccs/bin:/usr/bin:"
109*6812Sraf "/opt/SUNWspro/bin";
1100Sstevel@tonic-gate
1110Sstevel@tonic-gate conf_length = strlen(path) + 1;
1120Sstevel@tonic-gate if (length != 0) {
1130Sstevel@tonic-gate (void) strncpy(buf, path, length);
1140Sstevel@tonic-gate buf[length - 1] = '\0';
1150Sstevel@tonic-gate }
1160Sstevel@tonic-gate return (conf_length);
1170Sstevel@tonic-gate }
1180Sstevel@tonic-gate /*
1190Sstevel@tonic-gate * Make sure others are known configuration parameters
1200Sstevel@tonic-gate */
1210Sstevel@tonic-gate entry = (config *)default_conf;
1220Sstevel@tonic-gate for (i = 0; i < CS_ENTRY_COUNT; i++) {
1230Sstevel@tonic-gate if (name == entry->config_value) {
1240Sstevel@tonic-gate /*
1250Sstevel@tonic-gate * Copy out the parameter from our tables.
1260Sstevel@tonic-gate */
1270Sstevel@tonic-gate conf_length = strlen(entry->value) + 1;
1280Sstevel@tonic-gate if (length != 0) {
1290Sstevel@tonic-gate (void) strncpy(buf, entry->value, length);
1300Sstevel@tonic-gate buf[length - 1] = '\0';
1310Sstevel@tonic-gate }
1320Sstevel@tonic-gate return (conf_length);
1330Sstevel@tonic-gate }
1340Sstevel@tonic-gate entry++;
1350Sstevel@tonic-gate }
1360Sstevel@tonic-gate
1370Sstevel@tonic-gate /* If the entry was not found in table return an error */
1380Sstevel@tonic-gate errno = EINVAL;
1390Sstevel@tonic-gate return ((size_t)0);
1400Sstevel@tonic-gate }
141