TEST_SRC = tests/testmain.c
TEST_SRC += tests/test-editor.c
+TEST_SRC += tests/test-store.c
TEST_OBJ = $(TEST_SRC:%.c=../build/application/%$(OBJ_EXT))
--- /dev/null
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2026 Olaf Wintermann. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "test-store.h"
+
+#include "../store.h"
+
+CX_TEST(test_init_note_store) {
+ CX_TEST_DO {
+ int ret = init_note_store();
+
+ CX_TEST_ASSERT(ret == 0);
+ }
+}
--- /dev/null
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2026 Olaf Wintermann. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef TEST_STORE_H
+#define TEST_STORE_H
+
+#include <cx/test.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+CX_TEST(test_init_note_store);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* TEST_STORE_H */
+
* POSSIBILITY OF SUCH DAMAGE.
*/
+#include <stdlib.h>
#include <cx/test.h>
+#include <ui/ui.h>
+
+#include <sys/stat.h>
+
#include "test-editor.h"
+#include "test-store.h"
int main(int argc, char **argv) {
+ struct stat s;
+ if(!stat("notetestdata", &s)) {
+ system("rm -Rf notetestdata");
+ }
+
+ ui_setappdir("notetestdata");
+ ui_init(NULL, 0, NULL);
+
CxTestSuite *suite = cx_test_suite_new("note");
+ cx_test_register(suite, test_init_note_store);
+
cx_test_register(suite, test_parse_markdown_para);
cx_test_register(suite, test_parse_markdown_formatting_simple);
cx_test_register(suite, test_parse_markdown_formatting_nested);
static void *properties_data = NULL;
static size_t properties_data_length = 0;
+static char *config_root = NULL;
+
void ui_load_properties_file_on_startup(UiBool enable) {
load_on_startup = enable;
}
}
char* ui_getappdir(void) {
- if(ui_appname() == NULL) {
+ if(ui_appname() == NULL && config_root == NULL) {
return NULL;
}
return ui_configfile(NULL);
}
+void ui_setappdir(const char *path) {
+ free(config_root);
+ if(path) {
+ cxmutstr cfgpath = cx_strdup(path);
+ config_root = cfgpath.ptr;
+ if(cfgpath.length > 0 && cfgpath.ptr[cfgpath.length-1] == '/') {
+ config_root[cfgpath.length-1] = 0;
+ }
+ } else {
+ config_root = NULL;
+ }
+}
+
#ifndef _WIN32
#define UI_PATH_SEPARATOR '/'
#define UI_ENV_HOME "HOME"
#define UI_XDG_CONFIG_HOME_VAR "XDG_CONFIG_HOME"
char* ui_configfile(const char *name) {
+ if(config_root) {
+ if(!name) {
+ return strdup(config_root);
+ } else if(name[0] == '/') {
+ return cx_strdup(cx_strcat(CX_NULLSTR, 2, cx_str(config_root), cx_str(name))).ptr;
+ } else {
+ return cx_strdup(cx_strcat(CX_NULLSTR, 3, cx_str(config_root), cx_str("/"), cx_str(name))).ptr;
+ }
+ }
+
const char *appname = ui_appname();
if(!appname) {
return NULL;
return;
}
- if(!ui_appname()) {
- // applications without name cannot load app properties
- return;
- }
+ //if(!ui_appname()) {
+ // // applications without name cannot load app properties
+ // return;
+ //}
char *dir = ui_configfile(NULL);
if(!dir) {
UIEXPORT char* ui_getappdir(void);
+UIEXPORT void ui_setappdir(const char *path);
UIEXPORT char* ui_configfile(const char *name);
UIEXPORT UiCondVar* ui_condvar_create(void);