You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
46 lines
969 B
46 lines
969 B
/*
|
|
* 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;
|
|
}
|