Exemple #1
0
LPVOID CActiveXUI::GetInterface(LPCTSTR pstrName)
{
	if( _tcscmp(pstrName, _T("ActiveX")) == 0 ) return static_cast<CActiveXUI*>(this);
	return CControlUI::GetInterface(pstrName);
}
Exemple #2
0
bool DevLXV7::PLXV0(PDeviceDescriptor_t d, const TCHAR* sentence, NMEA_INFO* info)
{
TCHAR  szTmp1[80], szTmp2[80];




  NMEAParser::ExtractParameter(sentence,szTmp1,1);
  if  (_tcscmp(szTmp1,_T("W"))!=0)  // no write flag received
	 return false;

  NMEAParser::ExtractParameter(sentence,szTmp1,0);
  if  (_tcscmp(szTmp1,_T("BRGPS"))==0)
  {
	NMEAParser::ExtractParameter(sentence,szTmp2,2);
	LXV7_iGPSBaudrate = Baudrate( (int)( (StrToDouble(szTmp2,NULL))+0.1 ) );
	return true;
  }

  if (_tcscmp(szTmp1,_T("BRPDA"))==0)
  {
	NMEAParser::ExtractParameter(sentence,szTmp2,2);
	LXV7_iPDABaudrate = Baudrate( (int) StrToDouble(szTmp2,NULL));
	return true;
  }

  NMEAParser::ExtractParameter(sentence,szTmp1,0);
  if  (_tcscmp(szTmp1,_T("QNH"))==0)
  {
	NMEAParser::ExtractParameter(sentence,szTmp2,2);
	QNH =  (StrToDouble(szTmp2,NULL))/100.0;
	return true;
  }
#ifdef DEBUG_PARAMETERS
  if (_tcscmp(szTmp1,_T("MC"))==0)
  {
	NMEAParser::ExtractParameter(sentence,szTmp2,2);
	iTmp =(int) StrToDouble(szTmp2,NULL);
	return true;
  }

  if (_tcscmp(szTmp1,_T("BAL"))==0)
  {
	NMEAParser::ExtractParameter(sentence,szTmp2,2);
	iTmp = (int) StrToDouble(szTmp2,NULL);
	return true;
  }

  if (_tcscmp(szTmp1,_T("BUGS"))==0)
  {
	NMEAParser::ExtractParameter(sentence,szTmp2,2);
	iTmp = (int) StrToDouble(szTmp2,NULL);
	return true;
  }


  if (_tcscmp(szTmp1,_T("VOL"))==0)
  {
	NMEAParser::ExtractParameter(sentence,szTmp2,2);
	iTmp = (int) StrToDouble(szTmp2,NULL);
	return true;
  }

  if (_tcscmp(szTmp1,_T("POLAR"))==0)
  {
	NMEAParser::ExtractParameter(sentence,szTmp2,2);
	iTmp = (int) StrToDouble(szTmp2,NULL);
	return true;
  }

  if (_tcscmp(szTmp1,_T("CONNECTION"))==0)
  {
	NMEAParser::ExtractParameter(sentence,szTmp2,2);
	iTmp = (int) StrToDouble(szTmp2,NULL);
	return true;
  }

  if (_tcscmp(szTmp1,_T("NMEARATE"))==0)
  {
	NMEAParser::ExtractParameter(sentence,szTmp2,2);
	iTmp = (int) StrToDouble(szTmp2,NULL);
	return true;
  }
#endif
  return(false);
} // PLXV0()
Exemple #3
0
void CShortcutEditUI::SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue)
{
	if( _tcscmp(pstrName, _T("readonly")) == 0 ) SetReadOnly(_tcscmp(pstrValue, _T("true")) == 0);
	else if( _tcscmp(pstrName, _T("numberonly")) == 0 ) SetNumberOnly(_tcscmp(pstrValue, _T("true")) == 0);
	else if( _tcscmp(pstrName, _T("password")) == 0 ) SetPasswordMode(_tcscmp(pstrValue, _T("true")) == 0);
	else if( _tcscmp(pstrName, _T("maxchar")) == 0 ) SetMaxChar(_ttoi(pstrValue));
	else if( _tcscmp(pstrName, _T("normalimage")) == 0 ) SetNormalImage(pstrValue);
	else if( _tcscmp(pstrName, _T("hotimage")) == 0 ) SetHotImage(pstrValue);
	else if( _tcscmp(pstrName, _T("focusedimage")) == 0 ) SetFocusedImage(pstrValue);
	else if( _tcscmp(pstrName, _T("disabledimage")) == 0 ) SetDisabledImage(pstrValue);
	else if( _tcscmp(pstrName, _T("nativebkcolor")) == 0 ) {
		if( *pstrValue == _T('#')) pstrValue = ::CharNext(pstrValue);
		LPTSTR pstr = NULL;
		DWORD clrColor = _tcstoul(pstrValue, &pstr, 16);
		SetNativeEditBkColor(clrColor);
	}
	else CLabelUI::SetAttribute(pstrName, pstrValue);
}
// Parses URL. This method's code was taken from 
// http://www.codeproject.com/KB/IP/simplehttpclient.aspx
void CHttpRequestSender::ParseURL(LPCTSTR szURL, LPTSTR szProtocol, UINT cbProtocol, 
  LPTSTR szAddress, UINT cbAddress, DWORD &dwPort, LPTSTR szURI, UINT cbURI)
{  
	cbURI;
	cbAddress;
	cbProtocol;
	
	DWORD dwPosition=0;
	BOOL bFlag=FALSE;

	while(_tcslen(szURL)>0 && dwPosition<_tcslen(szURL) && _tcsncmp((szURL+dwPosition), _T(":"), 1))
		++dwPosition;

	if(!_tcsncmp((szURL+dwPosition+1), _T("/"), 1)){	// is PROTOCOL
		if(szProtocol){
			_TCSNCPY_S(szProtocol, cbProtocol, szURL, dwPosition);
			szProtocol[dwPosition]=0;
		}
		bFlag=TRUE;
	}else{	// is HOST 
		if(szProtocol){
			_TCSNCPY_S(szProtocol, cbProtocol, _T("http"), 4);
			szProtocol[5]=0;
		}
	}

	DWORD dwStartPosition=0;
	
	if(bFlag){
		dwStartPosition=dwPosition+=3;				
	}else{
		dwStartPosition=dwPosition=0;
	}

	bFlag=FALSE;
	while(_tcslen(szURL)>0 && dwPosition<_tcslen(szURL) && _tcsncmp(szURL+dwPosition, _T("/"), 1))
			++dwPosition;

	DWORD dwFind=dwStartPosition;

	for(;dwFind<=dwPosition;dwFind++){
		if(!_tcsncmp((szURL+dwFind), _T(":"), 1)){ // find PORT
			bFlag=TRUE;
			break;
		}
	}

	if(bFlag)
  {
		TCHAR sztmp[256]=_T("");
		_TCSNCPY_S(sztmp, 256, (szURL+dwFind+1), dwPosition-dwFind);
		dwPort=_ttol(sztmp);
    int len = dwFind-dwStartPosition;
		_TCSNCPY_S(szAddress, cbAddress, (szURL+dwStartPosition), len);
    szAddress[len]=0;
	}
  else if(!_tcscmp(szProtocol,_T("https")))
  {
		dwPort=INTERNET_DEFAULT_HTTPS_PORT;
    int len = dwPosition-dwStartPosition;
		_TCSNCPY_S(szAddress, cbAddress, (szURL+dwStartPosition), len);
    szAddress[len]=0;
	}
  else 
  {
		dwPort=INTERNET_DEFAULT_HTTP_PORT;
    int len = dwPosition-dwStartPosition;
		_TCSNCPY_S(szAddress, cbAddress, (szURL+dwStartPosition), len);    
    szAddress[len]=0;
	}

	if(dwPosition<_tcslen(szURL))
  { 
    // find URI
    int len = (int)(_tcslen(szURL)-dwPosition);
		_TCSNCPY_S(szURI, cbURI, (szURL+dwPosition), len);
    szURI[len] = 0;
	}
  else
  {
		szURI[0]=0;
	}

	return;
}
Exemple #5
0
	LPVOID CButtonUI::GetInterface(LPCTSTR pstrName)
	{
		if( _tcscmp(pstrName, DUI_CTR_BUTTON) == 0 ) return static_cast<CButtonUI*>(this);
		return CLabelUI::GetInterface(pstrName);
	}
