From b9a6566267e03e15ca3a0c635adb40bf2af9f85d Mon Sep 17 00:00:00 2001 From: Sani7 Date: Sat, 2 Dec 2023 23:04:05 +0100 Subject: [PATCH] tcp_cmd remove tcp_cmd_get_filename_ext and move over to llfs variant --- project/Core/Inc/tcp_cmd.h | 1 - project/Core/Src/tcp_cmd.c | 16 ++-------------- 2 files changed, 2 insertions(+), 15 deletions(-) diff --git a/project/Core/Inc/tcp_cmd.h b/project/Core/Inc/tcp_cmd.h index 68a702f..38e0fc2 100644 --- a/project/Core/Inc/tcp_cmd.h +++ b/project/Core/Inc/tcp_cmd.h @@ -23,7 +23,6 @@ void tcp_cmd_remove_newline(char* str, size_t len); char* tcp_cmd_remove_leading_space(char* str, size_t len); -char* tcp_cmd_get_filename_ext(char* filename); char* tcp_cmd_get_next_token(char* input, const char* delimiters, char** next); void tcp_cmd_init(void); err_t tcp_cmd_recv(void* arg, struct tcp_pcb* pcb, struct pbuf* p, err_t err); diff --git a/project/Core/Src/tcp_cmd.c b/project/Core/Src/tcp_cmd.c index f066a92..778e3b6 100644 --- a/project/Core/Src/tcp_cmd.c +++ b/project/Core/Src/tcp_cmd.c @@ -100,18 +100,6 @@ void tcp_cmd_str_tolower(char* str) { } } -/** - * @brief This function returns the extension of a file - * @param filename The filename to get the extension from - * @return char* The extension of the file - */ -char* tcp_cmd_get_filename_ext(char* filename) { - char* dot = strrchr(filename, '.'); - if (!dot || dot == filename) - return NULL; - return dot + 1; -} - /** * @brief This function finds the next token in the input string * If the token is between quotes, return the whole string between quotes @@ -290,7 +278,7 @@ static bool tcp_cmd_parser(struct tcp_pcb* pcb, int argc, char** argv) { } if (strcmp(argv[0], "setimage") == 0) { if (argc >= 2) { - ext = tcp_cmd_get_filename_ext(argv[1]); + ext = llfs_get_filename_ext(argv[1]); if (strcmp(ext, "bmp") != 0) { LOG_WARN(TAG, "setimage: File is not a bmp"); tcp_cmd_write(pcb, "File is not a bmp\n"); @@ -314,7 +302,7 @@ static bool tcp_cmd_parser(struct tcp_pcb* pcb, int argc, char** argv) { } if (strcmp(argv[0], "setgif") == 0) { if (argc >= 2) { - ext = tcp_cmd_get_filename_ext(argv[1]); + ext = llfs_get_filename_ext(argv[1]); if (strcmp(ext, "gif") != 0) { LOG_WARN(TAG, "setgif: File is not a gif"); tcp_cmd_write(pcb, "File is not a gif\n");