示例#1
0
int     main( int argc, char *argv[] ) {
//======================================

// FORTRAN compiler main line.

    int         ret_code;
    char        *opts[MAX_OPTIONS+1];
    char        *p;
#if !defined( __INCL_ERRMSGS__ )
    char        imageName[_MAX_PATH];
#endif

#if !defined( __WATCOMC__ )
    _argc = argc;
    _argv = argv;
#else
    argc = argc;
    argv = argv;
#endif
#if defined( __INCL_ERRMSGS__ )
    __InitError();
    __ErrorInit( NULL );
#else
    _cmdname( imageName );
    __InitResource();
    __ErrorInit( imageName );
#endif
#if defined( _M_IX86 )
    _real87 = _8087 = 0;
#endif
    p = getenv( _WFC );
    if( p != NULL && *p != '\0' ) {
        strcpy( CmdBuff, p );
        p = &CmdBuff[ strlen( p ) ];
        *p = ' ';
        ++p;
    } else {
        p = CmdBuff;
    }
    getcmd( p );
    ret_code = 0;
    InitCompMain();
    if( MainCmdLine( &SrcName, &CmdPtr, opts, CmdBuff ) ) {
        SrcExtn = SDSrcExtn( SrcName ); // parse the file name in case we get
        ProcOpts( opts );               // an error in ProcOpts() so error
        InitPredefinedMacros();         // file can be created
        ret_code = CompMain( CmdBuff );
    } else {
        ShowUsage();
    }
    FiniCompMain();
    __ErrorFini();
    return( ret_code );
}
示例#2
0
unsigned        RTSysInit( void ) {
//===========================

    if( RTSysInitialized ) return( 0 );
#if defined( __OS2__ ) && defined( __386__ )
    {
        #define INCL_DOSPROCESS
        #include <os2.h>

        TIB     *ptib;
        PIB     *ppib;

        DosGetInfoBlocks( &ptib, &ppib );
        if( ppib->pib_ultype == 3 ) {
            if( _WindowsStdout == 0 ) {
                __FAppType = FAPP_GUI;
            } else {
                __FAppType = FAPP_DEFAULT_GUI;
            }
        }
    }
#elif defined( __NT__ )
    {
        if( _WindowsStdout != 0 ) {
            __FAppType = FAPP_DEFAULT_GUI;
        }
    }
#endif
    // WATFOR-77 calls __ErrorInit() when it starts
    __ErrorInit( _LpPgmName );
    RTSysInitialized = 1;
    __InitRTData(); // for main thread
    _ExceptionInit();
    // call to RTSysFini() is done in LGSysFini() for load'n go
    // (i.e. we must call RTSysFini() after each time we execute, not when
    // WATFOR-77 exits in case we are operating in batch mode)
    atexit( &RTSysFini );
    return( 0 );
}
示例#3
0
int     main( int argc, char *argv[] ) {
//======================================

    int         rc;
    char        *wfl_env;
    char        *p;
    char        *q;
    char        *cmd;

    /* unused parameters */ (void)argc;

    __InitResource();
    __ErrorInit( argv[0] );

    CmpOpts[0] = NULL;

    SwitchChars[0] = '-';
    SwitchChars[1] = _dos_switch_char();
    SwitchChars[2] = '\0';

    Word = MemAlloc( MAX_CMD );
    cmd = MemAlloc( 2*MAX_CMD ); // for "WFL" environment variable and command line

    // add "WFL" environment variable to "cmd" unless "/y" is specified
    // in "cmd" or the "WFL" environment string

    wfl_env = getenv( WFLENV );
    if( wfl_env != NULL ) {
        strcpy( cmd, wfl_env );
        strcat( cmd, " " );
        p = cmd + strlen( cmd );
        getcmd( p );
        for( q = cmd; (q = strpbrk( q, SwitchChars )) != NULL; ) {
            if( tolower( *(++q) ) == 'y' ) {
                getcmd( cmd );
                p = cmd;
                break;
            }
        }
    } else {
        getcmd( cmd );
        p = cmd;
    }
    p = SkipSpaces( p );
    if( ( *p == '\0' ) || ( strncmp( p, "? ", 2 ) == 0 ) ) {
        Usage();
        rc = 1;
    } else {
        Fp = fopen( TEMPFILE, "w" );
        if( Fp == NULL ) {
            PrintMsg( CL_ERROR_OPENING_TMP_FILE );
            rc = 1;
        } else {
            ObjName = NULL;
            rc = Parse( argc, argv );
            if( rc == 0 ) {
                if( !Flags.quiet ) {
                    PrtBanner();
                }
                rc = CompLink();
            }
            if( rc == 1 )
                fclose( Fp );
            if( LinkName != NULL ) {
                if( stricmp( LinkName, TEMPFILE ) != 0 ) {
                    remove( LinkName );
                    rename( TEMPFILE, LinkName );
                }
            } else {
                remove( TEMPFILE );
            }
        }
    }
    free( Word );
    free( cmd );
    wfl_exit( rc == 0 ? 0 : 1 );
    return( 0 );
}