Пример #1
0
int _tmain(int argc, _TCHAR* argv[])
{
	CTGitPath path;
	CString root;
	TCHAR buff[256];
	
	GetCurrentDirectory(256,buff);
	path.SetFromWin(buff);

	if(!path.HasAdminDir(&root))
	{
		printf("not in git repository\n");
		return -1;
	}

	CGitIndexList list;
	list.ReadIndex(root+_T("\\.git\\index"));

	CGitHeadFileList filelist;
	filelist.ReadHeadHash(buff);
	_tprintf(_T("update %d\n"), filelist.CheckHeadUpdate());

	git_init();
//	filelist.ReadTree();

	WIN32_FIND_DATA data;
	CString str(buff);
	str+=_T("\\*.*");
	GitStatus status;

	HANDLE handle = FindFirstFile(str,&data);
	while(FindNextFile(handle,&data))
	{
		if( _tcsnccmp(data.cFileName, _T(".."),2) ==0) 
			continue;
		if( _tcsnccmp(data.cFileName, _T("."),1) ==0 ) 
			continue;

		CString spath(buff);
		spath += _T("\\");
		spath += data.cFileName;
		CTGitPath path(spath);

		TCHAR name[100];
		int t1,t2;
		t1 = ::GetCurrentTime();
		status.GetStatusString(status.GetAllStatus(path), 100,name);
		t2 = ::GetCurrentTime();

		_tprintf(_T("%s - %s - %d\n"),data.cFileName, name, t2-t1);
		
	}

	return 0;
}
Пример #2
0
    virtual void ParseParam(const TCHAR* pszParam, BOOL bFlag, BOOL bLast) {
        // Expected command line:
        // /h | help  : msg box with command line arguments
        // /f | force : force UI selection
        // /7         : require java 1.7
        // path-to-launch

        if (!bFlag) {
            mFilename = pszParam;
        } else if (_tcsnccmp(pszParam, _T("h"), 2) == 0) {
            mDoHelp = true;
        } else if (_tcsnccmp(pszParam, _T("f"), 2) == 0) {
            mDoForceUi = true;
        } else if (_tcsnccmp(pszParam, _T("7"), 2) == 0) {
            mDoJava1_7 = true;
        }
    }
