Esempio n. 1
0
static MEPTR defineStringMacro( // DEFINE A MACRO NAME
    const char *name )          // - name of macro
{
    MEPTR mptr;
    char const *save = CmdScanAddr();

    CmdScanInit( name );
    mptr = DefineCmdLineMacro( false );
    CmdScanInit( save );
    return( mptr );
}
Esempio n. 2
0
void CmdLnCtxInfo(              // PRINT CONTEXT INFO
    void )
{
    CTX_CL* entry;              // - current entry
    VBUF buf;                   // - buffer

    VbufInit( &buf );
    for( entry = VstkTop( &cmdLnContexts )
       ; entry != NULL
       ; entry = VstkNext( &cmdLnContexts, entry ) ) {
        VbufRewind( &buf );
        switch( entry->base.ctx_type ) {
          case CTX_CLTYPE_ENV :
            VbufConcChr( &buf, '@' );
            VbufConcStr( &buf, entry->env.var );
            break;
          case CTX_CLTYPE_FC :
            VbufConcStr( &buf, "batch file of commands, line " );
            VbufConcDecimal( &buf, CompInfo.fc_file_line );
            break;
          case CTX_CLTYPE_PGM :
            VbufConcStr( &buf, "command line" );
            break;
          case CTX_CLTYPE_FILE :
            VbufConcStr( &buf, SrcFileFullName( entry->file.source ) );
            break;
          DbgDefault( "bad command-line context" );
        }
        if( entry->base.sw_ptr != NULL ) {
            size_t size;
            char const * not_used;
            char const* old = CmdScanAddr();
            CmdScanInit( entry->base.sw_ptr );
            CmdScanChar();
            size = CmdScanOption( &not_used ) + 1;
            CmdScanInit( old );
            VbufConcStr( &buf, ", switch: " );
            for( old = entry->base.sw_ptr; size > 0; ++old, --size ) {
                VbufConcChr( &buf, *old );
            }
        }
        InfMsgPtr( INF_SWITCH, VbufString( &buf ) );
    }
    VbufFree( &buf );
}
Esempio n. 3
0
static void procOptions(        // PROCESS AN OPTIONS LINE
    OPT_STORAGE *data,          // - options data
    const char *str )           // - scan position in command line
{
    int c;                      // - next character
    char const *fnm;            // - scanned @ name
    char *env;                  // - environment name
    size_t len;                 // - length of file name

    if( indirectionLevel >= MAX_INDIRECTION ) {
        BadCmdLine( ERR_MAX_CMD_INDIRECTION );
    } else if( str != NULL ) {
        ++indirectionLevel;
        CtxSetSwitchAddr( str );
        CmdScanInit( str );
        for(;;) {
            c = CmdScanWhiteSpace();
            if( c == '\0' ) break;
            CmdScanSwitchBegin();
            CmdLnCtxSwitch( CmdScanAddr() - 1 );
            if( c == '-'  ||  c == SwitchChar ) {
                if( OPT_PROCESS( data ) ) {
                    BadCmdLine( ERR_INVALID_OPTION );
                }
            } else if( c == '@' ) {
                CmdScanWhiteSpace();
                CmdScanUngetChar();
                len = CmdScanFilename( &fnm );
                env = get_env( fnm, len );
                if( NULL == env ) {
                    if( openCmdFile( fnm, len ) ) {
                        CmdLnCtxPushCmdFile( SrcFileCurrent() );
                        processCmdFile( data );
                        CmdLnCtxPop();
                    } else {
                        CmdLnCtxPushEnv( fnm );
                        BadCmdLine( ERR_BAD_CMD_INDIRECTION );
                        CmdLnCtxPop();
                    }
                } else {
                    CmdLnCtxPushEnv( fnm );
                    procOptions( data, env );
                    CmdLnCtxPop();
                }
            } else {
                CmdScanUngetChar();
                scanInputFile();
            }
        }
        --indirectionLevel;
    }
}
Esempio n. 4
0
void CmdLnCtxPop(               // POP A CONTEXT
    void )
{
    CTX_CL* entry;              // - new entry

    entry = VstkPop( &cmdLnContexts );
    if( CTX_CLTYPE_ENV == entry->base.ctx_type ) {
        CMemFree( (void*)entry->env.var );
    }
    if( CTX_CLTYPE_PGM != entry->base.ctx_type ) {
        CmdScanInit( entry->base.cmd_line );
        CtxSwitchAddr( entry->base.cmd_scan );
    }
}