#include "log.h"
#include "main.h" // for g_settings
#include "settings.h"
+#include "version.h"
#if USE_CURL
#include <curl/curl.h>
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &liststring);
curl_easy_setopt(curl, CURLOPT_TIMEOUT_MS, g_settings->getS32("curl_timeout"));
+ curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT_MS, g_settings->getS32("curl_timeout"));
+ curl_easy_setopt(curl, CURLOPT_USERAGENT, (std::string("Minetest ")+minetest_version_hash).c_str());
+
if (chunk != 0)
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, chunk);
-
res = curl_easy_perform(curl);
if (res != CURLE_OK)
errorstream<<"Jsonreader: "<< url <<" not found (" << curl_easy_strerror(res) << ")" <<std::endl;
//id
if (modlist[i]["id"].asString().size()) {
- const char* id_raw = modlist[i]["id"].asString().c_str();
+ std::string id_raw = modlist[i]["id"].asString();
char* endptr = 0;
- int numbervalue = strtol(id_raw,&endptr,10);
+ int numbervalue = strtol(id_raw.c_str(),&endptr,10);
- if ((*id_raw != 0) && (*endptr == 0)) {
+ if ((id_raw != "") && (*endptr == 0)) {
toadd.id = numbervalue;
}
+ else {
+ errorstream << "readModStoreList: missing id" << std::endl;
+ toadd.valid = false;
+ }
}
else {
errorstream << "readModStoreList: missing id" << std::endl;
ModStoreVersionEntry toadd;
if (details["version_set"][i]["id"].asString().size()) {
- const char* id_raw = details["version_set"][i]["id"].asString().c_str();
+ std::string id_raw = details["version_set"][i]["id"].asString();
char* endptr = 0;
- int numbervalue = strtol(id_raw,&endptr,10);
+ int numbervalue = strtol(id_raw.c_str(),&endptr,10);
- if ((*id_raw != 0) && (*endptr == 0)) {
+ if ((id_raw != "") && (*endptr == 0)) {
toadd.id = numbervalue;
}
}
if (details["categories"][i]["id"].asString().size()) {
- const char* id_raw = details["categories"][i]["id"].asString().c_str();
+ std::string id_raw = details["categories"][i]["id"].asString();
char* endptr = 0;
- int numbervalue = strtol(id_raw,&endptr,10);
+ int numbervalue = strtol(id_raw.c_str(),&endptr,10);
- if ((*id_raw != 0) && (*endptr == 0)) {
+ if ((id_raw != "") && (*endptr == 0)) {
toadd.id = numbervalue;
}
}
if (details["author"].isObject()) {
if (details["author"]["id"].asString().size()) {
- const char* id_raw = details["author"]["id"].asString().c_str();
+ std::string id_raw = details["author"]["id"].asString();
char* endptr = 0;
- int numbervalue = strtol(id_raw,&endptr,10);
+ int numbervalue = strtol(id_raw.c_str(),&endptr,10);
- if ((*id_raw != 0) && (*endptr == 0)) {
+ if ((id_raw != "") && (*endptr == 0)) {
retval.author.id = numbervalue;
}
else {
if (details["license"].isObject()) {
if (details["license"]["id"].asString().size()) {
- const char* id_raw = details["license"]["id"].asString().c_str();
+ std::string id_raw = details["license"]["id"].asString();
char* endptr = 0;
- int numbervalue = strtol(id_raw,&endptr,10);
+ int numbervalue = strtol(id_raw.c_str(),&endptr,10);
- if ((*id_raw != 0) && (*endptr == 0)) {
+ if ((id_raw != "") && (*endptr == 0)) {
retval.license.id = numbervalue;
}
}
if (details["titlepic"].isObject()) {
if (details["titlepic"]["id"].asString().size()) {
- const char* id_raw = details["titlepic"]["id"].asString().c_str();
+ std::string id_raw = details["titlepic"]["id"].asString();
char* endptr = 0;
- int numbervalue = strtol(id_raw,&endptr,10);
+ int numbervalue = strtol(id_raw.c_str(),&endptr,10);
- if ((*id_raw != 0) && (*endptr == 0)) {
+ if ((id_raw != "") && (*endptr == 0)) {
retval.titlepic.id = numbervalue;
}
}
if (details["titlepic"]["mod"].asString().size()) {
- const char* mod_raw = details["titlepic"]["mod"].asString().c_str();
+ std::string mod_raw = details["titlepic"]["mod"].asString();
char* endptr = 0;
- int numbervalue = strtol(mod_raw,&endptr,10);
+ int numbervalue = strtol(mod_raw.c_str(),&endptr,10);
- if ((*mod_raw != 0) && (*endptr == 0)) {
+ if ((mod_raw != "") && (*endptr == 0)) {
retval.titlepic.mod = numbervalue;
}
}
//id
if (details["id"].asString().size()) {
- const char* id_raw = details["id"].asString().c_str();
+ std::string id_raw = details["id"].asString();
char* endptr = 0;
- int numbervalue = strtol(id_raw,&endptr,10);
+ int numbervalue = strtol(id_raw.c_str(),&endptr,10);
- if ((*id_raw != 0) && (*endptr == 0)) {
+ if ((id_raw != "") && (*endptr == 0)) {
retval.id = numbervalue;
}
}
//value
if (details["rating"].asString().size()) {
- const char* id_raw = details["rating"].asString().c_str();
+ std::string id_raw = details["rating"].asString();
char* endptr = 0;
- float numbervalue = strtof(id_raw,&endptr);
+ float numbervalue = strtof(id_raw.c_str(),&endptr);
- if ((*id_raw != 0) && (*endptr == 0)) {
+ if ((id_raw != "") && (*endptr == 0)) {
retval.rating = numbervalue;
}
}