Esempio n. 1
0
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);
}
Esempio n. 2
0
void List_FreeElements(TYP_LIST *pstHandle)
{
	void *pEntry;

	while (pEntry = List_Pop(pstHandle))
		free (pEntry);
}
Esempio n. 3
0
void List_FreeElements(TYP_LIST *pstHandle)
{
	void *pEntry;
	HANDLE hHeap = GetProcessHeap();

	while (pEntry = List_Pop(pstHandle))
		HeapFree (hHeap, 0, pEntry);
}
Esempio n. 4
0
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);
}
Esempio n. 5
0
void AvatarList_Exit(TYP_LIST *hList)
{
	AVATARENTRY *pEntry;

	while (pEntry=(AVATARENTRY*)List_Pop(hList))
	{
		AvatarList_FreeEntry(pEntry);
		free (pEntry);
	}
	List_Exit(hList);
}
Esempio n. 6
0
static LONG APIENTRY WndProc(HWND hWnd, UINT message, UINT wParam, LONG lParam) 
{ 
    switch (message) 
    { 
		case WM_CREATE:
		{
			LPCREATESTRUCT lpCr = (LPCREATESTRUCT)lParam;

			SetWindowLongPtr (hWnd, GWLP_USERDATA, (LONG_PTR)lpCr->lpCreateParams);
			SetTimer (hWnd, 0, 60000, NULL);
			break;
		}
        case WM_COPYDATA: 
		{
			PCOPYDATASTRUCT pCopyData = (PCOPYDATASTRUCT)lParam;
			CONNINST *pInst;
			IMO2SPROXY_INST *hProxy = (IMO2SPROXY_INST*)GetWindowLongPtr(hWnd, GWLP_USERDATA);

			if (pInst = FindClient (hProxy, (HWND)wParam))
			{
				if (pInst->hProxy->pMyCfg->bDelayLogin && pInst->iConnectionStat < 1)
				{
					char *pszError;

					if ((pInst->iConnectionStat = Imo2S_Login (pInst->hInst, hProxy->pCfg->pszUser, hProxy->pCfg->pszPass, &pszError)) != 1)
					{
						pInst->hProxy->pCfg->logerror (stderr, "Connection %08X: Cannot login with (%s/****): %s\n", 
							pInst->hWnd, hProxy->pCfg->pszUser, pszError);
						FreeConnection(pInst);
						free (List_Pop(hProxy->hClients));
						PostMessage ((HWND)wParam, m_ControlAPIAttach, (WPARAM)hWnd, SKYPECONTROLAPI_ATTACH_REFUSED);
						return 0;
					}
				}
				LockMutex(pInst->sendmutex);
				if (pInst->hProxy->pCfg->bVerbose && pInst->hProxy->pCfg->fpLog)
				{
					fprintf (pInst->hProxy->pCfg->fpLog, "%08X< [%s]\n", pInst->hWnd, pCopyData->lpData);
					fflush (pInst->hProxy->pCfg->fpLog);
				}
				Imo2S_Send (pInst->hInst, pCopyData->lpData);
				UnlockMutex(pInst->sendmutex);
			}
			return 1;
		}
		case WM_TIMER:
			// Housekeeping timer
			CleanConnections (((IMO2SPROXY_INST*)GetWindowLongPtr(hWnd, GWLP_USERDATA))->hClients);
			break;
		case WM_DESTROY:
			KillTimer (hWnd, 0);
			break;
		default:
			if (message == m_ControlAPIDiscover)
			{
				CONNINST *pInst;
				IMO2SPROXY_INST *hProxy = (IMO2SPROXY_INST*)GetWindowLongPtr(hWnd, GWLP_USERDATA);
				char *pszError;
				
				if (!(pInst = FindClient (hProxy, (HWND)wParam)))
				{
					pInst = (CONNINST*)calloc (1, sizeof(CONNINST));
					if (!pInst) break;
					List_Push(hProxy->hClients, pInst);
					pInst->hProxy = hProxy;
					pInst->hWnd = (HWND)wParam;
					if (hProxy->pCfg->bVerbose && hProxy->pCfg->fpLog)
						fprintf (hProxy->pCfg->fpLog, "Imo2sproxy::SkypeControlAPIDiscover\n");

					if (!(pInst->hInst = Imo2S_Init(EventHandler, pInst, hProxy->pCfg->iFlags)))
					{
						hProxy->pCfg->logerror (stderr, "Connection %08X: Cannot start Imo2Skype instance.\n", pInst->hWnd);
						free (List_Pop(hProxy->hClients));
						PostMessage ((HWND)wParam, m_ControlAPIAttach, (WPARAM)hWnd, SKYPECONTROLAPI_ATTACH_REFUSED);
						return 0;
					}

					// FIXME: We should enable logging dependent on a loglevel rather than just enabling it
					if (hProxy->pCfg->bVerbose)
						Imo2S_SetLog (pInst->hInst, hProxy->pCfg->fpLog);

					InitMutex(pInst->sendmutex);
					
					if (!pInst->hProxy->pMyCfg->bDelayLogin)
					{
						PostMessage ((HWND)wParam, m_ControlAPIAttach, (WPARAM)hWnd, SKYPECONTROLAPI_ATTACH_NOT_AVAILABLE);
						if ((pInst->iConnectionStat = Imo2S_Login (pInst->hInst, hProxy->pCfg->pszUser, hProxy->pCfg->pszPass, &pszError)) != 1)
						{
							pInst->hProxy->pCfg->logerror (stderr, "Connection %08X: Cannot login with (%s/****): %s\n", 
								pInst->hWnd, hProxy->pCfg->pszUser, pszError);
							FreeConnection(pInst);
							free (List_Pop(hProxy->hClients));
							PostMessage ((HWND)wParam, m_ControlAPIAttach, (WPARAM)hWnd, SKYPECONTROLAPI_ATTACH_REFUSED);
							return 0;
						}
						PostMessage ((HWND)wParam, m_ControlAPIAttach, (WPARAM)hWnd, SKYPECONTROLAPI_ATTACH_API_AVAILABLE);
					}
					else
					{
						SendMessage ((HWND)wParam, m_ControlAPIAttach, (WPARAM)hWnd, SKYPECONTROLAPI_ATTACH_SUCCESS);
					}
					return 0;
				}
				else
					SendMessage ((HWND)wParam, m_ControlAPIAttach, (WPARAM)hWnd, SKYPECONTROLAPI_ATTACH_SUCCESS);
				return 0;
			}
			break;
	}
	return (DefWindowProc(hWnd, message, wParam, lParam)); 
}
Esempio n. 7
0
void
CfrTil_Endif_ConditionalInterpret ( )
{
    //_dllist_PopValue ( _Context_->Interpreter0->PreprocessorStackList ) ;
    List_Pop ( _Context_->Interpreter0->PreprocessorStackList ) ;
}