static bool openSrc( // ATTEMPT TO OPEN FILE char *name, // - file name enum file_type typ ) // - type of file being opened { pch_absorb pch_OK; // - pre-compiled header load status FILE *fp; // - file pointer #ifdef OPT_BR bool might_browse; // - true ==> might browse, if right file type #endif if( SrcFileProcessOnce( name ) ) { SrcFileOpen( NULL, name ); return( TRUE ); } fp = SrcFileFOpen( name, SFO_SOURCE_FILE ); if( fp == NULL ) { return( FALSE ); } #ifdef OPT_BR might_browse = FALSE; #endif if( CompFlags.watch_for_pcheader ) { CompFlags.watch_for_pcheader = FALSE; pch_OK = PCHeaderAbsorb( name ); if( pch_OK != PCHA_OK ) { SrcFileSetCreatePCHeader(); SrcFileOpen( fp, name ); #ifdef OPT_BR might_browse = TRUE; #endif } else { SrcFileOpen( NULL, name ); fclose( fp ); } } else { SrcFileOpen( fp, name ); if( typ == FT_SRC ) { SetSrcFilePrimary(); } #ifdef OPT_BR might_browse = TRUE; #endif } #ifdef OPT_BR if( might_browse ) switch( typ ) { case FT_SRC : case FT_LIBRARY : case FT_HEADER : BrinfOpenSource( SrcFileCurrent() ); break; } #endif return( TRUE ); }
extern void DwarfFini( dw_client client ) /****************************************/ { int i; int status; char *out_fname; FILE *out_file; if( !CompFlags.emit_browser_info ) return; DWEndCompileUnit( client ); DWFini( client ); // close after writing for( i = 0 ; i < DW_DEBUG_MAX ; i++ ) { DwioCloseOutputFile( dw_sections[i].file ); } out_fname = IoSuppOutFileName( OFT_MBR ); out_file = SrcFileFOpen( out_fname, SFO_WRITE_BINARY ); if( out_file == NULL ) { puts( strerror( errno ) ); puts( out_fname ); CFatal( "dwarf: unable to open file for writing" ); } // concatenate files if( createBrowseFile( out_file, &dw_sections[DW_DEBUG_ABBREV], &dw_sections[DW_DEBUG_INFO], &dw_sections[DW_DEBUG_REF], &dw_sections[DW_DEBUG_LINE], &dw_sections[DW_DEBUG_MACINFO] ) ) { puts( strerror( errno ) ); CFatal( "dwarf: error in merging browse files" ); } status = SrcFileFClose( out_file ); if( status ) { puts( strerror( errno ) ); puts( out_fname ); CFatal( "dwarf: unable to close file" ); } // delete for( i = 0 ; i < DW_DEBUG_MAX ; i++ ) { DwioFreeFile( dw_sections[i].file ); } DwioFini(); }
void PpOpen( // OPEN PREPROCESSOR OUTPUT void ) { char *name; if( CompFlags.cpp_output_to_file ) { /* 29-sep-90 */ name = IoSuppOutFileName( OFT_PPO ); CppFile = SrcFileFOpen( name, SFO_WRITE_TEXT ); if( CppFile == NULL ) { printf( "Unable to open '%s'\n", name ); CppExit( 1 ); } else { IoSuppSetBuffering( CppFile, 512 ); } } else { CppFile = stdout; } }