wasapi: Patched to compile on C89 systems, and use SDL_ceilf instead of ceilf.
1 /* See COPYING.txt for the full license governing this code. */
5 * Header file with some helper functions for working with SDL_RWops.
10 #ifndef SDL_visualtest_rwhelper_h_
11 #define SDL_visualtest_rwhelper_h_
13 /** Length of the buffer in SDLVisualTest_RWHelperBuffer */
14 #define RWOPS_BUFFER_LEN 256
16 /* Set up for C function definitions, even when using C++ */
22 * Struct that is used as a buffer by the RW helper functions. Should be initialized by calling
23 * SDLVisualTest_RWHelperResetBuffer() before being used.
25 typedef struct SDLVisualTest_RWHelperBuffer
27 /*! Character buffer that data is read into */
28 char buffer[RWOPS_BUFFER_LEN];
29 /*! buffer[buffer_pos] is the next character to be read from the buffer */
31 /*! Number of character read into the buffer */
33 } SDLVisualTest_RWHelperBuffer;
36 * Resets the buffer pointed to by \c buffer used by some of the helper functions.
37 * This function should be called when you're using one of the helper functions
38 * with a new SDL_RWops object.
40 void SDLVisualTest_RWHelperResetBuffer(SDLVisualTest_RWHelperBuffer* buffer);
43 * Reads a single character using the SDL_RWops object pointed to by \c rw.
44 * This function reads data in blocks and stores them in the buffer pointed to by
45 * \c buffer, so other SDL_RWops functions should not be used in conjunction
48 * \return The character that was read.
50 char SDLVisualTest_RWHelperReadChar(SDL_RWops* rw,
51 SDLVisualTest_RWHelperBuffer* buffer);
54 * Reads characters using the SDL_RWops object pointed to by \c rw into the
55 * character array pointed to by \c str (of size \c size) until either the
56 * array is full or a new line is encountered. If \c comment_char is encountered,
57 * all characters from that position till the end of the line are ignored. The new line
58 * is not included as part of the buffer. Lines with only whitespace and comments
59 * are ignored. This function reads data in blocks and stores them in the buffer
60 * pointed to by \c buffer, so other SDL_RWops functions should not be used in
61 * conjunction with this function.
63 * \return pointer to the string on success, NULL on failure or EOF.
65 char* SDLVisualTest_RWHelperReadLine(SDL_RWops* rw, char* str, int size,
66 SDLVisualTest_RWHelperBuffer* buffer,
70 * Counts the number of lines that are not all whitespace and comments using the
71 * SDL_RWops object pointed to by \c rw. \c comment_char indicates the character
72 * used for comments. Uses the buffer pointed to by \c buffer to read data in blocks.
74 * \return Number of lines on success, -1 on failure.
76 int SDLVisualTest_RWHelperCountNonEmptyLines(SDL_RWops* rw,
77 SDLVisualTest_RWHelperBuffer* buffer,
80 /* Ends C function definitions when using C++ */
85 #endif /* SDL_visualtest_rwhelper_h_ */
87 /* vi: set ts=4 sw=4 expandtab: */