Example #1
0
// !!UNC
static LPTSTR translate( LPCTSTR path, TCHAR *buffer )
{
	TCHAR *l = host_drive_list;
	const TCHAR *p = path;

	while(*l) {
		if(_totupper(p[1]) == _totupper(*l)) break;
		l += _tcslen(l) + 1;
	}

	if(p[0] == TEXT('\\') && *l && (p[2] == 0 || p[2] == TEXT(':') || p[2] == TEXT('\\'))) {
		p += 2;
		if(*p == TEXT(':')) p++;
		if(*p == TEXT('\\')) p++;
		_sntprintf( buffer, MAX_PATH_LENGTH, TEXT("%c:\\%s"), *l, p );
	} else {
		if(*path == TEXT('\\')) {
			_sntprintf( buffer, MAX_PATH_LENGTH, TEXT("%s%s"), virtual_root, path );
		} else {
			int len = _tcslen(path);
			if(len == 0 || path[len-1] == TEXT('\\')) {
				make_mask( buffer, virtual_root, path, tstr(my_computer).get() );
			} else {
				make_mask( buffer, virtual_root, path, 0 );
			}
		}
	}
	charset_mac2host( buffer );

	return buffer;
}
Example #2
0
    Boolean MatchStringPattern (const char * string, const char * pattern, Boolean CaseSensative)
    {
        Boolean escaped = FALSE;

        for (; *pattern != '\0'; pattern++)
        {
            if (PATTERN_ESCCHAR == *pattern && !escaped)
            {
                escaped = TRUE;
                continue;
            }

            if (PATTERN_MANYCHAR == *pattern && !escaped)
            {
                for (;;)
                {
                    if ('\0' == *(pattern + 1))
                       return TRUE;  // We can have any number of trailing characters.

                    if (MatchStringPattern (string, pattern + 1))
                       return TRUE;

                    if ('\0' == *string)
                        return FALSE;  // We have unmatched pattern char/s.

                    string++;
                }
            }

            if ('\0' == *string)
                return FALSE;  // We have unmatched pattern char/s. Not a PATTERN_MANYCHAR.

            if (*pattern != PATTERN_ANYCHAR || escaped)
            {
                if(CaseSensative)
                {
                  if (*pattern != *string)
                     return FALSE;  // Something is not matched.
                } else
                {
                    if(_totupper(*pattern) != _totupper(*string))
                     return FALSE;  // Something is not matched.
                }

            }

            escaped = FALSE;
            string++;
        }

        return '\0' == *string;
    }
Example #3
0
void TitleCase (CString& str)
{
	if (str.GetLength () == 0)
		return;

	str.MakeLower ();	
	bool bNewWord = true;

	int last = str.GetLength ();

/*	int ext_pos = str.ReverseFind ('.');

	if (ext_pos != -1)
		last = ext_pos;*/

	for (int i = 0; i < last; i++)
	{
		if (_istalpha (str[i]))
		{
			if (bNewWord)
			{
				bNewWord = false;
				str.SetAt (i, _totupper (str[i]));
			}
		}
		else
			bNewWord = true;
	}
}
Example #4
0
/** ini_getl()
 * \param Section     the name of the section to search for
 * \param Key         the name of the entry to find the value of
 * \param DefValue    the default value in the event of a failed read
 * \param Filename    the name of the .ini file to read from
 *
 * \return            the value located at Key
 */
long ini_getl(const TCHAR *Section, const TCHAR *Key, long DefValue, const TCHAR *Filename)
{
  TCHAR LocalBuffer[64];
  int len = ini_gets(Section, Key, __T(""), LocalBuffer, sizearray(LocalBuffer), Filename);
  return (len == 0) ? DefValue : ((len >= 2 && _totupper(LocalBuffer[1]) == 'X') ? _tcstol(LocalBuffer, NULL, 16)
                                                                      : _tcstol(LocalBuffer, NULL, 10));
}
Example #5
0
void CMGTOOls::makeUpper(TCHAR *pChar)
{
	for (int i=0;pChar[i]!=_T('\0');i++)
	{
		pChar[i] = _totupper(pChar[i]);
	}
}
Example #6
0
/*
 * Determine the default official application name
 *
 * This function provides the default application name that appears in a variety of
 * places such as: title of message dialog, title of splash screen window
 * that shows up in Windows task bar.
 * It is computed from the name of the launcher executable and
 * by capitalizing the first letter. e.g. "c:/ide/eclipse.exe" provides
 * a default name of "Eclipse".
 */
static _TCHAR* getDefaultOfficialName(_TCHAR* program)
{
    _TCHAR *ch = NULL;

    /* Skip the directory part */
    ch = lastDirSeparator( program );
    if (ch == NULL) ch = program;
    else ch++;

    ch = _tcsdup( ch );
#ifdef _WIN32
    {
        /* Search for the extension .exe and cut it */
        _TCHAR *extension = _tcsrchr(ch, _T_ECLIPSE('.'));
        if (extension != NULL)
        {
            *extension = _T_ECLIPSE('\0');
        }
    }
#endif
    /* Upper case the first character */
#ifndef LINUX
    {
        *ch = _totupper(*ch);
    }
#else
    {
        if (*ch >= 'a' && *ch <= 'z')
        {
            *ch -= 32;
        }
    }
#endif
    return ch;
}
Example #7
0
static int hextoint( _TCHAR c )
{
    if ( (c >= __T('0')) && (c <= __T('9')) )
        return c-__T('0');

    return _totupper(c)-__T('A')+10;
}
Example #8
0
/**
 * @brief Convert a string to upper case string.
 * @param [in] str String to convert to upper case.
 * @return upper case string.
 */
String makeupper(const String &str)
{
	String ret(str);
	String::size_type i = 0;
	for (i = 0; i < ret.length(); i++)
		ret[i] = _totupper(ret[i]);
	return ret;
}
Example #9
0
static int readval (const TCHAR *s)
{
	int base = 10;
	TCHAR *endptr;
	if (s[0] == '0' && _totupper (s[1]) == 'X')
		s += 2, base = 16;
	return _tcstol (s, &endptr, base);
}
Example #10
0
CStr CStr::UpperCase() const
{
	std::tstring NewString = *this;
	for (size_t i = 0; i < length(); i++)
		NewString[i] = (tchar)_totupper((*this)[i]);

	return NewString;
}
Example #11
0
String firstLetterToUpperCase(const String &str) { // Return a copy of str, with first non-space letter changed to uppercase.
  String  result(str);
  _TUCHAR *s;
  for(s = (_TUCHAR*)result.cstr(); _istspace(*s); s++);
  if(_istascii(*s) && _istlower(*s)) {
    *s = _totupper(*s);
  }
  return result;
}
Example #12
0
// Convert str to uppercase in place.
void _strupr (str_char *str)
{
    SC_ASSERT (str);

    while (*str)
    {
        *str = _totupper (*str);
		str++;
    }
}
Example #13
0
TCHAR *_tcstoupper(TCHAR *dst)
{
	unsigned int i = 0;
	setlocale(LC_ALL, "");
	if (!dst)
		return NULL;
	for (i = 0; i < _tcslen(dst); i++)
		dst[i] = _totupper(dst[i]);
	return dst;
}
Example #14
0
void String::toUpper()
{
	if (!m_pString)
	{
		return;
	}
    
    checkToCopyAndAlloc(getLength());

	_totupper(*m_pString);
}
Example #15
0
size_t CharToHex(TCHAR cChar)
{
	if(_istdigit(cChar))
		return cChar - TEXT('0');

	cChar = _totupper(cChar);

	if(cChar >= TEXT('A') && cChar <= TEXT('F'))
		return cChar - TEXT('A') + 10;

	return 0;
}
Example #16
0
std::wstring WizGetAppExeFileName()
{
	TCHAR szFileName[1024] = {0};
	GetModuleFileName(NULL, szFileName, 1024);
	//
	TCHAR szLongFileName[1024] = {0};
	GetLongPathName(szFileName, szLongFileName, 1024);
	//
	*szLongFileName = _totupper(*szLongFileName);

	return std::wstring(szLongFileName);
}
Example #17
0
void COXFileChanger::ReverseCase(CString& sText)
	// --- In      : sText, the text to reverse case
	// --- Out     : 
	// --- Returns : a string with reversed case for each character
	// --- Effect  : reverse every character's case in a string
	{
	TCHAR ch;
	for (int i = 0; i < sText.GetLength(); i++)
		{
		ch = sText[i];
		sText.SetAt(i, (_istlower(ch) ? (TCHAR)_totupper(ch) : (TCHAR)_totlower(ch)));
		}
	}
