summaryrefslogtreecommitdiff
path: root/src/lib/evil/evil_stdlib.h
blob: a5645b7585de8ffeab181caa8ddc4b1bd6c0d34b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
#ifndef __EVIL_STDLIB_H__
#define __EVIL_STDLIB_H__


/**
 * @file evil_stdlib.h
 * @brief The file that provides functions ported from Unix in stdlib.h.
 * @defgroup Evil_Stdlib_Group Stdlib.h functions.
 * @ingroup Evil
 *
 * This header provides functions ported from Unix in stdlib.h.
 *
 * @{
 */


/*
 * Environment variable related functions
 *
 */

/**
 * @brief Create, modify, or remove environment variables.
 *
 * @param name The name of the environment variable.
 * @param value The value of the environment variable to set.
 * @param overwrite 0 to let the environment variable unchanged, 1 otherwise.
 * @return 0 on success, -1 otherwise.
 *
 * Add the new environment variable @p name or modify its value if it
 * exists, and set it to @p value. Environment variables define the
 * environment in which a process executes. If @p value is @c NULL, the
 * variable is removed (unset) and that call is equivalent to
 * unsetenv().If the environment variable named by @p name already
 * exists and the value of @p overwrite is 0, the function shall
 * return success and the environment shall remain unchanged.
 * If the function succeeds, it returns 0, otherwise it returns -1.
 *
 * Conformity: Non applicable.
 *
 * Supported OS: Windows XP.
 */
EAPI int setenv(const char *name,
                const char *value,
                int         overwrite);

/**
 * @brief Remove environment variables.
 *
 * @param name The name of the environment variable.
 * @return 0 on success, -1 otherwise.
 *
 * Remove the new environment variable @p name if it exists. That
 * function is equivalent to setenv() with its second parameter to
 * @c NULL and the third to 1. If the function succeeds, it returns 0,
 * otherwise it returns -1.
 *
 * Conformity: Non applicable.
 *
 * Supported OS: Windows XP.
 */
EAPI int unsetenv(const char *name);


/*
 * Files related functions
 *
 */

/**
 * @brief create an unique temporary directory
 *
 * @since 1.8.0
 */
EAPI char *mkdtemp(char *__template);

/**
 * @brief Create a unique temporary file name with a suffix.
 *
 * @param __template Template of the file to create.
 * @param suffixlen Length of the suffix following the 'XXXXXX' placeholder.
 * @return A file descriptor on success, -1 otherwise.
 *
 * @since 1.10.0
 */
EAPI int mkstemps(char *__template, int suffixlen);

/**
 * @brief Return an absolute or full path name for a specified relative path name.
 *
 * @param file_name The absolute path name.
 * @param resolved_name The relative path name.
 * @return @c NULL on failure, a pointer to the absolute path name otherwise.
 *
 * The function expands the relative path name @p file_name to its
 * fully qualified or absolute path and store it in the buffer pointed
 * by @p resolved_name. The buffer is at most @c PATH_MAX bytes long.
 * If @p resolved_name is @c NULL, malloc() is used to allocate a
 * buffer of sufficient length to hold the path name. In that case, it
 * is the responsibility of the caller to free this buffer with free().
 *
 * That function can be used to obtain the absolute path name for
 * relative paths (relPath) that include "./" or "../" in their names.
 *
 * On Windows XP, errno is set in the following cases:
 *
 * @li EACCESS: if @p file_name can not be accessed.
 * @li EINVAL: if @p file_name is @c NULL.
 * @li ENAMETOOLONG: if the path name is too long.
 * @li ENOENT: @p file_name does not exist
 * @li ENOMEM: if memory allocation fails.
 *
 * Conformity: None.
 *
 * Supported OS: Windows XP.
 */
EAPI char *realpath(const char *file_name, char *resolved_name);
#ifndef HAVE_REALPATH
#define HAVE_REALPATH 1
#endif


/**
 * @}
 */


#endif /* __EVIL_STDLIB_H__ */