From cf726e362434726a75158e4d3c267744ce4a4ffd Mon Sep 17 00:00:00 2001 From: Samual Date: Sun, 19 Feb 2012 18:18:01 -0500 Subject: [PATCH] Quick little cleanup for generic.qc command code --- qcsrc/common/command/generic.qc | 56 ++++++++++++++++----------------- qcsrc/common/command/generic.qh | 3 ++ 2 files changed, 30 insertions(+), 29 deletions(-) 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 -- 2.39.2