Fun 0.41.5
The programming language that makes You have fun
Loading...
Searching...
No Matches
open.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
22#ifdef FUN_WITH_SQLITE
23 Value vpath = pop_value(vm);
26 if (!path) {
27 push_value(vm, make_int(0));
28 break;
29 }
30 sqlite3 *db = NULL;
31 int rc = sqlite3_open(path, &db);
32 free(path);
33 if (rc != SQLITE_OK || !db) {
34 if (db) sqlite3_close(db);
35 push_value(vm, make_int(0));
36 break;
37 }
38 SqlHandle *h = sql_reg_add(db);
39 if (!h) {
40 sqlite3_close(db);
41 push_value(vm, make_int(0));
42 break;
43 }
44 push_value(vm, make_int(h->id));
45#else
46 Value v = pop_value(vm);
49#endif
50 break;
51}
@ OP_SQLITE_OPEN
Definition bytecode.h:178
Value v
Definition cast.c:22
int rc
double db
Definition fmax.c:27
free(vals)
push_value(vm, make_int(0))
free_value(v)
Tagged union representing a Fun value.
Definition value.h:68
void vpath
Definition stubs.c:23
char * value_to_string_alloc(const Value *v)
Allocate a printable C string for a Value.
Definition value.c:641
Value make_int(int64_t v)
Construct a Value representing a 64-bit integer.
Definition value.c:51
Value path
Definition write_file.c:33