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#ifndef _ENVU_EXTERN
11#ifdef _WIN32
12#define _ENVU_EXTERN __declspec(dllexport) extern
13#else
14#define _ENVU_EXTERN __attribute__((visibility("default"))) extern
15#endif
16#endif
17
18#define _ENVU_ENUM(s) typedef unsigned int s; enum
19
20// Version info
21#define ENVU_VERSION "0.3.0"
22#define ENVU_VERSION_INT 300
23
30_ENVU_EXTERN const char* envuGetVersion(void);
31
40
46_ENVU_EXTERN void envuFree(void *p);
47
56
63_ENVU_EXTERN int envuFileExists(const char *path);
64
71_ENVU_EXTERN int envuPathExists(const char *path);
72
82_ENVU_EXTERN char *envuGetFullPath(const char *path);
83
95_ENVU_EXTERN char *envuGetRealPath(const char *path);
96
105_ENVU_EXTERN char *envuGetDirectory(const char *path);
106
115
124
131_ENVU_EXTERN int envuSetCwd(const char *path);
132
141_ENVU_EXTERN char *envuGetEnv(const char *name);
142
152_ENVU_EXTERN int envuSetEnv(const char *name, const char *value);
153
162
171
183
194
210
219_ENVU_EXTERN char **envuGetEnvPaths(int *path_count);
220
231_ENVU_EXTERN char **envuParseEnvPaths(const char *env_path, int *path_count);
232
239
240#ifdef __cplusplus
241}
242#endif
243
244#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:14
_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.