Exemple #1
0
int main( int argc, char * argv[] )
#endif
/***************************************/
{
    bool    noerror;

#ifndef DLL_COMPILE
    RcMemInit();
    Layer0InitStatics();
#if !defined(__UNIX__) && !defined(__OSI__) /* _grow_handles doesn't work yet */
    _grow_handles(100);
#endif
#endif
    if( !InitRcMsgs( argv[0] ) ) return( 1 );

    noerror = ScanParams( argc, argv );
    if (!CmdLineParms.Quiet) {
        RcIoPrintBanner();
    }
    if (CmdLineParms.PrintHelp) {
        RcIoPrintHelp( argv[0] );
    }

    if (noerror && !CmdLineParms.Pass2Only) {
        noerror = Pass1();
    }
    if (noerror && !CmdLineParms.Pass1Only && !CmdLineParms.PreprocessOnly ) {
        noerror = Pass2();
    }

    FiniTable();
#ifndef DLL_COMPILE
    ScanParamShutdown();
    FiniRcMsgs();
    RcMemShutdown();
#endif

    if (noerror) {
        return( 0 );
    } else {
        return( 1 );
    }
} /* main */
Exemple #2
0
static int RCMainLine( const char *opts, int argc, char **argv )
/**************************************************************/
{
    char        *cmdbuf = NULL;
    const char  *str;
    char        infile[_MAX_PATH + 2];  // +2 for quotes
    char        outfile[_MAX_PATH + 6]; // +6 for -fo="" or -fe=""
    bool        pass1;
    int         i;
    int         rc;

    curBufPos = formatBuffer;
    RcMemInit();
    InitGlobs();
    rc = setjmp( jmpbuf_RCFatalError );
    if( rc == 0 ) {
        InitRcMsgs();
        if( opts != NULL ) {
            str = opts;
            argc = ParseEnvVar( str, NULL, NULL );
            argv = RcMemMalloc( ( argc + 4 ) * sizeof( char * ) );
            cmdbuf = RcMemMalloc( strlen( str ) + argc + 1 );
            ParseEnvVar( str, argv, cmdbuf );
            pass1 = false;
            for( i = 0; i < argc; i++ ) {
                if( argv[i] != NULL && !stricmp( argv[i], "-r" ) ) {
                    pass1 = true;
                    break;
                }
            }
            if( initInfo != NULL && initInfo->ver > 1 && initInfo->cmd_line_has_files ) {
                if( !ideCb->GetInfo( cbHandle, IDE_GET_SOURCE_FILE, 0, (IDEGetInfoLParam)( infile + 1 ) ) ) {
                    infile[0] = '\"';
                    strcat( infile, "\"" );
                    argv[argc++] = infile;
                }
                if( !ideCb->GetInfo( cbHandle, IDE_GET_TARGET_FILE, 0, (IDEGetInfoLParam)( outfile + 5 ) ) ) {
                    if( pass1 ) {
                        strcpy( outfile, "-fo=\"" );
                    } else {
                        strcpy( outfile, "-fe=\"" );
                    }
                    strcat( outfile, "\"" );
                    argv[argc++] = outfile;
                }
            }
            argv[argc] = NULL;        // last element of the array must be NULL
        }
        if( !ScanParams( argc, argv ) ) {
            rc = 1;
        }
        if( !CmdLineParms.Quiet ) {
            RcIoPrintBanner();
        }
        if( CmdLineParms.PrintHelp ) {
            RcIoPrintHelp();
        }
        if( rc == 0 ) {
            rc = RCSpawn( RCmain );
        }
        if( opts != NULL ) {
            RcMemFree( argv );
            RcMemFree( cmdbuf );
        }
        FiniRcMsgs();
    }
    FiniGlobs();
    flushPrintf();
    RcMemShutdown();
    return( rc );
}