From 2883bda17d2f4a311b6fca7fdac782e9894afc13 Mon Sep 17 00:00:00 2001 From: Ilya Shipitsin Date: Thu, 8 Feb 2018 07:26:03 +0500 Subject: [PATCH] remove unused functions (identified by cppcheck) [src/Cedar/Hub.c:6663]: (style) The function 'CalcTrafficEntryDiff' is never used. [src/Mayaqua/Cfg.c:539]: (style) The function 'CfgRead' is never used. [src/Mayaqua/Cfg.c:1429]: (style) The function 'CfgStrToType' is never used. [src/Mayaqua/Network.c:7782]: (style) The function 'CheckSubnetLength6' is never used. [src/Mayaqua/Network.c:14614]: (style) The function 'CheckTCPPortThread' is never used. [src/Cedar/WinUi.c:9257]: (style) The function 'CheckTextLen' is never used. [src/Cedar/WinUi.c:9238]: (style) The function 'CheckTextSize' is never used. [src/Mayaqua/Network.c:6827]: (style) The function 'CheckUnicastAddress' is never used. [src/Mayaqua/Encrypt.c:2748]: (style) The function 'CheckX' is never used. [src/Cedar/Client.c:10394]: (style) The function 'CiFreeInnerVPNServer' is never used. [src/Cedar/Client.c:10785]: (style) The function 'CiGetNumActiveSessions' is never used. [src/Cedar/Client.c:2042]: (style) The function 'CiHasAccountSensitiveInformationFile' is never used. [src/Cedar/Client.c:10377]: (style) The function 'CiNewInnerVPNServer' is never used. [src/Mayaqua/Secure.c:842]: (style) The function 'CkDateToUINT64' is never used. [src/Mayaqua/Memory.c:2605]: (style) The function 'ClearFifo' is never used. [src/Mayaqua/Memory.c:4267]: (style) The function 'CloneTail' is never used. [src/Cedar/Command.c:9739]: (style) The function 'CmdEvalIpAndMask46' is never used. [src/Cedar/Command.c:9826]: (style) The function 'CmdEvalNetworkAndSubnetMask46' is never used. [src/Cedar/Command.c:22767]: (style) The function 'CmdPrintRow' is never used. [src/Cedar/Client.c:1128]: (style) The function 'CncGetSessionId' is never used. [src/Cedar/Client.c:767]: (style) The function 'CncPasswordDlgHaltThread' is never used. [src/Cedar/Client.c:10589]: (style) The function 'CompareInternetSetting' is never used. [src/Cedar/Protocol.c:907]: (style) The function 'CompareNodeInfo' is never used. [src/Cedar/Session.c:1853]: (style) The function 'CompareSession' is never used. [src/Mayaqua/Network.c:8171]: (style) The function 'CompareTcpTable' is never used. [src/Mayaqua/Tracking.c:593]: (style) The function 'CompareTrackingObject' is never used. [src/Mayaqua/FileIO.c:728]: (style) The function 'ConvertSafeFileNameW' is never used. [src/Mayaqua/Str.c:2024]: (style) The function 'CopyBinToStr' is never used. --- src/Cedar/Client.c | 165 ----------------------------------------- src/Cedar/Client.h | 9 --- src/Cedar/Command.c | 88 ---------------------- src/Cedar/Command.h | 3 - src/Cedar/Hub.c | 28 ------- src/Cedar/Hub.h | 1 - src/Cedar/Protocol.c | 89 ---------------------- src/Cedar/Session.c | 17 ----- src/Cedar/Session.h | 2 - src/Cedar/WinUi.c | 38 ---------- src/Cedar/WinUi.h | 2 - src/Mayaqua/Cfg.c | 20 ----- src/Mayaqua/Cfg.h | 2 - src/Mayaqua/Encrypt.c | 4 - src/Mayaqua/Encrypt.h | 1 - src/Mayaqua/FileIO.c | 18 ----- src/Mayaqua/FileIO.h | 1 - src/Mayaqua/Memory.c | 33 --------- src/Mayaqua/Memory.h | 2 - src/Mayaqua/Network.c | 79 -------------------- src/Mayaqua/Network.h | 4 - src/Mayaqua/Secure.c | 26 ------- src/Mayaqua/Str.c | 17 ----- src/Mayaqua/Str.h | 1 - src/Mayaqua/Tracking.c | 27 ------- src/Mayaqua/Tracking.h | 1 - 26 files changed, 678 deletions(-) diff --git a/src/Cedar/Client.c b/src/Cedar/Client.c index a5eaaf2c..09172d21 100644 --- a/src/Cedar/Client.c +++ b/src/Cedar/Client.c @@ -763,29 +763,6 @@ void CndMsgDlgFree(SOCK *s) ReleaseSock(s); } -// The thread to stop the password input dialog client forcibly -void CncPasswordDlgHaltThread(THREAD *thread, void *param) -{ - CNC_CONNECT_ERROR_DLG_THREAD_PARAM *dp = (CNC_CONNECT_ERROR_DLG_THREAD_PARAM *)param; - // Validate arguments - if (thread == NULL || param == NULL) - { - return; - } - - while (true) - { - if (dp->Session->Halt || dp->HaltThread) - { - break; - } - - Wait(dp->Event, 100); - } - - Disconnect(dp->Sock); -} - // Show the password input dialog bool CncPasswordDlg(SESSION *session, UI_PASSWORD_DLG *dlg) { @@ -1124,41 +1101,6 @@ void CncReleaseSocket() ReleaseSock(s); } -// Get the Session ID of the client notification service -UINT CncGetSessionId() -{ - SOCK *s = CncConnect(); - PACK *p; - UINT ret; - if (s == NULL) - { - return INFINITE; - } - - p = NewPack(); - PackAddStr(p, "function", "get_session_id"); - - SendPack(s, p); - FreePack(p); - - p = RecvPack(s); - if (p == NULL) - { - Disconnect(s); - ReleaseSock(s); - return INFINITE; - } - - ret = PackGetInt(p, "session_id"); - - FreePack(p); - - Disconnect(s); - ReleaseSock(s); - - return ret; -} - // Terminate the process of the client notification service void CncExit() { @@ -2039,28 +1981,6 @@ bool CiHasAccountSensitiveInformation(BUF *b) return ret; } -bool CiHasAccountSensitiveInformationFile(wchar_t *name) -{ - bool ret = false; - BUF *b; - // Validate arguments - if (name == NULL) - { - return false; - } - - b = ReadDumpW(name); - if (b == NULL) - { - return false; - } - - ret = CiHasAccountSensitiveInformation(b); - - FreeBuf(b); - - return ret; -} // Delete the sensitive information in the account information bool CiEraseSensitiveInAccount(BUF *b) @@ -10373,35 +10293,6 @@ void CiWriteSettingToCfg(CLIENT *c, FOLDER *root) } } -// Create the inner VPN Server -SERVER *CiNewInnerVPNServer(CLIENT *c, bool relay_server) -{ - SERVER *s = NULL; - // Validate arguments - if (c == NULL) - { - return NULL; - } - - SetNatTLowPriority(); - - s = SiNewServerEx(false, true, relay_server); - - return s; -} - -// Stop the inner VPN Server -void CiFreeInnerVPNServer(CLIENT *c, SERVER *s) -{ - // Validate arguments - if (c == NULL || s == NULL) - { - return; - } - - SiReleaseServer(s); -} - // Apply settings of Inner VPN Server void CiApplyInnerVPNServerConfig(CLIENT *c) { @@ -10585,48 +10476,6 @@ CLIENT *CiNewClient() return c; } -// Examine whether two proxy server settings equal -bool CompareInternetSetting(INTERNET_SETTING *s1, INTERNET_SETTING *s2) -{ - // Validate arguments - if (s1 == NULL || s2 == NULL) - { - return false; - } - - if (s1->ProxyType != s2->ProxyType) - { - return false; - } - - if (s1->ProxyType == PROXY_DIRECT) - { - return true; - } - - if (s1->ProxyPort != s2->ProxyPort) - { - return false; - } - - if (StrCmp(s1->ProxyHostName, s2->ProxyHostName) != 0) - { - return false; - } - - if (StrCmp(s1->ProxyUsername, s2->ProxyUsername) != 0) - { - return false; - } - - if (StrCmp(s1->ProxyPassword, s2->ProxyPassword) != 0) - { - return false; - } - - return true; -} - // Send a global pulse void CiSendGlobalPulse(CLIENT *c) { @@ -10781,20 +10630,6 @@ void CiDecrementNumActiveSessions() Unlock(ci_active_sessions_lock); } -// Get the number of active sessions -UINT CiGetNumActiveSessions() -{ - UINT ret; - - Lock(ci_active_sessions_lock); - { - ret = ci_num_active_sessions; - } - Unlock(ci_active_sessions_lock); - - return ret; -} - // Release the client void CtReleaseClient(CLIENT *c) { diff --git a/src/Cedar/Client.h b/src/Cedar/Client.h index 9e2f2ffe..f203be98 100644 --- a/src/Cedar/Client.h +++ b/src/Cedar/Client.h @@ -598,9 +598,6 @@ void CcSetServiceToForegroundProcess(REMOTE_CLIENT *r); char *CiGetFirstVLan(CLIENT *c); void CiNormalizeAccountVLan(CLIENT *c); -bool CompareInternetSetting(INTERNET_SETTING *s1, INTERNET_SETTING *s2); - - void CnStart(); void CnListenerProc(THREAD *thread, void *param); @@ -642,7 +639,6 @@ SOCK *CncConnect(); SOCK *CncConnectEx(UINT timeout); void CncReleaseSocket(); void CncExit(); -UINT CncGetSessionId(); bool CncExecDriverInstaller(char *arg); SOCK *CncStatusPrinterWindowStart(SESSION *s); void CncStatusPrinterWindowPrint(SOCK *s, wchar_t *str); @@ -651,7 +647,6 @@ void CncStatusPrinterWindowThreadProc(THREAD *thread, void *param); bool CncConnectErrorDlg(SESSION *session, UI_CONNECTERROR_DLG *dlg); void CncConnectErrorDlgHaltThread(THREAD *thread, void *param); bool CncPasswordDlg(SESSION *session, UI_PASSWORD_DLG *dlg); -void CncPasswordDlgHaltThread(THREAD *thread, void *param); void CncCheckCert(SESSION *session, UI_CHECKCERT *dlg); void CncCheckCertHaltThread(THREAD *thread, void *param); bool CncSecureSignDlg(SECURE_SIGN *sign); @@ -793,13 +788,9 @@ bool CiTryToParseAccount(BUF *b); bool CiTryToParseAccountFile(wchar_t *name); bool CiEraseSensitiveInAccount(BUF *b); bool CiHasAccountSensitiveInformation(BUF *b); -bool CiHasAccountSensitiveInformationFile(wchar_t *name); void CiApplyInnerVPNServerConfig(CLIENT *c); -SERVER *CiNewInnerVPNServer(CLIENT *c, bool relay_server); -void CiFreeInnerVPNServer(CLIENT *c, SERVER *s); void CiIncrementNumActiveSessions(); void CiDecrementNumActiveSessions(); -UINT CiGetNumActiveSessions(); BUF *EncryptPassword(char *password); BUF *EncryptPassword2(char *password); diff --git a/src/Cedar/Command.c b/src/Cedar/Command.c index 76b2a3cc..16bd67ea 100644 --- a/src/Cedar/Command.c +++ b/src/Cedar/Command.c @@ -9736,39 +9736,6 @@ bool CmdEvalIpAndMask6(CONSOLE *c, wchar_t *str, void *param) return true; } -bool CmdEvalIpAndMask46(CONSOLE *c, wchar_t *str, void *param) -{ - char tmp[MAX_SIZE]; - TOKEN_LIST *t; - bool ret = false; - - Zero(tmp, sizeof(tmp)); - UniToStr(tmp, sizeof(tmp), str); - - t = ParseToken(tmp, "/"); - if (t == NULL) - { - return false; - } - - if (t->NumTokens >= 1) - { - Trim(t->Token[0]); - - if (IsIpStr4(t->Token[0])) - { - ret = CmdEvalIpAndMask4(c, str, param); - } - else - { - ret = CmdEvalIpAndMask6(c, str, param); - } - } - - FreeToken(t); - - return ret; -} // Evaluate the network address and the subnet mask bool CmdEvalNetworkAndSubnetMask4(CONSOLE *c, wchar_t *str, void *param) @@ -9823,39 +9790,6 @@ bool CmdEvalNetworkAndSubnetMask6(CONSOLE *c, wchar_t *str, void *param) return true; } -bool CmdEvalNetworkAndSubnetMask46(CONSOLE *c, wchar_t *str, void *param) -{ - char tmp[MAX_SIZE]; - TOKEN_LIST *t; - bool ret = false; - - Zero(tmp, sizeof(tmp)); - UniToStr(tmp, sizeof(tmp), str); - - t = ParseToken(tmp, "/"); - if (t == NULL) - { - return false; - } - - if (t->NumTokens >= 1) - { - Trim(t->Token[0]); - - if (IsIpStr4(t->Token[0])) - { - ret = CmdEvalNetworkAndSubnetMask4(c, str, param); - } - else - { - ret = CmdEvalNetworkAndSubnetMask6(c, str, param); - } - } - - FreeToken(t); - - return ret; -} // Evaluate the IP address and subnet mask bool CmdEvalHostAndSubnetMask4(CONSOLE *c, wchar_t *str, void *param) @@ -22763,28 +22697,6 @@ UINT PsListenerDelete(CONSOLE *c, char *cmd_name, wchar_t *str, void *param) return 0; } -// Draw a row -void CmdPrintRow(CONSOLE *c, wchar_t *title, wchar_t *tag, ...) -{ - wchar_t buf[MAX_SIZE * 2]; - wchar_t buf2[MAX_SIZE * 2]; - va_list args; - // Validate arguments - if (title == NULL || c == NULL || tag == NULL) - { - return; - } - - va_start(args, tag); - UniFormatArgs(buf, sizeof(buf), tag, args); - - UniFormat(buf2, sizeof(buf2), L"[%s] %s", title, buf); - - va_end(args); - - c->Write(c, buf2); -} - // ServerInfoGet command UINT PsServerInfoGet(CONSOLE *c, char *cmd_name, wchar_t *str, void *param) { diff --git a/src/Cedar/Command.h b/src/Cedar/Command.h index 6708fc92..e33a182d 100644 --- a/src/Cedar/Command.h +++ b/src/Cedar/Command.h @@ -325,7 +325,6 @@ void InRpcTtResult(PACK *p, TT_RESULT *t); void CmdPrintError(CONSOLE *c, UINT err); void CmdPrintAbout(CONSOLE *c); -void CmdPrintRow(CONSOLE *c, wchar_t *title, wchar_t *tag, ...); wchar_t *CmdPromptPort(CONSOLE *c, void *param); wchar_t *CmdPromptChoosePassword(CONSOLE *c, void *param); bool CmdEvalPort(CONSOLE *c, wchar_t *str, void *param); @@ -346,10 +345,8 @@ wchar_t *GetConnectionTypeStr(UINT type); bool CmdEvalHostAndSubnetMask4(CONSOLE *c, wchar_t *str, void *param); bool CmdEvalNetworkAndSubnetMask4(CONSOLE *c, wchar_t *str, void *param); bool CmdEvalNetworkAndSubnetMask6(CONSOLE *c, wchar_t *str, void *param); -bool CmdEvalNetworkAndSubnetMask46(CONSOLE *c, wchar_t *str, void *param); bool CmdEvalIpAndMask4(CONSOLE *c, wchar_t *str, void *param); bool CmdEvalIpAndMask6(CONSOLE *c, wchar_t *str, void *param); -bool CmdEvalIpAndMask46(CONSOLE *c, wchar_t *str, void *param); wchar_t *GetLogSwitchStr(UINT i); wchar_t *GetPacketLogNameStr(UINT i); UINT StrToLogSwitchType(char *str); diff --git a/src/Cedar/Hub.c b/src/Cedar/Hub.c index 82e00ff7..d654554e 100644 --- a/src/Cedar/Hub.c +++ b/src/Cedar/Hub.c @@ -6659,34 +6659,6 @@ void SetRadiusServerEx(HUB *hub, char *name, UINT port, char *secret, UINT inter Unlock(hub->RadiusOptionLock); } -// Get the difference between the traffic data -void CalcTrafficEntryDiff(TRAFFIC_ENTRY *diff, TRAFFIC_ENTRY *old, TRAFFIC_ENTRY *current) -{ - // Validate arguments - Zero(diff, sizeof(TRAFFIC_ENTRY)); - if (old == NULL || current == NULL || diff == NULL) - { - return; - } - - if (current->BroadcastCount >= old->BroadcastCount) - { - diff->BroadcastCount = current->BroadcastCount - old->BroadcastCount; - } - if (current->BroadcastBytes >= old->BroadcastBytes) - { - diff->BroadcastBytes = current->BroadcastBytes - old->BroadcastBytes; - } - if (current->UnicastCount >= old->UnicastCount) - { - diff->UnicastCount = current->UnicastCount - old->UnicastCount; - } - if (current->UnicastBytes >= old->UnicastBytes) - { - diff->UnicastBytes = current->UnicastBytes - old->UnicastBytes; - } -} - // Add the traffic information for Virtual HUB void IncrementHubTraffic(HUB *h) { diff --git a/src/Cedar/Hub.h b/src/Cedar/Hub.h index 85ccc3de..9360d276 100644 --- a/src/Cedar/Hub.h +++ b/src/Cedar/Hub.h @@ -638,7 +638,6 @@ USERLIST *FindUserList(LIST *o, char *filename); bool IsUserMatchInUserList(LIST *o, char *filename, UINT64 user_hash); bool IsUserMatchInUserListWithCacheExpires(LIST *o, char *filename, UINT64 user_hash, UINT64 lifetime); bool IsUserMatchInUserListWithCacheExpiresAcl(LIST *o, char *name_in_acl, UINT64 user_hash, UINT64 lifetime); -void CalcTrafficEntryDiff(TRAFFIC_ENTRY *diff, TRAFFIC_ENTRY *old, TRAFFIC_ENTRY *current); bool CheckMaxLoggedPacketsPerMinute(SESSION *s, UINT max_packets, UINT64 now); void VgsSetUserAgentValue(char *str); void VgsSetEmbTag(bool b); diff --git a/src/Cedar/Protocol.c b/src/Cedar/Protocol.c index 501b7eff..4bdf516e 100644 --- a/src/Cedar/Protocol.c +++ b/src/Cedar/Protocol.c @@ -903,95 +903,6 @@ void NodeInfoToStr(wchar_t *str, UINT size, NODE_INFO *info) info->HubName, unique_id); } -// Comparison of node information -bool CompareNodeInfo(NODE_INFO *a, NODE_INFO *b) -{ - // Validate arguments - if (a == NULL || b == NULL) - { - return false; - } - - if (StrCmp(a->ClientProductName, b->ClientProductName) != 0) - { - return false; - } - if (a->ClientProductVer != b->ClientProductVer) - { - return false; - } - if (a->ClientProductBuild != b->ClientProductBuild) - { - return false; - } - if (StrCmp(a->ServerProductName, b->ServerProductName) != 0) - { - return false; - } - if (a->ServerProductVer != b->ServerProductVer) - { - return false; - } - if (a->ServerProductBuild != b->ServerProductBuild) - { - return false; - } - if (StrCmp(a->ClientOsName, b->ClientOsName) != 0) - { - return false; - } - if (StrCmp(a->ClientOsVer, b->ClientOsVer) != 0) - { - return false; - } - if (StrCmp(a->ClientOsProductId, b->ClientOsProductId) != 0) - { - return false; - } - if (StrCmp(a->ClientHostname, b->ClientHostname) != 0) - { - return false; - } - if (a->ClientIpAddress != b->ClientIpAddress) - { - return false; - } - if (StrCmp(a->ServerHostname, b->ServerHostname) != 0) - { - return false; - } - if (a->ServerIpAddress != b->ServerIpAddress) - { - return false; - } - if (a->ServerPort != b->ServerPort) - { - return false; - } - if (StrCmp(a->ProxyHostname, b->ProxyHostname) != 0) - { - return false; - } - if (a->ProxyIpAddress != b->ProxyIpAddress) - { - return false; - } - if (a->ProxyPort != b->ProxyPort) - { - return false; - } - if (StrCmp(a->HubName, b->HubName) != 0) - { - return false; - } - if (Cmp(a->UniqueId, b->UniqueId, 16) != 0) - { - return false; - } - - return true; -} - // Accept the password change UINT ChangePasswordAccept(CONNECTION *c, PACK *p) { diff --git a/src/Cedar/Session.c b/src/Cedar/Session.c index 5475485a..03fb4394 100644 --- a/src/Cedar/Session.c +++ b/src/Cedar/Session.c @@ -1849,23 +1849,6 @@ SKIP: } } -// Name comparison of sessions -int CompareSession(void *p1, void *p2) -{ - SESSION *s1, *s2; - if (p1 == NULL || p2 == NULL) - { - return 0; - } - s1 = *(SESSION **)p1; - s2 = *(SESSION **)p2; - if (s1 == NULL || s2 == NULL) - { - return 0; - } - return StrCmpi(s1->Name, s2->Name); -} - // Create an RPC session SESSION *NewRpcSession(CEDAR *cedar, CLIENT_OPTION *option) { diff --git a/src/Cedar/Session.h b/src/Cedar/Session.h index 10b23281..f65c9850 100644 --- a/src/Cedar/Session.h +++ b/src/Cedar/Session.h @@ -413,7 +413,6 @@ void StopSession(SESSION *s); void StopSessionEx(SESSION *s, bool no_wait); bool SessionConnect(SESSION *s); bool ClientConnect(CONNECTION *c); -int CompareSession(void *p1, void *p2); PACKET_ADAPTER *NewPacketAdapter(PA_INIT *init, PA_GETCANCEL *getcancel, PA_GETNEXTPACKET *getnext, PA_PUTPACKET *put, PA_FREE *free); void FreePacketAdapter(PACKET_ADAPTER *pa); @@ -435,7 +434,6 @@ LIST *NewCancelList(); void ReleaseCancelList(LIST *o); void AddCancelList(LIST *o, CANCEL *c); void CancelList(LIST *o); -bool CompareNodeInfo(NODE_INFO *a, NODE_INFO *b); bool IsPriorityHighestPacketForQoS(void *data, UINT size); UINT GetNextDelayedPacketTickDiff(SESSION *s); diff --git a/src/Cedar/WinUi.c b/src/Cedar/WinUi.c index 0188331c..d6c8d757 100644 --- a/src/Cedar/WinUi.c +++ b/src/Cedar/WinUi.c @@ -9234,44 +9234,6 @@ void Check(HWND hWnd, UINT id, bool b) } } -// Confirm that the character size of the text-box is less than or equal to specified size -bool CheckTextSize(HWND hWnd, UINT id, UINT size, bool unicode) -{ - // Validate arguments - if (hWnd == NULL) - { - return false; - } - - if (GetTextSize(hWnd, id, unicode) <= size) - { - return true; - } - else - { - return false; - } -} - -// Confirm that a length of the string in the text-box is less than or equal to the specified size -bool CheckTextLen(HWND hWnd, UINT id, UINT len, bool unicode) -{ - // Validate arguments - if (hWnd == NULL) - { - return false; - } - - if (GetTextLen(hWnd, id, unicode) <= len) - { - return true; - } - else - { - return false; - } -} - // Limit the number of characters that can be entered into the text-box void LimitText(HWND hWnd, UINT id, UINT count) { diff --git a/src/Cedar/WinUi.h b/src/Cedar/WinUi.h index 31e0cc8e..9c34f9e5 100644 --- a/src/Cedar/WinUi.h +++ b/src/Cedar/WinUi.h @@ -661,8 +661,6 @@ bool GetFontSize(HFONT hFont, UINT *x, UINT *y); void SetFont(HWND hWnd, UINT id, HFONT hFont); void SetFontEx(HWND hWnd, UINT id, HFONT hFont, bool no_adjust_font_size); void LimitText(HWND hWnd, UINT id, UINT count); -bool CheckTextLen(HWND hWnd, UINT id, UINT len, bool unicode); -bool CheckTextSize(HWND hWnd, UINT id, UINT size, bool unicode); void Check(HWND hWnd, UINT id, bool b); bool IsChecked(HWND hWnd, UINT id); void SetIcon(HWND hWnd, UINT id, UINT icon_id); diff --git a/src/Mayaqua/Cfg.c b/src/Mayaqua/Cfg.c index 73b62dcd..e313afa9 100644 --- a/src/Mayaqua/Cfg.c +++ b/src/Mayaqua/Cfg.c @@ -536,15 +536,6 @@ bool CfgSaveExW3(CFG_RW *rw, FOLDER *f, wchar_t *name, UINT *written_size, bool } // Read the settings from the file -FOLDER *CfgRead(char *name) -{ - wchar_t *name_w = CopyStrToUni(name); - FOLDER *ret = CfgReadW(name_w); - - Free(name_w); - - return ret; -} FOLDER *CfgReadW(wchar_t *name) { wchar_t tmp[MAX_SIZE]; @@ -1425,17 +1416,6 @@ void CfgAddData(BUF *b, UINT type, char *name, char *data, char *sub, UINT depth Free(tmp); } -// Convert the data type string to an integer value -UINT CfgStrToType(char *str) -{ - if (!StrCmpi(str, TAG_INT)) return ITEM_TYPE_INT; - if (!StrCmpi(str, TAG_INT64)) return ITEM_TYPE_INT64; - if (!StrCmpi(str, TAG_BYTE)) return ITEM_TYPE_BYTE; - if (!StrCmpi(str, TAG_STRING)) return ITEM_TYPE_STRING; - if (!StrCmpi(str, TAG_BOOL)) return ITEM_TYPE_BOOL; - return 0; -} - // Convert the type of data to a string char *CfgTypeToStr(UINT type) { diff --git a/src/Mayaqua/Cfg.h b/src/Mayaqua/Cfg.h index 2ffe4fb5..aa42ac51 100644 --- a/src/Mayaqua/Cfg.h +++ b/src/Mayaqua/Cfg.h @@ -226,7 +226,6 @@ void CfgAddLine(BUF *b, char *str, UINT depth); void CfgAddDeclare(BUF *b, char *name, UINT depth); void CfgAddEnd(BUF *b, UINT depth); void CfgAddData(BUF *b, UINT type, char *name, char *data, char *sub, UINT depth); -UINT CfgStrToType(char *str); char *CfgTypeToStr(UINT type); void CfgAddItemText(BUF *b, ITEM *t, UINT depth); bool CfgEnumFolderProc(FOLDER *f, void *param); @@ -242,7 +241,6 @@ bool CfgSaveEx(CFG_RW *rw, FOLDER *f, char *name); bool CfgSaveExW(CFG_RW *rw, FOLDER *f, wchar_t *name); bool CfgSaveExW2(CFG_RW *rw, FOLDER *f, wchar_t *name, UINT *written_size); bool CfgSaveExW3(CFG_RW *rw, FOLDER *f, wchar_t *name, UINT *written_size, bool write_binary); -FOLDER *CfgRead(char *name); FOLDER *CfgReadW(wchar_t *name); FOLDER *CfgCreateRoot(); void CfgTest(); diff --git a/src/Mayaqua/Encrypt.c b/src/Mayaqua/Encrypt.c index 192f20c6..c049dfa9 100644 --- a/src/Mayaqua/Encrypt.c +++ b/src/Mayaqua/Encrypt.c @@ -2745,10 +2745,6 @@ bool RsaGen(K **priv, K **pub, UINT bit) } // Confirm whether the certificate X is signed by the issuer of the certificate x_issuer -bool CheckX(X *x, X *x_issuer) -{ - return CheckXEx(x, x_issuer, false, false); -} bool CheckXEx(X *x, X *x_issuer, bool check_name, bool check_date) { K *k; diff --git a/src/Mayaqua/Encrypt.h b/src/Mayaqua/Encrypt.h index 512c7054..fbcff409 100644 --- a/src/Mayaqua/Encrypt.h +++ b/src/Mayaqua/Encrypt.h @@ -427,7 +427,6 @@ bool CompareName(NAME *n1, NAME *n2); K *GetKFromX(X *x); bool CheckSignature(X *x, K *k); X *X509ToX(X509 *x509); -bool CheckX(X *x, X *x_issuer); bool CheckXEx(X *x, X *x_issuer, bool check_name, bool check_date); bool Asn1TimeToSystem(SYSTEMTIME *s, void *asn1_time); bool StrToSystem(SYSTEMTIME *s, char *str); diff --git a/src/Mayaqua/FileIO.c b/src/Mayaqua/FileIO.c index a610ffad..fd81f1e6 100644 --- a/src/Mayaqua/FileIO.c +++ b/src/Mayaqua/FileIO.c @@ -725,24 +725,6 @@ void ConvertSafeFileName(char *dst, UINT size, char *src) } } } -void ConvertSafeFileNameW(wchar_t *dst, UINT size, wchar_t *src) -{ - UINT i; - // Validate arguments - if (dst == NULL || src == NULL) - { - return; - } - - UniStrCpy(dst, size, src); - for (i = 0;i < UniStrLen(dst);i++) - { - if (UniIsSafeChar(dst[i]) == false) - { - dst[i] = L'_'; - } - } -} // Get the free disk space bool GetDiskFree(char *path, UINT64 *free_size, UINT64 *used_size, UINT64 *total_size) diff --git a/src/Mayaqua/FileIO.h b/src/Mayaqua/FileIO.h index 0822f2a9..2a500e88 100644 --- a/src/Mayaqua/FileIO.h +++ b/src/Mayaqua/FileIO.h @@ -370,7 +370,6 @@ int CompareDirListByName(void *p1, void *p2); bool GetDiskFree(char *path, UINT64 *free_size, UINT64 *used_size, UINT64 *total_size); bool GetDiskFreeW(wchar_t *path, UINT64 *free_size, UINT64 *used_size, UINT64 *total_size); void ConvertSafeFileName(char *dst, UINT size, char *src); -void ConvertSafeFileNameW(wchar_t *dst, UINT size, wchar_t *src); bool FileReplaceRename(char *old_name, char *new_name); bool FileReplaceRenameW(wchar_t *old_name, wchar_t *new_name); bool IsFile(char *name); diff --git a/src/Mayaqua/Memory.c b/src/Mayaqua/Memory.c index 92b7efa5..5ccb38e3 100644 --- a/src/Mayaqua/Memory.c +++ b/src/Mayaqua/Memory.c @@ -2601,20 +2601,6 @@ void PadFifoFront(FIFO *f, UINT size) f->p = ReAlloc(f->p, f->memsize); } -// Clear the FIFO -void ClearFifo(FIFO *f) -{ - // Validate arguments - if (f == NULL) - { - return; - } - - f->size = f->pos = 0; - f->memsize = FIFO_INIT_MEM_SIZE; - f->p = ReAlloc(f->p, f->memsize); -} - // Get the current pointer of the FIFO UCHAR *GetFifoPointer(FIFO *f) { @@ -4263,25 +4249,6 @@ void *AddHead(void *src, UINT src_size, void *head, UINT head_size) return ret; } -// Clone the memory area (only the tail) -void *CloneTail(void *src, UINT src_size, UINT dst_size) -{ - // Validate arguments - if (src_size != 0 && src == NULL) - { - return NULL; - } - - if (src_size >= dst_size) - { - return Clone(((UCHAR *)src) + (src_size - dst_size), dst_size); - } - else - { - return Clone(src, src_size); - } -} - // Clone the memory area void *Clone(void *addr, UINT size) { diff --git a/src/Mayaqua/Memory.h b/src/Mayaqua/Memory.h index 28babd8b..c41ef1ff 100644 --- a/src/Mayaqua/Memory.h +++ b/src/Mayaqua/Memory.h @@ -290,7 +290,6 @@ int CmpCaseIgnore(void *p1, void *p2, UINT size); void ZeroMem(void *addr, UINT size); void Zero(void *addr, UINT size); void *Clone(void *addr, UINT size); -void *CloneTail(void *src, UINT src_size, UINT dst_size); void *AddHead(void *src, UINT src_size, void *head, UINT head_size); char B64_CodeToChar(BYTE c); @@ -360,7 +359,6 @@ UCHAR *FifoPtr(FIFO *f); void WriteFifo(FIFO *f, void *p, UINT size); void WriteFifoFront(FIFO *f, void *p, UINT size); void PadFifoFront(FIFO *f, UINT size); -void ClearFifo(FIFO *f); UINT FifoSize(FIFO *f); void LockFifo(FIFO *f); void UnlockFifo(FIFO *f); diff --git a/src/Mayaqua/Network.c b/src/Mayaqua/Network.c index 73166847..177bb263 100644 --- a/src/Mayaqua/Network.c +++ b/src/Mayaqua/Network.c @@ -6823,23 +6823,6 @@ bool IsNetworkPrefixAddress6(IP *ip, IP *subnet) return false; } -// Check whether the unicast address is available -bool CheckUnicastAddress(IP *ip) -{ - // Validate arguments - if (ip == NULL) - { - return false; - } - - if ((GetIPAddrType6(ip) & IPV6_ADDR_UNICAST) == 0) - { - return false; - } - - return true; -} - // Get the host address void GetHostAddress6(IP *dst, IP *ip, IP *subnet) { @@ -7778,17 +7761,6 @@ void CopyIP(IP *dst, IP *src) Copy(dst, src, sizeof(IP)); } -// Check the length of the IPv6 subnet -bool CheckSubnetLength6(UINT i) -{ - if (i >= 1 && i <= 127) - { - return true; - } - - return false; -} - // Get the process ID of the corresponding TCP connection by the socket UINT GetTcpProcessIdFromSocket(SOCK *s) { @@ -8167,24 +8139,6 @@ void PrintTcpTableList(LIST *o) Print("------\n\n"); } -// Comparison of TCP table items -int CompareTcpTable(void *p1, void *p2) -{ - TCPTABLE *t1, *t2; - if (p1 == NULL || p2 == NULL) - { - return 0; - } - t1 = *(TCPTABLE **)p1; - t2 = *(TCPTABLE **)p2; - if (t1 == NULL || t2 == NULL) - { - return 0; - } - - return Cmp(t1, t2, sizeof(TCPTABLE)); -} - // Get the TCP table list LIST *GetTcpTableList() { @@ -14610,39 +14564,6 @@ typedef struct TCP_PORT_CHECK bool ok; } TCP_PORT_CHECK; -// The thread to check the TCP port -void CheckTCPPortThread(THREAD *thread, void *param) -{ - TCP_PORT_CHECK *c; - SOCK *s; - // Validate arguments - if (thread == NULL || param == NULL) - { - return; - } - - c = (TCP_PORT_CHECK *)param; - AddRef(c->ref); - NoticeThreadInit(thread); - - AddWaitThread(thread); - - s = Connect(c->hostname, c->port); - if (s != NULL) - { - c->ok = true; - Disconnect(s); - ReleaseSock(s); - } - - if (Release(c->ref) == 0) - { - Free(c); - } - - DelWaitThread(thread); -} - // Check whether the TCP port can be connected bool CheckTCPPortEx(char *hostname, UINT port, UINT timeout) { diff --git a/src/Mayaqua/Network.h b/src/Mayaqua/Network.h index 21b67ba7..a1018efc 100644 --- a/src/Mayaqua/Network.h +++ b/src/Mayaqua/Network.h @@ -1354,7 +1354,6 @@ void SetTimeout(SOCK *sock, UINT timeout); UINT GetTimeout(SOCK *sock); bool CheckTCPPort(char *hostname, UINT port); bool CheckTCPPortEx(char *hostname, UINT port, UINT timeout); -void CheckTCPPortThread(THREAD *thread, void *param); ROUTE_TABLE *GetRouteTable(); void FreeRouteTable(ROUTE_TABLE *t); bool AddRouteEntryEx(ROUTE_ENTRY *e, bool *already_exists); @@ -1426,7 +1425,6 @@ UINT GetNumIpClient(IP *ip); void SetLinuxArpFilter(); LIST *GetTcpTableList(); void FreeTcpTableList(LIST *o); -int CompareTcpTable(void *p1, void *p2); void PrintTcpTableList(LIST *o); TCPTABLE *GetTcpTableFromEndPoint(LIST *o, IP *local_ip, UINT local_port, IP *remote_ip, UINT remote_port); UINT GetTcpProcessIdFromSocket(SOCK *s); @@ -1455,7 +1453,6 @@ SOCKET_TIMEOUT_PARAM *NewSocketTimeout(SOCK *sock); void FreeSocketTimeout(SOCKET_TIMEOUT_PARAM *ttp); void CopyIP(IP *dst, IP *src); -bool CheckSubnetLength6(UINT i); bool IsIP6(IP *ip); bool IsIP4(IP *ip); bool IsSameIPVer(IP *ip1, IP *ip2); @@ -1489,7 +1486,6 @@ UINT GetIPAddrType6(IP *ip); UINT GetIPv6AddrType(IPV6_ADDR *addr); void GenerateMulticastMacAddress6(UCHAR *mac, IP *ip); void GetSoliciationMulticastAddr6(IP *dst, IP *src); -bool CheckUnicastAddress(IP *ip); bool IsNetworkPrefixAddress6(IP *ip, IP *subnet); bool IsNetworkAddress6(IP *ip, IP *subnet); void GetHostAddress6(IP *dst, IP *ip, IP *subnet); diff --git a/src/Mayaqua/Secure.c b/src/Mayaqua/Secure.c index ef43ad7a..e995a5fb 100644 --- a/src/Mayaqua/Secure.c +++ b/src/Mayaqua/Secure.c @@ -838,32 +838,6 @@ bool DeleteSecCert(SECURE *sec, char *name) return DeleteSecObjectByName(sec, name, SEC_X); } -// Convert the the CK_DATE to the 64 bit time -UINT64 CkDateToUINT64(struct CK_DATE *ck_date) -{ - SYSTEMTIME st; - char year[32], month[32], day[32]; - // Validate arguments - if (ck_date == NULL) - { - return 0; - } - - Zero(year, sizeof(year)); - Zero(month, sizeof(month)); - Zero(day, sizeof(day)); - - Copy(year, ck_date->year, 4); - Copy(month, ck_date->month, 2); - Copy(day, ck_date->day, 2); - - st.wYear = ToInt(year); - st.wMonth = ToInt(month); - st.wDay = ToInt(day); - - return SystemToUINT64(&st); -} - // Convert the 64 bit time to the CK_DATE void UINT64ToCkDate(void *p_ck_date, UINT64 time64) { diff --git a/src/Mayaqua/Str.c b/src/Mayaqua/Str.c index 5d386755..f9fe2d41 100644 --- a/src/Mayaqua/Str.c +++ b/src/Mayaqua/Str.c @@ -2021,23 +2021,6 @@ char *CopyBinToStrEx(void *data, UINT data_size) return ret; } -char *CopyBinToStr(void *data, UINT data_size) -{ - char *ret; - UINT size; - // Validate arguments - if (data == NULL) - { - return NULL; - } - - size = data_size * 2 + 1; - ret = ZeroMalloc(size); - - BinToStr(ret, size, data, data_size); - - return ret; -} // Convert the binary data to a hexadecimal string void BinToStr(char *str, UINT str_size, void *data, UINT data_size) diff --git a/src/Mayaqua/Str.h b/src/Mayaqua/Str.h index 92da8dc8..ac0b33d0 100644 --- a/src/Mayaqua/Str.h +++ b/src/Mayaqua/Str.h @@ -207,7 +207,6 @@ bool IsEmptyStr(char *str); void BinToStrEx(char *str, UINT str_size, void *data, UINT data_size); void BinToStrEx2(char *str, UINT str_size, void *data, UINT data_size, char padding_char); char *CopyBinToStrEx(void *data, UINT data_size); -char *CopyBinToStr(void *data, UINT data_size); BUF *StrToBin(char *str); void MacToStr(char *str, UINT size, UCHAR *mac_address); void ToStr3(char *str, UINT size, UINT64 v); diff --git a/src/Mayaqua/Tracking.c b/src/Mayaqua/Tracking.c index 1a1ccfd1..434d697e 100644 --- a/src/Mayaqua/Tracking.c +++ b/src/Mayaqua/Tracking.c @@ -589,33 +589,6 @@ void TrackChangeObjSize(UINT64 addr, UINT size, UINT64 new_addr) UnlockTrackingList(); } -// Memory address comparison function -int CompareTrackingObject(const void *p1, const void *p2) -{ - TRACKING_OBJECT *o1, *o2; - // Validate arguments - if (p1 == NULL || p2 == NULL) - { - return 0; - } - o1 = *(TRACKING_OBJECT **)p1; - o2 = *(TRACKING_OBJECT **)p2; - if (o1 == NULL || o2 == NULL) - { - return 0; - } - - if (o1->Address > o2->Address) - { - return 1; - } - if (o1->Address == o2->Address) - { - return 0; - } - return -1; -} - // Search an object in the tracking list TRACKING_OBJECT *SearchTrackingList(UINT64 Address) { diff --git a/src/Mayaqua/Tracking.h b/src/Mayaqua/Tracking.h index 8706c9fe..882414b9 100644 --- a/src/Mayaqua/Tracking.h +++ b/src/Mayaqua/Tracking.h @@ -166,7 +166,6 @@ void GetCallStackStr(char *str, UINT size, CALLSTACK_DATA *s); void PrintCallStack(CALLSTACK_DATA *s); void InitTracking(); void FreeTracking(); -int CompareTrackingObject(const void *p1, const void *p2); void LockTrackingList(); void UnlockTrackingList(); void InsertTrackingList(TRACKING_OBJECT *o);