void _tcstoupper( TCHAR* str1 )
{
	if ( !str1 ) return;
	
	while ( *str1 )
	{
		int ch = *str1;
		ch = _totupper( ch );
		*str1 = ch;

		str1++;
	}
}
Example #19
0
void  MakeUpper (CString &str)
{
	int last = str.GetLength ();

	/*int ext_pos = str.ReverseFind ('.');

	if (ext_pos != -1)
		last = ext_pos;*/

	for (int i = 0; i < last; i++)	
			str.SetAt (i, _totupper (str[i]));
				
}
Example #20
0
INT CommandHistory (LPTSTR param)
{
	LPTSTR tmp;
	INT tmp_int;
	LPHIST_ENTRY h_tmp;
	TCHAR szBuffer[2048];

	tmp=_tcschr(param,_T('/'));

	if (tmp)
	{
		param=tmp;
		switch (_totupper(param[1]))
		{
			case _T('F'):/*delete history*/
				CleanHistory();InitHistory();
				break;

			case _T('R'):/*read history from standard in*/
				//hIn=GetStdHandle (STD_INPUT_HANDLE);

				for(;;)
				{
					ConInString(szBuffer,sizeof(szBuffer)/sizeof(TCHAR));
					if (*szBuffer!=_T('\0'))
						History(0,szBuffer);
					else
						break;
				}
				break;

			case _T('A'):/*add an antry*/
				History(0,param+2);
				break;

			case _T('S'):/*set history size*/
				if ((tmp_int=_ttoi(param+2)))
					set_size(tmp_int);
				break;

			default:
				return 1;
		}
	}
	else
	{
		for (h_tmp = Top->prev; h_tmp != Bottom; h_tmp = h_tmp->prev)
			ConErrPuts(h_tmp->string);
	}
	return 0;
}
int __cdecl _tchdir (
        const _TSCHAR *path
        )
{
        _TSCHAR env_var[4];
        _TSCHAR abspath[MAX_PATH+1];

        if ( SetCurrentDirectory((LPTSTR)path) )
        {
            /*
             * If the new current directory path is NOT a UNC path, we must
             * update the OS environment variable specifying the current
             * directory for what is now current drive. To do this, get the
             * full current directory, build the environment variable string
             * and call SetEnvironmentVariable(). We need to do this because
             * SetCurrentDirectory does not (i.e., does not update the
             * current-directory-on-drive environment variables) and other
             * functions (fullpath, spawn, etc) need them to be set.
             *
             * If associated with a 'drive', the current directory should
             * have the form of the example below:
             *
             *  D:\nt\private\mytests
             *
             * so that the environment variable should be of the form:
             *
             *  =D:=D:\nt\private\mytests
             *
             */
            if ( GetCurrentDirectory(MAX_PATH+1, (LPTSTR)abspath) != 0 )
            {
                /*
                 * check if it is a UNC name, just return if is
                 */
                if ( ((abspath[0] == _T('\\')) || (abspath[0] == _T('/'))) &&
                     (abspath[0] == abspath[1]) )
                    return 0;

                env_var[0] = _T('=');
                env_var[1] = (_TSCHAR) _totupper((_TUCHAR)abspath[0]);
                env_var[2] = _T(':');
                env_var[3] = _T('\0');

                if ( SetEnvironmentVariable(env_var, abspath) )
                    return 0;
            }
        }

        _dosmaperr(GetLastError());
        return -1;
}
Example #22
0
TCHAR CMaskData::PreProcessChar(TCHAR chNewChar)
{
	TCHAR chProcessedChar=chNewChar;
	switch(m_eType)
	{
	case MaskDataTypeALPHAETICUPPER    :
		chProcessedChar=(TCHAR)_totupper(chNewChar);
		break;
	case MaskDataTypeALPHAETICLOWER    :
		chProcessedChar=(TCHAR)_totlower(chNewChar);
		break;
	}
	return chProcessedChar;
}
Example #23
0
/*
read a color value in hex (like win nt's cmd syntax)
if an error occurs return -1
*/
static
WORD hex_clr(LPTSTR str)
{
	WORD ret= (WORD)-1;
	TCHAR ch;

	ch = str[1];

	if(_istdigit(ch))
		ret = ch-_T('0');
	else
	{
		ch=_totupper(ch);

		if(  ch >= _T('A') && ch <= _T('F')  )
			ret = ch-_T('A')+10;
		else
			return (WORD)-1;
	}


	ch = str[0];

	if(_istdigit(ch))
		ret |= (ch-_T('0')) << 4;
	else
	{
		ch=_totupper(ch);

		if(  ch >= _T('A') && ch <= _T('F')  )
			ret |= (ch-_T('A')+10) <<4;
		else
			return (WORD)-1;
	}

	return ret;
}
Example #24
0
/**
 * Case insensitive _tcsstr
 *
 * @param szString TCHAR *: String to be searched
 * @param szSearchFor
 *                 TCHAR *: String that should be found in szString
 *
 * @return TCHAR *: found position of szSearchFor in szString. 0 if szSearchFor was not found
 */
