]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Merge branch 'master' of git://de.git.xonotic.org/xonotic/xonotic-data.pk3dir
authorRudolf Polzer <divverent@alientrap.org>
Fri, 26 Nov 2010 19:35:22 +0000 (20:35 +0100)
committerRudolf Polzer <divverent@alientrap.org>
Fri, 26 Nov 2010 19:35:22 +0000 (20:35 +0100)
qcsrc/menu/gamecommand.qc
qcsrc/menu/mbuiltin.qh
qcsrc/menu/xonotic/util.qc
qcsrc/menu/xonotic/util.qh

index 4b2b9cf0c921345dd48d4032b745a9971b2600b3..03e863e278a1cfa8885469cfad5d30cd27bdb1f6 100644 (file)
@@ -31,6 +31,30 @@ void _dumptree_close(entity pass, entity me)
        }
 }
 
+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("error: status is ", ftos(status), "\n");
+               return;
+       }
+       if(do_exec)
+               localcmd(data);
+       if(do_cvar)
+               cvar_set(do_cvar, data);
+       if(!do_exec && !do_cvar)
+               print(data);
+}
+
 void GameCommand(string theCommand)
 {
        float argc;
@@ -100,6 +124,67 @@ void GameCommand(string theCommand)
                return;
        }
 
+       if(argv(0) == "curl")
+       {
+               float do_exec;
+               string do_cvar;
+               float key;
+               float i, j;
+               string url;
+               float buf;
+
+               do_exec = FALSE;
+               do_cvar = string_null;
+               key = -1;
+
+               for(i = 1; i+1 < argc; ++i)
+               {
+                       if(argv(i) == "--cvar" && i+2 < argc)
+                       {
+                               ++i;
+                               do_cvar = argv(i);
+                               ++i;
+                               continue;
+                       }
+                       if(argv(i) == "--exec")
+                       {
+                               do_exec = TRUE;
+                               ++i;
+                               continue;
+                       }
+                       if(argv(i) == "--key" && i+2 < argc)
+                       {
+                               ++i;
+                               key = stof(argv(i));
+                               ++i;
+                               continue;
+                       }
+                       break;
+               }
+
+               // now, argv(i) is the URL
+               // following args may be POST parameters
+               url = argv(i);
+               ++i;
+               buf = buf_create();
+               j = 0;
+               for(; i+1 < argc; i += 2)
+                       bufstr_set(buf, ++j, sprintf("%s=%s", uri_escape(argv(i)), uri_escape(argv(i+1))));
+               if(i < argc)
+                       bufstr_set(buf, ++j, sprintf("submit=%s", uri_escape(argv(i))));
+
+               if(j == 0) // no args: GET
+                       crypto_uri_postbuf(url, URI_GET_CURL + curl_uri_get_pos, string_null, string_null, -1, key);
+               else // with args: POST
+                       crypto_uri_postbuf(url, URI_GET_CURL + curl_uri_get_pos, "application/x-www-form-urlencoded", "&", buf, key);
+
+               curl_uri_get_pos = mod(curl_uri_get_pos + 1, URI_GET_CURL_END - URI_GET_CURL + 1);
+
+               buf_del(buf);
+
+               return;
+       }
+
 #if 0
        if(argv(0) == "tokentest")
        {
index 699548197bc668e151ee279eb061960ec77eb97d..761b63a83b30dc1a97990cdc7a172e6c53e3de40 100644 (file)
@@ -381,4 +381,5 @@ string(string format, ...) sprintf = #627;
 string crypto_getkeyfp(string serveraddress) = #633; // retrieves the cached host key's CA fingerprint of a server given by IP address
 string crypto_getidfp(string serveraddress) = #634; // retrieves the cached host key fingerprint of a server given by IP address
 string crypto_getencryptlevel(string serveraddress) = #635; // 0 if never encrypting, 1 supported, 2 requested, 3 required, appended by list of allowed methods in order of preference ("AES128"), preceded by a space each
+float(string url, float id, string content_type, string delim, float buf, float keyid) crypto_uri_postbuf = #513;
 //description:
index 6f5b037acff686485fba7aeef08c1b75ed2e118c..800f3488692b618f7b7ac917ba34ec004828a68c 100644 (file)
@@ -234,11 +234,6 @@ void setDependentWeird(entity e, float(entity) func)
 float _Nex_ExtResponseSystem_Queried;
 string _Nex_ExtResponseSystem_UpdateTo;
 
-float URI_GET_DISCARD = 0;
-
-float URI_GET_UPDATENOTIFICATION = 1;
-void UpdateNotification_URI_Get_Callback(float id, float status, string data);
-
 void URI_Get_Callback(float id, float status, string data)
 {
        if (id == URI_GET_DISCARD)
@@ -247,9 +242,12 @@ void URI_Get_Callback(float id, float status, string data)
        }
        else if(id == URI_GET_UPDATENOTIFICATION)
        {
-               // online ban list
                UpdateNotification_URI_Get_Callback(id, status, data);
        }
+       else if(id >= URI_GET_CURL && id <= URI_GET_CURL_END)
+       {
+               Curl_URI_Get_Callback(id, status, data);
+       }
        else
        {
                print("Received HTTP request data for an invalid id ", ftos(id), ".\n");
index 78eb7c1c43caa7cea3019c50652e7ab4173497db..ace912dc21394bbcde6a5a6e9398eb443eecbd7a 100644 (file)
@@ -20,3 +20,14 @@ string getZonedTooltipForIdentifier(string s);
 string resolvemod(string m);
 
 string HUD_Panel_GetSettingName(float setting);
+
+float URI_GET_DISCARD = 0;
+
+float URI_GET_UPDATENOTIFICATION = 1;
+void UpdateNotification_URI_Get_Callback(float id, float status, string data);
+
+float URI_GET_CURL = 2;
+float URI_GET_CURL_END = 9;
+void Curl_URI_Get_Callback(float id, float status, string data);
+
+void URI_Get_Callback(float id, float status, string data);