Fun
0.41.5
The programming language that makes You have fun
Main Page
Data Structures
Files
File List
Globals
Loading...
Searching...
No Matches
src
vm
ini
save.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
25
26
/* OP_INI_SAVE */
27
#ifdef FUN_WITH_INI
28
case
OP_INI_SAVE
: {
29
Value
vpath
= pop_value(vm);
30
Value
vh
= pop_value(vm);
31
const
char
*
path
= (
vpath
.type ==
VAL_STRING
) ?
vpath
.s : NULL;
32
dictionary *d = ini_get((
vh
.type ==
VAL_INT
) ? (
int
)
vh
.i : 0);
33
int
ok
= 0;
34
if
(d &&
path
) {
35
FILE *
f
= fopen(
path
,
"w"
);
36
if
(
f
) {
37
iniparser_dump_ini(d,
f
);
38
fclose
(
f
);
39
ok
= 1;
40
}
41
}
42
free_value
(
vpath
);
43
free_value
(
vh
);
44
push_value(vm,
make_int
(
ok
));
45
break
;
46
}
47
#endif
OP_INI_SAVE
@ OP_INI_SAVE
Definition
bytecode.h:211
ok
int ok
Definition
contains.c:38
fclose
fclose(f)
f
FILE * f
Definition
read_file.c:38
Value
Tagged union representing a Fun value.
Definition
value.h:68
vh
Value vh
Definition
stubs.c:44
vpath
void vpath
Definition
stubs.c:23
free_value
void free_value(Value v)
Free dynamic storage owned by a Value.
Definition
value.c:517
make_int
Value make_int(int64_t v)
Construct a Value representing a 64-bit integer.
Definition
value.c:51
VAL_STRING
@ VAL_STRING
Definition
value.h:53
VAL_INT
@ VAL_INT
Definition
value.h:51
path
Value path
Definition
write_file.c:33
Generated on
for Fun by
1.16.1