diff -r f421aef8f865 -r 8ebf55d78341 ui/common/properties.c --- a/ui/common/properties.c Fri Dec 12 12:28:32 2025 +0100 +++ b/ui/common/properties.c Fri Dec 12 12:38:35 2025 +0100 @@ -58,6 +58,23 @@ #endif +static UiBool load_on_startup = TRUE; +static void *properties_data = NULL; +static size_t properties_data_length = 0; + +void ui_load_properties_file_on_startup(UiBool enable) { + load_on_startup = enable; +} + +void ui_set_properties_data(const char *str, size_t len) { + if(str && len > 0) { + properties_data = malloc(len); + memcpy(properties_data, str, len); + } else { + properties_data = NULL; + properties_data_length = 0; + } +} char* ui_getappdir(void) { if(ui_appname() == NULL) { @@ -155,11 +172,12 @@ cxPropertiesFilln(&prop, buf, r); cxstring key; cxstring value; - status = cxPropertiesNext(&prop, &key, &value); + while((status = cxPropertiesNext(&prop, &key, &value)) == CX_PROPERTIES_NO_ERROR) { + cxMapPut(map, key, cx_strdup(value).ptr); + } if(status > CX_PROPERTIES_OK) { break; } - cxMapPut(map, key, cx_strdup(value).ptr); } return status == CX_PROPERTIES_NO_ERROR ? 0 : 1; } @@ -168,6 +186,29 @@ application_properties = cxHashMapCreate(cxDefaultAllocator, CX_STORE_POINTERS, 128); application_properties->collection.simple_destructor = free; + if(!load_on_startup) { + if(properties_data) { + CxProperties prop; + cxPropertiesInitDefault(&prop); + + CxPropertiesStatus status = CX_PROPERTIES_NO_ERROR; + cxPropertiesFilln(&prop, properties_data, properties_data_length); + + cxstring key; + cxstring value; + while((status = cxPropertiesNext(&prop, &key, &value)) == CX_PROPERTIES_NO_ERROR) { + cxMapPut(application_properties, key, cx_strdup(value).ptr); + } + + if(status != CX_PROPERTIES_NO_ERROR) { + fprintf(stderr, "Error: cannot load properties: %d\n", (int)status); + } else { + cxMapRehash(application_properties); + } + } + return; + } + if(!ui_appname()) { // applications without name cannot load app properties return;