|
|
|
@ -419,6 +419,20 @@ char *yon_char_append(const char *source, const char *append)
|
|
|
|
return NULL;
|
|
|
|
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)
|
|
|
|
char *yon_char_new(const char *chr)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (chr){
|
|
|
|
if (chr){
|
|
|
|
@ -471,11 +485,11 @@ int yon_char_check_begins_with(char *haystack, char *needle){
|
|
|
|
int size = strlen(needle);
|
|
|
|
int size = strlen(needle);
|
|
|
|
for (int i=0;i<size;i++){
|
|
|
|
for (int i=0;i<size;i++){
|
|
|
|
if (haystack[i]!=needle[i])
|
|
|
|
if (haystack[i]!=needle[i])
|
|
|
|
return -1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
char *yon_char_parsed_check_exist_begins_with(char **target, int size, char *compare){
|
|
|
|
char *yon_char_parsed_check_exist_begins_with(char **target, int size, char *compare){
|
|
|
|
@ -648,6 +662,26 @@ char *yon_char_replace(char *source, char *find, char*replace){
|
|
|
|
return source;
|
|
|
|
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){
|
|
|
|
char **yon_char_parse(char *parameters, int *size, char *divider){
|
|
|
|
*size=0;
|
|
|
|
*size=0;
|
|
|
|
if (parameters){
|
|
|
|
if (parameters){
|
|
|
|
@ -702,7 +736,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){
|
|
|
|
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;i<size;i++){
|
|
|
|
for (int i=0;i<size;i++){
|
|
|
|
if (parameters[i]){
|
|
|
|
if (parameters[i]){
|
|
|
|
if (!strcmp(parameters[i],param))
|
|
|
|
if (!strcmp(parameters[i],param))
|
|
|
|
@ -1157,6 +1191,7 @@ typedef struct yon_config_parameter
|
|
|
|
int ignore;
|
|
|
|
int ignore;
|
|
|
|
char *save_command;
|
|
|
|
char *save_command;
|
|
|
|
char *load_command;
|
|
|
|
char *load_command;
|
|
|
|
|
|
|
|
int compare_ignore;
|
|
|
|
} yon_config_parameter;
|
|
|
|
} yon_config_parameter;
|
|
|
|
|
|
|
|
|
|
|
|
yon_config_parameter *yon_config_parameter_new_with_data(char *key, void *data){
|
|
|
|
yon_config_parameter *yon_config_parameter_new_with_data(char *key, void *data){
|
|
|
|
@ -1172,6 +1207,7 @@ yon_config_parameter *yon_config_parameter_new_with_data(char *key, void *data){
|
|
|
|
param->ignore=0;
|
|
|
|
param->ignore=0;
|
|
|
|
param->save_command=NULL;
|
|
|
|
param->save_command=NULL;
|
|
|
|
param->load_command=NULL;
|
|
|
|
param->load_command=NULL;
|
|
|
|
|
|
|
|
param->compare_ignore=0;
|
|
|
|
return param;
|
|
|
|
return param;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -1534,6 +1570,22 @@ int yon_config_load_register(YON_CONFIG_TYPE config_type,char *section,char *par
|
|
|
|
} else return -1;
|
|
|
|
} 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){
|
|
|
|
int yon_config_remove_by_key(char *key){
|
|
|
|
check_config{
|
|
|
|
check_config{
|
|
|
|
dictionary *dict = yon_dictionary_get((dictionary**)&__yon__config__strings,key);
|
|
|
|
dictionary *dict = yon_dictionary_get((dictionary**)&__yon__config__strings,key);
|
|
|
|
@ -1543,7 +1595,7 @@ int yon_config_remove_by_key(char *key){
|
|
|
|
dict->data="";
|
|
|
|
dict->data="";
|
|
|
|
return 1;
|
|
|
|
return 1;
|
|
|
|
} else return 0;
|
|
|
|
} else return 0;
|
|
|
|
}else return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -2505,7 +2557,7 @@ int yon_file_save(char *file_path, char *text){
|
|
|
|
FILE *file = fopen(file_path,"w");
|
|
|
|
FILE *file = fopen(file_path,"w");
|
|
|
|
struct passwd *user = getpwnam(yon_ubl_root_user_get());
|
|
|
|
struct passwd *user = getpwnam(yon_ubl_root_user_get());
|
|
|
|
if (chown(file_path,user->pw_uid,user->pw_gid)){};
|
|
|
|
if (chown(file_path,user->pw_uid,user->pw_gid)){};
|
|
|
|
chmod(file_path,0644);
|
|
|
|
if (chmod(file_path,0755)){};
|
|
|
|
if (file){
|
|
|
|
if (file){
|
|
|
|
fputs(text,file);
|
|
|
|
fputs(text,file);
|
|
|
|
fclose(file);
|
|
|
|
fclose(file);
|
|
|
|
@ -2522,7 +2574,7 @@ int yon_file_create(char *path, char *name, int rules){
|
|
|
|
if (fl){
|
|
|
|
if (fl){
|
|
|
|
struct passwd *user = getpwnam(yon_ubl_root_user_get());
|
|
|
|
struct passwd *user = getpwnam(yon_ubl_root_user_get());
|
|
|
|
if (chown(path,user->pw_uid,user->pw_gid)){};
|
|
|
|
if (chown(path,user->pw_uid,user->pw_gid)){};
|
|
|
|
chmod(full_path,rules);
|
|
|
|
if (chmod(path,0755)){};
|
|
|
|
fclose(fl);
|
|
|
|
fclose(fl);
|
|
|
|
return 1;
|
|
|
|
return 1;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
@ -2536,7 +2588,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 (path){
|
|
|
|
if (access(path,F_OK)){
|
|
|
|
if (access(path,F_OK)){
|
|
|
|
int size;
|
|
|
|
int size;
|
|
|
|
@ -2548,12 +2600,17 @@ int yon_file_create_full_path(char *path, int rules){
|
|
|
|
if (access(temp,F_OK)){
|
|
|
|
if (access(temp,F_OK)){
|
|
|
|
if (i!=size-1){
|
|
|
|
if (i!=size-1){
|
|
|
|
mkdir(temp,0755);
|
|
|
|
mkdir(temp,0755);
|
|
|
|
|
|
|
|
struct passwd *user = getpwnam(yon_ubl_root_user_get());
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
FILE *fl = fopen(temp,"w");
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
|
|
|
if (!yon_char_is_empty(current)) free(current);
|
|
|
|
|