コード例 #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
char *LoadTrap( char *trapbuff, char *buff, trap_version *trap_ver )
{
    dig_fhandle         filehndl;
    char                *ptr;
    char                *parm;
    const trap_requests *(*ld_func)( const trap_callbacks * );
    const trap_requests *trap_funcs;

    if( trapbuff == NULL )
        trapbuff = "std";
    for( ptr = trapbuff; *ptr != '\0' && *ptr != ';'; ++ptr )
        ;
    parm = (*ptr != '\0') ? ptr + 1 : ptr;
    filehndl = DIGPathOpen( trapbuff, ptr - trapbuff, "trp", NULL, 0 );
    if( filehndl == DIG_NIL_HANDLE ) {
        sprintf( buff, TC_ERR_CANT_LOAD_TRAP, trapbuff );
        return( buff );
    }
    TrapCode = ReadInImp( filehndl );
    DIGPathClose( filehndl );
    sprintf( buff, TC_ERR_CANT_LOAD_TRAP, trapbuff );
    if( TrapCode != NULL ) {
#ifdef __WATCOMC__
        if( TrapCode->sig == TRAPSIG ) {
#endif
            strcpy( buff, TC_ERR_BAD_TRAP_FILE );
            ld_func = (void *)TrapCode->init_rtn;
            trap_funcs = ld_func( &TrapCallbacks );
            if( trap_funcs != NULL ) {
                *trap_ver = trap_funcs->init_func( parm, buff, trap_ver->remote );
                FiniFunc = trap_funcs->fini_func;
                if( buff[0] == '\0' ) {
                    if( TrapVersionOK( *trap_ver ) ) {
                        TrapVer = *trap_ver;
                        ReqFunc = trap_funcs->req_func;
                        return( NULL );
                    }
                    strcpy( buff, TC_ERR_BAD_TRAP_FILE );
                }
            }
#ifdef __WATCOMC__
        }
#endif
        KillTrap();
    }
    return( buff );
}