Exemple #6
0
IHTMLElement* FindElement(IHTMLDocument2* pDoc2, LPCTSTR elementId, LPCTSTR elementName)
{
	USES_CONVERSION;
	HRESULT hr;

	//Enumerate the HTML elements
    IHTMLElementCollection* pColl = NULL;
    hr = pDoc2->get_all( &pColl );
    if (hr == S_OK && pColl != NULL)
    {
		LONG celem;
        pColl->get_length( &celem );

		 //Loop through each elment
        for ( int i=0; i< celem; i++ )
        {
            VARIANT varIndex;
            varIndex.vt = VT_UINT;
            varIndex.lVal = i;
            VARIANT var2;
            VariantInit( &var2 );

            IDispatch* pDisp; 

            hr = pColl->item( varIndex, var2, &pDisp );//Get an element

			if ( hr == S_OK )
            {
                IHTMLElement* pElem;
				//Ask for an HTMLElemnt interface
                hr = pDisp->QueryInterface(IID_IHTMLElement, (void **)&pElem);

				if ( hr == S_OK )
                {
					if(elementId != NULL) //find element by Id
					{
						BSTR bstr;
						//Get the id of the element
						pElem->get_id(&bstr);
	                   					
						LPCTSTR id = OLE2T(bstr);

						if(_tcscmp(id, elementId))
						{
							return pElem;						
						}
					}
					else if(elementName != NULL) //find element by Name
					{
						IHTMLInputButtonElement* pButton;
                        hr = pDisp->QueryInterface(IID_IHTMLInputButtonElement,(void **)&pButton);
                        if ( hr == S_OK )
                        {
							BSTR bstr;
							//Get the name of the element
							pButton->get_name(&bstr);
		                   					
							LPCTSTR name = OLE2T(bstr);

							if(_tcscmp(name, elementName))
							{
								return pElem;						
							}
						}
					}
					
					pElem->Release();
				}
			}			
		}

		pColl->Release();
	}

	return NULL;
}
Exemple #7
0
static DWORD
ProcessDirectory(LPTSTR FileName, DWORD* dwFlags, DWORD dwAttrFlags)
{
        TCHAR szFullPath[MAX_PATH];
        LPTSTR pFilePart;
        LPTSTR pSearchPart;
        HANDLE hFile;
        WIN32_FIND_DATA f;
        DWORD dwFiles = 0;

        GetFullPathName (FileName,
                         MAX_PATH,
                         szFullPath,
                         &pFilePart);

        dwFiles = DeleteFiles(szFullPath, dwFlags, dwAttrFlags);
        if (dwFiles & 0x80000000)
                return dwFiles;

        if (*dwFlags & DEL_SUBDIR)
        {
	        /* Get just the file name */
	        pSearchPart = _tcsrchr(FileName,_T('\\'));
	        if(pSearchPart != NULL)
		        pSearchPart++;
	        else
		        pSearchPart = FileName;

	        /* Get the full path to the file */
	        GetFullPathName (FileName,MAX_PATH,szFullPath,NULL);

	        /* strip the filename off of it */
                pFilePart = _tcsrchr(szFullPath, _T('\\'));
                if (pFilePart == NULL)
                {
                        pFilePart = szFullPath;
                }
                else
                {
                        pFilePart++;
                }

                _tcscpy(pFilePart, _T("*"));

                hFile = FindFirstFile(szFullPath, &f);
                if (hFile != INVALID_HANDLE_VALUE)
                {
                        do
                        {
       		                if (!(f.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ||
                                    !_tcscmp(f.cFileName, _T(".")) ||
                                    !_tcscmp(f.cFileName, _T("..")))
		                        continue;

                                _tcscpy(pFilePart, f.cFileName);
                                _tcscat(pFilePart, _T("\\"));
                                _tcscat(pFilePart, pSearchPart);

                                dwFiles +=ProcessDirectory(szFullPath, dwFlags, dwAttrFlags);
                                if (dwFiles & 0x80000000)
                                {
                                    break;
                                }
                        }
                        while (FindNextFile (hFile, &f));
	                FindClose (hFile);
                }
        }
        return dwFiles;
}
LPVOID CWkeWebkitUI::GetInterface(LPCTSTR pstrName)
{
	if( _tcscmp(pstrName, _T("WbkWebkit")) == 0 ) return static_cast<CWkeWebkitUI*>(this);
	return CControlUI::GetInterface(pstrName);
}
Exemple #9
0
bool LRegistry::EnumRegistryKeys(HKEY hkMain, LPCTSTR tszSubKey, ENTRY **paEntries, DWORD *dwCount, bool bSort)
{
   if (dwCount == NULL)
      return false;

   HKEY hkKey = NULL;
   LONG res = ::RegOpenKeyEx(hkMain, tszSubKey, 0, KEY_READ, &hkKey);
   if (ERROR_SUCCESS == res)
   {
      DWORD dwValueCount = 0;
      DWORD dwEnumCounter = 0;
      _TCHAR tszName[256];
      while (ERROR_SUCCESS == res)
      {
         DWORD dwSize = 255;
         res = ::RegEnumKey(hkKey, dwEnumCounter, tszName, dwSize);
         if (ERROR_SUCCESS == res)
         {
            if (_tcscmp(tszName, _T("")) != 0)
            {
               if (paEntries)
               {
                  paEntries[dwValueCount]->lsName = tszName;
               }
               dwValueCount++;
            }
            dwEnumCounter++;
         }
      }

      if (ERROR_NO_MORE_ITEMS == res)
      {
         res = ERROR_SUCCESS;
         *dwCount = dwValueCount;
      }
      else
      {
         *dwCount = 0;
      }
   }

   if (ERROR_SUCCESS == res && bSort && paEntries)
   {
      ENTRY *pSmallest      = NULL;
      int    nSmallestIndex = 0;
      int    nCount = (int) *dwCount;
      // Insert Sort
      for (int i=0; i<nCount; ++i)
      {
         pSmallest = paEntries[i];
         nSmallestIndex = i;

         for (int j=i+1; j<nCount; ++j)
         {
            if (_tcsicmp((LPCTSTR) paEntries[j]->lsName, (LPCTSTR) pSmallest->lsName) < 0)
            {
               pSmallest = paEntries[j];
               nSmallestIndex = j;
            }
         }

         if (nSmallestIndex != i)
         {
            paEntries[nSmallestIndex] = paEntries[i];
            paEntries[i] = pSmallest;
         }
      }
   }

   return (ERROR_SUCCESS == res);
}
Exemple #10
0
	LPVOID CSeqButtonUI::GetInterface(LPCTSTR pstrName)
	{
		if( _tcscmp(pstrName, _T("SeqButton")) == 0 ) 
			return static_cast<CSeqButtonUI*>(this);
		return CButtonUI::GetInterface(pstrName);
	}
Exemple #11
0
	void CSeqButtonUI::SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue)
	{
		if( _tcscmp(pstrName, _T("seqimages")) == 0 ) SetSeqImages(pstrValue);
		else if( _tcscmp(pstrName, _T("framecnt")) == 0 ) SetTotalFrameCnt(_ttoi(pstrValue));
		else CButtonUI::SetAttribute(pstrName,pstrValue);
	}
