Browse Source

update: remove redundant functions

dev
Dnomd343 2 years ago
parent
commit
4482d3953b
  1. 4
      include/common/sundry.h
  2. 1
      include/common/system.h
  3. 8
      src/common/sundry.c
  4. 10
      src/common/system.c

4
include/common/sundry.h

@ -4,13 +4,11 @@
#include <stdint.h>
char* show_bool(uint8_t value);
uint8_t check_port(uint16_t port);
char* string_load(const char *fmt, ...);
char* uint32_to_string(uint32_t number);
char* string_join(const char *base, const char *add);
void string_list_debug(char *describe, char **string_list);
void uint32_list_debug(char *describe, uint32_t **uint32_list);
uint8_t check_port(uint16_t port);
uint16_t gen_rand_num(uint16_t limit);
#endif

1
include/common/system.h

@ -4,7 +4,6 @@
#include <stdint.h>
char* read_file(const char *file);
void remove_file(const char *file);
int run_command(const char *command);
void create_folder(const char *folder);
uint8_t is_file_exist(const char *file);

8
src/common/sundry.c

@ -56,11 +56,3 @@ uint8_t check_port(uint16_t port) { // whether port is valid
}
return FALSE;
}
uint16_t gen_rand_num(uint16_t limit) { // 0 ~ (limit - 1)
struct timeval tv;
gettimeofday(&tv, NULL);
srand(tv.tv_usec);
usleep(1); // sleep 1us (different time seed)
return rand() % limit; // NOLINT
}

10
src/common/system.c

@ -17,16 +17,6 @@ int run_command(const char *command) { // running command under system shell
return ret_code;
}
void remove_file(const char *file) { // delete file
if (!is_file_exist(file)) { // file not found
log_debug("Delete file `%s` skip -> file not exist", file);
} else if (remove(file)) { // remove failed
log_perror("Delete file `%s` failed -> ", file);
} else { // remove success
log_debug("Delete file `%s` success", file);
}
}
void create_folder(const char *folder) { // create folder
if (!access(folder, 0)) { // target is file or folder
struct stat buf;

Loading…
Cancel
Save