const TCHAR* CMimAPI::StriStr(const TCHAR *szString, const TCHAR *szSearchFor)
{
	assert(szString != 0 && szSearchFor != 0);

	if(szString && *szString) {
		if (0 == szSearchFor || 0 == *szSearchFor)
			return(szString);

		for(; *szString; ++szString) {
			if(_totupper(*szString) == _totupper(*szSearchFor)) {
				const TCHAR *h, *n;
				for(h = szString, n = szSearchFor; *h && *n; ++h, ++n) {
					if(_totupper(*h) != _totupper(*n))
						break;
				}
				if(!*n)
					return(szString);
			}
		}
		return(0);
	}
	else
		return(0);
}
Example #25
0
long ini_getl_OpenedFile(
		const mTCHAR *Section,
		const mTCHAR *Key,
		long DefValue,
		INI_FILETYPE* pFile)
{
	TCHAR LocalBuffer[64];
	int pos = 0;

//	(void) ini_seek(pFile, &pos);

	int len = ini_gets_OpenedFile(Section, Key, __T(""), LocalBuffer, sizearray(LocalBuffer), pFile);
	return (len == 0) ? DefValue : ((len >= 2 && _totupper(LocalBuffer[1]) == 'X') ? _tcstol(LocalBuffer, NULL, 16)
																	  : _tcstol(LocalBuffer, NULL, 10));
}
Example #26
0
CString GetLocaleLanguage(LANGID langid)
{
    CString s = GetLocaleString(LOCALE_SNATIVELANGNAME, langid);

    // In the French case, the system returns "francais",
    // but we want "Francais".

    // TODO: need a Unicode version for this function

    if(s.GetLength() > 0)
    {
        s.SetAt(0, (TCHAR)_totupper(s[0])); // FIXME: same holds for Russian, but _toupper won't work there ...
    }

    return s + _T(" - ") + GetLocaleString(LOCALE_SNATIVECTRYNAME, langid);
}
Example #27
0
/** ini_getbool()
 * \param Section     the name of the section to search for
 * \param Key         the name of the entry to find the value of
 * \param DefValue    default value in the event of a failed read; it should
 *                    zero (0) or one (1).
 * \param Buffer      a pointer to the buffer to copy into
 * \param BufferSize  the maximum number of characters to copy
 * \param Filename    the name and full path of the .ini file to read from
 *
 * A true boolean is found if one of the following is matched:
 * - A string starting with 'y' or 'Y'
 * - A string starting with 't' or 'T'
 * - A string starting with '1'
 *
 * A false boolean is found if one of the following is matched:
 * - A string starting with 'n' or 'N'
 * - A string starting with 'f' or 'F'
 * - A string starting with '0'
 *
 * \return            the true/false flag as interpreted at Key
 */
