diff include/core/http.h @ 397:811697ad826a

http: do proper global init/cleanup of libcurl this is done automagically using RAII
author Paper <paper@tflc.us>
date Fri, 07 Nov 2025 08:39:24 -0500
parents 963047512d34
children
line wrap: on
line diff
--- a/include/core/http.h	Fri Nov 07 07:56:03 2025 -0500
+++ b/include/core/http.h	Fri Nov 07 08:39:24 2025 -0500
@@ -11,6 +11,17 @@
 
 namespace HTTP {
 
+/* Global state init/quit */
+void Init();
+void Quit();
+
+/* helper class that automatically init/deinit as constructors
+ * and destructors */
+struct Initializer {
+	Initializer() { Init(); }
+	~Initializer() { Quit(); }
+};
+
 /* calls libcurl to encode/decode */
 std::string UrlEncode(const std::string &data);
 std::string UrlDecode(const std::string &data);