Added tons of AI generated docs and a lot of cleanups. No code changes. (0.41.5)
This commit is contained in:
parent
24c54fba41
commit
4e69a3ce63
151 changed files with 3897 additions and 427 deletions
|
|
@ -1,5 +1,41 @@
|
|||
/**
|
||||
* libcurl DOWNLOAD builtin
|
||||
* This file is part of the Fun programming language.
|
||||
* https://fun-lang.xyz/
|
||||
*
|
||||
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
||||
* Licensed under the terms of the Apache-2.0 license.
|
||||
* https://opensource.org/license/apache-2-0
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file download.c
|
||||
* @brief Fun VM opcode snippet: HTTP download to file via libcurl (OP_CURL_DOWNLOAD).
|
||||
*
|
||||
* This snippet is included by vm.c and implements the OP_CURL_DOWNLOAD
|
||||
* instruction. When FUN_WITH_CURL is enabled, it downloads the content at
|
||||
* the given URL and writes it to the specified filesystem path.
|
||||
*
|
||||
* Stack behavior:
|
||||
* - Pops: path:string, url:string (values are converted via value_to_string_alloc)
|
||||
* - Pushes: int (1 on success, 0 on error or when CURL is disabled)
|
||||
*
|
||||
* Error handling:
|
||||
* - Returns 0 if URL/path conversion fails, file open fails, CURL init
|
||||
* or perform fails.
|
||||
* - Follows redirects (CURLOPT_FOLLOWLOCATION = 1L).
|
||||
* - Writes via fun_curl_file_write_cb directly into the opened FILE*.
|
||||
*
|
||||
* Notes:
|
||||
* - All temporary allocations (URL, path) are freed; FILE* is closed.
|
||||
* - On builds without FUN_WITH_CURL, consumes two values and pushes 0.
|
||||
*/
|
||||
/**
|
||||
* @brief Opcode handler for OP_CURL_DOWNLOAD.
|
||||
*
|
||||
* Pops a destination path and URL, streams the HTTP response body
|
||||
* into the file, and pushes 1 on success or 0 on any error. Without
|
||||
* FUN_WITH_CURL, behaves as a no-op that consumes two values and
|
||||
* pushes 0.
|
||||
*/
|
||||
case OP_CURL_DOWNLOAD: {
|
||||
#ifdef FUN_WITH_CURL
|
||||
|
|
|
|||
|
|
@ -1,5 +1,42 @@
|
|||
/**
|
||||
* libcurl GET builtin
|
||||
* This file is part of the Fun programming language.
|
||||
* https://fun-lang.xyz/
|
||||
*
|
||||
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
||||
* Licensed under the terms of the Apache-2.0 license.
|
||||
* https://opensource.org/license/apache-2-0
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file get.c
|
||||
* @brief Fun VM opcode snippet: HTTP GET via libcurl (OP_CURL_GET).
|
||||
*
|
||||
* This snippet is included by vm.c and implements the OP_CURL_GET
|
||||
* instruction. When FUN_WITH_CURL is enabled, it performs an HTTP GET
|
||||
* request for the provided URL and pushes the response body as a string.
|
||||
* If libcurl support is not built in, or an error occurs, an empty string
|
||||
* is pushed instead.
|
||||
*
|
||||
* Stack behavior:
|
||||
* - Pops: url:string (any value is converted via value_to_string_alloc)
|
||||
* - Pushes: body:string ("" on error or when CURL is disabled)
|
||||
*
|
||||
* Error handling:
|
||||
* - If URL conversion fails or CURL initialization/performance fails,
|
||||
* the opcode pushes an empty string.
|
||||
* - Follows HTTP redirects (CURLOPT_FOLLOWLOCATION = 1L).
|
||||
*
|
||||
* Notes:
|
||||
* - Uses FunCurlBuf and fun_curl_write_cb from the curl extension helpers.
|
||||
* - Memory allocated for temporary strings and buffers is freed before exit.
|
||||
*/
|
||||
/**
|
||||
* @brief Opcode handler for OP_CURL_GET.
|
||||
*
|
||||
* Converts the top stack value to a URL string, issues a GET request
|
||||
* using libcurl, and pushes the response body as a string. When
|
||||
* compiled without FUN_WITH_CURL, the opcode becomes a no-op that
|
||||
* consumes one value and pushes an empty string.
|
||||
*/
|
||||
case OP_CURL_GET: {
|
||||
#ifdef FUN_WITH_CURL
|
||||
|
|
|
|||
|
|
@ -1,5 +1,42 @@
|
|||
/**
|
||||
* libcurl POST builtin
|
||||
* This file is part of the Fun programming language.
|
||||
* https://fun-lang.xyz/
|
||||
*
|
||||
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
||||
* Licensed under the terms of the Apache-2.0 license.
|
||||
* https://opensource.org/license/apache-2-0
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file post.c
|
||||
* @brief Fun VM opcode snippet: HTTP POST via libcurl (OP_CURL_POST).
|
||||
*
|
||||
* This snippet is included by vm.c and implements the OP_CURL_POST
|
||||
* instruction. When FUN_WITH_CURL is enabled, it performs an HTTP POST
|
||||
* to the given URL with the provided request body and pushes the response
|
||||
* body as a string. If libcurl support is not built in, or an error occurs,
|
||||
* an empty string is pushed instead.
|
||||
*
|
||||
* Stack behavior:
|
||||
* - Pops: body:string, url:string (values are converted via value_to_string_alloc)
|
||||
* - Pushes: body:string (server response; "" on error or when CURL is disabled)
|
||||
*
|
||||
* Error handling:
|
||||
* - If URL conversion fails, the opcode pushes an empty string and discards
|
||||
* any converted body.
|
||||
* - Follows redirects (CURLOPT_FOLLOWLOCATION = 1L).
|
||||
* - Sets CURLOPT_POST=1L and CURLOPT_POSTFIELDS to submit the body.
|
||||
*
|
||||
* Notes:
|
||||
* - Uses FunCurlBuf and fun_curl_write_cb from the curl extension helpers.
|
||||
* - All temporary allocations (URL, body, response buffer) are freed.
|
||||
*/
|
||||
/**
|
||||
* @brief Opcode handler for OP_CURL_POST.
|
||||
*
|
||||
* Pops the POST body and URL, performs an HTTP POST, and pushes the
|
||||
* response as a string. Without FUN_WITH_CURL, consumes two values and
|
||||
* pushes an empty string.
|
||||
*/
|
||||
case OP_CURL_POST: {
|
||||
#ifdef FUN_WITH_CURL
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue