ShellBanner
System:Linux MiraNet 3.0.0-14-generic-pae #23-Ubuntu SMP Mon Nov 21 22:07:10 UTC 2011 i686
Software:Apache. PHP/5.3.6-13ubuntu3.10
ID:uid=65534(nobody) gid=65534(nogroup) groups=65534(nogroup)
Safe Mode:OFF
Open_Basedir:OFF
Freespace:21.79 GB of 70.42 GB (30.94%)
MySQL: ON MSSQL: OFF Oracle: OFF PostgreSQL: OFF Curl: OFF Sockets: ON Fetch: OFF Wget: ON Perl: ON
Disabled Functions: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,

/ usr/ share/ doc/ re2c/ examples/ lessons/ 001_upn_calculator/ - drwxr-xr-x

Directory:
Viewing file:     calc_005.c (3.67 KB)      -rw-r--r--
Select action/file-type:
(+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
/* Generated by re2c */
#line 1 "calc_005.re"
/* re2c lesson 001_upn_calculator, calc_005, (c) M. Boerger 2006 - 2007 */
#line 19 "calc_005.re"

#include <stdlib.h>
#include <stdio.h>
#include <string.h>

#define DEBUG(stmt) stmt

int  stack[4];
int  depth = 0;

int push_num(const char *t, const char *l, int radix)
{
    int num = 0;
    
    if (depth >= sizeof(stack))
    {
        return 3;
    }

    --t;
    while(++t < l)
    {
        num = num * radix + (*t - '0');
    }
    DEBUG(printf("Num: %d\n", num));

    stack[depth++] = num;
    return 0;
}

int stack_add()
{
    if (depth < 2) return 4;
    
    --depth;
    stack[depth-1] = stack[depth-1] + stack[depth];
    return 0;
}

int stack_sub()
{
    if (depth < 2) return 4;

    --depth;
    stack[depth-1] = stack[depth-1] - stack[depth];
    return 0;
}

int scan(char *s, int l)
{
    char *p = s;
    char *q = 0;
    char *t;
    int res = 0;

#define YYCTYPE         char
#define YYCURSOR        p
#define YYLIMIT         (s+l+1)
#define YYMARKER        q
#define YYFILL(n)        { return depth == 1 ? 0 : 2; }
    
    while(!res)
    {
        t = p;

#line 71 "<stdout>"
        {
            YYCTYPE yych;

            if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2);
            yych = *YYCURSOR;
            switch (yych) {
            case '\t':
            case ' ':    goto yy2;
            case '+':    goto yy7;
            case '-':    goto yy9;
            case '0':    goto yy4;
            case '1':
            case '2':
            case '3':
            case '4':
            case '5':
            case '6':
            case '7':
            case '8':
            case '9':    goto yy6;
            default:    goto yy11;
            }
yy2:
            ++YYCURSOR;
            yych = *YYCURSOR;
            goto yy19;
yy3:
#line 91 "calc_005.re"
            { continue; }
#line 101 "<stdout>"
yy4:
            ++YYCURSOR;
            switch ((yych = *YYCURSOR)) {
            case '0':
            case '1':
            case '2':
            case '3':
            case '4':
            case '5':
            case '6':
            case '7':
            case '8':
            case '9':    goto yy15;
            default:    goto yy5;
            }
yy5:
#line 93 "calc_005.re"
            { res = push_num(t, p, 10); continue; }
#line 120 "<stdout>"
yy6:
            yych = *++YYCURSOR;
            goto yy14;
yy7:
            ++YYCURSOR;
#line 94 "calc_005.re"
            { res = stack_add();        continue; }
#line 128 "<stdout>"
yy9:
            ++YYCURSOR;
#line 95 "calc_005.re"
            { res = stack_sub();        continue; }
#line 133 "<stdout>"
yy11:
            ++YYCURSOR;
#line 96 "calc_005.re"
            { res = 1;                     continue; }
#line 138 "<stdout>"
yy13:
            ++YYCURSOR;
            if (YYLIMIT <= YYCURSOR) YYFILL(1);
            yych = *YYCURSOR;
yy14:
            switch (yych) {
            case '0':
            case '1':
            case '2':
            case '3':
            case '4':
            case '5':
            case '6':
            case '7':
            case '8':
            case '9':    goto yy13;
            default:    goto yy5;
            }
yy15:
            ++YYCURSOR;
            if (YYLIMIT <= YYCURSOR) YYFILL(1);
            yych = *YYCURSOR;
            switch (yych) {
            case '0':
            case '1':
            case '2':
            case '3':
            case '4':
            case '5':
            case '6':
            case '7':
            case '8':
            case '9':    goto yy15;
            default:    goto yy17;
            }
yy17:
#line 92 "calc_005.re"
            { res = push_num(t, p, 8);    continue; }
#line 177 "<stdout>"
yy18:
            ++YYCURSOR;
            if (YYLIMIT <= YYCURSOR) YYFILL(1);
            yych = *YYCURSOR;
yy19:
            switch (yych) {
            case '\t':
            case ' ':    goto yy18;
            default:    goto yy3;
            }
        }
#line 97 "calc_005.re"

    }
    return res;
}

int main(int argc, char **argv)
{
    if (argc > 1)
    {
        char *inp;
        int res = 0, argp = 0, len;
        
        while(!res && ++argp < argc)
        {
            inp = argv[argp];
            len = strlen(inp);
            if (inp[0] == '\"' && inp[len-1] == '\"')
            {
                ++inp;
                len -=2;
            }
            res = scan(inp, len);
        }
        switch(res)
        {
        case 0:
            printf("Result: %d\n", stack[0]);
            return 0;
        case 1:
            fprintf(stderr, "Illegal character in input.\n");
            return 1;
        case 2:
            fprintf(stderr, "Premature end of input.\n");
            return 2;
        case 3:
            fprintf(stderr, "Stack overflow.\n");
            return 3;
        case 4:
            fprintf(stderr, "Stack underflow.\n");
            return 4;
        }
    }
    else
    {
        fprintf(stderr, "%s <expr>\n", argv[0]);
        return 0;
    }
}
Command:
Quick Commands:
Upload:
[Read-Only] Max size: 100MB
PHP Filesystem: <@ Ú
Search File:
regexp
Create File:
Overwrite [Read-Only]
View File:
Mass Defacement:
[+] Main Directory: [+] Defacement Url:
LmfaoX Shell - Private Build [BETA] - v0.1 -; Generated: 0.446 seconds