LOCALBASE
Path to the local software base directory
Return the path to the local software base directory
#include <libutil.h>
const char *
getlocalbase(void);
System Utilities Library (libutil, -lutil)
The getlocalbase function returns the path to the local software base directory, normally /usr/local.
First the LOCALBASE environment variable is checked. If that variable is undefined or empty, the user.localbase sysctl is checked. If that returns an empty string or an error occurs, the value of _PATH_LOCALBASE is used as a last resort.
If the value obtained through these means is not a valid absolute path shorter than MAXPATHLEN, a constant string which has been deliberately chosen to cause any file system operation using it to fail is returned instead.
The contents of the string returned by getlocalbase shall not be modified by the caller.
The LOCALBASE environment variable will only be used if the process calling getlocalbase is not setugid.
Successive calls to getlocalbase will return the same value throughout the lifetime of the process, regardless of any subsequent changes to the environment or sysctl variables.
The getlocalbase function is thread-safe if and only if it has been called at least once already.
The getlocalbase() function returns a pointer to a null-terminated string.
LOCALBASE
Path to the local software base directory
15 releases since FreeBSD 13.0-RELEASE; the text changed 3 times.