Exemplo n.º 1
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;
    }
}
Exemplo n.º 2
0
static bool scanOffNumber       // SCAN A NUMBER
    ( unsigned *pvalue )        // - target
{
    bool number_scanned;
    unsigned value;
    int c;

    CmdRecogEquals();
    number_scanned = FALSE;
    value = 0;
    for(;;) {
        c = CmdScanLowerChar();
        if( !isdigit( c ) ) {
            CmdScanUngetChar();
            break;
        }
        value *= 10;
        value += c - '0';
        number_scanned = TRUE;
    }
    if( number_scanned ) {
        *pvalue = value;
    }
    return( number_scanned );
}
Exemplo n.º 3
0
int CmdPeekChar(                // PEEK AT NEXT CHARACTER, IN LOWER CASE
    void )
{
    int ch;                     // - character scanned

    ch = CmdScanLowerChar();
    CmdScanUngetChar();
    return( ch );
}
Exemplo n.º 4
0
bool CmdRecogChar(              // RECOGNIZE A CHARACTER
    int recog )                 // - character to be recognized
{
    bool retn;                  // - true ==> got it

    if( recog == CmdScanChar() ) {
        retn = true;
    } else {
        CmdScanUngetChar();
        retn = false;
    }
    return( retn );
}
Exemplo n.º 5
0
size_t CmdScanId(               // SCAN AN IDENTIFIER
    char const **option )       // - addr( option pointer )
{
    char const *p;              // - scan position
    char const *str_beg;        // - start of string

    p = CmdScanUngetChar();
    *option = p;
    str_beg = p;
    while( isalnum( *p ) || *p == '_' ) {
        ++p;
    }
    cmd.curr_ptr = p;
    return( p - str_beg );
}
Exemplo n.º 6
0
bool CmdPathDelim(              // SKIP EQUALCHAR # or ' ' IN COMMAND LINE
    void )
{
    switch( CmdPeekChar() ) {
    case ' ':
        CmdScanWhiteSpace();
        CmdScanUngetChar();
        return( true );
    case '=':
    case '#':
        CmdScanChar();
        return( true );
    }
    return( false );
}
Exemplo n.º 7
0
void OPT_UNGET                  // UNGET A CHARACTER
    ( void )
{
    CmdScanUngetChar();
}