1.\" $OpenBSD: confstr.3,v 1.16 2007/05/31 19:19:28 jmc Exp $ 2.\" 3.\" Copyright (c) 1993 4.\" The Regents of the University of California. All rights reserved. 5.\" 6.\" Redistribution and use in source and binary forms, with or without 7.\" modification, are permitted provided that the following conditions 8.\" are met: 9.\" 1. Redistributions of source code must retain the above copyright 10.\" notice, this list of conditions and the following disclaimer. 11.\" 2. Redistributions in binary form must reproduce the above copyright 12.\" notice, this list of conditions and the following disclaimer in the 13.\" documentation and/or other materials provided with the distribution. 14.\" 3. Neither the name of the University nor the names of its contributors 15.\" may be used to endorse or promote products derived from this software 16.\" without specific prior written permission. 17.\" 18.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 19.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 22.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28.\" SUCH DAMAGE. 29.\" 30.Dd $Mdocdate: May 31 2007 $ 31.Dt CONFSTR 3 32.Os 33.Sh NAME 34.Nm confstr 35.Nd get string-valued configurable variables 36.Sh SYNOPSIS 37.Fd #include <unistd.h> 38.Ft size_t 39.Fn confstr "int name" "char *buf" "size_t len" 40.Sh DESCRIPTION 41.Bf -symbolic 42This interface is obsoleted by 43.Xr sysctl 3 . 44.Ef 45.Pp 46The 47.Fn confstr 48function provides a method for applications to get configuration 49defined string values. 50.Pp 51The 52.Fa name 53argument specifies the system variable to be queried. 54Symbolic constants for each name value are found in the include file 55.Aq Pa unistd.h . 56The 57.Fa len 58argument specifies the size of the buffer referenced by the 59argument 60.Fa buf . 61If 62.Fa len 63is non-zero, 64.Fa buf 65is a non-null pointer, and 66.Fa name 67has a value; up to 68.Fa len 69\- 1 bytes of the value are copied into the buffer 70.Fa buf . 71The copied value is always NUL terminated. 72.Pp 73The available values are as follows: 74.Bl -tag -width "123456" 75.It Li _CS_PATH 76Return a value for the 77.Ev PATH 78environment variable that finds all the standard utilities. 79.El 80.Sh RETURN VALUES 81If the call to 82.Nm 83is not successful, 0 is returned and 84.Va errno 85is set appropriately. 86Otherwise, if the variable does not have a configuration defined value, 870 is returned and 88.Va errno 89is not modified. 90Otherwise, the buffer size needed to hold the entire configuration-defined 91value is returned. 92If this size is greater than the argument 93.Fa len , 94the string in 95.Fa buf 96was truncated. 97.Sh ERRORS 98The 99.Nm 100function may fail and set 101.Va errno 102for any of the errors specified for the library functions 103.Xr malloc 3 104and 105.Xr sysctl 3 . 106.Pp 107In addition, the following errors may be reported: 108.Bl -tag -width Er 109.It Bq Er EINVAL 110The value of the 111.Fa name 112argument is invalid. 113.El 114.Sh SEE ALSO 115.Xr sysctl 3 116.Sh STANDARDS 117The 118.Nm 119function conforms to 120.St -p1003.2-92 . 121.Sh HISTORY 122The 123.Nm 124function first appeared in 125.Bx 4.4 . 126