Exemple #12
0
int Run(LPTSTR /*lpstrCmdLine*/ = NULL, int /*nCmdShow*/ = SW_SHOWDEFAULT)
{ 
	int nRet = 0; // Return code
	CErrorReportDlg dlgErrorReport; // Error Report dialog
	CResendDlg dlgResend; // Resend dialog

	// Get command line parameters.
	LPCWSTR szCommandLine = GetCommandLineW();

    // Split command line.
    int argc = 0;
    LPWSTR* argv = CommandLineToArgvW(szCommandLine, &argc);

    // Check parameter count.
    if(argc!=2)
        return 1; // No arguments passed, exit.

	if(_tcscmp(argv[1], _T("/terminate"))==0)
	{
		// User wants us to find and terminate all instances of CrashSender.exe
		return CErrorReportSender::TerminateAllCrashSenderProcesses();
	}

	// Extract file mapping name from command line arg.    
    CString sFileMappingName = CString(argv[1]);
		
	// Create the sender model that will collect crash report data 
	// and send error report(s).
	CErrorReportSender* pSender = CErrorReportSender::GetInstance();

	// Init the sender object
	BOOL bInit = pSender->Init(sFileMappingName.GetBuffer(0));
	if(!bInit)
    {
		// Failed to init 
		delete pSender;
        return 0;
    }      

	// Determine what to do next 
	// (either run in GUI more or run in silent mode).
	if(!pSender->GetCrashInfo()->m_bSilentMode)
	{
		// GUI mode.
		// Create message loop.
		CMessageLoop theLoop;
		_Module.AddMessageLoop(&theLoop);

		if(!pSender->GetCrashInfo()->m_bSendRecentReports)
		{
			// Create "Error Report" dialog			
			if(dlgErrorReport.Create(NULL) == NULL)
			{
				ATLTRACE(_T("Error report dialog creation failed!\n"));
				delete pSender;
				return 1;
			}			
		}
		else
		{        
			// Create "Send Error Reports" dialog.					
			if(dlgResend.Create(NULL) == NULL)
			{
				ATLTRACE(_T("Resend dialog creation failed!\n"));
				delete pSender;
				return 1;
			}			
		}

		// Process window messages.
		nRet = theLoop.Run();	    
		_Module.RemoveMessageLoop();
	}
	else
	{
		// Silent (non-GUI mode).
		// Run the sender and wait until it exits.
		pSender->Run();
		pSender->WaitForCompletion();
		// Get return status
		nRet = pSender->GetStatus();
	}
    
	// Delete sender object.
	delete pSender;

	// Exit.
    return nRet;
}
Exemple #13
0
void LookupAirfieldDetail(TCHAR *Name, TCHAR *Details) {
  int i;
  TCHAR UName[100];
  TCHAR NameA[100];
  TCHAR NameB[100];
  TCHAR NameC[100];
  TCHAR NameD[100];
  TCHAR TmpName[100];

#ifndef NOLAND_HOME_WP
  bool isHome, isPreferred;
#else
  bool isHome, isPreferred, isLandable;
#endif

  if (!WayPointList) return;

  for(i=NUMRESWP;i<(int)NumberOfWayPoints;i++) {

    #ifndef NOLAND_HOME_WP
      if (((WayPointList[i].Flags & AIRPORT) == AIRPORT) || ((WayPointList[i].Flags & LANDPOINT) == LANDPOINT)) { 
    #endif

	_tcscpy(UName, WayPointList[i].Name);

	CharUpper(UName); // WP name
	CharUpper(Name);  // AIR name  If airfields name was not uppercase it was not recon

	_stprintf(NameA,TEXT("%s A/F"),Name);
	_stprintf(NameB,TEXT("%s AF"),Name);
	_stprintf(NameC,TEXT("%s A/D"),Name);
	_stprintf(NameD,TEXT("%s AD"),Name);

	isHome=false;
	isPreferred=false;
    #ifdef NOLAND_HOME_WP
      isLandable = (((WayPointList[i].Flags & AIRPORT) == AIRPORT) || 
                   ((WayPointList[i].Flags & LANDPOINT) == LANDPOINT));
    #endif

	_stprintf(TmpName,TEXT("%s=HOME"),UName);
	if ( (_tcscmp(Name, TmpName)==0) )  isHome=true;

  #ifdef NOLAND_HOME_WP
  // Only bother checking whether it's preferred if it's landable.
  if (isLandable) {
  #endif
	_stprintf(TmpName,TEXT("%s=PREF"),UName);
	if ( (_tcscmp(Name, TmpName)==0) )  isPreferred=true;
	_stprintf(TmpName,TEXT("%s=PREFERRED"),UName);
	if ( (_tcscmp(Name, TmpName)==0) )  isPreferred=true;
  #ifdef NOLAND_HOME_WP
  }
  #endif

	if ( isHome==true ) {
    #ifdef NOLAND_HOME_WP
    if (isLandable)
    #endif
	  WayPointCalc[i].Preferred = true;
	  HomeWaypoint = i;
	  AirfieldsHomeWaypoint = i; // make it survive a reset..
	}
	if ( isPreferred==true ) {
	  WayPointCalc[i].Preferred = true;
	}

	if ((_tcscmp(UName, Name)==0)
	    ||(_tcscmp(UName, NameA)==0)
	    ||(_tcscmp(UName, NameB)==0)
	    ||(_tcscmp(UName, NameC)==0)
	    ||(_tcscmp(UName, NameD)==0)
	    || isHome || isPreferred )
	  {
	    if (_tcslen(Details) >0 ) { // avoid setting empty details
	      if (WayPointList[i].Details) {
		free(WayPointList[i].Details);
	      }
	      WayPointList[i].Details = (TCHAR*)malloc((_tcslen(Details)+1)*sizeof(TCHAR));
	      if (WayPointList[i].Details != NULL) _tcscpy(WayPointList[i].Details, Details);
	    } 
	    return;
	  }

    #ifndef NOLAND_HOME_WP // end of "if airport or landpoint" block
      }
    #endif

    }
}
Exemple #14
0
bool
TaskStore::Item::operator<(const Item &other) const
{
  return _tcscmp(GetName(), other.GetName()) < 0;
}
Exemple #15
0
static void parse_cmdline (int argc, TCHAR **argv)
{
	int i;
	bool firstconfig = true;

	for (i = 1; i < argc; i++) {
		if (!_tcsncmp (argv[i], _T("-diskswapper="), 13)) {
			TCHAR *txt = parsetextpath (argv[i] + 13);
			parse_diskswapper (txt);
			xfree (txt);
		} else if (_tcsncmp (argv[i], _T("-cfgparam="), 10) == 0) {
			;
		} else if (_tcscmp (argv[i], _T("-cfgparam")) == 0) {
			if (i + 1 < argc)
				i++;
		} else if (_tcsncmp (argv[i], _T("-config="), 8) == 0) {
			TCHAR *txt = parsetextpath (argv[i] + 8);
			currprefs.mountitems = 0;
			target_cfgfile_load (&currprefs, txt, firstconfig ? CONFIG_TYPE_ALL : CONFIG_TYPE_HARDWARE | CONFIG_TYPE_HOST | CONFIG_TYPE_NORESET, 0);
			xfree (txt);
			firstconfig = false;
		} else if (_tcsncmp (argv[i], _T("-statefile="), 11) == 0) {
			TCHAR *txt = parsetextpath (argv[i] + 11);
			savestate_state = STATE_DORESTORE;
			_tcscpy (savestate_fname, txt);
			xfree (txt);
		} else if (_tcscmp (argv[i], _T("-f")) == 0) {
			/* Check for new-style "-f xxx" argument, where xxx is config-file */
			if (i + 1 == argc) {
				write_log (_T("Missing argument for '-f' option.\n"));
			} else {
				TCHAR *txt = parsetextpath (argv[++i]);
				currprefs.mountitems = 0;
				target_cfgfile_load (&currprefs, txt, firstconfig ? CONFIG_TYPE_ALL : CONFIG_TYPE_HARDWARE | CONFIG_TYPE_HOST | CONFIG_TYPE_NORESET, 0);
				xfree (txt);
				firstconfig = false;
			}
		} else if (_tcscmp (argv[i], _T("-s")) == 0) {
			if (i + 1 == argc)
				write_log (_T("Missing argument for '-s' option.\n"));
			else
				cfgfile_parse_line (&currprefs, argv[++i], 0);
		} else if (_tcscmp (argv[i], _T("-h")) == 0 || _tcscmp (argv[i], _T("-help")) == 0) {
			usage ();
			exit (0);
		} else if (_tcsncmp (argv[i], _T("-cdimage="), 9) == 0) {
			TCHAR *txt = parsetextpath (argv[i] + 9);
			TCHAR *txt2 = xmalloc(TCHAR, _tcslen(txt) + 2);
			_tcscpy(txt2, txt);
			if (_tcsrchr(txt2, ',') != NULL)
				_tcscat(txt2, _T(","));
			cfgfile_parse_option (&currprefs, _T("cdimage0"), txt2, 0);
			xfree(txt2);
			xfree (txt);
		} else {
			if (argv[i][0] == '-' && argv[i][1] != '\0') {
				const TCHAR *arg = argv[i] + 2;
				int extra_arg = *arg == '\0';
				if (extra_arg)
					arg = i + 1 < argc ? argv[i + 1] : 0;
				if (parse_cmdline_option (&currprefs, argv[i][1], arg) && extra_arg)
					i++;
			}
		}
	}
}
	LPVOID CVerticalLayoutUI::GetInterface(LPCTSTR pstrName)
	{
		if( _tcscmp(pstrName, DUI_CTR_VERTICALLAYOUT) == 0 ) return static_cast<CVerticalLayoutUI*>(this);
		return CContainerUI::GetInterface(pstrName);
	}
