Unistd.h functions

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

Macros

#define getcwd(b, s)   evil_getcwd((b),(s))
 Wrapper around evil_getcwd().
 
#define pipe(fds)   evil_pipe(fds)
 Wrapper around evil_pipe().
 

Functions

double evil_time_get (void)
 Return the time spent since the Evil library has been initialized. More...
 
int symlink (const char *oldpath, const char *newpath)
 Create a shell link. More...
 
ssize_t readlink (const char *path, char *buf, size_t bufsiz)
 Read value of a shell link. More...
 
char * evil_getcwd (char *buffer, size_t size)
 Get the current directory. More...
 
int evil_sockets_init (void)
 Initiates the use of Windows sockets. More...
 
void evil_sockets_shutdown (void)
 Shutdown the Windows socket system. More...
 
int evil_pipe (int *fds)
 Create a pair of sockets. More...
 

Detailed Description

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

Function Documentation

double evil_time_get ( void  )

Return the time spent since the Evil library has been initialized.

Returns
The time spent since the Evil library has been initialized.

This function returns the time spent since the Evil library has been initialized. It uses a high-resolution timer and then can have a precision up to the nano-second. The precision is processor dependant. This function can be used to benchmark parts of code in with high precision.

Conformity: Not appliclable.

Supported OS: Windows XP, Windows CE.

Referenced by ecore_time_get().

int symlink ( const char *  oldpath,
const char *  newpath 
)

Create a shell link.

Parameters
oldpathThe file name to be linked.
newpathThe file name to create.
Returns
0 on success, -1 otherwise.

Create a shell link newpath to oldpath (newpath is the name of the file created, oldpath is the string used in creating the shell link).

On success, this function returns 0. Otherwise, it returns -1 and errno may be set to the following value:

  • ENOMEM: Not enough memory.

On Windows, the symbolic links do not exist. Nevertheless shell links can be created. This function is named like the Unix function for portability reasons.

Conformity: None.

Supported OS: Windows XP, Windows CE.

References evil_char_to_wchar().

ssize_t readlink ( const char *  path,
char *  buf,
size_t  bufsiz 
)

Read value of a shell link.

Parameters
pathThe file name to be linked.
bufThe file name to create.
bufsizThe size of the buffer.
Returns
0 on success, -1 otherwise.

Place the content of the shell link path in the buffer buf, which has size bufzsiz.

On success, this function returns 0. Otherwise, it returns -1 and errno may be set to the following value:

  • ENOMEM: Not enough memory.

On Windows, the symbolic links do not exist. Nevertheless shell links can be managed. This function is named like the Unix function for portability reasons.

Conformity: None.

Supported OS: Windows XP, Windows CE.

References evil_char_to_wchar(), and evil_wchar_to_char().

char* evil_getcwd ( char *  buffer,
size_t  size 
)

Get the current directory.

Parameters
bufferBuffer to store the current directory.
sizeSize of the buffer.
Returns
The current directory.

On Windows desktop, use the _getcwd function in MSVCRT.

On Windows CE, get the current directory by extracting the path from the executable that is running and put the result in buffer of length size. If size is less or equal than 0, return NULL. If the current absolute path would require a buffer longer than size elements, NULL is returned. If buffer is NULL, a buffer of length size is allocated and is returned. If the allocation fails, NULL is returned. On success, buffer is returned and contains the current directory. The last '\' is not included. If buffer is NULL, the returned value must be freed if not NULL.

Specially usefull on WinCE where the current directory functionality is not supported.

Conformity: Almost POSIX.1 (no errno set)

Supported OS: Windows XP, Windows CE.

References evil_wchar_to_char().

int evil_sockets_init ( void  )

Initiates the use of Windows sockets.

Returns
1 on success, 0 otherwise.

Initiates the use of Windows sockets. If the function succeeds, it returns 1, otherwise it returns 0.

Conformity: Non applicable.

Supported OS: Windows XP, Windows CE.

Referenced by evil_init().

void evil_sockets_shutdown ( void  )

Shutdown the Windows socket system.

Shutdown the Windows socket system.

Conformity: Non applicable.

Supported OS: Windows XP, Windows CE.

Referenced by evil_shutdown().

int evil_pipe ( int *  fds)

Create a pair of sockets.

Parameters
fdsA pointer that contains two sockets.

Create a pair of sockets that can be use with select(). Hence, evil_sockets_init() must have been caled at least once before. Contrary to Unix, that functions does not create a pair of file descriptors.

Conformity: Not applicable.

Supported OS: Windows XP, Windows CE.