#include <unistd.h>
|
|
size_t
confstr (int name, char *buf, size_t len); |
The name argument specifies the system variable to be queried. Symbolic constants for each name value are found in the include file
#include <unistd.h.>The
len
argument specifies the size of the buffer referenced by the
argument
buf.
If
len
is non-zero,
buf
is a non-null pointer, and
name
has a value, up to
len
- 1 bytes of the value are copied into the buffer
buf.
The copied value is always null terminated.
The available values are as follows:
|
|||||
#include<unistd.h>
#include<stdio.h>
#include <stdlib.h>
int main()
{
int n = 0;
char *buf = NULL;
int len = 0;
n = confstr(_CS_PATH, NULL, 0);
printf("{Expected: 31} %d\n", n);
if( n == 0 )
return -1;
buf = (char *)malloc(n);
if ( buf == NULL )
{
printf("malloc failed!!");
return -1;
}
len = confstr(_CS_PATH, buf, n);
printf("PATH in buffer: \n%s", buf);
printf("\nlength: %d", len);
free(buf);
return 0;
}
Output
PATH in buffer:
/usr/bin:/bin:/usr/sbin:/sbin:
length: 31
| [EINVAL] | |
| The value of the name argument is invalid. | |
|
© 2005-2007 Nokia |