Exemple #17
0
LPVOID SearchLayout::GetInterface(LPCTSTR pstrName)
{
	if (_tcscmp(pstrName, _T("SearchLayout")) == 0) return static_cast<SearchLayout*>(this);
	return __super::GetInterface(pstrName);
}
	void CVerticalLayoutUI::SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue)
	{
		if( _tcscmp(pstrName, _T("sepheight")) == 0 ) SetSepHeight(_ttoi(pstrValue));
		else if( _tcscmp(pstrName, _T("sepimm")) == 0 ) SetSepImmMode(_tcscmp(pstrValue, _T("true")) == 0);
		else CContainerUI::SetAttribute(pstrName, pstrValue);
	}
Exemple #19
0
static DWORD
DeleteFiles(LPTSTR FileName, DWORD* dwFlags, DWORD dwAttrFlags)
{
        TCHAR szFullPath[MAX_PATH];
        TCHAR szFileName[MAX_PATH];
        LPTSTR pFilePart;
        HANDLE hFile;
        WIN32_FIND_DATA f;
        BOOL bExclusion;
        INT res;
        DWORD dwFiles = 0;

        _tcscpy(szFileName, FileName);

        if(_tcschr (szFileName, _T('*')) == NULL &&
	   IsExistingDirectory (szFileName))
        {
	        /* If it doesnt have a \ at the end already then on needs to be added */
		if(szFileName[_tcslen(szFileName) -  1] != _T('\\'))
                        _tcscat (szFileName, _T("\\"));
                /* Add a wildcard after the \ */
                _tcscat (szFileName, _T("*"));
        }

	if(!_tcscmp (szFileName, _T("*")) ||
           !_tcscmp (szFileName, _T("*.*")) ||
           (szFileName[_tcslen(szFileName) -  2] == _T('\\') && szFileName[_tcslen(szFileName) -  1] == _T('*')))
        {
                /* well, the user wants to delete everything but if they didnt yes DEL_YES, DEL_QUIET, or DEL_PROMPT
	           then we are going to want to make sure that in fact they want to do that.  */

		if (!((*dwFlags & DEL_YES) || (*dwFlags & DEL_QUIET) || (*dwFlags & DEL_PROMPT)))
	        {
        	        res = FilePromptYNA (STRING_DEL_HELP2);
		        if ((res == PROMPT_NO) || (res == PROMPT_BREAK))
			        return 0x80000000;
		        if(res == PROMPT_ALL)
			        *dwFlags |= DEL_YES;
	        }
	}

        GetFullPathName (szFileName,
                         MAX_PATH,
                         szFullPath,
                         &pFilePart);

        hFile = FindFirstFile(szFullPath, &f);
        if (hFile != INVALID_HANDLE_VALUE)
        {
                do
                {
					bExclusion = FALSE;

					/*if it is going to be excluded by - no need to check attrs*/
					if(*dwFlags & DEL_ATTRIBUTES && !bExclusion)
					{

						/*save if file attr check if user doesnt care about that attr anyways*/
					 if(dwAttrFlags & ATTR_ARCHIVE && !(f.dwFileAttributes & FILE_ATTRIBUTE_ARCHIVE))
				        bExclusion = TRUE;
					 if(dwAttrFlags & ATTR_HIDDEN && !(f.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN))
				        bExclusion = TRUE;
					 if(dwAttrFlags & ATTR_SYSTEM && !(f.dwFileAttributes & FILE_ATTRIBUTE_SYSTEM))
				        bExclusion = TRUE;
					 if(dwAttrFlags & ATTR_READ_ONLY && !(f.dwFileAttributes & FILE_ATTRIBUTE_READONLY))
			            bExclusion = TRUE;
		             if(dwAttrFlags & ATTR_N_ARCHIVE && (f.dwFileAttributes & FILE_ATTRIBUTE_ARCHIVE))
			            bExclusion = TRUE;
		             if(dwAttrFlags & ATTR_N_HIDDEN && (f.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN))
			            bExclusion = TRUE;
		             if(dwAttrFlags & ATTR_N_SYSTEM && (f.dwFileAttributes & FILE_ATTRIBUTE_SYSTEM))
			            bExclusion = TRUE;
		             if(dwAttrFlags & ATTR_N_READ_ONLY && (f.dwFileAttributes & FILE_ATTRIBUTE_READONLY))
			            bExclusion = TRUE;
					}
					if(bExclusion)
						continue;

					/* ignore directories */
					if (f.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
		                continue;


					_tcscpy (pFilePart, f.cFileName);

					/* We cant delete ourselves */
					if(!_tcscmp (CMDPath,szFullPath))
						continue;


					TRACE("Full filename: %s\n", debugstr_aw(szFullPath));

					/* ask for deleting */
					if (*dwFlags & DEL_PROMPT)
					{
		                ConErrResPrintf(STRING_DEL_ERROR5, szFullPath);

		                res = FilePromptYN (STRING_DEL_ERROR6);

		                if ((res == PROMPT_NO) || (res == PROMPT_BREAK))
		                {
								 nErrorLevel = 0;
			                continue;
		                }
	                }

	                /*user cant ask it to be quiet and tell you what it did*/
	                if (!(*dwFlags & DEL_QUIET) && !(*dwFlags & DEL_TOTAL))
	                {
		                ConErrResPrintf(STRING_DEL_ERROR7, szFullPath);
	                }

	                /* delete the file */
	                if(*dwFlags & DEL_NOTHING)
		                continue;

	                if(RemoveFile (szFullPath, *dwFlags, &f))
		                dwFiles++;
					else
                        {
							ErrorMessage (GetLastError(), _T(""));
//                                FindClose(hFile);
//                                return -1;
						}
                }
                while (FindNextFile (hFile, &f));
				FindClose (hFile);
        }
		else error_sfile_not_found(szFullPath);
        return dwFiles;
}
BOOL CJabberMessageManager::HandleMessagePermanent(HXML node, ThreadData *pThreadData)
{
	BOOL bStopHandling = FALSE;
	Lock();
	CJabberMessagePermanentInfo *pInfo = m_pPermanentHandlers;
	while ( pInfo && !bStopHandling ) {
	// have to get all data here, in the loop, because there's always possibility that previous handler modified it
		CJabberMessageInfo messageInfo;

		LPCTSTR szType = xmlGetAttrValue(node, _T("type"));
		if ( szType )
		{
			if ( !_tcsicmp( szType, _T("normal")))
				messageInfo.m_nMessageType = JABBER_MESSAGE_TYPE_NORMAL;
			else if ( !_tcsicmp( szType, _T("error")))
				messageInfo.m_nMessageType = JABBER_MESSAGE_TYPE_ERROR;
			else if ( !_tcsicmp( szType, _T("chat")))
				messageInfo.m_nMessageType = JABBER_MESSAGE_TYPE_CHAT;
			else if ( !_tcsicmp( szType, _T("groupchat")))
				messageInfo.m_nMessageType = JABBER_MESSAGE_TYPE_GROUPCHAT;
			else if ( !_tcsicmp( szType, _T("headline")))
				messageInfo.m_nMessageType = JABBER_MESSAGE_TYPE_HEADLINE;
			else
				break; // m_nMessageType = JABBER_MESSAGE_TYPE_FAIL;
		}
		else {
			messageInfo.m_nMessageType = JABBER_MESSAGE_TYPE_NORMAL;
		}

		if ( (pInfo->m_nMessageTypes & messageInfo.m_nMessageType )) {
			int i;
			for ( i = xmlGetChildCount( node ) - 1; i >= 0; i-- ) {
			// enumerate all children and see whether this node suits handler criteria
				HXML child = xmlGetChild( node, i );
				
				LPCTSTR szTagName = xmlGetName(child);
				LPCTSTR szXmlns = xmlGetAttrValue( child, _T("xmlns"));

				if ( (!pInfo->m_szXmlns || ( szXmlns && !_tcscmp( pInfo->m_szXmlns, szXmlns ))) &&
				( !pInfo->m_szTag || !_tcscmp( pInfo->m_szTag, szTagName ))) {
				// node suits handler criteria, call the handler
					messageInfo.m_hChildNode = child;
					messageInfo.m_szChildTagName = szTagName;
					messageInfo.m_szChildTagXmlns = szXmlns;
					messageInfo.m_pUserData = pInfo->m_pUserData;
					messageInfo.m_szFrom = xmlGetAttrValue( node, _T("from")); // is necessary for ppro->Log() below, that's why we must parse it even if JABBER_MESSAGE_PARSE_FROM flag is not set

					if (pInfo->m_dwParamsToParse & JABBER_MESSAGE_PARSE_ID_STR)
						messageInfo.m_szId = xmlGetAttrValue( node, _T("id"));

					if (pInfo->m_dwParamsToParse & JABBER_IQ_PARSE_TO)
						messageInfo.m_szTo = xmlGetAttrValue( node, _T("to"));

					if (pInfo->m_dwParamsToParse & JABBER_MESSAGE_PARSE_HCONTACT)
						messageInfo.m_hContact = ppro->HContactFromJID( messageInfo.m_szFrom, 3 );

					if (messageInfo.m_szFrom)
						ppro->Log( "Handling message from " TCHAR_STR_PARAM, messageInfo.m_szFrom );
					if ((ppro->*(pInfo->m_pHandler))(node, pThreadData, &messageInfo)) {
						bStopHandling = TRUE;
						break;
					}
				}
			}
		}
		pInfo = pInfo->m_pNext;
	}
	Unlock();

	return bStopHandling;
}
Exemple #21
0
oodControl_t winName2controlType(const rxcharT *className)
{
    if (      _tcscmp(className, WC_STATIC         ) == 0 ) return winStatic;
    else if ( _tcscmp(className, WC_BUTTON         ) == 0 ) return winPushButton;
    else if ( _tcscmp(className, WC_EDIT           ) == 0 ) return winEdit;
    else if ( _tcscmp(className, WC_LISTBOX        ) == 0 ) return winListBox;
    else if ( _tcscmp(className, WC_COMBOBOX       ) == 0 ) return winComboBox;
    else if ( _tcscmp(className, WC_SCROLLBAR      ) == 0 ) return winScrollBar;
    else if ( _tcscmp(className, WC_TREEVIEW       ) == 0 ) return winTreeView;
    else if ( _tcscmp(className, WC_LISTVIEW       ) == 0 ) return winListView;
    else if ( _tcscmp(className, WC_TABCONTROL     ) == 0 ) return winTab;
    else if ( _tcscmp(className, PROGRESS_CLASS    ) == 0 ) return winProgressBar;
    else if ( _tcscmp(className, TRACKBAR_CLASS    ) == 0 ) return winTrackBar;
    else if ( _tcscmp(className, MONTHCAL_CLASS    ) == 0 ) return winMonthCalendar;
    else if ( _tcscmp(className, DATETIMEPICK_CLASS) == 0 ) return winDateTimePicker;
    else if ( _tcscmp(className, UPDOWN_CLASS      ) == 0 ) return winUpDown;
    else
    {
        return winUnknown;
    }
}
Exemple #22
0
void PreloadInitialisation(bool ask) {
  LKLanguageReady=false;
  LKReadLanguageFile();
  FillDataOptions(); // Load infobox list

  if (ask) {
    // Load default profile and status file: we are at an early stage
    LKProfileResetDefault();
    LKProfileLoad(startAircraftFile);
    LKProfileLoad(startPilotFile);
    LKProfileLoad(startDeviceFile);
    // if DEFAULT PROFILE does not exist, initialize ResetDefaults!
    // This is because LKProfileLoad will do this at its end, normally.
    // Notice: aircraft and pilot files will not be overridden by defaults
    if (!LKProfileLoad(startProfileFile)) {
	LKProfileInitRuntime();
    }

    StatusFileInit();
  } else {
    // We are in the dialog startup phase
    FullScreen();
    short retstartup;
    do {
	retstartup=dlgStartupShowModal();
    } while (retstartup>0);

    if (retstartup<0) return;

    if (_tcscmp(startProfileFile,_T("PROFILE_RESET"))==0) {
	StartupStore(_T(". USER ASKED FOR PROFILE FULL RESET!%s"),NEWLINE);
	DoStatusMessage(gettext(_T("[email protected]_"))); // LK8000 PROFILES RESET
	LKProfileResetDefault();
	LKProfileInitRuntime();
	// Notice: this is also resetting the default Aircraft and Pilot profiles to demo settings
    } else  {
	if (!LKProfileLoad(startPilotFile)) {
		#if TESTBENCH
		StartupStore(_T(". PilotFile RESET to defaults%s"),NEWLINE);
		#endif
	}
	if (!LKProfileLoad(startDeviceFile)) {
		#if TESTBENCH
		StartupStore(_T(". DeviceFile RESET to defaults%s"),NEWLINE);
		#endif
	}
	if (!LKProfileLoad(startAircraftFile)) {
		#if TESTBENCH
		StartupStore(_T(". AircraftFile RESET to defaults%s"),NEWLINE);
		#endif
	}
	LKProfileLoad(startProfileFile); // this is calling adjust and InitRuntime itself
    }
    LKSW_ReloadProfileBitmaps=true;

    // LKTOKEN [email protected]_ "Initialising..."
	CreateProgressDialog(gettext(TEXT("[email protected]_"))); 
  }

  // Interface (before interface)
  if (!ask) {
    LKReadLanguageFile();
    InputEvents::readFile();
  }

}
Exemple #23
0
BOOL CFileLogger::CheckLogFile()
{
	if (!m_pOptions->GetOptionVal(OPTION_ENABLELOGGING))
	{
		if (m_hLogFile != INVALID_HANDLE_VALUE)
		{
			CloseHandle(m_hLogFile);
			m_hLogFile = INVALID_HANDLE_VALUE;
		}
		return TRUE;
	}

	//Get logfile path
	TCHAR path[MAX_PATH + 1000]; //Make it large enough
	GetModuleFileName( 0, path, MAX_PATH );
	LPTSTR pos=_tcsrchr(path, '\\');
	if (pos)
		*++pos=0;
	_tcscat(path, _T("Logs\\"));
	
	//Get logfile name
	_int64 nLogType = m_pOptions->GetOptionVal(OPTION_LOGTYPE);		
	TCHAR filename[MAX_PATH + 1];
	if (!nLogType)
	{
		_tcscpy(filename, _T("FileZilla Server.log"));
	}
	else
	{
		SYSTEMTIME time;
		GetSystemTime(&time);
		_stprintf(filename, _T("fzs-%d-%02d-%02d.log"), time.wYear, time.wMonth, time.wDay);
	}

	if (m_hLogFile == INVALID_HANDLE_VALUE || (m_pFileName && _tcscmp(m_pFileName, filename)))
	{
		TCHAR buffer[MAX_PATH + 1000]; //Make it large enough
		_tcscpy(buffer, path);
		CreateDirectory(buffer, NULL);

		if (m_pFileName)
			delete [] m_pFileName;
		m_pFileName = new TCHAR[_tcslen(filename)+1];
		_tcscpy(m_pFileName, filename);	
		_tcscat(buffer, filename);
		
		if (m_hLogFile != INVALID_HANDLE_VALUE)
			CloseHandle(m_hLogFile);
		m_hLogFile = CreateFile(buffer, GENERIC_WRITE|GENERIC_READ, FILE_SHARE_READ, 0, OPEN_ALWAYS, 0, 0);
		if (m_hLogFile == INVALID_HANDLE_VALUE)
			return FALSE;
		
		SetFilePointer(m_hLogFile, 0, 0, FILE_END);
	}
	_int64 nLimit = m_pOptions->GetOptionVal(OPTION_LOGLIMITSIZE);
	
	if (nLogType)
	{
		//Different logfiles for each day
		//Find all log files, delete old ones
		//Also delete newer ones if total size exceeds limit

		//Get current date

		SYSTEMTIME time;
		FILETIME curFileTime;
		GetSystemTime(&time);
		SystemTimeToFileTime(&time, &curFileTime);
		_int64 nTime = curFileTime.dwLowDateTime + ((_int64)curFileTime.dwHighDateTime<<32);
		
		TCHAR buffer[MAX_PATH + 1000]; //Make it large enough
		_tcscpy(buffer, path);
		_tcscat(buffer, _T("fzs-*.log"));

		WIN32_FIND_DATA FindFileData;
		WIN32_FIND_DATA NextFindFileData;
		HANDLE hFind;
		hFind = FindFirstFile(buffer, &NextFindFileData);
		
		_int64 nDeleteTime = (_int64)m_pOptions->GetOptionVal(OPTION_LOGDELETETIME);
		if (nDeleteTime)
			nDeleteTime = (nDeleteTime+1) * 60 * 60 * 24 * 10000000;

		//Count total size of all logs, delete the oldest log if exceeding limit
		_int64 totalsize = 0;
		CStdString oldestname;
		_int64 oldestDate = 0;
		
		while (hFind != INVALID_HANDLE_VALUE)
		{
			FindFileData=NextFindFileData;
			if (!FindNextFile(hFind, &NextFindFileData))
			{
				FindClose(hFind);
				hFind = INVALID_HANDLE_VALUE;
			}

			if (!_tcscmp(FindFileData.cFileName, _T(".")) || !_tcscmp(FindFileData.cFileName, _T("..")))
				continue;

			_int64 size = ((_int64)FindFileData.nFileSizeHigh<<32) + FindFileData.nFileSizeLow;
			if (!_tcscmp(FindFileData.cFileName, m_pFileName))
			{
				totalsize += size;
				continue;
			}

			_int64 curtime=FindFileData.ftLastWriteTime.dwLowDateTime + ((_int64)FindFileData.ftLastWriteTime.dwHighDateTime<<32);
			_int64 span = nTime - curtime;
			TCHAR filename[MAX_PATH + 1000];
			_tcscpy(filename, path);
			_tcscat(filename, FindFileData.cFileName);
			if (nDeleteTime && span > nDeleteTime)
				DeleteFile(filename); //File is too old, delete it
			else
			{
				totalsize += size;
				if (curtime < oldestDate || !oldestDate)
				{
					oldestDate = curtime;
					oldestname = filename;
				}
			}
		}
		
		if (_tcscmp(oldestname, "") && nLimit && totalsize > nLimit*1024)
		{
			DeleteFile(oldestname);
			return TRUE;
		}
	}

	//Single logfile, check size...
	if (nLimit)
	{
		_int64 size = GetPosition64(m_hLogFile);
		size /= 1024;
		if (size > nLimit) //Log file too large, shrink it...
		{
			int curReadPos = (int)(size * 1024 - (nLimit * 1024) * 0.9); //New log size is 10% smaller than the set limit
			int curWritePos =0;
			const int bufsize = 16384; // 16KB
			char buffer[bufsize];
			DWORD numread;
			DWORD numwritten;
			BOOL bFirst = TRUE;;
			do {
				SetFilePointer(m_hLogFile, curReadPos, 0, FILE_BEGIN);
				if (!ReadFile(m_hLogFile, buffer, bufsize, &numread, 0))
					break;
				curReadPos += numread;
				
				SetFilePointer(m_hLogFile, curWritePos, 0, FILE_BEGIN);
				if (bFirst) //Assure log starts with complete line
				{
					unsigned int i;
					for (i=0; i<numread; i++)
					{
						if (buffer[i] == '\n')
							break;
					}
					if (i >= (numread-1))
						continue;
					bFirst = FALSE;
					if (!WriteFile(m_hLogFile, buffer + i + 1, numread - i - 1, &numwritten, 0))
						break;
				}
				else
					if (!WriteFile(m_hLogFile, buffer, numread, &numwritten, 0))
						break;
					curWritePos += numwritten;
					
			} while (numread == bufsize);
			
			SetFilePointer(m_hLogFile, curWritePos, 0, FILE_BEGIN);
			SetEndOfFile(m_hLogFile);
		}
	}
	return TRUE;
}
Exemple #24
0
int getopt(int argc, TCHAR *argv[], TCHAR *optstring)
{
	static TCHAR *next = NULL;
	if (optind == 0)
		next = NULL;

	optarg = NULL;

	if (next == NULL || *next == _T('\0'))
	{
		if (optind == 0)
			optind++;

		if (optind >= argc || argv[optind][0] != _T('-') || argv[optind][1] == _T('\0'))
		{
			optarg = NULL;
			if (optind < argc)
				optarg = argv[optind];
			return EOF;
		}

		if (_tcscmp(argv[optind], _T("--")) == 0)
		{
			optind++;
			optarg = NULL;
			if (optind < argc)
				optarg = argv[optind];
			return EOF;
		}

		next = argv[optind];
		next++;		// skip past -
		optind++;
	}

	TCHAR c = *next++;
	TCHAR *cp = _tcschr(optstring, c);

	if (cp == NULL || c == _T(':'))
		return _T('?');

	cp++;
	if (*cp == _T(':'))
	{
		if (*next != _T('\0'))
		{
			optarg = next;
			next = NULL;
		}
		else if (optind < argc)
		{
			optarg = argv[optind];
			optind++;
		}
		else
		{
			return _T('?');
		}
	}

	return c;
}
Exemple #25
0
	void CButtonUI::SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue)
	{
		if( _tcscmp(pstrName, _T("normalimage")) == 0 ) SetNormalImage(pstrValue);
		else if( _tcscmp(pstrName, _T("hotimage")) == 0 ) SetHotImage(pstrValue);
		else if( _tcscmp(pstrName, _T("pushedimage")) == 0 ) SetPushedImage(pstrValue);
		else if( _tcscmp(pstrName, _T("focusedimage")) == 0 ) SetFocusedImage(pstrValue);
		else if( _tcscmp(pstrName, _T("disabledimage")) == 0 ) SetDisabledImage(pstrValue);
		else if( _tcscmp(pstrName, _T("foreimage")) == 0 ) SetForeImage(pstrValue);
		else if( _tcscmp(pstrName, _T("hotforeimage")) == 0 ) SetHotForeImage(pstrValue);
		else if( _tcscmp(pstrName, _T("hotbkcolor")) == 0 )
		{
			if( *pstrValue == _T('#')) pstrValue = ::CharNext(pstrValue);
			LPTSTR pstr = NULL;
			DWORD clrColor = _tcstoul(pstrValue, &pstr, 16);
			SetHotBkColor(clrColor);
		}
		else if( _tcscmp(pstrName, _T("hottextcolor")) == 0 )
		{
			if( *pstrValue == _T('#')) pstrValue = ::CharNext(pstrValue);
			LPTSTR pstr = NULL;
			DWORD clrColor = _tcstoul(pstrValue, &pstr, 16);
			SetHotTextColor(clrColor);
		}
		else if( _tcscmp(pstrName, _T("pushedtextcolor")) == 0 )
		{
			if( *pstrValue == _T('#')) pstrValue = ::CharNext(pstrValue);
			LPTSTR pstr = NULL;
			DWORD clrColor = _tcstoul(pstrValue, &pstr, 16);
			SetPushedTextColor(clrColor);
		}
		else if( _tcscmp(pstrName, _T("focusedtextcolor")) == 0 )
		{
			if( *pstrValue == _T('#')) pstrValue = ::CharNext(pstrValue);
			LPTSTR pstr = NULL;
			DWORD clrColor = _tcstoul(pstrValue, &pstr, 16);
			SetFocusedTextColor(clrColor);
		}
		else CLabelUI::SetAttribute(pstrName, pstrValue);
	}
