master #22

Merged
asmeron merged 3 commits from YanTheKaller/libublsettings:master into master 2 years ago

@ -781,6 +781,7 @@ char *yon_ubl_root_user_get(){
memset(user,0,4096);
fgets(user,4096,file);
user=yon_char_divide_search(user,"\n",-1);
fclose(file);
if (user) return user;
}
}
@ -793,6 +794,7 @@ char *yon_ubl_user_get_home_directory(){
memset(ret,0,4096);
fgets(ret,4096,path);
ret=yon_char_divide_search(ret,"\n",-1);
fclose(path);
return ret;
}
@ -1344,6 +1346,7 @@ void *yon_config_get_all_by_key(char *key, int *size){
}
return ret_data;
}
return NULL;
}
void *yon_config_get_all_by_key_no_ignored(char *key, int *size){
@ -1491,6 +1494,8 @@ config_str yon_config_load(char *command, int *str_len){
i++;
}
}
if (output)
fclose(output);
if (i>0){
*str_len = i;
return output_strings;
@ -1500,33 +1505,47 @@ config_str yon_config_load(char *command, int *str_len){
}
}
config_str yon_config_load_file(FILE *file, int *str_len){
config_str yon_config_load_file(FILE *file, int *str_len) {
FILE *output = file;
char **output_strings = NULL;
output_strings = malloc(sizeof(char));
int i = 0;
char str[4096];
memset(str, 0, 4096);
while (fgets(str, 4096, output))
{
if (strcmp(str, "") != 0)
{
output_strings = realloc(output_strings, sizeof(char *) * (i + 1));
output_strings[i] = NULL;
output_strings = malloc(sizeof(char *));
if (!output_strings) {
*str_len = -1;
return NULL;
}
while (fgets(str, sizeof(str), output)) {
if (strcmp(str, "") != 0) {
output_strings[i] = yon_char_new(str);
memset(str, 0, 4096);
if (!output_strings[i]) {
*str_len = -1;
for (int j = 0; j < i; j++) {
free(output_strings[j]);
}
free(output_strings);
return NULL;
}
i++;
output_strings = realloc(output_strings, sizeof(char *) * (i + 1));
if (!output_strings) {
*str_len = -1;
for (int j = 0; j < i; j++) {
free(output_strings[j]);
}
free(output_strings);
return NULL;
}
if (i>0){
}
}
*str_len = i;
return output_strings;
} else{
*str_len=-1;
return NULL;
}
}
char *yon_config_parameter_to_string(yon_config_parameter *parameter, int insert_section){
if (parameter){
char *param_string = NULL;
@ -1725,6 +1744,7 @@ char *yon_config_save_simple(YON_CONFIG_TYPE target, char *path){
return final_string;
}
}
fclose(file);
}
}
return NULL;
@ -1996,7 +2016,7 @@ int yon_launch_app_with_arguments(char *name, char *args)
void yon_launch(char *command)
{
system(command);
int ansver = system(command);
}
// // Trash collector functions

Loading…
Cancel
Save