static void SetMMerror(char *function, MMRESULT code) { int len; char errbuf[MAXERRORLENGTH]; SDL_snprintf(errbuf, SDL_arraysize(errbuf), "%s: ", function); len = SDL_strlen(errbuf); waveOutGetErrorText(code, errbuf+len, MAXERRORLENGTH-len); SDL_SetError("%s",errbuf); }
void LogOutput( void* userData, int category, SDL_LogPriority priority, const char* message ) { size_t strLen = SDL_strlen( message ); SDL_RWwrite( logFile, message, 1, strLen ); #ifdef WIN32 SDL_RWwrite( logFile, "\r\n", 1, 2 ); #else #warning "NO END OF LINE DEFINED FOR THIS PLATFORM!" #endif }
int SDL_SYS_CDInit(void) { /* checklist: /dev/cdrom,/dev/cd?c /dev/acd?c /dev/matcd?c /dev/mcd?c /dev/scd?c */ static char *checklist[] = { "cdrom", "?0 cd?", "?0 acd?", "?0 matcd?", "?0 mcd?", "?0 scd?",NULL }; char *SDLcdrom; int i, j, exists; char drive[32]; struct stat stbuf; /* Fill in our driver capabilities */ SDL_CDcaps.Name = SDL_SYS_CDName; SDL_CDcaps.Open = SDL_SYS_CDOpen; SDL_CDcaps.GetTOC = SDL_SYS_CDGetTOC; SDL_CDcaps.Status = SDL_SYS_CDStatus; SDL_CDcaps.Play = SDL_SYS_CDPlay; SDL_CDcaps.Pause = SDL_SYS_CDPause; SDL_CDcaps.Resume = SDL_SYS_CDResume; SDL_CDcaps.Stop = SDL_SYS_CDStop; SDL_CDcaps.Eject = SDL_SYS_CDEject; SDL_CDcaps.Close = SDL_SYS_CDClose; /* Look in the environment for our CD-ROM drive list */ SDLcdrom = SDL_getenv("SDL_CDROM"); /* ':' separated list of devices */ if ( SDLcdrom != NULL ) { char *cdpath, *delim; size_t len = SDL_strlen(SDLcdrom)+1; cdpath = SDL_stack_alloc(char, len); if ( cdpath != NULL ) { SDL_strlcpy(cdpath, SDLcdrom, len); SDLcdrom = cdpath; do { delim = SDL_strchr(SDLcdrom, ':'); if ( delim ) { *delim++ = '\0'; } if ( CheckDrive(SDLcdrom, &stbuf) > 0 ) { AddDrive(SDLcdrom, &stbuf); } if ( delim ) { SDLcdrom = delim; } else { SDLcdrom = NULL; } } while ( SDLcdrom ); SDL_stack_free(cdpath); } /* If we found our drives, there's nothing left to do */ if ( SDL_numcds > 0 ) { return(0); } }
bool SDLFileHandler::writeString(std::stringstream text) { std::string sText = text.str(); size_t len = SDL_strlen(sText.c_str()); if (SDL_RWwrite(file, &sText, sizeof(text), len) != len) { std::cout << "[ERROR]: text couldn't be written" << std::endl; return false; } return true; }
char *SDL_strstr(const char *haystack, const char *needle) { size_t length = SDL_strlen(needle); while ( *haystack ) { if ( SDL_strncmp(haystack, needle, length) == 0 ) { return (char *)haystack; } ++haystack; } return NULL; }
int SDL_SYS_CDInit(void) { static char *checklist[] = { "?0 rsr?", NULL }; char *SDLcdrom; int i, j, exists; char drive[32]; struct stat stbuf; SDL_CDcaps.Name = SDL_SYS_CDName; SDL_CDcaps.Open = SDL_SYS_CDOpen; SDL_CDcaps.GetTOC = SDL_SYS_CDGetTOC; SDL_CDcaps.Status = SDL_SYS_CDStatus; SDL_CDcaps.Play = SDL_SYS_CDPlay; SDL_CDcaps.Pause = SDL_SYS_CDPause; SDL_CDcaps.Resume = SDL_SYS_CDResume; SDL_CDcaps.Stop = SDL_SYS_CDStop; SDL_CDcaps.Eject = SDL_SYS_CDEject; SDL_CDcaps.Close = SDL_SYS_CDClose; SDLcdrom = SDL_getenv("SDL_CDROM"); if ( SDLcdrom != NULL ) { char *cdpath, *delim; size_t len = SDL_strlen(SDLcdrom)+1; cdpath = SDL_stack_alloc(char, len); if ( cdpath != NULL ) { SDL_strlcpy(cdpath, SDLcdrom, len); SDLcdrom = cdpath; do { delim = SDL_strchr(SDLcdrom, ':'); if ( delim ) { *delim++ = '\0'; } if ( CheckDrive(SDLcdrom, &stbuf) > 0 ) { AddDrive(SDLcdrom, &stbuf); } if ( delim ) { SDLcdrom = delim; } else { SDLcdrom = NULL; } } while ( SDLcdrom ); SDL_stack_free(cdpath); } if ( SDL_numcds > 0 ) { return(0); } }
size_t SDL_strlcpy(char *dst, const char *src, size_t maxlen) { size_t srclen = SDL_strlen(src); if (maxlen > 0) { size_t len = SDL_min(srclen, maxlen - 1); SDL_memcpy(dst, src, len); dst[len] = '\0'; } return srclen; }
char *SDL_strrchr(const char *string, int c) { const char *bufp = string + SDL_strlen(string) - 1; while ( bufp >= string ) { if ( *bufp == c ) { return (char *)bufp; } --bufp; } return NULL; }
/* * Get the mapping string for this GUID */ char * SDL_GameControllerMappingForGUID(SDL_JoystickGUID guid) { char *pMappingString = NULL; ControllerMapping_t *mapping = SDL_PrivateGetControllerMappingForGUID(&guid); if (mapping) { char pchGUID[33]; size_t needed; SDL_JoystickGetGUIDString(guid, pchGUID, sizeof(pchGUID)); /* allocate enough memory for GUID + ',' + name + ',' + mapping + \0 */ needed = SDL_strlen(pchGUID) + 1 + SDL_strlen(mapping->name) + 1 + SDL_strlen(mapping->mapping) + 1; pMappingString = SDL_malloc(needed); if (!pMappingString) { SDL_OutOfMemory(); return NULL; } SDL_snprintf(pMappingString, needed, "%s,%s,%s", pchGUID, mapping->name, mapping->mapping); } return pMappingString; }
bool SDLFileHandler::writeInt(int integer) { std::string text; text = integer; size_t len = SDL_strlen(text.c_str()); if (SDL_RWwrite(file, &text, sizeof(text), len) != len) { std::cout << "[ERROR]: text couldn't be written" << std::endl; return false; } return true; }
int DIB_CreateWindow(_THIS) { char *windowid; SDL_RegisterApp(NULL, 0, 0); windowid = SDL_getenv("SDL_WINDOWID"); SDL_windowid = (windowid != NULL); if ( SDL_windowid ) { #if defined(_WIN32_WCE) && (_WIN32_WCE < 300) wchar_t *windowid_t = SDL_malloc((SDL_strlen(windowid) + 1) * sizeof(wchar_t)); MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, windowid, -1, windowid_t, SDL_strlen(windowid) + 1); SDL_Window = (HWND)wcstol(windowid_t, NULL, 0); SDL_free(windowid_t); #else SDL_Window = (HWND)((size_t)SDL_strtoull(windowid, NULL, 0)); #endif if ( SDL_Window == NULL ) { SDL_SetError("Couldn't get user specified window"); return(-1); } userWindowProc = (WNDPROCTYPE)GetWindowLongPtr(SDL_Window, GWLP_WNDPROC); SetWindowLongPtr(SDL_Window, GWLP_WNDPROC, (LONG_PTR)WinMessage); } else { SDL_Window = CreateWindow(SDL_Appname, SDL_Appname, (WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX), CW_USEDEFAULT, CW_USEDEFAULT, 0, 0, NULL, NULL, SDL_Instance, NULL); if ( SDL_Window == NULL ) { SDL_SetError("Couldn't create window"); return(-1); } ShowWindow(SDL_Window, SW_HIDE); } WIN_FlushMessageQueue(); return(0); }
int SDL_AddTouch(const SDL_Touch * touch, char *name) { SDL_Touch **touchPads; int index; size_t length; if (SDL_GetTouchIndexId(touch->id) != -1) { SDL_SetError("Touch ID already in use"); } /* Add the touch to the list of touch */ touchPads = (SDL_Touch **) SDL_realloc(SDL_touchPads, (SDL_num_touch + 1) * sizeof(*touch)); if (!touchPads) { SDL_OutOfMemory(); return -1; } SDL_touchPads = touchPads; index = SDL_num_touch++; SDL_touchPads[index] = (SDL_Touch *) SDL_malloc(sizeof(*SDL_touchPads[index])); if (!SDL_touchPads[index]) { SDL_OutOfMemory(); return -1; } SDL_memcpy(SDL_touchPads[index], touch, sizeof(*touch)); /* we're setting the touch properties */ length = 0; length = SDL_strlen(name); SDL_touchPads[index]->focus = 0; SDL_touchPads[index]->name = SDL_malloc((length + 2) * sizeof(char)); SDL_strlcpy(SDL_touchPads[index]->name, name, length + 1); SDL_touchPads[index]->num_fingers = 0; SDL_touchPads[index]->max_fingers = 1; SDL_touchPads[index]->fingers = (SDL_Finger **) SDL_malloc(sizeof(SDL_Finger*)); SDL_touchPads[index]->fingers[0] = NULL; SDL_touchPads[index]->buttonstate = 0; SDL_touchPads[index]->relative_mode = SDL_FALSE; SDL_touchPads[index]->flush_motion = SDL_FALSE; SDL_touchPads[index]->xres = (1<<(16-1)); SDL_touchPads[index]->yres = (1<<(16-1)); SDL_touchPads[index]->pressureres = (1<<(16-1)); //Do I want this here? Probably SDL_GestureAddTouch(SDL_touchPads[index]); return index; }
char *SDL_strrev(char *string) { size_t len = SDL_strlen(string); char *a = &string[0]; char *b = &string[len-1]; len /= 2; while ( len-- ) { char c = *a; *a++ = *b; *b-- = c; } return string; }
void RWopsSetUp(void *arg) { int fileLen; FILE *handle; int writtenLen; int result; /* Clean up from previous runs (if any); ignore errors */ remove(RWopsReadTestFilename); remove(RWopsWriteTestFilename); remove(RWopsAlphabetFilename); /* Create a test file */ handle = fopen(RWopsReadTestFilename, "w"); SDLTest_AssertCheck(handle != NULL, "Verify creation of file '%s' returned non NULL handle", RWopsReadTestFilename); if (handle == NULL) return; /* Write some known text into it */ fileLen = SDL_strlen(RWopsHelloWorldTestString); writtenLen = (int)fwrite(RWopsHelloWorldTestString, 1, fileLen, handle); SDLTest_AssertCheck(fileLen == writtenLen, "Verify number of written bytes, expected %i, got %i", fileLen, writtenLen); result = fclose(handle); SDLTest_AssertCheck(result == 0, "Verify result from fclose, expected 0, got %i", result); /* Create a second test file */ handle = fopen(RWopsAlphabetFilename, "w"); SDLTest_AssertCheck(handle != NULL, "Verify creation of file '%s' returned non NULL handle", RWopsAlphabetFilename); if (handle == NULL) return; /* Write alphabet text into it */ fileLen = SDL_strlen(RWopsAlphabetString); writtenLen = (int)fwrite(RWopsAlphabetString, 1, fileLen, handle); SDLTest_AssertCheck(fileLen == writtenLen, "Verify number of written bytes, expected %i, got %i", fileLen, writtenLen); result = fclose(handle); SDLTest_AssertCheck(result == 0, "Verify result from fclose, expected 0, got %i", result); SDLTest_AssertPass("Creation of test file completed"); }
/*! * Handle text events (if we were to use SDL2) */ void inputhandleText(SDL_TextInputEvent *Tevent) { size_t *newtextsize = NULL; int size = SDL_strlen(Tevent->text); if (size) { if (utf8Buf) { // clean up memory from last use. free(utf8Buf); utf8Buf = NULL; } utf8Buf = UTF8toUTF32(Tevent->text, newtextsize); debug(LOG_INPUT, "Keyboard: text input \"%s\"", Tevent->text); inputAddBuffer(CurrentKey, *utf8Buf); if (SDL_strlen(text) + SDL_strlen(Tevent->text) < sizeof(text)) { SDL_strlcat(text, Tevent->text, sizeof(text)); } debug(LOG_INPUT, "adding text inputed: %s, to string [%s]", Tevent->text, text); } }
static void PrintText(char *text) { unsigned char *spot, expanded[1024]; expanded[0] = '\0'; for ( spot = text; *spot; ++spot ) { size_t length = SDL_strlen(expanded); SDL_snprintf(expanded + length, sizeof(expanded) - length, "\\x%.2x", *spot); } SDL_Log("Text (%s): \"%s%s\"\n", expanded, *text == '"' ? "\\" : "", text); }
char * SDL_strdup(const char *string) { #if defined(HAVE_STRDUP) return strdup(string); #else size_t len = SDL_strlen(string) + 1; char *newstr = SDL_malloc(len); if (newstr) { SDL_strlcpy(newstr, string, len); } return newstr; #endif /* HAVE_STRDUP */ }
// Saves out the file. int cfg_SaveFile( void* cfgFile ) { assert( cfgFile != NULL ); int success = 0; CFGFile* file = (CFGFile*)cfgFile; char* outBuffer = NULL; SDL_RWops* rwopsFile = NULL; char strVal[32]; int writeNewLine = 0; int count = sb_Count( file->sbAttributes ); for( int i = 0; i < count; ++i ) { char* c = NULL; if( writeNewLine ) { c = sb_Add( outBuffer, 1 ); (*c) = '\n'; } writeNewLine = 1; // write out attribute name size_t attrLen = SDL_strlen( file->sbAttributes[i].fileName ); c = sb_Add( outBuffer, attrLen ); SDL_memcpy( c, file->sbAttributes[i].fileName, attrLen ); // write out separator c = sb_Add( outBuffer, 3 ); SDL_memcpy( c, " = ", 3 ); // write out value int pl = SDL_snprintf( strVal, sizeof( strVal ), "%i", file->sbAttributes[i].value ); if( pl >= ARRAY_SIZE( strVal ) ) { llog( LOG_ERROR, "Problem writing out configuration file value, value to long. File: %s Name: %s", file->filePath, file->sbAttributes[i].fileName ); goto clean_up; } else { c = sb_Add( outBuffer, pl ); SDL_memcpy( c, strVal, pl ); } } rwopsFile = SDL_RWFromFile( file->filePath, "w" ); SDL_RWwrite( rwopsFile, outBuffer, sizeof( char ), sb_Count( outBuffer ) ); clean_up: SDL_RWclose( rwopsFile ); sb_Release( outBuffer ); return success; }
void SGL_ConvertPNGToIconArray(const char * imagePath, const char * fileName) { SDL_RWops* rwop = SDL_RWFromFile(imagePath, "rb"); if (rwop) { SDL_Surface* surf = IMG_LoadPNG_RW(rwop); SDL_RWclose(rwop); SDL_RWops *rw = SDL_RWFromFile(fileName, "w"); if (rw) { size_t len = surf->h*surf->w*surf->format->BytesPerPixel; const char start[] = "unsigned char icon[] = { "; SDL_RWwrite(rw, start, 1, SDL_strlen(start)); size_t i; for (i = 0; i < len; i++) { char buffer[5]; SDL_snprintf(buffer, 5, "%u", *(((unsigned char*)surf->pixels) + i)); //sprintf(buffer, "%u", *(((unsigned char*)surf->pixels) + i)); size_t l; for (l = 1; l < 4; l++) { if (buffer[l] == 0 && i + 1 < len) { buffer[l] = ','; buffer[l + 1] = ' '; SDL_RWwrite(rw, buffer, 1, l + 2); break; } } } char buffer[7]; SDL_snprintf(buffer, 7,"%u", *(((unsigned char*)surf->pixels) + (len - 1))); size_t l; for (l = 1; l < 4; l++) { if (buffer[l] == 0) { buffer[l] = ' '; buffer[l + 1] = '}'; buffer[l + 2] = ';'; SDL_RWwrite(rw, buffer, 1, l + 3); break; } } SDL_RWclose(rw); } } }
int SDL_setenv(const char *name, const char *value, int overwrite) { size_t len; char *new_variable; if (getenv(name) != NULL) { if (overwrite) { unsetenv(name); } else { return 0; /* leave the existing one there. */ } } /* This leaks. Sorry. Get a better OS so we don't have to do this. */ len = SDL_strlen(name) + SDL_strlen(value) + 2; new_variable = (char *) SDL_malloc(len); if (!new_variable) { return (-1); } SDL_snprintf(new_variable, len, "%s=%s", name, value); return putenv(new_variable); }
void *SDL_LoadFunction(void *handle, const char *name) { void *symbol = dlsym(handle, name); if ( symbol == NULL ) { /* append an underscore for platforms that need that. */ size_t len = 1+SDL_strlen(name)+1; char *_name = SDL_stack_alloc(char, len); _name[0] = '_'; SDL_strlcpy(&_name[1], name, len); symbol = dlsym(handle, _name); SDL_stack_free(_name); if ( symbol == NULL ) { SDL_SetError("Failed loading %s: %s", name, (const char *)dlerror()); } }
char * SDL_GetPrefPath(const char *org, const char *app) { const char *append = "/libsdl/"; char *retval; size_t len = 0; len = SDL_strlen(append) + SDL_strlen(org) + SDL_strlen(app) + 3; retval = (char *) SDL_malloc(len); if (!retval) { SDL_OutOfMemory(); return NULL; } SDL_snprintf(retval, len, "%s%s/%s/", append, org, app); if (mkdir(retval, 0700) != 0 && errno != EEXIST) { SDL_SetError("Couldn't create directory '%s': '%s'", retval, strerror(errno)); SDL_free(retval); return NULL; } return retval; }
size_t SDL_strlcpy(char *dst, const char *src, size_t maxlen) { #if defined(HAVE_STRLCPY) return strlcpy(dst, src, maxlen); #else size_t srclen = SDL_strlen(src); if (maxlen > 0) { size_t len = SDL_min(srclen, maxlen - 1); SDL_memcpy(dst, src, len); dst[len] = '\0'; } return srclen; #endif /* HAVE_STRLCPY */ }
int SDL_OpenAudioPath(char *path, int maxlen, int flags, int classic) { const char *audiodev; int audio_fd; char audiopath[1024]; /* Figure out what our audio device is */ if ( ((audiodev=SDL_getenv("SDL_PATH_DSP")) == NULL) && ((audiodev=SDL_getenv("AUDIODEV")) == NULL) ) { if ( classic ) { audiodev = _PATH_DEV_AUDIO; } else { struct stat sb; /* Added support for /dev/sound/\* in Linux 2.4 */ if ( ((stat("/dev/sound", &sb) == 0) && S_ISDIR(sb.st_mode)) && ((stat(_PATH_DEV_DSP24, &sb) == 0) && S_ISCHR(sb.st_mode)) ) { audiodev = _PATH_DEV_DSP24; } else { audiodev = _PATH_DEV_DSP; } } } audio_fd = open(audiodev, flags, 0); /* If the first open fails, look for other devices */ if ( (audio_fd < 0) && (SDL_strlen(audiodev) < (sizeof(audiopath)-3)) ) { int exists, instance; struct stat sb; instance = 1; do { /* Don't use errno ENOENT - it may not be thread-safe */ SDL_snprintf(audiopath, SDL_arraysize(audiopath), "%s%d", audiodev, instance++); exists = 0; if ( stat(audiopath, &sb) == 0 ) { exists = 1; audio_fd = open(audiopath, flags, 0); } } while ( exists && (audio_fd < 0) ); audiodev = audiopath; } if ( path != NULL ) { SDL_strlcpy(path, audiodev, maxlen); path[maxlen-1] = '\0'; } return(audio_fd); }
int SDL_OpenAudioPath(char *path, int maxlen, int flags, int classic) { const char *audiodev; int audio_fd; char audiopath[1024]; if ( ((audiodev=SDL_getenv("SDL_PATH_DSP")) == NULL) && ((audiodev=SDL_getenv("AUDIODEV")) == NULL) ) { if ( classic ) { audiodev = _PATH_DEV_AUDIO; } else { struct stat sb; if ( ((stat("/dev/sound", &sb) == 0) && S_ISDIR(sb.st_mode)) && ((stat(_PATH_DEV_DSP24, &sb) == 0) && S_ISCHR(sb.st_mode)) ) { audiodev = _PATH_DEV_DSP24; } else { audiodev = _PATH_DEV_DSP; } } } audio_fd = open(audiodev, flags, 0); if ( (audio_fd < 0) && (SDL_strlen(audiodev) < (sizeof(audiopath)-3)) ) { int exists, instance; struct stat sb; instance = 1; do { SDL_snprintf(audiopath, SDL_arraysize(audiopath), "%s%d", audiodev, instance++); exists = 0; if ( stat(audiopath, &sb) == 0 ) { exists = 1; audio_fd = open(audiopath, flags, 0); } } while ( exists && (audio_fd < 0) ); audiodev = audiopath; } if ( path != NULL ) { SDL_strlcpy(path, audiodev, maxlen); path[maxlen-1] = '\0'; } return(audio_fd); }
static void SetMMerror(char *function, MMRESULT code) { size_t len; char errbuf[MAXERRORLENGTH]; wchar_t werrbuf[MAXERRORLENGTH]; SDL_snprintf(errbuf, SDL_arraysize(errbuf), "%s: ", function); len = SDL_strlen(errbuf); waveOutGetErrorText(code, werrbuf, MAXERRORLENGTH - len); WideCharToMultiByte(CP_ACP, 0, werrbuf, -1, errbuf + len, MAXERRORLENGTH - len, NULL, NULL); SDL_SetError("%s", errbuf); }
char * SDL_strstr(const char *haystack, const char *needle) { #if defined(HAVE_STRSTR) return SDL_const_cast(char*,strstr(haystack, needle)); #else size_t length = SDL_strlen(needle); while (*haystack) { if (SDL_strncmp(haystack, needle, length) == 0) { return (char *) haystack; } ++haystack; } return NULL; #endif /* HAVE_STRSTR */ }
char * SDL_GetPrefPath(const char *org, const char *app) { const char *path = SDL_AndroidGetInternalStoragePath(); if (path) { size_t pathlen = SDL_strlen(path)+2; char *fullpath = (char *)SDL_malloc(pathlen); if (!fullpath) { SDL_OutOfMemory(); return NULL; } SDL_snprintf(fullpath, pathlen, "%s/", path); return fullpath; } return NULL; }
static DBusHandlerResult DBus_MessageFilter(DBusConnection *conn, DBusMessage *msg, void *data) { SDL_DBusContext *dbus = (SDL_DBusContext *)data; if (dbus->message_is_signal(msg, FCITX_IC_DBUS_INTERFACE, "CommitString")) { DBusMessageIter iter; const char *text = NULL; dbus->message_iter_init(msg, &iter); dbus->message_iter_get_basic(&iter, &text); if (text) SDL_SendKeyboardText(text); return DBUS_HANDLER_RESULT_HANDLED; } if (dbus->message_is_signal(msg, FCITX_IC_DBUS_INTERFACE, "UpdatePreedit")) { DBusMessageIter iter; const char *text; dbus->message_iter_init(msg, &iter); dbus->message_iter_get_basic(&iter, &text); if (text && *text) { char buf[SDL_TEXTEDITINGEVENT_TEXT_SIZE]; size_t text_bytes = SDL_strlen(text), i = 0; size_t cursor = 0; while (i < text_bytes) { size_t sz = SDL_utf8strlcpy(buf, text + i, sizeof(buf)); size_t chars = _fcitx_utf8_strlen(buf); SDL_SendEditingText(buf, cursor, chars); i += sz; cursor += chars; } } SDL_Fcitx_UpdateTextRect(NULL); return DBUS_HANDLER_RESULT_HANDLED; } return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; }
void *SDL_LoadFunction(void *handle, const char *name) { void *symbol = NULL; const char *loaderror = "Unknown error"; #if defined(_WIN32_WCE) char errbuf[512]; int length = SDL_strlen(name); wchar_t *name_t = SDL_malloc((length + 1) * sizeof(wchar_t)); wchar_t *errbuf_t = SDL_malloc(512 * sizeof(wchar_t)); MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, name, -1, name_t, length); symbol = (void *)GetProcAddress((HMODULE)handle, name_t); if ( symbol == NULL ) { FormatMessage((FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_FROM_SYSTEM), NULL, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), errbuf_t, SDL_arraysize(errbuf), NULL); WideCharToMultiByte(CP_ACP, 0, errbuf_t, -1, errbuf, 511, NULL, NULL); loaderror = errbuf; } SDL_free(name_t); SDL_free(errbuf_t); #else /*if defined(WIN32)*/ char errbuf[512]; symbol = (void *)GetProcAddress((HMODULE)handle, name); if ( symbol == NULL ) { FormatMessage((FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_FROM_SYSTEM), NULL, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), errbuf, SDL_arraysize(errbuf), NULL); loaderror = errbuf; } #endif if ( symbol == NULL ) { SDL_SetError("Failed loading %s: %s", name, loaderror); } return(symbol); }