|
|
|
|
@ -335,6 +335,7 @@ int yon_char_find_last(char *source, char find){
|
|
|
|
|
int size = strlen(source);
|
|
|
|
|
int i=size;
|
|
|
|
|
for (;source[i]!=find&&i>0;i--);
|
|
|
|
|
if (source[i]!=find)i=-1;
|
|
|
|
|
return i;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -345,13 +346,9 @@ char *yon_char_append(char *source, char *append)
|
|
|
|
|
int size = strlen(source) + strlen(append) + 1;
|
|
|
|
|
char *final = malloc(size);
|
|
|
|
|
memset(final, 0, size);
|
|
|
|
|
// if (strstr(source, "%%"))
|
|
|
|
|
// sprintf(final, source, append);
|
|
|
|
|
// else
|
|
|
|
|
sprintf(final, "%s%s", source, append);
|
|
|
|
|
sprintf(final, "%s%s", source, append);
|
|
|
|
|
return final;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -367,27 +364,37 @@ char *yon_char_new(char *chr)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
char *yon_char_unite(char *source, ...){
|
|
|
|
|
va_list arglist;
|
|
|
|
|
char *new_char=NULL;
|
|
|
|
|
char *unite_char=NULL;
|
|
|
|
|
new_char=yon_char_new(source);
|
|
|
|
|
va_start(arglist,source);
|
|
|
|
|
unite_char = va_arg(arglist,char*);
|
|
|
|
|
while(unite_char){
|
|
|
|
|
new_char = yon_char_append(new_char,unite_char);
|
|
|
|
|
if (source){
|
|
|
|
|
va_list arglist;
|
|
|
|
|
char *new_char=NULL;
|
|
|
|
|
char *unite_char=NULL;
|
|
|
|
|
new_char=yon_char_new(source);
|
|
|
|
|
va_start(arglist,source);
|
|
|
|
|
unite_char = va_arg(arglist,char*);
|
|
|
|
|
while(unite_char){
|
|
|
|
|
char *temp = yon_char_append(new_char,unite_char);
|
|
|
|
|
free(new_char);
|
|
|
|
|
new_char=temp;
|
|
|
|
|
unite_char = va_arg(arglist,char*);
|
|
|
|
|
}
|
|
|
|
|
va_end(arglist);
|
|
|
|
|
return new_char;
|
|
|
|
|
}
|
|
|
|
|
va_end(arglist);
|
|
|
|
|
return new_char;
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
char *yon_cut(char *source, int size, int startpos)
|
|
|
|
|
{
|
|
|
|
|
char *cut = NULL;
|
|
|
|
|
cut = malloc(size + 1);
|
|
|
|
|
memset(cut, 0, size + 1);
|
|
|
|
|
memcpy(cut, source + startpos, size);
|
|
|
|
|
return cut;
|
|
|
|
|
if (source){
|
|
|
|
|
if (strlen(source+startpos)>=size){
|
|
|
|
|
char *cut = NULL;
|
|
|
|
|
cut = malloc(size + 1);
|
|
|
|
|
memset(cut, 0, size + 1);
|
|
|
|
|
memcpy(cut, source + startpos, size);
|
|
|
|
|
return cut;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
char *yon_char_divide(char *source, int dividepos)
|
|
|
|
|
@ -401,6 +408,7 @@ char *yon_char_divide(char *source, int dividepos)
|
|
|
|
|
memcpy(left, source + dividepos + 1, (strlen(source) - dividepos));
|
|
|
|
|
memset(source, 0, strlen(source));
|
|
|
|
|
memcpy(source, left, strlen(left));
|
|
|
|
|
free(left);
|
|
|
|
|
return cut;
|
|
|
|
|
}
|
|
|
|
|
return NULL;
|
|
|
|
|
@ -412,6 +420,7 @@ int yon_char_find_count(char *source, char *find){
|
|
|
|
|
int size=0;
|
|
|
|
|
int pos=0;
|
|
|
|
|
config_str rtn = yon_char_parse(working_string,&size,"\n");
|
|
|
|
|
free(working_string);
|
|
|
|
|
for (int j=0;j<size;j++){
|
|
|
|
|
if(strstr(rtn[j],find))
|
|
|
|
|
i++;
|
|
|
|
|
@ -423,11 +432,11 @@ char *yon_char_divide_search(char *source, char *dividepos, int delete_divider)
|
|
|
|
|
{
|
|
|
|
|
if (source&÷pos){
|
|
|
|
|
char *cut = strstr(source, dividepos);
|
|
|
|
|
if (cut)
|
|
|
|
|
{
|
|
|
|
|
if (cut){
|
|
|
|
|
int leng = strlen(source) - strlen(cut);
|
|
|
|
|
cut = yon_char_divide(source, leng);
|
|
|
|
|
return cut;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return source;
|
|
|
|
|
@ -477,8 +486,6 @@ char *yon_char_from_long(long int_to_convert)
|
|
|
|
|
|
|
|
|
|
char *yon_char_replace(char *source, char *find, char*replace){
|
|
|
|
|
if (!strstr(replace,find)){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
char *final=NULL;
|
|
|
|
|
char *temp=NULL;
|
|
|
|
|
if(!strstr(replace,find)){
|
|
|
|
|
@ -1927,6 +1934,16 @@ config_str yon_file_open(char *file_path, int *size){
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int yon_file_save(char *file_path, char *text){
|
|
|
|
|
FILE *file = fopen(file_path,"w");
|
|
|
|
|
if (file){
|
|
|
|
|
fputs(text,file);
|
|
|
|
|
fclose(file);
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int yon_file_create(char *path, char *name, int rules){
|
|
|
|
|
if (path&&name){
|
|
|
|
|
char *full_path = yon_char_unite(path,"/",name,NULL);
|
|
|
|
|
|