Пример #3
0
void fsUpdateMgr::ProcessUpdateLstFile()
{	
	TCHAR szSections [10000];
	*szSections = 0;
	TCHAR szValues [10000];

	if (::GetVersion () & 0x80000000)
		FixIniFileFor9x (fsGetDataFilePath (_T("Update\\proupd3.lst")));

	
	
	if (0 == GetPrivateProfileSectionNames (szSections, sizeof (szSections), 
		fsGetDataFilePath (_T("Update\\proupd3.lst"))) || 
		_tstoi (szSections) <= (int)vmsFdmAppMgr::getVersion ()->m_appVersion [2].dwVal)
	{
		ASSERT (GetPrivateProfileSectionNames (szSections, sizeof (szSections), fsGetDataFilePath (_T("Update\\proupd3.lst"))));
		
		_App.NewVerExists (FALSE);
		Event (UME_NEWVERSIONNOTAVAIL);
		m_bRunning = FALSE;
		return;
	}

	
	m_strBN = szSections;

	CString strCurBN;	
	strCurBN = vmsFdmAppMgr::getBuildNumberAsString ();
	
	m_strUpgSize = "";
	m_strUpgFileName = "";
	m_vWN.clear ();

	LPCTSTR pszSect = szSections;

	while (*pszSect)
	{
		
		GetPrivateProfileSection (pszSect, szValues, sizeof (szValues), 
			fsGetDataFilePath (_T("Update\\proupd3.lst")));
		LPTSTR pszValue = szValues;

		
		BOOL bCommon = _tcsicmp (pszSect, _T("Common")) == 0;

		
		BOOL bNewBNNow = bCommon == FALSE && _tcscmp (pszSect, m_strBN) == 0;
		
		BOOL bBiggerBNNow = bCommon == FALSE && _tstoi (pszSect) > (int)vmsFdmAppMgr::getVersion ()->m_appVersion [2].dwVal;

		
		while (*pszValue)
		{
			
			LPTSTR pszVVal = _tcschr (pszValue, _T('='));
			*pszVVal = 0;
			pszVVal++;	

			if (bCommon)
			{
				
				if (_tcsicmp (pszValue, _T("DownloadPathForFullInstall")) == 0)
				{
					m_strDlFullInstallPath = pszVVal;
					if (m_strDlFullInstallPath [m_strDlFullInstallPath.GetLength () - 1] != _T('\\') && 
							m_strDlFullInstallPath [m_strDlFullInstallPath.GetLength () - 1] != _T('/'))
						m_strDlFullInstallPath += _T('/');
				}

				if (_tcsicmp (pszValue, _T("DownloadPathForUpgrades")) == 0)
				{
					m_strDlUpgradesPath = pszVVal;
					if (m_strDlUpgradesPath [m_strDlUpgradesPath.GetLength () - 1] != _T('\\') && 
							m_strDlUpgradesPath [m_strDlUpgradesPath.GetLength () - 1] != _T('/'))
						m_strDlUpgradesPath += _T('/');
				}
			}

			if (bNewBNNow)
			{
				if (_tcsicmp (pszValue, _T("Version")) == 0)
					m_strVersion = pszVVal;	
				else if (_tcsicmp (pszValue, _T("FullSize")) == 0)
					m_strFullSize = pszVVal;	
				else if (_tcsicmp (pszValue, strCurBN) == 0)
					m_strUpgSize = pszVVal;	
				else if (_tcsncicmp (pszValue, strCurBN, strCurBN.GetLength ()) == 0)
				{
					
					
					if (_tcsicmp (pszValue + strCurBN.GetLength (), _T("-name")) == 0)
						m_strUpgFileName = pszVVal;
					
					
					else if (_tcsicmp (pszValue + strCurBN.GetLength (), _T("-size")) == 0)
						m_strUpgSize = pszVVal;
				}
				else if (_tcsicmp (pszValue, _T("FrmtVer")) == 0)
				{
					
					int nVer = _tstoi (pszVVal);
					if (nVer != 1)
					{
						
						_App.NewVerExists (FALSE);
						Event (UME_NEWVERSIONNOTAVAIL);
						m_bRunning = FALSE;
						return;
					}
				}
				else if (!_tcsicmp (pszValue, _T("Flags")))
					m_dwFlags = _tcstoul (pszVVal, NULL, 10);
			}

			
			
			if (bBiggerBNNow && _tcsnccmp (pszValue, _T("WN"), 2) == 0)
				m_vWN.add (pszVVal);

			pszValue = pszVVal;
			while (*pszValue++);	
		}

		while (*pszSect++); 
	}

	if ((m_dwFlags & IgnoreUpdateInAutomaticMode) && !m_bCheckingByUser)
	{
		
		_App.NewVerExists (FALSE);
		Event (UME_NEWVERSIONNOTAVAIL);
		m_bRunning = FALSE;
		return;
	}

	Event (UME_NEWVERSIONAVAIL);
}
Пример #4
0
int __cdecl _tmain(int argc, _TCHAR* argv[])
{

#if defined(TWO_PIPE)
    //
    // Experiment with pipe to pipe so we can debug using VPC and capture
    // a log of a working debug session.
    //

    PipeReader  sock;

#else

    SockReader  sock;

#endif

    PipeReader  pipe;
    Logger      log;

    //
    // Save the name of the current running program. This is not presented
    // in argv[0] as you might expect... but hey, this is Windows.
    //

    GetModuleFileName(NULL, g_progname, sizeof (g_progname));
    g_progname[sizeof(g_progname) - 1] = _T('\0');
    *argv++;
    --argc;

    if (argc == 0)
        usage();

    //
    // Three arguments if you count the program name, the pipe name and
    // the port (or 2nd pipe).
    //

    if (_tcsncmp(*argv, _T("-l"), 2) == 0)
    {
        if (!log.Initialize())
        {
            die("couldn't initialize logger");
        }
        argv++;
        --argc;

        if (argc == 0)
            usage();
    }


    bool passive;

    if (argc == 2)
    {
        passive = true;
    }
    else if (argc == 3)
    {
        passive = false;
    }
    else
    {
        usage();
    }

    g_log = &log;

    //
    // Note: sock.Initialize will fire up the socket pump thread,
    // pipe initialization needs to be completed before that.
    //

    _TCHAR * lpipename = *argv;

#define whack_pipe _T("\\\\.\\pipe\\")

    size_t whackPipeLen =  (sizeof(whack_pipe) / sizeof(_TCHAR)) - 1;
    if (_tcsnccmp(lpipename, whack_pipe, whackPipeLen) != 0)
    {
        size_t originalNameLen = _tcslen(lpipename);
        size_t nameLen = whackPipeLen + originalNameLen + 1;
        if (nameLen > 1024) // arbitary
        {
            die("pipe name is too long.");
        }
        lpipename = (_TCHAR *)malloc(nameLen * sizeof(_TCHAR));
        if (lpipename == NULL)
        {
            die("failed to malloc space for local pipe name.");
        }
        memcpy(&lpipename[0], whack_pipe, whackPipeLen * sizeof(_TCHAR));
        memcpy(&lpipename[whackPipeLen],
               *argv,
               originalNameLen * sizeof(_TCHAR));
        lpipename[nameLen - 1] = 0;
    }
    argv++;

    printf("gonna try pipe '%s'\n", lpipename);
    if (!pipe.Initialize(lpipename, &log, &sock, false, false, "pip"))
    {
        die("couldn't open local named pipe, err %d", GetLastError());
    }

#if !defined(TWO_PIPE)
    _TCHAR * address;
    _TCHAR * portnumber;

    if (passive) {
        address = NULL;
        portnumber = *argv;
    } else {
        address = *argv++;
        portnumber = *argv;
    }

    if (!sock.Initialize(address, portnumber, &log, &pipe, true, "win"))
    {
        die("couldn't open socket.");
    }
#else
    _TCHAR * rpipename = *argv;

    if (!sock.Initialize(rpipename, &log, &pipe, true, true, "sok"))
    {
        die("couldn't open remote pipe.");
    }
#endif

    // 
    // We run the pipe reader directly on this thread.
    //

    pipe.ThreadEntry(&pipe);

    return 0;
}
Пример #5
0
int LoadWebservers(HTTPCSTR path) {

	FILE *webservers;
	HTTPCHAR tmp[512];
	HTTPCHAR line[512];



	webservers=_tfopen(path,_T("r"));
	if (!webservers) {
		return(0);
	}
	nvlist=-1;
	for(unsigned int i=0;i<sizeof(vlist)/sizeof(VLIST);i++) memset((HTTPCHAR *)&vlist[i],'\0',sizeof(VLIST));
	while (!feof(webservers))
	{
		memset(tmp,'\0',sizeof(tmp));
		if ( ReadAndSanitizeInput(webservers,tmp,sizeof(tmp)/sizeof(HTTPCHAR)) )
		{
			memset(line,'\0',sizeof(line));
			ValidateLine(tmp,line);

			if (_tcsnccmp(line,_T("vulnerability="),14)==0){
				nvlist++;
				_tcsncpy(vlist[nvlist].vulnerability,line+14,sizeof(vlist[nvlist].vulnerability)/sizeof(HTTPCHAR)-1);
			}
			if (_tcsnccmp(line,_T("status="),7)==0){
				vlist[nvlist].status=_tstoi(line+7);
			}
			if (_tcsnccmp(line,_T("server="),7)==0){
				_tcsncpy(vlist[nvlist].server,line+7,sizeof(vlist[nvlist].server)/sizeof(HTTPCHAR)-1);
			}
			if (_tcsnccmp(line,_T("url="),4)==0){
				_tcsncpy(vlist[nvlist].url,line+4,sizeof(vlist[nvlist].url)/sizeof(HTTPCHAR)-1);
			}
			if (_tcsnccmp(line,_T("Ignoresignature="),16)==0){
				_tcsncpy(vlist[nvlist].Ignoresignature,line+16,sizeof(vlist[nvlist].Ignoresignature)/sizeof(HTTPCHAR)-1);
			}
#define TOTALMATCHES vlist[nvlist].nMatch


			if (_tcsnccmp(line,_T("description="),12)==0){
				//RESERVAMOS MEMORIA PARA UN NUEVO MATCH
				vlist[nvlist].Match=(PMATCH)realloc(vlist[nvlist].Match,sizeof(MATCH)*(TOTALMATCHES+1));
				//PONEMOS A NULL LA VALIDACIoN
				//vlist[nvlist].Match[ TOTALMATCHES ].Validatestring=NULL;
				vlist[nvlist].Match[ TOTALMATCHES ].nstrings=0;
				//COPIAMOS LA DESCRIPCION
				_tcsncpy( vlist[nvlist].Match[vlist[nvlist].nMatch].description,line+12,sizeof(vlist[nvlist].Match[vlist[nvlist].nMatch].description)/sizeof(HTTPCHAR)-1);
				//INCREMENTAMOS EL CONTANDOR DE MATCHES
				vlist[nvlist].nMatch++;
			}

			if (_tcsnccmp(line,_T("Validatestring="),15)==0){
				//reservamos memoria para los matches..
				//vlist[nvlist].Match[ TOTALMATCHES -1].Validatestring=(char *)realloc(vlist[nvlist].Match[ TOTALMATCHES ].Validatestring, 200 * vlist[nvlist].Match[ TOTALMATCHES -1].nstrings+1);
				//copiamos la linea
				_tcsncpy(vlist[nvlist].Match[TOTALMATCHES -1].Validatestring[vlist[nvlist].Match[ TOTALMATCHES -1].nstrings],line+15,sizeof(vlist[nvlist].Match[TOTALMATCHES -1].Validatestring[vlist[nvlist].Match[ TOTALMATCHES -1].nstrings])/sizeof(HTTPCHAR)-1);
				vlist[nvlist].Match[ TOTALMATCHES  -1].nstrings++;
			}
			if (_tcsnccmp(line,_T("Ignorestring="),13)==0){
				//reservamos memoria para los matches..
				//vlist[nvlist].Match[ TOTALMATCHES -1].Validatestring=(char *)realloc(vlist[nvlist].Match[ TOTALMATCHES ].Validatestring, 200 * vlist[nvlist].Match[ TOTALMATCHES -1].nstrings+1);
				//copiamos la linea
				_tcscpy( vlist[nvlist].Match[TOTALMATCHES-1].Ignorestring-1,line+13);
			}


		}
	}
	nvlist++;
	fclose(webservers);
	return(nvlist);

}
Пример #6
0
int LoadWebForms(HTTPCSTR path)
{
	FILE *webforms=_tfopen(path,_T("r"));
	nWebforms=0;

	if (webforms) 
	{
		HTTPCHAR line[512];
		HTTPCHAR tmp[512];

		int i;
		for(i=0;i<MAX_WEBFORMS;i++) memset((HTTPCHAR*)&WEBFORMS[i],'\0',sizeof(struct _webform));
		while( (!feof(webforms)) && (nWebforms<MAX_WEBFORMS) )
		{
			//fgets(tmp,sizeof(tmp),webforms);

			//if ( (strlen(tmp)>6) && (tmp[0]!='#') && (tmp[0]!=';'))
			if (ReadAndSanitizeInput(webforms,tmp,sizeof(tmp)/sizeof(HTTPCHAR)))
			{
				memset(line,'\0',sizeof(line));
				ValidateLine(tmp,line);

				if (_tcsnccmp(line,_T("Model="),6)==0)
					_tcsncpy(WEBFORMS[nWebforms].model,line+6,sizeof(WEBFORMS[nWebforms].model)/sizeof(HTTPCHAR));

				if (_tcsnccmp(line,_T("status="),7)==0)
					WEBFORMS[nWebforms].status=_tstoi(line+7);
				if (_tcsnccmp(line,_T("server="),7)==0) {
					_tcsncpy(WEBFORMS[nWebforms].server,line+7,sizeof(WEBFORMS[nWebforms].server)/sizeof(HTTPCHAR));
				}
				if (_tcsnccmp(line,_T("Matchstring="),12)==0)
					_tcsncpy(WEBFORMS[nWebforms].matchstring,line+12,sizeof(WEBFORMS[nWebforms].matchstring)/sizeof(HTTPCHAR));
				if (_tcsnccmp(line,_T("ValidateImage="),14)==0)
					_tcsncpy(WEBFORMS[nWebforms].ValidateImage,line+14,sizeof(WEBFORMS[nWebforms].ValidateImage)/sizeof(HTTPCHAR));
				if (_tcsnccmp(line,_T("authurl="),8)==0)
					_tcsncpy(WEBFORMS[nWebforms].authurl,line+8,sizeof(WEBFORMS[nWebforms].authurl)/sizeof(HTTPCHAR));
				if (_tcsnccmp(line,_T("authmethod="),11)==0)
					_tcsncpy(WEBFORMS[nWebforms].authmethod,line+11,sizeof(WEBFORMS[nWebforms].authmethod)/sizeof(HTTPCHAR));
				if (_tcsnccmp(line,_T("requireloginandpass="******"authform="),9)==0)
					_tcsncpy(WEBFORMS[nWebforms].authform,line+9,sizeof(WEBFORMS[nWebforms].authform)/sizeof(HTTPCHAR));
				if (_tcsnccmp(line,_T("validauthstring="),16)==0) {
					_tcsncpy(WEBFORMS[nWebforms].validauthstring,line+16,sizeof(WEBFORMS[nWebforms].validauthstring)/sizeof(HTTPCHAR));
				}
				if (_tcsnccmp(line,_T("validauthstringalt="),19)==0) {
					_tcsncpy(WEBFORMS[nWebforms].validauthstringalt,line+19,sizeof(WEBFORMS[nWebforms].validauthstringalt)/sizeof(HTTPCHAR));
				}


				if (_tcsnccmp(line,_T("invalidauthstring="),18)==0) {
					_tcsncpy(WEBFORMS[nWebforms].invalidauthstring,line+18,sizeof(WEBFORMS[nWebforms].invalidauthstring)/sizeof(HTTPCHAR));
					nWebforms++;
				}
				//optional Headers
				if (_tcsnccmp(line,_T("invalidauthstringalt="),21)==0) {
					_tcsncpy(WEBFORMS[nWebforms-1].invalidauthstringalt,line+21,sizeof(WEBFORMS[nWebforms-1].invalidauthstringalt)/sizeof(HTTPCHAR));
				}
				if (_tcsnccmp(line,_T("AdditionalHeader="),17)==0) {
					_tcsncpy(WEBFORMS[nWebforms-1].AdditionalHeader,line+17,sizeof(WEBFORMS[nWebforms-1].AdditionalHeader)/sizeof(HTTPCHAR));
				}
				if (_tcsnccmp(line,_T("UpdateCookie="),13)==0)
					WEBFORMS[nWebforms-1].UpdateCookie=_tstoi(line+13);
				if (_tcsnccmp(line,_T("InitialCookieURL="),17)==0) {
					_tcsncpy(WEBFORMS[nWebforms-1].InitialCookieURL,line+17,sizeof(WEBFORMS[nWebforms-1].InitialCookieURL)/sizeof(HTTPCHAR));
				}
				if (_tcsnccmp(line,_T("ValidateAlternativeurl="),23)==0) {
					_tcsncpy(WEBFORMS[nWebforms-1].ValidateAlternativeurl,line+23,sizeof(WEBFORMS[nWebforms-1].ValidateAlternativeurl)/sizeof(HTTPCHAR));
				}
				if (_tcsnccmp(line,_T("LoadAdditionalUrl="),18)==0) {
					_tcsncpy(WEBFORMS[nWebforms-1].LoadAdditionalUrl,line+18,sizeof(WEBFORMS[nWebforms-1].LoadAdditionalUrl)/sizeof(HTTPCHAR));
				}
				if (_tcsnccmp(line,_T("ReconnectOnMatch="),17)==0) {
					_tcsncpy(WEBFORMS[nWebforms-1].ReconnectOnMatch,line+17,sizeof(WEBFORMS[nWebforms-1].ReconnectOnMatch)/sizeof(HTTPCHAR));
				}


			}
		}
		fclose(webforms);
	}
	return(nWebforms);
}