CStringz & CStringz::Upper(void) { // char *p=str; Refresh(); AnsiUpper(str); // for ( ; *p ; p++) *p=toupper(*p); return *this; }
/* ------------------------------------------------------------ */ int _export PASCAL FAR FtpSyst (LPCSTR FAR * szSystStr) { LPProcData pProcData; int Rc; char szBuffer[128]; /* chaine retournee par le serveur */ Rc= FtpAutomate (_S_SYST, NULL); if (Rc!=FTPERR_OK) return Rc; pProcData = ToolsLocateProcData (); AnsiUpper (pProcData->ftp.szInBuf); for ( Rc=0 ; szSystStr[Rc]!=NULL ; Rc++) { /* copier la chaine pour la comparaison en majuscules */ lstrcpyn (szBuffer, szSystStr[Rc], sizeof szBuffer); AnsiUpper (szBuffer); if (strstr (pProcData->ftp.szInBuf, szBuffer)!=NULL) return Rc; } return FTPERR_SYSTUNKNOWN; /* chaine non trouvee */ } /* FtpSyst */
// turn a file, relative path or other into an absolute path // This function copied from MFC 1.52 BOOL PASCAL _AfxFullPath(LPSTR lpszPathOut, LPCSTR lpszFileIn) // lpszPathOut = buffer of _MAX_PATH // lpszFileIn = file, relative path or absolute path // (both in ANSI character set) { OFSTRUCT of; if (OpenFile(lpszFileIn, &of, OF_PARSE) != HFILE_ERROR) { // of.szPathName is in the OEM character set OemToAnsi(of.szPathName, lpszPathOut); AnsiUpper(lpszPathOut); // paths in upper case just to be sure return TRUE; } else { TRACE1("Warning: could not parse the path %Fs\n", lpszFileIn); lstrcpy(lpszPathOut, lpszFileIn); // take it literally AnsiUpper(lpszPathOut); // paths in upper case just to be sure return FALSE; } }
VOID ACLStr::_UpperCase ( IN LPCTSTR strToFind, IN OUT LPTSTR upperFind, IN const int sizeUpperFind, IN OUT LPTSTR internalBuff, IN const int sizeInternalBuff ) { // First copy the buffer sent to us to the new // uppercase buffer. STRCPY_S(upperFind, sizeUpperFind, strToFind); AnsiUpper(upperFind); // Now copy the internal ACLStr buffer to the new // tempory Upper case version. if (_string) { STRCPY_S(internalBuff, sizeInternalBuff, _string); AnsiUpper(internalBuff); } } // _UpperCase
// P R I V A T E M E T H O D S int ACLStr::_FindCh ( IN const TCHAR charToFind, IN BOOL caseSensitive /*=TRUE*/, IN BOOL reverseFind /*=FALSE*/ ) { LPTSTR string = NULL; TCHAR ib[MAX_STRING]; // Initialize this to the // internal buffer. LPTSTR ibPtr = _string; TCHAR chToFind = charToFind; // If the internal string is NULL or the lenght is // zero then we will just bail and say we couldn't // find the string we were searching for. if (ibPtr != NULL || 0 != _length) { if (caseSensitive == TRUE) { chToFind = TOUPPER(charToFind); // Now copy the internal ACLStr buffer to the new // tempory Upper case version. if (_string) { // NOTE: STRCPY_S(target, length, source) - The length parameter is for // the length of the target string, not the source string. STRCPY_S(ib, MAX_STRING, _string); AnsiUpper(ib); ibPtr = ib; } } // case sensitive search? // Go look for the starting point of the string. // if we do NOT find it return STR_NOTFOUND if (reverseFind == TRUE) { string = STRRCHR(ibPtr, chToFind); } else { string = STRCHR(ibPtr, chToFind); } } // search string NULL? return (string == NULL) ? STR_NOTFOUND : (int)(string - ibPtr); } // ::_FindCh
int FAR PASCAL Soundex(char *in_pntr,LPSTR out_pntr) { char ch,last_ch; int count = 0; AnsiUpper(in_pntr); lstrcpy(out_pntr,"0000"); out_pntr[0]=toupper(*in_pntr); last_ch = get_scode(*in_pntr); while((ch = get_scode(*(++in_pntr)) ) && (count < 3) ) { if( (ch != '0') && (ch != last_ch) ) *(out_pntr+(++count)) = ch; last_ch = ch; } return(0); }
VOID APIENTRY GetInternational() { ENTER("GetInternational"); GetProfileString(szInternational, "sShortDate", szShortDate, szShortDate, 11); AnsiUpper(szShortDate); GetProfileString(szInternational, "sTime", szTime, szTime, 2); GetProfileString(szInternational, "s1159", sz1159, sz1159, 9); GetProfileString(szInternational, "s2359", sz2359, sz2359, 9); GetProfileString(szInternational, "sThousand", szComma, szComma, sizeof(szComma)); iTime = GetProfileInt(szInternational, "iTime", iTime); iTLZero = GetProfileInt(szInternational, "iTLZero", iTLZero); LEAVE("GetInternational"); }
//--------------------------------------------------------------------------- // ParseCommandLine // // This routine parses the command line given. If the command line is valid, // then it is assumed that the user's intention is to execute the test given // and then exit -- without using the UI for anything. Else, we display the // usage message box (if the cmdline wasn't valid), and return. // // RETURNS: NULL if cmdline was valid (script run made, or attempted), // or if command line was invalid and usage was given, // OR pointer to script to load if /RUN not present given. // // NOTE: If no script was given, this function returns a ptr // to a null string. //--------------------------------------------------------------------------- HANDLE *ParseCommandLine (LPSTR cmdline) { CHAR *tok, *scr; INT doit = 0, scriptfound = 0; static HANDLE hScr[9] = {NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL}; #ifdef DEBUG fDiags = 0; #endif // We always return at least one file name, so allocate it now //----------------------------------------------------------------------- listflag = 0; if (!(hScr[0] = LocalAlloc (LHND, 128))) { MPError (NULL, MB_OK | MB_ICONEXCLAMATION, IDS_OUTOFMEM); return (NULL); } scr = LocalLock (hScr[0]); // Return now if no cmdline args given //----------------------------------------------------------------------- scr[0] = 0; tok = GetCmdToken(cmdline); if (!tok) return (hScr); do { // Check here for the /T (testmode) switch and get its parameter //------------------------------------------------------------------- if (!_stricmp (tok, "/T") || !_stricmp (tok, "-T")) { tok = GetCmdToken(cmdline); if (!tok) { Usage(); return (NULL); } lstrcpy (tmbuf, tok); } // Here we check for /C (command) switch //------------------------------------------------------------------- else if (!_stricmp (tok, "/C") || !_stricmp (tok, "-C")) { tok = GetCmdToken(cmdline); if (!tok) { Usage(); return (NULL); } lstrcpy (cmdbuf, tok); } // /NOE (no error dialog) //------------------------------------------------------------------- else if (!_stricmp (tok, "/NOE") || !_stricmp (tok, "-NOE")) { NOERRDLG = 1; } // /A (filename) switch (produce assembly listing/diagnostics) //------------------------------------------------------------------- else if (!_stricmp (tok, "/A") || !_stricmp (tok, "-A")) { tok = GetCmdToken (cmdline); if (!tok) { Usage(); return (NULL); } SetAssemblyListFile (tok); } // /RUN switch //------------------------------------------------------------------- else if (!_stricmp (tok, "/RUN") || !_stricmp (tok, "-RUN")) { doit = 1; } #ifdef DEBUG else if (!_stricmp (tok, "/DIAG") || !_stricmp (tok, "-DIAG")) { fDiags = 1; } #endif // /D (define) switch //------------------------------------------------------------------- else if (!_stricmp (tok, "/D") || !_stricmp (tok, "-D")) { tok = GetCmdToken(cmdline); if (!tok) { Usage(); return (NULL); } if (SymCount == 16) { MPError (NULL, MB_OK | MB_ICONSTOP, IDS_MANYSYMBOLS); return (NULL); } _fstrncpy (DefSym[SymCount], tok, MAXSYMLEN); DefSym[SymCount++][MAXSYMLEN] = 0; } // If this was nothing above, we assume it's a script name //------------------------------------------------------------------- else if (scriptfound < 8) { if (!hScr[scriptfound]) { if (!(hScr[scriptfound] = LocalAlloc (LHND, 128))) { MPError (NULL, MB_OK | MB_ICONEXCLAMATION, IDS_OUTOFMEM); return (NULL); } scr = LocalLock (hScr[scriptfound]); } lstrcpy (scr, tok); LocalUnlock (hScr[scriptfound]); scriptfound += 1; } // Must have given too many script names //------------------------------------------------------------------- else { Usage (); return (NULL); } } while (tok = GetCmdToken(cmdline)); // No error dialog gets nullified if we're running the environment //----------------------------------------------------------------------- if (NOERRDLG && (!doit)) NOERRDLG = 0; // Return a pointer to the scripts given if no /RUN switch given //----------------------------------------------------------------------- if (!doit) return (hScr); // Give an error if no script name found, or more than one //----------------------------------------------------------------------- if (scriptfound != 1) { Usage (); return (NULL); } // Okay, we got a valid cmdline and we need to run. Send the script to // the parsing engine. // // NEW: Create a simple window which stays minimized and behind every // NEW: other window. The window text for this will contain the name // NEW: of the script running. //----------------------------------------------------------------------- EnsureExt (scr, 80); AnsiUpper (scr); Command = cmdbuf; TestMode = tmbuf; // KLUDGE: Call peekmessage to yield once... { MSG msg; CHAR buf[256], fmt[40]; PeekMessage (&msg, NULL, 0, 0, PM_NOREMOVE); // Change the window text of the viewport for this guy... //----------------------------------------------------------------------- if (LoadString (hInst, IDS_VPRUNTITLE, fmt, sizeof(fmt))) { wsprintf (buf, fmt, (LPSTR)scr); SetWindowText (hwndViewPort, buf); } } // Here's where we create the dummy window //----------------------------------------------------------------------- hwndDummy = CreateWindow (szRBRun, (LPSTR)scr, WS_OVERLAPPED|WS_SYSMENU, 0, 0, 0, 0, NULL, NULL, hInst, NULL); SetWindowPos (hwndDummy, (HWND)1, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE); ShowWindow (hwndDummy, SW_SHOWMINNOACTIVE); // Okay, here we go. //----------------------------------------------------------------------- if (InitParser ()) { // HACKHACK: ntbldrus (kenhia) - on x86, complains about uninit var // 41 lines below (in final else WITHIN this if block) HCURSOR hOld = 0; // Initialize the scanner //------------------------------------------------------------------- if (BeginScan (scr, CBLoaderImmediate, SymCount, DefPtrs)) { #ifdef DEBUG if (fDiags) OpenDiagFile (scr); #endif hOld = SetCursor (LoadCursor (NULL, IDC_WAIT)); if (!PcodeCompile()) { if (PcodeFixup(0)) { SetCursor (hOld); PcodeExecute(PE_RUN, NULL); DestroyWindow (hwndDummy); DestroyWindow (hwndViewPort); exit (ExitVal); } else { SetCursor (hOld); DestroyWindow (hwndDummy); DestroyWindow (hwndViewPort); exit (1); } } else { SetCursor (hOld); DestroyWindow (hwndDummy); DestroyWindow (hwndViewPort); exit (1); } EndScan (); } else { SetCursor (hOld); AbortParser(); MPError (NULL, MB_OK | MB_ICONSTOP, IDS_CANTREAD, (LPSTR)scr); DestroyWindow (hwndDummy); DestroyWindow (hwndViewPort); exit (1); } } else MPError (NULL, MB_OK | MB_ICONSTOP, IDS_CANTINIT); DestroyWindow (hwndViewPort); DestroyWindow (hwndDummy); exit (1); }
/* This function handles the WM_COMMAND message. */ void FASTCALL CmdSignatureDlg_OnCommand( HWND hwnd, int id, HWND hwndCtl, UINT codeNotify ) { switch( id ) { case IDD_LIST: if( codeNotify == CBN_SELCHANGE ) { HWND hwndList; HWND hwndEdit; int index; index = (int)GetWindowLong( hwnd, DWL_USER ); hwndEdit = GetDlgItem( hwnd, IDD_EDIT ); if( EditMap_GetModified( hwndEdit ) ) { if( !CmdSignatureDlg_SaveSig( hwnd, index ) ) break; fCancelToClose( hwnd, IDCANCEL ); } hwndList = GetDlgItem( hwnd, IDD_LIST ); index = ComboBox_GetCurSel( hwndList ); CmdSignatureDlg_DisplaySig( hwnd, index ); } break; case IDD_NEW: { char sz[ 9 ]; if( Adm_Dialog( hRscLib, hwnd, MAKEINTRESOURCE( IDDLG_NEWSIG ), NewSig, (LPARAM)(LPSTR)sz ) ) { HWND hwndList; HWND hwndEdit; int index; index = (int)GetWindowLong( hwnd, DWL_USER ); hwndEdit = GetDlgItem( hwnd, IDD_EDIT ); hwndList = GetDlgItem( hwnd, IDD_LIST ); if( EditMap_GetModified( hwndEdit ) && ComboBox_GetCount( hwndList ) > 0 ) if( !CmdSignatureDlg_SaveSig( hwnd, index ) ) break; AnsiUpper( sz ); if( ( index = ComboBox_FindStringExact( hwndList, -1, sz ) ) == LB_ERR ) index = ComboBox_AddString( hwndList, sz ); EnableControl( hwnd, IDOK, TRUE ); EnableControl( hwnd, IDD_DELETE, TRUE ); ComboBox_SetCurSel( hwndList, index ); CmdSignatureDlg_DisplaySig( hwnd, index ); fCancelToClose( hwnd, IDCANCEL ); SetFocus( hwndEdit ); } break; } case IDD_DELETE: { HWND hwndList; int index; hwndList = GetDlgItem( hwnd, IDD_LIST ); if( ( index = ComboBox_GetCurSel( hwndList ) ) != CB_ERR ) { char sz[ _MAX_FNAME ]; PCAT pcat; PCL pcl; PTL ptl; /* Get confirmation first. */ if( IDNO == fMessageBox( hwnd, 0, GS(IDS_STR975), MB_YESNO|MB_ICONINFORMATION ) ) break; /* Get the signature and delete the signature * file itself. */ ComboBox_GetLBText( hwndList, index, sz ); lstrcat( sz, ".sig" ); Ameol2_DeleteFile( sz, DSD_SIG ); /* Remove the signature from the listbox and display the * next one, if there is one. */ if( ComboBox_DeleteString( hwndList, index ) == index ) --index; if( index != CB_ERR ) { ComboBox_SetCurSel( hwndList, index ); CmdSignatureDlg_DisplaySig( hwnd, index ); } else { InvalidateRect( hwndList, NULL, FALSE ); UpdateWindow( hwndList ); EnableControl( hwnd, IDD_DELETE, FALSE ); EnableControl( hwnd, IDOK, FALSE ); Edit_SetText( GetDlgItem( hwnd, IDD_EDIT ), "" ); } /* For every topic which used the signature just deleted, * change it to the global signature. */ ComboBox_GetLBText( hwndList, index, sz ); for( pcat = Amdb_GetFirstCategory(); pcat; pcat = Amdb_GetNextCategory( pcat ) ) for( pcl = Amdb_GetFirstFolder( pcat ); pcl; pcl = Amdb_GetNextFolder( pcl ) ) for( ptl = Amdb_GetFirstTopic( pcl ); ptl; ptl = Amdb_GetNextTopic( ptl ) ) { TOPICINFO topicinfo; Amdb_GetTopicInfo( ptl, &topicinfo ); if( lstrcmp( topicinfo.szSigFile, sz ) == 0 ) Amdb_SetTopicSignature( ptl, szGlobalSig ); } fCancelToClose( hwnd, IDCANCEL ); } break; } case IDOK: { HWND hwndEdit; int index; index = (int)GetWindowLong( hwnd, DWL_USER ); hwndEdit = GetDlgItem( hwnd, IDD_EDIT ); if( EditMap_GetModified( hwndEdit ) ) if( !CmdSignatureDlg_SaveSig( hwnd, index ) ) break; EndDialog( hwnd, TRUE ); break; } case IDCANCEL: { HWND hwndEdit; hwndEdit = GetDlgItem( hwnd, IDD_EDIT ); if( EditMap_GetModified( hwndEdit ) ) { register int r; r = fMessageBox( hwnd, 0, GS(IDS_STR516), MB_YESNOCANCEL|MB_ICONINFORMATION ); if( r == IDCANCEL ) break; if( r == IDYES ) { int index; index = (int)GetWindowLong( hwnd, DWL_USER ); if( !CmdSignatureDlg_SaveSig( hwnd, index ) ) break; } } EndDialog( hwnd, FALSE ); break; } } }
/* Resets and fills the given combobox with a list of current * drives. The type of drive is stored with the item data. */ void FASTCALL DriveListInitialize(HWND hList, HWND hTempList, UINT iCurDrive ) { UINT i, iItem; UINT cch; UINT cItems; UINT iDrive, iType; char szDrive[ 10 ]; char szNet[ 64 ]; char szItem[ 68 ]; if( NULL == hList ) return; /* Clear out all the lists. */ ComboBox_ResetContent( hList ); ListBox_ResetContent( hTempList ); /* Get available drive letters in the temp list */ ListBox_Dir( hTempList, DDL_DRIVES | DDL_EXCLUSIVE, "*" ); iCurDrive -= 1; /* Fix for zero-based drive indexing */ /* Walk through the list of drives, parsing off the "[-" and "-]" * For each drive letter parsed, add a string to the combobox * composed of the drive letter and the volume label. We then * determine the drive type and add that information as the item data. */ cItems = ListBox_GetCount( hTempList ); for( i = 0; i < cItems; i++ ) { ListBox_GetText( hTempList, i, szDrive ); /* Ensure lowercase drive letters */ AnsiLower(szDrive); iDrive = szDrive[ 2 ] - 'a'; iType = AmDriveType( szDrive ); /* See Below */ if( iType < 2 ) /* Skip non-existent drive B's */ continue; /* Start the item string with the drive letter, color, and two spaces */ wsprintf( szItem, "%c%s", szDrive[ 2 ], (LPSTR)": " ); /* For fixed or ram disks, append the volume label which we find * using _dos_findfirst and attribute _A_VOLID. */ if( DRIVE_FIXED == iType || DRIVE_RAMDISK == iType ) { #ifdef WIN32 wsprintf( szDrive, "%c:\\", szDrive[ 2 ] ); GetVolumeInformation( szDrive, szItem + strlen( szItem ), 20, NULL, NULL, NULL, NULL, 0 ); #else FINDDATA fi; HFIND hFind; char ch; wsprintf( szDrive, "%c:\\*.*", szDrive[ 2 ] ); if( ( hFind = Amuser_FindFirst( szDrive, _A_VOLID, &fi ) ) != -1 ) { /* Convert volume to lowercase and strip any '.' in the name. */ AnsiLower( fi.name ); /* If a period exists, it has to be in position 8, so clear it. */ ch = fi.name[ 8 ]; fi.name[ 8 ] = 0; strcat( szItem, fi.name ); /* If we did have a broken volume name, append the last 3 chars */ if( '.' == ch ) strcat( szItem, &fi.name[ 9 ] ); } Amuser_FindClose( hFind ); #endif } /* For network drives, go grab the \\server\share for it. */ if( DRIVE_REMOTE == iType ) { szNet[ 0 ] = 0; cch = sizeof( szNet ); wsprintf( szDrive, "%c:", szDrive[ 2 ] ); AnsiUpper(szDrive); // if( WNetGetConnection( (LPSTR)szDrive, (LPSTR)szNet, &cch ) == NO_ERROR ) // { // AnsiLower(szNet); // strcat( szItem, szNet ); // } } iItem = ComboBox_AddString( hList, szItem ); ComboBox_SetItemData( hList, iItem, MAKELONG( iDrive, iType ) ); if( iDrive == iCurDrive ) ComboBox_SetCurSel( hList, iItem ); } }