Fun 0.41.5
The programming language that makes You have fun
Loading...
Searching...
No Matches
curl.c
Go to the documentation of this file.
1/*
2 * This file is part of the Fun programming language.
3 * https://fun-lang.xyz/
4 *
5 * Copyright 2025 Johannes Findeisen <you@hanez.org>
6 * Licensed under the terms of the Apache-2.0 license.
7 * https://opensource.org/license/apache-2-0
8 */
9
17
18/* Ensure libcurl headers and helpers are defined at file scope (not inside vm_run) */
19#ifdef FUN_WITH_CURL
20#include <curl/curl.h>
21
28typedef struct {
29 char *d;
30 size_t n;
31} FunCurlBuf;
32
45static size_t fun_curl_write_cb(void *ptr, size_t sz, size_t nm, void *ud) {
46 size_t add = sz * nm;
47 FunCurlBuf *b = (FunCurlBuf *)ud;
48 char *p = (char *)realloc(b->d, b->n + add + 1);
49 if (!p) return 0;
50 memcpy(p + b->n, ptr, add);
51 b->d = p;
52 b->n += add;
53 b->d[b->n] = '\0';
54 return add;
55}
56
66static size_t fun_curl_file_write_cb(void *ptr, size_t sz, size_t nm, void *ud) {
67 FILE *f = (FILE *)ud;
68 return fwrite(ptr, sz, nm, f);
69}
70#endif
uint32_t b
Definition band.c:32
int n
Definition insert.c:41
FILE * f
Definition read_file.c:38
const char * p
Definition read_file.c:37
long sz
Definition read_file.c:50