char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) { FILE *fp; trap_file_header __far *head; char filename[256]; char *p; char chr; if( parms == NULL || *parms == '\0' ) parms = DEFAULT_TRP_NAME; p = filename; for( ; (chr = *parms) != '\0'; parms++ ) { if( chr == TRAP_PARM_SEPARATOR ) { parms++; break; } *p++ = chr; } #ifdef USE_FILENAME_VERSION *p++ = ( USE_FILENAME_VERSION / 10 ) + '0'; *p++ = ( USE_FILENAME_VERSION % 10 ) + '0'; #endif *p = '\0'; fp = DIGLoader( Open )( filename, p - filename, DEFAULT_TRP_EXT, NULL, 0 ); if( fp == NULL ) { sprintf( buff, "%s '%s'", TC_ERR_CANT_LOAD_TRAP, filename ); return( buff ); } p = ReadInTrap( fp ); DIGLoader( Close )( fp ); sprintf( buff, "%s '%s'", TC_ERR_CANT_LOAD_TRAP, filename ); if( p == NULL ) { if( (p = SetTrapHandler()) != NULL || (p = CopyEnv()) != NULL ) { strcpy( buff, p ); } else { strcpy( buff, TC_ERR_WRONG_TRAP_VERSION ); head = EXTENDER_RM2PM( TrapMem.rm, 0 ); if( head->sig == TRAP_SIGNATURE ) { PMData->initfunc.s.offset = head->init; PMData->reqfunc.s.offset = head->req; PMData->finifunc.s.offset = head->fini; PMData->initfunc.s.segment = TrapMem.rm; PMData->reqfunc.s.segment = TrapMem.rm; PMData->finifunc.s.segment = TrapMem.rm; if( CallTrapInit( parms, buff, trap_ver ) ) { if( TrapVersionOK( *trap_ver ) ) { TrapVer = *trap_ver; ReqFunc = DoTrapAccess; return( NULL ); } strcpy( buff, TC_ERR_WRONG_TRAP_VERSION ); } } } } KillTrap(); return( buff ); }
char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) { dig_fhandle filehndl; const char *ptr; trap_init_func *init_func; #ifdef USE_FILENAME_VERSION char filename[256]; char *p; #endif if( parms == NULL || *parms == '\0' ) parms = "std"; #ifdef USE_FILENAME_VERSION for( ptr = parms, p = filename; *ptr != '\0' && *ptr != TRAP_PARM_SEPARATOR; ++ptr ) { *p++ = *ptr; } *p++ = ( USE_FILENAME_VERSION / 10 ) + '0'; *p++ = ( USE_FILENAME_VERSION % 10 ) + '0'; *p = '\0'; filehndl = DIGPathOpen( filename, p - filename, "trp", NULL, 0 ); #else for( ptr = parms; *ptr != '\0' && *ptr != TRAP_PARM_SEPARATOR; ++ptr ) { ; } filehndl = DIGPathOpen( parms, ptr - parms, "trp", NULL, 0 ); #endif if( filehndl == DIG_NIL_HANDLE ) { sprintf( buff, TC_ERR_CANT_LOAD_TRAP, parms ); return( buff ); } parms = ptr; ptr = ReadInTrap( DIGGetSystemHandle( filehndl ) ); DIGPathClose( filehndl ); if( ptr != NULL ) { strcpy( buff, ptr ); } else { strcpy( buff, TC_ERR_WRONG_TRAP_VERSION ); if( TrapCode->signature == TRAP_SIGNATURE ) { init_func = MK_FP( FP_SEG( TrapCode ), TrapCode->init_off ); if( *parms != '\0' ) ++parms; *trap_ver = init_func( parms, buff, trap_ver->remote ); if( buff[0] == '\0' ) { if( TrapVersionOK( *trap_ver ) ) { TrapVer = *trap_ver; FiniFunc = MK_FP( FP_SEG( TrapCode ), TrapCode->fini_off ); ReqFunc = MK_FP( FP_SEG( TrapCode ), TrapCode->req_off ); return( NULL ); } strcpy( buff, TC_ERR_WRONG_TRAP_VERSION ); } } } KillTrap(); return( buff ); }
char *LoadTrap( char *trapbuff, char *buff, trap_version *trap_ver ) { char *err; char *parm; char *end; dig_fhandle dh; trap_file_header __far *head; if( trapbuff == NULL ) { trapbuff = DEFAULT_TRP_NAME; } end = strchr( trapbuff, PARM_SEPARATOR ); if( end == NULL ) { end = &trapbuff[strlen( trapbuff )]; parm = end; } else { parm = end + 1; } dh = DIGPathOpen( trapbuff, end - trapbuff, DEFAULT_TRP_EXT, NULL, 0 ); if( dh == DIG_NIL_HANDLE ) { sprintf( buff, TC_ERR_CANT_LOAD_TRAP, trapbuff ); return( buff ); } err = ReadInTrap( DIGGetSystemHandle( dh ) ); DIGPathClose( dh ); sprintf( buff, TC_ERR_CANT_LOAD_TRAP, trapbuff ); if( err == NULL ) { if( (err = SetTrapHandler()) != NULL || (err = CopyEnv()) != NULL ) { strcpy( buff, err ); } else { strcpy( buff, TC_ERR_WRONG_TRAP_VERSION ); head = MK_PM( TrapMem.segm.rm, 0 ); if( head->sig == TRAP_SIGNATURE ) { PMData->initfunc.s.offset = head->init; PMData->reqfunc.s.offset = head->req; PMData->finifunc.s.offset = head->fini; PMData->initfunc.s.segment = TrapMem.segm.rm; PMData->reqfunc.s.segment = TrapMem.segm.rm; PMData->finifunc.s.segment = TrapMem.segm.rm; if( CallTrapInit( parm, buff, trap_ver ) ) { if( TrapVersionOK( *trap_ver ) ) { TrapVer = *trap_ver; ReqFunc = DoTrapAccess; return( NULL ); } strcpy( buff, TC_ERR_WRONG_TRAP_VERSION ); } } } } KillTrap(); return( buff ); }
char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) { char *err; const char *end; dig_fhandle dh; trap_file_header __far *head; if( parms == NULL || *parms == '\0' ) { parms = DEFAULT_TRP_NAME; } for( end = parms; *end != '\0' && *end != TRAP_PARM_SEPARATOR; ++end ) ; dh = DIGPathOpen( parms, end - parms, DEFAULT_TRP_EXT, NULL, 0 ); if( dh == DIG_NIL_HANDLE ) { sprintf( buff, TC_ERR_CANT_LOAD_TRAP, parms ); return( buff ); } err = ReadInTrap( DIGGetSystemHandle( dh ) ); DIGPathClose( dh ); sprintf( buff, TC_ERR_CANT_LOAD_TRAP, parms ); if( err == NULL ) { if( (err = SetTrapHandler()) != NULL || (err = CopyEnv()) != NULL ) { strcpy( buff, err ); } else { strcpy( buff, TC_ERR_WRONG_TRAP_VERSION ); head = MK_PM( TrapMem.segm.rm, 0 ); if( head->sig == TRAP_SIGNATURE ) { PMData->initfunc.s.offset = head->init; PMData->reqfunc.s.offset = head->req; PMData->finifunc.s.offset = head->fini; PMData->initfunc.s.segment = TrapMem.segm.rm; PMData->reqfunc.s.segment = TrapMem.segm.rm; PMData->finifunc.s.segment = TrapMem.segm.rm; parms = end; if( *parms != '\0' ) ++parms; if( CallTrapInit( parms, buff, trap_ver ) ) { if( TrapVersionOK( *trap_ver ) ) { TrapVer = *trap_ver; ReqFunc = DoTrapAccess; return( NULL ); } strcpy( buff, TC_ERR_WRONG_TRAP_VERSION ); } } } } KillTrap(); return( buff ); }
char *LoadTrap( char *trapbuff, char *buff, trap_version *trap_ver ) { dig_fhandle filehndl; char *ptr; char *parm; trap_init_func *init_func; 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 ); } ptr = ReadInTrap( DIGGetSystemHandle( filehndl ) ); DIGPathClose( filehndl ); if( ptr != NULL ) { strcpy( buff, ptr ); } else { strcpy( buff, TC_ERR_WRONG_TRAP_VERSION ); if( TrapCode->signature == TRAP_SIGNATURE ) { init_func = MK_FP( FP_SEG( TrapCode ), TrapCode->init_off ); *trap_ver = init_func( parm, buff, trap_ver->remote ); if( buff[0] == '\0' ) { if( TrapVersionOK( *trap_ver ) ) { TrapVer = *trap_ver; FiniFunc = MK_FP( FP_SEG( TrapCode ), TrapCode->fini_off ); ReqFunc = MK_FP( FP_SEG( TrapCode ), TrapCode->req_off ); return( NULL ); } strcpy( buff, TC_ERR_WRONG_TRAP_VERSION ); } } } KillTrap(); return( buff ); }
char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver ) { char *err; const char *ptr; dig_ldhandle ldfh; trap_file_header __far *head; #ifdef USE_FILENAME_VERSION char filename[256]; char *p; #endif if( parms == NULL || *parms == '\0' ) { parms = DEFAULT_TRP_NAME; } #ifdef USE_FILENAME_VERSION for( ptr = parms, p = filename; *ptr != '\0' && *ptr != TRAP_PARM_SEPARATOR; ++ptr ) { *p++ = *ptr; } *p++ = ( USE_FILENAME_VERSION / 10 ) + '0'; *p++ = ( USE_FILENAME_VERSION % 10 ) + '0'; *p = '\0'; ldfh = DIGLoader( Open )( filename, p - filename, DEFAULT_TRP_EXT, NULL, 0 ); #else for( ptr = parms; *ptr != '\0' && *ptr != TRAP_PARM_SEPARATOR; ++ptr ) { ; } ldfh = DIGLoader( Open )( parms, ptr - parms, DEFAULT_TRP_EXT, NULL, 0 ); #endif if( ldfh == DIGLD_NIL_HANDLE ) { sprintf( buff, TC_ERR_CANT_LOAD_TRAP, parms ); return( buff ); } err = ReadInTrap( ldfh ); DIGLoader( Close )( ldfh ); sprintf( buff, TC_ERR_CANT_LOAD_TRAP, parms ); if( err == NULL ) { if( (err = SetTrapHandler()) != NULL || (err = CopyEnv()) != NULL ) { strcpy( buff, err ); } else { strcpy( buff, TC_ERR_WRONG_TRAP_VERSION ); head = MK_PM( TrapMem.segm.rm, 0 ); if( head->sig == TRAP_SIGNATURE ) { PMData->initfunc.s.offset = head->init; PMData->reqfunc.s.offset = head->req; PMData->finifunc.s.offset = head->fini; PMData->initfunc.s.segment = TrapMem.segm.rm; PMData->reqfunc.s.segment = TrapMem.segm.rm; PMData->finifunc.s.segment = TrapMem.segm.rm; parms = ptr; if( *parms != '\0' ) ++parms; if( CallTrapInit( parms, buff, trap_ver ) ) { if( TrapVersionOK( *trap_ver ) ) { TrapVer = *trap_ver; ReqFunc = DoTrapAccess; return( NULL ); } strcpy( buff, TC_ERR_WRONG_TRAP_VERSION ); } } } } KillTrap(); return( buff ); }
char *LoadTrap( char *trapbuff, char *buff, trap_version *trap_ver ) { char *err; char *parm; char *end; handle dh; trap_file_header __far *head; char init_error[256]; if( trapbuff == NULL ) { trapbuff = DEFAULT_TRP_NAME; } end = strchr( trapbuff, PARM_SEPARATOR ); if( end == NULL ) { end = &trapbuff[ strlen( trapbuff ) ]; parm = end; } else { parm = end + 1; } dh = PathOpen( trapbuff, end - trapbuff, DEFAULT_TRP_EXT ); if( dh == NIL_HANDLE ) { sprintf( buff, TC_ERR_CANT_LOAD_TRAP, trapbuff ); return( buff ); } err = ReadInTrap( GetSystemHandle( dh ) ); FileClose( dh ); if( err != NULL ) { sprintf( buff, TC_ERR_CANT_LOAD_TRAP, trapbuff ); KillTrap(); return( buff ); } err = SetTrapHandler(); if( err != NULL ) { KillTrap(); return( err ); } err = CopyEnv(); if( err != NULL ) { KillTrap(); return( err ); } head = MK_PM( TrapMem.s.rm, 0 ); if( head->sig != TRAP_SIGNATURE ) { KillTrap(); strcpy( buff, TC_ERR_WRONG_TRAP_VERSION ); return( buff ); } PMData->initfunc.s.offset = head->init; PMData->reqfunc.s.offset = head->req; PMData->finifunc.s.offset = head->fini; PMData->initfunc.s.segment = TrapMem.s.rm; PMData->reqfunc.s.segment = TrapMem.s.rm; PMData->finifunc.s.segment = TrapMem.s.rm; if( !CallTrapInit( parm, init_error, trap_ver ) ) { KillTrap(); strcpy( buff, init_error ); return( buff ); } if( !TrapVersionOK( *trap_ver ) ) { KillTrap(); strcpy( buff, TC_ERR_WRONG_TRAP_VERSION ); return( buff ); } TrapVer = *trap_ver; ReqFunc = DoTrapAccess; return( NULL ); }