aboutsummaryrefslogtreecommitdiffstats
path: root/src/main.c
diff options
context:
space:
mode:
authorLibravatar bigfoot547 <[email protected]>2023-12-24 04:26:00 -0600
committerLibravatar bigfoot547 <[email protected]>2023-12-24 04:26:00 -0600
commit20d9fc5b5356a1054cb104ba6651b77184abf0db (patch)
tree5f115d8051dad73069d3a632a6f2c260cf7efdac /src/main.c
initial commit
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c58
1 files changed, 58 insertions, 0 deletions
diff --git a/src/main.c b/src/main.c
new file mode 100644
index 0000000..958f0b0
--- /dev/null
+++ b/src/main.c
@@ -0,0 +1,58 @@
+#include <stdio.h>
+
+#if 0
+struct res_buf {
+ void *data;
+ size_t len, cap;
+};
+
+size_t launcher_write_response(char *ptr, size_t size, size_t nmemb, void *userdata)
+{
+ ((void)size);
+ struct res_buf *rb = userdata;
+ if (nmemb == 0) return 0;
+
+ /* it is documented that size is always 1 */
+
+ if (rb->len + nmemb > rb->cap) {
+ size_t newcap = rb->cap;
+ while (newcap < rb->len + nmemb) newcap <<= 1;
+ rb->data = realloc(rb->data, newcap); /* assume it worked lol */
+ rb->cap = newcap;
+ }
+
+ memcpy((unsigned char *)rb->data + rb->len, ptr, nmemb);
+ rb->len += nmemb;
+ return nmemb;
+}
+
+int main(void)
+{
+ CURL *c = curl_easy_init();
+ struct res_buf rb;
+
+ rb.data = malloc(16);
+ rb.len = 0;
+ rb.cap = 16;
+
+ curl_easy_setopt(c, CURLOPT_URL, "https://launchermeta.mojang.com/mc/game/version_manifest_v2.json");
+ curl_easy_setopt(c, CURLOPT_WRITEFUNCTION, &launcher_write_response);
+ curl_easy_setopt(c, CURLOPT_WRITEDATA, &rb);
+
+ CURLcode res = curl_easy_perform(c);
+ if (res != CURLE_OK) {
+ fprintf(stderr, "%s\n", "uh oh curl failed :((((");
+ return 1;
+ }
+
+ curl_easy_cleanup(c);
+
+
+ printf("%s\n", "amogus amogus :))))");
+ printf("%zu %zu\n", rb.len, rb.cap);
+
+ fwrite(rb.data, rb.len, 1, stdout);
+ free(rb.data);
+ return 0;
+}
+#endif