53 lines
1.1 KiB
Groff
53 lines
1.1 KiB
Groff
.TH GETPATHS 3
|
|
|
|
.SH NAME
|
|
getpaths \- get an array of the current executable PATHs
|
|
|
|
.SH LIBRARY
|
|
libshell
|
|
|
|
.SH SYNOPSIS
|
|
.In stdlib.h
|
|
.In string.h
|
|
.In libshell.h
|
|
.Ft char **
|
|
.Fn getpaths void
|
|
|
|
.SH DESCRIPTION
|
|
.Fn getpaths
|
|
returns the system PATHs as an array of null-terminated strings ordered from highest to lowest priority.
|
|
The last address in the array is NULL.
|
|
The first address in the array, and the array address itself, should be passed to
|
|
.Xr free 3
|
|
to release the allocated storage when the returned array is no longer needed.
|
|
|
|
.SH EXAMPLES
|
|
To print the current PATHs, from highest to lowest priority:
|
|
.Bd -literal -offset indent
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <libshell.h>
|
|
int main(){
|
|
char **paths;
|
|
int i;
|
|
paths = getpaths();
|
|
if(paths == NULL)
|
|
exit(EXIT_FAILURE);
|
|
for(i = 0; paths[i] != NULL; ++i)
|
|
printf("%s\n", paths[i]);
|
|
free(*paths);
|
|
free(paths);
|
|
return EXIT_SUCCESS;
|
|
}
|
|
.Ed
|
|
|
|
.SH SEE ALSO
|
|
.Xr getenv 3
|
|
|
|
.SH STANDARDS
|
|
.Fn getpaths
|
|
is not part of any current standard.
|
|
|
|
.SH BUGS
|
|
Certainly existent but not yet known.
|