mirror of
https://github.com/Aurorastation/Aurora.3.git
synced 2026-08-26 06:22:26 +01:00
Update rust_g to 0.5.0+a2 (#12865)
Co-authored-by: Werner <Arrow768@users.noreply.github.com>
This commit is contained in:
+60
-11
@@ -38,21 +38,70 @@
|
||||
#define RUST_G (__rust_g || __detect_rust_g())
|
||||
#endif
|
||||
|
||||
#define WRITE_LOG(log, text) dll_call(RUST_G, "log_write", log, text) // Using Rust g dll to log faster with less CPU usage.
|
||||
/// Gets the version of rust_g
|
||||
/proc/rustg_get_version() return call(RUST_G, "get_version")()
|
||||
|
||||
#define rustg_dmi_strip_metadata(fname) call(RUST_G, "dmi_strip_metadata")(fname)
|
||||
#define rustg_dmi_create_png(path, width, height, data) call(RUST_G, "dmi_create_png")(path, width, height, data)
|
||||
#define rustg_dmi_resize_png(path, width, height, resizetype) call(RUST_G, "dmi_resize_png")(path, width, height, resizetype)
|
||||
|
||||
#define rustg_file_read(fname) call(RUST_G, "file_read")(fname)
|
||||
#define rustg_file_exists(fname) call(RUST_G, "file_exists")(fname)
|
||||
#define rustg_file_write(text, fname) call(RUST_G, "file_write")(text, fname)
|
||||
#define rustg_file_append(text, fname) call(RUST_G, "file_append")(text, fname)
|
||||
|
||||
#ifdef RUSTG_OVERRIDE_BUILTINS
|
||||
#define file2text(fname) rustg_file_read("[fname]")
|
||||
#define text2file(text, fname) rustg_file_append(text, "[fname]")
|
||||
#endif
|
||||
|
||||
#define rustg_git_revparse(rev) call(RUST_G, "rg_git_revparse")(rev)
|
||||
#define rustg_git_commit_date(rev) call(RUST_G, "rg_git_commit_date")(rev)
|
||||
|
||||
#define rustg_hash_string(algorithm, text) call(RUST_G, "hash_string")(algorithm, text)
|
||||
#define rustg_hash_file(algorithm, fname) call(RUST_G, "hash_file")(algorithm, fname)
|
||||
#define rustg_hash_generate_totp(seed) call(RUST_G, "generate_totp")(seed)
|
||||
#define rustg_hash_generate_totp_tolerance(seed, tolerance) call(RUST_G, "generate_totp_tolerance")(seed, tolerance)
|
||||
|
||||
#define RUSTG_HASH_MD5 "md5"
|
||||
#define RUSTG_HASH_SHA1 "sha1"
|
||||
#define RUSTG_HASH_SHA256 "sha256"
|
||||
#define RUSTG_HASH_SHA512 "sha512"
|
||||
#define RUSTG_HASH_XXH64 "xxh64"
|
||||
#define RUSTG_HASH_BASE64 "base64"
|
||||
|
||||
#ifdef RUSTG_OVERRIDE_BUILTINS
|
||||
#define md5(thing) (isfile(thing) ? rustg_hash_file(RUSTG_HASH_MD5, "[thing]") : rustg_hash_string(RUSTG_HASH_MD5, thing))
|
||||
#endif
|
||||
|
||||
#define RUSTG_HTTP_METHOD_GET "get"
|
||||
#define RUSTG_HTTP_METHOD_PUT "put"
|
||||
#define RUSTG_HTTP_METHOD_DELETE "delete"
|
||||
#define RUSTG_HTTP_METHOD_PATCH "patch"
|
||||
#define RUSTG_HTTP_METHOD_HEAD "head"
|
||||
#define RUSTG_HTTP_METHOD_POST "post"
|
||||
#define rustg_http_request_blocking(method, url, body, headers, options) call(RUST_G, "http_request_blocking")(method, url, body, headers, options)
|
||||
#define rustg_http_request_async(method, url, body, headers, options) call(RUST_G, "http_request_async")(method, url, body, headers, options)
|
||||
#define rustg_http_check_request(req_id) call(RUST_G, "http_check_request")(req_id)
|
||||
|
||||
#define RUSTG_JOB_NO_RESULTS_YET "NO RESULTS YET"
|
||||
#define RUSTG_JOB_NO_SUCH_JOB "NO SUCH JOB"
|
||||
#define RUSTG_JOB_ERROR "JOB PANICKED"
|
||||
|
||||
#define rustg_udp_shipper_send(addr, text) dll_call(RUST_G, "udp_shipper_send", addr, text)
|
||||
#define rustg_log_write(fname, text, format) call(RUST_G, "log_write")(fname, text, format)
|
||||
/proc/rustg_log_close_all() return call(RUST_G, "log_close_all")()
|
||||
|
||||
#define RUSTG_HTTP_METHOD_GET "get"
|
||||
#define RUSTG_HTTP_METHOD_POST "post"
|
||||
#define RUSTG_HTTP_METHOD_PUT "put"
|
||||
#define RUSTG_HTTP_METHOD_DELETE "delete"
|
||||
#define RUSTG_HTTP_METHOD_PATCH "patch"
|
||||
#define RUSTG_HTTP_METHOD_HEAD "head"
|
||||
#define rustg_time_microseconds(id) text2num(call(RUST_G, "time_microseconds")(id))
|
||||
#define rustg_time_milliseconds(id) text2num(call(RUST_G, "time_milliseconds")(id))
|
||||
#define rustg_time_reset(id) call(RUST_G, "time_reset")(id)
|
||||
|
||||
#define rustg_udp_send(addr, text) call(RUST_G, "udp_send")(addr, text)
|
||||
|
||||
#define rustg_url_encode(text) call(RUST_G, "url_encode")("[text]")
|
||||
#define rustg_url_decode(text) call(RUST_G, "url_decode")(text)
|
||||
|
||||
#ifdef RUSTG_OVERRIDE_BUILTINS
|
||||
#define url_encode(text) rustg_url_encode(text)
|
||||
#define url_decode(text) rustg_url_decode(text)
|
||||
#endif
|
||||
|
||||
#define rustg_http_request_blocking(method, url, body, headers) dll_call(RUST_G, "http_request_blocking", method, url, body, headers)
|
||||
#define rustg_http_request_async(method, url, body, headers) dll_call(RUST_G, "http_request_async", method, url, body, headers)
|
||||
#define rustg_http_check_request(req_id) dll_call(RUST_G, "http_check_request", req_id)
|
||||
|
||||
@@ -12,6 +12,9 @@
|
||||
#define SEVERITY_INFO 6 //Informational: informational messages
|
||||
#define SEVERITY_DEBUG 7 //Debug: debug-level messages
|
||||
|
||||
#define WRITE_LOG(log, text) rustg_log_write(log, text, "true")
|
||||
#define WRITE_LOG_NO_FORMAT(log, text) rustg_log_write(log, text, "false")
|
||||
|
||||
/var/global/log_end = world.system_type == UNIX ? ascii2text(13) : ""
|
||||
|
||||
// logging.dm
|
||||
|
||||
@@ -30,10 +30,12 @@
|
||||
var/body
|
||||
var/headers
|
||||
var/url
|
||||
/// If present response body will be saved to this file.
|
||||
var/output_file
|
||||
|
||||
var/_raw_response
|
||||
|
||||
/datum/http_request/proc/prepare(method, url, body = "", list/headers)
|
||||
/datum/http_request/proc/prepare(method, url, body = "", list/headers, output_file)
|
||||
if (!length(headers))
|
||||
headers = ""
|
||||
else
|
||||
@@ -43,15 +45,16 @@
|
||||
src.url = url
|
||||
src.body = body
|
||||
src.headers = headers
|
||||
src.output_file = output_file
|
||||
|
||||
/datum/http_request/proc/execute_blocking()
|
||||
_raw_response = rustg_http_request_blocking(method, url, body, headers)
|
||||
_raw_response = rustg_http_request_blocking(method, url, body, headers, build_options())
|
||||
|
||||
/datum/http_request/proc/begin_async()
|
||||
if (in_progress)
|
||||
crash_with("Attempted to re-use a request object.")
|
||||
|
||||
id = rustg_http_request_async(method, url, body, headers)
|
||||
id = rustg_http_request_async(method, url, body, headers, build_options())
|
||||
|
||||
if (isnull(text2num(id)))
|
||||
crash_with("Proc error: [id]")
|
||||
@@ -59,6 +62,11 @@
|
||||
else
|
||||
in_progress = TRUE
|
||||
|
||||
/datum/http_request/proc/build_options()
|
||||
if(output_file)
|
||||
return json_encode(list("output_filename"=output_file,"body_filename"=null))
|
||||
return "{}"
|
||||
|
||||
/datum/http_request/proc/is_complete()
|
||||
if (isnull(id))
|
||||
return TRUE
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
|
||||
The prerequisite for using this is rustg compiled with the udp_shipper feature.
|
||||
|
||||
Rustg's rustg_udp_shipper_send function is used to send data.
|
||||
Rustg's rustg_udp_send function is used to send data.
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -37,17 +37,17 @@
|
||||
*/
|
||||
/proc/send_udp_data(addr, data)
|
||||
#ifdef RUST_G
|
||||
# ifndef rustg_udp_shipper_send
|
||||
# error rustg_udp_shipper_send macro is not defined for rustg.
|
||||
# endif // rustg_udp_shipper_send
|
||||
# ifndef rustg_udp_send
|
||||
# error rustg_udp_send macro is not defined for rustg.
|
||||
# endif // rustg_udp_send
|
||||
|
||||
if (!addr || !data)
|
||||
return "Not enough args."
|
||||
|
||||
. = rustg_udp_shipper_send(addr, data)
|
||||
. = rustg_udp_send(addr, data)
|
||||
|
||||
if (.)
|
||||
error("UDP Shipper error: [.]")
|
||||
error("UDP Sender error: [.]")
|
||||
|
||||
#else
|
||||
return
|
||||
|
||||
Binary file not shown.
BIN
Binary file not shown.
Reference in New Issue
Block a user