core: core.globalSettingsGet JS => C.

This commit is contained in:
2025-10-15 18:24:38 -04:00
parent 8ca64550e5
commit 4bdc7ec616
4 changed files with 131 additions and 4 deletions

View File

@@ -2465,6 +2465,32 @@ bool tf_ssb_db_get_global_setting_string(sqlite3* db, const char* name, char* ou
return result;
}
const char* tf_ssb_db_get_global_setting_string_alloc(sqlite3* db, const char* name)
{
const char* result = NULL;
sqlite3_stmt* statement;
if (sqlite3_prepare_v2(db, "SELECT json_extract(value, '$.' || ?) FROM properties WHERE id = 'core' AND key = 'settings'", -1, &statement, NULL) == SQLITE_OK)
{
if (sqlite3_bind_text(statement, 1, name, -1, NULL) == SQLITE_OK)
{
if (sqlite3_step(statement) == SQLITE_ROW && sqlite3_column_type(statement, 0) != SQLITE_NULL)
{
result = tf_strdup((const char*)sqlite3_column_text(statement, 0));
}
}
sqlite3_finalize(statement);
}
else
{
tf_printf("prepare failed: %s\n", sqlite3_errmsg(db));
}
if (!result)
{
result = tf_strdup(tf_util_get_default_global_setting_string(name));
}
return result;
}
bool tf_ssb_db_set_global_setting_from_string(sqlite3* db, const char* name, char* value)
{
tf_setting_kind_t kind = tf_util_get_global_setting_kind(name);