diff src/joystick/win32/SDL_mmjoystick.c @ 1330:450721ad5436

It's now possible to build SDL without any C runtime at all on Windows, using Visual C++ 2005
author Sam Lantinga <slouken@libsdl.org>
date Mon, 06 Feb 2006 08:28:51 +0000
parents c9b51268668f
children 3692456e7b0f
line wrap: on
line diff
--- a/src/joystick/win32/SDL_mmjoystick.c	Sat Feb 04 22:01:44 2006 +0000
+++ b/src/joystick/win32/SDL_mmjoystick.c	Mon Feb 06 08:28:51 2006 +0000
@@ -22,15 +22,15 @@
 
 /* Win32 MultiMedia Joystick driver, contributed by Andrei de A. Formiga */
 
-#include <stdlib.h>
-#include <stdio.h>		/* For the definition of NULL */
-
 #include "SDL_error.h"
+#include "SDL_events.h"
 #include "SDL_joystick.h"
+#include "SDL_stdlib.h"
+#include "SDL_string.h"
 #include "SDL_sysjoystick.h"
 #include "SDL_joystick_c.h"
 
-#include <windows.h>
+#include "SDL_windows.h"
 #include <mmsystem.h>
 #include <regstr.h>
 
@@ -82,7 +82,7 @@
 	unsigned char regvalue[256];
 	unsigned char regname[256];
 
-	sprintf((char *) regkey, "%s\\%s\\%s",
+	snprintf((char *) regkey, SDL_arraysize(regkey), "%s\\%s\\%s",
 		REGSTR_PATH_JOYCONFIG,
 		szRegKey,
 		REGSTR_KEY_JOYCURR);
@@ -95,7 +95,7 @@
 			joystick's properties
 		*/
 		regsize = sizeof(regname);
-		sprintf((char *) regvalue,
+		snprintf((char *) regvalue, SDL_arraysize(regvalue),
 			"Joystick%d%s", index+1,
 			REGSTR_VAL_JOYOEMNAME);
 		regresult = RegQueryValueExA(hKey,
@@ -105,7 +105,7 @@
 		if (regresult == ERROR_SUCCESS)
 		{
 			/* open that registry key */
-			sprintf((char *) regkey, "%s\\%s",
+			snprintf((char *) regkey, SDL_arraysize(regkey), "%s\\%s",
 				REGSTR_PATH_JOYOEM, regname);
 			regresult = RegOpenKeyExA(HKEY_LOCAL_MACHINE,
 				(char *) regkey, 0, KEY_READ, &hKey);
@@ -379,7 +379,7 @@
 void SetMMerror(char *function, int code)
 {
 	static char *error;
-	static char  errbuf[BUFSIZ];
+	static char  errbuf[1024];
 
 	errbuf[0] = 0;
 	switch (code) 
@@ -406,13 +406,14 @@
 		break;
 
 		default:
-			sprintf(errbuf, "%s: Unknown Multimedia system error: 0x%x",
+			snprintf(errbuf, SDL_arraysize(errbuf),
+			         "%s: Unknown Multimedia system error: 0x%x",
 								function, code);
 		break;
 	}
 
 	if ( ! errbuf[0] ) {
-		sprintf(errbuf, "%s: %s", function, error);
+		snprintf(errbuf, SDL_arraysize(errbuf), "%s: %s", function, error);
 	}
 	SDL_SetError("%s", errbuf);
 }