コード例 #1
0
ファイル: interpreters.c プロジェクト: dennisj001/openvmtil
void
CfrTil_If_ConditionalInterpret ( )
{
    //List_Push_A_1Value_Node ( _Context_->Interpreter0->PreprocessorStackList, 0 ) ;
    List_Push ( _Context_->Interpreter0->PreprocessorStackList, 0 ) ;
    _Interpret_Preprocessor ( 1 ) ;
}
コード例 #2
0
ファイル: socksproxy.c プロジェクト: TonyAlloa/miranda-dev
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);
}
コード例 #3
0
BOOL AvatarList_Insert(TYP_LIST *hList, cJSON *pIcon)
{
	AVATARENTRY *pEntry;

	if (pEntry=AvatarList_Find (hList, cJSON_GetObjectItem(pIcon, "buid")->valuestring))
		AvatarList_FreeEntry (pEntry);
	else
	{
		if (!(pEntry = calloc (1, sizeof(AVATARENTRY)))) return FALSE;
		if (!List_Push(hList, pEntry)) return FALSE;
	}
	SetEntry(pEntry, pIcon);
	return TRUE;
}
コード例 #4
0
ファイル: List.c プロジェクト: bowlofstew/Cello
static void List_Assign(var self, var obj) {
    struct List* l = self;

    List_Clear(self);

    l->type = implements_method(obj, Iter, iter_type) ? iter_type(obj) : Ref;
    l->tsize = size(l->type);

    size_t nargs = len(obj);
    for (size_t i = 0; i < nargs; i++) {
        List_Push(self, get(obj, $I(i)));
    }

}
コード例 #5
0
ファイル: List.c プロジェクト: bowlofstew/Cello
static void List_New(var self, var args) {

    struct List* l = self;
    l->type   = cast(get(args, $I(0)), Type);
    l->tsize  = size(l->type);
    l->nitems = 0;
    l->head = NULL;
    l->tail = NULL;

    size_t nargs = len(args);
    for(size_t i = 0; i < nargs-1; i++) {
        List_Push(self, get(args, $I(i+1)));
    }

}
コード例 #6
0
ファイル: interpreters.c プロジェクト: dennisj001/openvmtil
dllist *
_CfrTil_Interpret_ReadToList ( )
{
    byte * token ;
    Interpreter * interp = _Context_->Interpreter0 ;
    interp->InterpList = List_New ( ) ;
    while ( token = Lexer_ReadToken ( _Lexer_ ) )
    {
        if ( String_Equal ( token, ";l" ) ) break ;
        Word * word = _Interpreter_TokenToWord ( interp, token ) ;
        if ( word )
        {
            _Word_Interpret ( word ) ;
            //List_Push_A_1Value_Node ( interp->InterpList, word ) ;
            List_Push ( interp->InterpList, word ) ;
        }
    } 
    return interp->InterpList ;
}
コード例 #7
0
ファイル: w32skypeemu.c プロジェクト: TonyAlloa/miranda-dev
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)); 
}
コード例 #8
0
ファイル: thread.c プロジェクト: CERT-Polska/hsn2-razorback
SO_PUBLIC struct Thread *
Thread_Launch (void (*p_fpFunction) (struct Thread *), void *p_pUserData, 
		char *p_sName, struct RazorbackContext *p_pContext) {
	struct Thread *l_pThread;
	
	ASSERT (p_fpFunction != NULL);

#ifdef _MSC_VER
	if (initialized == 0)
		initThreading();

#else //_MSC_VER
	pthread_once (&g_once_control, initThreading);
#endif //_MSC_VER

	// Racy
	if (sg_threadList->length == Config_getThreadLimit ())
		return NULL;

	// allocate memory for thread structure
	l_pThread = (struct Thread *)calloc (1, sizeof (struct Thread));
	if (l_pThread == NULL) {
		rzb_log (LOG_ERR,
				 "%s: Failed to launch thread in Thread_Launch due to out of memory for Thread", __func__);
		return NULL;
	}

	// initialize running indicator
	l_pThread->bRunning = false;
	l_pThread->pContext = NULL;
	l_pThread->pUserData = p_pUserData;
	l_pThread->sName = p_sName;
	l_pThread->bShutdown = false;
	// Init ref count, once for the list, once for the caller.
	l_pThread->refs =2;

	l_pThread->mainFunction = p_fpFunction;
	// initialize running mutex
	if ((l_pThread->mMutex = Mutex_Create(MUTEX_MODE_NORMAL)) == NULL) {
		free(l_pThread);
		return NULL;
	}

#ifdef _MSC_VER
	l_pThread->hThread = CreateThread(NULL, 0, Thread_MainWrapper, l_pThread, 0, &l_pThread->iThread);
#else //_MSC_VER
	// start thread, check for error
	if (pthread_create
		(&l_pThread->iThread, &g_attr, Thread_MainWrapper, l_pThread) != 0) {
		free (l_pThread);
		rzb_log (LOG_ERR,
				 "%s: Failed to launch thread in Thread_Launch due to pthread_create error (%i)", __func__,
				 errno);
		return NULL;
	}
#endif //_MSC_VER
	List_Push(sg_threadList, l_pThread);

	// done
	return l_pThread;
}
コード例 #9
0
ファイル: dict.c プロジェクト: metacore/spin
void Dict_Initialize()
{
    GlobalDictionary = Hash_NewTable(0);
    List_Push(&DictionaryStack, GlobalDictionary);
}
コード例 #10
0
ファイル: List.c プロジェクト: bowlofstew/Cello
 foreach (item in obj) {
     List_Push(self, item);
 }