blob: aaa4c2638d1e2ecf7e27edb1eae45d8706bdbd79 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
/*
* This file is part of MXE. See LICENSE.md for licensing information.
*
* This is a simple test program for SDL_rwhttp that tries to
* fetch something from the web.
*
* This file is in the Public Domain.
*/
#include <stdio.h>
#include <SDL_rwhttp.h>
int main(int argc, char *argv[])
{
int ret = EXIT_SUCCESS;
const char *url;
SDL_RWops* rwops;
if (argc != 2) {
fprintf(stderr, "usage: %s <url>\n", argv[0]);
return EXIT_FAILURE;
}
url = argv[1];
if (SDL_RWHttpInit() == -1) {
fprintf(stderr, "%s\n", SDL_GetError());
return EXIT_FAILURE;
}
rwops = SDL_RWFromHttpSync(url);
if (!rwops) {
fprintf(stderr, "%s\n", SDL_GetError());
ret = EXIT_FAILURE;
} else {
printf("success\n");
SDL_RWclose(rwops);
}
if (SDL_RWHttpShutdown() == -1) {
fprintf(stderr, "%s\n", SDL_GetError());
return EXIT_FAILURE;
}
return ret;
}
|