1confstr(3) Library Functions Manual confstr(3)
2
3
4
6 confstr - get configuration dependent string variables
7
9 Standard C library (libc, -lc)
10
12 #include <unistd.h>
13
14 size_t confstr(int name, char buf[.size], size_t size);
15
16 Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
17
18 confstr():
19 _POSIX_C_SOURCE >= 2 || _XOPEN_SOURCE
20
22 confstr() gets the value of configuration-dependent string variables.
23
24 The name argument is the system variable to be queried. The following
25 variables are supported:
26
27 _CS_GNU_LIBC_VERSION (GNU C library only; since glibc 2.3.2)
28 A string which identifies the GNU C library version on this sys‐
29 tem (e.g., "glibc 2.3.4").
30
31 _CS_GNU_LIBPTHREAD_VERSION (GNU C library only; since glibc 2.3.2)
32 A string which identifies the POSIX implementation supplied by
33 this C library (e.g., "NPTL 2.3.4" or "linuxthreads-0.10").
34
35 _CS_PATH
36 A value for the PATH variable which indicates where all the
37 POSIX.2 standard utilities can be found.
38
39 If buf is not NULL and size is not zero, confstr() copies the value of
40 the string to buf truncated to size - 1 bytes if necessary, with a null
41 byte ('\0') as terminator. This can be detected by comparing the re‐
42 turn value of confstr() against size.
43
44 If size is zero and buf is NULL, confstr() just returns the value as
45 defined below.
46
48 If name is a valid configuration variable, confstr() returns the number
49 of bytes (including the terminating null byte) that would be required
50 to hold the entire value of that variable. This value may be greater
51 than size, which means that the value in buf is truncated.
52
53 If name is a valid configuration variable, but that variable does not
54 have a value, then confstr() returns 0. If name does not correspond to
55 a valid configuration variable, confstr() returns 0, and errno is set
56 to EINVAL.
57
59 EINVAL The value of name is invalid.
60
62 For an explanation of the terms used in this section, see at‐
63 tributes(7).
64
65 ┌────────────────────────────────────────────┬───────────────┬─────────┐
66 │Interface │ Attribute │ Value │
67 ├────────────────────────────────────────────┼───────────────┼─────────┤
68 │confstr() │ Thread safety │ MT-Safe │
69 └────────────────────────────────────────────┴───────────────┴─────────┘
70
72 POSIX.1-2008.
73
75 POSIX.1-2001.
76
78 The following code fragment determines the path where to find the
79 POSIX.2 system utilities:
80
81 char *pathbuf;
82 size_t n;
83
84 n = confstr(_CS_PATH, NULL, (size_t) 0);
85 pathbuf = malloc(n);
86 if (pathbuf == NULL)
87 abort();
88 confstr(_CS_PATH, pathbuf, n);
89
91 getconf(1), sh(1), exec(3), fpathconf(3), pathconf(3), sysconf(3), sys‐
92 tem(3)
93
94
95
96Linux man-pages 6.04 2023-03-30 confstr(3)