| 1 | // for finding memory leaks in debug mode with Visual Studio cxx . . $ `<file>/src/pt2_helpers.c`/ |
| 2 | #if defined _DEBUG && defined _MSC_VER |
| 3 | #include <crtdbg.h> |
| 4 | #endif |
| 5 | |
| 6 | #include <SDL2/SDL.h> |
| 7 | #include <stdarg.h> |
| 8 | #include <stdio.h> |
| 9 | #include <stdint.h> |
| 10 | #include <stdbool.h> |
| 11 | #include <string.h> |
| 12 | #include <ctype.h> // toupper() |
| 13 | #include "pt2_structs.h"cxx . . $ `<file>/src/pt2_structs.h`/ |
| 14 | #include "pt2_config.h"cxx . . $ `<file>/src/pt2_config.h`/ |
| 15 | |
| 16 | void showErrorMsgBoxcxx . . $ showErrorMsgBox(326aeb464d16410c).(const char *fmt, ...) |
| 17 | { |
| 18 | char strBuf[512+1]; |
| 19 | va_listcxx . . $ va_list# args; |
| 20 | |
| 21 | // format the text string |
| 22 | va_startcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stdarg.h:50:9`!(args, fmt); |
| 23 | vsnprintfcxx . . $ vsnprintf(a85eea89d1bd834f).(strBuf, sizeof (strBuf)-1, fmt, args); |
| 24 | va_endcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stdarg.h:52:9`!(args); |
| 25 | |
| 26 | // SDL message boxes can be very buggy on Windows XP, use MessageBoxA() instead |
| 27 | #ifdef _WIN32 |
| 28 | MessageBoxA(NULL, strBuf, "Error", MB_OK | MB_ICONERROR); |
| 29 | #else |
| 30 | SDL_ShowSimpleMessageBoxcxx . . $ SDL_ShowSimpleMessageBox(465dae8f9cdff27c).(SDL_MESSAGEBOX_ERRORcxx . . $ SDL_MESSAGEBOX_ERROR., "Error", strBuf, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 31 | #endif |
| 32 | } |
| 33 | |
| 34 | void sanitizeFilenameCharcxx . . $ sanitizeFilenameChar(fda57c8427c60377).(char *chr) |
| 35 | { |
| 36 | // some of these are legal on GNU/Linux and macOS, but whatever... |
| 37 | if (*chr == '\\') *chr = ' '; |
| 38 | else if (*chr == '/') *chr = ' '; |
| 39 | else if (*chr == ':') *chr = ' '; |
| 40 | else if (*chr == '*') *chr = ' '; |
| 41 | else if (*chr == '?') *chr = ' '; |
| 42 | else if (*chr == '\"') *chr = ' '; |
| 43 | else if (*chr == '<') *chr = ' '; |
| 44 | else if (*chr == '>') *chr = ' '; |
| 45 | else if (*chr == '|') *chr = ' '; |
| 46 | } |
| 47 | |
| 48 | boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! sampleNameIsEmptycxx . . $ sampleNameIsEmpty(c6b7e35ff6de5671).(char *name) |
| 49 | { |
| 50 | if (name == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 51 | return truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!; |
| 52 | |
| 53 | for (int32_tcxx . . $ int32_t# i = 0; i < 22; i++) |
| 54 | { |
| 55 | if (name[i] != '\0') |
| 56 | return falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!; |
| 57 | } |
| 58 | |
| 59 | return truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!; |
| 60 | } |
| 61 | |
| 62 | boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! moduleNameIsEmptycxx . . $ moduleNameIsEmpty(c6b7e35ff6de5671).(char *name) |
| 63 | { |
| 64 | if (name == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 65 | return truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!; |
| 66 | |
| 67 | for (int32_tcxx . . $ int32_t# i = 0; i < 20; i++) |
| 68 | { |
| 69 | if (name[i] != '\0') |
| 70 | return falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!; |
| 71 | } |
| 72 | |
| 73 | return truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!; |
| 74 | } |
| 75 | |
| 76 | void updateWindowTitlecxx . . $ updateWindowTitle(b45ddcbc8423892c).(boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! modified) |
| 77 | { |
| 78 | char editStr[32], titleTemp[256]; |
| 79 | |
| 80 | editStr[0] = '\0'; |
| 81 | if (editorcxx . . $ editor..currModecxx . . $ editor_t#currMode. == MODE_EDITcxx . . $ MODE_EDIT.) |
| 82 | strcpycxx . . $ strcpy(b7b3a83273496486).(editStr, "[EDITING] "); |
| 83 | |
| 84 | if (modified) |
| 85 | songcxx . . $ song.->modifiedcxx . . $ module_t#modified. = truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!; |
| 86 | else |
| 87 | songcxx . . $ song.->modifiedcxx . . $ module_t#modified. = falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!; |
| 88 | |
| 89 | if (songcxx . . $ song.->headercxx . . $ module_t#header..namecxx . . $ moduleHeader_t#name.[0] != '\0') |
| 90 | { |
| 91 | if (modified) |
| 92 | { |
| 93 | if (configcxx . . $ config..modDotcxx . . $ config_t#modDot.) |
| 94 | sprintfcxx . . $ sprintf(26c8642d26409d6d).(titleTemp, "ProTracker 2 clone v%s %s- \"mod.%s\" (unsaved)", |
| 95 | PROG_VER_STRcxx . . $ `src/pt2_header.h:19:9`!, editStr, songcxx . . $ song.->headercxx . . $ module_t#header..namecxx . . $ moduleHeader_t#name.); |
| 96 | else |
| 97 | sprintfcxx . . $ sprintf(26c8642d26409d6d).(titleTemp, "ProTracker 2 clone v%s %s- \"%s.mod\" (unsaved)", |
| 98 | PROG_VER_STRcxx . . $ `src/pt2_header.h:19:9`!, editStr, songcxx . . $ song.->headercxx . . $ module_t#header..namecxx . . $ moduleHeader_t#name.); |
| 99 | } |
| 100 | else |
| 101 | { |
| 102 | if (configcxx . . $ config..modDotcxx . . $ config_t#modDot.) |
| 103 | sprintfcxx . . $ sprintf(26c8642d26409d6d).(titleTemp, "ProTracker 2 clone v%s %s- \"mod.%s\"", |
| 104 | PROG_VER_STRcxx . . $ `src/pt2_header.h:19:9`!, editStr, songcxx . . $ song.->headercxx . . $ module_t#header..namecxx . . $ moduleHeader_t#name.); |
| 105 | else |
| 106 | sprintfcxx . . $ sprintf(26c8642d26409d6d).(titleTemp, "ProTracker 2 clone v%s %s- \"%s.mod\"", |
| 107 | PROG_VER_STRcxx . . $ `src/pt2_header.h:19:9`!, editStr, songcxx . . $ song.->headercxx . . $ module_t#header..namecxx . . $ moduleHeader_t#name.); |
| 108 | } |
| 109 | } |
| 110 | else |
| 111 | { |
| 112 | if (modified) |
| 113 | { |
| 114 | if (configcxx . . $ config..modDotcxx . . $ config_t#modDot.) |
| 115 | sprintfcxx . . $ sprintf(26c8642d26409d6d).(titleTemp, "ProTracker 2 clone v%s %s- \"mod.untitled\" (unsaved)", |
| 116 | PROG_VER_STRcxx . . $ `src/pt2_header.h:19:9`!, editStr); |
| 117 | else |
| 118 | sprintfcxx . . $ sprintf(26c8642d26409d6d).(titleTemp, "ProTracker 2 clone v%s %s- \"untitled.mod\" (unsaved)", |
| 119 | PROG_VER_STRcxx . . $ `src/pt2_header.h:19:9`!, editStr); |
| 120 | } |
| 121 | else |
| 122 | { |
| 123 | if (configcxx . . $ config..modDotcxx . . $ config_t#modDot.) |
| 124 | sprintfcxx . . $ sprintf(26c8642d26409d6d).(titleTemp, "ProTracker 2 clone v%s %s- \"mod.untitled\"", |
| 125 | PROG_VER_STRcxx . . $ `src/pt2_header.h:19:9`!, editStr); |
| 126 | else |
| 127 | sprintfcxx . . $ sprintf(26c8642d26409d6d).(titleTemp, "ProTracker 2 clone v%s %s- \"untitled.mod\"", |
| 128 | PROG_VER_STRcxx . . $ `src/pt2_header.h:19:9`!, editStr); |
| 129 | } |
| 130 | } |
| 131 | |
| 132 | SDL_SetWindowTitlecxx . . $ SDL_SetWindowTitle(6190c2ba9f29b86).(videocxx . . $ video..windowcxx . . $ video_t#window., titleTemp); |
| 133 | } |