diff options
author | Simon Howard | 2014-04-01 21:49:16 -0400 |
---|---|---|
committer | Simon Howard | 2014-04-01 21:49:16 -0400 |
commit | a9d9335b20a0b708fae1b978f70348aec998356a (patch) | |
tree | 9d775843fddbffaa9babdf54221b0ac98105dc91 /textscreen/txt_main.h | |
parent | 17c14e1fad6dc277a6e58e4f421d5c65e210d1fe (diff) | |
download | chocolate-doom-a9d9335b20a0b708fae1b978f70348aec998356a.tar.gz chocolate-doom-a9d9335b20a0b708fae1b978f70348aec998356a.tar.bz2 chocolate-doom-a9d9335b20a0b708fae1b978f70348aec998356a.zip |
textscreen: Use safe string functions.
Define TXT_{StringCopy,StringConcat,snprintf,vsnprintf} as analogs of
the m_misc.c versions so that the textscreen library does not need a
dependency on the Doom code, and change all textscreen code to use
these instead of unsafe functions. This fixes #372.
Diffstat (limited to 'textscreen/txt_main.h')
-rw-r--r-- | textscreen/txt_main.h | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/textscreen/txt_main.h b/textscreen/txt_main.h index a6dcc954..d882b521 100644 --- a/textscreen/txt_main.h +++ b/textscreen/txt_main.h @@ -109,55 +109,55 @@ typedef enum // Initialize the screen // Returns 1 if successful, 0 if failed. - int TXT_Init(void); // Shut down text mode emulation - void TXT_Shutdown(void); // Get a pointer to the buffer containing the raw screen data. - unsigned char *TXT_GetScreenData(void); // Update an area of the screen - void TXT_UpdateScreenArea(int x, int y, int w, int h); // Update the whole screen - void TXT_UpdateScreen(void); // Read a character from the keyboard - int TXT_GetChar(void); // Read the current state of modifier keys that are held down. - int TXT_GetModifierState(txt_modifier_t mod); // Provides a short description of a key code, placing into the // provided buffer. - -void TXT_GetKeyDescription(int key, char *buf); +void TXT_GetKeyDescription(int key, char *buf, size_t buf_len); // Retrieve the current position of the mouse - void TXT_GetMousePosition(int *x, int *y); // Sleep until an event is received or the screen needs updating // Optional timeout in ms (timeout == 0 : sleep forever) - void TXT_Sleep(int timeout); // Controls whether keys are returned from TXT_GetChar based on keyboard // mapping, or raw key code. - void TXT_EnableKeyMapping(int enable); // Set the window title of the window containing the text mode screen - void TXT_SetWindowTitle(char *title); +// Safe string copy. +void TXT_StringCopy(char *dest, const char *src, size_t dest_len); + +// Safe string concatenate. +void TXT_StringConcat(char *dest, const char *src, size_t dest_len); + +// Safe version of vsnprintf(). +int TXT_vsnprintf(char *buf, size_t buf_len, const char *s, va_list args); + +// Safe version of snprintf(). +int TXT_snprintf(char *buf, size_t buf_len, const char *s, ...); + #endif /* #ifndef TXT_MAIN_H */ |