int ini_getbool(const TCHAR *Section, const TCHAR *Key, int DefValue, const TCHAR *Filename)
{
  TCHAR LocalBuffer[2] = __T("");
  int ret;

  ini_gets(Section, Key, __T(""), LocalBuffer, sizearray(LocalBuffer), Filename);
  LocalBuffer[0] = (TCHAR)_totupper((int)LocalBuffer[0]);
  if (LocalBuffer[0] == 'Y' || LocalBuffer[0] == '1' || LocalBuffer[0] == 'T')
    ret = 1;
  else if (LocalBuffer[0] == 'N' || LocalBuffer[0] == '0' || LocalBuffer[0] == 'F')
    ret = 0;
  else
    ret = DefValue;

  return(ret);
}
Example #28
0
int CEnString::GetCharacterCount(TCHAR nChar, BOOL bCaseSensitive) const
{
    if (!bCaseSensitive)
    {
		CEnString sThis(*this);
		sThis.MakeUpper();
		
		return sThis.GetCharacterCount((TCHAR)_totupper(nChar));
    }
	
    int nCount = 0;
    int nFind = Find(nChar, 0);
	
    while (nFind != -1)
    {
		nCount++;
		nFind = Find(nChar, nFind + 1);
    }
	
    return nCount;
}
Example #29
0
void CNumEdit::OnPaste()
{
	LockWindowUpdate(TRUE);
	DefWindowProc();
	int nStart, nEnd;
	GetSel(nStart, nEnd);
	TCHAR szValue[64];
	GetWindowText(szValue, countof(szValue));
	int i = 0, j = 0;
	for (;;)
	{
		TCHAR chValue = szValue[i++];
		if (chValue == _T('\0'))
		{
			szValue[j] = _T('\0');
			break;
		}
		switch (m_eNumFormat)
		{
		case NF_HEX:
			if (_istxdigit(chValue))
				szValue[j++] = (TCHAR)_totupper(chValue);
			break;
		case NF_DEC:
			if (_istdigit(chValue))
				szValue[j++] = chValue;
			break;
		}
	}
	if (nStart > j)
		nStart = j;
	if (nEnd > j)
		nEnd = j;
	SetWindowText(szValue);
	SetSel(nStart, nEnd);
	LockWindowUpdate(FALSE);
}
Example #30
0
INT CommandDelete (LPTSTR param)
{
	/*cmd is the command that was given, in this case it will always be "del" or "delete"
	param is whatever is given after the command*/

	LPTSTR *arg = NULL;
	INT args;
	INT i;
	INT   nEvalArgs = 0; /* nunber of evaluated arguments */
	DWORD dwFlags = 0;
	DWORD dwAttrFlags = 0;
	DWORD dwFiles = 0;
	LONG ch;
	TCHAR szOrginalArg[MAX_PATH];

	/*checks the first two chars of param to see if it is /?
	this however allows the following command to not show help
	"del frog.txt /?" */

        if (!StringsLoaded)
        {
                LoadStrings();
        }

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

	nErrorLevel = 0;

	arg = split (param, &args, FALSE);

	if (args == 0)
	{
		/* only command given */
		error_req_param_missing ();
		freep (arg);
		return 1;
	}
	/* check for options anywhere in command line */
	for (i = 0; i < args; i++)
	{
		if (*arg[i] == _T('/'))
		{
			/*found a command, but check to make sure it has something after it*/
			if (_tcslen (arg[i]) >= 2)
			{
				ch = _totupper (arg[i][1]);
				if (ch == _T('N'))
				{
					dwFlags |= DEL_NOTHING;
				}
				else if (ch == _T('P'))
				{
					dwFlags |= DEL_PROMPT;
				}
				else if (ch == _T('Q'))
				{
					dwFlags |= DEL_QUIET;
				}
				else if (ch == _T('F'))
				{
					dwFlags |= DEL_FORCE;
				}
				else if (ch == _T('S'))
				{
					dwFlags |= DEL_SUBDIR;
				}
				else if (ch == _T('T'))
				{
					dwFlags |= DEL_TOTAL;
				}
				else if (ch == _T('W'))
				{
					dwFlags |= DEL_WIPE;
				}
				else if (ch == _T('Y'))
				{
					dwFlags |= DEL_YES;
				}
				else if (ch == _T('A'))
				{

					dwFlags |= DEL_ATTRIBUTES;
					/*the proper syntax for /A has a min of 4 chars
					i.e. /A:R or /A:-H */
					if (_tcslen (arg[i]) < 4)
					{
						error_invalid_parameter_format(arg[i]);
						return 0;
					}
					ch = _totupper (arg[i][3]);
					if (_tcslen (arg[i]) == 4)
					{
						if(ch == _T('A'))
						{
							dwAttrFlags |= ATTR_ARCHIVE;
						}
						if(ch == _T('H'))
						{
							dwAttrFlags |= ATTR_HIDDEN;
						}
						if(ch == _T('S'))
						{
							dwAttrFlags |= ATTR_SYSTEM;
						}
						if(ch == _T('R'))
						{
							dwAttrFlags |= ATTR_READ_ONLY;
						}
					}
					if (_tcslen (arg[i]) == 5)
					{
						if(ch == _T('-'))
						{
							ch = _totupper (arg[i][4]);
							if(ch == _T('A'))
							{
								dwAttrFlags |= ATTR_N_ARCHIVE;
							}
							if(ch == _T('H'))
							{
								dwAttrFlags |= ATTR_N_HIDDEN;
							}
							if(ch == _T('S'))
							{
								dwAttrFlags |= ATTR_N_SYSTEM;
							}
							if(ch == _T('R'))
							{
								dwAttrFlags |= ATTR_N_READ_ONLY;
							}
						}
					}
				}
			}

			nEvalArgs++;
		}
	}

	/* there are only options on the command line --> error!!!
	there is the same number of args as there is flags, so none of the args were filenames*/
	if (args == nEvalArgs)
	{
		error_req_param_missing ();
		freep (arg);
		return 1;
	}

	/* keep quiet within batch files */
	if (bc != NULL)
		dwFlags |= DEL_QUIET;

	/* check for filenames anywhere in command line */
	for (i = 0; i < args && !(dwFiles & 0x80000000); i++)
	{

                /*this checks to see if it isnt a flag, if it isnt, we assume it is a file name*/
		if((*arg[i] == _T('/')) || (*arg[i] == _T('-')))
			continue;

		/* We want to make a copies of the argument */
		if(_tcslen(arg[i]) == 2 && arg[i][1] == _T(':'))
		{
			/* Check for C: D: ... */
			GetRootPath(arg[i],szOrginalArg,MAX_PATH);
		}
		else
		{
			_tcscpy(szOrginalArg,arg[i]);
		}
                dwFiles += ProcessDirectory(szOrginalArg, &dwFlags, dwAttrFlags);

        }

	freep (arg);

	/*Based on MS cmd, we only tell what files are being deleted when /S is used */
	if (dwFlags & DEL_TOTAL)
	{
                dwFiles &= 0x7fffffff;
		if (dwFiles < 2)
		{
                        ConOutResPrintf(STRING_DEL_HELP3, dwFiles);
		}
		else
		{
			ConOutResPrintf(STRING_DEL_HELP4, dwFiles);
		}
	}

	return 0;
}