38## @defgroup env Environment
39## @brief Access configuration parameters and query environment properties.
41## More detailed information on these functions can be found in the
42## [*C/C++ API documentation*](../home2l-api_c/group__env.html).
66#define HOME2L_USER "home2l"
156%feature(
"docstring")
EnvGetHome2lRootPath "Return an absolute path name in the root domain.\n\n" \
157 "Path starting with '/' are considered already absolute and are\n" \
158 "returned unchanged, but normalized.\n"
159%feature("docstring")
EnvGetHome2lEtcPath "Return an absolute path name in the 'etc' domain.\n\n" \
160 "Path starting with '/' are considered already absolute and are\n" \
161 "returned unchanged, but normalized.\n"
162%feature("docstring")
EnvGetHome2lVarPath "Return an absolute path name in the 'var' domain.\n\n" \
163 "Path starting with '/' are considered already absolute and are\n" \
164 "returned unchanged, but normalized.\n"
165%feature("docstring")
EnvGetHome2lTmpPath "Return an absolute path name in the 'tmp' domain.\n\n" \
166 "Path starting with '/' are considered already absolute and are\n" \
167 "returned unchanged, but normalized.\n"
197bool EnvNetResolve (
const char *hostAndPort,
CString *retHost,
int *retPort = NULL,
int defaultPort = 0,
bool warn =
true);
243void EnvInit (
int argc,
char **argv,
const char *specOptionsUsage = NULL,
const char *instanceName = NULL,
bool noBanner =
false);
297%feature(
"docstring")
EnvGet "Get a Home2L configuration variable from the environment."
305const char *
EnvPut (
const char *key,
const char *value);
310const char *
EnvPut (
const char *key,
int value);
313static inline void EnvDel (
const char *key) {
EnvPut (key, (
const char *) NULL); }
338bool EnvGetString (
const char *key,
const char **ret,
bool warnIfMissing =
false);
340const char *
EnvGetString (
const char *key,
const char *defaultVal,
bool warnIfMissing =
false);
342static inline const char *
EnvGetString (
const char *key,
bool warnIfMissing) {
return EnvGetString (key, (
const char *) NULL, warnIfMissing); }
347bool EnvGetPath (
const char *key,
const char **ret,
const char *path = NULL,
bool warnIfMissing =
false);
350const char *
EnvGetPath (
const char *key,
const char *path = NULL,
bool warnIfMissing =
false);
358bool EnvGetInt (
const char *key,
int *ret,
bool warnIfMissing =
false);
359int EnvGetInt (
const char *key,
int defaultVal = 0,
bool warnIfMissing =
false);
361bool EnvGetFloat (
const char *key,
float *ret,
bool warnIfMissing =
false);
362float EnvGetFloat (
const char *key,
float defaultVal = 0.0,
bool warnIfMissing =
false);
364bool EnvGetBool (
const char *key,
bool *ret,
bool warnIfMissing =
false);
365bool EnvGetBool (
const char *key,
bool defaultVal =
false,
bool warnIfMissing =
false);
378void EnvGetPrefixInterval (
const char *prefix,
int *retIdx0,
int *retIdx1);
379const char *EnvGetKey (
int idx);
380const char *EnvGetVal (
int idx);
441 CEnvPara (
const char *_key, EEnvParaType _type,
void *_pVar);
443 static void GetAll (
bool withVarKeys =
true);
451 static CEnvPara *first;
457#define ENV_PARA_STRING(key,varName,varDefault) const char *varName = varDefault; CEnvPara varName##PreInit (key, eptString, &varName); const char *varName##Key = key;
458#define ENV_PARA_PATH(key,varName,varDefault) const char *varName = varDefault; CEnvPara varName##PreInit (key, eptPath, &varName); const char *varName##Key = key;
460#define ENV_PARA_INT(key,varName,varDefault) int varName = varDefault; CEnvPara varName##PreInit (key, eptInt, &varName); const char *varName##Key = key;
461#define ENV_PARA_FLOAT(key,varName,varDefault) float varName = varDefault; CEnvPara varName##PreInit (key, eptFloat, &varName); const char *varName##Key = key;
462#define ENV_PARA_BOOL(key,varName,varDefault) bool varName = varDefault; CEnvPara varName##PreInit (key, eptBool, &varName); const char *varName##Key = key;
468#define ENV_PARA_VAR(key,varType,varName,varDefault) varType varName = varDefault; const char *varName##Key = key;
474#define ENV_PARA_NOVAR(key,varType,varName,varDefault) const char *varName##Key = key;
481#define ENV_PARA_SPECIAL(keyPattern, varType, varDefault)
Raw dictionary (base class for other dictionary variants).
Dynamically allocated string.
char * Disown()
Return current string as a dynamic object and clear 'this'.
bool EnvGetString(const char *key, const char **ret, bool warnIfMissing=false)
Read a string (advanced variant).
const CDictRaw * EnvGetKeySet()
Get the complete key set for direct key listing.
bool EnvGetHostAndPort(const char *key, CString *retHost, int *retPort=NULL, int defaultPort=0, bool warnIfMissing=false)
Get a host + port combination; host names are translated using the 'net.resolve.<name>' settings.
const char * EnvPut(const char *key, const char *value)
Generically put a string into the dictionary; Passing 'value == NULL' removes the entry.
bool EnvGetFloat(const char *key, float *ret, bool warnIfMissing=false)
Read a float value (advanced).
const char * EnvGet(const char *key)
Generically read a setting; Returns 'NULL' on non-existence and never prints warnings.
bool EnvGetInt(const char *key, int *ret, bool warnIfMissing=false)
Read an integer (advanced).
static void EnvDel(const char *key)
Remove an entry from the environment dictionary.
bool EnvGetPath(const char *key, const char **ret, const char *path=NULL, bool warnIfMissing=false)
Read a path, eventually convert value to an absolute path before (advanced). The returned path is alw...
bool EnvGetBool(const char *key, bool *ret, bool warnIfMissing=false)
Read a boolean value (advanced).
static bool EnvGetHost(const char *key, CString *retHost, bool warnIfMissing=false)
Get a host name; host names are translated using the 'net.resolve.<name>' settings.
void EnvPrintBanner()
Print the tool banner (only useful if banner was suppressed in the EnvInit() call).
void EnvFlush()
Write back any persistent variables now.
void EnvDone()
Shutdown the environment module.
void EnvInit(int argc, char **argv, const char *specOptionsUsage=NULL, const char *instanceName=NULL, bool noBanner=false)
Initialize the environment module.
void EnvEnablePersistence(bool writeThrough=true, const char *_varFileName=NULL)
Enable the persistence of all environment variables starting with "var.*".
const char * EnvGetHome2lEtcPath(CString *ret, const char *relOrAbsPath)
Return an absolute path name in the 'etc' domain.
const char * EnvExecName()
File name of the executable without path.
const char * EnvHome2lTmp()
'tmp' root path: dynamic data (not need to save over reboots).
bool EnvHaveTerminal()
'true', if the application has been started from an interactive terminal.
const char * EnvBuildArch()
Operating architecture (e.g. "i386", "armhf", ...).
void EnvReadIniFile(const char *fileName, CDictCompact< CString > *map)
Read a .ini file. 'fileName' must be an absolute path name.
const char * EnvGetHome2lRootPath(CString *ret, const char *relOrAbsPath)
Return an absolute path name in the root domain. A path starting with '/' is considered already absol...
const char * EnvHome2lVar()
'var' root path: dynamic data (saved over reboots).
const char * EnvDroidId()
Droid ID.
bool EnvMkVarDir(const char *relOrAbsPath)
Prepare (create) a directory in the 'var' domain.
const char * EnvInstanceName()
Instance name - the identifier for the running process.
const char * EnvBuildOS()
Operating software ("Debian", "Android", ...).
const char * EnvExecPathName()
Full path name of the executable (== argv[0]).
const char * EnvGetHome2lVarPath(CString *ret, const char *relOrAbsPath)
Return an absolute path name in the 'var' domain.
float EnvLocationLatitudeN()
Get the WGS84 latitude north coordinate of the home (the 'location.latitudeN' setting).
bool EnvNetResolve(const char *hostAndPort, CString *retHost, int *retPort=NULL, int defaultPort=0, bool warn=true)
Get a resolved host + port combination.
const char * EnvHome2lEtc()
'etc' root path: configuration data.
bool EnvMkTmpDir(const char *relOrAbsPath)
Prepare (create) a directory in the 'tmp' domain.
float EnvLocationLongitudeE()
Get the WGS84 longitude east coordinate of the home (the 'location.longitudeE' setting).
const char * EnvHome2lRoot()
Root installation path: all static data (blob + etc).
int EnvPid()
Operating system's process identifier (PID).
const char * EnvGetHome2lTmpPath(CString *ret, const char *relOrAbsPath)
Return an absolute path name in the 'tmp' domain.
const char * EnvMachineName()
Machine name (network host name).