Added support for .ini files (iniparser). (0.34.0)
This commit is contained in:
parent
49261b96c2
commit
fb5670a699
18 changed files with 710 additions and 5 deletions
29
src/vm/ini/load.c
Normal file
29
src/vm/ini/load.c
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
/*
|
||||
* 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
|
||||
*
|
||||
* Added: 2025-11-30
|
||||
*/
|
||||
|
||||
/* OP_INI_LOAD: pops path string; pushes handle (>0) or 0 */
|
||||
#ifdef FUN_WITH_INI
|
||||
case OP_INI_LOAD: {
|
||||
Value vpath = pop_value(vm);
|
||||
const char *path = (vpath.type == VAL_STRING && vpath.s) ? vpath.s : NULL;
|
||||
int h = 0;
|
||||
if (path) {
|
||||
dictionary *d = iniparser_load(path);
|
||||
if (d) {
|
||||
h = ini_alloc_handle(d);
|
||||
if (!h) { iniparser_freedict(d); }
|
||||
}
|
||||
}
|
||||
free_value(vpath);
|
||||
push_value(vm, make_int(h));
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue