c-env-utils
C library to get environment information
Loading...
Searching...
No Matches
env_utils.h
Go to the documentation of this file.
1#ifndef __C_ENV_UTILS_INCLUDE_ENV_UTILS_H__
2#define __C_ENV_UTILS_INCLUDE_ENV_UTILS_H__
3#include <stdlib.h>
4#include <stdint.h>
5
6#ifdef __cplusplus
7extern "C" {
8#endif
9
10// Export APIs when shared build
11#ifndef _ENVU_EXTERN
12#ifdef _ENVU_STATIC
13#define _ENVU_EXTERN extern
14#else // _ENVU_STATIC
15#ifdef _WIN32
16#define _ENVU_EXTERN __declspec(dllexport) extern
17#else // _WIN32
18#define _ENVU_EXTERN __attribute__((visibility("default"))) extern
19#endif // _WIN32
20#endif // _ENVU_STATIC
21#endif // _ENVU_EXTERN
22
23#define _ENVU_ENUM(s) typedef unsigned int s; enum
24
25// Version info
26#define ENVU_VERSION "0.3.1"
27#define ENVU_VERSION_INT 301
28
35_ENVU_EXTERN const char* envuGetVersion(void);
36
45
51_ENVU_EXTERN void envuFree(void *p);
52
61
68_ENVU_EXTERN int envuFileExists(const char *path);
69
76_ENVU_EXTERN int envuPathExists(const char *path);
77
87_ENVU_EXTERN char *envuGetFullPath(const char *path);
88
100_ENVU_EXTERN char *envuGetRealPath(const char *path);
101
110_ENVU_EXTERN char *envuGetDirectory(const char *path);
111
120
129
136_ENVU_EXTERN int envuSetCwd(const char *path);
137
146_ENVU_EXTERN char *envuGetEnv(const char *name);
147
157_ENVU_EXTERN int envuSetEnv(const char *name, const char *value);
158
167
176
188
199
215
224_ENVU_EXTERN char **envuGetEnvPaths(int *path_count);
225
236_ENVU_EXTERN char **envuParseEnvPaths(const char *env_path, int *path_count);
237
244
245#ifdef __cplusplus
246}
247#endif
248
249#endif // __C_ENV_UTILS_INCLUDE_ENV_UTILS_H__
_ENVU_EXTERN char * envuGetExecutablePath(void)
Gets the path to the executing binary.
_ENVU_EXTERN char ** envuGetEnvPaths(int *path_count)
Gets the environment paths from the PATH variable.
_ENVU_EXTERN char ** envuParseEnvPaths(const char *env_path, int *path_count)
Parses the PATH variable.
_ENVU_EXTERN int envuSetCwd(const char *path)
Sets the current working directory.
_ENVU_EXTERN char * envuGetRealPath(const char *path)
Gets a real path of the specified path.
_ENVU_EXTERN int envuSetEnv(const char *name, const char *value)
Sets an environment variable.
_ENVU_EXTERN int envuFileExists(const char *path)
Returns if the specified path is a regular file for not.
_ENVU_EXTERN char * envuGetHome(void)
Gets user's home directory.
_ENVU_EXTERN int envuPathExists(const char *path)
Returns if the specified path exists for not.
_ENVU_EXTERN const char * envuGetVersion(void)
Gets the version of c-env-utils.
_ENVU_EXTERN char * envuGetDirectory(const char *path)
Gets a parent directory of the specified path.
_ENVU_EXTERN char * envuGetFullPath(const char *path)
Gets a full path of the specified path.
_ENVU_EXTERN char * envuGetCwd(void)
Gets the current working directory.
_ENVU_EXTERN char * envuGetOSVersion(void)
Gets the version of running OS.
_ENVU_EXTERN void envuFree(void *p)
Frees the memory of a string allocated by c-env-utils.
_ENVU_EXTERN char * envuGetUsername(void)
Gets user name.
_ENVU_EXTERN void envuFreeEnvPaths(char **paths)
Frees the memory of an array allocated by envuGetEnvPaths() or envuParseEnvPaths().
_ENVU_EXTERN char * envuGetOSProductName(void)
Gets the product name and its version of running OS.
_ENVU_EXTERN char * envuGetEnv(const char *name)
Gets a value of an environment variable.
#define _ENVU_EXTERN
Definition: env_utils.h:18
_ENVU_EXTERN int envuGetVersionAsInt(void)
Gets the version of c-env-utils as an integer.
_ENVU_EXTERN char * envuGetExecutableDir(void)
Gets the directory of the executing binary.
_ENVU_EXTERN char * envuGetOS(void)
Gets the name of running OS.