Index of Section 3 Manual Pages
| Interix / SUA | _prefixInstallPath_Win.3 | Interix / SUA |
_prefixInstallPath_Win(3) _prefixInstallPath_Win(3)
_getInstallPath()
NAME
_getInstallPath(), _prefixInstallPath(), _getInstallPath_Win(),
_prefixInstallPath_Win() - find root of Interix install path
SYNOPSIS
#include
char * _getInstallPath(void)
char * _getInstallPath_Win(void)
char * _prefixInstallPath( const char *name, char *buf, int len )
char * _prefixInstallPath_Win( const char *name, char *buf, int len )
DESCRIPTION
These functions retrieve the pathname for the directory where Interix was
installed. If you installed the Interix Commands and Utilities in the
default location (usually /dev/fs/C/SFU/), then the pathname is /dev/fs/C/
SFU/.
The _getInstallPath(3) call returns the pathname itself. It looks in the
registry for the value of the
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Services for UNIX\InstallRoot entry
and stores the value in a static buffer. It returns a pointer to that
buffer. The pathname always ends in /.
Caution
* Incorrectly editing the registry may severely damage your system.
Before making changes to the registry, you should back up any valued
data on the computer.
The _getInstallPath_Win(3) call does the same, but the pathname is
returned in the Windows format. The Windows pathname is retrieved from the
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\
Services for UNIX\InstallRoot_Win registry entry.
The _prefixInstallPath(3) call prefixes the installed-root directory onto
another path (specified by name) and returns a pointer to the concatenated
name. If buf is NULL, then the concatenated name is stored in a static
buffer; if buf is non-NULL, the concatenated name is stored there. If you
specify buf, you must also specify a non-zero value for len, the number of
bytes that buf will hold.
The _prefixInstallPath_Win(3) call performs the transformation as
_prefixInstallPath(3), but the pathname is in the Windows format.
The _getInstallPath(3) and _prefixInstallPath(3) calls are legacies,
predating the single-rooted file system on Interix.
RETURN CODES
The _getInstallPath(3) and _getInstallPath_Win(3) functions return a
pointer to a static buffer, or NULL on failure. They can fail for one of
these reasons:
* Insufficient memory,
* a component of the installed path exceeds {NAME_MAX},
* or if the entire installed path is longer than {PATH_MAX}.
The _prefixInstallPath(3) and _prefixInstallPath_Win(3) functions return a
pointer to the concatenated path. They can return NULL for one of the
following errors:
* _getInstallPath(3) (or _getInstallPath_Win(3)) failed
* len was not specified and buf was not NULL;
* the concatenated pathname was longer than len.
EXAMPLE
Many traditional programs define paths as static strings. For example:
#define PAGER "/bin/more"
...
printf("Using %s as the pager\n", PAGER);
A trivial conversion which ignores the possibility of failure is:
#ifndef __INTERIX
# define PAGER "/bin/more"
#else
# define PAGER _prefixInstallPath("/bin/more",NULL,0)
#endif /* __INTERIX */
...
printf("Using %s as the pager\n", PAGER);
SEE ALSO
confstr(3)
USAGE NOTES
None of these functions are thread safe.
None of these functions are async-signal safe.