Functions
Stdlib.h functions.

This header provides functions ported from Unix in stdlib.h. More...

Functions

int setenv (const char *name, const char *value, int overwrite)
 Create, modify, or remove environment variables. More...
 
int unsetenv (const char *name)
 Remove environment variables. More...
 
int mkstemp (char *__template)
 Create a unique temporary file name. More...
 
char * mkdtemp (char *__template)
 create an unique temporary directory More...
 
int mkstemps (char *__template, int suffixlen)
 Create a unique temporary file name with a suffix. More...
 
char * realpath (const char *file_name, char *resolved_name)
 Return an absolute or full path name for a specified relative path name. More...
 

Detailed Description

This header provides functions ported from Unix in stdlib.h.

Function Documentation

◆ setenv()

int setenv ( const char *  name,
const char *  value,
int  overwrite 
)

Create, modify, or remove environment variables.

Parameters
nameThe name of the environment variable.
valueThe value of the environment variable to set.
overwrite0 to let the environment variable unchanged, 1 otherwise.
Returns
0 on success, -1 otherwise.

Add the new environment variable name or modify its value if it exists, and set it to value. Environment variables define the environment in which a process executes. If value is NULL, the variable is removed (unset) and that call is equivalent to unsetenv().If the environment variable named by name already exists and the value of 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.

Referenced by ecore_wl2_display_create(), and unsetenv().

◆ unsetenv()

int unsetenv ( const char *  name)

Remove environment variables.

Parameters
nameThe name of the environment variable.
Returns
0 on success, -1 otherwise.

Remove the new environment variable name if it exists. That function is equivalent to setenv() with its second parameter to NULL and the third to 1. If the function succeeds, it returns 0, otherwise it returns -1.

Conformity: Non applicable.

Supported OS: Windows XP.

References setenv().

Referenced by ecore_fork_reset(), and ecore_init().

◆ mkstemp()

int mkstemp ( char *  __template)

Create a unique temporary file name.

Parameters
__templateTemplate of the file to create.
Returns
A file descriptor on success, -1 otherwise.

Take the given file name template and overwrite a portion of it to create a file name. This file is guaranted not to exist at the time invocation and is suitable for use by the function.

The template parameter can be any file name with six X's at the end for example baseXXXXXX, where base is the part of the new file that you supply and each 'X' is a placeholder for a character supplied by mkstemp(). The trailing 'Xs' are replaced with a six-digit value; this value is a unique number. Each successful call to mkstemp() modifies template.

When mkstemp() succeeds, it creates and opens the temporary file for reading and writing.

On success, the function returns the file descriptor of the temporary file. Otherwise, it returns -1 and errno is set to the following values:

  • EINVAL: template has an invalid format.
  • EEXISTS: File name already exists.

Conformity: Should follow BSD conformity.

Supported OS: Windows XP.

References mkstemps().

◆ mkdtemp()

char* mkdtemp ( char *  __template)

create an unique temporary directory

Since
1.8.0

◆ mkstemps()

int mkstemps ( char *  __template,
int  suffixlen 
)

Create a unique temporary file name with a suffix.

Parameters
__templateTemplate of the file to create.
suffixlenLength of the suffix following the 'XXXXXX' placeholder.
Returns
A file descriptor on success, -1 otherwise.
Since
1.10.0

Referenced by mkstemp().

◆ realpath()

char* realpath ( const char *  file_name,
char *  resolved_name 
)

Return an absolute or full path name for a specified relative path name.

Parameters
file_nameThe absolute path name.
resolved_nameThe relative path name.
Returns
NULL on failure, a pointer to the absolute path name otherwise.

The function expands the relative path name file_name to its fully qualified or absolute path and store it in the buffer pointed by resolved_name. The buffer is at most PATH_MAX bytes long. If resolved_name is NULL, malloc() is used to allocate a buffer of sufficient length to hold the path name. In that case, it is the responsability 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:

  • EACCESS: if file_name can not be accessed.
  • EINVAL: if file_name is NULL.
  • ENAMETOOLONG: if the path name is too long.
  • ENOENT: file_name does not exist
  • ENOMEM: if memory allocation fails.

Conformity: None.

Supported OS: Windows XP.