Debian Codegraph @

test/testurl.c

raw
1 /*
2 Copyright (C) 1997-2026 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 "SDL.h"
13
14 static void tryOpenURL(const char *url)
15 {
16 SDL_Log("Opening '%s' ...", url);
17 if (SDL_OpenURL(url) == 0) {
18 SDL_Log(" success!");
19 } else {
20 SDL_Log(" failed! %s", SDL_GetError());
21 }
22 }
23
24 int main(int argc, char **argv)
25 {
26 int i;
27 if (SDL_Init(SDL_INIT_VIDEO) == -1) {
28 SDL_Log("SDL_Init failed: %s\n", SDL_GetError());
29 return 1;
30 }
31
32 if (argc > 1) {
33 for (i = 1; i < argc; i++) {
34 tryOpenURL(argv[i]);
35 }
36 } else {
37 tryOpenURL("https://libsdl.org/");
38 }
39
40 SDL_Quit();
41 return 0;
42 }
43
44 /* vi: set ts=4 sw=4 expandtab: */