}
e.url_wbufpos = 0;
e.url_rbuf = -1;
+ e.url_ready = rdy;
+ e.url_ready_pass = pass;
rdy(e, pass, URL_READY_CANWRITE);
break;
e = spawn();
e.classname = "url_single_fopen_stdout";
e.url_fh = URL_FH_STDOUT;
+ e.url_ready = rdy;
+ e.url_ready_pass = pass;
rdy(e, pass, URL_READY_CANWRITE);
break;
case FILE_READ:
e = spawn();
e.classname = "url_single_fopen_file";
e.url_fh = fh;
+ e.url_ready = rdy;
+ e.url_ready_pass = pass;
if(mode == FILE_READ)
rdy(e, pass, URL_READY_CANREAD);
else
}
// close a file
-void url_fclose(entity e, url_ready_func rdy, entity pass)
+void url_fclose(entity e)
{
float i;
if(i >= autocvar__urllib_nextslot)
{
print("url_fclose: too many concurrent requests\n");
- rdy(e, pass, URL_READY_ERROR);
+ e.url_ready(e,e.url_ready_pass, URL_READY_ERROR);
buf_del(e.url_wbuf);
strunzone(e.url_url);
remove(e);
if(!crypto_uri_postbuf(e.url_url, i + MIN_URL_ID, "text/plain", "", e.url_wbuf, 0))
{
print("url_fclose: failure in crypto_uri_postbuf\n");
- rdy(e, pass, URL_READY_ERROR);
+ e.url_ready(e, e.url_ready_pass, URL_READY_ERROR);
buf_del(e.url_wbuf);
strunzone(e.url_url);
remove(e);
// call the callback
buf_del(e.url_wbuf);
e.url_wbuf = -1;
- e.url_ready = rdy;
- e.url_ready_pass = pass;
e.url_id = i;
url_fromid[i] = e;
else
{
// we have READ all data, just close
- rdy(e, pass, URL_READY_CLOSED);
+ e.url_ready(e, e.url_ready_pass, URL_READY_CLOSED);
buf_del(e.url_rbuf);
strunzone(e.url_url);
remove(e);
}
else if(e.url_fh == URL_FH_STDOUT)
{
- rdy(e, pass, URL_READY_CLOSED); // closing creates no reading handle
+ e.url_ready(e, e.url_ready_pass, URL_READY_CLOSED); // closing creates no reading handle
remove(e);
}
else
{
// file
fclose(e.url_fh);
- rdy(e, pass, URL_READY_CLOSED); // closing creates no reading handle
+ e.url_ready(e, e.url_ready_pass, URL_READY_CLOSED); // closing creates no reading handle
remove(e);
}
}
typedef void(entity handle, entity pass, float status) url_ready_func;
void url_single_fopen(string url, float mode, url_ready_func rdy, entity pass);
-void url_fclose(entity e, url_ready_func rdy, entity pass);
+void url_fclose(entity e);
string url_fgets(entity e);
void url_fputs(entity e, string s);
}
}
url_fputs(fh, "#end\n\n");
- url_fclose(fh, WeaponStats_ready, world);
+ url_fclose(fh);
break;
case URL_READY_CANREAD:
// url_fclose is processing, we got a response for writing the data
while((s = url_fgets(fh)))
print(" ", s, "\n");
print("End of response.\n");
- url_fclose(fh, WeaponStats_ready, world);
+ url_fclose(fh);
break;
case URL_READY_CLOSED:
// url_fclose has finished
}
}
url_fputs(fh, "\n");
- url_fclose(fh, PlayerStats_ready, world);
+ url_fclose(fh);
break;
case URL_READY_CANREAD:
// url_fclose is processing, we got a response for writing the data
while((s = url_fgets(fh)))
print(" ", s, "\n");
print("End of response.\n");
- url_fclose(fh, PlayerStats_ready, world);
+ url_fclose(fh);
break;
case URL_READY_CLOSED:
// url_fclose has finished