From bc01573d1b12cc8a102d1b8b22777d5bd71c3420 Mon Sep 17 00:00:00 2001 From: TimePath Date: Thu, 27 Aug 2015 09:38:54 +1000 Subject: [PATCH] Move urllib to /lib --- qcsrc/client/miscfunctions.qc | 1 - qcsrc/client/progs.src | 1 - qcsrc/common/constants.qh | 10 ------- qcsrc/common/playerstats.qc | 1 - qcsrc/lib/_all.inc | 1 + qcsrc/{common => lib}/urllib.qc | 34 ++++++++--------------- qcsrc/{common => lib}/urllib.qh | 12 ++++++++ qcsrc/menu/progs.src | 1 - qcsrc/menu/xonotic/util.qc | 1 - qcsrc/server/miscfunctions.qc | 1 - qcsrc/server/mutators/mutators_include.qc | 1 - qcsrc/server/progs.src | 1 - qcsrc/server/weapons/weaponstats.qc | 1 - 13 files changed, 24 insertions(+), 42 deletions(-) rename qcsrc/{common => lib}/urllib.qc (92%) rename qcsrc/{common => lib}/urllib.qh (70%) diff --git a/qcsrc/client/miscfunctions.qc b/qcsrc/client/miscfunctions.qc index 845a564106..c9c5999454 100644 --- a/qcsrc/client/miscfunctions.qc +++ b/qcsrc/client/miscfunctions.qc @@ -7,7 +7,6 @@ #include "../common/command/generic.qh" #include "../common/teams.qh" -#include "../common/urllib.qh" #include "../common/util.qh" #include "../csqcmodellib/cl_model.qh" diff --git a/qcsrc/client/progs.src b/qcsrc/client/progs.src index b9006dd2c6..3c6ccc1c6f 100644 --- a/qcsrc/client/progs.src +++ b/qcsrc/client/progs.src @@ -53,7 +53,6 @@ weapons/projectile.qc // TODO ../common/playerstats.qc ../common/p2mathlib.qc ../common/test.qc -../common/urllib.qc ../common/util.qc ../common/viewloc.qc diff --git a/qcsrc/common/constants.qh b/qcsrc/common/constants.qh index bc18b4dc7a..7078401883 100644 --- a/qcsrc/common/constants.qh +++ b/qcsrc/common/constants.qh @@ -362,16 +362,6 @@ const int SPAWN_PRIO_NEAR_TEAMMATE_SAMETEAM = 100; const int SPAWN_PRIO_RACE_PREVIOUS_SPAWN = 50; const int SPAWN_PRIO_GOOD_DISTANCE = 10; -// URI handles -const int URI_GET_DISCARD = 0; -const int URI_GET_IPBAN = 1; -const int URI_GET_IPBAN_END = 16; -const int URI_GET_CURL = 17; -const int URI_GET_CURL_END = 32; -const int URI_GET_UPDATENOTIFICATION = 33; -const int URI_GET_URLLIB = 128; -const int URI_GET_URLLIB_END = 191; - // gametype vote flags const int GTV_FORBIDDEN = 0; // Cannot be voted const int GTV_AVAILABLE = 1; // Can be voted diff --git a/qcsrc/common/playerstats.qc b/qcsrc/common/playerstats.qc index e46e12fa1e..ea783a12d6 100644 --- a/qcsrc/common/playerstats.qc +++ b/qcsrc/common/playerstats.qc @@ -5,7 +5,6 @@ #include "../dpdefs/dpextensions.qh" #include "constants.qh" #include "util.qh" - #include "urllib.qh" #include "weapons/all.qh" #include "../server/weapons/accuracy.qh" #include "../server/defs.qh" diff --git a/qcsrc/lib/_all.inc b/qcsrc/lib/_all.inc index 410eac721a..1e7b85f489 100644 --- a/qcsrc/lib/_all.inc +++ b/qcsrc/lib/_all.inc @@ -7,3 +7,4 @@ #include "OO.qh" #include "Progname.qh" #include "Registry.qh" +#include "urllib.qc" diff --git a/qcsrc/common/urllib.qc b/qcsrc/lib/urllib.qc similarity index 92% rename from qcsrc/common/urllib.qc rename to qcsrc/lib/urllib.qc index 8529ebd6dd..ce8de504b0 100644 --- a/qcsrc/common/urllib.qc +++ b/qcsrc/lib/urllib.qc @@ -1,16 +1,4 @@ -#if defined(CSQC) - #include "../dpdefs/csprogsdefs.qh" - #include "constants.qh" - #include "util.qh" - #include "urllib.qh" -#elif defined(MENUQC) -#elif defined(SVQC) - #include "../dpdefs/progsdefs.qh" - #include "../dpdefs/dpextensions.qh" - #include "constants.qh" - #include "util.qh" - #include "urllib.qh" -#endif +#include "urllib.qh" // files .float url_fh; @@ -52,7 +40,7 @@ float url_URI_Get_Callback(int id, float status, string data) } // whatever happens, we will remove the URL from the list of IDs - url_fromid[id] = world; + url_fromid[id] = NULL; // if we get here, we MUST have both buffers cleared if(e.url_rbuf != -1 || e.url_wbuf != -1 || e.url_fh != URL_FH_CURL) @@ -135,17 +123,17 @@ void url_single_fopen(string url, int mode, url_ready_func rdy, entity pass) // get slot for HTTP request for(i = autocvar__urllib_nextslot; i < NUM_URL_ID; ++i) - if(url_fromid[i] == world) + if(url_fromid[i] == NULL) break; if(i >= NUM_URL_ID) { for(i = 0; i < autocvar__urllib_nextslot; ++i) - if(url_fromid[i] == world) + if(url_fromid[i] == NULL) break; if(i >= autocvar__urllib_nextslot) { print("url_single_fopen: too many concurrent requests\n"); - rdy(world, pass, URL_READY_ERROR); + rdy(NULL, pass, URL_READY_ERROR); return; } } @@ -154,7 +142,7 @@ void url_single_fopen(string url, int mode, url_ready_func rdy, entity pass) if(!crypto_uri_postbuf(url, i + MIN_URL_ID, string_null, string_null, -1, 0)) { print("url_single_fopen: failure in crypto_uri_postbuf\n"); - rdy(world, pass, URL_READY_ERROR); + rdy(NULL, pass, URL_READY_ERROR); return; } @@ -192,7 +180,7 @@ void url_single_fopen(string url, int mode, url_ready_func rdy, entity pass) break; case FILE_READ: print("url_single_fopen: cannot open '-' for reading\n"); - rdy(world, pass, URL_READY_ERROR); + rdy(NULL, pass, URL_READY_ERROR); break; } } @@ -202,7 +190,7 @@ void url_single_fopen(string url, int mode, url_ready_func rdy, entity pass) fh = fopen(url, mode); if(fh < 0) { - rdy(world, pass, URL_READY_ERROR); + rdy(NULL, pass, URL_READY_ERROR); return; } else @@ -238,12 +226,12 @@ void url_fclose(entity e) // get slot for HTTP request for(i = autocvar__urllib_nextslot; i < NUM_URL_ID; ++i) - if(url_fromid[i] == world) + if(url_fromid[i] == NULL) break; if(i >= NUM_URL_ID) { for(i = 0; i < autocvar__urllib_nextslot; ++i) - if(url_fromid[i] == world) + if(url_fromid[i] == NULL) break; if(i >= autocvar__urllib_nextslot) { @@ -384,7 +372,7 @@ void url_multi_fopen(string url, int mode, url_ready_func rdy, entity pass) if(n <= 0) { print("url_multi_fopen: need at least one URL\n"); - rdy(world, pass, URL_READY_ERROR); + rdy(NULL, pass, URL_READY_ERROR); return; } diff --git a/qcsrc/common/urllib.qh b/qcsrc/lib/urllib.qh similarity index 70% rename from qcsrc/common/urllib.qh rename to qcsrc/lib/urllib.qh index d58a0b1aaf..6f19678517 100644 --- a/qcsrc/common/urllib.qh +++ b/qcsrc/lib/urllib.qh @@ -1,6 +1,18 @@ #ifndef URLLIB_H #define URLLIB_H +#include "../common/util.qh" + +// URI handles +const int URI_GET_DISCARD = 0; +const int URI_GET_IPBAN = 1; +const int URI_GET_IPBAN_END = 16; +const int URI_GET_CURL = 17; +const int URI_GET_CURL_END = 32; +const int URI_GET_UPDATENOTIFICATION = 33; +const int URI_GET_URLLIB = 128; +const int URI_GET_URLLIB_END = 191; + const float URL_READY_ERROR = -1; const float URL_READY_CLOSED = 0; const float URL_READY_CANWRITE = 1; diff --git a/qcsrc/menu/progs.src b/qcsrc/menu/progs.src index 0a1a715f0a..4192c69917 100644 --- a/qcsrc/menu/progs.src +++ b/qcsrc/menu/progs.src @@ -21,7 +21,6 @@ xonotic/util.qc ../common/mapinfo.qc ../common/playerstats.qc ../common/test.qc -../common/urllib.qc ../common/util.qc ../common/items/all.qc diff --git a/qcsrc/menu/xonotic/util.qc b/qcsrc/menu/xonotic/util.qc index a50fb4cb19..a5fa9da476 100644 --- a/qcsrc/menu/xonotic/util.qc +++ b/qcsrc/menu/xonotic/util.qc @@ -4,7 +4,6 @@ #include "../../common/campaign_common.qh" #include "../../common/constants.qh" #include "../../common/mapinfo.qh" -#include "../../common/urllib.qh" #include "../../common/util.qh" #include "../../common/command/generic.qh" diff --git a/qcsrc/server/miscfunctions.qc b/qcsrc/server/miscfunctions.qc index e757e01729..71fb2de5e6 100644 --- a/qcsrc/server/miscfunctions.qc +++ b/qcsrc/server/miscfunctions.qc @@ -18,7 +18,6 @@ #include "../common/playerstats.qh" #include "../common/teams.qh" #include "../common/triggers/subs.qh" -#include "../common/urllib.qh" #include "../common/util.qh" #include "../common/turrets/sv_turrets.qh" #include "../common/weapons/all.qh" diff --git a/qcsrc/server/mutators/mutators_include.qc b/qcsrc/server/mutators/mutators_include.qc index 1286317eb3..a703fdc19b 100644 --- a/qcsrc/server/mutators/mutators_include.qc +++ b/qcsrc/server/mutators/mutators_include.qc @@ -15,7 +15,6 @@ #include "../../common/nades.qh" #include "../../common/buffs.qh" #include "../../common/test.qh" - #include "../../common/urllib.qh" #include "../../common/command/markup.qh" #include "../../common/command/rpn.qh" #include "../../common/command/generic.qh" diff --git a/qcsrc/server/progs.src b/qcsrc/server/progs.src index 4aea59eb6d..0cf64cae33 100644 --- a/qcsrc/server/progs.src +++ b/qcsrc/server/progs.src @@ -102,7 +102,6 @@ weapons/weaponsystem.qc ../common/test.qc ../common/viewloc.qc ../common/triggers/include.qc -../common/urllib.qc ../common/util.qc ../common/items/all.qc diff --git a/qcsrc/server/weapons/weaponstats.qc b/qcsrc/server/weapons/weaponstats.qc index a84969904a..09d2770467 100644 --- a/qcsrc/server/weapons/weaponstats.qc +++ b/qcsrc/server/weapons/weaponstats.qc @@ -3,7 +3,6 @@ #include "../g_world.qh" -#include "../../common/urllib.qh" #include "../../common/weapons/all.qh" void WeaponStats_Init() -- 2.39.2