ui/common/properties.c

changeset 94
7fdf1489b82f
parent 79
483d7342b439
--- a/ui/common/properties.c	Wed Nov 27 16:48:59 2024 +0100
+++ b/ui/common/properties.c	Wed Nov 27 17:14:57 2024 +0100
@@ -162,43 +162,52 @@
     free(path);
 }
 
-void uic_store_app_properties() {
+int uic_store_app_properties() {
     char *path = ui_configfile("application.properties");
     if(!path) {
-        return;
+        return 1;
     }
     
     FILE *file = fopen(path, "w");
     if(!file) {
         fprintf(stderr, "Ui Error: Cannot open properties file: %s\n", path);
         free(path);
-        return;
+        return 1;
     }
     
+    int ret = 0;
     if(ucx_properties_store(application_properties, file)) {
         fprintf(stderr, "Ui Error: Cannot store application properties.\n");
+        ret = 1;
     }
     
     fclose(file);
     free(path);
+    
+    return ret;
 }
 
 
-char* ui_get_property(char *name) {
+const char* ui_get_property(const char *name) {
     return cxMapGet(application_properties, name);
 }
 
-void ui_set_property(char *name, char *value) {
-    cxMapPut(application_properties, name, value);
+void ui_set_property(const char *name, const char *value) {
+    cxMapPut(application_properties, name, (char*)value);
 }
 
-void ui_set_default_property(char *name, char *value) {
-    char *v = cxMapGet(application_properties, name);
+const char* ui_set_default_property(const char *name, const char *value) {
+    const char *v = cxMapGet(application_properties, name);
     if(!v) {
-        cxMapPut(application_properties, name, value);
+        cxMapPut(application_properties, name, (char*)value);
+        v = value;
     }
+    return v;
 }
 
+int ui_properties_store(void) {
+    return uic_store_app_properties();
+}
 
 
 static char* uic_concat_path(const char *base, const char *p, const char *ext) {

mercurial