2008-10-11 07:35:26 -07:00
|
|
|
#ifndef __EVIL_STDIO_H__
|
|
|
|
#define __EVIL_STDIO_H__
|
|
|
|
|
|
|
|
|
2009-10-14 11:48:13 -07:00
|
|
|
/**
|
|
|
|
* @file evil_stdio.h
|
|
|
|
* @brief The file that provides functions ported from Unix in stdio.h.
|
|
|
|
* @defgroup Evil_Stdio_Group Stdio.h functions
|
|
|
|
*
|
|
|
|
* This header provides functions ported from Unix in stdio.h.
|
|
|
|
*
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2010-02-27 23:57:03 -08:00
|
|
|
#ifdef _WIN32_WCE
|
2008-10-11 07:35:26 -07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Error related functions
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2011-11-12 14:31:16 -08:00
|
|
|
/**
|
|
|
|
* @brief Print the given string to stderr.
|
|
|
|
*
|
|
|
|
* @param s The string to print.
|
|
|
|
*
|
|
|
|
* This function just printf the string @p s to stderr.
|
|
|
|
*
|
|
|
|
* Conformity: None.
|
|
|
|
*
|
|
|
|
* Supported OS: Windows CE.
|
|
|
|
*/
|
2011-01-06 11:32:03 -08:00
|
|
|
EAPI void evil_perror (const char *s);
|
|
|
|
|
2011-11-12 14:31:16 -08:00
|
|
|
/**
|
|
|
|
* @def perror(s)
|
|
|
|
*
|
|
|
|
* Wrapper around evil_perror().
|
|
|
|
*/
|
2011-01-06 11:32:03 -08:00
|
|
|
# define perror(s) evil_perror(s)
|
2008-10-11 07:35:26 -07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Stream related functions
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2011-11-12 14:31:16 -08:00
|
|
|
/**
|
|
|
|
* @brief Emulate the fopen() function on Windows CE.
|
|
|
|
*
|
|
|
|
* @param path The file to open.
|
|
|
|
* @param mode The mode.
|
|
|
|
* @return A FILE pointer on success, @c NULL otherwise.
|
|
|
|
*
|
|
|
|
* This function emulates the fopen() function on Windows CE using the
|
|
|
|
* Windows libc. The main problem is that the filesytem on Windows CE
|
|
|
|
* is like on Sys V : the top level directory is beginning by '/' or
|
|
|
|
* '\' and the full path must be calculated.. This function takes care
|
|
|
|
* of this feature, and replace all the '/' by '/'. Otherwise, it
|
|
|
|
* calls the Windows CE fopen() function once the filename has been
|
|
|
|
* correctly set. If @p path is @c NULL or empty, this function
|
|
|
|
* returns @c NULL. On success, this function returns a FILE stream,
|
|
|
|
* @c NULL otherwise.
|
|
|
|
*
|
|
|
|
* Conformity: None.
|
|
|
|
*
|
|
|
|
* Supported OS: Windows CE.
|
|
|
|
*/
|
2008-10-24 00:32:08 -07:00
|
|
|
EAPI FILE *evil_fopen(const char *path, const char *mode);
|
|
|
|
|
2011-11-12 14:31:16 -08:00
|
|
|
/**
|
|
|
|
* @def fopen(path, mode)
|
|
|
|
*
|
|
|
|
* Wrapper around evil_fopen().
|
|
|
|
*/
|
2008-11-03 23:53:43 -08:00
|
|
|
# define fopen(path, mode) evil_fopen(path, mode)
|
|
|
|
|
2011-11-12 14:31:16 -08:00
|
|
|
/**
|
|
|
|
* @brief Emulate the rewind() function on Windows CE.
|
|
|
|
*
|
|
|
|
* @param stream The FILE stream.
|
|
|
|
*
|
|
|
|
* This function emulates the rewind() function on Windows CE by just
|
|
|
|
* calling fseek().
|
|
|
|
*
|
|
|
|
* Conformity: None.
|
|
|
|
*
|
|
|
|
* Supported OS: Windows CE.
|
|
|
|
*/
|
2008-11-05 09:27:20 -08:00
|
|
|
EAPI void evil_rewind(FILE *stream);
|
|
|
|
|
2011-11-12 14:31:16 -08:00
|
|
|
/**
|
|
|
|
* @def rewind(f)
|
|
|
|
*
|
|
|
|
* Wrapper around evil_rewind().
|
|
|
|
*/
|
2008-12-27 10:53:56 -08:00
|
|
|
# define rewind(f) evil_rewind(f)
|
2008-10-11 07:35:26 -07:00
|
|
|
|
2011-11-12 14:31:16 -08:00
|
|
|
/**
|
|
|
|
* @brief Emulate the remove() function on Windows CE.
|
|
|
|
*
|
|
|
|
* @param path The path to remove.
|
|
|
|
* @return 0 on success, -1 otherwise.
|
|
|
|
*
|
|
|
|
* This function emulates the remove() function on Windows CE. If
|
|
|
|
* @p path is an empty directory, it removes it. If @p path is a file,
|
|
|
|
* it deletes it. On success, 0 is returns, -1 otherwise.
|
|
|
|
*
|
|
|
|
* Conformity: None.
|
|
|
|
*
|
|
|
|
* Supported OS: Windows CE.
|
|
|
|
*/
|
2009-12-19 11:08:28 -08:00
|
|
|
EAPI int evil_remove(const char *path);
|
|
|
|
|
2011-11-12 14:31:16 -08:00
|
|
|
/**
|
|
|
|
* @def remove(p)
|
|
|
|
*
|
|
|
|
* Wrapper around evil_remove().
|
|
|
|
*/
|
2009-12-19 11:08:28 -08:00
|
|
|
# define remove(p) evil_remove(p)
|
|
|
|
|
2010-02-27 23:57:03 -08:00
|
|
|
#endif /* _WIN32_WCE */
|
2008-10-11 07:35:26 -07:00
|
|
|
|
|
|
|
|
2008-11-09 11:27:13 -08:00
|
|
|
#ifdef _WIN32_WCE
|
|
|
|
|
2011-11-12 14:31:16 -08:00
|
|
|
/**
|
|
|
|
* @brief Emulate the fopen() function on Windows CE using Windows API.
|
|
|
|
*
|
|
|
|
* @param path The file to open.
|
|
|
|
* @param mode The mode.
|
|
|
|
* @return A FILE pointer on success, @c NULL otherwise.
|
|
|
|
*
|
|
|
|
* This function emulates the fopen() function on Windows CE using the
|
|
|
|
* Windows API and not the libc. It is similar to evil_fopen().
|
|
|
|
*
|
|
|
|
* @see evil_fopen()
|
|
|
|
* @see evil_fread_native()
|
|
|
|
* @see evil_fclose_native()
|
|
|
|
*
|
|
|
|
* Conformity: None.
|
|
|
|
*
|
|
|
|
* Supported OS: Windows CE.
|
|
|
|
*/
|
2008-11-09 11:27:13 -08:00
|
|
|
EAPI FILE *evil_fopen_native(const char *path, const char *mode);
|
|
|
|
|
2011-11-12 14:31:16 -08:00
|
|
|
/**
|
|
|
|
* @brief Read the given stream on Windows CE using Windows API.
|
|
|
|
*
|
|
|
|
* @param buffer The buffer to store the data.
|
|
|
|
* @param size The size of each element of data to read.
|
|
|
|
* @param count The number of elements of data to read.
|
|
|
|
* @param stream The stream to read.
|
|
|
|
* @return The size read on success, 0 otherwise.
|
|
|
|
*
|
|
|
|
* This function read @p stream using the Windows API. It reads
|
|
|
|
* @p size elements of data, each @ size bytes long. The data is
|
|
|
|
* stored in the buffer @p buffer. On success, the size read is
|
|
|
|
* returned, 0 otherwise.
|
|
|
|
*
|
|
|
|
* @see evil_fopen_native()
|
|
|
|
* @see evil_fclose_native()
|
|
|
|
*
|
|
|
|
* Conformity: None.
|
|
|
|
*
|
|
|
|
* Supported OS: Windows CE.
|
|
|
|
*/
|
2008-11-09 11:27:13 -08:00
|
|
|
EAPI size_t evil_fread_native(void* buffer, size_t size, size_t count, FILE* stream);
|
|
|
|
|
2011-11-12 14:31:16 -08:00
|
|
|
/**
|
|
|
|
* @brief Close the given stream on Windows CE using Windows API.
|
|
|
|
*
|
|
|
|
* @param stream The stream to close.
|
|
|
|
* @return 0 on success, -1 otherwise.
|
|
|
|
*
|
|
|
|
* This function closes @p stream using the Windows API. On success, 0
|
|
|
|
* is returned, -1 otherwise.
|
|
|
|
*
|
|
|
|
* @see evil_fopen_native()
|
|
|
|
* @see evil_fread_native()
|
|
|
|
*
|
|
|
|
* Conformity: None.
|
|
|
|
*
|
|
|
|
* Supported OS: Windows CE.
|
|
|
|
*/
|
2008-11-09 11:27:13 -08:00
|
|
|
EAPI int evil_fclose_native(FILE *stream);
|
|
|
|
|
|
|
|
#endif /* _WIN32_WCE */
|
|
|
|
|
|
|
|
|
2009-10-14 11:48:13 -07:00
|
|
|
/**
|
|
|
|
* @}
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2008-10-11 07:35:26 -07:00
|
|
|
#endif /* __EVIL_STDIO_H__ */
|