From f56664947960fc4f802648867110796026093401 Mon Sep 17 00:00:00 2001 From: Alexander Batalov Date: Sat, 18 Jun 2022 15:31:46 +0300 Subject: [PATCH] Cleanup message.h See #42 --- src/message.cc | 29 ++++++++++++++++++----------- src/message.h | 18 ------------------ 2 files changed, 18 insertions(+), 29 deletions(-) diff --git a/src/message.cc b/src/message.cc index f620a2b..96280c5 100644 --- a/src/message.cc +++ b/src/message.cc @@ -11,30 +11,37 @@ #include #include +#define BADWORD_LENGTH_MAX 80 + +static bool _message_find(MessageList* msg, int num, int* out_index); +static bool _message_add(MessageList* msg, MessageListItem* new_entry); +static bool _message_parse_number(int* out_num, const char* str); +static int _message_load_field(File* file, char* str); + // 0x50B79C -char _Error_1[] = "Error"; +static char _Error_1[] = "Error"; // 0x50B960 -const char* gBadwordsReplacements = "!@#$%&*@#*!&$%#&%#*%!$&%@*$@&"; +static const char* gBadwordsReplacements = "!@#$%&*@#*!&$%#&%#*%!$&%@*$@&"; // 0x519598 -char** gBadwords = NULL; +static char** gBadwords = NULL; // 0x51959C -int gBadwordsCount = 0; +static int gBadwordsCount = 0; // 0x5195A0 -int* gBadwordsLengths = NULL; +static int* gBadwordsLengths = NULL; // Default text for getmsg when no entry is found. // // 0x5195A4 -char* _message_error_str = _Error_1; +static char* _message_error_str = _Error_1; // Temporary message list item text used during filtering badwords. // // 0x63207C -char _bad_copy[MESSAGE_LIST_ITEM_FIELD_MAX_SIZE]; +static char _bad_copy[MESSAGE_LIST_ITEM_FIELD_MAX_SIZE]; // 0x484770 int badwordsInit() @@ -298,7 +305,7 @@ bool _message_make_path(char* dest, const char* path) } // 0x484D10 -bool _message_find(MessageList* msg, int num, int* out_index) +static bool _message_find(MessageList* msg, int num, int* out_index) { int r, l, mid; int cmp; @@ -336,7 +343,7 @@ bool _message_find(MessageList* msg, int num, int* out_index) } // 0x484D68 -bool _message_add(MessageList* msg, MessageListItem* new_entry) +static bool _message_add(MessageList* msg, MessageListItem* new_entry) { int index; MessageListItem* entries; @@ -397,7 +404,7 @@ bool _message_add(MessageList* msg, MessageListItem* new_entry) } // 0x484F60 -bool _message_parse_number(int* out_num, const char* str) +static bool _message_parse_number(int* out_num, const char* str) { const char* ch; bool success; @@ -434,7 +441,7 @@ bool _message_parse_number(int* out_num, const char* str) // 4 - limit exceeded (> 1024) // // 0x484FB4 -int _message_load_field(File* file, char* str) +static int _message_load_field(File* file, char* str) { int ch; int len; diff --git a/src/message.h b/src/message.h index b8fb129..a1fab3a 100644 --- a/src/message.h +++ b/src/message.h @@ -1,10 +1,6 @@ #ifndef MESSAGE_H #define MESSAGE_H -#include "db.h" - -#define BADWORD_LENGTH_MAX 80 - #define MESSAGE_LIST_ITEM_TEXT_FILTERED 0x01 #define MESSAGE_LIST_ITEM_FIELD_MAX_SIZE 1024 @@ -21,16 +17,6 @@ typedef struct MessageList { MessageListItem* entries; } MessageList; -extern char _Error_1[]; -extern const char* gBadwordsReplacements; - -extern char** gBadwords; -extern int gBadwordsCount; -extern int* gBadwordsLengths; -extern char* _message_error_str; - -extern char _bad_copy[MESSAGE_LIST_ITEM_FIELD_MAX_SIZE]; - int badwordsInit(); void badwordsExit(); bool messageListInit(MessageList* msg); @@ -38,10 +24,6 @@ bool messageListFree(MessageList* msg); bool messageListLoad(MessageList* msg, const char* path); bool messageListGetItem(MessageList* msg, MessageListItem* entry); bool _message_make_path(char* dest, const char* path); -bool _message_find(MessageList* msg, int num, int* out_index); -bool _message_add(MessageList* msg, MessageListItem* new_entry); -bool _message_parse_number(int* out_num, const char* str); -int _message_load_field(File* file, char* str); char* getmsg(MessageList* msg, MessageListItem* entry, int num); bool messageListFilterBadwords(MessageList* messageList);