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 d5385b3a..06bc0ce2 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/Logging.c b/src/Cedar/Logging.c index abf5b0bc..a5ec927d 100644 --- a/src/Cedar/Logging.c +++ b/src/Cedar/Logging.c @@ -287,23 +287,6 @@ void FreeEraseFileList(LIST *o) ReleaseList(o); } -// Show the deleting file list -void PrintEraseFileList(LIST *o) -{ - UINT i; - // Validate arguments - if (o == NULL) - { - return; - } - - for (i = 0;i < LIST_NUM(o);i++) - { - ERASE_FILE *f = LIST_DATA(o, i); - Print("%I64u - %s\n", f->UpdateTime, f->FullPath); - } -} - // Generate a deleting file list of the specified directory void EnumEraseFile(LIST *o, char *dirname) { @@ -614,23 +597,6 @@ void ELog(ERASER *e, char *name, ...) va_end(args); } -// Take the log of the server -void ServerLog(CEDAR *c, wchar_t *fmt, ...) -{ - wchar_t buf[MAX_SIZE * 2]; - va_list args; - // Validate arguments - if (fmt == NULL) - { - return; - } - - va_start(args, fmt); - UniFormatArgs(buf, sizeof(buf), fmt, args); - - WriteServerLog(c, buf); - va_end(args); -} void SLog(CEDAR *c, char *name, ...) { wchar_t buf[MAX_SIZE * 2]; @@ -672,22 +638,6 @@ void CLog(CLIENT *c, char *name, ...) } // Take the security log of the HUB -void HubLog(HUB *h, wchar_t *fmt, ...) -{ - wchar_t buf[MAX_SIZE * 2]; - va_list args; - // Validate arguments - if (fmt == NULL) - { - return; - } - - va_start(args, fmt); - UniFormatArgs(buf, sizeof(buf), fmt, args); - - WriteHubLog(h, buf); - va_end(args); -} void ALog(ADMIN *a, HUB *h, char *name, ...) { wchar_t buf[MAX_SIZE * 2]; @@ -880,34 +830,6 @@ void PPPLog(PPP_SESSION *p, char *name, ...) WriteServerLog(p->Cedar, buf); } -// Write an IPC log -void IPCLog(IPC *ipc, char *name, ...) -{ - wchar_t buf[MAX_SIZE * 2]; - va_list args; - HUB *h; - // Validate arguments - if (name == NULL) - { - return; - } - - h = GetHub(ipc->Cedar, ipc->HubName); - - if (h == NULL) - { - return; - } - - va_start(args, name); - UniFormatArgs(buf, sizeof(buf), _UU(name), args); - - WriteHubLog(h, buf); - va_end(args); - - ReleaseHub(h); -} - // Save the security log of the HUB void WriteHubLog(HUB *h, wchar_t *str) { @@ -989,69 +911,6 @@ void WriteServerLog(CEDAR *c, wchar_t *str) } } -// Write a multi-line log -void WriteMultiLineLog(LOG *g, BUF *b) -{ - // Validate arguments - if (g == NULL || b == NULL) - { - return; - } - - SeekBuf(b, 0, 0); - - while (true) - { - char *s = CfgReadNextLine(b); - if (s == NULL) - { - break; - } - - if (IsEmptyStr(s) == false) - { - InsertStringRecord(g, s); - } - - Free(s); - } -} - -// Take the security log (variable-length argument) *abolished -void SecLog(HUB *h, char *fmt, ...) -{ - char buf[MAX_SIZE * 2]; - va_list args; - // Validate arguments - if (fmt == NULL) - { - return; - } - - if (h->LogSetting.SaveSecurityLog == false) - { - return; - } - - va_start(args, fmt); - FormatArgs(buf, sizeof(buf), fmt, args); - - WriteSecurityLog(h, buf); - va_end(args); -} - -// Take a security log -void WriteSecurityLog(HUB *h, char *str) -{ - // Validate arguments - if (h == NULL || str == NULL) - { - return; - } - - InsertStringRecord(h->SecurityLogger, str); -} - // Take a packet log bool PacketLog(HUB *hub, SESSION *src_session, SESSION *dest_session, PKT *packet, UINT64 now) { @@ -2272,46 +2131,6 @@ void ReplaceForCsv(char *str) } } -// Set the directory name of the log -void SetLogDirName(LOG *g, char *dir) -{ - // Validate arguments - if (g == NULL || dir == NULL) - { - return; - } - - LockLog(g); - { - if (g->DirName != NULL) - { - Free(g->DirName); - } - g->DirName = CopyStr(dir); - } - UnlockLog(g); -} - -// Set the name of the log -void SetLogPrefix(LOG *g, char *prefix) -{ - // Validate arguments - if (g == NULL || prefix == NULL) - { - return; - } - - LockLog(g); - { - if (g->DirName != NULL) - { - Free(g->Prefix); - } - g->DirName = CopyStr(prefix); - } - UnlockLog(g); -} - // Set the switch type of log void SetLogSwitchType(LOG *g, UINT switch_type) { diff --git a/src/Cedar/Logging.h b/src/Cedar/Logging.h index 65131af5..81220af1 100644 --- a/src/Cedar/Logging.h +++ b/src/Cedar/Logging.h @@ -223,8 +223,6 @@ char *StringRecordParseProc(RECORD *rec); bool MakeLogFileName(LOG *g, char *name, UINT size, char *dir, char *prefix, UINT64 tick, UINT switch_type, UINT num, char *old_datestr); void MakeLogFileNameStringFromTick(LOG *g, char *str, UINT size, UINT64 tick, UINT switch_type); void WriteRecordToBuffer(BUF *b, RECORD *r); -void SetLogDirName(LOG *g, char *dir); -void SetLogPrefix(LOG *g, char *prefix); void SetLogSwitchType(LOG *g, UINT switch_type); bool PacketLog(HUB *hub, SESSION *src_session, SESSION *dest_session, PKT *packet, UINT64 now); char *PacketLogParseProc(RECORD *rec); @@ -234,17 +232,12 @@ char *GenCsvLine(TOKEN_LIST *t); void ReplaceForCsv(char *str); char *PortStr(CEDAR *cedar, UINT port, bool udp); char *TcpFlagStr(UCHAR flag); -void WriteSecurityLog(HUB *h, char *str); -void SecLog(HUB *h, char *fmt, ...); void SiSetDefaultLogSetting(HUB_LOG *g); void DebugLog(CEDAR *c, char *fmt, ...); -void HubLog(HUB *h, wchar_t *fmt, ...); -void ServerLog(CEDAR *c, wchar_t *fmt, ...); void SLog(CEDAR *c, char *name, ...); void WriteHubLog(HUB *h, wchar_t *str); void HLog(HUB *h, char *name, ...); void NLog(VH *v, char *name, ...); -void IPCLog(IPC *ipc, char *name, ...); void PPPLog(PPP_SESSION *p, char *name, ...); void IPsecLog(IKE_SERVER *ike, IKE_CLIENT *c, IKE_SA *ike_sa, IPSECSA *ipsec_sa, char *name, ...); void EtherIPLog(ETHERIP_SERVER *s, char *name, ...); @@ -261,13 +254,11 @@ bool CheckEraserDiskFreeSpace(ERASER *e); int CompareEraseFile(void *p1, void *p2); LIST *GenerateEraseFileList(ERASER *e); void FreeEraseFileList(LIST *o); -void PrintEraseFileList(LIST *o); void EnumEraseFile(LIST *o, char *dirname); SLOG *NewSysLog(char *hostname, UINT port, IP *ip); void SetSysLog(SLOG *g, char *hostname, UINT port); void FreeSysLog(SLOG *g); void SendSysLog(SLOG *g, wchar_t *str); -void WriteMultiLineLog(LOG *g, BUF *b); char *BuildHttpLogStr(HTTPLOG *h); void MakeSafeLogStr(char *str); void AddLogBufToStr(BUF *b, char *name, char *value); diff --git a/src/Cedar/Protocol.c b/src/Cedar/Protocol.c index 9cf11dff..f73ab655 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 2abc0afc..a34aa07b 100644 --- a/src/Cedar/WinUi.c +++ b/src/Cedar/WinUi.c @@ -1130,25 +1130,6 @@ void FreeWizard(WIZARD *w) Free(w); } -// Get the index page of the wizard -UINT GetWizardPageIndex(WIZARD *w, UINT id) -{ - WIZARD_PAGE *p; - // Validate arguments - if (w == NULL || id == 0) - { - return INFINITE; - } - - p = GetWizardPage(w, id); - if (p == NULL) - { - return INFINITE; - } - - return p->Index; -} - // Get the wizard page WIZARD_PAGE *GetWizardPage(WIZARD *w, UINT id) { @@ -1555,10 +1536,6 @@ UINT WinConnectDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam, void * } // TCP connection with showing the UI -SOCK *WinConnectEx2(HWND hWnd, char *server, UINT port, UINT timeout, UINT icon_id, wchar_t *caption, wchar_t *info, bool try_start_ssl, bool ssl_no_tls) -{ - return WinConnectEx3(hWnd, server, port, timeout, icon_id, caption, info, NULL, false, try_start_ssl, ssl_no_tls); -} SOCK *WinConnectEx3(HWND hWnd, char *server, UINT port, UINT timeout, UINT icon_id, wchar_t *caption, wchar_t *info, UINT *nat_t_error_code, char *nat_t_svc_name, bool try_start_ssl, bool ssl_no_tls) { wchar_t tmp[MAX_SIZE]; @@ -2023,30 +2000,6 @@ bool Win32CnCheckAlreadyExists(bool lock) return false; } -// Get whether it is set to not display the dialog about the free version -bool IsRegistedToDontShowFreeEditionDialog(char *server_name) -{ - // Validate arguments - if (server_name == NULL) - { - return false; - } - - if (MsRegReadInt(REG_LOCAL_MACHINE, FREE_REGKEY, server_name) != 0) - { - return true; - } - - if (MsRegWriteInt(REG_LOCAL_MACHINE, FREE_REGKEY, "__test__", 1) == false) - { - return true; - } - - MsRegDeleteValue(REG_LOCAL_MACHINE, FREE_REGKEY, "__test__"); - - return false; -} - // Set in the registry not to show a dialog about the free version void RegistToDontShowFreeEditionDialog(char *server_name) { @@ -2059,147 +2012,6 @@ void RegistToDontShowFreeEditionDialog(char *server_name) MsRegWriteInt(REG_LOCAL_MACHINE, FREE_REGKEY, server_name, 1); } -// Free Edition dialog procedure -UINT FreeInfoDialogProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam, void *param) -{ - FREEINFO *info = (FREEINFO *)param; - // Validate arguments - if (hWnd == NULL) - { - return 0; - } - - switch (msg) - { - case WM_INITDIALOG: - SetIcon(hWnd, 0, ICO_HUB); - Top(hWnd); - info->hWnd = hWnd; - Set(info->Event); - FormatText(hWnd, S_INFO_2, info->ServerName); - DlgFont(hWnd, S_INFO_1, 13, true); - DlgFont(hWnd, S_INFO_3, 13, false); - DlgFont(hWnd, B_HIDE, 10, true); - break; - - case WM_COMMAND: - switch (wParam) - { - case IDOK: - case IDCANCEL: - if (IsChecked(hWnd, B_HIDE)) - { - RegistToDontShowFreeEditionDialog(info->ServerName); - } - - Close(hWnd); - break; - } - break; - - case WM_CLOSE: - EndDialog(hWnd, 0); - break; - } - - return 0; -} - -// Display the dialog about the Free Edition -void ShowFreeInfoDialog(HWND hWnd, FREEINFO *info) -{ - // Validate arguments - if (info == NULL) - { - return; - } - - Dialog(hWnd, D_FREEINFO, FreeInfoDialogProc, info); - Set(info->Event); -} - -// Free Edition dialog thread -void FreeInfoThread(THREAD *thread, void *param) -{ - FREEINFO *info = (FREEINFO *)param; - // Validate arguments - if (thread == NULL || info == NULL) - { - return; - } - - ShowFreeInfoDialog(NULL, info); -} - -// Start the Free Edition Announcement dialog -FREEINFO *StartFreeInfoDlg(char *server_name) -{ - FREEINFO *info; - - if (IsRegistedToDontShowFreeEditionDialog(server_name)) - { - return NULL; - } - - info = ZeroMalloc(sizeof(FREEINFO)); - - StrCpy(info->ServerName, sizeof(info->ServerName), server_name); - info->Event = NewEvent(); - - info->Thread = NewThread(FreeInfoThread, info); - Wait(info->Event, INFINITE); - ReleaseEvent(info->Event); - info->Event = NULL; - - return info; -} - -// End the Free Edition Announcement dialog -void EndFreeInfoDlg(FREEINFO *info) -{ - // Validate arguments - if (info == NULL) - { - return; - } - - SendMsg(info->hWnd, 0, WM_CLOSE, 0, 0); - WaitThread(info->Thread, INFINITE); - ReleaseThread(info->Thread); - - Free(info); -} - -// Execute a EXE in the hamcore -bool ExecuteHamcoreExe(char *name) -{ - BUF *b; - wchar_t tmp[MAX_PATH]; - char tmp2[MAX_PATH]; - UCHAR hash[MD5_SIZE]; - // Validate arguments - if (name == NULL) - { - return false; - } - - b = ReadDump(name); - if (b == NULL) - { - return false; - } - - Hash(hash, name, StrLen(name), false); - BinToStr(tmp2, sizeof(tmp2), hash, sizeof(hash)); - UniFormat(tmp, sizeof(tmp), L"%s\\tmp_%S.exe", MsGetMyTempDirW(), tmp2); - SeekBuf(b, 0, 0); - DumpBufW(b, tmp); - - FreeBuf(b); - - return RunW(tmp, NULL, false, false); -} - // Show the Easter Egg void ShowEasterEgg(HWND hWnd) { @@ -2924,40 +2736,6 @@ HFONT GetDialogDefaultFontEx(bool meiryo) return GetFont(default_font_name, default_font_size, false, false, false, false); } -// Get the adjustment scale between the control size and the window size -void GetWindowAndControlSizeResizeScale(HWND hWnd, bool *need_resize, double *factor_x, double *factor_y) -{ - UINT dlgfont_x, dlgfont_y; - HFONT hDlgFont; - // Validate arguments - if (hWnd == NULL || need_resize == NULL || factor_x == NULL || factor_y == NULL) - { - return; - } - - *need_resize = true; - - // Get the font of the current window - hDlgFont = (HFONT)SendMsg(hWnd, 0, WM_GETFONT, 0, 0); - - // Get the width and height of the font of the current window - CalcFontSize(hDlgFont, &dlgfont_x, &dlgfont_y); - - if ((dlgfont_x == WINUI_DEFAULT_DIALOG_UNIT_X) && - (dlgfont_y == WINUI_DEFAULT_DIALOG_UNIT_Y)) - { - // There is no need to adjust - *need_resize = false; - *factor_x = 1.0; - *factor_y = 1.0; - return; - } - - // Calculate the adjustment amount - *factor_x = (double)dlgfont_x / (double)WINUI_DEFAULT_DIALOG_UNIT_X; - *factor_y = (double)dlgfont_y / (double)WINUI_DEFAULT_DIALOG_UNIT_Y; -} - // Adjust the control size and window size void AdjustWindowAndControlSize(HWND hWnd, bool *need_resize, double *factor_x, double *factor_y) { @@ -3651,20 +3429,6 @@ char *StringDlgA(HWND hWnd, wchar_t *title, wchar_t *info, char *def, UINT icon, return ret; } -// Draw frame -void LedDrawRect(LED *d) -{ - RECT r; - // Validate arguments - if (d == NULL) - { - return; - } - - SetRect(&r, 0, 0, LED_WIDTH, LED_HEIGHT); - FrameRect(d->hDC, &r, GetStockObject(WHITE_BRUSH)); -} - // Restarting dialog UINT Win9xRebootDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam, void *param) { @@ -3963,18 +3727,6 @@ bool IpIsFilled(HWND hWnd, UINT id) } } -// Clear the IP address -void IpClear(HWND hWnd, UINT id) -{ - // Validate arguments - if (hWnd == NULL) - { - return; - } - - SendMsg(hWnd, id, IPM_CLEARADDRESS, 0, 0); -} - // Get an IP address UINT IpGet(HWND hWnd, UINT id) { @@ -4538,39 +4290,6 @@ void SetMenuItemBold(HMENU hMenu, UINT pos, bool bold) SetMenuItemInfo(hMenu, pos, true, &info); } -// Enable / disable the menu item -void SetMenuItemEnable(HMENU hMenu, UINT pos, bool enable) -{ - MENUITEMINFO info; - // Validate arguments - if (hMenu == NULL || pos == INFINITE) - { - return; - } - - Zero(&info, sizeof(info)); - info.cbSize = sizeof(info); - info.fMask = MIIM_STATE; - - if (GetMenuItemInfo(hMenu, pos, true, &info) == false) - { - return; - } - - if (enable) - { - info.fState |= MFS_ENABLED; - info.fState = info.fState & ~MFS_DISABLED; - } - else - { - info.fState |= MFS_DISABLED; - info.fState = info.fState & ~MFS_ENABLED; - } - - SetMenuItemInfo(hMenu, pos, true, &info); -} - // Remove a menu item void DeleteMenuItem(HMENU hMenu, UINT pos) { @@ -5703,10 +5422,6 @@ UINT LvInsertItemByImageListIdA(HWND hWnd, UINT id, UINT image, void *param, cha } // Change the image -void LvSetItemImage(HWND hWnd, UINT id, UINT index, UINT icon) -{ - LvSetItemImageByImageListId(hWnd, id, index, GetIcon(icon)); -} void LvSetItemImageByImageListId(HWND hWnd, UINT id, UINT index, UINT image) { LVITEM t; @@ -5830,18 +5545,6 @@ void LvSetView(HWND hWnd, UINT id, bool details) } } -// Ensure that the specified item is visible -void LvShow(HWND hWnd, UINT id, UINT index) -{ - // Validate arguments - if (hWnd == NULL) - { - return; - } - - ListView_EnsureVisible(DlgItem(hWnd, id), index, false); -} - // Get whether there is currently selected item bool LvIsSelected(HWND hWnd, UINT id) { @@ -5999,31 +5702,6 @@ bool LvIsMasked(HWND hWnd, UINT id) return true; } -// Get the number of items that are currently masked -UINT LvGetMaskedNum(HWND hWnd, UINT id) -{ - UINT i = INFINITE; - UINT num = 0; - // Validate arguments - if (hWnd == NULL) - { - return 0; - } - - while (true) - { - i = LvGetNextMasked(hWnd, id, i); - if (i == INFINITE) - { - break; - } - - num++; - } - - return num; -} - // Get the items that is currently masked UINT LvGetNextMasked(HWND hWnd, UINT id, UINT start) { @@ -6036,27 +5714,6 @@ UINT LvGetNextMasked(HWND hWnd, UINT id, UINT start) return ListView_GetNextItem(DlgItem(hWnd, id), start, LVNI_SELECTED); } -// Search an item with the specified string -UINT LvSearchStr_(HWND hWnd, UINT id, UINT pos, wchar_t *str) -{ - UINT ret; - LVFINDINFOW t; - // Validate arguments - if (hWnd == NULL || str == NULL) - { - return INFINITE; - } - - Zero(&t, sizeof(t)); - t.flags = LVFI_STRING; - t.psz = str; - t.vkDirection = VK_DOWN; - - ret = SendMsg(hWnd, id, LVM_FINDITEMW, -1, (LPARAM)&t); - - return ret; -} - // Search an item with the specified string UINT LvSearchStr(HWND hWnd, UINT id, UINT pos, wchar_t *str) { @@ -6811,33 +6468,6 @@ STATUS_WINDOW *StatusPrinterWindowStart(SOCK *s, wchar_t *account_name) return sw; } -// Get the string -wchar_t *LbGetStr(HWND hWnd, UINT id) -{ - // Validate arguments - if (hWnd == NULL) - { - return NULL; - } - - return GetText(hWnd, id); -} - -// String search -UINT LbFindStr(HWND hWnd, UINT id, wchar_t *str) -{ - UINT ret; - // Validate arguments - if (hWnd == NULL || str == NULL) - { - return INFINITE; - } - - ret = SendMsg(hWnd, id, LB_FINDSTRING, -1, (LPARAM)str); - - return ret; -} - // Get the number of items UINT LbNum(HWND hWnd, UINT id) { @@ -6850,104 +6480,6 @@ UINT LbNum(HWND hWnd, UINT id) return SendMsg(hWnd, id, LB_GETCOUNT, 0, 0); } -// Add a string -UINT LbAddStr(HWND hWnd, UINT id, wchar_t *str, UINT data) -{ - UINT ret; - - if (MsIsNt() == false) - { - char *s = CopyUniToStr(str); - ret = LbAddStrA(hWnd, id, s, data); - Free(s); - return ret; - } - - // Validate arguments - if (hWnd == NULL || str == NULL) - { - return INFINITE; - } - - ret = SendMsg(hWnd, id, LB_ADDSTRING, 0, (LPARAM)str); - SendMsg(hWnd, id, LB_SETITEMDATA, ret, (LPARAM)data); - - if (LbNum(hWnd, id) == 1) - { - LbSelectIndex(hWnd, id, 0); - } - - return ret; -} -UINT LbAddStrA(HWND hWnd, UINT id, char *str, UINT data) -{ - UINT ret; - // Validate arguments - if (hWnd == NULL || str == NULL) - { - return INFINITE; - } - - ret = SendMsg(hWnd, id, LB_ADDSTRING, 0, (LPARAM)str); - SendMsg(hWnd, id, LB_SETITEMDATA, ret, (LPARAM)data); - - if (LbNum(hWnd, id) == 1) - { - LbSelectIndex(hWnd, id, 0); - } - - return ret; -} - -// Insert a string -UINT LbInsertStr(HWND hWnd, UINT id, UINT index, wchar_t *str, UINT data) -{ - UINT ret; - - if (MsIsNt() == false) - { - char *s = CopyUniToStr(str); - ret = LbInsertStrA(hWnd, id, index, s, data); - Free(s); - return ret; - } - - // Validate arguments - if (hWnd == NULL || str == NULL) - { - return INFINITE; - } - - ret = SendMsg(hWnd, id, LB_INSERTSTRING, index, (LPARAM)str); - SendMsg(hWnd, id, LB_SETITEMDATA, ret, (LPARAM)data); - - if (LbNum(hWnd, id) == 1) - { - LbSelect(hWnd, id, 0); - } - - return ret; -} -UINT LbInsertStrA(HWND hWnd, UINT id, UINT index, char *str, UINT data) -{ - UINT ret; - // Validate arguments - if (hWnd == NULL || str == NULL) - { - return INFINITE; - } - - ret = SendMsg(hWnd, id, LB_INSERTSTRING, index, (LPARAM)str); - SendMsg(hWnd, id, LB_SETITEMDATA, ret, (LPARAM)data); - - if (LbNum(hWnd, id) == 1) - { - LbSelect(hWnd, id, 0); - } - - return ret; -} - // Remove all void LbReset(HWND hWnd, UINT id) { @@ -6960,18 +6492,6 @@ void LbReset(HWND hWnd, UINT id) SendMsg(hWnd, id, LB_RESETCONTENT, 0, 0); } -// Select by specifying the index -void LbSelectIndex(HWND hWnd, UINT id, UINT index) -{ - // Validate arguments - if (hWnd == NULL) - { - return; - } - - SendMsg(hWnd, id, LB_SETCURSEL, index, 0); -} - // Get the data UINT LbGetData(HWND hWnd, UINT id, UINT index) { @@ -6984,104 +6504,6 @@ UINT LbGetData(HWND hWnd, UINT id, UINT index) return SendMsg(hWnd, id, LB_GETITEMDATA, index, 0); } -// Search for the data -UINT LbFindData(HWND hWnd, UINT id, UINT data) -{ - UINT i, num; - // Validate arguments - if (hWnd == NULL) - { - return INFINITE; - } - - num = LbNum(hWnd, id); - if (num == INFINITE) - { - return INFINITE; - } - - for (i = 0;i < num;i++) - { - if (LbGetData(hWnd, id, i) == data) - { - return i; - } - } - - return INFINITE; -} - -// Set the height of the item -void LbSetHeight(HWND hWnd, UINT id, UINT value) -{ - // Validate arguments - if (hWnd == NULL) - { - return; - } - - SendMsg(hWnd, id, LB_SETITEMHEIGHT, 0, (UINT)(GetTextScalingFactor() * (double)value)); -} - -// Search by specifying the data -void LbSelect(HWND hWnd, UINT id, int data) -{ - UINT index; - // Validate arguments - if (hWnd == NULL) - { - return; - } - - if (data == INFINITE) - { - // Get the first item - LbSelectIndex(hWnd, id, 0); - return; - } - - index = LbFindData(hWnd, id, data); - if (index == INFINITE) - { - // Can not be found - return; - } - - // Select - LbSelectIndex(hWnd, id, index); -} - -// Get the currently selected item -UINT LbGetSelectIndex(HWND hWnd, UINT id) -{ - // Validate arguments - if (hWnd == NULL) - { - return INFINITE; - } - - return SendMsg(hWnd, id, LB_GETCURSEL, 0, 0); -} - -// Get the value that is currently selected -UINT LbGetSelect(HWND hWnd, UINT id) -{ - UINT index; - // Validate arguments - if (hWnd == NULL) - { - return INFINITE; - } - - index = LbGetSelectIndex(hWnd, id); - if (index == INFINITE) - { - return INFINITE; - } - - return LbGetData(hWnd, id, index); -} - // Password input dialog state change void PasswordDlgProcChange(HWND hWnd, UI_PASSWORD_DLG *p) { @@ -7239,54 +6661,6 @@ UINT CbAddStr9xA(HWND hWnd, UINT id, char *str, UINT data) return ret; } -// Insert a string -UINT CbInsertStr(HWND hWnd, UINT id, UINT index, wchar_t *str, UINT data) -{ - UINT ret; - // Validate arguments - if (hWnd == NULL || str == NULL) - { - return INFINITE; - } - - if (MsIsNt() == false) - { - char *s = CopyUniToStr(str); - ret = CbInsertStr9xA(hWnd, id, index, s, data); - Free(s); - return ret; - } - - ret = SendMsg(hWnd, id, CB_INSERTSTRING, index, (LPARAM)str); - SendMsg(hWnd, id, CB_SETITEMDATA, ret, (LPARAM)data); - - if (CbNum(hWnd, id) == 1) - { - CbSelect(hWnd, id, 0); - } - - return ret; -} -UINT CbInsertStr9xA(HWND hWnd, UINT id, UINT index, char *str, UINT data) -{ - UINT ret; - // Validate arguments - if (hWnd == NULL || str == NULL) - { - return INFINITE; - } - - ret = SendMsg(hWnd, id, CB_INSERTSTRING, index, (LPARAM)str); - SendMsg(hWnd, id, CB_SETITEMDATA, ret, (LPARAM)data); - - if (CbNum(hWnd, id) == 1) - { - CbSelect(hWnd, id, 0); - } - - return ret; -} - // Remove all void CbReset(HWND hWnd, UINT id) { @@ -7853,155 +7227,6 @@ UINT PassphraseDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam, void * return 0; } -// PKCS utility -void PkcsUtil() -{ - InitWinUi(_UU("PKCS_UTIL_TITLE"), _SS("DEFAULT_FONT"), _II("DEFAULT_FONT_SIZE")); - Dialog(NULL, D_PKCSUTIL, PkcsUtilProc, NULL); - FreeWinUi(); -} - -// PKCS writing -void PkcsUtilWrite(HWND hWnd) -{ - wchar_t *filename; - BUF *in_buf; - char filename_ansi[MAX_SIZE]; - char pass[MAX_SIZE]; - // Validate arguments - if (hWnd == NULL) - { - return; - } - - filename = OpenDlg(hWnd, _UU("DLG_PKCS12_FILTER"), _UU("PKCS_UTIL_SAVEDLG_TITLE")); - if (filename == NULL) - { - return; - } - - UniToStr(filename_ansi, sizeof(filename_ansi), filename); - - in_buf = ReadDump(filename_ansi); - - if (in_buf == NULL) - { - MsgBoxEx(hWnd, MB_ICONEXCLAMATION, _UU("PKCS_UTIL_READ_ERROR"), filename); - } - else - { - if (PassphraseDlg(hWnd, pass, sizeof(pass), in_buf, true)) - { - P12 *p12 = BufToP12(in_buf); - if (p12 == NULL) - { - MsgBox(hWnd, MB_ICONEXCLAMATION, _UU("PKCS_UTIL_BAD_FILE")); - } - else - { - X *x = NULL; - K *k = NULL; - BUF *b; - ParseP12(p12, &x, &k, pass); - FreeP12(p12); - p12 = NewP12(x, k, NULL); - FreeX(x); - FreeK(k); - b = P12ToBuf(p12); - FreeP12(p12); - if (b != NULL) - { - // Batch processing - WINUI_SECURE_BATCH batch[] = - { - {WINUI_SECURE_WRITE_DATA, _SS("PKCS_UTIL_SECA_FILENAME"), false, - b, NULL, NULL, NULL, NULL, NULL}, - }; - - if (SecureDeviceWindow(hWnd, batch, sizeof(batch) / sizeof(batch[0]), 2, 0)) - { - MsgBoxEx(hWnd, MB_ICONINFORMATION, _UU("PKCS_UTIL_WRITE_OK_MSG"), filename); - } - } - FreeBuf(b); - } - } - - FreeBuf(in_buf); - } - - Free(filename); -} - -// PKCS erase -void PkcsUtilErase(HWND hWnd) -{ - // Validate arguments - if (hWnd == NULL) - { - return; - } - - if (MsgBox(hWnd, MB_ICONQUESTION | MB_YESNO | MB_DEFBUTTON2, - _UU("PKCS_MAKE_SURE")) == IDYES) - { - // Batch processing - WINUI_SECURE_BATCH batch[] = - { - {WINUI_SECURE_DELETE_OBJECT, _SS("PKCS_UTIL_SECA_FILENAME"), false, - NULL, NULL, NULL, NULL, NULL, NULL}, - }; - - if (SecureDeviceWindow(hWnd, batch, sizeof(batch) / sizeof(batch[0]), 2, 0)) - { - MsgBox(hWnd, MB_ICONINFORMATION, _UU("PKCS_UTIL_DELETE_OK_MSG")); - } - } -} - -// PKCS Utility dialog -UINT PkcsUtilProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam, void *param) -{ - // Validate arguments - if (hWnd == NULL) - { - return 0; - } - - switch (msg) - { - case WM_INITDIALOG: - DlgFont(hWnd, S_TITLE, 12, true); - SetIcon(hWnd, 0, ICO_CERT); - SetFont(hWnd, S_COPYRIGHT, GetFont("Arial", 8, false, false, false, false)); - break; - - case WM_COMMAND: - switch (wParam) - { - case B_WRITE: - PkcsUtilWrite(hWnd); - break; - - case B_ERASE: - PkcsUtilErase(hWnd); - break; - - case IDCANCEL: - Close(hWnd); - break; - } - - break; - - case WM_CLOSE: - EndDialog(hWnd, 0); - break; - } - - return 0; -} - // [Save File] dialog wchar_t *SaveDlg(HWND hWnd, wchar_t *filter, wchar_t *title, wchar_t *default_name, wchar_t *default_ext) { @@ -8935,114 +8160,6 @@ UINT DialogEx2(HWND hWnd, UINT id, WINUI_DIALOG_PROC *proc, void *param, bool wh return ret; } -// Create a modeless dialog -HWND DialogCreateEx(HWND hWnd, UINT id, WINUI_DIALOG_PROC *proc, void *param, bool white) -{ - HWND ret = NULL; - DIALOG_PARAM p; - // Validate arguments - if (id == 0) - { - return 0; - } - - Zero(&p, sizeof(p)); - p.param = param; - p.white = white; - p.proc = proc; - - if (MsIsNt() == false) - { - // Win9x - ret = CreateDialogParamA(hDll, MAKEINTRESOURCEA(id), hWnd, - (DLGPROC)proc, (LPARAM)param); - } - else - { - // WinNT - ret = CreateDialogParamW(hDll, MAKEINTRESOURCEW(id), hWnd, - (DLGPROC)proc, (LPARAM)param); - } - - return ret; -} - -// Set the bitmap to the button -void SetBitmap(HWND hWnd, UINT id, UINT bmp_id) -{ - HBITMAP bmp; - char *class_name; - DIALOG_PARAM *dialog_param = NULL; - bool need_resize = 0; - double resize_x = 1.0; - double resize_y = 1.0; - bool add_to_free_list = false; - // Validate arguments - if (hWnd == NULL) - { - return; - } - - bmp = LoadImage(hDll, MAKEINTRESOURCE(bmp_id), IMAGE_BITMAP, 0, 0, (MsIsNt() ? LR_SHARED : 0) | LR_VGACOLOR); - if (bmp == NULL) - { - return; - } - - dialog_param = GetParam(hWnd); - - // Determine the need for resizing - if (dialog_param) - { - if (MsIsVista()) - { - GetWindowAndControlSizeResizeScale(hWnd, &need_resize, &resize_x, &resize_y); - - if (need_resize) - { - // Resize - UINT src_x, src_y, dst_x, dst_y; - - if (GetBitmapSize(bmp, &src_x, &src_y)) - { - HBITMAP new_bmp; - double scale_factor = MIN(resize_x, resize_y); - - dst_x = (UINT)((double)src_x * scale_factor); - dst_y = (UINT)((double)src_y * scale_factor); - - new_bmp = ResizeBitmap(bmp, src_x, src_y, dst_x, dst_y); - - if (new_bmp != NULL) - { - bmp = new_bmp; - - add_to_free_list = true; - } - } - } - } - } - - class_name = GetClassA(hWnd, id); - - if (StrCmpi(class_name, "Static") != 0) - { - SendMsg(hWnd, id, BM_SETIMAGE, IMAGE_BITMAP, (LPARAM)bmp); - } - else - { - SendMsg(hWnd, id, STM_SETIMAGE, IMAGE_BITMAP, (LPARAM)bmp); - } - - Free(class_name); - - if (add_to_free_list) - { - Add(dialog_param->BitmapList, bmp); - } -} - // Initialize the icon cache void InitIconCache() { @@ -9251,44 +8368,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) { @@ -9322,58 +8401,6 @@ void SetFontEx(HWND hWnd, UINT id, HFONT hFont, bool no_adjust_font_size) } } -// Get the font size -bool GetFontSize(HFONT hFont, UINT *x, UINT *y) -{ - bool ret = false; - UINT xx = 0; - UINT yy = 0; - - // Search for the font handle - LockList(font_list); - { - UINT i; - - for (i = 0;i < LIST_NUM(font_list);i++) - { - FONT *f = LIST_DATA(font_list, i); - - if (f->hFont == hFont) - { - xx = f->x; - yy = f->y; - - ret = true; - break; - } - } - } - UnlockList(font_list); - - if (ret == false) - { - ret = CalcFontSize(hFont, &xx, &yy); - } - - if (xx == 0 || yy == 0) - { - xx = 8; - yy = 16; - } - - if (x != NULL) - { - *x = xx; - } - - if (y != NULL) - { - *y = yy; - } - - return ret; -} - // Calculate the font size bool CalcFontSize(HFONT hFont, UINT *x, UINT *y) { @@ -9758,45 +8785,6 @@ void CenterParent(HWND hWnd) SetWindowPos(hWnd, NULL, x, y, 0, 0, SWP_NOSIZE | SWP_NOACTIVATE); } -// Get the coordinates of the client region of the window -void GetWindowClientRect(HWND hWnd, struct tagRECT *rect) -{ - RECT r1, r2; - HWND hParent; - WINDOWINFO info; - Zero(rect, sizeof(RECT)); - // Validate arguments - if (hWnd == NULL || rect == NULL) - { - return; - } - - hParent = GetParent(hWnd); - if (hParent == NULL) - { - return; - } - - Zero(&info, sizeof(info)); - info.cbSize = sizeof(WINDOWINFO); - - if (GetWindowInfo(hParent, &info) == false) - { - return; - } - - if (GetWindowRect(hWnd, &r1) == false || - GetWindowRect(hParent, &r2) == false) - { - return; - } - - rect->left = r1.left - r2.left - (info.rcClient.left - info.rcWindow.left); - rect->right = r1.right - r2.left - (info.rcClient.left - info.rcWindow.left); - rect->top = r1.top - r2.top - (info.rcClient.top - info.rcWindow.top); - rect->bottom = r1.bottom - r2.top - (info.rcClient.top - info.rcWindow.top); -} - // Move the window to the center void Center(HWND hWnd) { @@ -9840,19 +8828,6 @@ void Center(HWND hWnd) SetWindowPos(hWnd, NULL, x, y, 0, 0, SWP_NOSIZE | SWP_NOACTIVATE); } -// Get the size of the monitor -void GetMonitorSize(UINT *width, UINT *height) -{ - // Validate arguments - if (width == NULL || height == NULL) - { - return; - } - - *width = GetSystemMetrics(SM_CXSCREEN); - *height = GetSystemMetrics(SM_CYSCREEN); -} - // Format the string in the window void FormatText(HWND hWnd, UINT id, ...) { @@ -9885,83 +8860,6 @@ void FormatText(HWND hWnd, UINT id, ...) Free(str); va_end(args); } -void FormatTextA(HWND hWnd, UINT id, ...) -{ - va_list args; - char *buf; - UINT size; - char *str; - // Validate arguments - if (hWnd == NULL) - { - return; - } - - str = GetTextA(hWnd, id); - if (str == NULL) - { - return; - } - - size = MAX(StrSize(str) * 10, MAX_SIZE * 10); - buf = MallocEx(size, true); - - va_start(args, id); - FormatArgs(buf, size, str, args); - - SetTextA(hWnd, id, buf); - - Free(buf); - - Free(str); - va_end(args); -} - -// Set a variable-length argument string to the window -void SetTextEx(HWND hWnd, UINT id, wchar_t *str, ...) -{ - va_list args; - wchar_t *buf; - UINT size; - // Validate arguments - if (str == NULL || hWnd == NULL) - { - return; - } - - size = MAX(UniStrSize(str) * 10, MAX_SIZE * 10); - buf = MallocEx(size, true); - - va_start(args, str); - UniFormatArgs(buf, size, str, args); - - SetText(hWnd, id, buf); - - Free(buf); - va_end(args); -} -void SetTextExA(HWND hWnd, UINT id, char *str, ...) -{ - va_list args; - char *buf; - UINT size; - // Validate arguments - if (str == NULL || hWnd == NULL) - { - return; - } - - size = MAX(StrSize(str) * 10, MAX_SIZE * 10); - buf = MallocEx(size, true); - - va_start(args, str); - FormatArgs(buf, size, str, args); - - SetTextA(hWnd, id, buf); - - Free(buf); - va_end(args); -} // Show the variable-length message box UINT MsgBoxEx(HWND hWnd, UINT flag, wchar_t *msg, ...) @@ -10046,13 +8944,6 @@ UINT DialogInternal(HWND hWnd, UINT id, DIALOG_PROC *proc, void *param) } } -// Notice that the system configuration has been updated -void NoticeSettingChange() -{ - PostMessage(HWND_BROADCAST, WM_SETTINGCHANGE, 0, 0); - DoEvents(NULL); -} - // Dialog box procedure managed by WinUi UINT DlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam, bool white_color) { @@ -10154,18 +9045,6 @@ void *GetParam(HWND hWnd) return ret; } -// Relieve the window from foreground -void NoTop(HWND hWnd) -{ - // Validate arguments - if (hWnd == NULL) - { - return; - } - - SetWindowPos(hWnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); -} - // Show the windows as foreground void Top(HWND hWnd) { @@ -10356,21 +9235,6 @@ UINT GetStyle(HWND hWnd, UINT id) return GetWindowLong(DlgItem(hWnd, id), GWL_STYLE); } -// Get the number of bytes of the text -UINT GetTextSize(HWND hWnd, UINT id, bool unicode) -{ - UINT len; - // Validate arguments - if (hWnd == NULL) - { - return 0; - } - - len = GetTextLen(hWnd, id, unicode); - - return len + (unicode ? 2 : 1); -} - // Get the number of characters in the text UINT GetTextLen(HWND hWnd, UINT id, bool unicode) { @@ -11271,19 +10135,6 @@ HWND DlgItem(HWND hWnd, UINT id) } } -// Set the title -void SetWinUiTitle(wchar_t *title) -{ - // Validate arguments - if (title == NULL) - { - return; - } - - Free(title_bar); - title_bar = CopyUniStr(title); -} - // Initialize the WinUi void InitWinUi(wchar_t *software_name, char *font, UINT fontsize) { diff --git a/src/Cedar/WinUi.h b/src/Cedar/WinUi.h index 31e0cc8e..409b88db 100644 --- a/src/Cedar/WinUi.h +++ b/src/Cedar/WinUi.h @@ -410,7 +410,6 @@ struct LED }; void LedDrawString(LED *d, char *str, HFONT f); -void LedDrawRect(LED *d); void LedMainDraw(LED *d, HANDLE h); void LedSpecial(LED *d, HANDLE h, UINT n); @@ -575,7 +574,6 @@ struct WINUI_UPDATE_DLG_PARAM // Function prototype void InitWinUi(wchar_t *software_name, char *font, UINT fontsize); -void SetWinUiTitle(wchar_t *title); void FreeWinUi(); WINUI_UPDATE *InitUpdateUi(wchar_t *title, char *name, char *family_name, UINT64 current_date, UINT current_build, UINT current_ver, char *client_id, bool use_suppress_flag); @@ -619,7 +617,6 @@ void UnselectEdit(HWND hWnd, UINT id); UINT SendMsg(HWND hWnd, UINT id, UINT msg, WPARAM wParam, LPARAM lParam); bool IsEmpty(HWND hWnd, UINT id); UINT GetTextLen(HWND hWnd, UINT id, bool unicode); -UINT GetTextSize(HWND hWnd, UINT id, bool unicode); UINT GetStyle(HWND hWnd, UINT id); void SetStyle(HWND hWnd, UINT id, UINT style); void RemoveStyle(HWND hWnd, UINT id, UINT style); @@ -632,23 +629,16 @@ void SetShow(HWND hWnd, UINT id, bool b); bool IsHide(HWND hWnd, UINT id); bool IsShow(HWND hWnd, UINT id); void Top(HWND hWnd); -void NoTop(HWND hWnd); void *GetParam(HWND hWnd); void SetParam(HWND hWnd, void *param); UINT DlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam, bool white_color); -void NoticeSettingChange(); void UiTest(); UINT DialogInternal(HWND hWnd, UINT id, DIALOG_PROC *proc, void *param); UINT MsgBox(HWND hWnd, UINT flag, wchar_t *msg); UINT MsgBoxEx(HWND hWnd, UINT flag, wchar_t *msg, ...); -void SetTextEx(HWND hWnd, UINT id, wchar_t *str, ...); -void SetTextExA(HWND hWnd, UINT id, char *str, ...); void FormatText(HWND hWnd, UINT id, ...); -void FormatTextA(HWND hWnd, UINT id, ...); void Center(HWND hWnd); -void GetWindowClientRect(HWND hWnd, struct tagRECT *rect); void CenterParent(HWND hWnd); -void GetMonitorSize(UINT *width, UINT *height); void DisableClose(HWND hWnd); void EnableClose(HWND hWnd); void InitFont(); @@ -657,21 +647,16 @@ int CompareFont(void *p1, void *p2); HFONT GetFont(char *name, UINT size, bool bold, bool italic, bool underline, bool strikeout); double GetTextScalingFactor(); bool CalcFontSize(HFONT hFont, UINT *x, UINT *y); -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); -void SetBitmap(HWND hWnd, UINT id, UINT bmp_id); bool SecureDeviceWindow(HWND hWnd, WINUI_SECURE_BATCH *batch, UINT num_batch, UINT device_id, UINT bitmap_id); UINT Dialog(HWND hWnd, UINT id, WINUI_DIALOG_PROC *proc, void *param); UINT DialogEx(HWND hWnd, UINT id, WINUI_DIALOG_PROC *proc, void *param, bool white); UINT DialogEx2(HWND hWnd, UINT id, WINUI_DIALOG_PROC *proc, void *param, bool white, bool meiryo); -HWND DialogCreateEx(HWND hWnd, UINT id, WINUI_DIALOG_PROC *proc, void *param, bool white); UINT __stdcall InternalDialogProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); UINT SecureDeviceWindowProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam, void *param); HFONT Font(UINT size, UINT bold); @@ -689,10 +674,6 @@ wchar_t *SaveDlg(HWND hWnd, wchar_t *filter, wchar_t *title, wchar_t *default_na char *SaveDlgA(HWND hWnd, char *filter, char *title, char *default_name, char *default_ext); wchar_t *MakeFilter(wchar_t *str); char *MakeFilterA(char *str); -void PkcsUtil(); -UINT PkcsUtilProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam, void *param); -void PkcsUtilWrite(HWND hWnd); -void PkcsUtilErase(HWND hWnd); bool PassphraseDlg(HWND hWnd, char *pass, UINT pass_size, BUF *buf, bool p12); UINT PassphraseDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam, void *param); bool PasswordDlg(HWND hWnd, UI_PASSWORD_DLG *p); @@ -702,8 +683,6 @@ void PasswordDlgProcChange(HWND hWnd, UI_PASSWORD_DLG *p); UINT CbAddStr(HWND hWnd, UINT id, wchar_t *str, UINT data); UINT CbAddStrA(HWND hWnd, UINT id, char *str, UINT data); UINT CbAddStr9xA(HWND hWnd, UINT id, char *str, UINT data); -UINT CbInsertStr(HWND hWnd, UINT id, UINT index, wchar_t *str, UINT data); -UINT CbInsertStr9xA(HWND hWnd, UINT id, UINT index, char *str, UINT data); void CbSelectIndex(HWND hWnd, UINT id, UINT index); UINT CbNum(HWND hWnd, UINT id); UINT CbFindStr(HWND hWnd, UINT id, wchar_t *str); @@ -718,21 +697,9 @@ UINT CbGetSelectIndex(HWND hWnd, UINT id); UINT CbGetSelect(HWND hWnd, UINT id); void SetRange(HWND hWnd, UINT id, UINT start, UINT end); void SetPos(HWND hWnd, UINT id, UINT pos); -UINT LbAddStr(HWND hWnd, UINT id, wchar_t *str, UINT data); -UINT LbAddStrA(HWND hWnd, UINT id, char *str, UINT data); -UINT LbInsertStr(HWND hWnd, UINT id, UINT index, wchar_t *str, UINT data); -UINT LbInsertStrA(HWND hWnd, UINT id, UINT index, char *str, UINT data); -void LbSelectIndex(HWND hWnd, UINT id, UINT index); UINT LbNum(HWND hWnd, UINT id); -UINT LbFindStr(HWND hWnd, UINT id, wchar_t *str); -wchar_t *LbGetStr(HWND hWnd, UINT id); -UINT LbFindData(HWND hWnd, UINT id, UINT data); UINT LbGetData(HWND hWnd, UINT id, UINT index); -void LbSelect(HWND hWnd, UINT id, int data); void LbReset(HWND hWnd, UINT id); -void LbSetHeight(HWND hWnd, UINT id, UINT value); -UINT LbGetSelectIndex(HWND hWnd, UINT id); -UINT LbGetSelect(HWND hWnd, UINT id); STATUS_WINDOW *StatusPrinterWindowStart(SOCK *s, wchar_t *account_name); void StatusPrinterWindowStop(STATUS_WINDOW *sw); void StatusPrinterWindowPrint(STATUS_WINDOW *sw, wchar_t *str); @@ -753,14 +720,12 @@ UINT LvInsertItemByImageListIdA(HWND hWnd, UINT id, UINT image, void *param, cha void LvSetItem(HWND hWnd, UINT id, UINT index, UINT pos, wchar_t *str); void LvSetItemA(HWND hWnd, UINT id, UINT index, UINT pos, char *str); void LvSetItemParam(HWND hWnd, UINT id, UINT index, void *param); -void LvSetItemImage(HWND hWnd, UINT id, UINT index, UINT icon); void LvSetItemImageByImageListId(HWND hWnd, UINT id, UINT index, UINT image); void LvDeleteItem(HWND hWnd, UINT id, UINT index); UINT LvNum(HWND hWnd, UINT id); void *LvGetParam(HWND hWnd, UINT id, UINT index); wchar_t *LvGetStr(HWND hWnd, UINT id, UINT index, UINT pos); char *LvGetStrA(HWND hWnd, UINT id, UINT index, UINT pos); -void LvShow(HWND hWnd, UINT id, UINT index); UINT LvSearchParam(HWND hWnd, UINT id, void *param); UINT LvSearchStr(HWND hWnd, UINT id, UINT pos, wchar_t *str); UINT LvSearchStrA(HWND hWnd, UINT id, UINT pos, char *str); @@ -775,7 +740,6 @@ UINT LvGetNextMasked(HWND hWnd, UINT id, UINT start); bool LvIsMasked(HWND hWnd, UINT id); bool LvIsSingleSelected(HWND hWnd, UINT id); bool LvIsMultiMasked(HWND hWnd, UINT id); -UINT LvGetMaskedNum(HWND hWnd, UINT id); void LvAutoSize(HWND hWnd, UINT id); void LvSelect(HWND hWnd, UINT id, UINT index); void LvSelectByParam(HWND hWnd, UINT id, void *param); @@ -807,7 +771,6 @@ void LvRemoveStyle(HWND hWnd, UINT id, UINT style); HMENU LoadSubMenu(UINT menu_id, UINT pos, HMENU *parent_menu); UINT GetMenuItemPos(HMENU hMenu, UINT id); void DeleteMenuItem(HMENU hMenu, UINT pos); -void SetMenuItemEnable(HMENU hMenu, UINT pos, bool enable); void SetMenuItemBold(HMENU hMenu, UINT pos, bool bold); wchar_t *GetMenuStr(HMENU hMenu, UINT pos); char *GetMenuStrA(HMENU hMenu, UINT pos); @@ -831,7 +794,6 @@ void LvSortHander(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam, UINT id); void LvStandardHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam, UINT id); void IpSet(HWND hWnd, UINT id, UINT ip); UINT IpGet(HWND hWnd, UINT id); -void IpClear(HWND hWnd, UINT id); bool IpIsFilled(HWND hWnd, UINT id); UINT IpGetFilledNum(HWND hWnd, UINT id); void About(HWND hWnd, CEDAR *cedar, wchar_t *product_name); @@ -844,7 +806,6 @@ char *StringDlgA(HWND hWnd, wchar_t *title, wchar_t *info, char *def, UINT icon, UINT StringDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam, void *param); void InitDialogInternational(HWND hWnd, void *pparam); void AdjustWindowAndControlSize(HWND hWnd, bool *need_resize, double *factor_x, double *factor_y); -void GetWindowAndControlSizeResizeScale(HWND hWnd, bool *need_resize, double *factor_x, double *factor_y); void AdjustDialogXY(UINT *x, UINT *y, UINT dlgfont_x, UINT dlgfont_y); HFONT GetDialogDefaultFont(); HFONT GetDialogDefaultFontEx(bool meiryo); @@ -862,14 +823,7 @@ void KakushiThread(THREAD *thread, void *param); KAKUSHI *InitKakushi(); void FreeKakushi(KAKUSHI *k); void ShowEasterEgg(HWND hWnd); -bool ExecuteHamcoreExe(char *name); -bool IsRegistedToDontShowFreeEditionDialog(char *server_name); void RegistToDontShowFreeEditionDialog(char *server_name); -void ShowFreeInfoDialog(HWND hWnd, FREEINFO *info); -UINT FreeInfoDialogProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam, void *param); -FREEINFO *StartFreeInfoDlg(char *server_name); -void FreeInfoThread(THREAD *thread, void *param); -void EndFreeInfoDlg(FREEINFO *info); bool Win32CnCheckAlreadyExists(bool lock); void RegistWindowsFirewallAll(); void RegistWindowsFirewallAllEx(char *dir); @@ -891,7 +845,6 @@ HFONT GetMeiryoFont(); HFONT GetMeiryoFontEx(UINT font_size); HFONT GetMeiryoFontEx2(UINT font_size, bool bold); bool ShowWindowsNetworkConnectionDialog(); -SOCK *WinConnectEx2(HWND hWnd, char *server, UINT port, UINT timeout, UINT icon_id, wchar_t *caption, wchar_t *info, bool try_start_ssl, bool ssl_no_tls); SOCK *WinConnectEx3(HWND hWnd, char *server, UINT port, UINT timeout, UINT icon_id, wchar_t *caption, wchar_t *info, UINT *nat_t_error_code, char *nat_t_svc_name, bool try_start_ssl, bool ssl_no_tls); UINT WinConnectDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam, void *param); void WinConnectDlgThread(THREAD *thread, void *param); @@ -909,7 +862,6 @@ WIZARD_PAGE *NewWizardPage(UINT id, WINUI_WIZARD_PROC *proc, wchar_t *title); void FreeWizardPage(WIZARD_PAGE *p); void AddWizardPage(WIZARD *w, WIZARD_PAGE *p); WIZARD_PAGE *GetWizardPage(WIZARD *w, UINT id); -UINT GetWizardPageIndex(WIZARD *w, UINT id); void *CreateWizardPageInstance(WIZARD *w, WIZARD_PAGE *p); void ShowWizard(HWND hWndParent, WIZARD *w, UINT start_id); void SetWizardButton(WIZARD_PAGE *p, bool enable_next, bool enable_back, bool enable_close, bool is_finish); 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 015cdfeb..a0493ecd 100644 --- a/src/Mayaqua/Encrypt.c +++ b/src/Mayaqua/Encrypt.c @@ -2759,10 +2759,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 428ec9bc..f9af0a88 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/Mayaqua.h b/src/Mayaqua/Mayaqua.h index 36fdc648..190ad80d 100644 --- a/src/Mayaqua/Mayaqua.h +++ b/src/Mayaqua/Mayaqua.h @@ -501,7 +501,6 @@ if (kernel_status_inited) { \ #define KS_FREEFIFO_COUNT 37 // Number of times the FIFO object is deleted #define KS_READ_FIFO_COUNT 38 // Number of calls ReadFifo #define KS_WRITE_FIFO_COUNT 39 // Number of calls WriteFifo -#define KS_PEEK_FIFO_COUNT 40 // Number of calls PeekFifo // List related #define KS_NEWLIST_COUNT 41 // Number of calls NewList #define KS_FREELIST_COUNT 42 // Number of times the object LIST was deleted diff --git a/src/Mayaqua/Memory.c b/src/Mayaqua/Memory.c index 92b7efa5..fca27f36 100644 --- a/src/Mayaqua/Memory.c +++ b/src/Mayaqua/Memory.c @@ -831,18 +831,6 @@ LIST *NewCandidateList() return NewList(ComapreCandidate); } -// Fill a range of memory -void FillBytes(void *data, UINT size, UCHAR c) -{ - UCHAR *buf = (UCHAR *)data; - UINT i; - - for (i = 0;i < size;i++) - { - buf[i] = c; - } -} - // Examine whether the specified address points all-zero area bool IsZero(void *data, UINT size) { @@ -1116,28 +1104,6 @@ void *Pop(SK *s) return ret; } -// Peep -void *PeekQueue(QUEUE *q) -{ - void *p = NULL; - // Validate arguments - if (q == NULL) - { - return NULL; - } - - if (q->num_item == 0) - { - // No items - return NULL; - } - - // Read from the FIFO - PeekFifo(q->fifo, &p, sizeof(void *)); - - return p; -} - // Get the number of queued items UINT GetQueueNum(QUEUE *q) { @@ -1360,22 +1326,6 @@ QUEUE *NewQueueFast() return q; } -// Set the comparison function to list -void SetCmp(LIST *o, COMPARE *cmp) -{ - // Validate arguments - if (o == NULL || cmp == NULL) - { - return; - } - - if (o->cmp != cmp) - { - o->cmp = cmp; - o->sorted = false; - } -} - // Clone the list LIST *CloneList(LIST *o) { @@ -1471,23 +1421,6 @@ void *Search(LIST *o, void *target) } } -// Insert an item to the list (Do not insert if it already exists) -void InsertDistinct(LIST *o, void *p) -{ - // Validate arguments - if (o == NULL || p == NULL) - { - return; - } - - if (IsInList(o, p)) - { - return; - } - - Insert(o, p); -} - // Insert an item to the list void Insert(LIST *o, void *p) { @@ -1566,18 +1499,6 @@ void Insert(LIST *o, void *p) KS_INC(KS_INSERT_COUNT); } -// Setting the sort flag -void SetSortFlag(LIST *o, bool sorted) -{ - // Validate arguments - if (o == NULL) - { - return; - } - - o->sorted = sorted; -} - // Sort the list void Sort(LIST *o) { @@ -1593,43 +1514,6 @@ void Sort(LIST *o) // KS KS_INC(KS_SORT_COUNT); } -void SortEx(LIST *o, COMPARE *cmp) -{ - // Validate arguments - if (o == NULL) - { - return; - } - - qsort(o->p, o->num_item, sizeof(void *), (int(*)(const void *, const void *))cmp); - o->sorted = false; - - // KS - KS_INC(KS_SORT_COUNT); -} - -// Examine whether a certain string items are present in the list (Unicode version) -bool IsInListUniStr(LIST *o, wchar_t *str) -{ - UINT i; - // Validate arguments - if (o == NULL || str == NULL) - { - return false; - } - - for (i = 0;i < LIST_NUM(o);i++) - { - wchar_t *s = LIST_DATA(o, i); - - if (UniStrCmpi(s, str) == 0) - { - return true; - } - } - - return false; -} // Replace the pointer in the list bool ReplaceListPointer(LIST *o, void *oldptr, void *newptr) @@ -1968,26 +1852,6 @@ bool IsInt64InList(LIST *o, UINT64 i) return false; } -// Remove all int from the interger list -void DelAllInt(LIST *o) -{ - UINT i; - // Validate arguments - if (o == NULL) - { - return; - } - - for (i = 0;i < LIST_NUM(o);i++) - { - UINT *p = LIST_DATA(o, i); - - Free(p); - } - - DeleteAll(o); -} - // Release the integer list void ReleaseIntList(LIST *o) { @@ -2065,44 +1929,6 @@ void DelInt(LIST *o, UINT i) ReleaseList(o2); } } -void DelInt64(LIST *o, UINT64 i) -{ - LIST *o2 = NULL; - UINT j; - // Validate arguments - if (o == NULL) - { - return; - } - - for (j = 0;j < LIST_NUM(o);j++) - { - UINT64 *p = LIST_DATA(o, j); - - if (*p == i) - { - if (o2 == NULL) - { - o2 = NewListFast(NULL); - } - Add(o2, p); - } - } - - for (j = 0;j < LIST_NUM(o2);j++) - { - UINT64 *p = LIST_DATA(o2, j); - - Delete(o, p); - - Free(p); - } - - if (o2 != NULL) - { - ReleaseList(o2); - } -} // Create a new list of integers LIST *NewIntList(bool sorted) @@ -2154,41 +1980,6 @@ int CompareInt64(void *p1, void *p2) return COMPARE_RET(*v1, *v2); } -// Randomize the contents of the list -void RandomizeList(LIST *o) -{ - LIST *o2; - UINT i; - // Validate arguments - if (o == NULL) - { - return; - } - - o2 = NewListFast(NULL); - - while (LIST_NUM(o) != 0) - { - UINT num = LIST_NUM(o); - UINT i = Rand32() % num; - void *p = LIST_DATA(o, i); - - Add(o2, p); - Delete(o, p); - } - - DeleteAll(o); - - for (i = 0;i < LIST_NUM(o2);i++) - { - void *p = LIST_DATA(o2, i); - - Add(o, p); - } - - ReleaseList(o2); -} - // Add an integer to the list void AddInt(LIST *o, UINT i) { @@ -2220,16 +2011,6 @@ void InsertInt(LIST *o, UINT i) Insert(o, Clone(&i, sizeof(UINT))); } -void InsertInt64(LIST *o, UINT64 i) -{ - // Validate arguments - if (o == NULL) - { - return; - } - - Insert(o, Clone(&i, sizeof(UINT64))); -} // Add an integer to the list (no duplicates) void AddIntDistinct(LIST *o, UINT i) @@ -2271,19 +2052,6 @@ void InsertIntDistinct(LIST *o, UINT i) InsertInt(o, i); } } -void InsertInt64Distinct(LIST *o, UINT64 i) -{ - // Validate arguments - if (o == NULL) - { - return; - } - - if (IsInt64InList(o, i) == false) - { - InsertInt64(o, i); - } -} // String comparison function (Unicode) int CompareUniStr(void *p1, void *p2) @@ -2406,32 +2174,6 @@ LIST *NewListEx2(COMPARE *cmp, bool fast, bool fast_malloc) return o; } -// Peek from the FIFO -UINT PeekFifo(FIFO *f, void *p, UINT size) -{ - UINT read_size; - if (f == NULL || size == 0) - { - return 0; - } - - // KS - KS_INC(KS_PEEK_FIFO_COUNT); - - read_size = MIN(size, f->size); - if (read_size == 0) - { - return 0; - } - - if (p != NULL) - { - Copy(p, (UCHAR *)f->p + f->pos, read_size); - } - - return read_size; -} - // Read all data from FIFO BUF *ReadFifoAll(FIFO *f) { @@ -2528,25 +2270,6 @@ void ShrinkFifoMemory(FIFO *f) } } -// Write data to the front of FIFO -void WriteFifoFront(FIFO *f, void *p, UINT size) -{ - // Validate arguments - if (f == NULL || size == 0) - { - return; - } - - if (f->pos < size) - { - PadFifoFront(f, size - f->pos); - } - - Copy(((UCHAR *)f->p) + (f->pos - size), p, size); - f->pos -= size; - f->size += size; -} - // Write to the FIFO void WriteFifo(FIFO *f, void *p, UINT size) { @@ -2587,34 +2310,6 @@ void WriteFifo(FIFO *f, void *p, UINT size) KS_INC(KS_WRITE_FIFO_COUNT); } -// Add a padding before the head of fifo -void PadFifoFront(FIFO *f, UINT size) -{ - // Validate arguments - if (f == NULL || size == 0) - { - return; - } - - f->memsize += 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) { @@ -2643,30 +2338,6 @@ UINT FifoSize(FIFO *f) return f->size; } -// Lock the FIFO -void LockFifo(FIFO *f) -{ - // Validate arguments - if (f == NULL) - { - return; - } - - Lock(f->lock); -} - -// Unlock the FIFO -void UnlockFifo(FIFO *f) -{ - // Validate arguments - if (f == NULL) - { - return; - } - - Unlock(f->lock); -} - // Release the FIFO void ReleaseFifo(FIFO *f) { @@ -2755,12 +2426,6 @@ FIFO *NewFifoEx2(bool fast, bool fixed) return f; } -// Get the default memory reclaiming size of the FIFO -UINT GetFifoCurrentReallocMemSize() -{ - return fifo_current_realloc_mem_size; -} - // Set the default memory reclaiming size of the FIFO void SetFifoCurrentReallocMemSize(UINT size) { @@ -2931,25 +2596,6 @@ bool DumpDataW(void *data, UINT size, wchar_t *filename) return true; } -bool DumpData(void *data, UINT size, char *filename) -{ - IO *o; - // Validate arguments - if (filename == NULL || (size != 0 && data == NULL)) - { - return false; - } - - o = FileCreate(filename); - if (o == NULL) - { - return false; - } - FileWrite(o, data, size); - FileClose(o); - - return true; -} // Dump the contents of the buffer to the file bool DumpBuf(BUF *b, char *filename) @@ -3714,28 +3360,6 @@ UINT64 Endian64(UINT64 src) } } -// Swap data of any -void Swap(void *buf, UINT size) -{ - UCHAR *tmp, *src; - UINT i; - // Validate arguments - if (buf == NULL || size == 0) - { - return; - } - - src = (UCHAR *)buf; - tmp = Malloc(size); - for (i = 0;i < size;i++) - { - tmp[size - i - 1] = src[i]; - } - - Copy(buf, tmp, size); - Free(buf); -} - // 16bit swap USHORT Swap16(USHORT value) { @@ -4263,25 +3887,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..27220fbd 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); @@ -300,7 +299,6 @@ int B64_Decode(char *set, char *source, int len); UINT Encode64(char *dst, char *src); UINT Decode64(char *dst, char *src); -void Swap(void *buf, UINT size); USHORT Swap16(USHORT value); UINT Swap32(UINT value); UINT64 Swap64(UINT64 value); @@ -338,7 +336,6 @@ void AddBufStr(BUF *b, char *str); bool DumpBuf(BUF *b, char *filename); bool DumpBufW(BUF *b, wchar_t *filename); bool DumpBufWIfNecessary(BUF *b, wchar_t *filename); -bool DumpData(void *data, UINT size, char *filename); bool DumpDataW(void *data, UINT size, wchar_t *filename); BUF *ReadDump(char *filename); BUF *ReadDumpWithMaxSize(char *filename, UINT max_size); @@ -351,19 +348,13 @@ BUF *ReadRemainBuf(BUF *b); UINT ReadBufRemainSize(BUF *b); bool CompareBuf(BUF *b1, BUF *b2); -UINT PeekFifo(FIFO *f, void *p, UINT size); UINT ReadFifo(FIFO *f, void *p, UINT size); BUF *ReadFifoAll(FIFO *f); void ShrinkFifoMemory(FIFO *f); UCHAR *GetFifoPointer(FIFO *f); 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); void ReleaseFifo(FIFO *f); void CleanupFifo(FIFO *f); FIFO *NewFifo(); @@ -371,16 +362,13 @@ FIFO *NewFifoFast(); FIFO *NewFifoEx(bool fast); FIFO *NewFifoEx2(bool fast, bool fixed); void InitFifo(); -UINT GetFifoCurrentReallocMemSize(); void SetFifoCurrentReallocMemSize(UINT size); void *Search(LIST *o, void *target); void Sort(LIST *o); -void SortEx(LIST *o, COMPARE *cmp); void Add(LIST *o, void *p); void AddDistinct(LIST *o, void *p); void Insert(LIST *o, void *p); -void InsertDistinct(LIST *o, void *p); bool Delete(LIST *o, void *p); bool DeleteKey(LIST *o, UINT key); void DeleteAll(LIST *o); @@ -397,8 +385,6 @@ void CopyToArray(LIST *o, void *p); void *ToArray(LIST *o); void *ToArrayEx(LIST *o, bool fast); LIST *CloneList(LIST *o); -void SetCmp(LIST *o, COMPARE *cmp); -void SetSortFlag(LIST *o, bool sorted); int CompareStr(void *p1, void *p2); bool InsertStr(LIST *o, char *str); int CompareUniStr(void *p1, void *p2); @@ -406,17 +392,14 @@ bool IsInList(LIST *o, void *p); bool IsInListKey(LIST *o, UINT key); void *ListKeyToPointer(LIST *o, UINT key); bool IsInListStr(LIST *o, char *str); -bool IsInListUniStr(LIST *o, wchar_t *str); bool ReplaceListPointer(LIST *o, void *oldptr, void *newptr); void AddInt(LIST *o, UINT i); void AddInt64(LIST *o, UINT64 i); void AddIntDistinct(LIST *o, UINT i); void AddInt64Distinct(LIST *o, UINT64 i); void DelInt(LIST *o, UINT i); -void DelInt64(LIST *o, UINT64 i); void ReleaseIntList(LIST *o); void ReleaseInt64List(LIST *o); -void DelAllInt(LIST *o); bool IsIntInList(LIST *o, UINT i); bool IsInt64InList(LIST *o, UINT64 i); LIST *NewIntList(bool sorted); @@ -424,14 +407,10 @@ LIST *NewInt64List(bool sorted); int CompareInt(void *p1, void *p2); int CompareInt64(void *p1, void *p2); void InsertInt(LIST *o, UINT i); -void InsertInt64(LIST *o, UINT64 i); void InsertIntDistinct(LIST *o, UINT i); -void InsertInt64Distinct(LIST *o, UINT64 i); -void RandomizeList(LIST *o); void *GetNext(QUEUE *q); void *GetNextWithLock(QUEUE *q); -void *PeekQueue(QUEUE *q); void InsertQueue(QUEUE *q, void *p); void InsertQueueWithLock(QUEUE *q, void *p); void InsertQueueInt(QUEUE *q, UINT value); @@ -460,7 +439,6 @@ BUF *CompressBuf(BUF *src_buf); BUF *UncompressBuf(BUF *src_buf); bool IsZero(void *data, UINT size); -void FillBytes(void *data, UINT size, UCHAR c); LIST *NewStrMap(); void *StrMapSearch(LIST *map, char *key); diff --git a/src/Mayaqua/Network.c b/src/Mayaqua/Network.c index b6fba840..19e85c03 100644 --- a/src/Mayaqua/Network.c +++ b/src/Mayaqua/Network.c @@ -6872,23 +6872,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) { @@ -7827,17 +7810,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) { @@ -8216,24 +8188,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() { @@ -14659,39 +14613,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 ccec80b1..829a8780 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);