示例#1
0
mad_status MADSysLoad( const char *path, mad_client_routines *cli,
                                mad_imp_routines **imp, mad_sys_handle *sys_hdl )
{
    dig_fhandle         fid;
    imp_header          *mad;
    mad_init_func       *init_func;
    mad_status          status;

    fid = DIGLoader( Open )( path, strlen( path ), "mad", NULL, 0 );
    if( fid == DIG_NIL_HANDLE ) {
        return( MS_ERR | MS_FOPEN_FAILED );
    }
    mad = ReadInImp( fid );
    DIGLoader( Close )( fid );
    status = MS_ERR | MS_INVALID_MAD;
    if( mad != NULL ) {
#ifdef __WATCOMC__
        if( mad->sig == MADSIG ) {
#endif
            init_func = (mad_init_func *)mad->init_rtn;
            if( init_func != NULL && (*imp = init_func( &status, cli )) != NULL ) {
                *sys_hdl = (mad_sys_handle)mad;
                return( MS_OK );
            }
#ifdef __WATCOMC__
        }
#endif
        DIGCli( Free )( (void *)mad );
    }
    return( status );
}
示例#2
0
dig_fhandle PathOpen( char *name, unsigned len, char *ext )
{
    char        path[ _MAX_PATH ];
    char        *realname;
    char        *filename;

    len = len;
    if( ext == NULL || *ext == '\0' ) {
        realname = name;
    } else {
        realname = MemAlloc( _MAX_PATH );
        filename = MemAlloc( _MAX_FNAME );
        _splitpath( name, NULL, NULL, filename, NULL );
        _makepath( realname, NULL, NULL, filename, ext );
        MemFree( realname );
        MemFree( filename );
    }
    _searchenv( realname, "PATH", path );
    if( *path == '\0' ) {
        return( DIG_NIL_HANDLE );
    } else {
        return( DIGCli( Open )( path, DIG_READ ) );
    }
}
示例#3
0
    "export\0"
#endif
    "\0"
};

static const address    NilAddr = { 0 };

/*
 * Client interface
 */

dip_client_routines DIPClientInterface = {
    DIP_MAJOR,
    DIP_MINOR_OLD,
    sizeof( dip_client_routines ),
    DIGCli( Alloc ),
    DIGCli( Realloc ),
    DIGCli( Free ),
    DIPCli( MapAddr ),
    DIPCli( SymCreate ),
    DIPCli( ItemLocation ),
    DIPCli( AssignLocation ),
    DIPCli( SameAddrSpace ),
    DIPCli( AddrSection ),
    DIGCli( Open ),
    DIGCli( Seek ),
    DIGCli( Read ),
    DIGCli( Write ),
    DIGCli( Close ),
    DIGCli( Remove ),
    DIPCli( Status ),
示例#4
0
void MADSysUnload( mad_sys_handle *sys_hdl )
{
    DIGCli( Free )( *sys_hdl );
}
示例#5
0
STATIC void loadImageInfo( image_info * curr_image )
/**************************************************/
{
    int             name_len;
    dig_fhandle     obj_dfh;
    dig_fhandle     sym_dfh;
    struct stat     file_status;

    sym_dfh = DIG_NIL_HANDLE;
    obj_dfh = DIG_NIL_HANDLE;
    curr_image->dip_handle = NO_MOD;
    if( curr_image->sym_deleted ) {
    } else if( curr_image->sym_name != NULL ) {
        sym_dfh = DIGCli( Open )( curr_image->sym_name, DIG_READ );
        if( sym_dfh != DIG_NIL_HANDLE ) {
            curr_image->dip_handle = WPDipLoadInfo( sym_dfh, curr_image->sym_name, curr_image,
                                       sizeof( image_info ), DIP_PRIOR_MIN, DIP_PRIOR_MAX );
        }
    } else {
        name_len = strlen( curr_image->name ) + 1;
        memcpy( FNameBuff, curr_image->name, name_len );
        ReplaceExt( FNameBuff, ".sym" );
        name_len = strlen( FNameBuff ) + 1;
        curr_image->sym_name = ProfAlloc( name_len );
        memcpy( curr_image->sym_name, FNameBuff, name_len );
        sym_dfh = DIGCli( Open )( curr_image->sym_name, DIG_READ );
        if( sym_dfh != DIG_NIL_HANDLE ) {
            curr_image->dip_handle = WPDipLoadInfo( sym_dfh, curr_image->sym_name, curr_image,
                                      sizeof( image_info ), DIP_PRIOR_MIN, DIP_PRIOR_MAX );
        }
        if( curr_image->dip_handle == NO_MOD ) {
            ProfFree( curr_image->sym_name );
            curr_image->sym_name = NULL;
        }
    }
    obj_dfh = DIGCli( Open )( curr_image->name, DIG_READ );
    if( obj_dfh == DIG_NIL_HANDLE ) {
        curr_image->exe_not_found = true;
        if( curr_image->main_load ) {
            ErrorMsg( LIT( Exe_Not_Found ), curr_image->name );
        }
    } else if( curr_image->time_stamp == 0 ) {
        /*
           If sample timestamp is 0, the sampler couldn't figure out
           the right value. Assume it's OK.
        */
    } else {
        if( fstat( DFH2PH( obj_dfh ), &file_status ) == 0 ) {
            /* QNX creation dates and time stamps tend to be 1 */
            /* unit different, so do not test for equality */
            if( file_status.st_mtime - curr_image->time_stamp > 1 ) {
                curr_image->exe_changed = true;
                if( curr_image->main_load ) {
                    ErrorMsg( LIT( Exe_Has_Changed ), curr_image->name );
                }
            }
        }
    }
    if( curr_image->dip_handle == NO_MOD && !curr_image->sym_deleted && obj_dfh != DIG_NIL_HANDLE ) {
        curr_image->dip_handle = WPDipLoadInfo( obj_dfh, curr_image->name, curr_image,
                                   sizeof( image_info ), DIP_PRIOR_MIN, DIP_PRIOR_MAX );
    }
    if( curr_image->dip_handle == NO_MOD ) {
        if( sym_dfh != DIG_NIL_HANDLE ) {
            DIGCli( Close )( sym_dfh );
        }
        if( obj_dfh != DIG_NIL_HANDLE ) {
            DIGCli( Close )( obj_dfh );
        }
    }
    initModuleInfo( curr_image );
    if( curr_image->dip_handle != NO_MOD ) {
        DIPWalkModList( curr_image->dip_handle, &loadModuleInfo, curr_image );
    }
}