Atlas - testurl.c
Home / ext / SDL / test Lines: 1 | Size: 1572 bytes [Download] [Show on GitHub] [Search similar files] [Raw] [Raw (proxy)][FILE BEGIN]1/* 2 Copyright (C) 1997-2025 Sam Lantinga <[email protected]> 3 4 This software is provided 'as-is', without any express or implied 5 warranty. In no event will the authors be held liable for any damages 6 arising from the use of this software. 7 8 Permission is granted to anyone to use this software for any purpose, 9 including commercial applications, and to alter it and redistribute it 10 freely. 11*/ 12#include <SDL3/SDL.h> 13#include <SDL3/SDL_main.h> 14#include <SDL3/SDL_test.h> 15 16static void tryOpenURL(const char *url) 17{ 18 SDL_Log("Opening '%s' ...", url); 19 if (SDL_OpenURL(url)) { 20 SDL_Log(" success!"); 21 } else { 22 SDL_Log(" failed! %s", SDL_GetError()); 23 } 24} 25 26int main(int argc, char **argv) 27{ 28 int i; 29 SDLTest_CommonState *state; 30 31 state = SDLTest_CommonCreateState(argv, 0); 32 33 if (!SDL_Init(SDL_INIT_VIDEO)) { 34 SDL_Log("SDL_Init failed: %s", SDL_GetError()); 35 return 1; 36 } 37 38 /* Parse commandline */ 39 for (i = 1; i < argc;) { 40 int consumed; 41 42 consumed = SDLTest_CommonArg(state, i); 43 if (consumed == 0) { 44 if (argv[i][0] != '-') { 45 tryOpenURL(argv[i]); 46 consumed = 1; 47 } 48 } 49 if (consumed <= 0) { 50 static const char *options[] = { 51 "[URL [...]]", 52 NULL, 53 }; 54 SDLTest_CommonLogUsage(state, argv[0], options); 55 return SDL_APP_FAILURE; 56 } 57 i += consumed; 58 } 59 60 SDL_Quit(); 61 SDLTest_CommonDestroyState(state); 62 return 0; 63} 64[FILE END](C) 2025 0x4248 (C) 2025 4248 Media and 4248 Systems, All part of 0x4248 See LICENCE files for more information. Not all files are by 0x4248 always check Licencing.