From: Samual Date: Sun, 19 Feb 2012 23:18:01 +0000 (-0500) Subject: Quick little cleanup for generic.qc command code X-Git-Tag: xonotic-v0.6.0~66^2~3 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=cf726e362434726a75158e4d3c267744ce4a4ffd;p=xonotic%2Fxonotic-data.pk3dir.git Quick little cleanup for generic.qc command code --- diff --git a/qcsrc/common/command/generic.qc b/qcsrc/common/command/generic.qc index 68ee8c712..a4389b139 100644 --- a/qcsrc/common/command/generic.qc +++ b/qcsrc/common/command/generic.qc @@ -17,6 +17,33 @@ string GetProgramCommandPrefix(void) #endif } +// used by curl command +void Curl_URI_Get_Callback(float id, float status, string data) +{ + float i; + float do_exec; + string do_cvar; + i = id - URI_GET_CURL; + do_exec = curl_uri_get_exec[i]; + do_cvar = curl_uri_get_cvar[i]; + if(status != 0) + { + print(sprintf(_("error: status is %d\n"), status)); + if(do_cvar) + strunzone(do_cvar); + return; + } + if(do_exec) + localcmd(data); + if(do_cvar) + { + cvar_set(do_cvar, data); + strunzone(do_cvar); + } + if(!do_exec && !do_cvar) + print(data); +} + // ======================= // Command Sub-Functions @@ -65,35 +92,6 @@ void GenericCommand_addtolist(float request, float argc) } } -float curl_uri_get_pos; -float curl_uri_get_exec[URI_GET_CURL_END - URI_GET_CURL + 1]; -string curl_uri_get_cvar[URI_GET_CURL_END - URI_GET_CURL + 1]; -void Curl_URI_Get_Callback(float id, float status, string data) -{ - float i; - float do_exec; - string do_cvar; - i = id - URI_GET_CURL; - do_exec = curl_uri_get_exec[i]; - do_cvar = curl_uri_get_cvar[i]; - if(status != 0) - { - print(sprintf(_("error: status is %d\n"), status)); - if(do_cvar) - strunzone(do_cvar); - return; - } - if(do_exec) - localcmd(data); - if(do_cvar) - { - cvar_set(do_cvar, data); - strunzone(do_cvar); - } - if(!do_exec && !do_cvar) - print(data); -} - void GenericCommand_curl(float request, float argc) { switch(request) diff --git a/qcsrc/common/command/generic.qh b/qcsrc/common/command/generic.qh index 4391555c6..be096db17 100644 --- a/qcsrc/common/command/generic.qh +++ b/qcsrc/common/command/generic.qh @@ -17,3 +17,6 @@ string GetProgramCommandPrefix(void); void GenericCommand_macro_write_aliases(float fh); void Curl_URI_Get_Callback(float id, float status, string data); +float curl_uri_get_pos; +float curl_uri_get_exec[URI_GET_CURL_END - URI_GET_CURL + 1]; +string curl_uri_get_cvar[URI_GET_CURL_END - URI_GET_CURL + 1]; \ No newline at end of file