getconf.c revision 1
1N/A/*********************************************************************** 1N/A* This software is part of the ast package * 1N/A* Copyright (c) 1992-2011 AT&T Intellectual Property * 1N/A* and is licensed under the * 1N/A* Common Public License, Version 1.0 * 1N/A* by AT&T Intellectual Property * 1N/A* A copy of the License is available at * 1N/A* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) * 1N/A* Information and Software Systems Research * 1N/A* Glenn Fowler <gsf@research.att.com> * 1N/A* David Korn <dgk@research.att.com> * 1N/A***********************************************************************/ 1N/A * getconf - get configuration values 1N/A"[-?\n@(#)$Id: getconf (AT&T Research) 2008-04-24 $\n]" 1N/A"[+NAME?getconf - get configuration values]" 1N/A"[+DESCRIPTION?\bgetconf\b displays the system configuration value for" 1N/A" \aname\a. If \aname\a is a filesystem specific variable then" 1N/A" the value is determined relative to \apath\a or the current" 1N/A" directory if \apath\a is omitted. If \avalue\a is specified then" 1N/A" \bgetconf\b attempts to change the process local value to \avalue\a." 1N/A" \b-\b may be used in place of \apath\a when it is not relevant." 1N/A" If \apath\a is \b=\b then the the \avalue\a is cached and used" 1N/A" for subsequent tests in the calling and all child processes." 1N/A" Only \bwritable\b variables may be set; \breadonly\b variables" 1N/A" cannot be changed.]" 1N/A"[+?The current value for \aname\a is written to the standard output. If" 1N/A" \aname\a is valid but undefined then \bundefined\b is written to" 1N/A" the standard output. If \aname\a is invalid or an error occurs in" 1N/A" determining its value, then a diagnostic written to the standard error" 1N/A" and \bgetconf\b exits with a non-zero exit status.]" 1N/A"[+?More than one variable may be set or queried by providing the \aname\a" 1N/A" \apath\a \avalue\a 3-tuple for each variable, specifying \b-\b for" 1N/A" \avalue\a when querying.]" 1N/A"[+?If no operands are specified then all known variables are written in" 1N/A" \aname\a=\avalue\a form to the standard output, one per line." 1N/A" Only one of \b--call\b, \b--name\b or \b--standard\b may be specified.]" 1N/A"[+?This implementation uses the \bastgetconf\b(3) string interface to the native" 1N/A" \bsysconf\b(2), \bconfstr\b(2), \bpathconf\b(2), and \bsysinfo\b(2)" 1N/A" system calls. If \bgetconf\b on \b$PATH\b is not the default native" 1N/A" \bgetconf\b, named by \b$(getconf GETCONF)\b, then \bastgetconf\b(3)" 1N/A" checks only \bast\b specific extensions and the native system calls;" 1N/A" invalid options and/or names not supported by \bastgetconf\b(3) cause" 1N/A" the \bgetconf\b on \b$PATH\b to be executed.]" 1N/A"[a:all?Call the native \bgetconf\b(1) with option \b-a\b.]" 1N/A"[b:base?List base variable name sans call and standard prefixes.]" 1N/A"[c:call?Display variables with call prefix that matches \aRE\a. The call" 1N/A" prefixes are:]:[RE]{" 1N/A" [+CS?\bconfstr\b(2)]" 1N/A" [+PC?\bpathconf\b(2)]" 1N/A" [+SC?\bsysconf\b(2)]" 1N/A" [+SI?\bsysinfo\b(2)]" 1N/A" [+XX?Constant value.]" 1N/A"[d:defined?Only display defined values when no operands are specified.]" 1N/A"[l:lowercase?List variable names in lower case.]" 1N/A"[n:name?Display variables with name that match \aRE\a.]:[RE]" 1N/A"[p:portable?Display the named \bwritable\b variables and values in a form that" 1N/A" can be directly executed by \bsh\b(1) to set the values. If \aname\a" 1N/A" is omitted then all \bwritable\b variables are listed.]" 1N/A"[q:quote?\"...\" quote values.]" 1N/A"[r:readonly?Display the named \breadonly\b variables in \aname\a=\avalue\a form." 1N/A" If \aname\a is omitted then all \breadonly\b variables are listed.]" 1N/A"[s:standard?Display variables with standard prefix that matches \aRE\a." 1N/A" Use the \b--table\b option to view all standard prefixes, including" 1N/A" local additions. The standard prefixes available on all systems" 1N/A"[t:table?Display the internal table that contains the name, standard," 1N/A" standard section, and system call symbol prefix for each variable.]" 1N/A"[w:writable?Display the named \bwritable\b variables in \aname\a=\avalue\a" 1N/A" form. If \aname\a is omitted then all \bwritable\b variables are" 1N/A"[v:specification?Call the native \bgetconf\b(1) with option" 1N/A" \b-v\b \aname\a.]:[name]" 1N/A"\n[ name [ path [ value ] ] ... ]\n" 1N/A" [+_AST_FEATURES?Process local writable values that are different from" 1N/A" the default are stored in the \b_AST_FEATURES\b environment" 1N/A" variable. The \b_AST_FEATURES\b value is a space-separated" 1N/A" list of \aname\a \apath\a \avalue\a 3-tuples, where" 1N/A" \aname\a is the system configuration name, \apath\a is the" 1N/A" corresponding path, \b-\b if no path is applicable, and" 1N/A" \avalue\a is the system configuration value.]" 1N/A"[+SEE ALSO?\bpathchk\b(1), \bconfstr\b(2), \bpathconf\b(2)," 1N/A" \bsysconf\b(2), \bastgetconf\b(3)]" 1N/A register const char* s;
1N/A register const char* t;
1N/A * defer to argv[0] if absolute and it exists 1N/A * defer to the first getconf on $PATH that is also on the standard PATH 1N/A for (t = s; *s && *s !=
':'; s++);
1N/A if ((n = s - t) && *t ==
'/')
1N/A for (i = 0; i <
2; i++)
1N/A for (t = s; *s && *s !=
':'; s++);
1N/A if ((n = s - t) && *t ==
'/')
1N/A * defer to the first getconf on the standard PATH 1N/A error(
4,
"%s: unknown name -- no native getconf(1) to defer to",
name);
1N/A error(
4,
"no native getconf(1) to defer to");
1N/A * don't blame us for crappy diagnostics