static BOOL IsDemo( LPSTR lpProgram ) /***********************************************************************/ { #ifndef _MAC int i; int fp; char buf[32]; #ifndef FileOpen OFSTRUCT ofstruct; #endif #define DEMO "xgm" #define PROTECT "lartsa" #define SZPROTECT 6 #define SYSCHAR (BYTE far *)0xffff0000 #ifdef FileOpen if ( ( fp = FileOpen( lpProgram, FO_READ ) ) == FILE_HANDLE_INVALID ) return( 0 ); /* something is wierd */ if ( FileSeek( fp, -(long)sizeof(buf), SEEK_END ) < 0 ) *buf = '\0'; /* goto the bottom bytes */ if ( FileRead( fp, buf, sizeof(buf) ) != sizeof(buf) ) *buf = '\0'; /* something is wierd */ FileClose( fp ); #else if ( ( fp = OpenFile( lpProgram, &ofstruct, OF_READ ) ) < 0 ) return( 0 ); /* something is wierd */ if ( _llseek( fp, -(long)sizeof(buf), SEEK_END ) < 0 ) *buf = '\0'; /* goto the bottom bytes */ if ( _lread( fp, buf, sizeof(buf) ) != sizeof(buf) ) *buf = '\0'; /* something is wierd */ _lclose( fp ); #endif // FileOpen for ( i=0; i<sizeof(buf)-1; i++ ) { // Zap any non-ascii characters if ( buf[i] < 'a' || buf[i] > 'z' ) buf[i] = '.'; } buf[i] = '\0'; if ( lstrfind( buf, DEMO ) ) // Is it a crippled demo? return( IDS_CRIPPLED ); #endif // _MAC return( FALSE ); }
BOOL HandleCommandLine( HWND hWindow, LPTSTR lpszCmdLine, LPINT lpPrint ) /***********************************************************************/ { FNAME szFileName; LPTSTR lp; BOOL bPassedByClient; LPIMAGE lpImageDoc; HWND hWnd; WORD wChar; *lpPrint = NO; if( !lpszCmdLine ) return( TRUE ); // Check if we have "[/ | -]embedding" and a possible filename. // usage: PP ["[-/]embedding"] file1 file2 ... //dbg("full command line = '%ls'", lpszCmdLine ); // See if the command line is being passed by a client bPassedByClient = NO; if(( lp = lstrfind( lpszCmdLine, _T("embedding") )) && ( lp == lpszCmdLine || lp == ( MyCharNext( lpszCmdLine )))) { // Command line passed by a client // dbg(_T("command line passed by client")); bPassedByClient = YES; lpszCmdLine = SkipSpaces( MyCharNextN( lp, 9 )); // skip over _T("embedding") } while( *lpszCmdLine ) // Process any files and switches on the command line { // Skip white space and see if we're done... lpszCmdLine = SkipSpaces( lpszCmdLine ); if( !( *lpszCmdLine )) // If NULL get out break; // dbg( _T("file='%ls' print=%d"), lpszCmdLine, *lpPrint );dbg(0); // Check for any switches preceeding the file name: only /p for now while( TRUE ) { if( IsDBCSLeadByte(( BYTE )*lpszCmdLine )) wChar = *(( LPWORD )lpszCmdLine ); else wChar = *lpszCmdLine; if( wChar != _T('/')) // if not a switch... break; lpszCmdLine = MyCharNext( lpszCmdLine ); // Skip over the slash if( !*lpszCmdLine ) // If NULL get out break; if( IsDBCSLeadByte(( BYTE )*lpszCmdLine )) wChar = *(( LPWORD )lpszCmdLine ); else wChar = *lpszCmdLine; if( wChar == _T('p') || wChar == _T('P') ) *lpPrint = YES; lpszCmdLine = SkipSpaces( MyCharNext( lpszCmdLine )); } // Skip white space and see if we're done... lpszCmdLine = SkipSpaces( lpszCmdLine ); if( !( *lpszCmdLine )) // If NULL get out break; // Try to zap the space after a single file name if(( lp = lstrfind( lpszCmdLine, _T(" ") ))) *lp = _T('\0'); // If we found a space, zap it // Copy the full path name into szFileName if( lStrChr( lpszCmdLine, _T('\\') )) lstrcpy( szFileName, lpszCmdLine ); else // If not a full path name... { GetCurrentDir( szFileName, sizeof(FNAME) ); FixPath( szFileName ); lstrcat( szFileName, lpszCmdLine ); } // Now we're done with lpszCmdLine, so set it up for the next loop // If we had found a space, there might be more file names if( lp ) lpszCmdLine = MyCharNext( lp ); else lpszCmdLine += lstrlen( lpszCmdLine ); // Point to nothing // Process szFileName // Special handling of documents passed by a client if ( bPassedByClient ) { CServerDoc *pDoc = PictPubApp.GetDocument(szFileName); if (pDoc) { // It's already open.... POSITION ViewPos = pDoc->GetFirstViewPosition(); ASSERT(ViewPos!=NULL); CView* pView = pDoc->GetNextView( ViewPos ); ASSERT(pView); // NOTE send Message to View's Parent MDIFrame SendMessage( PictPubApp.Get_hClientAstral(), WM_MDIACTIVATE, (WORD)pView->GetParentFrame()->GetSafeHwnd(), 0L ); lpImageDoc->fOwnedByClient = YES; *szFileName = _T('\0'); // Zap it } } // If we have a file name, open it... if ( *szFileName ) hWnd = AstralImageLoad( 0, szFileName, MAYBE, YES ); else hWnd = NULL; // If the printing option was passed, print it and close it if ( hWnd && *lpPrint ) { FORWARD_WM_COMMAND(PictPubApp.Get_hWndAstral(), IDM_PRINT, NULL, 0, SendMessage); CloseImage( NO, NULL, NULL ); } } return( TRUE ); }
BOOL HandleCommandLine( /***********************************************************************/ HWND hWindow, LPSTR lpszCmdLine, LPINT lpPrint) { FNAME szFileName; LPSTR lp; BOOL bPassedByClient, bGotImage; LPIMAGE lpImageDoc; HWND hWnd; int i; bPaintAppActive = TRUE; *lpPrint = NO; if ( !lpszCmdLine ) { // If no command line, bring up an empty image SendMessage( hWindow, WM_COMMAND, IDM_NEW, 0L ); if ( (hWnd = AstralDlgGet(IDD_MAIN)) && !IsWindowVisible( hWnd ) ) ShowWindow( hWnd, SW_SHOW ); return( TRUE ); } // Check if we have "[/ | -]embedding" and a possible filename. // usage: PP ["[-/]embedding"] file1 file2 ... // See if the command line is being passed by a client bPassedByClient = NO; if ( (lp = lstrfind( lpszCmdLine, "embedding" )) && (lp == lpszCmdLine || lp == (lpszCmdLine+1)) ) { // Command line passed by a client bPassedByClient = YES; lpszCmdLine = SkipSpaces( lp + 9 ); // skip over "embedding" } bGotImage = NO; while ( *lpszCmdLine ) { // Process any files and switches on the command line // Skip white space and see if we're done... lpszCmdLine = SkipSpaces( lpszCmdLine ); if ( !(*lpszCmdLine ) ) break; // If NULL get out // Check for any switches preceeding the file name: only /p for now while ( *lpszCmdLine == '/' ) { // a switch... lpszCmdLine++; // Skip over the slash if ( !*lpszCmdLine ) break; // If NULL get out if ( *lpszCmdLine == 'p' || *lpszCmdLine == 'P' ) *lpPrint = YES; lpszCmdLine++; // Skip the option character lpszCmdLine = SkipSpaces( lpszCmdLine ); } // Skip white space and see if we're done... lpszCmdLine = SkipSpaces( lpszCmdLine ); if ( !(*lpszCmdLine ) ) break; // If NULL get out // Try to zap the space after a single file name if ( (lp = lstrfind( lpszCmdLine, " " )) ) *lp = '\0'; // If we found a space, zap it // Copy the full path name into szFileName #ifdef _MAC lstrcpy( szFileName, lpszCmdLine ); #else if ( lstrchr( lpszCmdLine, '\\' ) ) lstrcpy( szFileName, lpszCmdLine ); else { // If not a full path name... GetCurrentDir( szFileName, sizeof(FNAME) ); FixPath( szFileName ); lstrcat( szFileName, lpszCmdLine ); } #endif // Now we're done with lpszCmdLine, so set it up for the next loop if ( lp ) // If we had found a space, there might be more file names lpszCmdLine = lp + 1; else lpszCmdLine += lstrlen(lpszCmdLine); // Point to nothing // Special handling of documents passed by a client ////if ( bPassedByClient ) //// { // Loop through documents to see if it's already open for ( i=0; i<NumDocs(); i++ ) { hWnd = GetDoc(i); if ( !(lpImageDoc = (LPIMAGE)GetWindowLong( hWnd, GWL_IMAGEPTR ))) continue; if ( !StringsEqual( lpImageDoc->CurFile, szFileName ) ) continue; // It's already open.... SendMessage( hClientAstral, WM_MDIACTIVATE, (WPARAM)hWnd, 0L ); if ( bPassedByClient ) lpImageDoc->fOwnedByClient = YES; szFileName[0] = '\0'; // Zap it bGotImage = YES; break; } //// } // If we have a file name, open it... if ( *szFileName ) { if ( AstralImageLoad( NULL, szFileName, MAYBE, YES ) ) bGotImage = YES; } // If the printing option was passed, print it and close it if ( *lpPrint && lpImage ) { SendMessage(hWndAstral, WM_COMMAND, IDM_PRINT, 0L ); CloseImage( NO, NULL ); } } if ( !bGotImage ) { if ( !idCurrentRoom ) { GoRoom (hInstAstral, -1, FALSE); return( FALSE ); } // If no image was opened via the command line, go to the opening screen SendMessage( hWindow, WM_COMMAND, IDM_NEW, 0L ); } if ( (hWnd = AstralDlgGet(IDD_MAIN)) && !IsWindowVisible( hWnd ) ) ShowWindow( hWnd, SW_SHOW ); return( TRUE ); }