blob: 4fd0d85f26adaf49a024eb82ecc25cf327246ce5 (
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
46
|
/*
* This file is part of MXE.
* See index.html for further 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;
}
|