17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate * CDDL HEADER START
37c478bd9Sstevel@tonic-gate *
47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the
564e3e6f9Scraigm * Common Development and Distribution License (the "License").
664e3e6f9Scraigm * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate *
87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate * and limitations under the License.
127c478bd9Sstevel@tonic-gate *
137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate *
197c478bd9Sstevel@tonic-gate * CDDL HEADER END
207c478bd9Sstevel@tonic-gate */
21*7257d1b4Sraf
227c478bd9Sstevel@tonic-gate /*
23*7257d1b4Sraf * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
247c478bd9Sstevel@tonic-gate * Use is subject to license terms.
257c478bd9Sstevel@tonic-gate */
267c478bd9Sstevel@tonic-gate
277c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI"
287c478bd9Sstevel@tonic-gate
29*7257d1b4Sraf #pragma weak _confstr = confstr
3064e3e6f9Scraigm
31*7257d1b4Sraf #include "lint.h"
327c478bd9Sstevel@tonic-gate #include "xpg6.h"
337c478bd9Sstevel@tonic-gate #include <sys/types.h>
347c478bd9Sstevel@tonic-gate #include <unistd.h>
357c478bd9Sstevel@tonic-gate #include <errno.h>
367c478bd9Sstevel@tonic-gate #include <string.h>
377c478bd9Sstevel@tonic-gate
387c478bd9Sstevel@tonic-gate typedef struct {
397c478bd9Sstevel@tonic-gate int config_value;
407c478bd9Sstevel@tonic-gate char *value;
417c478bd9Sstevel@tonic-gate } config;
427c478bd9Sstevel@tonic-gate
437c478bd9Sstevel@tonic-gate /*
447c478bd9Sstevel@tonic-gate * keep these in the same order as in sys/unistd.h
457c478bd9Sstevel@tonic-gate */
467c478bd9Sstevel@tonic-gate static const config default_conf[] = {
477c478bd9Sstevel@tonic-gate { _CS_LFS_CFLAGS, "-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64" },
487c478bd9Sstevel@tonic-gate { _CS_LFS_LDFLAGS, "" },
497c478bd9Sstevel@tonic-gate { _CS_LFS_LIBS, "" },
507c478bd9Sstevel@tonic-gate { _CS_LFS_LINTFLAGS, "-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64" },
517c478bd9Sstevel@tonic-gate { _CS_LFS64_CFLAGS, "-D_LARGEFILE64_SOURCE" },
527c478bd9Sstevel@tonic-gate { _CS_LFS64_LDFLAGS, "" },
537c478bd9Sstevel@tonic-gate { _CS_LFS64_LIBS, "" },
547c478bd9Sstevel@tonic-gate { _CS_LFS64_LINTFLAGS, "-D_LARGEFILE64_SOURCE" },
557c478bd9Sstevel@tonic-gate { _CS_XBS5_ILP32_OFF32_CFLAGS, "" },
567c478bd9Sstevel@tonic-gate { _CS_XBS5_ILP32_OFF32_LDFLAGS, "" },
577c478bd9Sstevel@tonic-gate { _CS_XBS5_ILP32_OFF32_LIBS, "" },
587c478bd9Sstevel@tonic-gate { _CS_XBS5_ILP32_OFF32_LINTFLAGS, "" },
597c478bd9Sstevel@tonic-gate { _CS_XBS5_ILP32_OFFBIG_CFLAGS,
607c478bd9Sstevel@tonic-gate "-Xa -Usun -Usparc -Uunix -Ui386 -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64" },
617c478bd9Sstevel@tonic-gate { _CS_XBS5_ILP32_OFFBIG_LDFLAGS, "" },
627c478bd9Sstevel@tonic-gate { _CS_XBS5_ILP32_OFFBIG_LIBS, "" },
637c478bd9Sstevel@tonic-gate { _CS_XBS5_ILP32_OFFBIG_LINTFLAGS,
647c478bd9Sstevel@tonic-gate "-Xa -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"},
657c478bd9Sstevel@tonic-gate { _CS_POSIX_V6_ILP32_OFF32_CFLAGS, "" },
667c478bd9Sstevel@tonic-gate { _CS_POSIX_V6_ILP32_OFF32_LDFLAGS, "" },
677c478bd9Sstevel@tonic-gate { _CS_POSIX_V6_ILP32_OFF32_LIBS, "" },
687c478bd9Sstevel@tonic-gate { _CS_POSIX_V6_ILP32_OFFBIG_CFLAGS,
697c478bd9Sstevel@tonic-gate "-Xa -Usun -Usparc -Uunix -Ui386 -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64" },
707c478bd9Sstevel@tonic-gate { _CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS, "" },
717c478bd9Sstevel@tonic-gate { _CS_POSIX_V6_ILP32_OFFBIG_LIBS, "" },
727c478bd9Sstevel@tonic-gate { _CS_POSIX_V6_WIDTH_RESTRICTED_ENVS,
737c478bd9Sstevel@tonic-gate "POSIX_V6_ILP32_OFF32\nPOSIX_V6_ILP32_OFFBIG\n"
747c478bd9Sstevel@tonic-gate "POSIX_V6_LP64_OFF64\nPOSIX_V6_LPBIG_OFFBIG" },
757c478bd9Sstevel@tonic-gate { _CS_XBS5_LP64_OFF64_CFLAGS, "-xarch=generic64" },
767c478bd9Sstevel@tonic-gate { _CS_XBS5_LP64_OFF64_LDFLAGS, "-xarch=generic64" },
777c478bd9Sstevel@tonic-gate { _CS_XBS5_LP64_OFF64_LIBS, "" },
787c478bd9Sstevel@tonic-gate { _CS_XBS5_LP64_OFF64_LINTFLAGS, "-xarch=generic64" },
797c478bd9Sstevel@tonic-gate { _CS_XBS5_LPBIG_OFFBIG_CFLAGS, "-xarch=generic64" },
807c478bd9Sstevel@tonic-gate { _CS_XBS5_LPBIG_OFFBIG_LDFLAGS, "-xarch=generic64" },
817c478bd9Sstevel@tonic-gate { _CS_XBS5_LPBIG_OFFBIG_LIBS, "" },
827c478bd9Sstevel@tonic-gate { _CS_XBS5_LPBIG_OFFBIG_LINTFLAGS, "-xarch=generic64" },
837c478bd9Sstevel@tonic-gate { _CS_POSIX_V6_LP64_OFF64_CFLAGS, "-xarch=generic64" },
847c478bd9Sstevel@tonic-gate { _CS_POSIX_V6_LP64_OFF64_LDFLAGS, "-xarch=generic64" },
857c478bd9Sstevel@tonic-gate { _CS_POSIX_V6_LP64_OFF64_LIBS, "" },
867c478bd9Sstevel@tonic-gate { _CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS, "-xarch=generic64" },
877c478bd9Sstevel@tonic-gate { _CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS, "-xarch=generic64" },
887c478bd9Sstevel@tonic-gate { _CS_POSIX_V6_LPBIG_OFFBIG_LIBS, "" },
897c478bd9Sstevel@tonic-gate };
907c478bd9Sstevel@tonic-gate
917c478bd9Sstevel@tonic-gate #define CS_ENTRY_COUNT (sizeof (default_conf) / sizeof (config))
927c478bd9Sstevel@tonic-gate
937c478bd9Sstevel@tonic-gate size_t
confstr(int name,char * buf,size_t length)947c478bd9Sstevel@tonic-gate confstr(int name, char *buf, size_t length)
957c478bd9Sstevel@tonic-gate {
967c478bd9Sstevel@tonic-gate size_t conf_length;
977c478bd9Sstevel@tonic-gate config *entry;
987c478bd9Sstevel@tonic-gate int i;
997c478bd9Sstevel@tonic-gate char *path;
1007c478bd9Sstevel@tonic-gate
1017c478bd9Sstevel@tonic-gate /* Keep _CS_PATH in sync with execvp.c */
1027c478bd9Sstevel@tonic-gate
1037c478bd9Sstevel@tonic-gate if (name == _CS_PATH) {
1047c478bd9Sstevel@tonic-gate if (__xpg6 & _C99SUSv3_XPG6_sysconf_version)
105*7257d1b4Sraf path = "/usr/xpg6/bin:/usr/xpg4/bin:/usr/ccs/bin:"
1067c478bd9Sstevel@tonic-gate "/usr/bin:/opt/SUNWspro/bin";
1077c478bd9Sstevel@tonic-gate else
108*7257d1b4Sraf path = "/usr/xpg4/bin:/usr/ccs/bin:/usr/bin:"
1097c478bd9Sstevel@tonic-gate "/opt/SUNWspro/bin";
1107c478bd9Sstevel@tonic-gate
1117c478bd9Sstevel@tonic-gate conf_length = strlen(path) + 1;
1127c478bd9Sstevel@tonic-gate if (length != 0) {
1137c478bd9Sstevel@tonic-gate (void) strncpy(buf, path, length);
1147c478bd9Sstevel@tonic-gate buf[length - 1] = '\0';
1157c478bd9Sstevel@tonic-gate }
1167c478bd9Sstevel@tonic-gate return (conf_length);
1177c478bd9Sstevel@tonic-gate }
1187c478bd9Sstevel@tonic-gate /*
1197c478bd9Sstevel@tonic-gate * Make sure others are known configuration parameters
1207c478bd9Sstevel@tonic-gate */
1217c478bd9Sstevel@tonic-gate entry = (config *)default_conf;
1227c478bd9Sstevel@tonic-gate for (i = 0; i < CS_ENTRY_COUNT; i++) {
1237c478bd9Sstevel@tonic-gate if (name == entry->config_value) {
1247c478bd9Sstevel@tonic-gate /*
1257c478bd9Sstevel@tonic-gate * Copy out the parameter from our tables.
1267c478bd9Sstevel@tonic-gate */
1277c478bd9Sstevel@tonic-gate conf_length = strlen(entry->value) + 1;
1287c478bd9Sstevel@tonic-gate if (length != 0) {
1297c478bd9Sstevel@tonic-gate (void) strncpy(buf, entry->value, length);
1307c478bd9Sstevel@tonic-gate buf[length - 1] = '\0';
1317c478bd9Sstevel@tonic-gate }
1327c478bd9Sstevel@tonic-gate return (conf_length);
1337c478bd9Sstevel@tonic-gate }
1347c478bd9Sstevel@tonic-gate entry++;
1357c478bd9Sstevel@tonic-gate }
1367c478bd9Sstevel@tonic-gate
1377c478bd9Sstevel@tonic-gate /* If the entry was not found in table return an error */
1387c478bd9Sstevel@tonic-gate errno = EINVAL;
1397c478bd9Sstevel@tonic-gate return ((size_t)0);
1407c478bd9Sstevel@tonic-gate }
141