From b55b4eca7235b85b9cec188f4a9218eabfd812b8 Mon Sep 17 00:00:00 2001 From: Curtis McEnroe Date: Tue, 26 Mar 2019 19:13:17 -0400 Subject: Search for lowercase cards.dll and fall back to current directory --- sol.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/sol.c b/sol.c index 4da4933..16a688f 100644 --- a/sol.c +++ b/sol.c @@ -24,6 +24,8 @@ #include "cards.h" #include "stack.h" +#define ARRAY_LEN(a) (sizeof(a) / sizeof((a)[0])) + typedef unsigned uint; enum { @@ -403,24 +405,24 @@ int main(void) { char *basePath = SDL_GetBasePath(); if (!basePath) err("SDL_GetBasePath"); - char paths[4][1024]; - snprintf(paths[0], sizeof(paths[0]), "%sCARDS.DLL", prefPath); - snprintf(paths[1], sizeof(paths[1]), "%sSOL.EXE", prefPath); - snprintf(paths[2], sizeof(paths[2]), "%sCARDS.DLL", basePath); - snprintf(paths[3], sizeof(paths[3]), "%sSOL.EXE", basePath); + const char *paths[] = { prefPath, basePath, "" }; + const char *names[] = { "CARDS.DLL", "SOL.EXE", "cards.dll" }; - SDL_RWops *rw; - for (uint i = 0; i < 4; ++i) { - rw = SDL_RWFromFile(paths[i], "rb"); - if (rw) break; + SDL_RWops *rw = NULL; + for (uint i = 0; !rw && i < ARRAY_LEN(paths); ++i) { + for (uint j = 0; !rw && j < ARRAY_LEN(names); ++j) { + char path[1024]; + snprintf(path, sizeof(path), "%s%s", paths[i], names[j]); + rw = SDL_RWFromFile(path, "rb"); + } } if (!rw) { - char buf[4096]; + char msg[4096]; snprintf( - buf, sizeof(buf), "CARDS.DLL not found in:\n%s\n%s", + msg, sizeof(msg), "CARDS.DLL or SOL.EXE not found in:\n%s\n%s", prefPath, basePath ); - SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Cards", buf, NULL); + SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Cards", msg, NULL); return EXIT_FAILURE; } -- cgit 1.4.1 n>
path: root/home/.config/X/resources (unfollow)
Commit message (Collapse)Author
2021-02-06Add initial OpenBSD X configurationJune McEnroe
cwm still needs a lot more rebinding, and I need to actually look at its other options. xterm definitely still needs some configuration, but I at least managed to get it to use a decent looking font. Very happy that OpenBSD includes Luxi Mono, which is what my usual font, Go Mono, is based on anyway. Still missing is xmodmap and such.
2021-02-06Add xterm output to schemeJune McEnroe