Delay(1);
}
+static char *getPasswordJSON(char *password)
+{
+ static char password_json[MAX_FILENAME_LEN] = "";
+ static boolean initialized = FALSE;
+
+ if (!initialized)
+ {
+ if (password != NULL &&
+ !strEqual(password, "") &&
+ !strEqual(password, UNDEFINED_PASSWORD))
+ snprintf(password_json, MAX_FILENAME_LEN,
+ " \"password\": \"%s\",\n",
+ setup.api_server_password);
+
+ initialized = TRUE;
+ }
+
+ return password_json;
+}
+
static void DownloadServerScoreToCacheExt(struct HttpRequest *request,
struct HttpResponse *response,
int level_nr,
snprintf(request->body, MAX_HTTP_BODY_SIZE,
"{\n"
+ "%s"
" \"levelset_identifier\": \"%s\",\n"
" \"level_nr\": \"%d\"\n"
"}\n",
+ getPasswordJSON(setup.api_server_password),
levelset.identifier, level_nr);
ConvertHttpRequestBodyToServerEncoding(request);
snprintf(request->body, MAX_HTTP_BODY_SIZE,
"{\n"
+ "%s"
" \"game_version\": \"%s\",\n"
" \"levelset_identifier\": \"%s\",\n"
" \"levelset_name\": \"%s\",\n"
" \"tape_basename\": \"%s\",\n"
" \"tape\": \"%s\"\n"
"}\n",
+ getPasswordJSON(setup.api_server_password),
getProgramRealVersionString(),
levelset_identifier,
levelset_name,
TYPE_STRING,
&setup.api_server_hostname, "api_server_hostname"
},
+ {
+ TYPE_STRING,
+ &setup.api_server_password, "api_server_password"
+ },
{
TYPE_STRING,
&setup.touch.control_type, "touch.control_type"
si->api_server = TRUE;
si->api_server_hostname = getStringCopy(API_SERVER_HOSTNAME);
+ si->api_server_password = getStringCopy(UNDEFINED_PASSWORD);
si->touch.control_type = getStringCopy(TOUCH_CONTROL_DEFAULT);
si->touch.move_distance = TOUCH_MOVE_DISTANCE_DEFAULT; // percent
// default value for undefined levelset
#define UNDEFINED_LEVELSET "[NONE]"
+// default value for undefined password
+#define UNDEFINED_PASSWORD "[undefined]"
+
// default value for undefined parameter
#define ARG_DEFAULT "[DEFAULT]"
boolean api_server;
char *api_server_hostname;
+ char *api_server_password;
struct SetupAutoSetupInfo auto_setup;
struct SetupLevelSetupInfo level_setup;