xref: /original-bsd/lib/libc/gen/confstr.3 (revision c3e32dec)
1.\" Copyright (c) 1993
2.\"	The Regents of the University of California.  All rights reserved.
3.\"
4.\" %sccs.include.redist.roff%
5.\"
6.\"	@(#)confstr.3	8.1 (Berkeley) 06/04/93
7.\"
8.Dd
9.Dt CONFSTR 3
10.Os BSD 4
11.Sh NAME
12.Nm confstr
13.Nd get string-valued configurable variables
14.Sh SYNOPSIS
15.Fd #include <unistd.h>
16.Ft size_t
17.Fn confstr "int name" "char *buf" "size_t len"
18.Sh DESCRIPTION
19.Bf -symbolic
20This interface is obsoleted by sysctl(3).
21.Ef
22.Pp
23The
24.Fn confstr
25function provides a method for applications to get configuration
26defined string values.
27.Pp
28The
29.Fa name
30argument specifies the system variable to be queried.
31Symbolic constants for each name value are found in the include file
32.Li <unistd.h> .
33The
34.Fa len
35argument specifies the size of the buffer referenced by the
36argument
37.Fa buf .
38If
39.Fa len
40is non-zero,
41.Fa buf
42is a non-null pointer, and
43.Fa name
44has a value, up to
45.Fa len
46\- 1 bytes of the value are copied into the buffer
47.Fa buf .
48The copied value is always null terminated.
49.Pp
50The available values are as follows:
51.Pp
52.Bl -tag -width "123456"
53.Pp
54.It Li _CS_PATH
55Return a value for the
56.Ev PATH
57environment variable that finds all the standard utilities.
58.El
59.Sh RETURN VALUES
60If the call to
61.Nm confstr
62is not successful, \-1 is returned and
63.Va errno
64is set appropriately.
65Otherwise, if the variable does not have a configuration defined value,
660 is returned and
67.Va errno
68is not modified.
69Otherwise, the buffer size needed to hold the entire configuration-defined
70value is returned.
71If this size is greater than the argument
72.Fa len ,
73the string in
74.Fa buf
75was truncated.
76.Sh ERRORS
77The
78.Nm confstr
79function may fail and set
80.Va error
81for any of the errors specified for the library functions
82.Xr malloc 3
83and
84.Xr sysctl 3 .
85.Pp
86In addition, the following errors may be reported:
87.Bl -tag -width Er
88.It Bq Er EINVAL
89The value of the
90.Fa name
91argument is invalid.
92.Sh SEE ALSO
93.Xr sysctl 3
94.Sh HISTORY
95The
96.Nm confstr
97function first appeared in 4.4BSD.
98