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 option>
path: root/etc/CodeQWERTY.keylayout (unfollow)
Commit message (Expand)Author
2019-11-01Use initial in git authorJune McEnroe
2019-11-01Add Hobo Johnson and The Lovemakers Tiny DeskJune McEnroe
2019-10-30Use braces in causal.agency MakefileJune McEnroe
2019-10-30Add scheme "screenshot" to causal.agencyJune McEnroe
2019-10-30Add pounce to causal.agencyJune McEnroe
2019-10-28Mark ' for \aJune McEnroe
2019-10-23Add The Book of the Unnamed MidwifeJune McEnroe
2019-10-22Add ConcreteJune McEnroe
2019-10-14Set the write variable for nvim man modeJune McEnroe
2019-10-13Add All Systems RedJune McEnroe
2019-10-10Add The Book of PhoenixJune McEnroe
2019-10-03Add two Kim Petras songsJune McEnroe
2019-10-02Update neovim 0.4.2June McEnroe
2019-10-02Claim to be curl(1) in titleJune McEnroe
2019-10-02Add The Red Threads of FortuneJune McEnroe
2019-09-28Add The Black Tides of HeavenJune McEnroe
2019-09-27Fail on HTTP failure status in titleJune McEnroe
2019-09-23Add Trail of LightningJune McEnroe
2019-09-22Revert "Enable cookies in title"June McEnroe
2019-09-20Enable cookies in titleJune McEnroe
2019-09-16Use sensitivity aliases in TF2June McEnroe
2019-09-16Add The Just CityJune McEnroe
2019-09-12Only GET the final redirect locationJune McEnroe
2019-09-12Consume entire bodyJune McEnroe
2019-09-10Add title -v flagJune McEnroe
2019-09-10Use curl error bufferJune McEnroe
2019-09-10Set Accept-Encoding in titleJune McEnroe
2019-09-08Set title User-AgentJune McEnroe
2019-09-07Add -x flag to titleJune McEnroe
2019-09-07Ignore SIGPIPE in relayJune McEnroe
2019-09-07Add A Memory Called EmpireJune McEnroe
2019-09-05Handle lack of Content-TypeJune McEnroe
2019-09-05Use CURLINFO_CONTENT_TYPEJune McEnroe
2019-09-05Decode entities in titlesJune McEnroe
2019-09-05Print title as soon as it's availableJune McEnroe
2019-09-05Use CURL_PREFIX to set flagsJune McEnroe
2019-09-05Add titleJune McEnroe
2019-09-04Add Avorter n'est pas tuerJune McEnroe
2019-08-29Unset executable on shell scriptsJune McEnroe
2019-08-29Add long-missing setopt to bin.7June McEnroe
2019-08-29Add editJune McEnroe