1 #ifndef __EVIL_STDLIB_H__ 2 #define __EVIL_STDLIB_H__ 3 4 5 /** 6 * @file evil_stdlib.h 7 * @brief The file that provides functions ported from Unix in stdlib.h. 8 * @defgroup Evil_Stdlib_Group Stdlib.h functions. 9 * @ingroup Evil 10 * 11 * This header provides functions ported from Unix in stdlib.h. 12 * 13 * @{ 14 */ 15 16 17 /* 18 * Environment variable related functions 19 * 20 */ 21 22 /** 23 * @brief Create, modify, or remove environment variables. 24 * 25 * @param name The name of the environment variable. 26 * @param value The value of the environment variable to set. 27 * @param overwrite 0 to let the environment variable unchanged, 1 otherwise. 28 * @return 0 on success, -1 otherwise. 29 * 30 * Add the new environment variable @p name or modify its value if it 31 * exists, and set it to @p value. Environment variables define the 32 * environment in which a process executes. If @p value is @c NULL, the 33 * variable is removed (unset) and that call is equivalent to 34 * unsetenv().If the environment variable named by @p name already 35 * exists and the value of @p overwrite is 0, the function shall 36 * return success and the environment shall remain unchanged. 37 * If the function succeeds, it returns 0, otherwise it returns -1. 38 * 39 * Conformity: Non applicable. 40 * 41 * Supported OS: Windows XP. 42 */ 43 EAPI int setenv(const char *name, 44 const char *value, 45 int overwrite); 46 47 /** 48 * @brief Remove environment variables. 49 * 50 * @param name The name of the environment variable. 51 * @return 0 on success, -1 otherwise. 52 * 53 * Remove the new environment variable @p name if it exists. That 54 * function is equivalent to setenv() with its second parameter to 55 * @c NULL and the third to 1. If the function succeeds, it returns 0, 56 * otherwise it returns -1. 57 * 58 * Conformity: Non applicable. 59 * 60 * Supported OS: Windows XP. 61 */ 62 EAPI int unsetenv(const char *name); 63 64 65 /* 66 * Files related functions 67 * 68 */ 69 70 /** 71 * @brief create an unique temporary directory 72 * 73 * @since 1.8.0 74 */ 75 EAPI char *mkdtemp(char *__template); 76 77 /** 78 * @brief Create a unique temporary file name with a suffix. 79 * 80 * @param __template Template of the file to create. 81 * @param suffixlen Length of the suffix following the 'XXXXXX' placeholder. 82 * @return A file descriptor on success, -1 otherwise. 83 * 84 * @since 1.10.0 85 */ 86 EAPI int mkstemps(char *__template, int suffixlen); 87 88 /** 89 * @brief Return an absolute or full path name for a specified relative path name. 90 * 91 * @param file_name The absolute path name. 92 * @param resolved_name The relative path name. 93 * @return @c NULL on failure, a pointer to the absolute path name otherwise. 94 * 95 * The function expands the relative path name @p file_name to its 96 * fully qualified or absolute path and store it in the buffer pointed 97 * by @p resolved_name. The buffer is at most @c PATH_MAX bytes long. 98 * If @p resolved_name is @c NULL, malloc() is used to allocate a 99 * buffer of sufficient length to hold the path name. In that case, it 100 * is the responsibility of the caller to free this buffer with free(). 101 * 102 * That function can be used to obtain the absolute path name for 103 * relative paths (relPath) that include "./" or "../" in their names. 104 * 105 * On Windows XP, errno is set in the following cases: 106 * 107 * @li EACCESS: if @p file_name can not be accessed. 108 * @li EINVAL: if @p file_name is @c NULL. 109 * @li ENAMETOOLONG: if the path name is too long. 110 * @li ENOENT: @p file_name does not exist 111 * @li ENOMEM: if memory allocation fails. 112 * 113 * Conformity: None. 114 * 115 * Supported OS: Windows XP. 116 */ 117 EAPI char *realpath(const char *file_name, char *resolved_name); 118 #ifndef HAVE_REALPATH 119 # define HAVE_REALPATH 1 120 #endif 121 122 123 /** 124 * @} 125 */ 126 127 128 #endif /* __EVIL_STDLIB_H__ */ 129 130