Esempio n. 1
0
static TString ProcessCommands(const _TCHAR *file) {
	FILE *fin;
#ifdef UNICODE
    int err = _wfopen_s(&fin, file, L"r,ccs=unicode");
#else
    int err = fopen_s(&fin, file, "r");
#endif
    if (err)
        return TString(file);

    FILE *fout;
    auto output_file = TempFile::Create(TEXT(".txt"), true);
#ifdef UNICODE
    err = _wfopen_s(&fout, output_file.data(), L"w,ccs=unicode");
#else
    err = fopen_s(&fout, output_file.data(), "w");
#endif
    if (err) {
        perror("LinkWrapper:ProcessCommands");
        exit(err);
    }

    _TINT ch = _gettc(fin);
	while (ch != _TEOF) {
        while (ch != _TEOF && _istspace(ch)) {
            _puttc(ch, fout);
            ch = _gettc(fin);
        }

        // FIXME: input files with spaces in them??? (are they quoted???)
		TString word;
		while (ch != _TEOF && !_istspace(ch)) {
			word.push_back(ch);
			ch = _gettc(fin);
		}
        // FIXME: handle comments (starting with ';')
        auto comment_pos = word.find(TCHAR(';'));
        assert(comment_pos == -1 && "Found comment in command file");
		if (!word.empty()) {
			auto new_word = ProcessArg(word.data());
            _fputts(new_word.data(), fout);
		}
	}
	fclose(fin);
    fclose(fout);
    return output_file;
}
Esempio n. 2
0
void CAipi_ExpParser::getToken()
{
	//AfxMessageBox(_T("GET TOKEN Lexer"));
	if( g_dataSource == DATA_GUI )
	{	
		CAipi_Lexer lex;
		++g_currentPos;
		m_lookahead = lex.getTokenGUI();
	
		while( m_lookahead == COMMENT )
		{
			++g_currentPos;
			m_lookahead = lex.getTokenGUI();	
		}

		CString str;
		str.Format(_T("Look Ahead...%d  " ), m_lookahead);
		AfxMessageBox(str);
		//str.Format(_T("pos...%d  " ), g_currentPos);
		//AfxMessageBox(str);
		m_sToken = lex.m_sToken;
		AfxMessageBox(m_sToken);
}

if( g_dataSource == DATA_FILE )
{
	CAipi_Lexer lex;
	TCHAR symbol =  _gettc(g_fp);
	m_lookahead = lex.getTokenFile(symbol);
	CString str;
	str.Format(_T("Look Ahead...%d  " ), m_lookahead);
	AfxMessageBox(str);
	//str.Format(_T("pos...%d  " ), g_fcurrentPos);
	//AfxMessageBox(str);
	m_sToken = lex.m_sToken;
	AfxMessageBox(m_sToken);

}

/*
	if( m_lookahead == _TEOF )
		return;
*/
}
Esempio n. 3
0
void CAipi_ExpParser::initExpParser()
{
	//g_currentTimeTag = 0;
	g_currentId_IForm = 1000;

	CAipi_Lexer lex;
		
	if( g_dataSource == DATA_GUI )
	{
		getToken();
	}
	else
	{
		TCHAR symbol =  _gettc(g_fp);
		m_lookahead = lex.getTokenFile(symbol);
	}

	
	translation_unit();
		
 
}
Esempio n. 4
0
VOID
CNdasService::ServiceDebug(DWORD dwArgc, LPTSTR *lpArgs)
{
	m_bDebugMode = TRUE;

	BOOL fSuccess = this->ximeta::CTask::Initialize();
	if (!fSuccess) {
		// TODO: Return appropriate error code for stopped
		// TODO: Event Log
		ReportStatusToSCMgr(SERVICE_STOPPED, 0, ::GetLastError());
		return;
	}

	//
	// Debug Window
	//

	DWORD dwDebugWndThreadId;
	HANDLE hDebugWndThread = (HANDLE) _beginthreadex( 
		NULL, 
		0, 
		&DebugWndThreadProc, 
		&m_hWndDebug, 
		0, 
		(PUINT) &dwDebugWndThreadId);

	while (!m_hWndDebug) {
		::Sleep(500); // wait for the window created.
	}

	fSuccess = this->Run();

	if (!fSuccess) {
		// TODO: Return appropriate error code for stopped
		// TODO: Event Log
		ReportStatusToSCMgr(SERVICE_STOPPED, 0, ::GetLastError());
		return;
	}

	HANDLE hServiceThread = this->GetTaskHandle();
	
	_tprintf(_T("Service Debug Started...\n"));
	while (TRUE) {
		_tprintf(_T("Press q and <Enter> to stop...\n"));
		TCHAR c = _gettc(stdin);
		if (c == _T('q') || c == _T('Q')) {
			break;
		}
	}

	_tprintf(_T("Please wait while stopping...\n"));

	HANDLE hTask = GetTaskHandle();
	this->Stop(FALSE);
	
	DWORD dwWaitTimeout = 5000L; // 30 sec
	DWORD dwWaitResult = ::WaitForSingleObject(hTask, dwWaitTimeout);
	
	if (dwWaitResult == WAIT_TIMEOUT) {
		_tprintf(_T("Freezed, forcibly terminating...\n"));
	}

	return;
}