1CONFSTR(3)                 Linux Programmer's Manual                CONFSTR(3)
2
3
4

NAME

6       confstr - get configuration dependent string variables
7

SYNOPSIS

9       #define _POSIX_C_SOURCE 2
10       or
11       #define _XOPEN_SOURCE
12       #include <unistd.h>
13
14       size_t confstr(int name, char *buf, size_t len);
15

DESCRIPTION

17       confstr() gets the value of configuration-dependent string variables.
18
19       The  name argument is the system variable to be queried.  The following
20       variables are supported:
21
22       _CS_GNU_LIBC_VERSION (GNU C library only; since glibc 2.3.2)
23              A string which identifies the GNU C library version on this sys‐
24              tem (e.g, "glibc 2.3.4").
25
26       _CS_GNU_LIBPTHREAD_VERSION (GNU C library only; since glibc 2.3.2)
27              A  string  which identifies the POSIX implementation supplied by
28              this C library (e.g, "NPTL 2.3.4" or "linuxthreads-0.10").
29
30       _CS_PATH
31              A value for the PATH variable  which  indicates  where  all  the
32              POSIX.2 standard utilities can be found.
33
34       If  buf  is not NULL and len is not zero, confstr() copies the value of
35       the string to buf truncated to len - 1 characters if necessary, with  a
36       null  byte ('\0') as terminator.  This can be detected by comparing the
37       return value of confstr() against len.
38
39       If len is zero and buf is NULL, confstr() just  returns  the  value  as
40       defined below.
41

RETURN VALUE

43       If name is a valid configuration variable, confstr() returns the number
44       of bytes (including the terminating null byte) that would  be  required
45       to  hold  the entire value of that variable.  This value may be greater
46       than len, which means that the value in buf is truncated.
47
48       If name is a valid configuration variable, but that variable  does  not
49       have a value, then confstr() returns 0.  If name does not correspond to
50       a valid configuration variable, confstr() returns 0, and errno  is  set
51       to EINVAL.
52

ERRORS

54       EINVAL If the value of name is invalid.
55

EXAMPLE

57       The  following  code  fragment  determines  the  path where to find the
58       POSIX.2 system utilities:
59
60          char *pathbuf; size_t n;
61
62          n = confstr(_CS_PATH,NULL,(size_t)0);
63          if ((pathbuf = malloc(n)) == NULL) abort();
64          confstr(_CS_PATH, pathbuf, n);
65

CONFORMING TO

67       POSIX.1-2001
68

SEE ALSO

70       sh(1), exec(3), system(3), feature_test_macros(7)
71
72
73
74GNU                               1993-04-17                        CONFSTR(3)
Impressum