xref: /freebsd/lib/libc/gen/confstr.3 (revision dc36d6f9bb1753f3808552f3afd30eda9a7b206a)
158f0484fSRodney W. Grimes.\" Copyright (c) 1993
258f0484fSRodney W. Grimes.\"	The Regents of the University of California.  All rights reserved.
358f0484fSRodney W. Grimes.\"
458f0484fSRodney W. Grimes.\" Redistribution and use in source and binary forms, with or without
558f0484fSRodney W. Grimes.\" modification, are permitted provided that the following conditions
658f0484fSRodney W. Grimes.\" are met:
758f0484fSRodney W. Grimes.\" 1. Redistributions of source code must retain the above copyright
858f0484fSRodney W. Grimes.\"    notice, this list of conditions and the following disclaimer.
958f0484fSRodney W. Grimes.\" 2. Redistributions in binary form must reproduce the above copyright
1058f0484fSRodney W. Grimes.\"    notice, this list of conditions and the following disclaimer in the
1158f0484fSRodney W. Grimes.\"    documentation and/or other materials provided with the distribution.
12*fbbd9655SWarner Losh.\" 3. Neither the name of the University nor the names of its contributors
1358f0484fSRodney W. Grimes.\"    may be used to endorse or promote products derived from this software
1458f0484fSRodney W. Grimes.\"    without specific prior written permission.
1558f0484fSRodney W. Grimes.\"
1658f0484fSRodney W. Grimes.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
1758f0484fSRodney W. Grimes.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1858f0484fSRodney W. Grimes.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1958f0484fSRodney W. Grimes.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2058f0484fSRodney W. Grimes.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2158f0484fSRodney W. Grimes.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2258f0484fSRodney W. Grimes.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2358f0484fSRodney W. Grimes.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2458f0484fSRodney W. Grimes.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2558f0484fSRodney W. Grimes.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2658f0484fSRodney W. Grimes.\" SUCH DAMAGE.
2758f0484fSRodney W. Grimes.\"
2888ce7257SMaxim Konovalov.Dd December 3, 2006
2958f0484fSRodney W. Grimes.Dt CONFSTR 3
30a307d598SRuslan Ermilov.Os
3158f0484fSRodney W. Grimes.Sh NAME
3258f0484fSRodney W. Grimes.Nm confstr
3358f0484fSRodney W. Grimes.Nd get string-valued configurable variables
3425bb73e0SAlexey Zelkin.Sh LIBRARY
3525bb73e0SAlexey Zelkin.Lb libc
3658f0484fSRodney W. Grimes.Sh SYNOPSIS
3732eef9aeSRuslan Ermilov.In unistd.h
3858f0484fSRodney W. Grimes.Ft size_t
3958f0484fSRodney W. Grimes.Fn confstr "int name" "char *buf" "size_t len"
4058f0484fSRodney W. Grimes.Sh DESCRIPTION
413f22a03fSGarrett WollmanThis interface is specified by
42edd2da71SRuslan Ermilov.St -p1003.1-2001 .
433f22a03fSGarrett WollmanA more flexible (but non-portable) interface is provided by
44bf5a138eSMike Pritchard.Xr sysctl 3 .
4558f0484fSRodney W. Grimes.Pp
4658f0484fSRodney W. GrimesThe
4758f0484fSRodney W. Grimes.Fn confstr
4858f0484fSRodney W. Grimesfunction provides a method for applications to get configuration
4958f0484fSRodney W. Grimesdefined string values.
503f22a03fSGarrett WollmanShell programmers needing access to these parameters should use the
513f22a03fSGarrett Wollman.Xr getconf 1
523f22a03fSGarrett Wollmanutility.
5358f0484fSRodney W. Grimes.Pp
5458f0484fSRodney W. GrimesThe
5558f0484fSRodney W. Grimes.Fa name
5658f0484fSRodney W. Grimesargument specifies the system variable to be queried.
5758f0484fSRodney W. GrimesSymbolic constants for each name value are found in the include file
58fe08efe6SRuslan Ermilov.In unistd.h .
5958f0484fSRodney W. GrimesThe
6058f0484fSRodney W. Grimes.Fa len
6158f0484fSRodney W. Grimesargument specifies the size of the buffer referenced by the
6258f0484fSRodney W. Grimesargument
6358f0484fSRodney W. Grimes.Fa buf .
6458f0484fSRodney W. GrimesIf
6558f0484fSRodney W. Grimes.Fa len
6658f0484fSRodney W. Grimesis non-zero,
6758f0484fSRodney W. Grimes.Fa buf
6858f0484fSRodney W. Grimesis a non-null pointer, and
6958f0484fSRodney W. Grimes.Fa name
7058f0484fSRodney W. Grimeshas a value, up to
7158f0484fSRodney W. Grimes.Fa len
7258f0484fSRodney W. Grimes\- 1 bytes of the value are copied into the buffer
7358f0484fSRodney W. Grimes.Fa buf .
7458f0484fSRodney W. GrimesThe copied value is always null terminated.
7558f0484fSRodney W. Grimes.Pp
7658f0484fSRodney W. GrimesThe available values are as follows:
7742635956SRuslan Ermilov.Bl -tag -width 6n
7858f0484fSRodney W. Grimes.It Li _CS_PATH
7958f0484fSRodney W. GrimesReturn a value for the
8058f0484fSRodney W. Grimes.Ev PATH
8158f0484fSRodney W. Grimesenvironment variable that finds all the standard utilities.
8258f0484fSRodney W. Grimes.El
8358f0484fSRodney W. Grimes.Sh RETURN VALUES
8458f0484fSRodney W. GrimesIf the call to
85bf5a138eSMike Pritchard.Fn confstr
8688ce7257SMaxim Konovalovis not successful, 0 is returned and
8758f0484fSRodney W. Grimes.Va errno
8858f0484fSRodney W. Grimesis set appropriately.
8958f0484fSRodney W. GrimesOtherwise, if the variable does not have a configuration defined value,
9058f0484fSRodney W. Grimes0 is returned and
9158f0484fSRodney W. Grimes.Va errno
9258f0484fSRodney W. Grimesis not modified.
9358f0484fSRodney W. GrimesOtherwise, the buffer size needed to hold the entire configuration-defined
9458f0484fSRodney W. Grimesvalue is returned.
9558f0484fSRodney W. GrimesIf this size is greater than the argument
9658f0484fSRodney W. Grimes.Fa len ,
9758f0484fSRodney W. Grimesthe string in
9858f0484fSRodney W. Grimes.Fa buf
9958f0484fSRodney W. Grimeswas truncated.
10058f0484fSRodney W. Grimes.Sh ERRORS
10158f0484fSRodney W. GrimesThe
102bf5a138eSMike Pritchard.Fn confstr
10358f0484fSRodney W. Grimesfunction may fail and set
1043f22a03fSGarrett Wollman.Va errno
10558f0484fSRodney W. Grimesfor any of the errors specified for the library functions
10658f0484fSRodney W. Grimes.Xr malloc 3
10758f0484fSRodney W. Grimesand
10858f0484fSRodney W. Grimes.Xr sysctl 3 .
10958f0484fSRodney W. Grimes.Pp
11058f0484fSRodney W. GrimesIn addition, the following errors may be reported:
11158f0484fSRodney W. Grimes.Bl -tag -width Er
11258f0484fSRodney W. Grimes.It Bq Er EINVAL
11358f0484fSRodney W. GrimesThe value of the
11458f0484fSRodney W. Grimes.Fa name
11558f0484fSRodney W. Grimesargument is invalid.
11642635956SRuslan Ermilov.El
11758f0484fSRodney W. Grimes.Sh SEE ALSO
1183f22a03fSGarrett Wollman.Xr getconf 1 ,
1193f22a03fSGarrett Wollman.Xr pathconf 2 ,
1203f22a03fSGarrett Wollman.Xr sysconf 3 ,
12158f0484fSRodney W. Grimes.Xr sysctl 3
12258f0484fSRodney W. Grimes.Sh HISTORY
12358f0484fSRodney W. GrimesThe
124bf5a138eSMike Pritchard.Fn confstr
1257bdf80e5SMike Pritchardfunction first appeared in
1267bdf80e5SMike Pritchard.Bx 4.4 .
127