/* ------------------------------------------------------------------- lsh_klist - ------------------------------------------------------------------- */ LONG KL_CALLTYPE KL_EXPORT lsh_klist (HANDLE hListBox, TICKETINFO FAR * lpti) { LPSTR lp1 ; // clear out list box SendMessage (hListBox, LB_RESETCONTENT, 0, 0L) ; // only list if we have a NetID if (lpFt->bAuthenticated == FALSE) return (0) ; // note: ctime() can't take a FAR pointer, so use the struct "directly" // append expired time, due to funky way ctime() works. Unfortunately, I can't // put this in 1 wsprintf() statement. Dooh! wsprintf (lpszTemp, "%s\t", (LPSTR)ctime(&ft.lTimeAcquired)) ; _fstrcat (lpszTemp, (LPSTR)ctime(&ft.lTimeExpires)) ; _fstrcat (lpszTemp, (LPSTR)"\t") ; _fstrcat (lpszTemp, lpFt->szNetID) ; // remove '\n' from ctime output if ((lp1 = _fstrchr(lpszTemp, '\n')) != NULL) { *lp1 = ' ' ; lp1++ ; if ((lp1 = _fstrchr(lpszTemp, '\n')) != NULL) *lp1 = ' ' ; } SendMessage (hListBox, LB_ADDSTRING, 0, (LPARAM)(LPCSTR)lpszTemp) ; return (0) ; }
/************************************* * * Search for a file in the given directory. * **************************************/ BOOL __far __pascal FindFile( char __far * szDir, char __far * szWildName, struct _find_t __far * FileInfo ) { char szFilesPath[_MAX_PATH]; short int LastCharPos; /* First time through. */ if( szDir != NULL ) { /* Build full path for search directory and wild name of file. */ _fstrcpy( szFilesPath, szDir ); /* Is there already a dir. separator? */ LastCharPos = ( _fstrlen( szFilesPath ) / sizeof(char) ) - 1; if( szFilesPath[LastCharPos] != DIR_CHAR_SEPARATOR ) { _fstrcat( szFilesPath, DIR_STRING_SEPARATOR ); } _fstrcat( szFilesPath, szWildName ); if( !_dos_findfirst( szFilesPath, _A_NORMAL, FileInfo ) ) return TRUE; } /* No first time through. */ else { if( !_dos_findnext( FileInfo ) ) return TRUE; } /* Failure. */ return FALSE; }
/*********************************************************************************************** * * Private Rountines * ************************************************************************************************/ static void __far __pascal GetINIPath( char __far * szINIPath ) { /* Get the windows directory. */ GetWindowsDirectory( szINIPath, _MAX_PATH ); /* Append the INI file path. */ _fstrcat( szINIPath, DIR_SEP_STR ); _fstrcat( szINIPath, INI_FILENAME ); }
WORD2DWORD FAR PASCAL MExtDeviceMode(HWND hWnd,LPSTR lpDriverName, LPDEVMODE lpDevModeOutput, LPSTR lpDeviceName, LPSTR lpPort, LPDEVMODE lpDevModeInput, LPSTR lpProfile, WORD2DWORD flMode) { HANDLE hmod; INT (APIENTRY *fpTarget)(HWND, HANDLE, LPDEVMODE, LPSTR, LPSTR, LPDEVMODE, LPSTR, WORD2DWORD); INT iRC; CHAR szAddDrv[13]; _fstrcpy(szAddDrv, lpDriverName); _fstrcat(szAddDrv, ".DRV"); hmod = LoadLibrary(szAddDrv); if (hmod < 32) { GlobalLastError = hmod; return(-1); } else { fpTarget = GetProcAddress(hmod, "ExtDeviceMode"); if (fpTarget == NULL) { GlobalLastError = ERROR_GETADDR_FAILED; FreeLibrary(hmod); return(-1); } else { iRC = (*fpTarget)(hWnd, hmod, lpDevModeOutput, lpDeviceName, lpPort, lpDevModeInput, lpProfile, flMode); FreeLibrary(hmod); return(iRC); } } }
BOOL FAR PASCAL MDeviceMode(HWND hWnd, LPSTR lpDriverName, LPSTR lpDeviceName, LPSTR lpOutput) { HANDLE hmod; INT (APIENTRY *fpTarget)(HWND, HANDLE, LPSTR, LPSTR); CHAR szAddDrv[13]; _fstrcpy(szAddDrv, lpDriverName); _fstrcat(szAddDrv, ".DRV"); hmod = LoadLibrary(szAddDrv); if (hmod < 32) { GlobalLastError = hmod; return(FALSE); } fpTarget = GetProcAddress(hmod, "DeviceMode"); if (fpTarget == NULL) { GlobalLastError = ERROR_GETADDR_FAILED; FreeLibrary(hmod); return(FALSE); } else { (*fpTarget)(hWnd, hmod, lpDeviceName, lpOutput); FreeLibrary(hmod); return(TRUE); } }
DWORD FAR PASCAL MDeviceCapabilities(LPSTR lpDriverName, LPSTR lpDeviceName, LPSTR lpPort, WORD2DWORD nIndex, LPSTR lpOutput, LPDEVMODE lpDevMode) { HANDLE hmod; INT (APIENTRY *fpTarget)(LPSTR, LPSTR, WORD, LPSTR, LPDEVMODE); INT iRC; CHAR szAddDrv[13]; _fstrcpy(szAddDrv, lpDriverName); _fstrcat(szAddDrv, ".DRV"); hmod = LoadLibrary(szAddDrv); if (hmod < 32) { GlobalLastError = hmod; return(-1L); } else { fpTarget = GetProcAddress(hmod, "DeviceCapabilitiesEx"); if (fpTarget == NULL) { GlobalLastError = ERROR_GETADDR_FAILED; FreeLibrary(hmod); return(-1L); } else { iRC = (*fpTarget)(lpDeviceName, lpPort, nIndex, lpOutput, lpDevMode); FreeLibrary(hmod); return(iRC); } } }
//================================================================================== // _FormatLongs(void FAR *pdata, long count) // //================================================================================== static VOID NEAR PASCAL _FormatLongs(sBYTE FAR *pData, long count, sBYTE FAR *msg) { uBYTE temp[32]; short i; for (i = 0 ; i < count; ++i) { ConvertNumberToString(*((long *)pData), (sBYTE *)temp, 8); if (_fstrlen(msg) + _fstrlen(temp) + 1 < sizeof(SZMSGBUF)) { _fstrcat(msg, temp); _fstrcat(msg, _szSpace); pData += sizeof(sLONG); } } }
/*----------------------------------------------- Helper function to keep the title bar and the switch entry up to date. -----------------------------------------------*/ VOID SetSwitchEntry(HWND hwnd, PSZ szTitleBar, PSZ szFract) { PID pid; static SWCNTRL swcntrl; static HSWITCH hswitch = NULL; HWND hwndFrame; hwndFrame = WinQueryWindow (hwnd, QW_PARENT, FALSE); if (hswitch == (HSWITCH) NULL) { /* if first time */ /* get our process ID for the Switch structure */ WinQueryWindowProcess(hwndFrame, &pid, NULL); /* add/change switch list entry */ swcntrl.hwnd = hwndFrame; swcntrl.hwndIcon = (HWND) NULL; swcntrl.hprog = (HPROGRAM) NULL; swcntrl.idProcess = pid; swcntrl.idSession = 0; swcntrl.uchVisibility = SWL_VISIBLE; swcntrl.fbJump = SWL_JUMPABLE; _fstrcpy( swcntrl.szSwtitle, szTitleBar); strcat( swcntrl.szSwtitle, " - "); _fstrcat( swcntrl.szSwtitle, szFract); swcntrl.fReserved = '\0'; hswitch = WinAddSwitchEntry( &swcntrl ); } else { /* do an update */ _fstrcpy( swcntrl.szSwtitle, szTitleBar); strcat( swcntrl.szSwtitle, " - "); _fstrcat( swcntrl.szSwtitle, szFract); WinChangeSwitchEntry( hswitch, &swcntrl); } /* now put it in the titlebar also */ WinSetWindowText(hwndFrame, swcntrl.szSwtitle); }
/**************************************************** ** ** Save last position and size of main help window. ** ****************************************************/ void __far __pascal WriteLastMainWndPos( WINDOWPLACEMENT __far * WndPlacePtr ) { char szNumber[ 8 ]; char szString[ MAX_WNDPOS_STRING ]; char szINIFilePath[ _MAX_PATH ]; /* Get path to the INI file. */ GetINIPath( szINIFilePath ); /* If maximized. */ if( WndPlacePtr->showCmd == SW_SHOWMAXIMIZED ) { /* Save window state. */ itoa( TRUE, szNumber, 10 ); _fstrcpy( szString, szNumber ); } /* If not maximized. */ else { /* Save window state. */ itoa( FALSE, szNumber, 10 ); _fstrcpy( szString, szNumber ); _fstrcat( szString, INI_WNDPOS_TOKEN ); /* Process x position. */ itoa( WndPlacePtr->rcNormalPosition.left, szNumber, 10 ); _fstrcat( szString, szNumber ); _fstrcat( szString, INI_WNDPOS_TOKEN ); /* Process y position. */ itoa( WndPlacePtr->rcNormalPosition.top, szNumber, 10 ); _fstrcat( szString, szNumber ); _fstrcat( szString, INI_WNDPOS_TOKEN ); /* Process width position. */ itoa( WndPlacePtr->rcNormalPosition.right, szNumber, 10 ); _fstrcat( szString, szNumber ); _fstrcat( szString, INI_WNDPOS_TOKEN ); /* Process height position. */ itoa( WndPlacePtr->rcNormalPosition.bottom, szNumber, 10 ); _fstrcat( szString, szNumber ); } /* Write entry "LastPos" */ WritePrivateProfileString( INI_GENERAL_SECTION, INI_WNDPOS_ENTRY, szString, szINIFilePath ); }
void TestMoveF( void ) { char bufA[80] = "FoO baR gOoBeR bLaH"; char bufB[80]; char __far *bufPtr; char __far *newBuf; int status; bufPtr = _fstrcpy( bufB, "FoO baR" ); /* copy string */ VERIFY( bufPtr == bufB ); bufPtr = _fstrcat( bufB, " gOoBeR bLaH" ); /* append the rest */ VERIFY( bufPtr == bufB ); status = _fstrcmp( bufA, bufB ); /* check result */ VERIFY( status == 0 ); bufPtr = _fstrset( bufB, 0x00 ); /* zero out buffer */ VERIFY( bufPtr == bufB ); bufPtr = _fstrncpy( bufB, "ABCDEFGHIJ", 2 );/* copy two bytes */ VERIFY( bufPtr == bufB ); bufPtr = _fstrncat( bufB, "CDEFGHIJ", 3 ); /* copy three more */ VERIFY( bufPtr == bufB ); status = _fstrcmp( bufB, "ABCDE" ); /* ensure only five bytes */ VERIFY( status == 0 ); bufPtr = _fstrnset( bufB, 0x00, 10 ); /* blank string */ VERIFY( bufPtr == bufB ); status = _fstrcmp( bufB, "" ); /* verify empty */ VERIFY( status == 0 ); bufPtr = _fstrcpy( bufB, "abcdefghij" ); /* copy string */ VERIFY( bufPtr == bufB ); bufPtr = _fstrrev( bufB ); /* reverse it */ VERIFY( bufPtr == bufB ); status = _fstrcmp( bufB, "jihgfedcba" ); /* ensure reversed ok */ VERIFY( status == 0 ); newBuf = _fstrdup( bufA ); /* duplicate string */ status = _fstrcmp( bufA, newBuf ); VERIFY( status == 0 ); }
void FAR PASCAL AmpStaPnt (HWND hWnd, const AMPDES FAR *lpAmpDes, const AMPUSR FAR *lpAmpUsr) { PAINTSTRUCT ps; char szTxtBuf[AMPMAXSTR]; DWORD ulSelBeg; DWORD ulSelEnd; WORD usTotWid; /* Total window width */ HFONT hFixFnt; HFONT hOldFnt; RECT rShdRec; /* Shd rec outer bounds */ HDC hDC; /********************************************************************/ /********************************************************************/ GetClientRect (hWnd, &rShdRec); usTotWid = rShdRec.right; /********************************************************************/ /********************************************************************/ hDC = BeginPaint (hWnd, &ps); /* Prepare the client area */ SetBkMode (hDC, TRANSPARENT); /********************************************************************/ /********************************************************************/ hFixFnt = CreFntFix (hDC, AmpGlo.usFntSiz, rShdRec); hOldFnt = SelectObject (hDC, hFixFnt); /********************************************************************/ /* Display document length position */ /********************************************************************/ MsgLodStr (AmpGlo.hLibIns, SI_EXTSEGLEN, szTxtBuf, AMPMAXSTR); _fdtorna ((lpAmpDes->ulDocLen) / (float) lpAmpDes->ulSmpFrq, AmpGlo.usDecPrc, &szTxtBuf[_fstrlen(szTxtBuf)]); MsgCatStr (SI_EXTSEGSEC, szTxtBuf, AMPMAXSTR); rShdRec.left = ShdRecTxt (hDC, szTxtBuf, rShdRec, usTotWid); /********************************************************************/ /* Display "at" position */ /********************************************************************/ MsgLodStr (AmpGlo.hLibIns, SI_EXTSEGATP, szTxtBuf, AMPMAXSTR); _fdtorna ((lpAmpUsr->ulPosAtP) / (float) lpAmpDes->ulSmpFrq, AmpGlo.usDecPrc, &szTxtBuf[_fstrlen(szTxtBuf)]); MsgCatStr (SI_EXTSEGSEC, szTxtBuf, AMPMAXSTR); rShdRec.left = ShdRecTxt (hDC, szTxtBuf, rShdRec, usTotWid); /********************************************************************/ /* Display selection extents & length */ /********************************************************************/ if (GetSelFTo (lpAmpUsr, &ulSelBeg, &ulSelEnd)) { /****************************************************************/ /* Display text fields */ /****************************************************************/ _fdtorna (ulSelBeg / (float) lpAmpDes->ulSmpFrq, AmpGlo.usDecPrc, szTxtBuf); MsgCatStr (SI_EXTSEGSYM, szTxtBuf, AMPMAXSTR); _fdtorna (ulSelEnd / (float) lpAmpDes->ulSmpFrq, AmpGlo.usDecPrc, &szTxtBuf[_fstrlen(szTxtBuf)]); _fstrcat (szTxtBuf, " ("); _fdtorna ((ulSelEnd - ulSelBeg) / (float) lpAmpDes->ulSmpFrq, AmpGlo.usDecPrc, &szTxtBuf[_fstrlen(szTxtBuf)]); MsgCatStr (SI_EXTSEGSEC, szTxtBuf, AMPMAXSTR); _fstrcat (szTxtBuf, ")"); rShdRec.left = ShdRecTxt (hDC, szTxtBuf, rShdRec, usTotWid); /****************************************************************/ /* Display current window overview */ /* Display selection region overview */ /****************************************************************/ ShdRecRec (hDC, rShdRec, lpAmpDes->ulSmpOff, lpAmpDes->ulSmpOff + (DWORD) (lpAmpDes->flSmppGP * lpAmpDes->usArrLen), lpAmpDes->ulDocLen, AmpGlo.hOvrPen, AmpGlo.hOvrBsh); ShdRecRec (hDC, rShdRec, ulSelBeg, ulSelEnd, lpAmpDes->ulDocLen ? lpAmpDes->ulDocLen : (DWORD) (lpAmpDes->flSmppGP * lpAmpDes->usArrLen), AmpGlo.hSOvPen, GetStockObject (NULL_BRUSH)); } else { /****************************************************************/ /* Display current window overview only */ /****************************************************************/ ShdRecRec (hDC, rShdRec, lpAmpDes->ulSmpOff, lpAmpDes->ulSmpOff + (DWORD) (lpAmpDes->flSmppGP * lpAmpDes->usArrLen), lpAmpDes->ulDocLen, AmpGlo.hLgtPen, AmpGlo.hOvrBsh); } /********************************************************************/ /********************************************************************/ rShdRec.right = usTotWid; ShdRecBox (hDC, rShdRec, AmpGlo.hShdPen, AmpGlo.hLgtPen); /********************************************************************/ /********************************************************************/ SelectObject (hDC, hOldFnt); DeleteObject (hFixFnt); /********************************************************************/ /********************************************************************/ EndPaint (hWnd, &ps); /* Done painting for now */ }
/*-------------------------------------------------------------------------- * Function: _tdb_DoAssertDlg * Expects: char FAR * lpszTest * char FAR * lpszReason * char FAR * lpszFilename * uLONG ulLineNo * uLONG ulCount * void FAR * lpvData * uLONG ulFormat * Returns: int iUserSelection * Purpose: Setup and run the Macintosh Assertion Dialog * History: 10/28/94 MGD - Initial Revision *-------------------------------------------------------------------------- */ TDBAPI( int ) _tdb_DoAssertDlg( LPSZ lpszTest, LPSZ lpszReason, LPSZ lpszFilename, uLONG ulLineNo, uLONG ulCount, LPVOID lpvData, uLONG ulFormat ) { int iUserSelection = ID_OK; // In order to prevent possible nesting of DoAssertDlg. Only enter this section // if we are not currently displaying an Assert. In a true pre-emptive multi-threaded app // there is a small chance that we may execute the test and be paged out before setting // the boolean, but it is a small enough change that I am not going to worry about it for now. if ( !fInDoAssertDialog ) { fInDoAssertDialog = TRUE; if (_hDlgTemplate) { // Hey, Dude! DLGVALS dlgVals; FARPROC lpDlgTest = MakeProcInstance( (FARPROC) _tdb_AssertDlgProc, g_tdb_hinstApp ); dlgVals.lpszTest = lpszTest? lpszTest : _szEmpty; dlgVals.lpszReason = lpszReason? lpszReason : _szEmpty; dlgVals.lpszFilename = lpszFilename? lpszFilename : _szUnknown; dlgVals.ulLineNo = ulLineNo; dlgVals.ulCount = ulCount; dlgVals.lpvData = lpvData; dlgVals.ulFormat = ulFormat; dlgVals.hStackData = g_tdb_hStackData; iUserSelection = DialogBoxIndirectParam( g_tdb_hinstApp, _hDlgTemplate, g_tdb_hwndApp, lpDlgTest, (LPARAM)&dlgVals); FreeProcInstance(lpDlgTest); } else { int iret; int iApproxMessageSize; // To count the potential size of the message to make sure I // don't overflow the szMessageBufferSize sBYTE FAR* szBuf; iApproxMessageSize = wsprintf( _szMessageBoxBuffer, "%s%s\n%s%ld\n\n", _szFile, lpszFilename, _szLineNo, ulLineNo ); szBuf = _szMessageBoxBuffer + iApproxMessageSize; iApproxMessageSize += _fstrlen( lpszReason ); iApproxMessageSize += 256; // 256 is an unofficial size for the amount of data that will // be visible in an Assert as extra data // If there is any data to add and a rough calculation implies that the data will fit // in the buffer, include it. Otherwise, don't include it if ((ulCount > 0) && (iApproxMessageSize<MESSAGE_BUFFER_SIZE)) { switch (ulFormat) { case 'b': case 'B': _FormatBytes((sBYTE FAR*)lpvData, ulCount, szBuf); break; case 'w': case 'W': _FormatWords((sBYTE FAR*)lpvData, ulCount, szBuf); break; case 'l': case 'L': _FormatLongs((sBYTE FAR*)lpvData, ulCount, szBuf); break; case 's': case 'S': _FormatCStr((sBYTE FAR*)lpvData, szBuf); break; case 'p': case 'P': _FormatPStr((sBYTE FAR*)lpvData, szBuf); break; } _fstrcat( _szMessageBoxBuffer, _szCRLF ); _fstrcat( _szMessageBoxBuffer, _szCRLF ); } // Add the Reason to the buffer _fstrcat( _szMessageBoxBuffer, lpszReason ); iret = MessageBox(NULL, _szMessageBoxBuffer, ((lpszTest)? lpszTest : _szAssertFailed), MB_YESNOCANCEL | MB_TASKMODAL); switch (iret) { case IDYES: iUserSelection = ID_OK; break; case IDNO: iUserSelection = ID_TERMINATE; break; default: iUserSelection = ID_DEBUGGER; break; } } fInDoAssertDialog = FALSE; } return iUserSelection; }
/************************************* * * Search for a file in the following places: * - Current dir. * - /WINDOWS * - /WINDOWS/SYSTEM * - All directories listed in the system's $PATH$ variable. * * Call EnumFilesProc() if a matching file is found. * **************************************/ BOOL __export __far __pascal EnumFiles( char __far * szWildName, FILESENUMPROC EnumFilesProc, LPARAM lParam, BOOL Yield ) { char szWinDir[_MAX_PATH]; char szWinSysDir[_MAX_PATH]; char szCurrentDir[_MAX_PATH]; char szDir[_MAX_PATH]; char szFilePath[_MAX_PATH]; char szPathCopyBuffer[_MAX_PATH]; char __far * szPathCopy; char __far * szPath; char __far * szNextPath; struct _find_t FileInfo; int nPhase, nResult; BOOL bCallBack; MSG Msg; // Storage for messages pulled from windows message // queue. short int LastCharPos; /* Each phase equates to a different search path. */ for( nPhase = 1; nPhase < 5; nPhase ++ ) { /* If we should let other applications execute. */ if( Yield ) { while ( PeekMessage( &Msg, NULL, NULL, NULL, PM_REMOVE ) ) { TranslateMessage( &Msg ); DispatchMessage( &Msg ); } } switch( nPhase ) { /* PHASE 1: use current directory. */ case 1: getcwd( szDir, _MAX_PATH ); _fstrcpy( szCurrentDir, szDir ); break; /* PHASE 2: use windows directory */ case 2: GetWindowsDirectory( szDir, _MAX_PATH); _fstrcpy( szWinDir, szDir ); break; /* PHASE 3: use windows\system directory */ case 3: GetSystemDirectory( szDir, _MAX_PATH); _fstrcpy( szWinSysDir, szDir ); break; } /* For Phases #1 - #3. */ if( nPhase < 4 ) { if( FindFile( szDir, szWildName, &FileInfo ) ) { /* Start with file's path. */ _fstrcpy( szFilePath, szDir ); /* Is there already a dir. separator? */ LastCharPos = ( _fstrlen( szFilePath ) / sizeof(char) ) - 1; if( szFilePath[LastCharPos] != DIR_CHAR_SEPARATOR ) { _fstrcat( szFilePath, DIR_STRING_SEPARATOR ); } /* Use filename. */ _fstrcat( szFilePath, FileInfo.name ); /* Call EnumFilesProc() callback function. */ bCallBack = ( *EnumFilesProc )( szFilePath, lParam ); /* Does callback tell us to quit. */ if( !bCallBack ) return TRUE; /* Any more file? */ while( FindFile( NULL, NULL, &FileInfo ) ) { /* Start with file's path. */ _fstrcpy( szFilePath, szDir ); /* Is there already a dir. separator? */ LastCharPos = ( _fstrlen( szFilePath ) / sizeof(char) ) - 1; if( szFilePath[LastCharPos] != DIR_CHAR_SEPARATOR ) { _fstrcat( szFilePath, DIR_STRING_SEPARATOR ); } /* Use filename. */ _fstrcat( szFilePath, FileInfo.name ); /* Call EnumFilesProc() callback function. */ bCallBack = ( *EnumFilesProc )( szFilePath, lParam ); /* Does callback tell us to quit. */ if( !bCallBack ) return TRUE; } } } /* For Phase #4 - Use PATH. */ else { /* Is there a WIN_PATH set? */ szPath = getenv("WIN_PATH"); /* If no WIN_PATH set, use standard PATH variable. */ if( szPath == NULL ) szPath = getenv( "PATH" ); /* If we have some path to search. */ if( szPath != 0) { /* Make a copy of the path so that we can change with the copy. */ lstrcpy( (LPSTR) szPathCopyBuffer, (LPSTR) szPath ); szPathCopy = szPathCopyBuffer; /* Walk the path... */ for( szNextPath = szPathCopy; szNextPath && *szNextPath; szNextPath = szPathCopy) { /* If we should let other applications execute. */ if( Yield ) { while ( PeekMessage( &Msg, NULL, NULL, NULL, PM_REMOVE ) ) { TranslateMessage( &Msg ); DispatchMessage( &Msg ); } } /* Get the next element in the path and terminate it */ szPathCopy = strchr( szNextPath, AUTOEXEC_PATH_DELIMITER ); if( szPathCopy ) { *szPathCopy = 0; /* End the current part. */ szPathCopy++; /* Point to the next one. */ } /* If it's a directory that we've already visited - skip search. */ nResult = _fstricmp( szNextPath, szWinDir ); /* \Windows dir. */ if( nResult == 0 ) continue; nResult = _fstricmp( szNextPath, szWinSysDir ); /* \Windows\System dir. */ if( nResult == 0 ) continue; nResult = _fstricmp( szNextPath, szCurrentDir ); /* Original dir. */ if( nResult == 0 ) continue; if( FindFile( szNextPath, szWildName, &FileInfo ) ) { /* Start with file's path. */ _fstrcpy( szFilePath, szNextPath ); /* Is there already a dir. separator? */ LastCharPos = ( _fstrlen( szFilePath ) / sizeof(char) ) - 1; if( szFilePath[LastCharPos] != DIR_CHAR_SEPARATOR ) { _fstrcat( szFilePath, DIR_STRING_SEPARATOR ); } /* Use filename. */ _fstrcat( szFilePath, FileInfo.name ); /* Call EnumFilesProc() callback function. */ bCallBack = ( *EnumFilesProc )( szFilePath, lParam ); /* Does callback tell us to quit. */ if( !bCallBack ) return TRUE; while( FindFile( NULL, NULL, &FileInfo ) ) { /* Start with file's path. */ _fstrcpy( szFilePath, szNextPath ); /* Is there already a dir. separator? */ LastCharPos = ( _fstrlen( szFilePath ) / sizeof(char) ) - 1; if( szFilePath[LastCharPos] != DIR_CHAR_SEPARATOR ) { _fstrcat( szFilePath, DIR_STRING_SEPARATOR ); } /* Use filename. */ _fstrcat( szFilePath, FileInfo.name ); /* Call EnumFilesProc() callback function. */ bCallBack = ( *EnumFilesProc )( szFilePath, lParam ); /* Does callback tell us to quit. */ if( !bCallBack ) return TRUE; } } } } } } /* for loop. */ /* Return success. */ return( TRUE ); }
void writedriveletter(cwindow *pwin0, cwindow *pwin1) { char str[65],strX[35],strPriOrLog[10],strActive[10],szfat[9]; YG_PARTITION_INFO *p; BYTE btitem = 0; MID mid; //find disk number p = g_pCurFixDiskInfo; while(p != NULL) { g_pCurFixDiskInfo = g_pCurFixDiskInfo->pNext; free(g_pCurFixDiskInfo); p = g_pCurFixDiskInfo; } GetFixDiskInfo(pwin0->m_pitemactive->btItem); p = g_pCurFixDiskInfo; pwin1->emptyitem(); pwin1->emptyscreen(); while(p != NULL) { _fmemset(str,0x20,65); _fstrcpy(str, SELPREFIX); if(p->dwSystemFlag) { if((int)p->DriveLetter< 0x40 ) { _fmemset(szfat,32,9); _fstrcat(str, " "); str[SELPREFIXLEN]='*'; str[9]= 0x20; switch(p->dwSystemFlag) { case 0x0b: case 0x0c: _fmemcpy(szfat,"FAT32",5); break; case 0x01: case 0x04: case 0x06: case 0x0e: _fmemcpy(szfat, "FAT",3); break; case 0x1b: case 0x1c: _fmemcpy(szfat, "H-FAT32",7); break; case 0x11: case 0x14: case 0x16: case 0x1e: _fmemcpy(szfat, "H-FAT",5); break; case 0x17: _fmemcpy(szfat, "H-NTFS",6); break; case 0x07: _fmemcpy(szfat, "NTFS",4); break; case 0x82: _fmemcpy(szfat, "LinSwap",7); break; case 0x83: _fmemcpy(szfat, "LinExt2",7); break; default: if(!p->dwSystemFlag) _fmemcpy(szfat,"FREE",4); else sprintf(szfat,UNKNOWNFILESYSTEM,p->dwSystemFlag); break; } for(int i=0; i<9; i++) if(szfat[i]==0) szfat[i]=32; _fmemcpy(&str[19],szfat,8); str[27]=0; if(p->bLogic) _fstrcpy(strPriOrLog,"LOGICAL"); else _fstrcpy(strPriOrLog,"PRIMARY"); _fstrcpy(strActive," - "); sprintf(strX,PAR,p->dwPartSize/2048,strActive,strPriOrLog); _fstrcat(str,strX); } else { _fmemset(&mid,0x20,sizeof(MID)); GetMID(p->DriveLetter-'A'+1,&mid); _fstrcat(str, " :\\"); str[SELPREFIXLEN] = p->DriveLetter; for(int i=0; i<11; i++) { if(mid.midVolLabel[i]==0) mid.midVolLabel[i]=0x20; } _fmemcpy(&str[SELPREFIXLEN+3],mid.midVolLabel,11); switch(p->dwSystemFlag) { case 0x0b: case 0x0c: _fmemcpy(&str[19],"FAT32 ",8); break; case 0x01: case 0x04: case 0x06: case 0x0e: _fmemcpy(&str[19],"FAT ",8); break; default: break; } str[27]=0; if(p->bLogic) _fstrcpy(strPriOrLog,"LOGICAL"); else _fstrcpy(strPriOrLog,"PRIMARY"); if(p->BootFlag==0x80) _fstrcpy(strActive,"Active"); else _fstrcpy(strActive," - "); if(p->BootFlag!=0x80) sprintf(strX,PAR,p->dwPartSize/2048,strActive,strPriOrLog); else sprintf(strX,PAR1,p->dwPartSize/2048,strActive,strPriOrLog); _fstrcat(str,strX); } pwin1->additemNotSort(str,btitem); } p = p->pNext; btitem ++; } pwin1->enabledscroll(); }
///////////////////////////////////////////////////////////////////////////// // // OPERATION: EnqueueInstance // // PARAMETERS: zVIEW vInstance - View to the instance to be enqueued // zPCHAR szEntityNames - A string containing 1 or // more entity names on which to enqueue // the instance. The first entity name // MUST BE the root of the object and // the remaining entity names MUST be // separated by the plus '+' character. // // RETURN CODES: 0 - Enqueue successful // 1 - Enqueue unsuccessful, the instance is already // Enqueued // zCALL_ERROR - Enqueue unsuccessful, error in processing // ///////////////////////////////////////////////////////////////////////////// zSHORT OPERATION EnqueueInstance( zVIEW vInstance, zPCHAR szEntityNames ) { zVIEW vEnqueue; zVIEW vEnqueueHolder; zVIEW vQual; zVIEW vWkInstance; zPCHAR szEntityNamePtr; zCHAR szCurrentEntity[ 34 ]; zCHAR szLevel[ 2 ]; zSHORT nEntity, nEnqueue, nIdx, nRC, nRetries; zLONG lER_Token; zCHAR szTimestamp[ 6 ]; zCHAR szObjectName[ 34 ]; zCHAR szUserID[ 34 ]; zCHAR szPassword[ 34 ]; zCHAR szKey[ 64 ]; zCHAR szMsg[ 256 ]; // We put the enqueue logic in a for loop so we can restart the // enqueue if the enqueue fails and we cannot find the owner of // the enqueue. nRetries = 4; if ( MiGetObjectNameForView( szObjectName, vInstance ) < 0 ) return( zCALL_ERROR ); for ( ; ; ) { // Set up work variables szEntityNamePtr = szEntityNames; _fstrcpy( szLevel, "R" ); nEntity = nEnqueue = 0; // Set up a multiple root instance for enqueueing if ( ActivateEmptyObjectInstance( &vEnqueue, szlCGENQUEU, vInstance, zMULTIPLE ) != 0 ) { return( zCALL_ERROR ); } // Create a view on the instance so we do not step on the applications // cursor positions. CreateViewFromViewForTask( &vWkInstance, vInstance, 0 ); // Get timestamp and user information for enqueue MiGetDateTimeForOI( szTimestamp, vWkInstance ); SysGetUserID( vInstance, szUserID, szPassword ); if ( szUserID[ 0 ] == 0 ) _fstrcpy( szUserID, "(null)" ); // Loop for each entity type to be enqueued while ( szEntityNamePtr[ 0 ] ) { // Gather the next entity name on which to enqueue nIdx = 0; while ( szEntityNamePtr[ 0 ] && szEntityNamePtr[ 0 ] != '+' ) { szCurrentEntity[ nIdx++ ] = szEntityNamePtr[ 0 ]; szEntityNamePtr++; } szCurrentEntity[ nIdx ] = 0; if ( szEntityNamePtr[ 0 ] == '+' ) szEntityNamePtr++; nEntity++; // Now that an entity name has been gathered, troll the instance // for every occurrence of that entity type and create an // enqueue instance for it nRC = SetCursorFirstEntity( vWkInstance, szCurrentEntity, zSCOPE_OI ); if ( nRC == zCALL_ERROR ) { DropView( vWkInstance ); DropObjectInstance( vEnqueue ); return( zCALL_ERROR ); } if ( nRC >= zCURSOR_SET ) { lER_Token = MiGetERTokenForEntity( vWkInstance, szCurrentEntity ); do { // Set up an enqueue instance, The ER_Token and the Instance // key are the unique keys to the object, a duplicate instance // on the database will result in an enqueue failure with the // instance in use. The UserID combined with the Timestamp is // the non-unique key for deletion of a logical enqueue. // The object name and level ( 'R' - root, 'C' - child ) are // informational only. CreateEntity( vEnqueue, szlEnqueue, zPOS_AFTER ); SetAttributeFromInteger( vEnqueue, szlEnqueue, szlER_Token, lER_Token ); MiGetKeyFromInstance( szKey, 61, vWkInstance, szCurrentEntity ); SetAttributeFromString( vEnqueue, szlEnqueue, szlInstanceKey, szKey ); SetAttributeFromVariable( vEnqueue, szlEnqueue, szlTimestamp, szTimestamp, zTYPE_DATETIME, 6, 0, 0 ); SetAttributeFromString( vEnqueue, szlEnqueue, szlType, "U" ); SetAttributeFromString( vEnqueue, szlEnqueue, szlUser, szUserID ); SetAttributeFromString( vEnqueue, szlEnqueue, szlObject, szObjectName ); SetAttributeFromString( vEnqueue, szlEnqueue, szlLevel, szLevel ); nEnqueue++; } while ( SetCursorNextEntity( vWkInstance, szCurrentEntity, zSCOPE_OI ) >= zCURSOR_SET ); } // After processing an entity type, all other enqueues are at the // child level szLevel[ 0 ] = 'C'; } // Now that we're done gathering the enqueue information, we can drop // the view to the instance DropView( vWkInstance ); // The enqueue instance has been built, now it is time to insert it // into the database for locking the instance. nRC = CommitObjectInstance( vEnqueue ); if ( nRC != zDUPLICATE_ROOT ) { DropObjectInstance( vEnqueue ); return( nRC ); } // The enqueue failed, now we will determine the owner of the enqueue // to see if we are conflicting with ourself or to report the owner // to the enqueue requestor SetCursorFirstEntity( vEnqueue, szlEnqueue, 0 ); do { fnBuildQualForEnqueue( vEnqueue, &vQual ); nRC = ActivateObjectInstance( &vEnqueueHolder, szlCGENQUEU, vInstance, vQual, zSINGLE ); DropObjectInstance( vQual ); if ( nRC < -1 ) return( zCALL_ERROR ); else if ( nRC >= 0 ) break; else DropObjectInstance( vEnqueueHolder ); } while ( SetCursorNextEntity( vEnqueue, szlEnqueue, 0 ) >= zCURSOR_SET ); // If the enqueue holder was not found, then the enqueue may have // disappeared while trying to find the holder, retry the enqueue // operation. nRetries--; if ( nRC == -1 ) { if ( nRetries == 0 ) return( zCALL_ERROR ); } // Report on the enqueue holder GetStringFromAttribute( szKey, vEnqueueHolder, szlEnqueue, szlUser ); GetStringFromAttribute( &szKey[ 30 ], vEnqueueHolder, szlEnqueue, szlObject ); // if the current enqueue holder is the current user for the // same object type, then offer to drop the previous enqueue and // re-establish the enqueue for the current user if ( _fstrcmp( szUserID, szKey ) == 0 && _fstrcmp( szObjectName, &szKey[ 30 ] ) == 0 && nRetries ) { // we will retry this once and once only nRetries = 1; _fstrcpy( szMsg, "The " ); _fstrcat( szMsg, szObjectName ); _fstrcat( szMsg, " is already enqueued by you in this session or" " a previous session. Would you like to release" " the previously held enqueue?" ); nRC = MessagePrompt( vInstance, "1", szlEnqueue, szMsg, 0, zBUTTONS_YESNO, zRESPONSE_YES, zICON_QUESTION ); if ( nRC == zRESPONSE_NO ) { DropObjectInstance( vEnqueue ); DropObjectInstance( vEnqueueHolder ); return( 1 ); } // The user wants to delete a previous enqueue for the same // object type, build the qualification for the delete and remove // the prior enqueue. fnBuildQualForEnqueueDelete( vEnqueueHolder, &vQual ); DropObjectInstance( vEnqueueHolder ); nRC = ActivateObjectInstance( &vEnqueueHolder, szlCGENQUEU, vInstance, vQual, zMULTIPLE ); DropObjectInstance( vQual ); if ( nRC < 0 ) return( zCALL_ERROR ); nRC = SetCursorFirstEntity( vEnqueueHolder, szlEnqueue, 0 ); while ( nRC >= zCURSOR_SET ) nRC = DeleteEntity( vEnqueueHolder, szlEnqueue, zREPOS_NEXT ); nRC = CommitObjectInstance( vEnqueueHolder ); DropObjectInstance( vEnqueueHolder ); // If the attempt to reuse the enqueue failed on a database error, // return that error. Otherwise, return zero ==> the enqueue was // reused. if ( nRC < 0 ) return( zCALL_ERROR ); else return( 0 ); } else { // Report on the owner of the enqueue _fstrcpy( szMsg, "The " ); _fstrcat( szMsg, szObjectName ); _fstrcat( szMsg, " is currently in use by " ); _fstrcat( szMsg, szKey ); if ( _fstrcmp( szObjectName, &szKey[ 30 ] ) != 0 ) { _fstrcat( szMsg, " under the object " ); _fstrcat( szMsg, &szKey[ 30 ] ); } _fstrcat( szMsg, "." ); MessagePrompt( vInstance, "1", szlEnqueue, szMsg, 0, zBUTTONS_OK, zRESPONSE_OK, 0 ); DropObjectInstance( vEnqueue ); DropObjectInstance( vEnqueueHolder ); return( 1 ); } } // End of for loop for enqueueing // If we reach here, then the enqueue was in use and failed. return( 1 ); }
// // ORGINAL used in Aliens of Gold // //------------------------------------------------------------------------- // CheckForEpisodes() - CHECK FOR EPISODES //------------------------------------------------------------------------- void CheckForEpisodes(void) { struct ffblk f; Sint16 i; #if (GAME_VERSION != SHAREWARE_VERSION) #ifdef CHECK_FOR_EPISODES if (!findfirst("*.BS6",&f,FA_ARCH)) #else if (!findfirst("*.BS1",&f,FA_ARCH)) #endif { #ifdef CHECK_FOR_EPISODES strcpy(extension,"BS6"); #else strcpy(extension,"BS1"); #endif NewEmenu[1].active = NewEmenu[2].active = NewEmenu[3].active = NewEmenu[4].active = NewEmenu[5].active = EpisodeSelect[1] = EpisodeSelect[2] = EpisodeSelect[3] = EpisodeSelect[4] = EpisodeSelect[5] = AT_ENABLED; } else #ifdef CHECK_FOR_EPISODES if (!findfirst("*.BS3",&f,FA_ARCH)) #else if (!findfirst("*.BS1",&f,FA_ARCH)) #endif { #ifdef CHECK_FOR_EPISODES strcpy(extension,"BS3"); #else strcpy(extension,"BS1"); #endif NewEmenu[1].active = NewEmenu[2].active = EpisodeSelect[1] = EpisodeSelect[2] = AT_ENABLED; } else #endif if (!findfirst("*.BS1",&f,FA_ARCH)) { strcpy(extension,"BS1"); } else { printf("No Blake Stone data files found!"); exit(0); } #if BETA_TEST // This enables specific missions for beta testers. // NewEmenu[1].active = EpisodeSelect[1] = NewEmenu[2].active = EpisodeSelect[2] = NewEmenu[3].active = EpisodeSelect[3] = NewEmenu[4].active = EpisodeSelect[4] = NewEmenu[5].active = EpisodeSelect[5] = AT_ENABLED; #endif for (i=0;i<mv_NUM_MOVIES;i++) strcat(Movies[i].FName,extension); #ifdef ACTIVATE_TERMINAL strcat(term_com_name,extension); strcat(term_msg_name,extension); #endif strcat(configname,extension); _fstrcat(SaveName,extension); strcat(PageFileName,extension); strcat(audioname,extension); strcat(demoname,extension); #if DUAL_SWAP_FILES strcat(AltPageFileName,extension); ShadowsAvail = (!findfirst(AltPageFileName,&f,FA_ARCH)); #endif }