char *LoadTrap( char *trapbuff, char *buff, trap_version *trap_ver ) { char trpfile[256]; int len; char *ptr; char *parm; unsigned rc; trap_init_func *init_func; if( trapbuff == NULL ) trapbuff = "std"; ptr = trapbuff; while( *ptr != '\0' && *ptr != ';' ) { ++ptr; } parm = (*ptr != '\0') ? ptr + 1 : ptr; len = ptr - trapbuff; memcpy( trpfile, trapbuff, len ); trpfile[len] = '\0'; if( !stricmp( trpfile, "std" ) ) { unsigned version; char os2ver; DosGetVersion( (PUSHORT)&version ); os2ver = version >> 8; if( os2ver >= 20 ) { trpfile[len++] = '3'; trpfile[len++] = '2'; } else { trpfile[len++] = '1'; trpfile[len++] = '6'; } trpfile[len] = 0; }
/* If we're running on OS/2 2.x and it's an LX style file, spawn off the OS/2 2.x sampler to collect things */ bool VersionCheck( void ) { USHORT env_sel; USHORT cmd_off; RESULTCODES res; DosGetVersion( &OSVer ); if( OSVer >= 0x1400 && IsLX() ) { if( DosSearchPath( 0x0003, "PATH", OS22SAMPLER, (unsigned char *)UtilBuff, sizeof( UtilBuff ) ) ) { InternalError( MsgArray[MSG_SAMPLE_8 - ERR_FIRST_MESSAGE] ); } DosGetEnv( &env_sel, &cmd_off ); if( DosExecPgm( NULL, 0, EXEC_ASYNC, MK_FP( env_sel, cmd_off ), NULL, &res, UtilBuff ) != 0 ) { InternalError( MsgArray[MSG_SAMPLE_9 - ERR_FIRST_MESSAGE] ); } _exit( 0 ); } return( OSVer >= 0x0a14 ); }
int _OS2Main( char far *stklow, char far * stktop, unsigned envseg, unsigned cmdoff ) /*************************************************/ { cmdoff = cmdoff; /* supress warnings */ envseg = envseg; stktop = stktop; /* set up global variables */ #if defined(__SW_BD) _STACKTOP = 0; _curbrk = _dynend = (unsigned)&end; stklow = NULL; #else _STACKTOP = FP_OFF( stktop ); _curbrk = _dynend = _STACKTOP; #endif DosGetHugeShift( (PUSHORT)&_HShift ); DosGetMachineMode( (PBYTE)&_osmode ); { unsigned short version; DosGetVersion( (PUSHORT)&version ); _osmajor = version >> 8; _osminor = version & 0xff; } #if defined(__SW_BD) _LpPgmName = ""; _LpCmdLine = ""; #else /* copy progname and arguments to bottom of stack */ { char far *src; char far *pgmp; src = MK_FP( envseg, cmdoff ); _LpPgmName = stklow; /* back up from the ao: pointer to the eo: pointer (see OS/2 2.0 docs)*/ for( pgmp = src - 1; *--pgmp != '\0'; ); ++pgmp; while( *stklow++ = *pgmp++ ); while( *src ) ++src; ++src; _LpCmdLine = stklow; while( *stklow++ = *src++ ); } #endif #if defined(__SW_BM) { SEL globalseg; SEL localseg; DosGetInfoSeg( &globalseg, &localseg ); _threadid = MK_FP( localseg, offsetof( LINFOSEG, tidCurrent ) ); if( __InitThreadProcessing() == NULL ) __fatal_runtime_error( "Not enough memory", 1 ); #if defined(__SW_BD) { unsigned i; unsigned j; j = __MaxThreads; for( i = 1; i <= j; i++ ) { __SetupThreadProcessing( i ); } } #else __SetupThreadProcessing( 1 ); #endif _STACKLOW = (unsigned)stklow; } #else _nothread = getpid(); _threadid = &_nothread; _STACKLOW = (unsigned)stklow; /* set bottom of stack */ #endif // { /* removed JBS 99/11/10 */ // // make sure the iomode array is of the proper length // // this needs to be done before the InitRtns // extern void __grow_iomode(int); // if( _osmode == OS2_MODE ) { // __grow_iomode( 100 ); // } // } __InitRtns( 255 ); #ifdef __SW_BD { int status; status = setjmp( JmpBuff ); if( status == 0 ) return( _CMain() ); return( RetCode ); } #else return( _CMain() ); #endif }