From 9568b9ddc61804ab91f510d8d3785248233aa77a Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Fri, 10 Jan 2025 09:10:21 +0600 Subject: [PATCH 01/10] Added remove command macro --- source/libublsettings.h | 1 + 1 file changed, 1 insertion(+) diff --git a/source/libublsettings.h b/source/libublsettings.h index dfaa421..cf9e46a 100644 --- a/source/libublsettings.h +++ b/source/libublsettings.h @@ -750,6 +750,7 @@ config_str yon_dir_get_contents(char *dir_path, int *size); #define ubconfig_set_command_full(target, section, data) yon_char_unite("ubconfig ",!yon_char_is_empty(target)?"--target ":"",!yon_char_is_empty(target)?target:""," set ",section," ",data,NULL) #define ubconfig_load_command(target) yon_char_unite("ubconfig --source ",target," get ",NULL) #define ubconfig_load_command_full(target, data) yon_char_unite("ubconfig --source ",target," get ",data,NULL) +#define ubconfig_remove_command_full(target, section, data) yon_char_unite("ubconfig ",!yon_char_is_empty(target)?"--target ":"",!yon_char_is_empty(target)?target:""," remove ",section," ",data,NULL) /** * Типы конфигураций ubconfig-а -- 2.35.1 From 38f2093df7c5a815db64df36b036cfcec12e0a9a Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Tue, 14 Jan 2025 10:20:19 +0600 Subject: [PATCH 02/10] Added parameter existance checks for function --- source/libublsettings.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/libublsettings.c b/source/libublsettings.c index 8e0c533..799fa2d 100644 --- a/source/libublsettings.c +++ b/source/libublsettings.c @@ -702,7 +702,7 @@ char **yon_char_parsed_rip(char **char_string, int *size, int item_to_delete) { int yon_char_parsed_check_exist(char **parameters, int size, char *param){ - if (parameters){ + if (parameters&&size&&!yon_char_is_empty(param)){ for (int i=0;idata=""; return 1; } else return 0; - }else return 0; + } } return 0; } -- 2.35.1 From 997d6057d1318fc303c4847f21bb97d35b3562e1 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Mon, 20 Jan 2025 11:31:38 +0600 Subject: [PATCH 03/10] Added compare ignore parameter --- source/libublsettings.c | 18 ++++++++++++++++++ source/libublsettings.h | 4 ++++ 2 files changed, 22 insertions(+) diff --git a/source/libublsettings.c b/source/libublsettings.c index 799fa2d..ef04c51 100644 --- a/source/libublsettings.c +++ b/source/libublsettings.c @@ -1157,6 +1157,7 @@ typedef struct yon_config_parameter int ignore; char *save_command; char *load_command; + int compare_ignore; } yon_config_parameter; yon_config_parameter *yon_config_parameter_new_with_data(char *key, void *data){ @@ -1172,6 +1173,7 @@ yon_config_parameter *yon_config_parameter_new_with_data(char *key, void *data){ param->ignore=0; param->save_command=NULL; param->load_command=NULL; + param->compare_ignore=0; return param; } @@ -1534,6 +1536,22 @@ int yon_config_load_register(YON_CONFIG_TYPE config_type,char *section,char *par } else return -1; } +void yon_config_compare_ignore_set(char *key, int status){ + dictionary *cur = yon_dictionary_get((dictionary**)&__yon__config__strings,key); + if (cur){ + ((yon_config_parameter*)cur)->compare_ignore=!!status; + } +} + +int yon_config_compare_ignore_get(char *key){ + + dictionary *cur = yon_dictionary_get((dictionary**)&__yon__config__strings,key); + if (cur){ + return ((yon_config_parameter*)cur)->compare_ignore; + } + return 0; +} + int yon_config_remove_by_key(char *key){ check_config{ dictionary *dict = yon_dictionary_get((dictionary**)&__yon__config__strings,key); diff --git a/source/libublsettings.h b/source/libublsettings.h index cf9e46a..96894fd 100644 --- a/source/libublsettings.h +++ b/source/libublsettings.h @@ -862,6 +862,10 @@ int yon_config_load_register_no_cleaning(YON_CONFIG_TYPE config_type,char *secti [[ deprecated ( "Use yon_config_load_config instead" ) ]] int yon_config_load_register(YON_CONFIG_TYPE config_type,char *section,char *parameter, ...); +void yon_config_compare_ignore_set(char *key, int status); + +int yon_config_compare_ignore_get(char *key); + /**yon_config_remove_by_key(char *key) * [EN] * -- 2.35.1 From 38c4e66d05228a935ec5aac8d216cd54e6129d5b Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Wed, 22 Jan 2025 13:23:31 +0600 Subject: [PATCH 04/10] Added new functions --- source/libublsettings.c | 14 ++++++++++++++ source/libublsettings.h | 2 ++ 2 files changed, 16 insertions(+) diff --git a/source/libublsettings.c b/source/libublsettings.c index ef04c51..0d95d2d 100644 --- a/source/libublsettings.c +++ b/source/libublsettings.c @@ -419,6 +419,20 @@ char *yon_char_append(const char *source, const char *append) return NULL; } +char *yon_char_append_c(const char *source, char append) +{ + if (source) + { + size_t size = strlen(source) + 2; + char *final = malloc(size); + memset(final, 0, size); + memcpy(final,source,size-2); + final[size-2]=append; + return final; + } + return NULL; +} + char *yon_char_new(const char *chr) { if (chr){ diff --git a/source/libublsettings.h b/source/libublsettings.h index 96894fd..6013756 100644 --- a/source/libublsettings.h +++ b/source/libublsettings.h @@ -315,6 +315,8 @@ int yon_char_find_last(char *source, char find); */ char *yon_char_append(const char *source, const char *append); +char *yon_char_append_c(const char *source, char append); + /**[EN] * * creates new char string by copying another char. -- 2.35.1 From 2831fa7a854cf128746a2cda461b5b7d20394842 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Tue, 28 Jan 2025 18:01:07 +0600 Subject: [PATCH 05/10] Added function to header file --- source/libublsettings.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/source/libublsettings.h b/source/libublsettings.h index 6013756..0fa5378 100644 --- a/source/libublsettings.h +++ b/source/libublsettings.h @@ -741,6 +741,8 @@ void yon_dir_remove(const char *path); */ config_str yon_dir_get_contents(char *dir_path, int *size); +config_str yon_dir_get_by_mask(char *path, char *mask, int *size); + //config functions #define ubconfig_save_command "ubconfig " -- 2.35.1 From cddff6c596a591fe595c3672cf9e329265f6fd6a Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Wed, 29 Jan 2025 17:26:23 +0600 Subject: [PATCH 06/10] Fixed file creation --- source/libublsettings.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/source/libublsettings.c b/source/libublsettings.c index 0d95d2d..5ec7727 100644 --- a/source/libublsettings.c +++ b/source/libublsettings.c @@ -2582,10 +2582,11 @@ int yon_file_create_full_path(char *path, int rules){ mkdir(temp,0755); } else { FILE *fl = fopen(temp,"w"); - int chmod_success = chmod(temp,rules); + fclose(fl); } - struct passwd *user = getpwnam(yon_ubl_root_user_get()); - int chown_success = chown(temp,user->pw_uid,user->pw_gid); + struct passwd *user = getpwnam(yon_ubl_root_user_get()); + int chown_success = chown(temp,user->pw_uid,user->pw_gid); + int chmod_success = chmod(temp,rules); } } if (!yon_char_is_empty(current)) free(current); -- 2.35.1 From 7e1decdcd17f0c1c070202a4d08c3be4f64de669 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Mon, 10 Feb 2025 12:05:59 +0600 Subject: [PATCH 07/10] Fixed file creation --- source/libublsettings.c | 13 +++++++------ source/libublsettings.h | 2 +- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/source/libublsettings.c b/source/libublsettings.c index 5ec7727..db1e438 100644 --- a/source/libublsettings.c +++ b/source/libublsettings.c @@ -2537,7 +2537,6 @@ int yon_file_save(char *file_path, char *text){ FILE *file = fopen(file_path,"w"); struct passwd *user = getpwnam(yon_ubl_root_user_get()); if (chown(file_path,user->pw_uid,user->pw_gid)){}; - chmod(file_path,0644); if (file){ fputs(text,file); fclose(file); @@ -2554,7 +2553,6 @@ int yon_file_create(char *path, char *name, int rules){ if (fl){ struct passwd *user = getpwnam(yon_ubl_root_user_get()); if (chown(path,user->pw_uid,user->pw_gid)){}; - chmod(full_path,rules); fclose(fl); return 1; } else { @@ -2568,7 +2566,7 @@ int yon_file_create(char *path, char *name, int rules){ } } -int yon_file_create_full_path(char *path, int rules){ +int yon_file_create_full_path(char *path, mode_t rules){ if (path){ if (access(path,F_OK)){ int size; @@ -2580,13 +2578,16 @@ int yon_file_create_full_path(char *path, int rules){ if (access(temp,F_OK)){ if (i!=size-1){ mkdir(temp,0755); + struct passwd *user = getpwnam(yon_ubl_root_user_get()); } else { FILE *fl = fopen(temp,"w"); fclose(fl); } - struct passwd *user = getpwnam(yon_ubl_root_user_get()); - int chown_success = chown(temp,user->pw_uid,user->pw_gid); - int chmod_success = chmod(temp,rules); + + } + if (i>2){ + struct passwd *user = getpwnam(yon_ubl_root_user_get()); + int chown_success = chown(temp,user->pw_uid,user->pw_gid); } } if (!yon_char_is_empty(current)) free(current); diff --git a/source/libublsettings.h b/source/libublsettings.h index 0fa5378..6c35671 100644 --- a/source/libublsettings.h +++ b/source/libublsettings.h @@ -697,7 +697,7 @@ int yon_file_create(char *path, char *name, int rules); * Создать файл по пути [path] * С правами доступа [rules] (от 0000 до 0777) */ -int yon_file_create_full_path(char *path, int rules); +int yon_file_create_full_path(char *path, mode_t rules); /**yon_file_ls (char *path, int *size) * [EN] -- 2.35.1 From 8e3dde8c9e5acf3d69b09060e8092dddf78ca72c Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Tue, 11 Feb 2025 17:58:09 +0600 Subject: [PATCH 08/10] Added new replace function --- source/libublsettings.c | 20 ++++++++++++++++++++ source/libublsettings.h | 1 + 2 files changed, 21 insertions(+) diff --git a/source/libublsettings.c b/source/libublsettings.c index db1e438..c3e0885 100644 --- a/source/libublsettings.c +++ b/source/libublsettings.c @@ -662,6 +662,26 @@ char *yon_char_replace(char *source, char *find, char*replace){ return source; } +char *yon_char_replace_single(char *source, char *find, char *replace){ + if (!yon_char_is_empty(source)&&!yon_char_is_empty(find)){ + char *current = NULL; + if ((current=strstr(source,find))){ + int size = sizeof(char)*(strlen(source)-strlen(find)+strlen(replace)+1); + int replace_pos = strlen(source)-strlen(find); + char *final = malloc(size); + memset(final,0,size); + memcpy(final,source,replace_pos); + memcpy(final+replace_pos,replace,strlen(replace)); + if (strlen(source+replace_pos)>strlen(find)){ + memcpy(final+strlen(final),source+strlen(find),strlen(source+strlen(find))); + } + + return final; + } + } + return NULL; +} + char **yon_char_parse(char *parameters, int *size, char *divider){ *size=0; if (parameters){ diff --git a/source/libublsettings.h b/source/libublsettings.h index 6c35671..0b1f315 100644 --- a/source/libublsettings.h +++ b/source/libublsettings.h @@ -417,6 +417,7 @@ char *yon_char_from_long(long int_to_convert); * Заменяет в строке [source] все вхождения строки [find] на [replace] */ char *yon_char_replace(char *source, char *find, char*replace); +char *yon_char_replace_single(char *source, char *find, char *replace); /**yon_char_parse(char *parameters, int *size, char *divider) * [EN] -- 2.35.1 From e03ec21f4b22bd6e11e99166476eaa574ff6be7c Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Mon, 24 Feb 2025 14:44:30 +0600 Subject: [PATCH 09/10] Fixed return value of one function --- source/libublsettings.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/libublsettings.c b/source/libublsettings.c index c3e0885..b08ab89 100644 --- a/source/libublsettings.c +++ b/source/libublsettings.c @@ -485,11 +485,11 @@ int yon_char_check_begins_with(char *haystack, char *needle){ int size = strlen(needle); for (int i=0;i Date: Thu, 27 Feb 2025 15:55:48 +0600 Subject: [PATCH 10/10] Test fix for file creation under root --- source/libublsettings.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/source/libublsettings.c b/source/libublsettings.c index b08ab89..fe57668 100644 --- a/source/libublsettings.c +++ b/source/libublsettings.c @@ -2557,6 +2557,7 @@ int yon_file_save(char *file_path, char *text){ FILE *file = fopen(file_path,"w"); struct passwd *user = getpwnam(yon_ubl_root_user_get()); if (chown(file_path,user->pw_uid,user->pw_gid)){}; + if (chmod(file_path,0755)){}; if (file){ fputs(text,file); fclose(file); @@ -2573,6 +2574,7 @@ int yon_file_create(char *path, char *name, int rules){ if (fl){ struct passwd *user = getpwnam(yon_ubl_root_user_get()); if (chown(path,user->pw_uid,user->pw_gid)){}; + if (chmod(path,0755)){}; fclose(fl); return 1; } else { @@ -2608,6 +2610,7 @@ int yon_file_create_full_path(char *path, mode_t rules){ if (i>2){ struct passwd *user = getpwnam(yon_ubl_root_user_get()); int chown_success = chown(temp,user->pw_uid,user->pw_gid); + int chmod_success = chmod(temp,0755); } } if (!yon_char_is_empty(current)) free(current); -- 2.35.1