|
|
|
|
@ -229,7 +229,6 @@ void *yon_dictionary_free_all(dictionary *dictionary_to_free,void (*data_manipul
|
|
|
|
|
if(data_manipulation)
|
|
|
|
|
data_manipulation(dict->data);
|
|
|
|
|
if(dict->prev)
|
|
|
|
|
free(dict->prev->key);
|
|
|
|
|
free(dict->prev);
|
|
|
|
|
}
|
|
|
|
|
free(dict);
|
|
|
|
|
@ -408,7 +407,7 @@ int yon_char_find_last(char *source, char find){
|
|
|
|
|
return i;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
char *yon_char_append(char *source, char *append)
|
|
|
|
|
char *yon_char_append(const char *source, const char *append)
|
|
|
|
|
{
|
|
|
|
|
if (source && append)
|
|
|
|
|
{
|
|
|
|
|
@ -421,7 +420,7 @@ char *yon_char_append(char *source, char *append)
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
char *yon_char_new(char *chr)
|
|
|
|
|
char *yon_char_new(const char *chr)
|
|
|
|
|
{
|
|
|
|
|
if (chr){
|
|
|
|
|
char *newchar = malloc(strlen(chr) + 1);
|
|
|
|
|
@ -432,7 +431,7 @@ char *yon_char_new(char *chr)
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
char *yon_char_unite(char *source, ...){
|
|
|
|
|
char *yon_char_unite(const char *source, ...){
|
|
|
|
|
if (source){
|
|
|
|
|
va_list arglist;
|
|
|
|
|
char *new_char=NULL;
|
|
|
|
|
@ -555,28 +554,28 @@ char *yon_char_from_float(float int_to_convert)
|
|
|
|
|
|
|
|
|
|
char *yon_char_from_double(double int_to_convert)
|
|
|
|
|
{
|
|
|
|
|
int negative = int_to_convert < 0 ? 1 : 0;
|
|
|
|
|
int digits_before_decimal = (int_to_convert == 0) ? 1 : (int)log10(fabs(int_to_convert)) + 1;
|
|
|
|
|
int total_length = digits_before_decimal + 1 + 2 + negative + 1;
|
|
|
|
|
char *ch = malloc(total_length * sizeof(char));
|
|
|
|
|
if (!ch) {
|
|
|
|
|
return NULL;
|
|
|
|
|
int i = 1;
|
|
|
|
|
double convert_check = (double)int_to_convert;
|
|
|
|
|
for (i = 1; convert_check >= 10; i++)
|
|
|
|
|
{
|
|
|
|
|
convert_check = convert_check / 10;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
char *ch = malloc((i + 9)* sizeof(char));
|
|
|
|
|
memset(ch,0,(i + 9)* sizeof(char));
|
|
|
|
|
sprintf(ch, "%.2f", int_to_convert);
|
|
|
|
|
return ch;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
char *yon_char_from_long(long int_to_convert)
|
|
|
|
|
{
|
|
|
|
|
int negative = int_to_convert < 0 ? 1 : 0;
|
|
|
|
|
int digits = (int_to_convert == 0) ? 1 : (int)log10(labs(int_to_convert)) + 1;
|
|
|
|
|
int total_length = digits + negative + 1;
|
|
|
|
|
char *ch = malloc(total_length * sizeof(char));
|
|
|
|
|
if (!ch) {
|
|
|
|
|
return NULL;
|
|
|
|
|
int i = 1;
|
|
|
|
|
double convert_check = (double)int_to_convert;
|
|
|
|
|
for (i = 1; convert_check >= 10; i++)
|
|
|
|
|
{
|
|
|
|
|
convert_check = convert_check / 10;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
char *ch = malloc(i * sizeof(char) + 1);
|
|
|
|
|
memset(ch,0,i * sizeof(char) + 1);
|
|
|
|
|
sprintf(ch, "%ld", int_to_convert);
|
|
|
|
|
return ch;
|
|
|
|
|
}
|
|
|
|
|
@ -585,6 +584,7 @@ char *yon_char_replace(char *source, char *find, char*replace){
|
|
|
|
|
if (!strstr(replace,find)){
|
|
|
|
|
char *final=NULL;
|
|
|
|
|
char *temp=NULL;
|
|
|
|
|
if(!strstr(replace,find)){
|
|
|
|
|
while ((final=strstr(source,find))){
|
|
|
|
|
temp=malloc(strlen(source)-strlen(final)+strlen(replace));
|
|
|
|
|
memset(temp,0,strlen(source)-strlen(final)+strlen(replace));
|
|
|
|
|
@ -592,6 +592,8 @@ char *yon_char_replace(char *source, char *find, char*replace){
|
|
|
|
|
temp=yon_char_append(temp,replace);
|
|
|
|
|
source=yon_char_append(temp,final+strlen(find));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return source;
|
|
|
|
|
}
|
|
|
|
|
@ -619,23 +621,16 @@ char **yon_char_parse(char *parameters, int *size, char *divider){
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
char **yon_char_parsed_rip(char **char_string, int *size, int item_to_delete) {
|
|
|
|
|
if (char_string && size && (*size) > 0 && item_to_delete >= 0 && item_to_delete < (*size)) {
|
|
|
|
|
if (char_string && size && (*size) > 0 && (*size) > item_to_delete && item_to_delete >= 0) {
|
|
|
|
|
char **new_char_parsed = malloc(sizeof(char*) * ((*size) - 1));
|
|
|
|
|
if (!new_char_parsed) {
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int new_index = 0;
|
|
|
|
|
for (int i = 0; i < (*size); i++) {
|
|
|
|
|
if (i != item_to_delete) {
|
|
|
|
|
new_char_parsed[new_index] = yon_char_new(char_string[i]);
|
|
|
|
|
if (!new_char_parsed[new_index]) {
|
|
|
|
|
for (int j = 0; j < new_index; j++) {
|
|
|
|
|
free(new_char_parsed[j]);
|
|
|
|
|
}
|
|
|
|
|
free(new_char_parsed);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
new_index++;
|
|
|
|
|
} else {
|
|
|
|
|
free(char_string[i]);
|
|
|
|
|
@ -975,8 +970,8 @@ config_str yon_dir_get_contents(char *dir_path, int *size){
|
|
|
|
|
DIR *directory = opendir(dir_path);
|
|
|
|
|
struct dirent *de;
|
|
|
|
|
while ((de = readdir(directory))){
|
|
|
|
|
if (dir){ dir = yon_char_parsed_append(dir,size,de->d_name);
|
|
|
|
|
} else dir = yon_char_parsed_new(size,de->d_name,NULL);
|
|
|
|
|
if (dir){ dir = yon_char_parsed_append(dir,size,yon_char_new(de->d_name));
|
|
|
|
|
} else dir = yon_char_parsed_new(size,yon_char_new(de->d_name),NULL);
|
|
|
|
|
}
|
|
|
|
|
closedir(directory);
|
|
|
|
|
}
|
|
|
|
|
@ -1284,16 +1279,10 @@ int yon_config_command_prepare(config_str *commands, int *commands_size,char *co
|
|
|
|
|
for (int j=5;j<parsed_size;j++){
|
|
|
|
|
int new_size;
|
|
|
|
|
config_str new_element = yon_char_parsed_new(&new_size,parsed[0],parsed[1],parsed[2],parsed[3],parsed[4],parsed[j],NULL);
|
|
|
|
|
char *full = yon_char_parsed_to_string(new_element,new_size," ");
|
|
|
|
|
*commands = yon_char_parsed_append(*commands,commands_size,full);
|
|
|
|
|
yon_char_parsed_free(new_element,new_size);
|
|
|
|
|
free(full);
|
|
|
|
|
*commands = yon_char_parsed_append(*commands,commands_size,yon_char_parsed_to_string(new_element,new_size," "));
|
|
|
|
|
done=1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (parsed_size){
|
|
|
|
|
yon_char_parsed_free(parsed,parsed_size);
|
|
|
|
|
}
|
|
|
|
|
return done;
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
@ -1340,8 +1329,6 @@ int yon_config_load_config(YON_CONFIG_TYPE config_type, ...){
|
|
|
|
|
}
|
|
|
|
|
yon_char_parsed_free(parsed,parsed_size);
|
|
|
|
|
}
|
|
|
|
|
yon_char_parsed_free(command,command_size);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -1631,6 +1618,7 @@ int yon_config_clean(){
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void yon_config_register(char *key, char *config_load, void *data){
|
|
|
|
|
key=yon_char_new(key);
|
|
|
|
|
config_load=yon_char_new(config_load);
|
|
|
|
|
yon_config_parameter *current = NULL;
|
|
|
|
|
if (data){
|
|
|
|
|
@ -1751,7 +1739,7 @@ config_str yon_config_load(char *command, int *str_len){
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (output)
|
|
|
|
|
pclose(output);
|
|
|
|
|
fclose(output);
|
|
|
|
|
if (i>0){
|
|
|
|
|
*str_len = i;
|
|
|
|
|
return output_strings;
|
|
|
|
|
|