static void Imo2sproxy_Exit(IMO2SPROXY *hInst) { IMO2SPROXY_INST *hProxy = (IMO2SPROXY_INST*)hInst; CONNINST *pInst; if (hProxy->pCfg->bVerbose && hProxy->pCfg->fpLog) fprintf (hProxy->pCfg->fpLog, "W32SkypeEmu:Exit()\n"); if (hProxy->hWndDispatch) DestroyWindow (hProxy->hWndDispatch); if (hProxy->dwThreadID) PostThreadMessage (hProxy->dwThreadID, WM_QUIT, 0, 0); LockMutex(hProxy->loopmutex); // Kill 'em all! if (hProxy->hClients) { while (pInst=List_Pop(hProxy->hClients)) { FreeConnection(pInst); free (pInst); } List_Exit (hProxy->hClients); } UnregisterClass ("Imo2SProxyDispatchWindow", GetModuleHandle(NULL)); UnlockMutex(hProxy->loopmutex); ExitMutex(hProxy->loopmutex); free (hProxy); }
void MsgList_Exit(void) { if (!m_hMsgList) return; List_FreeElements (m_hMsgList); List_Exit(m_hMsgList); m_hMsgList = NULL; }
static void Imo2sproxy_Loop(IMO2SPROXY *hInst) { struct sockaddr_in sock; int socklen; SOCKET new_fd; TYP_LIST *hConns = List_Init(32); CONNINST *pInst; IMO2SPROXY_INST *hProxy = (IMO2SPROXY_INST*)hInst; fd_set fdListen; if (hProxy->pCfg->bVerbose && hProxy->pCfg->fpLog) fprintf (hProxy->pCfg->fpLog, "Socksproxy:Loop(Start)\n"); hProxy->iRunning = 1; LockMutex(hProxy->loopmutex); while (hProxy->iRunning) { FD_ZERO(&fdListen); FD_SET(hProxy->listen_fd, &fdListen); socklen = sizeof(sock); if (select (0, &fdListen, NULL, NULL, NULL) != SOCKET_ERROR && FD_ISSET(hProxy->listen_fd, &fdListen)) { new_fd = accept(hProxy->listen_fd, (struct sockaddr *) &sock, &socklen); if (hProxy->pCfg->bVerbose && hProxy->pCfg->fpLog) { fprintf (hProxy->pCfg->fpLog, "Connection from %s:%d -> Connection: %d\n", inet_ntoa(sock.sin_addr), ntohs(sock.sin_port), new_fd); fflush (hProxy->pCfg->fpLog); } if (new_fd != INVALID_SOCKET && (pInst = calloc (1, sizeof(CONNINST)))) { CleanConnections (hConns); List_Push(hConns, pInst); pInst->hSock = new_fd; pInst->hProxy = hProxy; InitMutex(pInst->connected); LockMutex(pInst->connected); InitMutex(pInst->sendmutex); Dispatcher_Start(pInst); } } } if (hProxy->pCfg->bVerbose && hProxy->pCfg->fpLog) fprintf (hProxy->pCfg->fpLog, "Socksproxy:Loop(End)\n"); CleanConnections (hConns); while (pInst=List_Pop(hConns)) { Dispatcher_Stop(pInst); FreeConnection(pInst); free (pInst); } List_Exit(hConns); UnlockMutex(hProxy->loopmutex); }
void AvatarList_Exit(TYP_LIST *hList) { AVATARENTRY *pEntry; while (pEntry=(AVATARENTRY*)List_Pop(hList)) { AvatarList_FreeEntry(pEntry); free (pEntry); } List_Exit(hList); }