diff options
Diffstat (limited to 'system_cmds/getconf.tproj')
-rw-r--r-- | system_cmds/getconf.tproj/confstr.gperf | 73 | ||||
-rw-r--r-- | system_cmds/getconf.tproj/fake-gperf.awk | 66 | ||||
-rw-r--r-- | system_cmds/getconf.tproj/getconf.1 | 212 | ||||
-rw-r--r-- | system_cmds/getconf.tproj/getconf.c | 189 | ||||
-rw-r--r-- | system_cmds/getconf.tproj/getconf.h | 43 | ||||
-rw-r--r-- | system_cmds/getconf.tproj/limits.gperf | 142 | ||||
-rw-r--r-- | system_cmds/getconf.tproj/pathconf.gperf | 88 | ||||
-rw-r--r-- | system_cmds/getconf.tproj/progenv.gperf | 70 | ||||
-rw-r--r-- | system_cmds/getconf.tproj/sysconf.gperf | 187 |
9 files changed, 1070 insertions, 0 deletions
diff --git a/system_cmds/getconf.tproj/confstr.gperf b/system_cmds/getconf.tproj/confstr.gperf new file mode 100644 index 0000000..4e79502 --- /dev/null +++ b/system_cmds/getconf.tproj/confstr.gperf @@ -0,0 +1,73 @@ +%{ +/* + * Copyright is disclaimed as to the contents of this file. + * + * $FreeBSD: src/usr.bin/getconf/confstr.gperf,v 1.5 2003/08/22 17:32:07 markm Exp $ + */ + +#include <sys/types.h> + +#include <string.h> +#include <unistd.h> + +#include "getconf.h" + +/* + * Override gperf's built-in external scope. + */ +static const struct map *in_word_set(const char *str); + +/* + * The Standard seems a bit ambiguous over whether the POSIX_V6_* + * are specified with or without a leading underscore, so we just + * use both. + */ +%} +struct map { const char *name; int key; int valid; }; +%% +PATH, _CS_PATH +POSIX_V6_ILP32_OFF32_CFLAGS, _CS_POSIX_V6_ILP32_OFF32_CFLAGS +POSIX_V6_ILP32_OFF32_LDFLAGS, _CS_POSIX_V6_ILP32_OFF32_LDFLAGS +POSIX_V6_ILP32_OFF32_LIBS, _CS_POSIX_V6_ILP32_OFF32_LIBS +POSIX_V6_ILP32_OFFBIG_CFLAGS, _CS_POSIX_V6_ILP32_OFFBIG_CFLAGS +POSIX_V6_ILP32_OFFBIG_LDFLAGS, _CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS +POSIX_V6_ILP32_OFFBIG_LIBS, _CS_POSIX_V6_ILP32_OFFBIG_LIBS +POSIX_V6_LP64_OFF64_CFLAGS, _CS_POSIX_V6_LP64_OFF64_CFLAGS +POSIX_V6_LP64_OFF64_LDFLAGS, _CS_POSIX_V6_LP64_OFF64_LDFLAGS +POSIX_V6_LP64_OFF64_LIBS, _CS_POSIX_V6_LP64_OFF64_LIBS +POSIX_V6_LPBIG_OFFBIG_CFLAGS, _CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS +POSIX_V6_LPBIG_OFFBIG_LDFLAGS, _CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS +POSIX_V6_LPBIG_OFFBIG_LIBS, _CS_POSIX_V6_LPBIG_OFFBIG_LIBS +POSIX_V6_WIDTH_RESTRICTED_ENVS, _CS_POSIX_V6_WIDTH_RESTRICTED_ENVS +_POSIX_V6_ILP32_OFF32_CFLAGS, _CS_POSIX_V6_ILP32_OFF32_CFLAGS +_POSIX_V6_ILP32_OFF32_LDFLAGS, _CS_POSIX_V6_ILP32_OFF32_LDFLAGS +_POSIX_V6_ILP32_OFF32_LIBS, _CS_POSIX_V6_ILP32_OFF32_LIBS +_POSIX_V6_ILP32_OFFBIG_CFLAGS, _CS_POSIX_V6_ILP32_OFFBIG_CFLAGS +_POSIX_V6_ILP32_OFFBIG_LDFLAGS, _CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS +_POSIX_V6_ILP32_OFFBIG_LIBS, _CS_POSIX_V6_ILP32_OFFBIG_LIBS +_POSIX_V6_LP64_OFF64_CFLAGS, _CS_POSIX_V6_LP64_OFF64_CFLAGS +_POSIX_V6_LP64_OFF64_LDFLAGS, _CS_POSIX_V6_LP64_OFF64_LDFLAGS +_POSIX_V6_LP64_OFF64_LIBS, _CS_POSIX_V6_LP64_OFF64_LIBS +_POSIX_V6_LPBIG_OFFBIG_CFLAGS, _CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS +_POSIX_V6_LPBIG_OFFBIG_LDFLAGS, _CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS +_POSIX_V6_LPBIG_OFFBIG_LIBS, _CS_POSIX_V6_LPBIG_OFFBIG_LIBS +_POSIX_V6_WIDTH_RESTRICTED_ENVS, _CS_POSIX_V6_WIDTH_RESTRICTED_ENVS +DARWIN_USER_DIR, _CS_DARWIN_USER_DIR +DARWIN_USER_TEMP_DIR, _CS_DARWIN_USER_TEMP_DIR +DARWIN_USER_CACHE_DIR, _CS_DARWIN_USER_CACHE_DIR +%% +int +find_confstr(const char *name, int *key) +{ + const struct map *rv; + + rv = in_word_set(name); + if (rv != NULL) { + if (rv->valid) { + *key = rv->key; + return 1; + } + return -1; + } + return 0; +} diff --git a/system_cmds/getconf.tproj/fake-gperf.awk b/system_cmds/getconf.tproj/fake-gperf.awk new file mode 100644 index 0000000..b3107fe --- /dev/null +++ b/system_cmds/getconf.tproj/fake-gperf.awk @@ -0,0 +1,66 @@ +#!/usr/bin/awk -f +# $FreeBSD: src/usr.bin/getconf/fake-gperf.awk,v 1.3 2003/08/22 17:32:07 markm Exp $ +BEGIN { + state = 0; + struct_seen = ""; +} +/^%{$/ && state == 0 { + state = 1; + next; +} +/^%}$/ && state == 1 { + state = 0; + next; +} +state == 1 { print; next; } +/^struct/ && state == 0 { + print; + struct_seen = $2; + next; +} +/^%%$/ && state == 0 { + state = 2; + if (struct_seen !~ /^$/) { + print "static const struct", struct_seen, "wordlist[] = {"; + } else { + print "static const struct map {"; + print "\tconst char *name;"; + print "\tint key;"; + print "\tint valid;"; + print "} wordlist[] = {"; + struct_seen = "map"; + } + next; +} +/^%%$/ && state == 2 { + state = 3; + print "\t{ NULL, 0, 0 }"; + print "};"; + print "#define\tNWORDS\t(sizeof(wordlist)/sizeof(wordlist[0]) - 1)"; + print "static const struct map *"; + print "in_word_set(const char *word)"; + print "{"; + print "\tconst struct", struct_seen, "*mp;"; + print ""; + print "\tfor (mp = wordlist; mp < &wordlist[NWORDS]; mp++) {"; + print "\t\tif (strcmp(word, mp->name) == 0)"; + print "\t\t\treturn (mp);"; + print "\t}"; + print "\treturn (NULL);"; + print "}"; + print ""; + next; +} +state == 2 && NF == 2 { + name = substr($1, 1, length($1) - 1); + printf "#ifdef %s\n", $2; + printf "\t{ \"%s\", %s, 1 },\n", name, $2; + print "#else"; + printf "\t{ \"%s\", 0, 0 },\n", name, $2; + print "#endif" + next; +} +state == 3 { print; next; } +{ + # eat anything not matched. +} diff --git a/system_cmds/getconf.tproj/getconf.1 b/system_cmds/getconf.tproj/getconf.1 new file mode 100644 index 0000000..384f780 --- /dev/null +++ b/system_cmds/getconf.tproj/getconf.1 @@ -0,0 +1,212 @@ +.\" +.\" Copyright 2000 Massachusetts Institute of Technology +.\" +.\" Permission to use, copy, modify, and distribute this software and +.\" its documentation for any purpose and without fee is hereby +.\" granted, provided that both the above copyright notice and this +.\" permission notice appear in all copies, that both the above +.\" copyright notice and this permission notice appear in all +.\" supporting documentation, and that the name of M.I.T. not be used +.\" in advertising or publicity pertaining to distribution of the +.\" software without specific, written prior permission. M.I.T. makes +.\" no representations about the suitability of this software for any +.\" purpose. It is provided "as is" without express or implied +.\" warranty. +.\" +.\" THIS SOFTWARE IS PROVIDED BY M.I.T. ``AS IS''. M.I.T. DISCLAIMS +.\" ALL EXPRESS OR IMPLIED WARRANTIES WITH REGARD TO THIS SOFTWARE, +.\" INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +.\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT +.\" SHALL M.I.T. 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. +.\" +.\" $FreeBSD: src/usr.bin/getconf/getconf.1,v 1.14 2005/01/18 13:43:49 ru Exp $ +.\" +.Dd September 18, 2002 +.Dt GETCONF 1 +.Os +.Sh NAME +.Nm getconf +.Nd retrieve standard configuration variables +.Sh SYNOPSIS +.Nm +.Op Fl v Ar environment +.Ar path_var +.Ar file +.Nm +.Op Fl v Ar environment +.Ar system_var +.Sh DESCRIPTION +The +.Nm +utility prints the value of a +.Tn POSIX +or +.Tn X/Open +path or system configuration variable to the standard output. +If the specified variable is undefined, the string +.Dq Li undefined +is output. +.Pp +The first form of the command, with two mandatory +arguments, retrieves file- and file system-specific +configuration variables using +.Xr pathconf 2 . +The second form, with a single argument, retrieves system +configuration variables using +.Xr confstr 3 +and +.Xr sysconf 3 , +depending on the type of variable. +As an extension, the second form can also be used to query static limits from +.In limits.h . +.Pp +All +.Xr sysconf 3 +and +.Xr pathconf 2 +variables use the same name as the manifest constants defined in +the relevant standard C-language bindings, including any leading +underscore or prefix. +That is to say, +.Ar system_var +might be +.Dv ARG_MAX +or +.Dv _POSIX_VERSION , +as opposed to the +.Xr sysconf 3 +names +.Dv _SC_ARG_MAX +or +.Dv _SC_POSIX_VERSION . +Variables retrieved from +.Xr confstr 3 +have the leading +.Ql _CS_ +stripped off; thus, +.Dv _CS_PATH +is queried by a +.Ar system_var +of +.Dq Li PATH . +.Ss Programming Environments +The +.Fl v Ar environment +option specifies a +.St -p1003.1-2001 +programming environment under which the values are to be queried. +This option currently does nothing, but may in the future be used +to select between 32-bit and 64-bit execution environments on platforms +which support both. +Specifying an environment which is not supported on the current execution +platform gives undefined results. +.Pp +The standard programming environments are as follows: +.Bl -tag -width ".Li POSIX_V6_LPBIG_OFFBIG" -offset indent +.It Li POSIX_V6_ILP32_OFF32 +Exactly 32-bit integer, long, pointer, and file offset. +.Sy Supported platforms : +None. +.It Li POSIX_V6_ILP32_OFFBIG +Exactly 32-bit integer, long, and pointer; at least 64-bit file offset. +.Sy Supported platforms : +.Tn IA32 , +.Tn PowerPC . +.It Li POSIX_V6_LP64_OFF64 +Exactly 32-bit integer; exactly 64-bit long, pointer, and file offset. +.Sy Supported platforms : +.Tn Alpha , +.Tn SPARC64 . +.It Li POSIX_V6_LPBIG_OFFBIG +At least 32-bit integer; at least 64-bit long, pointer, and file offset. +.Sy Supported platforms : +None. +.El +.Pp +The command: +.Pp +.Dl "getconf POSIX_V6_WIDTH_RESTRICTED_ENVS" +.Pp +returns a newline-separated list of environments in which the width +of certain fundamental types is no greater than the width of the native +C type +.Vt long . +At present, all programming environments supported by +.Fx +have this property. +Several of the +.Xr confstr 3 +variables provide information on the necessary compiler and linker flags +to use the standard programming environments described above. +.Pp +Many of these values are also available through the +.Xr sysctl 8 +mechanism. +.Sh EXIT STATUS +.Ex -std +.Sh EXAMPLES +The command: +.Pp +.Dl "getconf PATH" +.Pp +will display the system default setting for the +.Ev PATH +environment variable. +.Pp +The command: +.Pp +.Dl "getconf NAME_MAX /tmp" +.Pp +will display the maximum length of a filename in the +.Pa /tmp +directory. +.Pp +The command: +.Pp +.Dl "getconf -v POSIX_V6_LPBIG_OFFBIG LONG_MAX" +.Pp +will display the maximum value of the C type +.Vt long +in the +.Li POSIX_V6_LPBIG_OFFBIG +programming environment, +if the system supports that environment. +.Sh DIAGNOSTICS +Use of a +.Ar system_var +or +.Ar path_var +which is completely unrecognized is considered an error, +causing a diagnostic message to be written to standard error. +One +which is known but merely undefined does not result in an error +indication. +The +.Nm +utility recognizes all of the variables defined for +.St -p1003.1-2001 , +including those which are not currently implemented. +.Sh SEE ALSO +.Xr pathconf 2 , +.Xr confstr 3 , +.Xr sysconf 3 , +.Xr sysctl 8 +.Sh STANDARDS +The +.Nm +utility is expected to be compliant with +.St -p1003.1-2001 . +.Sh HISTORY +The +.Nm +utility first appeared in +.Fx 5.0 . +.Sh AUTHORS +.An Garrett A. Wollman Aq wollman@lcs.mit.edu diff --git a/system_cmds/getconf.tproj/getconf.c b/system_cmds/getconf.tproj/getconf.c new file mode 100644 index 0000000..b2a2752 --- /dev/null +++ b/system_cmds/getconf.tproj/getconf.c @@ -0,0 +1,189 @@ +/* + * Copyright 2000 Massachusetts Institute of Technology + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby + * granted, provided that both the above copyright notice and this + * permission notice appear in all copies, that both the above + * copyright notice and this permission notice appear in all + * supporting documentation, and that the name of M.I.T. not be used + * in advertising or publicity pertaining to distribution of the + * software without specific, written prior permission. M.I.T. makes + * no representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied + * warranty. + * + * THIS SOFTWARE IS PROVIDED BY M.I.T. ``AS IS''. M.I.T. DISCLAIMS + * ALL EXPRESS OR IMPLIED WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT + * SHALL M.I.T. 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. + */ + +#include <sys/cdefs.h> +__FBSDID("$FreeBSD: src/usr.bin/getconf/getconf.c,v 1.10 2006/12/06 12:00:26 maxim Exp $"); + +#include <sys/types.h> + +#include <err.h> +#include <errno.h> +#include <stdio.h> +#include <stdlib.h> +#include <sysexits.h> +#include <unistd.h> + +#include "getconf.h" + +static void do_confstr(const char *name, int key); +static void do_sysconf(const char *name, int key); +static void do_pathconf(const char *name, int key, const char *path); + +static void +usage(void) +{ + fprintf(stderr, +"usage: getconf [-v prog_env] system_var\n" +" getconf [-v prog_env] path_var pathname\n"); + exit(EX_USAGE); +} + +int +main(int argc, char **argv) +{ + int c, key, valid; + const char *name, *vflag, *alt_path; + intmax_t limitval; + + vflag = NULL; + while ((c = getopt(argc, argv, "v:")) != -1) { + switch (c) { + case 'v': + vflag = optarg; + break; + + default: + usage(); + } + } + + if ((name = argv[optind]) == NULL) + usage(); + + if (vflag != NULL) { + if ((valid = find_progenv(vflag, &alt_path)) == 0) + errx(EX_USAGE, "invalid programming environment %s", + vflag); + if (valid > 0 && alt_path != NULL) { + if (argv[optind + 1] == NULL) + execl(alt_path, "getconf", argv[optind], + (char *)NULL); + else + execl(alt_path, "getconf", argv[optind], + argv[optind + 1], (char *)NULL); + + err(EX_OSERR, "execl: %s", alt_path); + } + if (valid < 0) + errx(EX_UNAVAILABLE, "environment %s is not available", + vflag); + } + + if (argv[optind + 1] == NULL) { /* confstr or sysconf */ + if ((valid = find_limit(name, &limitval)) != 0) { + if (valid > 0) + printf("%" PRIdMAX "\n", limitval); + else + printf("undefined\n"); + + return 0; + } + if ((valid = find_confstr(name, &key)) != 0) { + if (valid > 0) + do_confstr(name, key); + else + printf("undefined\n"); + } else { + valid = find_sysconf(name, &key); + if (valid > 0) { + do_sysconf(name, key); + } else if (valid < 0) { + printf("undefined\n"); + } else + errx(EX_USAGE, + "no such configuration parameter `%s'", + name); + } + } else { + valid = find_pathconf(name, &key); + if (valid != 0) { + if (valid > 0) + do_pathconf(name, key, argv[optind + 1]); + else + printf("undefined\n"); + } else + errx(EX_USAGE, + "no such path configuration parameter `%s'", + name); + } + return 0; +} + +static void +do_confstr(const char *name, int key) +{ + size_t len; + int savederr; + + savederr = errno; + errno = 0; + len = confstr(key, 0, 0); + if (len == 0) { + if (errno) + err(EX_OSERR, "confstr: %s", name); + else + printf("undefined\n"); + } else { + char buf[len + 1]; + + confstr(key, buf, len); + printf("%s\n", buf); + } + errno = savederr; +} + +static void +do_sysconf(const char *name, int key) +{ + long value; + + errno = 0; + value = sysconf(key); + if (value == -1 && errno != 0) + err(EX_OSERR, "sysconf: %s", name); + else if (value == -1) + printf("undefined\n"); + else + printf("%ld\n", value); +} + +static void +do_pathconf(const char *name, int key, const char *path) +{ + long value; + + errno = 0; + value = pathconf(path, key); + if (value == -1 && errno != 0) + err(EX_OSERR, "pathconf: %s", name); + else if (value == -1) + printf("undefined\n"); + else + printf("%ld\n", value); +} diff --git a/system_cmds/getconf.tproj/getconf.h b/system_cmds/getconf.tproj/getconf.h new file mode 100644 index 0000000..3f7e412 --- /dev/null +++ b/system_cmds/getconf.tproj/getconf.h @@ -0,0 +1,43 @@ +/* + * Copyright 2000 Massachusetts Institute of Technology + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby + * granted, provided that both the above copyright notice and this + * permission notice appear in all copies, that both the above + * copyright notice and this permission notice appear in all + * supporting documentation, and that the name of M.I.T. not be used + * in advertising or publicity pertaining to distribution of the + * software without specific, written prior permission. M.I.T. makes + * no representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied + * warranty. + * + * THIS SOFTWARE IS PROVIDED BY M.I.T. ``AS IS''. M.I.T. DISCLAIMS + * ALL EXPRESS OR IMPLIED WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT + * SHALL M.I.T. 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. + * + * $FreeBSD: src/usr.bin/getconf/getconf.h,v 1.4 2002/10/27 04:14:08 wollman Exp $ + */ + +#ifdef STABLE +typedef long long intmax_t; +#define PRIdMAX "lld" +#else +#include <inttypes.h> +#endif + +int find_confstr(const char *name, int *key); +int find_limit(const char *name, intmax_t *value); +int find_pathconf(const char *name, int *key); +int find_progenv(const char *name, const char **alt_path); +int find_sysconf(const char *name, int *key); diff --git a/system_cmds/getconf.tproj/limits.gperf b/system_cmds/getconf.tproj/limits.gperf new file mode 100644 index 0000000..e94a8c7 --- /dev/null +++ b/system_cmds/getconf.tproj/limits.gperf @@ -0,0 +1,142 @@ +%{ +/* + * Copyright is disclaimed as to the contents of this file. + * + * $FreeBSD: src/usr.bin/getconf/limits.gperf,v 1.2 2003/08/22 17:32:07 markm Exp $ + */ + +#include <sys/types.h> + +#include <string.h> +#include <limits.h> +#ifdef APPLE_GETCONF_UNDERSCORE +#include <alloca.h> +#endif /* APPLE_GETCONF_UNDERSCORE */ + +#include "getconf.h" + +/* + * Override gperf's built-in external scope. + */ +static const struct map *in_word_set(const char *str); + +%} +struct map { const char *name; intmax_t value; int valid; }; +%% +_POSIX_AIO_LISTIO_MAX, _POSIX_AIO_LISTIO_MAX +_POSIX_AIO_MAX, _POSIX_AIO_MAX +_POSIX_ARG_MAX, _POSIX_ARG_MAX +_POSIX_CHILD_MAX, _POSIX_CHILD_MAX +_POSIX_CLOCKRES_MIN, _POSIX_CLOCKRES_MIN +_POSIX_DELAYTIMER_MAX, _POSIX_DELAYTIMER_MAX +_POSIX_HOST_NAME_MAX, _POSIX_HOST_NAME_MAX +_POSIX_LINK_MAX, _POSIX_LINK_MAX +_POSIX_LOGIN_NAME_MAX, _POSIX_LOGIN_NAME_MAX +_POSIX_MAX_CANON, _POSIX_MAX_CANON +_POSIX_MAX_INPUT, _POSIX_MAX_INPUT +_POSIX_MQ_OPEN_MAX, _POSIX_MQ_OPEN_MAX +_POSIX_MQ_PRIO_MAX, _POSIX_MQ_PRIO_MAX +_POSIX_NAME_MAX, _POSIX_NAME_MAX +_POSIX_NGROUPS_MAX, _POSIX_NGROUPS_MAX +_POSIX_OPEN_MAX, _POSIX_OPEN_MAX +_POSIX_PATH_MAX, _POSIX_PATH_MAX +_POSIX_PIPE_BUF, _POSIX_PIPE_BUF +_POSIX_RE_DUP_MAX, _POSIX_RE_DUP_MAX +_POSIX_RTSIG_MAX, _POSIX_RTSIG_MAX +_POSIX_SEM_NSEMS_MAX, _POSIX_SEM_NSEMS_MAX +_POSIX_SEM_VALUE_MAX, _POSIX_SEM_VALUE_MAX +_POSIX_SIGQUEUE_MAX, _POSIX_SIGQUEUE_MAX +_POSIX_SSIZE_MAX, _POSIX_SSIZE_MAX +_POSIX_STREAM_MAX, _POSIX_STREAM_MAX +_POSIX_SS_REPL_MAX, _POSIX_SS_REPL_MAX +_POSIX_SYMLINK_MAX, _POSIX_SYMLINK_MAX +_POSIX_SYMLOOP_MAX, _POSIX_SYMLOOP_MAX +_POSIX_THREAD_DESTRUCTOR_ITERATIONS, _POSIX_THREAD_DESTRUCTOR_ITERATIONS +_POSIX_THREAD_KEYS_MAX, _POSIX_THREAD_KEYS_MAX +_POSIX_THREAD_THREADS_MAX, _POSIX_THREAD_THREADS_MAX +_POSIX_TIMER_MAX, _POSIX_TIMER_MAX +_POSIX_TRACE_EVENT_NAME_MAX, _POSIX_TRACE_EVENT_NAME_MAX +_POSIX_TRACE_NAME_MAX, _POSIX_TRACE_NAME_MAX +_POSIX_TRACE_SYS_MAX, _POSIX_TRACE_SYS_MAX +_POSIX_TRACE_USER_EVENT_MAX, _POSIX_TRACE_USER_EVENT_MAX +_POSIX_TTY_NAME_MAX, _POSIX_TTY_NAME_MAX +_POSIX_TZNAME_MAX, _POSIX_TZNAME_MAX +_POSIX2_BC_BASE_MAX, _POSIX2_BC_BASE_MAX +_POSIX2_BC_DIM_MAX, _POSIX2_BC_DIM_MAX +_POSIX2_BC_SCALE_MAX, _POSIX2_BC_SCALE_MAX +_POSIX2_BC_STRING_MAX, _POSIX2_BC_STRING_MAX +_POSIX2_CHARCLASS_NAME_MAX, _POSIX2_CHARCLASS_NAME_MAX +_POSIX2_COLL_WEIGHTS_MAX, _POSIX2_COLL_WEIGHTS_MAX +_POSIX2_EXPR_NEST_MAX, _POSIX2_EXPR_NEST_MAX +_POSIX2_LINE_MAX, _POSIX2_LINE_MAX +_POSIX2_RE_DUP_MAX, _POSIX2_RE_DUP_MAX +_XOPEN_IOV_MAX, _XOPEN_IOV_MAX +_XOPEN_NAME_MAX, _XOPEN_NAME_MAX +_XOPEN_PATH_MAX, _XOPEN_PATH_MAX +CHAR_BIT, CHAR_BIT +CHAR_MAX, CHAR_MAX +CHAR_MIN, CHAR_MIN +INT_MAX, INT_MAX +INT_MIN, INT_MIN +LLONG_MIN, LLONG_MIN +LLONG_MAX, LLONG_MAX +LONG_BIT, LONG_BIT +LONG_MAX, LONG_MAX +LONG_MIN, LONG_MIN +MB_LEN_MAX, MB_LEN_MAX +SCHAR_MAX, SCHAR_MAX +SCHAR_MIN, SCHAR_MIN +SHRT_MAX, SHRT_MAX +SHRT_MIN, SHRT_MIN +SSIZE_MAX, SSIZE_MAX +UCHAR_MAX, UCHAR_MAX +UINT_MAX, UINT_MAX +ULLONG_MAX, ULLONG_MAX +ULONG_MAX, ULONG_MAX +USHRT_MAX, USHRT_MAX +WORD_BIT, WORD_BIT +CHARCLASS_NAME_MAX, CHARCLASS_NAME_MAX +NL_ARGMAX, NL_ARGMAX +ML_LANGMAX, NL_LANGMAX +NL_MSGMAX, NL_MSGMAX +NL_NMAX, NL_NMAX +NL_SETMAX, NL_SETMAX +NL_TEXTMAX, NL_TEXTMAX +NZERO, NZERO +%% +int +find_limit(const char *name, intmax_t *value) +{ + const struct map *rv; +#ifdef APPLE_GETCONF_UNDERSCORE + char *alt; +#endif /* APPLE_GETCONF_UNDERSCORE */ + + rv = in_word_set(name); + if (rv != NULL) { + if (rv->valid) { + *value = rv->value; + return 1; + } + return -1; + } +#ifdef APPLE_GETCONF_UNDERSCORE + if(*name == '_') + alt = (char *)name + 1; + else { + if((alt = (char *)alloca(strlen(name) + 2)) == NULL) + return 0; + *alt = '_'; + strcpy(alt + 1, name); + } + rv = in_word_set(alt); + if (rv != NULL) { + if (rv->valid) { + *value = rv->value; + return 1; + } + return -1; + } +#endif /* APPLE_GETCONF_UNDERSCORE */ + return 0; +} diff --git a/system_cmds/getconf.tproj/pathconf.gperf b/system_cmds/getconf.tproj/pathconf.gperf new file mode 100644 index 0000000..ebb317f --- /dev/null +++ b/system_cmds/getconf.tproj/pathconf.gperf @@ -0,0 +1,88 @@ +%{ +/* + * Copyright is disclaimed as to the contents of this file. + * + * $FreeBSD: src/usr.bin/getconf/pathconf.gperf,v 1.4 2003/08/22 17:32:07 markm Exp $ + */ + +#include <sys/types.h> + +#include <string.h> +#include <unistd.h> +#ifdef APPLE_GETCONF_UNDERSCORE +#include <alloca.h> +#endif /* APPLE_GETCONF_UNDERSCORE */ + +#include "getconf.h" + +/* + * Override gperf's built-in external scope. + */ +static const struct map *in_word_set(const char *str); + +%} +struct map { const char *name; int key; int valid; }; +%% +FILESIZEBITS, _PC_FILESIZEBITS +LINK_MAX, _PC_LINK_MAX +MAX_CANON, _PC_MAX_CANON +MAX_INPUT, _PC_MAX_INPUT +NAME_MAX, _PC_NAME_MAX +PATH_MAX, _PC_PATH_MAX +PIPE_BUF, _PC_PIPE_BUF +POSIX_ALLOC_SIZE_MIN, _PC_ALLOC_SIZE_MIN +POSIX_REC_INCR_XFER_SIZE, _PC_REC_INCR_XFER_SIZE +POSIX_REC_MAX_XFER_SIZE, _PC_REC_MAX_XFER_SIZE +POSIX_REC_MIN_XFER_SIZE, _PC_REC_MIN_XFER_SIZE +POSIX_REC_XFER_ALIGN, _PC_REC_XFER_ALIGN +POSIX2_SYMLINKS, _PC_2_SYMLINKS +SYMLINK_MAX, _PC_SYMLINK_MAX +TRUSTEDBSD_ACL_EXTENDED, _PC_ACL_EXTENDED +TRUSTEDBSD_ACL_PATH_MAX, _PC_ACL_PATH_MAX +TRUSTEDBSD_CAP_PRESENT, _PC_CAP_PRESENT +TRUSTEDBSD_INF_PRESENT, _PC_INF_PRESENT +TRUSTEDBSD_MAC_PRESENT, _PC_MAC_PRESENT +_POSIX_ASYNC_IO, _PC_ASYNC_IO +_POSIX_CHOWN_RESTRICTED, _PC_CHOWN_RESTRICTED +_POSIX_NO_TRUNC, _PC_NO_TRUNC +_POSIX_PATH_MAX, _PC_PATH_MAX +_POSIX_PRIO_IO, _PC_PRIO_IO +_POSIX_SYNC_IO, _PC_SYNC_IO +_POSIX_VDISABLE, _PC_VDISABLE +%% +int +find_pathconf(const char *name, int *key) +{ + const struct map *rv; +#ifdef APPLE_GETCONF_UNDERSCORE + char *alt; +#endif /* APPLE_GETCONF_UNDERSCORE */ + + rv = in_word_set(name); + if (rv != NULL) { + if (rv->valid) { + *key = rv->key; + return 1; + } + return -1; + } +#ifdef APPLE_GETCONF_UNDERSCORE + if(*name == '_') + alt = (char *)name + 1; + else { + if((alt = (char *)alloca(strlen(name) + 2)) == NULL) + return 0; + *alt = '_'; + strcpy(alt + 1, name); + } + rv = in_word_set(alt); + if (rv != NULL) { + if (rv->valid) { + *key = rv->key; + return 1; + } + return -1; + } +#endif /* APPLE_GETCONF_UNDERSCORE */ + return 0; +} diff --git a/system_cmds/getconf.tproj/progenv.gperf b/system_cmds/getconf.tproj/progenv.gperf new file mode 100644 index 0000000..4e3245a --- /dev/null +++ b/system_cmds/getconf.tproj/progenv.gperf @@ -0,0 +1,70 @@ +%{ +/* + * Copyright is disclaimed as to the contents of this file. + * + * $FreeBSD: src/usr.bin/getconf/progenv.gperf,v 1.2 2003/08/22 17:32:07 markm Exp $ + */ + +#include <sys/types.h> + +#include <string.h> +#include <unistd.h> + +#include "getconf.h" + +/* + * Override gperf's built-in external scope. + */ +static const struct map *in_word_set(const char *str); + +/* + * The Standard seems a bit ambiguous over whether the POSIX_V6_* + * are specified with or without a leading underscore, so we just + * use both. + */ +/* + * The alt_path member gives the path containing another `getconf' + * executable which was compiled using the specified programming + * environment. If it is NULL, the current executable is good enough. + * If we ever support multiple environments, this table will need to + * be updated. (We cheat here and define the supported environments + * statically.) + */ +#if defined(__alpha__) || defined(__sparc64__) +#define have_LP64_OFF64 NULL +#elif defined(__APPLE__) +#define have_LP64_OFF64 NULL +#define have_LPBIG_OFFBIG NULL +#endif + +#if defined(__i386__) || defined(__powerpc__) || defined(__x86_64__) +#define have_ILP32_OFFBIG NULL +#endif + +%} +struct map { const char *name; const char *alt_path; int valid; }; +%% +POSIX_V6_ILP32_OFF32, notdef +POSIX_V6_ILP32_OFFBIG, have_ILP32_OFFBIG +POSIX_V6_LP64_OFF64, have_LP64_OFF64 +POSIX_V6_LPBIG_OFFBIG, have_LPBIG_OFFBIG +_POSIX_V6_ILP32_OFF32, notdef +_POSIX_V6_ILP32_OFFBIG, have_ILP32_OFFBIG +_POSIX_V6_LP64_OFF64, have_LP64_OFF64 +_POSIX_V6_LPBIG_OFFBIG, have_LPBIG_OFFBIG +%% +int +find_progenv(const char *name, const char **alt_path) +{ + const struct map *rv; + + rv = in_word_set(name); + if (rv != NULL) { + if (rv->valid) { + *alt_path = rv->alt_path; + return 1; + } + return -1; + } + return 0; +} diff --git a/system_cmds/getconf.tproj/sysconf.gperf b/system_cmds/getconf.tproj/sysconf.gperf new file mode 100644 index 0000000..9bc3866 --- /dev/null +++ b/system_cmds/getconf.tproj/sysconf.gperf @@ -0,0 +1,187 @@ +%{ +/* + * Copyright is disclaimed as to the contents of this file. + * + * $FreeBSD: src/usr.bin/getconf/sysconf.gperf,v 1.5 2003/08/22 17:32:07 markm Exp $ + */ + +#include <sys/types.h> + +#include <string.h> +#include <unistd.h> +#ifdef APPLE_GETCONF_UNDERSCORE +#include <alloca.h> +#endif /* APPLE_GETCONF_UNDERSCORE */ + +#include "getconf.h" + +/* + * Override gperf's built-in external scope. + */ +static const struct map *in_word_set(const char *str); + +%} +struct map { const char *name; int key; int valid; }; +%% +AIO_LISTIO_MAX, _SC_AIO_LISTIO_MAX +AIO_MAX, _SC_AIO_MAX +AIO_PRIO_DELTA_MAX, _SC_AIO_PRIO_DELTA_MAX +ARG_MAX, _SC_ARG_MAX +ATEXIT_MAX, _SC_ATEXIT_MAX +BC_BASE_MAX, _SC_BC_BASE_MAX +BC_DIM_MAX, _SC_BC_DIM_MAX +BC_SCALE_MAX, _SC_BC_SCALE_MAX +BC_STRING_MAX, _SC_BC_STRING_MAX +CHILD_MAX, _SC_CHILD_MAX +CLK_TCK, _SC_CLK_TCK +COLL_WEIGHTS_MAX, _SC_COLL_WEIGHTS_MAX +DELAYTIMER_MAX, _SC_DELAYTIMER_MAX +EXPR_NEST_MAX, _SC_EXPR_NEST_MAX +GETGR_R_SIZE_MAX, _SC_GETGR_R_SIZE_MAX +GETPW_R_SIZE_MAX, _SC_GETPW_R_SIZE_MAX +HOST_NAME_MAX, _SC_HOST_NAME_MAX +IOV_MAX, _SC_IOV_MAX +LINE_MAX, _SC_LINE_MAX +LOGIN_NAME_MAX, _SC_LOGIN_NAME_MAX +MQ_OPEN_MAX, _SC_MQ_OPEN_MAX +MQ_PRIO_MAX, _SC_MQ_PRIO_MAX +NGROUPS_MAX, _SC_NGROUPS_MAX +NPROCESSORS_CONF, _SC_NPROCESSORS_CONF +NPROCESSORS_ONLN, _SC_NPROCESSORS_ONLN +OPEN_MAX, _SC_OPEN_MAX +PAGESIZE, _SC_PAGESIZE +PAGE_SIZE, _SC_PAGESIZE +PASS_MAX, _SC_PASS_MAX +PTHREAD_DESTRUCTOR_ITERATIONS, _SC_THREAD_DESTRUCTOR_ITERATIONS +PTHREAD_KEYS_MAX, _SC_THREAD_KEYS_MAX +PTHREAD_STACK_MIN, _SC_THREAD_STACK_MIN +PTHREAD_THREADS_MAX, _SC_THREAD_THREADS_MAX +RE_DUP_MAX, _SC_RE_DUP_MAX +RTSIG_MAX, _SC_RTSIG_MAX +SEM_NSEMS_MAX, _SC_SEM_NSEMS_MAX +SEM_VALUE_MAX, _SC_SEM_VALUE_MAX +SIGQUEUE_MAX, _SC_SIGQUEUE_MAX +STREAM_MAX, _SC_STREAM_MAX +SYMLOOP_MAX, _SC_SYMLOOP_MAX +TIMER_MAX, _SC_TIMER_MAX +TTY_NAME_MAX, _SC_TTY_NAME_MAX +TZNAME_MAX, _SC_TZNAME_MAX +_POSIX2_CHAR_TERM, _SC_2_CHAR_TERM +_POSIX2_C_BIND, _SC_2_C_BIND +_POSIX2_C_DEV, _SC_2_C_DEV +_POSIX2_C_VERSION, _SC_2_C_VERSION +_POSIX2_FORT_DEV, _SC_2_FORT_DEV +_POSIX2_FORT_RUN, _SC_2_FORT_RUN +_POSIX2_LOCALEDEF, _SC_2_LOCALEDEF +_POSIX2_PBS, _SC_PBS +_POSIX2_PBS_ACCOUNTING, _SC_PBS_ACCOUNTING +_POSIX2_PBS_CHECKPOINT, _SC_PBS_CHECKPOINT +_POSIX2_PBS_LOCATE, _SC_PBS_LOCATE +_POSIX2_PBS_MESSAGE, _SC_PBS_MESSAGE +_POSIX2_PBS_TRACK, _SC_PBS_TRACK +_POSIX2_SW_DEV, _SC_2_SW_DEV +_POSIX2_UPE, _SC_2_UPE +_POSIX2_VERSION, _SC_2_VERSION +_POSIX_ADVISORY_INFO, _SC_ADVISORY_INFO +_POSIX_ASYNCHRONOUS_IO, _SC_ASYNCHRONOUS_IO +_POSIX_BARRIERS, _SC_BARRIERS +_POSIX_CLOCK_SELECTION, _SC_CLOCK_SELECTION +_POSIX_CPUTIME, _SC_CPUTIME +_POSIX_FILE_LOCKING, _SC_FILE_LOCKING +_POSIX_FSYNC, _SC_FSYNC +_POSIX_IPV6, _SC_IPV6 +_POSIX_JOB_CONTROL, _SC_JOB_CONTROL +_POSIX_MAPPED_FILES, _SC_MAPPED_FILES +_POSIX_MEMLOCK, _SC_MEMLOCK +_POSIX_MEMLOCK_RANGE, _SC_MEMLOCK_RANGE +_POSIX_MEMORY_PROTECTION, _SC_MEMORY_PROTECTION +_POSIX_MESSAGE_PASSING, _SC_MESSAGE_PASSING +_POSIX_MONOTONIC_CLOCK, _SC_MONOTONIC_CLOCK +_POSIX_PRIORITIZED_IO, _SC_PRIORITIZED_IO +_POSIX_PRIORITY_SCHEDULING, _SC_PRIORITY_SCHEDULING +_POSIX_RAW_SOCKETS, _SC_RAW_SOCKETS +_POSIX_READER_WRITER_LOCKS, _SC_READER_WRITER_LOCKS +_POSIX_REALTIME_SIGNALS, _SC_REALTIME_SIGNALS +_POSIX_REGEXP, _SC_REGEXP +_POSIX_SAVED_IDS, _SC_SAVED_IDS +_POSIX_SEMAPHORES, _SC_SEMAPHORES +_POSIX_SHARED_MEMORY_OBJECTS, _SC_SHARED_MEMORY_OBJECTS +_POSIX_SHELL, _SC_SHELL +_POSIX_SPAWN, _SC_SPAWN +_POSIX_SPIN_LOCKS, _SC_SPIN_LOCKS +_POSIX_SPORADIC_SERVER, _SC_SPORADIC_SERVER +_POSIX_SS_REPL_MAX, _SC_SS_REPL_MAX +_POSIX_SYNCHRONIZED_IO, _SC_SYNCHRONIZED_IO +_POSIX_THREADS, _SC_THREADS +_POSIX_THREAD_ATTR_STACKADDR, _SC_THREAD_ATTR_STACKADDR +_POSIX_THREAD_ATTR_STACKSIZE, _SC_THREAD_ATTR_STACKSIZE +_POSIX_THREAD_CPUTIME, _SC_THREAD_CPUTIME +_POSIX_THREAD_PRIORITY_SCHEDULING, _SC_THREAD_PRIORITY_SCHEDULING +_POSIX_THREAD_PRIO_INHERIT, _SC_THREAD_PRIO_INHERIT +_POSIX_THREAD_PRIO_PROTECT, _SC_THREAD_PRIO_PROTECT +_POSIX_THREAD_PROCESS_SHARED, _SC_THREAD_PROCESS_SHARED +_POSIX_THREAD_SAFE_FUNCTIONS, _SC_THREAD_SAFE_FUNCTIONS +_POSIX_THREAD_SPORADIC_SERVER, _SC_THREAD_SPORADIC_SERVER +_POSIX_TIMEOUTS, _SC_TIMEOUTS +_POSIX_TIMERS, _SC_TIMERS +_POSIX_TRACE, _SC_TRACE +_POSIX_TRACE_EVENT_FILTER, _SC_TRACE_EVENT_FILTER +_POSIX_TRACE_EVENT_NAME_MAX, _SC_TRACE_EVENT_NAME_MAX +_POSIX_TRACE_INHERIT, _SC_TRACE_INHERIT +_POSIX_TRACE_LOG, _SC_TRACE_LOG +_POSIX_TRACE_NAME_MAX, _SC_TRACE_NAME_MAX +_POSIX_TRACE_SYS_MAX, _SC_TRACE_SYS_MAX +_POSIX_TRACE_USER_EVENT_MAX, _SC_TRACE_USER_EVENT_MAX +_POSIX_TYPED_MEMORY_OBJECTS, _SC_TYPED_MEMORY_OBJECTS +_POSIX_V6_ILP32_OFF32, _SC_V6_ILP32_OFF32 +_POSIX_V6_ILP32_OFFBIG, _SC_V6_ILP32_OFFBIG +_POSIX_V6_LP64_OFF64, _SC_V6_LP64_OFF64 +_POSIX_V6_LPBIG_OFFBIG, _SC_V6_LPBIG_OFFBIG +_POSIX_VERSION, _SC_VERSION +_XOPEN_CRYPT, _SC_XOPEN_CRYPT +_XOPEN_ENH_I18N, _SC_XOPEN_ENH_I18N +_XOPEN_LEGACY, _SC_XOPEN_LEGACY +_XOPEN_REALTIME, _SC_XOPEN_REALTIME +_XOPEN_REALTIME_THREADS, _SC_XOPEN_REALTIME_THREADS +_XOPEN_SHM, _SC_XOPEN_SHM +_XOPEN_STREAMS, _SC_XOPEN_STREAMS +_XOPEN_UNIX, _SC_XOPEN_UNIX +_XOPEN_VERSION, _SC_XOPEN_VERSION +_XOPEN_XCU_VERSION, _SC_XCU_VERSION +%% +int +find_sysconf(const char *name, int *key) +{ + const struct map *rv; +#ifdef APPLE_GETCONF_UNDERSCORE + char *alt; +#endif /* APPLE_GETCONF_UNDERSCORE */ + + rv = in_word_set(name); + if (rv != NULL) { + if (rv->valid) { + *key = rv->key; + return 1; + } + return -1; + } +#ifdef APPLE_GETCONF_UNDERSCORE + if(*name == '_') + alt = (char *)name + 1; + else { + if((alt = (char *)alloca(strlen(name) + 2)) == NULL) + return 0; + *alt = '_'; + strcpy(alt + 1, name); + } + rv = in_word_set(alt); + if (rv != NULL) { + if (rv->valid) { + *key = rv->key; + return 1; + } + return -1; + } +#endif /* APPLE_GETCONF_UNDERSCORE */ + return 0; +} |