2020-10-05 11:30:33 -04:00
|
|
|
/*
|
2026-01-01 09:48:19 -08:00
|
|
|
Copyright (C) 1997-2026 Sam Lantinga <slouken@libsdl.org>
|
2020-10-05 11:30:33 -04:00
|
|
|
|
|
|
|
|
This software is provided 'as-is', without any express or implied
|
|
|
|
|
warranty. In no event will the authors be held liable for any damages
|
|
|
|
|
arising from the use of this software.
|
|
|
|
|
|
|
|
|
|
Permission is granted to anyone to use this software for any purpose,
|
|
|
|
|
including commercial applications, and to alter it and redistribute it
|
|
|
|
|
freely.
|
|
|
|
|
*/
|
2022-11-26 20:43:38 -08:00
|
|
|
#include <SDL3/SDL.h>
|
2022-12-15 05:58:20 +01:00
|
|
|
#include <SDL3/SDL_main.h>
|
2025-11-17 13:24:16 +01:00
|
|
|
#include <SDL3/SDL_test.h>
|
2020-10-05 11:30:33 -04:00
|
|
|
|
2022-07-01 19:59:06 +01:00
|
|
|
static void tryOpenURL(const char *url)
|
|
|
|
|
{
|
|
|
|
|
SDL_Log("Opening '%s' ...", url);
|
2024-08-22 17:33:49 -07:00
|
|
|
if (SDL_OpenURL(url)) {
|
2022-07-01 19:59:06 +01:00
|
|
|
SDL_Log(" success!");
|
|
|
|
|
} else {
|
|
|
|
|
SDL_Log(" failed! %s", SDL_GetError());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-05 11:30:33 -04:00
|
|
|
int main(int argc, char **argv)
|
|
|
|
|
{
|
|
|
|
|
int i;
|
2025-11-17 13:24:16 +01:00
|
|
|
SDLTest_CommonState *state;
|
|
|
|
|
|
|
|
|
|
state = SDLTest_CommonCreateState(argv, 0);
|
|
|
|
|
|
2024-08-22 17:33:49 -07:00
|
|
|
if (!SDL_Init(SDL_INIT_VIDEO)) {
|
2025-01-22 12:59:57 -08:00
|
|
|
SDL_Log("SDL_Init failed: %s", SDL_GetError());
|
2020-10-05 11:30:33 -04:00
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2025-11-17 13:24:16 +01:00
|
|
|
/* Parse commandline */
|
|
|
|
|
for (i = 1; i < argc;) {
|
|
|
|
|
int consumed;
|
|
|
|
|
|
|
|
|
|
consumed = SDLTest_CommonArg(state, i);
|
|
|
|
|
if (consumed == 0) {
|
|
|
|
|
if (argv[i][0] != '-') {
|
|
|
|
|
tryOpenURL(argv[i]);
|
|
|
|
|
consumed = 1;
|
|
|
|
|
}
|
2020-10-05 11:30:33 -04:00
|
|
|
}
|
2025-11-17 13:24:16 +01:00
|
|
|
if (consumed <= 0) {
|
|
|
|
|
static const char *options[] = {
|
|
|
|
|
"[URL [...]]",
|
|
|
|
|
NULL,
|
|
|
|
|
};
|
|
|
|
|
SDLTest_CommonLogUsage(state, argv[0], options);
|
|
|
|
|
return SDL_APP_FAILURE;
|
|
|
|
|
}
|
|
|
|
|
i += consumed;
|
2020-10-05 11:30:33 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SDL_Quit();
|
2025-11-17 13:24:16 +01:00
|
|
|
SDLTest_CommonDestroyState(state);
|
2020-10-05 11:30:33 -04:00
|
|
|
return 0;
|
|
|
|
|
}
|