cstest: protopye for trim_str & replace_hex
This commit is contained in:
parent
c7b08c57cc
commit
5a882c7184
|
@ -13,8 +13,8 @@ char **split(char *str, char *delim, int *size);
|
||||||
void print_strs(char **list_str, int size);
|
void print_strs(char **list_str, int size);
|
||||||
void free_strs(char **list_str, int size);
|
void free_strs(char **list_str, int size);
|
||||||
void add_str(char **src, const char *format, ...);
|
void add_str(char **src, const char *format, ...);
|
||||||
void trim_str(char src[]);
|
void trim_str(char *src);
|
||||||
void replace_hex(char src[]);
|
void replace_hex(char *src);
|
||||||
const char *get_filename_ext(const char *filename);
|
const char *get_filename_ext(const char *filename);
|
||||||
|
|
||||||
char *readfile(const char *filename);
|
char *readfile(const char *filename);
|
||||||
|
|
|
@ -103,7 +103,7 @@ void add_str(char **src, const char *format, ...)
|
||||||
free(tmp);
|
free(tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
void replace_hex(char src[])
|
void replace_hex(char *src)
|
||||||
{
|
{
|
||||||
char *tmp, *result, *found, *origin;
|
char *tmp, *result, *found, *origin;
|
||||||
int i;
|
int i;
|
||||||
|
@ -137,6 +137,7 @@ void replace_hex(char src[])
|
||||||
fprintf(stderr, "[ Error ] --- Buffer Overflow in replace_hex()\n");
|
fprintf(stderr, "[ Error ] --- Buffer Overflow in replace_hex()\n");
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
strcpy(src, result);
|
strcpy(src, result);
|
||||||
free(result);
|
free(result);
|
||||||
free(origin);
|
free(origin);
|
||||||
|
@ -172,7 +173,7 @@ void listdir(const char *name, char ***files, int *num_files)
|
||||||
closedir(dir);
|
closedir(dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
void trim_str(char str[])
|
void trim_str(char *str)
|
||||||
{
|
{
|
||||||
char tmp[MAXMEM];
|
char tmp[MAXMEM];
|
||||||
int start, end, j, i;
|
int start, end, j, i;
|
||||||
|
@ -185,6 +186,7 @@ void trim_str(char str[])
|
||||||
|
|
||||||
for (i=start; i<=end; ++i)
|
for (i=start; i<=end; ++i)
|
||||||
tmp[j++] = str[i];
|
tmp[j++] = str[i];
|
||||||
|
|
||||||
tmp[j] = '\0';
|
tmp[j] = '\0';
|
||||||
strcpy(str, tmp);
|
strcpy(str, tmp);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue