Esempio n. 1
0
int dcomperm_main(int argc, char **argv)
{
#ifdef TESTING
    printf("args:\n");
    for (int i = 0; i < argc; i++) {
      printf("#%d: %s\n", i, argv[i]);
    }
    char c = getchar();
#endif

    if (argc < 2) {
        ShowUsage (TEXT("No option specified."));
        return 95;  // error.
    }

    if (_tcscmp (_tcsupr (argv [1]), TEXT("-DA")) == 0)
        HandleDAOption (argc, argv);
    else if (_tcscmp (_tcsupr (argv [1]), TEXT("-DL")) == 0)
        HandleDLOption (argc, argv);
    else if (_tcscmp (_tcsupr (argv [1]), TEXT("-AA")) == 0)
        HandleAAOption (argc, argv);
    else if (_tcscmp (_tcsupr (argv [1]), TEXT("-AL")) == 0)
        HandleALOption (argc, argv);
    else if (_tcscmp (_tcsupr (argv [1]), TEXT("-RUNAS")) == 0)
        HandleRunAsOption (argc, argv);
    else {
        ShowUsage (TEXT("Invalid option specified."));
        return 98;  // error.
    }
    return 0;  // no error.
}
Esempio n. 2
0
bool TNtlmAuth::getSpn(TCHAR* szSpn, size_t dwSpnLen)
{
	TCHAR szFullUserName[128] = _T("");
	ULONG szFullUserNameLen = _countof(szFullUserName);
	if (!GetUserNameEx(NameDnsDomain, szFullUserName, &szFullUserNameLen)) {
		szFullUserName[0] = 0;
		szFullUserNameLen = _countof(szFullUserName);
		GetUserNameEx(NameSamCompatible, szFullUserName, &szFullUserNameLen);
	}

	TCHAR *name = _tcsrchr(szFullUserName, '\\');
	if (name) *name = 0;
	else return false;

	if (szHostName && szHostName[0]) {
		TCHAR *szFullUserNameU = _tcsupr(mir_tstrdup(szFullUserName));
		mir_sntprintf(szSpn, dwSpnLen, _T("xmpp/%s/%s@%s"), szHostName, szFullUserName, szFullUserNameU);
		mir_free(szFullUserNameU);
	}
	else {
		const char* connectHost = info->conn.manualHost[0] ? info->conn.manualHost : info->conn.server;

		unsigned long ip = inet_addr(connectHost);
		PHOSTENT host = (ip == INADDR_NONE) ? NULL : gethostbyaddr((char*)&ip, 4, AF_INET);
		if (host && host->h_name)
			connectHost = host->h_name;

		TCHAR *connectHostT = mir_a2t(connectHost);
		mir_sntprintf(szSpn, dwSpnLen, _T("xmpp/%s@%s"), connectHostT, _tcsupr(szFullUserName));
		mir_free(connectHostT);
	}

	Netlib_Logf(NULL, "SPN: %S", szSpn);
	return true;
}
Esempio n. 3
0
extern "C" void
_tmain (
    int argc,
    TCHAR **argv
    )
{
    if (argc < 2)
        ShowUsage (TEXT("No option specified."));

    if (_tcscmp (_tcsupr (argv [1]), TEXT("-DA")) == 0)
        HandleDAOption (argc, argv); else

    if (_tcscmp (_tcsupr (argv [1]), TEXT("-DL")) == 0)
        HandleDLOption (argc, argv); else

    if (_tcscmp (_tcsupr (argv [1]), TEXT("-AA")) == 0)
        HandleAAOption (argc, argv); else

    if (_tcscmp (_tcsupr (argv [1]), TEXT("-AL")) == 0)
        HandleALOption (argc, argv); else

    if (_tcscmp (_tcsupr (argv [1]), TEXT("-RUNAS")) == 0)
        HandleRunAsOption (argc, argv); else

    ShowUsage (TEXT("Invalid option specified."));
}
Esempio n. 4
0
void
HandleRunAsOption (
    int argc,
    TCHAR **argv
    )
{
    DWORD returnValue = 0;
    HKEY  registryKey;
    TCHAR appid [256];
    TCHAR keyName [256];

    if (argc < 4)
        ShowUsage (TEXT("Invalid number of arguments."));

    if (argv [2][0] == '{')
        wsprintf (appid, TEXT("%s"), argv [2]); else
        wsprintf (appid, TEXT("{%s}"), argv [2]);

    wsprintf (keyName, TEXT("APPID\\%s"), appid);

    returnValue = RegOpenKeyEx (HKEY_CLASSES_ROOT, keyName, 0, KEY_ALL_ACCESS, &registryKey);
    if (returnValue != ERROR_SUCCESS)
        Error (TEXT("ERROR: Cannot open AppID registry key."), returnValue);

    bool try_setting_password = true;  // we will usually do this.
    if (_tcscmp (_tcsupr (argv[3]), TEXT("REMOVE")) == 0) {
      // we were told to remove the RunAs entry.
      try_setting_password = false;
      returnValue = RegDeleteValue(registryKey, TEXT("RunAs"));
      if (returnValue != ERROR_SUCCESS)
          Error (TEXT("ERROR: Cannot remove RunAs registry value."), returnValue);
    } else {
      returnValue = RegSetValueEx (registryKey, TEXT("RunAs"), 0, REG_SZ, (LPBYTE) argv [3], (DWORD)(_tcslen (argv[3]) * sizeof (TCHAR)));
      if (returnValue != ERROR_SUCCESS)
          Error (TEXT("ERROR: Cannot set RunAs registry value."), returnValue);
    }

    RegCloseKey (registryKey);

    if (try_setting_password && (_tcscmp (_tcsupr (argv[3]), TEXT("INTERACTIVE USER")) != 0) )
    {
        if (argc < 5)
            ShowUsage (TEXT("Invalid number of arguments."));

        returnValue = SetRunAsPassword (argv[2], argv[3], argv[4]);
        if (returnValue != ERROR_SUCCESS)
            Error (TEXT("ERROR: Cannot set RunAs password."), returnValue);
    }
}
Esempio n. 5
0
DWORD CXMemMapFile::CreateMappingName(LPCTSTR lpszName, 
									  LPTSTR lpszMappingName, 
									  DWORD dwSize, 
									  BOOL bNamed)
{
	TRACE(_T("in CXMemMapFile::CreateMappingName\n"));

	_ASSERTE(lpszName && (lpszName[0] != _T('\0')));
	if (!lpszName || (lpszName[0] == _T('\0')))
		return 0;

	_ASSERTE(lpszMappingName);
	_ASSERTE(dwSize > 2);
	if (!lpszMappingName || (dwSize <= 2))
		return 0;

	ZeroMemory(lpszMappingName, dwSize*sizeof(TCHAR));

	if (bNamed)
	{
		_tcsncpy(lpszMappingName, lpszName, dwSize-1);

		// Replace all '\' by '_'
		for (size_t i = 0; i < _tcslen(lpszName); i++)
		{
			if (lpszMappingName[i] == _T('\\'))
				lpszMappingName[i] = _T('_');
		}
		_tcsupr(lpszMappingName);
	}

	return _tcslen(lpszMappingName);
}
Esempio n. 6
0
void dlgTextEntryKeyboardShowModal(TCHAR *text, int width, const TCHAR* szFile, const TCHAR* szResource)
{
	first = true;
  wf = NULL;
  if (width==0) {
    width = MAX_TEXTENTRY;
  }
  max_width = min(MAX_TEXTENTRY, width);
  char filename[MAX_PATH];
    LocalPathS(filename, szFile);
    wf = dlgLoadFromXML(CallBackTable, 
			filename, 
			hWndMainWindow,			  
			szResource);
  if (!wf) return;

  cursor = 0;
  ClearText();

  if (_tcslen(text)>0) {
    _tcsupr(text);
    LK_tcsncpy(edittext, text, max_width-1);
    // position cursor at the end of imported text
    cursor=_tcslen(text); 
  }

  UpdateTextboxProp();
  wf->SetKeyDownNotify(FormKeyDown);
  wf->ShowModal();
  LK_tcsncpy(text, edittext, max_width-1);
  delete wf;
  wf=NULL;
}
Esempio n. 7
0
void  CBrainMemory::RegisterGlobalPeople(ePipeline& PeopleData){
	tstring& Name = *(tstring*)PeopleData.GetData(0);
	_tcsupr(&Name[0]);

	CLock lk(&m_MemoryMutex);
	m_GlobalPeopleList[Name] = PeopleData;	
};
void CInsertHeaderDialog::OnChangeTitle()
{
	UpdateData();

	// disable label-window?
	m_wndLabelEdit.EnableWindow(!m_strTitle.IsEmpty());

	// auto generate label
	BOOL bWhiteSpace = FALSE;
	TCHAR strC[2] = _T(" ");

	m_strLabel = AfxLoadString(SectionIDs[m_nDepth].second);

	for (int i = 0; i < m_strTitle.GetLength(); i++)
	{
		if (!_istalnum(m_strTitle[i]))
			bWhiteSpace = TRUE;
		else
		{
			strC[0] = m_strTitle[i];
			m_strLabel += (bWhiteSpace ? _tcsupr(strC) : strC); //bWhiteSpace + _tcsupr ==> CamelCase
			bWhiteSpace = FALSE;
		}
	}

	UpdateData(FALSE);
}
Esempio n. 9
0
// Unused. Currently using _tcstoui64 as it is a lot faster.
__int64 StrToNum(const TCHAR *udata, int udatalen, int base)
{
	long index;
	const TCHAR numdigits[] = TEXT("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ");
	long digitValue = 0;
	__int64 RetVal = 0;
	TCHAR digits[sizeof(numdigits) + 1];
	TCHAR *dataVal;
	TCHAR data[512];
	//copy the data to our variable
	_tcscpy(data, udata);
	//convert it to upper case
	_tcsupr(data);
	ZeroMemory(digits, sizeof(digits));
	//copy the number of digits supported by base in digits
	_tcsncpy(digits, numdigits, base);
	for (index = 0; index < udatalen; index++)
	{
		dataVal = _tcschr(digits, data[index]);
		if (dataVal != 0)
		{
			//if it is subtract where to start point
			digitValue = long(dataVal - digits);
			//increment Retval with digitvalue
			RetVal = RetVal * base + digitValue;
		}
	}
	return RetVal;
}
Esempio n. 10
0
// Binary value has changed
static int UpdateEaValueText(HWND hDlg)
{
    LPTSTR szTextValue;
    LPTSTR szBinValue;
    LPBYTE pbBinValue;
    HWND hSrcEdit = GetDlgItem(hDlg, IDC_DATA_VALUE_BIN);
    HWND hTrgEdit = GetDlgItem(hDlg, IDC_DATA_VALUE_TEXT);
    int nTextLength = GetWindowTextLength(hSrcEdit);
    int nBinLength;

    szTextValue = new TCHAR[nTextLength * 4 + 1];
    szBinValue = new TCHAR[nTextLength + 1];
    pbBinValue = new BYTE[nTextLength + 1];
    GetWindowText(hSrcEdit, szBinValue, nTextLength + 1);
    _tcsupr(szBinValue);

    // Process the binary buffer and convert it to the binary data
    nChangingEdit++;
    nBinLength = BinTextToBinArray(szBinValue, pbBinValue);
    if(nBinLength != -1)
    {
        BinArrayToCText(pbBinValue, nBinLength, szTextValue);
        SetWindowText(hTrgEdit, szTextValue);
    }
    else
        SetWindowTextRc(hTrgEdit, IDS_CONVERSION_ERROR);
    nChangingEdit--;

    delete [] pbBinValue;
    delete [] szBinValue;
    delete [] szTextValue;
    return TRUE;
}
long CMetronomeDlg_RegPersist::OnExportPresetButton(unsigned long const nIgnore1, long const nIgnore2) 
{
    OPENFILENAME ofn;
    TCHAR szE[] = _T("/e \"");
    TCHAR szR[] = _T("\" \"HKEY_CURRENT_USER\\Software\\BHBSoftware\\Open Metronome\"");
    TCHAR szWholeFile[MAX_PATH + sizeof(szE) + sizeof(szR)] = _T("");       // buffer for file name
    TCHAR szFile[255];       // buffer for file name
    TCHAR title[255];        //buffer for file title

    ZeroMemory(&ofn, sizeof(ofn));
    ofn.lStructSize = sizeof(ofn);
    ofn.hwndOwner = m_hWnd;
    ofn.lpstrFile = szFile;
    ofn.lpstrFileTitle = title;
    
    //
    // Set lpstrFile[0] to '\0' so that GetOpenFileName does not 
    // use the contents of szFile to initialize itself.
    ofn.lpstrFile[0] = (TCHAR)'\0';
    ofn.lpstrDefExt = _T("REG");
    ofn.lpstrFileTitle[0] = (TCHAR)'\0';
    ofn.nMaxFile = sizeof(szFile);
    ofn.nMaxFileTitle = sizeof(title);

#ifdef USE_WEIRD_MIDI
    ofn.lpstrFilter = _T("Registry Files (*.REG)\0*.REG\0\0");
#else //USE_WEIRD_WAV
    ofn.lpstrFilter = _T("Wave Sound (*.WAV)\0*.WAV\0Registry Files (*.REG)\0*.REG\0\0");
#endif

    ofn.nFilterIndex = 1;
    
    ofn.Flags = OFN_OVERWRITEPROMPT;

    if(GetSaveFileName(&ofn) == IDOK) 
    {
        std::basic_string<TCHAR> const strFilename(ofn.lpstrFile);
        if (_tcsstr(_tcsupr(ofn.lpstrFile), _T(".WAV"))-ofn.lpstrFile == strFilename.length()-4)
        {
            if (BuildPlayerInstance())
            {
                if (m_autopTicker.get())
                {
                    m_autopTicker->Export(strFilename.c_str(), m_NumExp);
                    m_autopTicker = (std::auto_ptr<IBeatBox>) NULL;
                }
            }
        }
#ifndef UNDER_CE
        else
        {
            _tcscpy(szWholeFile, szE);
            _tcscat(szWholeFile, strFilename.c_str());
            _tcscat(szWholeFile, szR);
	        ShellExecute(this->m_hWnd, _T("open"), _T("regedit"), szWholeFile, 0, SW_SHOWNORMAL);
        }
#endif
    }
    return 0;
}
void CShowActiveDirUsers::GetUserAndDomainNameFromUPN(LPTSTR szUser, 
								LPTSTR szUserName, LPTSTR szDomainName)
{
	ULONG size = 8192;
	TCHAR buffer[8192];

	if ( TranslateName( szUser, NameUserPrincipal, NameSamCompatible, 
										buffer, &size ) )
	{
		// we UPN name
		TCHAR  szSeparators[] = L"\\";
		TCHAR* szToken  = L"";

		szToken = _tcstok( buffer, szSeparators );

		// domain
		_tcsupr(szToken);
		_tcscpy(szDomainName, szToken);

		// user name
		szToken = wcstok( NULL, szSeparators );
		_tcslwr(szToken);
		_tcscpy(szUserName, szToken);

	}
}
Esempio n. 13
0
void Database::sysTabDbInsert(SysTableDbData &dbdef) {
  if(!DbFile::exist(SYSTEM_DBDATA_FNAME)) {
    createDbDb();
  }

  LogFile logFile(SYSTEM_DBLOG_FNAME);

  DataFile dataFile( SYSTEM_DBDATA_FNAME, DBFMODE_READWRITE, &logFile);
  KeyFile  indexFile(SYSTEM_DBKEY_FNAME,  DBFMODE_READWRITE, &logFile);

  logFile.begin();
  _tcsupr(dbdef.m_dbName);
  try {
    DbAddr addr = dataFile.insert(&dbdef, sizeof(SysTableDbData));

    KeyFileDefinition keydef(indexFile);
    KeyType key;
    keydef.put(key, 0, String(dbdef.m_dbName));
    keydef.putRecordAddr(key, addr);
    indexFile.insert(key);
  } catch(sqlca) {
    logFile.abort();
    throw;
  }
  logFile.commit();
}
Esempio n. 14
0
///////////////////////////////////////////////////////////////////////////////////////////
//  Function:       iConvertStrToInt
//
//  Description:    Converts a hex value saved as a string (coming from EnumSystemLocale)
//                  to an integer.
//
//  Comments:
//
///////////////////////////////////////////////////////////////////////////////////////////
int iConvertStrToInt(LPTSTR strString)
{
int		i, iNum;
int		iValue = 0;
int		iboundry;

	// convert the string to upper case first.
	_tcsupr(strString);

	// we look into 4 LSB only since:
	// LCID (DWORD) = Sort-Key (HI-WORD) + Lang ID (LOW-WORD)
    __try
    {
        // If strString is not null terminated , this call can cause access violation.
        iboundry = _tcslen(strString) - 1;
    }

    __except(EXCEPTION_EXECUTE_HANDLER)
    {
        iboundry = 0;
    }


	for (i = iboundry; i > iboundry - 4; i--)
	{
		iNum = strString[i] - 48;	// 48 being the ASCII number for 0
		if (iNum > 10)				// if it's over digit range
			iNum -= 7;
		iValue += iNum * (int)(pow(16, iboundry-i));
	}
	return iValue;
}
Esempio n. 15
0
void dlgTextEntryKeyboardShowModal(TCHAR *text, int width, const TCHAR* szFile, const TCHAR* szResource)
{

  first = true;
  wf = NULL;
  if (width==0) {
    width = MAX_TEXTENTRY;
  }
  max_width = min(MAX_TEXTENTRY, width);
  char filename[MAX_PATH];
    LocalPathS(filename, szFile);
    wf = dlgLoadFromXML(CallBackTable,
			filename,
			hWndMainWindow,
			szResource);
  if (!wf) return;

  cursor = 0;
  ClearText();

  if (_tcslen(text)>0) {
    _tcsupr(text);
    LK_tcsncpy(edittext, text, max_width-1);
    // show previous test.
    // this text is replaced by first key down
    // but used if "OK" is clicked first for don't reset current value.
  }

  UpdateTextboxProp();
  wf->SetKeyDownNotify(FormKeyDown);
  wf->ShowModal();
  LK_tcsncpy(text, edittext, max_width-1);
  delete wf;
  wf=NULL;
}
Esempio n. 16
0
void SearchLocEditDlg::OnOK(void)
{
    xpr_tchar_t sPath[XPR_MAX_PATH + 1] = {0};
    GetDlgItemText(IDC_SEARCH_LOC_EDIT_PATH, sPath, XPR_MAX_PATH);

    if (_tcslen(sPath) == 2)
        _tcscat(sPath, XPR_STRING_LITERAL("\\"));

    if (mSearchUserLocPathSet != XPR_NULL)
    {
        xpr_tchar_t sPathUpper[XPR_MAX_PATH + 1] = {0};
        _tcscpy(sPathUpper, sPath);
        _tcsupr(sPathUpper);

        if (mSearchUserLocPathSet->find(sPathUpper) != mSearchUserLocPathSet->end())
        {
            const xpr_tchar_t *sMsg = gApp.loadString(XPR_STRING_LITERAL("popup.search_user_location_edit.msg.duplicated_path"));
            MessageBox(sMsg, XPR_NULL, MB_OK | MB_ICONSTOP);

            GetDlgItem(IDC_SEARCH_LOC_EDIT_PATH)->SetFocus();
            return;
        }
    }

    xpr_bool_t sInclude   = ((CButton *)GetDlgItem(IDC_SEARCH_LOC_EDIT_INCLUDE))->GetCheck();
    xpr_bool_t sSubFolder = ((CButton *)GetDlgItem(IDC_SEARCH_LOC_EDIT_SUBFOLDER))->GetCheck();

    mPath      = sPath;
    mInclude   = sInclude;
    mSubFolder = sSubFolder;

    super::OnOK();
}
Esempio n. 17
0
/**
 * Checks whether the given string str equals "." or ".."
 * @param str The string to check
 * @return True if string equals "." or ".."
 */
#ifndef HAVE_POSIX
static bool
IsDots(const TCHAR* str)
{
  return !(_tcscmp(str, _T(".")) && _tcscmp(str, _T("..")));
}
#endif

#ifndef HAVE_POSIX /* we use fnmatch() on POSIX */
static bool
checkFilter(const TCHAR *filename, const TCHAR *filter)
{
  // filter = e.g. "*.igc" or "config/*.prf"
  // todo: make filters like "config/*.prf" work

  // if invalid or short filter "*" -> return true
  // todo: check for asterisk
  if (!filter || string_is_empty(filter + 1))
    return true;

  // Copy filter without first char into upfilter
  // *.igc         ->  .igc
  // config/*.prf  ->  onfig/*.prf
  TCHAR upfilter[MAX_PATH];
  _tcscpy(upfilter, filter + 1);

  // Search for upfilter in filename (e.g. ".igc" in "934CFAE1.igc") and
  //   save the position of the first occurence in ptr
  const TCHAR *ptr = _tcsstr(filename, upfilter);
  if (ptr != NULL && _tcslen(ptr) == _tcslen(upfilter))
    // If upfilter was found at the very end of filename
    // -> filename matches filter
    return true;

  // Convert upfilter to uppercase
  _tcsupr(upfilter);

  // And do it all again
  ptr = _tcsstr(filename, upfilter);

  // If still no match found -> filename does not match the filter
  return (ptr != NULL && _tcslen(ptr) == _tcslen(upfilter));
}
Esempio n. 18
0
void
HandleDAOption (
    int argc,
    TCHAR **argv
    )
{
    DWORD returnValue;

    if (argc < 3)
        ShowUsage (TEXT("Invalid number of arguments."));

    if (_tcscmp (_tcsupr (argv [2]), TEXT("LIST")) == 0)
    {
        _tprintf (TEXT("Default access permission list:\n\n"));
        ListDefaultAccessACL();
        return;
    }

    if (argc < 4)
        ShowUsage (TEXT("Invalid number of arguments."));

    if (_tcscmp (_tcsupr (argv [2]), TEXT("SET")) == 0)
    {
        if (argc < 5)
            ShowUsage (TEXT("Invalid number of arguments."));

        if (_tcscmp (_tcsupr (argv [4]), TEXT("PERMIT")) == 0)
            returnValue = ChangeDefaultAccessACL (argv [3], TRUE, TRUE); else

        if (_tcscmp (_tcsupr (argv [4]), TEXT("DENY")) == 0)
            returnValue = ChangeDefaultAccessACL (argv [3], TRUE, FALSE); else
        {
            ShowUsage (TEXT("You can only set a user's permissions to \"permit\" or \"deny\".\n\n"));
        }

        if (returnValue != ERROR_SUCCESS)
            Error (TEXT("ERROR: Cannot add user to default access ACL."), returnValue);
    } else
    if (_tcscmp (_tcsupr (argv [2]), TEXT("REMOVE")) == 0)
    {
        returnValue = ChangeDefaultAccessACL (argv[3], FALSE, FALSE);

        if (returnValue != ERROR_SUCCESS)
            Error (TEXT("ERROR: Cannot remove user from default access ACL."), returnValue);
    } else
        ShowUsage (TEXT("You can only \"set\" or \"remove\" a user."));
}
Esempio n. 19
0
static HICON
CreateLayoutIcon(LPTSTR szInd)
{
    HDC hdc, hdcsrc;
    HBITMAP hBitmap, hBmpNew, hBmpOld;
    RECT rect;
    DWORD bkColor, bkText;
    HFONT hFont = NULL;
    ICONINFO IconInfo;
    HICON hIcon = NULL;

    hdcsrc = GetDC(NULL);
    hdc = CreateCompatibleDC(hdcsrc);
    hBitmap = CreateCompatibleBitmap(hdcsrc, 16, 16);
    ReleaseDC(NULL, hdcsrc);

    if (hdc && hBitmap)
    {
        hBmpNew = CreateBitmap(16, 16, 1, 1, NULL);
        if (hBmpNew)
        {
            hBmpOld = SelectObject(hdc, hBitmap);
            rect.right = 16;
            rect.left = 0;
            rect.bottom = 16;
            rect.top = 0;

            bkColor = SetBkColor(hdc, GetSysColor(COLOR_HIGHLIGHT));
            bkText  = SetTextColor(hdc, GetSysColor(COLOR_HIGHLIGHTTEXT));

            ExtTextOut(hdc, rect.left, rect.top, ETO_OPAQUE, &rect, _T(""), 0, NULL);

            hFont = CreateFont(-11, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET,
                               OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,
                               DEFAULT_QUALITY, FF_DONTCARE, _T("Tahoma"));

            SelectObject(hdc, hFont);
            DrawText(hdc, _tcsupr(szInd), 2, &rect, DT_SINGLELINE|DT_CENTER|DT_VCENTER);
            SelectObject(hdc, hBmpNew);
            PatBlt(hdc, 0, 0, 16, 16, BLACKNESS);
            SelectObject(hdc, hBmpOld);

            IconInfo.hbmColor = hBitmap;
            IconInfo.hbmMask = hBmpNew;
            IconInfo.fIcon = TRUE;

            hIcon = CreateIconIndirect(&IconInfo);

            DeleteObject(hBmpNew);
            DeleteObject(hBmpOld);
            DeleteObject(hFont);
        }
    }

    DeleteDC(hdc);
    DeleteObject(hBitmap);

    return hIcon;
}
Esempio n. 20
0
KString KString::Upper() const
{
	KString String = *this;

	_tcsupr(String.GetDataPtr());

	return String;
}
Esempio n. 21
0
/*
 * Is the cmd line a valid form of NET ADMIN /C
 */
int DOSNEAR FASTCALL IsAdminCommand(VOID)
{
    if (!SwitchList[0] || !ArgList[1])
	return 0;
    _tcsupr(SwitchList[0]);
    return (IsComputerName(ArgList[1]) &&
	    (sw_compare(swtxt_SW_ADMIN_COMMAND, SwitchList[0]) >= 0));
}
Esempio n. 22
0
void CFilteringTable::LoadScript()
{
	CMHFile file;
	file.Init(
		_T("system\\resource\\filterWord.bin"),
		_T("rb"));

	Type type = TypeNone;

	while(FALSE == file.IsEOF())
	{
		TCHAR buffer[MAX_PATH] = {0};
		file.GetLine(
			buffer,
			sizeof(buffer) / sizeof(*buffer));
		
		if(0 == _tcslen(buffer))
		{
			continue;
		}

		LPCTSTR commentMark = _T("@");

		if(0 == _tcsnicmp(buffer, commentMark, _tcslen(commentMark)))
		{
			continue;
		}
		else if(0 == _tcsicmp(buffer, _T("#GM")))
		{
			type = TypePartiallyBlockedName;
			continue;
		}
		else if(0 == _tcsicmp(buffer, _T("#SLANG")))
		{
			type = TypePartiallyBlockedKeyword;
			continue;
		}
		else if(0 == _tcsicmp(buffer, _T("#SYSTEM")))
		{
			type = TypeEntirelyBlockedName;
			continue;
		}

		TCHAR text[MAX_PATH] = {0};
		RemoveSpace(
			buffer,
			text,
			sizeof(text) / sizeof(*text));
		_tcsupr(
			text);

		KeywordContainer& keywordContainer = mFilterContainer[type];
		keywordContainer.insert(
			text);
	}
}
Esempio n. 23
0
ePipeline* CBrainMemory::FindGlobalObject(tstring& Name){
	_tcsupr(&Name[0]);
	CLock lk(&m_MemoryMutex);
    map<tstring,ePipeline>::iterator It = m_GlobalObjectList.find(Name);
	while(It!=m_GlobalObjectList.end()){
		ePipeline& ObjectData = It->second;
		return &ObjectData;
	}
	return NULL;	
};
Esempio n. 24
0
bool CHelpDB::NewItem(CTSTRING& _sAlias, CTSTRING& sText, CTSTRING& sCreator)
{
    MSXML::IXMLDOMElementPtr El;
    bool r = false;
    if(m_doc == 0) return false;
    TSTRING sAlias;

    {
        TCHAR* tsz = _tcsdup(_sAlias.c_str());
        _tcsupr(tsz);
        sAlias = tsz;
        SAFE_FREE(tsz);
    }

    // Just determine if it exists.
    if(GetItemElement(sAlias, El, false))
    {
        // it already exists; fail.
        sprintf(m_err, _T("%s already exists.  If you want to change the existing entry, use !msgchange."), sAlias.c_str());
        g_pLog->msg(_T("%s"), m_err.c_str());
    }
    else
    {
        // doesn't already exist... we're golden like the shower.  This time
        // just call GetItemElement() with bCreate set to true.
        if(!GetItemElement(sAlias, El, true))
        {
            sprintf(m_err, _T("%s could not be added."), sAlias.c_str());
            g_pLog->msg(_T("%s"), m_err.c_str());
        }
        else
        {
            El->setAttribute(TAG_ALIAS, sAlias.c_str());
            El->setAttribute(TAG_CREATOR, sCreator.c_str());
            El->setAttribute(TAG_TEXT, sText.c_str());
            El->setAttribute(TAG_USAGE, _T("0"));
            SYSTEMTIME st;
            TSTRING sTime;
            GetLocalTime(&st);
            Bin2Str(sTime, (BYTE*)&st, sizeof(st));
            El->setAttribute(TAG_TIME, sTime.c_str());

            g_pLog->msg(_T("New db item: %s = %s"), _sAlias.c_str(), sText.c_str());

            r = true;
        }
    }

    return r;
}
Esempio n. 25
0
INT cmd_vol (LPTSTR param)
{
    TCHAR szRootPath[] = _T("A:\\");
    TCHAR szPath[MAX_PATH];

    if (!_tcsncmp(param, _T("/?"), 2))
    {
        ConOutResPaging(TRUE,STRING_VOL_HELP4);
        return 0;
    }

    nErrorLevel = 0;

    if (param[0] == _T('\0'))
    {
        GetCurrentDirectory(MAX_PATH, szPath);
        szRootPath[0] = szPath[0];
    }
    else
    {
        _tcsupr (param);
        if (param[1] == _T(':'))
        {
            szRootPath[0] = param[0];
        }
        else
        {
            error_invalid_drive ();
            nErrorLevel = 1;
            return 1;
        }
    }

    if (!IsValidPathName (szRootPath))
    {
        error_invalid_drive ();
        nErrorLevel = 1;
        return 1;
    }

    /* print the header */
    if (!PrintVolumeHeader (szRootPath))
    {
        nErrorLevel = 1;
        return 1;
    }

    return 0;
}
Esempio n. 26
0
void
LoggerImpl::AddDeclaration(double Latitude, double Longitude, const TCHAR *ID)
{
  char szCRecord[500];

  char IDString[MAX_PATH];
  int i;

  int DegLat, DegLon;
  double MinLat, MinLon;
  char NoS, EoW;

  TCHAR tmpstring[MAX_PATH];
  _tcscpy(tmpstring, ID);
  _tcsupr(tmpstring);
  for(i=0;i<(int)_tcslen(tmpstring);i++)
    {
      IDString[i] = (char)tmpstring[i];
    }
  IDString[i] = '\0';

  DegLat = (int)Latitude;
  MinLat = Latitude - DegLat;
  NoS = 'N';
  if((MinLat<0) || ((MinLat-DegLat==0) && (DegLat<0)))
    {
      NoS = 'S';
      DegLat *= -1; MinLat *= -1;
    }
  MinLat *= 60;
  MinLat *= 1000;

  DegLon = (int)Longitude ;
  MinLon = Longitude  - DegLon;
  EoW = 'E';
  if((MinLon<0) || ((MinLon-DegLon==0) && (DegLon<0)))
    {
      EoW = 'W';
      DegLon *= -1; MinLon *= -1;
    }
  MinLon *=60;
  MinLon *= 1000;

  sprintf(szCRecord,"C%02d%05.0f%c%03d%05.0f%c%s\r\n",
	  DegLat, MinLat, NoS, DegLon, MinLon, EoW, IDString);

  IGCWriteRecord(szCRecord, szLoggerFileName);
}
Esempio n. 27
0
static unsigned int __stdcall worker_routine(worker_context_t *ctx)
{
    _TCHAR message[1024];
    int length;
    unsigned id = (unsigned)GetCurrentThreadId();

    assert(ctx != NULL);

    _stprintf(message, _T("Welcome! Worker [%u] is serving you!\n"), id);

    if (send(ctx->sockfd, (const char *)message, (_tcslen(message) + 1) * sizeof(_TCHAR), 0) != SOCKET_ERROR)
    {
        while (ctx->running)
        {
            length = recv(ctx->sockfd, (char *)message, sizeof(message), 0);
            if (length == SOCKET_ERROR)
            {
                _ftprintf(stderr, _T("[%u] Failed to receive message from client <%s>: "), id, ctx->ipstr);
                print_error_ex(_T("recv"));
                break;
            }

            length /= sizeof(_TCHAR);
            length = MIN(length, ARRAYSIZE(message) - 1);
            message[length] = _T('\0');

            _tprintf(_T("[%u] Received message from client <%s>: %s\n"), id, ctx->ipstr, message);
            _tcsupr(message);

            if (send(ctx->sockfd, (const char *)message, (_tcslen(message) + 1) * sizeof(TCHAR), 0) == -1)
            {
                _ftprintf(stderr, _T("[%u] Failed to send reply message to client <%s>: "), id, ctx->ipstr);
                print_error_ex(_T("send"));
            }
        }
    }
    else
    {
        _ftprintf(stderr, _T("[%u] Failed to send welcome message to client <%s>: "), id, ctx->ipstr);
        print_error_ex(_T("send"));
    }

    InterlockedExchange(&ctx->running, 0);

    _tprintf(_T("[%u] Worker is fired!\n"), id);

    return 0;
}
Esempio n. 28
0
void __fastcall GetIconsIndexesA(LPSTR szMirVer, short *base, short *overlay, short *overlay2, short *overlay3, short *overlay4)
{
	if (mir_strcmp(szMirVer, "?") == 0) {
		*base = UNKNOWN_MASK_NUMBER;
		*overlay = -1;
		*overlay2 = -1;
		*overlay3 = -1;
		*overlay4 = -1;
		return;
	}

	LPTSTR tszMirVerUp = mir_a2t(szMirVer);
	_tcsupr(tszMirVerUp);
	MatchMasks(tszMirVerUp, base, overlay, overlay2, overlay3, overlay4);
	mir_free(tszMirVerUp);
}
void dlgNumberEntryKeyboardShowModal(int *value, int width) 
{
  wf = NULL;
  wGrid = NULL;
  if (width==0) {
    width = MAX_TEXTENTRY;
  }
  max_width = min(MAX_TEXTENTRY, width);
  char filename[MAX_PATH];
  if (InfoBoxLayout::landscape) 
    {
      LocalPathS(filename, TEXT("frmNumberEntry_Keyboard_L.xml"));
      wf = dlgLoadFromXML(CallBackTable, 
			  filename, 
			  hWndMainWindow,			  
			  TEXT("IDR_XML_NUMBERENTRY_KEYBOARD_L"));
      if (!wf) return;
    }
  else
    {
      LocalPathS(filename, TEXT("frmNumberEntry_Keyboard.xml"));
      wf = dlgLoadFromXML(CallBackTable, 
			  filename, 
			  hWndMainWindow,			  
			  TEXT("IDR_XML_NUMBERENTRY_KEYBOARD"));
      if (!wf) return;
    }
  wGrid = (WndOwnerDrawFrame*)wf->FindByName(TEXT("frmGrid"));
  cursor = 0;
  ClearText();
  TCHAR text[20];
  _stprintf(text, TEXT("%ld"), *value);
  if (_tcslen(text)>0) {
    _tcsupr(text);
    _tcsncpy(edittext, text, max_width-1);
    edittext[max_width-1]= 0;
  }
  UpdateTextboxProp();
  wf->SetKeyDownNotify(FormKeyDown);
  wf->ShowModal();
  _tcsncpy(text, edittext, max_width);
  text[max_width-1]=0;
  *value = _wtoi(text);
  delete wf;
  wf=NULL; //@ 101027 just to be sure
}
Esempio n. 30
0
bool CHelpDB::GetItemElement(CTSTRING& _sAlias, MSXML::IXMLDOMElementPtr& Out, bool bCreate)
{
    bool r = false;
    TSTRING sXPath;
    MSXML::IXMLDOMNodePtr Node;
    TSTRING sAlias;

    {
        TCHAR* tsz = _tcsdup(_sAlias.c_str());
        _tcsupr(tsz);
        sAlias = tsz;
        SAFE_FREE(tsz);
    }

    // this will look something like MSG[@ALIAS="hithere"]
    sprintf(sXPath, TAG_MSG _T("[@") TAG_ALIAS _T("=\"%s\"]"), sAlias.c_str());

    try
    {
        Node = m_root->selectSingleNode(_bstr_t(sXPath.c_str()));

        if((Node == NULL) && (bCreate == true))
        {
            MSXML::IXMLDOMElementPtr NewEl;
            MSXML::IXMLDOMNodePtr NewNode;

            NewEl = m_doc->createElement("MSG");
            NewEl.QueryInterface(__uuidof(MSXML::IXMLDOMNode), &NewNode);
            Node = m_root->appendChild(NewNode);
        }

        if(Node != NULL)
        {
            Node.QueryInterface(__uuidof(MSXML::IXMLDOMElement), &Out);
            r = true;
        }
    }
    catch(_com_error& e)
    {
        sprintf(m_err, _T("COM Error: %08x"), e.Error());
        g_pLog->msg(_T("CHelpDB::GetItemElement(%s)"), _sAlias.c_str());
    }

    return r;
}