static void InitJoystick(joystick_type *joystick)
{
	LPDIRECTINPUTDEVICE didTemp;
	HRESULT hr;
	LPDIRECTINPUT di = GetDirectInput();

	joystick->use_joystick = FALSE;

	joystick->did	   = NULL;
	joystick->num_axes = 0;

	joystick->is_light_gun = (_tcscmp(joystick->name, TEXT("ACT LABS GS (ACT LABS GS)")) == 0);

	/* get a did1 interface first... */
	hr = IDirectInput_CreateDevice(di, joystick->guidDevice, &didTemp, NULL);
	if (FAILED(hr))
	{
		ErrorMsg("DirectInput CreateDevice() joystick failed: %s\n", DirectXDecodeError(hr));
		return;
	}

	/* get a did2 interface to work with polling (most) joysticks */
	hr = IDirectInputDevice_QueryInterface(didTemp,
										   IID_IDirectInputDevice2,
										   (void**)&joystick->did);

	/* dispose of the temp interface */
	IDirectInputDevice_Release(didTemp);

	/* check result of getting the did2 */
	if (FAILED(hr))
	{
		/* no error message because this happens in dx3 */
		/* ErrorMsg("DirectInput QueryInterface joystick failed\n"); */
		joystick->did = NULL;
		return;
	}


	hr = IDirectInputDevice2_SetCooperativeLevel(joystick->did, GetMainWindow(),
												 DISCL_NONEXCLUSIVE | DISCL_BACKGROUND);
	if (FAILED(hr))
	{
		ErrorMsg("DirectInput SetCooperativeLevel() joystick failed: %s\n", DirectXDecodeError(hr));
		return;
	}


	hr = IDirectInputDevice2_SetDataFormat(joystick->did, &c_dfDIJoystick);
	if (FAILED(hr))
	{
		ErrorMsg("DirectInput SetDataFormat() joystick failed: %s\n", DirectXDecodeError(hr));
		return;
	}

	if (joystick->is_light_gun)
	{
		/* setup light gun to report raw screen pixel data */

		DIPROPDWORD diprop;
		memset(&diprop, 0, sizeof(diprop));
		diprop.diph.dwSize		 = sizeof(DIPROPDWORD);
		diprop.diph.dwHeaderSize = sizeof(DIPROPHEADER);
		diprop.diph.dwObj		 = 0;
		diprop.diph.dwHow		 = DIPH_DEVICE;
		diprop.dwData			 = DIPROPCALIBRATIONMODE_RAW;

		IDirectInputDevice2_SetProperty(joystick->did, DIPROP_CALIBRATIONMODE, &diprop.diph);
	}
	else
	{
		/* enumerate our axes */
		hr = IDirectInputDevice_EnumObjects(joystick->did,
											DIJoystick_EnumAxisObjectsProc,
											joystick,
											DIDFT_AXIS);
		if (FAILED(hr))
		{
			ErrorMsg("DirectInput EnumObjects() Axes failed: %s\n", DirectXDecodeError(hr));
			return;
		}

		/* enumerate our POV hats */
		joystick->num_pov = 0;
		hr = IDirectInputDevice_EnumObjects(joystick->did,
											DIJoystick_EnumPOVObjectsProc,
											joystick,
											DIDFT_POV);
		if (FAILED(hr))
		{
			ErrorMsg("DirectInput EnumObjects() POVs failed: %s\n", DirectXDecodeError(hr));
			return;
		}
	}

	/* enumerate our buttons */

	joystick->num_buttons = 0;
	hr = IDirectInputDevice_EnumObjects(joystick->did,
										DIJoystick_EnumButtonObjectsProc,
										joystick,
										DIDFT_BUTTON);
	if (FAILED(hr))
	{
		ErrorMsg("DirectInput EnumObjects() Buttons failed: %s\n", DirectXDecodeError(hr));
		return;
	}

	hr = IDirectInputDevice2_Acquire(joystick->did);
	if (FAILED(hr))
	{
		ErrorMsg("DirectInputDevice Acquire joystick failed!\n");
		return;
	}

	/* start by clearing the structures */

	ClearJoyState(&joystick->dijs);

	joystick->use_joystick = TRUE;
}
Exemple #27
0
LPVOID CShortcutEditUI::GetInterface(LPCTSTR pstrName)
{
	if( _tcscmp(pstrName, DUI_CTR_PATH_EDIT) == 0 ) return static_cast<CShortcutEditUI*>(this);
	return CLabelUI::GetInterface(pstrName);
}
int CShellCommandSetValue::Execute(CConsole &rConsole, CArgumentParser& rArguments)
{
  LONG nError;

	rArguments.ResetArgumentIteration();
	TCHAR *pszCommandItself = rArguments.GetNextArgument();

	TCHAR *pszParameter;
	TCHAR *pszValueFull = NULL;
	TCHAR *pszValueData = NULL;
	BOOL blnBadParameter = FALSE;
	BOOL blnHelp = FALSE;
	DWORD dwValueSize = 0;
	DWORD dwType = REG_NONE;
	BYTE *pDataBuffer = NULL;

	if ((_tcsnicmp(pszCommandItself,SET_VALUE_CMD _T(".."),SET_VALUE_CMD_LENGTH+2*sizeof(TCHAR)) == 0)||
		(_tcsnicmp(pszCommandItself,SET_VALUE_CMD _T("\\"),SET_VALUE_CMD_LENGTH+1*sizeof(TCHAR)) == 0))
	{
		pszValueFull = pszCommandItself + SET_VALUE_CMD_LENGTH;
	}
	else if (_tcsnicmp(pszCommandItself,SET_VALUE_CMD _T("/"),SET_VALUE_CMD_LENGTH+1*sizeof(TCHAR)) == 0)
	{
		pszParameter = pszCommandItself + SET_VALUE_CMD_LENGTH;
		goto CheckValueArgument;
	}

	while((pszParameter = rArguments.GetNextArgument()) != NULL)
	{
CheckValueArgument:
		blnBadParameter = FALSE;
		if (((*pszParameter == _T('/'))||(*pszParameter == _T('-')))
			&&(*(pszParameter+1) == _T('?')))
		{
			blnHelp = TRUE;
		}
		else if (dwType == REG_NONE)
		{
			if (_tcsicmp(pszParameter,_T("b")) == 0)
			{
				dwType = REG_BINARY;
			}
			else if (_tcsicmp(pszParameter,_T("dw")) == 0)
			{
				dwType = REG_DWORD;
			}
			else if (_tcsicmp(pszParameter,_T("dwle")) == 0)
			{
				dwType = REG_DWORD_LITTLE_ENDIAN;
			}
			else if (_tcsicmp(pszParameter,_T("dwbe")) == 0)
			{
				dwType = REG_DWORD_BIG_ENDIAN;
			}
			else if (_tcsicmp(pszParameter,_T("sz")) == 0)
			{
				dwType = REG_SZ;
			}
			else if (_tcsicmp(pszParameter,_T("esz")) == 0)
			{
				dwType = REG_EXPAND_SZ;
			}
			else
			{
				blnBadParameter = TRUE;
			}
		}
		else if (pszValueData == NULL)
		{
			pszValueData = pszParameter;
		}
		else if (!pszValueFull)
		{
			pszValueFull = pszParameter;
		}
		else
		{
			blnBadParameter = TRUE;
		}
		if (blnBadParameter)
		{
			rConsole.Write(_T("Bad parameter: "));
			rConsole.Write(pszParameter);
			rConsole.Write(_T("\n"));
		}
	}

	if (!pszValueData)
		blnHelp = TRUE;

	CRegistryKey Key;
	TCHAR *pszValueName;
	const TCHAR *pszEmpty = _T("");
	const TCHAR *pszPath;

	if (blnHelp)
	{
		rConsole.Write(GetHelpString());

		if (pDataBuffer)
			delete pDataBuffer;

		return 0;
	}

	if (pszValueFull)
	{
		if (_tcscmp(pszValueFull,_T("\\")) == 0)
			goto CommandNAonRoot;

		TCHAR *pchSep = _tcsrchr(pszValueFull,_T('\\'));
		pszValueName = pchSep?(pchSep+1):(pszValueFull);
		pszPath = pchSep?pszValueFull:_T(".");

		//if (_tcsrchr(pszValueName,_T('.')))
		//{
		//	pszValueName = _T("");
		//	pszPath = pszValueFull;
		//}
		//else
		if (pchSep)
			*pchSep = 0;
	}
	else
	{
		pszValueName = (TCHAR*)pszEmpty;
		pszPath = _T(".");
	}

  if (!m_rTree.GetKey(pszPath,KEY_SET_VALUE,Key))
  {
    rConsole.Write(m_rTree.GetLastErrorDescription());
    goto SkipCommand;
  }

	if (Key.IsRoot())
    goto CommandNAonRoot;

  switch (dwType)
  {
  case REG_BINARY:
    {
      HANDLE hFile;
      DWORD dwBytesReaded;
      hFile = CreateFile(pszValueData,GENERIC_READ,FILE_SHARE_READ,NULL,OPEN_EXISTING,0,NULL);
      if (hFile == INVALID_HANDLE_VALUE)
      {
        rConsole.Write(_T("Cannot open file "));
        rConsole.Write(pszValueData);
        rConsole.Write(_T("\n"));
        goto SkipCommand;
      }
      dwValueSize = GetFileSize(hFile,NULL);
      if (dwValueSize == (DWORD)-1)	// ok, that's right, we compare signed with unsigned here.
        // GetFileSize is documented and declared to return DWORD.
        // Error is indicated by checking if return is -1. Design->documentation bug ???
      {
        rConsole.Write(_T("Cannot get size of file "));
        rConsole.Write(pszValueData);
        rConsole.Write(_T("\n"));
        VERIFY(CloseHandle(hFile));
        goto SkipCommand;
      }
      pDataBuffer = new BYTE [dwValueSize];
      if (!pDataBuffer)
      {
        rConsole.Write(_T("Cannot load file into memory. Out of memory.\n"));
        VERIFY(CloseHandle(hFile));
        goto SkipCommand;
      }
      if (!ReadFile(hFile,pDataBuffer,dwValueSize,&dwBytesReaded,NULL))
      {
        rConsole.Write(_T("Cannot load file into memory. Error reading file.\n"));
        VERIFY(CloseHandle(hFile));
        goto SkipCommand;
      }

      VERIFY(CloseHandle(hFile));
      ASSERT(dwBytesReaded == dwValueSize);
    }
    break;
  case REG_DWORD_LITTLE_ENDIAN:
  case REG_DWORD_BIG_ENDIAN:
    dwValueSize = 4;
    pDataBuffer = (BYTE *) new BYTE [dwValueSize];
    if (!StringToDWORD(*(DWORD *)pDataBuffer,pszValueData))
    {
      rConsole.Write(_T("Cannot convert "));
      rConsole.Write(pszValueData);
      rConsole.Write(_T(" to DWORD \n"));
      goto SkipCommand;
    }
    if (dwType == REG_DWORD_BIG_ENDIAN)
    {
      unsigned char nByte;
      nByte = *pDataBuffer;
      *pDataBuffer = *(pDataBuffer+3);
      *(pDataBuffer+3) = nByte;
      nByte = *(pDataBuffer+1);
      *(pDataBuffer+1) = *(pDataBuffer+2);
      *(pDataBuffer+2) = nByte;
    }
    break;
  case REG_SZ:
  case REG_EXPAND_SZ:
    dwValueSize = _tcslen(pszValueData)+1;
    if (*pszValueData == _T('\"'))
    {
      dwValueSize -= 2;
      *(pszValueData+dwValueSize) = 0;
      pszValueData++;
    }
    dwValueSize *= sizeof(TCHAR);
    pDataBuffer = (BYTE *) new BYTE [dwValueSize];

    {
      const TCHAR *pchSrc = pszValueData;
      TCHAR *pchDest = (TCHAR *)pDataBuffer;
      while(*pchSrc)
      {
        if (pchSrc[0] == _T('^'))
        {
          if (pchSrc[1] == _T('a'))
            *pchDest = _T('\a');
          else if (pchSrc[1] == _T('b'))
            *pchDest = _T('\b');
          else if (pchSrc[1] == _T('f'))
            *pchDest = _T('\f');
          else if (pchSrc[1] == _T('n'))
            *pchDest = _T('\n');
          else if (pchSrc[1] == _T('r'))
            *pchDest = _T('\r');
          else if (pchSrc[1] == _T('t'))
            *pchDest = _T('\t');
          else
            *pchDest = pchSrc[1];

          pchSrc +=2;
          pchDest++;
          dwValueSize--;
        }
        else
        {
          *pchDest = *pchSrc;
          pchSrc++;
          pchDest++;
        }
      }
      *pchDest = _T('\0');
    }
    break;
  default:
    ASSERT(FALSE);
  }

  {
    size_t s = _tcslen(pszValueName);
    if (s && (pszValueName[0] == _T('\"'))&&(pszValueName[s-1] == _T('\"')))
    {
      pszValueName[s-1] = 0;
      pszValueName++;
    }
  }

  nError = Key.SetValue(pszValueName,dwType,pDataBuffer,dwValueSize);
  if (nError != ERROR_SUCCESS)
  {
    char Buffer[254];
    _stprintf(Buffer,_T("Cannot set value. Error is %u\n"),(unsigned int)nError);
    rConsole.Write(Buffer);
  }
  else
  {
    InvalidateCompletion();
  }

SkipCommand:
	if (pDataBuffer)
		delete[] pDataBuffer;
	return 0;

CommandNAonRoot:
  rConsole.Write(SET_VALUE_CMD COMMAND_NA_ON_ROOT);
  return 0;
}
UINT _stdcall Relocate_File(
	MSIHANDLE hModule,
	const TCHAR *sDirectoryFrom, // Directory to relocate from
	const TCHAR *sDirectoryTo,   // Directory to relocate to
	const TCHAR *sFile,          // File to relocate
	const TCHAR *sType)          // Type of relocation to do.
{
	UINT uiAnswer = ERROR_SUCCESS;
	TCHAR sFileIn[_MAX_PATH];
	TCHAR sFileOut[_MAX_PATH];
	_tcscpy_s(sFileIn, _MAX_PATH, sDirectoryTo);
	_tcscat_s(sFileIn, _MAX_PATH, sFile);
	_tcscpy_s(sFileOut, _MAX_PATH, sFileIn);
	_tcscat_s(sFileOut, _MAX_PATH, _T(".new"));

	TCHAR sStringIn[_MAX_PATH];
	TCHAR sStringOut[_MAX_PATH];

	// Log the fact that we're relocating a file.
	StartLogStringR(_T("Relocating "));
	AppendLogStringR(sFile);
	AppendLogStringR(_T(" using relocation type "));
	AppendLogStringR(sType);
	uiAnswer = LogStringR(hModule);
	MSI_OK(uiAnswer)

	// Get the strings to look for.
	Relocate_GetSearchString(sStringIn,  sDirectoryFrom, sType);
	Relocate_GetSearchString(sStringOut, sDirectoryTo,   sType);

	if (0 == _tcscmp(sStringIn, _T(""))) {
		return ERROR_INSTALL_FAILURE;
	}

	if (0 == _tcscmp(sStringOut, _T(""))) {
		return ERROR_INSTALL_FAILURE;
	}

	// Open our files.
	FILE *fFileIn;
	FILE *fFileOut;
	errno_t eAnswer = 0;
	eAnswer = _tfopen_s(&fFileIn, sFileIn, _T("rtS"));
	if (eAnswer != 0) {
		return ERROR_INSTALL_FAILURE;
	}
	eAnswer = _tfopen_s(&fFileOut, sFileOut, _T("wt"));
	if (eAnswer != 0) {
		fclose(fFileIn);
		return ERROR_INSTALL_FAILURE;
	}

	// Set up our variables for the relocation.
	TCHAR  sLine[32767];
	TCHAR  sWork1[32767];
	TCHAR  sWork2[32767];
	TCHAR *sLoc   = NULL;
	size_t iStringInLength = _tcslen(sStringIn);
	size_t iStringOutLength = _tcslen(sStringOut);
	int iErrorFlag = 0;
	long lLine = 0;
	// Do the relocation.
	while (!feof(fFileIn)) {

		// Deal with errors. 
		if( _fgetts( sLine, 32766, fFileIn ) == NULL) {
			if (iErrorFlag) {
				fclose(fFileIn);
				fclose(fFileOut);
				::DeleteFile(sFileOut);
				uiAnswer = ERROR_INSTALL_FAILURE;
				break;
			}
			iErrorFlag++;
			continue;
		}

		_tcscpy_s(sWork1, 32766, sLine);
		sLoc = _tcsstr(sWork1, sStringIn);
		while (sLoc) {
			// "Cap" the initial string and copy it to sWork2, then append sStringOut to it.
			*sLoc = _T('\0');
			_tcscpy_s(sWork2, 32766, sWork1);
			_tcscat_s(sWork2, 32766, sStringOut);

			// Append the rest of the line.
			sLoc += iStringInLength;
			_tcscat_s(sWork2, 32766, sLoc);

			// Copy back out of our work area, so that they match.
			_tcscpy_s(sWork1, 32766, sWork2);

			// Advance along the string.
			sLoc -= iStringInLength;
			sLoc += iStringInLength;

			// Try another search.
			sLoc = _tcsstr(sLoc, sStringIn);

			// If we're done, copy to sLine so it can be written out.
			if (!sLoc) {
				_tcscpy_s(sLine, 32766, sWork1);
			}
		}
		
		// Write the line out.
		_fputts(sLine, fFileOut);

		// Check every so often for cancel button.
		lLine++;
		if (0 == (lLine % 100)) {
			uiAnswer = Blip(hModule);
			if (ERROR_SUCCESS != uiAnswer) {
				fclose(fFileIn);
				fclose(fFileOut);
				::DeleteFile(sFileOut);
				return uiAnswer;
			}
		}

	}

	fflush(fFileOut);
	fclose(fFileIn);
	fclose(fFileOut);

	MSI_OK(uiAnswer);

	BOOL bAnswer = TRUE;
	// Check for readonly status on the file.
	DWORD dwAttributes = ::GetFileAttributes(sFileIn);
	if (dwAttributes && FILE_ATTRIBUTE_READONLY) {
		bAnswer = ::SetFileAttributes(sFileIn, dwAttributes && !FILE_ATTRIBUTE_READONLY);
		if (bAnswer == FALSE) { 
			::DeleteFile(sFileOut);
			uiAnswer = ERROR_INSTALL_FAILURE; 
		}
		MSI_OK(uiAnswer)
	}
Exemple #30
0
	LPVOID CTextUI::GetInterface(LPCTSTR pstrName)
	{
		if( _tcscmp(pstrName, DUI_CTR_TEXT) == 0 ) return static_cast<CTextUI*>(this);
		return CLabelUI::GetInterface(pstrName);
	}