Beispiel #1
0
static  lib_handle FindSrcFile( char *fname ) {
//=============================================

// Find a source file.

    lib_handle  lp;

    MakeName( fname, SDSrcExtn( fname ), fname );
    lp = SDOpen( fname, READ_FILE );
    if( lp != NULL ) {
        SrcInclude( fname );
    }
    return( lp );
}
Beispiel #2
0
void    InitObj( void ) {
//=================

// Allocate memory for object code.

    char        *fn;
    char        *tmp;
    int         len;
    int         idx;

    ObjCode = NULL; // in case FMemAlloc() fails
    ObjCode = FMemAlloc( PAGE_SIZE );
    ObjEnd = ObjCode + PAGE_SIZE;
    ObjPtr = ObjCode;
    *(unsigned_16 *)ObjPtr = FC_END_OF_SEQUENCE; // in case no source code in file
    PageFile = NULL;
    if( ( ProgSw & PS_DONT_GENERATE ) == 0 ) {
        fn = PageFileBuff;
        len = 0;
        tmp = getenv( "TMP" );
        if( tmp != NULL ) {
            strcpy( fn, tmp );
            len += strlen( fn );
            fn += len;
            if( ( fn[-1] != ':' ) && ( fn[-1] != '\\' ) && ( fn[-1] != '/' ) ) {
                *fn = PATH_SEP;
                ++fn;
                ++len;
            }
        }
        strcpy( fn, PageFileName );
        len += strlen( fn );
        PageFileBuff[ len + 1 ] = NULLCHAR;
        for( idx = 0; idx <= 25; idx++ ) {
            PageFileBuff[ len ] = 'a' + idx;
            if( access( PageFileBuff, 0 ) == -1 ) break;
        }
        if( idx == 26 ) {
            Error( SM_OUT_OF_VM_FILES, PageFileName );
        } else {
            SDSetAttr( PageFileAttrs );
            PageFile = SDOpen( PageFileBuff, UPDATE_FILE );
            ChkIOErr( PageFile, SM_OPENING_FILE );
        }
    }
    PageFlags = PF_INIT;
    CurrPage = 0;
    MaxPage = 0;
}
Beispiel #3
0
static void CLIWrite( dw_sectnum sect, const void *block, dw_size_t size ) {
/*********************************************************************/

    char                        *temp;
    section_data                *cur_sec;

    cur_sec = &Sections[sect];
    if ( cur_sec->sec_type == DEFAULT_SECTION ) {
        if ( ( initial_section_type == DEFAULT_SECTION ) ||
           ( initial_section_type == FILE_SECTION ) ) {
                cur_sec->sec_type = FILE_SECTION;
                SDSetAttr( REC_FIXED | SEEK );
                temp = tmpnam( NULL );
                cur_sec->u2.filename = FMemAlloc( strlen( temp ) + 1 );
                strcpy( cur_sec->u2.filename, temp );
                cur_sec->u1.fp = SDOpen( temp, UPDATE_FILE );
                chkIOErr( cur_sec->u1.fp, SM_OPENING_FILE, temp );
        } else {
                cur_sec->sec_type = initial_section_type;
                cur_sec->u1.size = MEM_INCREMENT;
                cur_sec->u2.data = FMemAlloc( MEM_INCREMENT );
        }
    }

    switch( cur_sec->sec_type ) {
    case( MEM_SECTION ):
        if ( cur_sec->u1.size <= ( cur_sec->cur_offset + size ) ) {
            temp = FMemAlloc( cur_sec->u1.size + MEM_INCREMENT );
            memcpy( temp, cur_sec->u2.data, cur_sec->u1.size );
            FMemFree( cur_sec->u2.data );
            cur_sec->u2.data = temp;
            cur_sec->u1.size += MEM_INCREMENT;
        }
        memcpy( ( cur_sec->u2.data + cur_sec->cur_offset ), block, size );
        break;
    case( FILE_SECTION ):
        SDWrite( cur_sec->u1.fp, (byte *)block, size );
        chkIOErr( cur_sec->u1.fp, SM_IO_WRITE_ERR, "temporary file" );
        break;
    default:
        Error( CP_FATAL_ERROR, "Internal browse generator error" );
        CSuicide();
    };
    cur_sec->cur_offset += size;
    if( cur_sec->cur_offset > cur_sec->max_offset ) {
        cur_sec->max_offset = cur_sec->cur_offset;
    }
}
Beispiel #4
0
void CLIDump( char *filename ) {
/******************************/

    file_handle         fp;

    SDSetAttr( REC_FIXED | SEEK );
    fp = SDOpen( filename, WRITE_FILE );
    chkIOErr( fp, SM_OPENING_FILE, filename );
    CLILock();
    CLIRewind();
    CreateBrowseFile( fp, &Sections[DW_DEBUG_ABBREV],
                        &Sections[DW_DEBUG_INFO], &Sections[DW_DEBUG_REF],
                        &Sections[DW_DEBUG_LINE], &Sections[DW_DEBUG_MACINFO],
                        CLIRead, filename );
    SDClose( fp );
}
Beispiel #5
0
void    Include( char *inc_name ) {
//=================================

    file_handle fp;
    char        bld_name[MAX_FILE+1];
    char        err_msg[ERR_BUFF_SIZE+1];

    SDInitAttr();
    CopyMaxStr( inc_name, bld_name, MAX_FILE );
    MakeName( bld_name, SDSrcExtn( bld_name ), bld_name );
    if( AlreadyOpen( inc_name ) )
        return;
    if( AlreadyOpen( bld_name ) )
        return;
    // try file called <include_name>.FOR.
    fp = SDOpen( bld_name, READ_FILE );
    if( fp != NULL ) {
        SrcInclude( bld_name );
        CurrFile->fileptr = fp;
    } else {
        // get error message before next i/o
        SDError( NULL, err_msg );
        // try library
        fp = IncSearch( inc_name );
        if( fp != NULL ) {
            // SrcInclude( inc_name ) now done in LIBSUPP
            CurrFile->fileptr = fp;
            CurrFile->flags |= INC_LIB_MEMBER;
        } else {
            // could not open include file
            InfoError( SM_OPENING_FILE, bld_name, err_msg );
        }
    }
    // clear RetCode so that we don't get "file not found" returned
    // because we could not open include file
    RetCode = _SUCCESSFUL;
    AddDependencyInfo( CurrFile );
}
Beispiel #6
0
void    OpenSrc( void ) {
//=======================

    file_handle fp;
    char        err_msg[ERR_BUFF_SIZE+1];
    char        bld_name[MAX_FILE+1];
    bool        erase_err;

    erase_err = ErrFile == NULL;
    SDInitAttr();
    MakeName( SrcName, SrcExtn, bld_name );
    fp = SDOpen( bld_name, READ_FILE );
    if( fp != NULL ) {
        SrcInclude( bld_name );
        CurrFile->fileptr = fp;
    } else {
        SDError( NULL, err_msg );
        InfoError( SM_OPENING_FILE, bld_name, err_msg );
    }
    if( erase_err ) {
        CloseErr();
        Erase( ErrExtn );
    }
}