static int look(Scanner *s) { int state = 0; int c = 0; String *str_delimiter = 0; Clear(s->text); s->start_line = s->line; Setfile(s->text, Getfile(s->str)); while (1) { switch (state) { case 0: if ((c = nextchar(s)) == 0) return (0); /* Process delimiters */ if (c == '\n') { return SWIG_TOKEN_ENDLINE; } else if (!isspace(c)) { retract(s, 1); state = 1000; Clear(s->text); Setline(s->text, s->line); Setfile(s->text, Getfile(s->str)); } break; case 1000: if ((c = nextchar(s)) == 0) return (0); if (c == '%') state = 4; /* Possibly a SWIG directive */ /* Look for possible identifiers or unicode/delimiter strings */ else if ((isalpha(c)) || (c == '_') || (s->idstart && strchr(s->idstart, c))) { state = 7; } /* Look for single character symbols */ else if (c == '(') { brackets_push(s); return SWIG_TOKEN_LPAREN; } else if (c == ')') { brackets_pop(s); return SWIG_TOKEN_RPAREN; } else if (c == ';') { brackets_clear(s); return SWIG_TOKEN_SEMI; } else if (c == ',') return SWIG_TOKEN_COMMA; else if (c == '*') state = 220; else if (c == '}') return SWIG_TOKEN_RBRACE; else if (c == '{') { brackets_reset(s); return SWIG_TOKEN_LBRACE; } else if (c == '=') state = 33; else if (c == '+') state = 200; else if (c == '-') state = 210; else if (c == '&') state = 31; else if (c == '|') state = 32; else if (c == '^') state = 230; else if (c == '<') state = 60; else if (c == '>') state = 61; else if (c == '~') return SWIG_TOKEN_NOT; else if (c == '!') state = 3; else if (c == '\\') return SWIG_TOKEN_BACKSLASH; else if (c == '[') return SWIG_TOKEN_LBRACKET; else if (c == ']') return SWIG_TOKEN_RBRACKET; else if (c == '@') return SWIG_TOKEN_AT; else if (c == '$') state = 75; else if (c == '#') return SWIG_TOKEN_POUND; else if (c == '?') return SWIG_TOKEN_QUESTION; /* Look for multi-character sequences */ else if (c == '/') { state = 1; /* Comment (maybe) */ s->start_line = s->line; } else if (c == ':') state = 5; /* maybe double colon */ else if (c == '0') state = 83; /* An octal or hex value */ else if (c == '\"') { state = 2; /* A string constant */ s->start_line = s->line; Clear(s->text); } else if (c == '\'') { s->start_line = s->line; Clear(s->text); state = 9; /* A character constant */ } else if (c == '`') { s->start_line = s->line; Clear(s->text); state = 900; } else if (c == '.') state = 100; /* Maybe a number, maybe just a period */ else if (isdigit(c)) state = 8; /* A numerical value */ else state = 99; /* An error */ break; case 1: /* Comment block */ if ((c = nextchar(s)) == 0) return (0); if (c == '/') { state = 10; /* C++ style comment */ Clear(s->text); Setline(s->text, Getline(s->str)); Setfile(s->text, Getfile(s->str)); Append(s->text, "//"); } else if (c == '*') { state = 11; /* C style comment */ Clear(s->text); Setline(s->text, Getline(s->str)); Setfile(s->text, Getfile(s->str)); Append(s->text, "/*"); } else if (c == '=') { return SWIG_TOKEN_DIVEQUAL; } else { retract(s, 1); return SWIG_TOKEN_SLASH; } break; case 10: /* C++ style comment */ if ((c = nextchar(s)) == 0) { Swig_error(cparse_file, cparse_start_line, "Unterminated comment\n"); return SWIG_TOKEN_ERROR; } if (c == '\n') { retract(s,1); return SWIG_TOKEN_COMMENT; } else { state = 10; } break; case 11: /* C style comment block */ if ((c = nextchar(s)) == 0) { Swig_error(cparse_file, cparse_start_line, "Unterminated comment\n"); return SWIG_TOKEN_ERROR; } if (c == '*') { state = 12; } else { state = 11; } break; case 12: /* Still in C style comment */ if ((c = nextchar(s)) == 0) { Swig_error(cparse_file, cparse_start_line, "Unterminated comment\n"); return SWIG_TOKEN_ERROR; } if (c == '*') { state = 12; } else if (c == '/') { return SWIG_TOKEN_COMMENT; } else { state = 11; } break; case 2: /* Processing a string */ if (!str_delimiter) { state=20; break; } if ((c = nextchar(s)) == 0) { Swig_error(cparse_file, cparse_start_line, "Unterminated string\n"); return SWIG_TOKEN_ERROR; } else if (c == '(') { state = 20; } else { char temp[2] = { 0, 0 }; temp[0] = c; Append( str_delimiter, temp ); } break; case 20: /* Inside the string */ if ((c = nextchar(s)) == 0) { Swig_error(cparse_file, cparse_start_line, "Unterminated string\n"); return SWIG_TOKEN_ERROR; } if (!str_delimiter) { /* Ordinary string: "value" */ if (c == '\"') { Delitem(s->text, DOH_END); return SWIG_TOKEN_STRING; } else if (c == '\\') { Delitem(s->text, DOH_END); get_escape(s); } } else { /* Custom delimiter string: R"XXXX(value)XXXX" */ if (c==')') { int i=0; String *end_delimiter = NewStringEmpty(); while ((c = nextchar(s)) != 0 && c!='\"') { char temp[2] = { 0, 0 }; temp[0] = c; Append( end_delimiter, temp ); i++; } if (Strcmp( str_delimiter, end_delimiter )==0) { Delete( end_delimiter ); /* Correct end delimiter )XXXX" occured */ Delete( str_delimiter ); str_delimiter = 0; return SWIG_TOKEN_STRING; } else { /* Incorrect end delimiter occured */ if (c == 0) { Swig_error(cparse_file, cparse_start_line, "Unterminated raw string, started with R\"%s( is not terminated by )%s\"\n", str_delimiter, str_delimiter); return SWIG_TOKEN_ERROR; } retract( s, i ); Delete( end_delimiter ); } } } break; case 3: /* Maybe a not equals */ if ((c = nextchar(s)) == 0) return SWIG_TOKEN_LNOT; else if (c == '=') return SWIG_TOKEN_NOTEQUAL; else { retract(s, 1); return SWIG_TOKEN_LNOT; } break; case 31: /* AND or Logical AND or ANDEQUAL */ if ((c = nextchar(s)) == 0) return SWIG_TOKEN_AND; else if (c == '&') return SWIG_TOKEN_LAND; else if (c == '=') return SWIG_TOKEN_ANDEQUAL; else { retract(s, 1); return SWIG_TOKEN_AND; } break; case 32: /* OR or Logical OR */ if ((c = nextchar(s)) == 0) return SWIG_TOKEN_OR; else if (c == '|') return SWIG_TOKEN_LOR; else if (c == '=') return SWIG_TOKEN_OREQUAL; else { retract(s, 1); return SWIG_TOKEN_OR; } break; case 33: /* EQUAL or EQUALTO */ if ((c = nextchar(s)) == 0) return SWIG_TOKEN_EQUAL; else if (c == '=') return SWIG_TOKEN_EQUALTO; else { retract(s, 1); return SWIG_TOKEN_EQUAL; } break; case 4: /* A wrapper generator directive (maybe) */ if ((c = nextchar(s)) == 0) return SWIG_TOKEN_PERCENT; if (c == '{') { state = 40; /* Include block */ Clear(s->text); Setline(s->text, Getline(s->str)); Setfile(s->text, Getfile(s->str)); s->start_line = s->line; } else if (s->idstart && strchr(s->idstart, '%') && ((isalpha(c)) || (c == '_'))) { state = 7; } else if (c == '=') { return SWIG_TOKEN_MODEQUAL; } else if (c == '}') { Swig_error(cparse_file, cparse_line, "Syntax error. Extraneous '%%}'\n"); exit(1); } else { retract(s, 1); return SWIG_TOKEN_PERCENT; } break; case 40: /* Process an include block */ if ((c = nextchar(s)) == 0) { Swig_error(cparse_file, cparse_start_line, "Unterminated block\n"); return SWIG_TOKEN_ERROR; } if (c == '%') state = 41; break; case 41: /* Still processing include block */ if ((c = nextchar(s)) == 0) { set_error(s,s->start_line,"Unterminated code block"); return 0; } if (c == '}') { Delitem(s->text, DOH_END); Delitem(s->text, DOH_END); Seek(s->text,0,SEEK_SET); return SWIG_TOKEN_CODEBLOCK; } else { state = 40; } break; case 5: /* Maybe a double colon */ if ((c = nextchar(s)) == 0) return SWIG_TOKEN_COLON; if (c == ':') state = 50; else { retract(s, 1); return SWIG_TOKEN_COLON; } break; case 50: /* DCOLON, DCOLONSTAR */ if ((c = nextchar(s)) == 0) return SWIG_TOKEN_DCOLON; else if (c == '*') return SWIG_TOKEN_DCOLONSTAR; else { retract(s, 1); return SWIG_TOKEN_DCOLON; } break; case 60: /* shift operators */ if ((c = nextchar(s)) == 0) { brackets_increment(s); return SWIG_TOKEN_LESSTHAN; } if (c == '<') state = 240; else if (c == '=') return SWIG_TOKEN_LTEQUAL; else { retract(s, 1); brackets_increment(s); return SWIG_TOKEN_LESSTHAN; } break; case 61: if ((c = nextchar(s)) == 0) { brackets_decrement(s); return SWIG_TOKEN_GREATERTHAN; } if (c == '>' && brackets_allow_shift(s)) state = 250; else if (c == '=') return SWIG_TOKEN_GTEQUAL; else { retract(s, 1); brackets_decrement(s); return SWIG_TOKEN_GREATERTHAN; } break; case 7: /* Identifier or true/false or unicode/custom delimiter string */ if (c == 'R') { /* Possibly CUSTOM DELIMITER string */ state = 72; break; } else if (c == 'L') { /* Probably identifier but may be a wide string literal */ state = 77; break; } else if (c != 'u' && c != 'U') { /* Definitely an identifier */ state = 70; break; } if ((c = nextchar(s)) == 0) { state = 76; } else if (c == '\"') { /* Definitely u, U or L string */ retract(s, 1); state = 1000; } else if (c == 'R') { /* Possibly CUSTOM DELIMITER u, U, L string */ state = 73; } else if (c == '8') { /* Possibly u8 string */ state = 71; } else { retract(s, 1); /* Definitely an identifier */ state = 70; } break; case 70: /* Identifier */ if ((c = nextchar(s)) == 0) state = 76; else if (isalnum(c) || (c == '_') || (c == '$')) { state = 70; } else { retract(s, 1); state = 76; } break; case 71: /* Possibly u8 string */ if ((c = nextchar(s)) == 0) { state = 76; } else if (c=='\"') { retract(s, 1); /* Definitely u8 string */ state = 1000; } else if (c=='R') { state = 74; /* Possibly CUSTOM DELIMITER u8 string */ } else { retract(s, 2); /* Definitely an identifier. Retract 8" */ state = 70; } break; case 72: /* Possibly CUSTOM DELIMITER string */ case 73: case 74: if ((c = nextchar(s)) == 0) { state = 76; } else if (c=='\"') { retract(s, 1); /* Definitely custom delimiter u, U or L string */ str_delimiter = NewStringEmpty(); state = 1000; } else { if (state==72) { retract(s, 1); /* Definitely an identifier. Retract ? */ } else if (state==73) { retract(s, 2); /* Definitely an identifier. Retract R? */ } else if (state==74) { retract(s, 3); /* Definitely an identifier. Retract 8R? */ } state = 70; } break; case 75: /* Special identifier $ */ if ((c = nextchar(s)) == 0) return SWIG_TOKEN_DOLLAR; if (isalnum(c) || (c == '_') || (c == '*') || (c == '&')) { state = 70; } else { retract(s,1); if (Len(s->text) == 1) return SWIG_TOKEN_DOLLAR; state = 76; } break; case 76: /* Identifier or true/false */ if (cparse_cplusplus) { if (Strcmp(s->text, "true") == 0) return SWIG_TOKEN_BOOL; else if (Strcmp(s->text, "false") == 0) return SWIG_TOKEN_BOOL; } return SWIG_TOKEN_ID; break; case 77: /*identifier or wide string literal*/ if ((c = nextchar(s)) == 0) return SWIG_TOKEN_ID; else if (c == '\"') { s->start_line = s->line; Clear(s->text); state = 78; } else if (c == '\'') { s->start_line = s->line; Clear(s->text); state = 79; } else if (isalnum(c) || (c == '_') || (c == '$')) state = 7; else { retract(s, 1); return SWIG_TOKEN_ID; } break; case 78: /* Processing a wide string literal*/ if ((c = nextchar(s)) == 0) { Swig_error(cparse_file, cparse_start_line, "Unterminated wide string\n"); return SWIG_TOKEN_ERROR; } if (c == '\"') { Delitem(s->text, DOH_END); return SWIG_TOKEN_WSTRING; } else if (c == '\\') { if ((c = nextchar(s)) == 0) { Swig_error(cparse_file, cparse_start_line, "Unterminated wide string\n"); return SWIG_TOKEN_ERROR; } } break; case 79: /* Processing a wide char literal */ if ((c = nextchar(s)) == 0) { Swig_error(cparse_file, cparse_start_line, "Unterminated wide character constant\n"); return SWIG_TOKEN_ERROR; } if (c == '\'') { Delitem(s->text, DOH_END); return (SWIG_TOKEN_WCHAR); } else if (c == '\\') { if ((c = nextchar(s)) == 0) { Swig_error(cparse_file, cparse_start_line, "Unterminated wide character literal\n"); return SWIG_TOKEN_ERROR; } } break; case 8: /* A numerical digit */ if ((c = nextchar(s)) == 0) return SWIG_TOKEN_INT; if (c == '.') { state = 81; } else if ((c == 'e') || (c == 'E')) { state = 82; } else if ((c == 'f') || (c == 'F')) { Delitem(s->text, DOH_END); return SWIG_TOKEN_FLOAT; } else if (isdigit(c)) { state = 8; } else if ((c == 'l') || (c == 'L')) { state = 87; } else if ((c == 'u') || (c == 'U')) { state = 88; } else { retract(s, 1); return SWIG_TOKEN_INT; } break; case 81: /* A floating pointer number of some sort */ if ((c = nextchar(s)) == 0) return SWIG_TOKEN_DOUBLE; if (isdigit(c)) state = 81; else if ((c == 'e') || (c == 'E')) state = 820; else if ((c == 'f') || (c == 'F')) { Delitem(s->text, DOH_END); return SWIG_TOKEN_FLOAT; } else if ((c == 'l') || (c == 'L')) { Delitem(s->text, DOH_END); return SWIG_TOKEN_DOUBLE; } else { retract(s, 1); return (SWIG_TOKEN_DOUBLE); } break; case 82: if ((c = nextchar(s)) == 0) { Swig_error(cparse_file, cparse_start_line, "Exponent does not have any digits\n"); return SWIG_TOKEN_ERROR; } if ((isdigit(c)) || (c == '-') || (c == '+')) state = 86; else { retract(s, 2); Swig_error(cparse_file, cparse_start_line, "Exponent does not have any digits\n"); return SWIG_TOKEN_ERROR; } break; case 820: /* Like case 82, but we've seen a decimal point. */ if ((c = nextchar(s)) == 0) { Swig_error(cparse_file, cparse_start_line, "Exponent does not have any digits\n"); return SWIG_TOKEN_ERROR; } if ((isdigit(c)) || (c == '-') || (c == '+')) state = 86; else { retract(s, 2); Swig_error(cparse_file, cparse_start_line, "Exponent does not have any digits\n"); return SWIG_TOKEN_ERROR; } break; case 83: /* Might be a hexadecimal or octal number */ if ((c = nextchar(s)) == 0) return SWIG_TOKEN_INT; if (isdigit(c)) state = 84; else if ((c == 'x') || (c == 'X')) state = 85; else if (c == '.') state = 81; else if ((c == 'l') || (c == 'L')) { state = 87; } else if ((c == 'u') || (c == 'U')) { state = 88; } else { retract(s, 1); return SWIG_TOKEN_INT; } break; case 84: /* This is an octal number */ if ((c = nextchar(s)) == 0) return SWIG_TOKEN_INT; if (isdigit(c)) state = 84; else if ((c == 'l') || (c == 'L')) { state = 87; } else if ((c == 'u') || (c == 'U')) { state = 88; } else { retract(s, 1); return SWIG_TOKEN_INT; } break; case 85: /* This is an hex number */ if ((c = nextchar(s)) == 0) return SWIG_TOKEN_INT; if (isxdigit(c)) state = 85; else if ((c == 'l') || (c == 'L')) { state = 87; } else if ((c == 'u') || (c == 'U')) { state = 88; } else { retract(s, 1); return SWIG_TOKEN_INT; } break; case 86: /* Rest of floating point number */ if ((c = nextchar(s)) == 0) return SWIG_TOKEN_DOUBLE; if (isdigit(c)) state = 86; else if ((c == 'f') || (c == 'F')) { Delitem(s->text, DOH_END); return SWIG_TOKEN_FLOAT; } else if ((c == 'l') || (c == 'L')) { Delitem(s->text, DOH_END); return SWIG_TOKEN_DOUBLE; } else { retract(s, 1); return SWIG_TOKEN_DOUBLE; } break; case 87: /* A long integer of some sort */ if ((c = nextchar(s)) == 0) return SWIG_TOKEN_LONG; if ((c == 'u') || (c == 'U')) { return SWIG_TOKEN_ULONG; } else if ((c == 'l') || (c == 'L')) { state = 870; } else { retract(s, 1); return SWIG_TOKEN_LONG; } break; /* A long long integer */ case 870: if ((c = nextchar(s)) == 0) return SWIG_TOKEN_LONGLONG; if ((c == 'u') || (c == 'U')) { return SWIG_TOKEN_ULONGLONG; } else { retract(s, 1); return SWIG_TOKEN_LONGLONG; } /* An unsigned number */ case 88: if ((c = nextchar(s)) == 0) return SWIG_TOKEN_UINT; if ((c == 'l') || (c == 'L')) { state = 880; } else { retract(s, 1); return SWIG_TOKEN_UINT; } break; /* Possibly an unsigned long long or unsigned long */ case 880: if ((c = nextchar(s)) == 0) return SWIG_TOKEN_ULONG; if ((c == 'l') || (c == 'L')) return SWIG_TOKEN_ULONGLONG; else { retract(s, 1); return SWIG_TOKEN_ULONG; } /* A character constant */ case 9: if ((c = nextchar(s)) == 0) { Swig_error(cparse_file, cparse_start_line, "Unterminated character constant\n"); return SWIG_TOKEN_ERROR; } if (c == '\'') { Delitem(s->text, DOH_END); return (SWIG_TOKEN_CHAR); } else if (c == '\\') { Delitem(s->text, DOH_END); get_escape(s); } break; /* A period or maybe a floating point number */ case 100: if ((c = nextchar(s)) == 0) return (0); if (isdigit(c)) state = 81; else { retract(s, 1); return SWIG_TOKEN_PERIOD; } break; case 200: /* PLUS, PLUSPLUS, PLUSEQUAL */ if ((c = nextchar(s)) == 0) return SWIG_TOKEN_PLUS; else if (c == '+') return SWIG_TOKEN_PLUSPLUS; else if (c == '=') return SWIG_TOKEN_PLUSEQUAL; else { retract(s, 1); return SWIG_TOKEN_PLUS; } break; case 210: /* MINUS, MINUSMINUS, MINUSEQUAL, ARROW */ if ((c = nextchar(s)) == 0) return SWIG_TOKEN_MINUS; else if (c == '-') return SWIG_TOKEN_MINUSMINUS; else if (c == '=') return SWIG_TOKEN_MINUSEQUAL; else if (c == '>') state = 211; else { retract(s, 1); return SWIG_TOKEN_MINUS; } break; case 211: /* ARROW, ARROWSTAR */ if ((c = nextchar(s)) == 0) return SWIG_TOKEN_ARROW; else if (c == '*') return SWIG_TOKEN_ARROWSTAR; else { retract(s, 1); return SWIG_TOKEN_ARROW; } break; case 220: /* STAR, TIMESEQUAL */ if ((c = nextchar(s)) == 0) return SWIG_TOKEN_STAR; else if (c == '=') return SWIG_TOKEN_TIMESEQUAL; else { retract(s, 1); return SWIG_TOKEN_STAR; } break; case 230: /* XOR, XOREQUAL */ if ((c = nextchar(s)) == 0) return SWIG_TOKEN_XOR; else if (c == '=') return SWIG_TOKEN_XOREQUAL; else { retract(s, 1); return SWIG_TOKEN_XOR; } break; case 240: /* LSHIFT, LSEQUAL */ if ((c = nextchar(s)) == 0) return SWIG_TOKEN_LSHIFT; else if (c == '=') return SWIG_TOKEN_LSEQUAL; else { retract(s, 1); return SWIG_TOKEN_LSHIFT; } break; case 250: /* RSHIFT, RSEQUAL */ if ((c = nextchar(s)) == 0) return SWIG_TOKEN_RSHIFT; else if (c == '=') return SWIG_TOKEN_RSEQUAL; else { retract(s, 1); return SWIG_TOKEN_RSHIFT; } break; /* An illegal character */ /* Reverse string */ case 900: if ((c = nextchar(s)) == 0) { Swig_error(cparse_file, cparse_start_line, "Unterminated character constant\n"); return SWIG_TOKEN_ERROR; } if (c == '`') { Delitem(s->text, DOH_END); return (SWIG_TOKEN_RSTRING); } break; default: return SWIG_TOKEN_ILLEGAL; } } }
static int look(Scanner * s) { int state; int c = 0; state = 0; Clear(s->text); s->start_line = s->line; Setfile(s->text, Getfile(s->str)); while (1) { switch (state) { case 0: if ((c = nextchar(s)) == 0) return (0); /* Process delimiters */ if (c == '\n') { return SWIG_TOKEN_ENDLINE; } else if (!isspace(c)) { retract(s, 1); state = 1000; Clear(s->text); Setline(s->text, s->line); Setfile(s->text, Getfile(s->str)); } break; case 1000: if ((c = nextchar(s)) == 0) return (0); if (c == '%') state = 4; /* Possibly a SWIG directive */ /* Look for possible identifiers */ else if ((isalpha(c)) || (c == '_') || (s->idstart && strchr(s->idstart, c))) state = 7; /* Look for single character symbols */ else if (c == '(') return SWIG_TOKEN_LPAREN; else if (c == ')') return SWIG_TOKEN_RPAREN; else if (c == ';') return SWIG_TOKEN_SEMI; else if (c == ',') return SWIG_TOKEN_COMMA; else if (c == '*') state = 220; else if (c == '}') return SWIG_TOKEN_RBRACE; else if (c == '{') return SWIG_TOKEN_LBRACE; else if (c == '=') state = 33; else if (c == '+') state = 200; else if (c == '-') state = 210; else if (c == '&') state = 31; else if (c == '|') state = 32; else if (c == '^') state = 230; else if (c == '<') state = 60; else if (c == '>') state = 61; else if (c == '~') return SWIG_TOKEN_NOT; else if (c == '!') state = 3; else if (c == '\\') return SWIG_TOKEN_BACKSLASH; else if (c == '[') return SWIG_TOKEN_LBRACKET; else if (c == ']') return SWIG_TOKEN_RBRACKET; else if (c == '@') return SWIG_TOKEN_AT; else if (c == '$') state = 75; else if (c == '#') return SWIG_TOKEN_POUND; else if (c == '?') return SWIG_TOKEN_QUESTION; /* Look for multi-character sequences */ else if (c == '/') { state = 1; /* Comment (maybe) */ s->start_line = s->line; } else if (c == '\"') { state = 2; /* Possibly a string */ s->start_line = s->line; Clear(s->text); } else if (c == ':') state = 5; /* maybe double colon */ else if (c == '0') state = 83; /* An octal or hex value */ else if (c == '\'') { s->start_line = s->line; Clear(s->text); state = 9; /* A character constant */ } else if (c == '`') { s->start_line = s->line; Clear(s->text); state = 900; } else if (c == '.') state = 100; /* Maybe a number, maybe just a period */ else if (isdigit(c)) state = 8; /* A numerical value */ else state = 99; /* An error */ break; case 1: /* Comment block */ if ((c = nextchar(s)) == 0) return (0); if (c == '/') { state = 10; /* C++ style comment */ Clear(s->text); Setline(s->text, Getline(s->str)); Setfile(s->text, Getfile(s->str)); Append(s->text, "//"); } else if (c == '*') { state = 11; /* C style comment */ Clear(s->text); Setline(s->text, Getline(s->str)); Setfile(s->text, Getfile(s->str)); Append(s->text, "/*"); } else if (c == '=') { return SWIG_TOKEN_DIVEQUAL; } else { retract(s, 1); return SWIG_TOKEN_SLASH; } break; case 10: /* C++ style comment */ if ((c = nextchar(s)) == 0) { Swig_error(cparse_file, cparse_start_line, "Unterminated comment\n"); return SWIG_TOKEN_ERROR; } if (c == '\n') { retract(s,1); return SWIG_TOKEN_COMMENT; } else { state = 10; } break; case 11: /* C style comment block */ if ((c = nextchar(s)) == 0) { Swig_error(cparse_file, cparse_start_line, "Unterminated comment\n"); return SWIG_TOKEN_ERROR; } if (c == '*') { state = 12; } else { state = 11; } break; case 12: /* Still in C style comment */ if ((c = nextchar(s)) == 0) { Swig_error(cparse_file, cparse_start_line, "Unterminated comment\n"); return SWIG_TOKEN_ERROR; } if (c == '*') { state = 12; } else if (c == '/') { return SWIG_TOKEN_COMMENT; } else { state = 11; } break; case 2: /* Processing a string */ if ((c = nextchar(s)) == 0) { Swig_error(cparse_file, cparse_start_line, "Unterminated string\n"); return SWIG_TOKEN_ERROR; } if (c == '\"') { Delitem(s->text, DOH_END); return SWIG_TOKEN_STRING; } else if (c == '\\') { Delitem(s->text, DOH_END); get_escape(s); } else state = 2; break; case 3: /* Maybe a not equals */ if ((c = nextchar(s)) == 0) return SWIG_TOKEN_LNOT; else if (c == '=') return SWIG_TOKEN_NOTEQUAL; else { retract(s, 1); return SWIG_TOKEN_LNOT; } break; case 31: /* AND or Logical AND or ANDEQUAL */ if ((c = nextchar(s)) == 0) return SWIG_TOKEN_AND; else if (c == '&') return SWIG_TOKEN_LAND; else if (c == '=') return SWIG_TOKEN_ANDEQUAL; else { retract(s, 1); return SWIG_TOKEN_AND; } break; case 32: /* OR or Logical OR */ if ((c = nextchar(s)) == 0) return SWIG_TOKEN_OR; else if (c == '|') return SWIG_TOKEN_LOR; else if (c == '=') return SWIG_TOKEN_OREQUAL; else { retract(s, 1); return SWIG_TOKEN_OR; } break; case 33: /* EQUAL or EQUALTO */ if ((c = nextchar(s)) == 0) return SWIG_TOKEN_EQUAL; else if (c == '=') return SWIG_TOKEN_EQUALTO; else { retract(s, 1); return SWIG_TOKEN_EQUAL; } break; case 4: /* A wrapper generator directive (maybe) */ if ((c = nextchar(s)) == 0) return SWIG_TOKEN_PERCENT; if (c == '{') { state = 40; /* Include block */ Clear(s->text); Setline(s->text, Getline(s->str)); Setfile(s->text, Getfile(s->str)); s->start_line = s->line; } else if (s->idstart && strchr(s->idstart, '%') && ((isalpha(c)) || (c == '_'))) { state = 7; } else if (c == '=') { return SWIG_TOKEN_MODEQUAL; } else { retract(s, 1); return SWIG_TOKEN_PERCENT; } break; case 40: /* Process an include block */ if ((c = nextchar(s)) == 0) { Swig_error(cparse_file, cparse_start_line, "Unterminated block\n"); return SWIG_TOKEN_ERROR; } if (c == '%') state = 41; break; case 41: /* Still processing include block */ if ((c = nextchar(s)) == 0) { set_error(s,s->start_line,"Unterminated code block"); return 0; } if (c == '}') { Delitem(s->text, DOH_END); Delitem(s->text, DOH_END); Seek(s->text,0,SEEK_SET); return SWIG_TOKEN_CODEBLOCK; } else { state = 40; } break; case 5: /* Maybe a double colon */ if ((c = nextchar(s)) == 0) return SWIG_TOKEN_COLON; if (c == ':') state = 50; else { retract(s, 1); return SWIG_TOKEN_COLON; } break; case 50: /* DCOLON, DCOLONSTAR */ if ((c = nextchar(s)) == 0) return SWIG_TOKEN_DCOLON; else if (c == '*') return SWIG_TOKEN_DCOLONSTAR; else { retract(s, 1); return SWIG_TOKEN_DCOLON; } break; case 60: /* shift operators */ if ((c = nextchar(s)) == 0) return SWIG_TOKEN_LESSTHAN; if (c == '<') state = 240; else if (c == '=') return SWIG_TOKEN_LTEQUAL; else { retract(s, 1); return SWIG_TOKEN_LESSTHAN; } break; case 61: if ((c = nextchar(s)) == 0) return SWIG_TOKEN_GREATERTHAN; if (c == '>') state = 250; else if (c == '=') return SWIG_TOKEN_GTEQUAL; else { retract(s, 1); return SWIG_TOKEN_GREATERTHAN; } break; case 7: /* Identifier */ if ((c = nextchar(s)) == 0) state = 71; else if (isalnum(c) || (c == '_') || (c == '$')) { state = 7; } else { retract(s, 1); state = 71; } break; case 71: /* Identifier or true/false */ if (cparse_cplusplus) { if (Strcmp(s->text, "true") == 0) return SWIG_TOKEN_BOOL; else if (Strcmp(s->text, "false") == 0) return SWIG_TOKEN_BOOL; } return SWIG_TOKEN_ID; break; case 75: /* Special identifier $ */ if ((c = nextchar(s)) == 0) return SWIG_TOKEN_DOLLAR; if (isalnum(c) || (c == '_') || (c == '*') || (c == '&')) { state = 7; } else { retract(s,1); if (Len(s->text) == 1) return SWIG_TOKEN_DOLLAR; state = 71; } break; case 8: /* A numerical digit */ if ((c = nextchar(s)) == 0) return SWIG_TOKEN_INT; if (c == '.') { state = 81; } else if ((c == 'e') || (c == 'E')) { state = 82; } else if ((c == 'f') || (c == 'F')) { Delitem(s->text, DOH_END); return SWIG_TOKEN_FLOAT; } else if (isdigit(c)) { state = 8; } else if ((c == 'l') || (c == 'L')) { state = 87; } else if ((c == 'u') || (c == 'U')) { state = 88; } else { retract(s, 1); return SWIG_TOKEN_INT; } break; case 81: /* A floating pointer number of some sort */ if ((c = nextchar(s)) == 0) return SWIG_TOKEN_DOUBLE; if (isdigit(c)) state = 81; else if ((c == 'e') || (c == 'E')) state = 820; else if ((c == 'f') || (c == 'F')) { Delitem(s->text, DOH_END); return SWIG_TOKEN_FLOAT; } else if ((c == 'l') || (c == 'L')) { Delitem(s->text, DOH_END); return SWIG_TOKEN_DOUBLE; } else { retract(s, 1); return (SWIG_TOKEN_DOUBLE); } break; case 82: if ((c = nextchar(s)) == 0) { retract(s, 1); return SWIG_TOKEN_INT; } if ((isdigit(c)) || (c == '-') || (c == '+')) state = 86; else { retract(s, 2); return (SWIG_TOKEN_INT); } break; case 820: /* Like case 82, but we've seen a decimal point. */ if ((c = nextchar(s)) == 0) { retract(s, 1); return SWIG_TOKEN_DOUBLE; } if ((isdigit(c)) || (c == '-') || (c == '+')) state = 86; else { retract(s, 2); return (SWIG_TOKEN_DOUBLE); } break; case 83: /* Might be a hexadecimal or octal number */ if ((c = nextchar(s)) == 0) return SWIG_TOKEN_INT; if (isdigit(c)) state = 84; else if ((c == 'x') || (c == 'X')) state = 85; else if (c == '.') state = 81; else if ((c == 'l') || (c == 'L')) { state = 87; } else if ((c == 'u') || (c == 'U')) { state = 88; } else { retract(s, 1); return SWIG_TOKEN_INT; } break; case 84: /* This is an octal number */ if ((c = nextchar(s)) == 0) return SWIG_TOKEN_INT; if (isdigit(c)) state = 84; else if ((c == 'l') || (c == 'L')) { state = 87; } else if ((c == 'u') || (c == 'U')) { state = 88; } else { retract(s, 1); return SWIG_TOKEN_INT; } break; case 85: /* This is an hex number */ if ((c = nextchar(s)) == 0) return SWIG_TOKEN_INT; if (isxdigit(c)) state = 85; else if ((c == 'l') || (c == 'L')) { state = 87; } else if ((c == 'u') || (c == 'U')) { state = 88; } else { retract(s, 1); return SWIG_TOKEN_INT; } break; case 86: /* Rest of floating point number */ if ((c = nextchar(s)) == 0) return SWIG_TOKEN_DOUBLE; if (isdigit(c)) state = 86; else if ((c == 'f') || (c == 'F')) { Delitem(s->text, DOH_END); return SWIG_TOKEN_FLOAT; } else if ((c == 'l') || (c == 'L')) { Delitem(s->text, DOH_END); return SWIG_TOKEN_DOUBLE; } else { retract(s, 1); return SWIG_TOKEN_DOUBLE; } break; case 87: /* A long integer of some sort */ if ((c = nextchar(s)) == 0) return SWIG_TOKEN_LONG; if ((c == 'u') || (c == 'U')) { return SWIG_TOKEN_ULONG; } else if ((c == 'l') || (c == 'L')) { state = 870; } else { retract(s, 1); return SWIG_TOKEN_LONG; } break; /* A long long integer */ case 870: if ((c = nextchar(s)) == 0) return SWIG_TOKEN_LONGLONG; if ((c == 'u') || (c == 'U')) { return SWIG_TOKEN_ULONGLONG; } else { retract(s, 1); return SWIG_TOKEN_LONGLONG; } /* An unsigned number */ case 88: if ((c = nextchar(s)) == 0) return SWIG_TOKEN_UINT; if ((c == 'l') || (c == 'L')) { state = 880; } else { retract(s, 1); return SWIG_TOKEN_UINT; } break; /* Possibly an unsigned long long or unsigned long */ case 880: if ((c = nextchar(s)) == 0) return SWIG_TOKEN_ULONG; if ((c == 'l') || (c == 'L')) return SWIG_TOKEN_ULONGLONG; else { retract(s, 1); return SWIG_TOKEN_ULONG; } /* A character constant */ case 9: if ((c = nextchar(s)) == 0) { Swig_error(cparse_file, cparse_start_line, "Unterminated character constant\n"); return SWIG_TOKEN_ERROR; } if (c == '\'') { Delitem(s->text, DOH_END); return (SWIG_TOKEN_CHAR); } else if (c == '\\') { Delitem(s->text, DOH_END); get_escape(s); } break; /* A period or maybe a floating point number */ case 100: if ((c = nextchar(s)) == 0) return (0); if (isdigit(c)) state = 81; else { retract(s, 1); return SWIG_TOKEN_PERIOD; } break; case 200: /* PLUS, PLUSPLUS, PLUSEQUAL */ if ((c = nextchar(s)) == 0) return SWIG_TOKEN_PLUS; else if (c == '+') return SWIG_TOKEN_PLUSPLUS; else if (c == '=') return SWIG_TOKEN_PLUSEQUAL; else { retract(s, 1); return SWIG_TOKEN_PLUS; } break; case 210: /* MINUS, MINUSMINUS, MINUSEQUAL, ARROW */ if ((c = nextchar(s)) == 0) return SWIG_TOKEN_MINUS; else if (c == '-') return SWIG_TOKEN_MINUSMINUS; else if (c == '=') return SWIG_TOKEN_MINUSEQUAL; else if (c == '>') state = 211; else { retract(s, 1); return SWIG_TOKEN_MINUS; } break; case 211: /* ARROW, ARROWSTAR */ if ((c = nextchar(s)) == 0) return SWIG_TOKEN_ARROW; else if (c == '*') return SWIG_TOKEN_ARROWSTAR; else { retract(s, 1); return SWIG_TOKEN_ARROW; } break; case 220: /* STAR, TIMESEQUAL */ if ((c = nextchar(s)) == 0) return SWIG_TOKEN_STAR; else if (c == '=') return SWIG_TOKEN_TIMESEQUAL; else { retract(s, 1); return SWIG_TOKEN_STAR; } break; case 230: /* XOR, XOREQUAL */ if ((c = nextchar(s)) == 0) return SWIG_TOKEN_XOR; else if (c == '=') return SWIG_TOKEN_XOREQUAL; else { retract(s, 1); return SWIG_TOKEN_XOR; } break; case 240: /* LSHIFT, LSEQUAL */ if ((c = nextchar(s)) == 0) return SWIG_TOKEN_LSHIFT; else if (c == '=') return SWIG_TOKEN_LSEQUAL; else { retract(s, 1); return SWIG_TOKEN_LSHIFT; } break; case 250: /* RSHIFT, RSEQUAL */ if ((c = nextchar(s)) == 0) return SWIG_TOKEN_RSHIFT; else if (c == '=') return SWIG_TOKEN_RSEQUAL; else { retract(s, 1); return SWIG_TOKEN_RSHIFT; } break; /* An illegal character */ /* Reverse string */ case 900: if ((c = nextchar(s)) == 0) { Swig_error(cparse_file, cparse_start_line, "Unterminated character constant\n"); return SWIG_TOKEN_ERROR; } if (c == '`') { Delitem(s->text, DOH_END); return (SWIG_TOKEN_RSTRING); } break; default: return SWIG_TOKEN_ILLEGAL; } } }
/* * Print the contents of a buffer, at remote address 'addr' and of 'bytes' * size, as a field using name 'name' (which may be NULL). If the PF_FAILED * flag is given, the buffer address is printed instead, since it is assumed * that the actual buffer contains garbage. If the PF_LOCADDR flag is given, * the given address is a local address and no intraprocess copies are * performed. If the PF_STRING flag is given, the buffer is expected to * contain a null terminator within its size, and the string will be printed * only up to there. Normally, the string is cut off beyond a number of bytes * which depends on the verbosity level; if the PF_FULL flag is given, the full * string will be printed no matter its size (used mainly for path names, which * typically become useless once cut off). */ void put_buf(struct trace_proc * proc, const char * name, int flags, vir_bytes addr, ssize_t size) { const char *escaped; size_t len, off, max, chunk; int i, cutoff; char *p; if ((flags & PF_FAILED) || valuesonly || addr == 0 || size < 0) { if (flags & PF_LOCADDR) put_field(proc, name, "&.."); else put_ptr(proc, name, addr); return; } if (size == 0) { put_field(proc, name, "\"\""); return; } /* * TODO: the maximum says nothing about the size of the printed text. * Escaped-character printing can make the output much longer. Does it * make more sense to apply a limit after the escape transformation? */ if (verbose == 0) max = 32; else if (verbose == 1) max = 256; else max = SIZE_MAX; /* * If the output is cut off, we put two dots after the closing quote. * For non-string buffers, the output is cut off if the size exceeds * our limit or we run into a copying error somewhere in the middle. * For strings, the output is cut off unless we find a null terminator. */ cutoff = !!(flags & PF_STRING); len = (size_t)size; if (!(flags & PF_FULL) && len > max) { len = max; cutoff = TRUE; } for (off = 0; off < len; off += chunk) { chunk = len - off; if (chunk > sizeof(formatbuf) - 1) chunk = sizeof(formatbuf) - 1; if (!(flags & PF_LOCADDR)) { if (mem_get_data(proc->pid, addr + off, formatbuf, chunk) < 0) { if (off == 0) { put_ptr(proc, name, addr); return; } cutoff = TRUE; break; } } else memcpy(formatbuf, (void *)addr, chunk); if (off == 0) put_field(proc, name, "\""); /* In strings, look for the terminating null character. */ if ((flags & PF_STRING) && (p = memchr(formatbuf, '\0', chunk)) != NULL) { chunk = (size_t)(p - formatbuf); cutoff = FALSE; } /* Print the buffer contents using escaped characters. */ for (i = 0; i < chunk; i++) { escaped = get_escape(formatbuf[i]); put_text(proc, escaped); } /* Stop if we found the end of the string. */ if ((flags & PF_STRING) && !cutoff) break; } if (cutoff) put_text(proc, "\".."); else put_text(proc, "\""); }
int char_ioctl_arg(struct trace_proc * proc, unsigned long req, void * ptr, int dir) { minix_i2c_ioctl_exec_t *iie; struct fb_var_screeninfo *fbvs; struct volume_level *level; struct inout_ctrl *inout; struct termios *tc; struct ptmget *pm; struct winsize *ws; struct kio_bell *bell; struct kio_leds *leds; struct pciio_cfgreg *pci_cfgreg; struct pciio_bdf_cfgreg *pci_bdf_cfgreg; struct pciio_businfo *pci_businfo; struct pciio_map *pci_iomap; struct pciio_acl *pci_acl; switch (req) { case MINIX_I2C_IOCTL_EXEC: if ((iie = (minix_i2c_ioctl_exec_t *)ptr) == NULL) return IF_OUT; /* we print only the request for now */ put_i2c_op(proc, "iie_op", iie->iie_op); put_value(proc, "iie_addr", "0x%04x", iie->iie_addr); return 0; /* TODO: print command/data/result */ case FBIOGET_VSCREENINFO: if ((fbvs = (struct fb_var_screeninfo *)ptr) == NULL) return IF_IN; put_value(proc, "xres", "%"PRIu32, fbvs->xres); put_value(proc, "yres", "%"PRIu32, fbvs->yres); put_value(proc, "xres_virtual", "%"PRIu32, fbvs->xres_virtual); put_value(proc, "yres_virtual", "%"PRIu32, fbvs->yres_virtual); put_value(proc, "xoffset", "%"PRIu32, fbvs->xoffset); put_value(proc, "yoffset", "%"PRIu32, fbvs->yoffset); put_value(proc, "bits_per_pixel", "%"PRIu32, fbvs->bits_per_pixel); return 0; case FBIOPUT_VSCREENINFO: case FBIOPAN_DISPLAY: if ((fbvs = (struct fb_var_screeninfo *)ptr) == NULL) return IF_OUT; put_value(proc, "xoffset", "%"PRIu32, fbvs->xoffset); put_value(proc, "yoffset", "%"PRIu32, fbvs->yoffset); return 0; case DSPIORATE: case DSPIOSTEREO: case DSPIOSIZE: case DSPIOBITS: case DSPIOSIGN: case DSPIOMAX: case DSPIOFREEBUF: case DSPIOSAMPLESINBUF: if (ptr == NULL) return dir; put_value(proc, NULL, "%u", *(unsigned int *)ptr); return IF_ALL; case MIXIOGETVOLUME: if ((level = (struct volume_level *)ptr) == NULL) return dir; if (dir == IF_OUT) put_sound_device(proc, "device", level->device); else { put_value(proc, "left", "%d", level->left); put_value(proc, "right", "%d", level->right); } return IF_ALL; case MIXIOSETVOLUME: /* Print the corrected volume levels only with verbosity on. */ if ((level = (struct volume_level *)ptr) == NULL) return IF_OUT | ((verbose > 0) ? IF_IN : 0); if (dir == IF_OUT) put_sound_device(proc, "device", level->device); put_value(proc, "left", "%d", level->left); put_value(proc, "right", "%d", level->right); return IF_ALL; case MIXIOGETINPUTLEFT: case MIXIOGETINPUTRIGHT: case MIXIOGETOUTPUT: if ((inout = (struct inout_ctrl *)ptr) == NULL) return dir; if (dir == IF_OUT) put_sound_device(proc, "device", inout->device); else { put_sound_state(proc, "left", inout->left); put_sound_state(proc, "right", inout->right); } return IF_ALL; case MIXIOSETINPUTLEFT: case MIXIOSETINPUTRIGHT: case MIXIOSETOUTPUT: if ((inout = (struct inout_ctrl *)ptr) == NULL) return IF_OUT; put_sound_device(proc, "device", inout->device); put_sound_state(proc, "left", inout->left); put_sound_state(proc, "right", inout->right); return IF_ALL; case TIOCFLUSH: if (ptr == NULL) return IF_OUT; put_flags(proc, NULL, flush_flags, COUNT(flush_flags), "0x%x", *(int *)ptr); return IF_ALL; case TIOCGETA: case TIOCSETA: case TIOCSETAW: case TIOCSETAF: if ((tc = (struct termios *)ptr) == NULL) return dir; /* * These are fairly common IOCTLs, so printing everything by * default would create a lot of noise. By default we limit * ourselves to printing the field that contains what I * consider to be the most important flag: ICANON. * TODO: see if we can come up with a decent format for * selectively printing (relatively important) flags. */ if (verbose > 0) { put_flags(proc, "c_iflag", tc_iflags, COUNT(tc_iflags), "0x%x", tc->c_iflag); put_flags(proc, "c_oflag", tc_oflags, COUNT(tc_oflags), "0x%x", tc->c_oflag); put_flags(proc, "c_cflag", tc_cflags, COUNT(tc_cflags), "0x%x", tc->c_cflag); } put_flags(proc, "c_lflag", tc_lflags, COUNT(tc_lflags), "0x%x", tc->c_lflag); if (verbose > 0) { put_value(proc, "c_ispeed", "%d", tc->c_ispeed); put_value(proc, "c_ospeed", "%d", tc->c_ospeed); } return 0; /* TODO: print the c_cc fields */ case TIOCGETD: case TIOCSETD: if (ptr == NULL) return dir; put_tty_disc(proc, NULL, *(int *)ptr); return IF_ALL; case TIOCGLINED: case TIOCSLINED: if (ptr == NULL) return dir; put_buf(proc, NULL, PF_LOCADDR | PF_STRING, (vir_bytes)ptr, sizeof(linedn_t)); return IF_ALL; case TIOCGPGRP: case TIOCSPGRP: case TIOCOUTQ: case TIOCPKT: case TIOCREMOTE: case TIOCUCNTL: case TIOCSTAT: /* argument seems unused? */ case TIOCGSID: case TIOCCONS: /* argument seems unused? */ case TIOCEXT: case TIOCSQSIZE: case TIOCGQSIZE: /* Print a simple integer. */ if (ptr == NULL) return dir; put_value(proc, NULL, "%d", *(int *)ptr); return IF_ALL; case TIOCPTSNAME: if ((pm = (struct ptmget *)ptr) == NULL) return IF_IN; put_buf(proc, "sn", PF_LOCADDR | PF_STRING, (vir_bytes)pm->sn, sizeof(pm->sn)); return IF_ALL; case TIOCSTI: if (ptr == NULL) return dir; if (!valuesonly) put_value(proc, NULL, "'%s'", get_escape(*(char *)ptr)); else put_value(proc, NULL, "%u", *(char *)ptr); return IF_ALL; case TIOCGWINSZ: case TIOCSWINSZ: if ((ws = (struct winsize *)ptr) == NULL) return dir; /* This is a stupid order, but we follow the struct layout. */ put_value(proc, "ws_row", "%u", ws->ws_row); put_value(proc, "ws_col", "%u", ws->ws_col); if (verbose > 0) { put_value(proc, "ws_xpixel", "%u", ws->ws_xpixel); put_value(proc, "ws_ypixel", "%u", ws->ws_ypixel); } return (verbose > 0) ? IF_ALL : 0; case KIOCBELL: if ((bell = (struct kio_bell *)ptr) == NULL) return IF_OUT; put_value(proc, "kb_pitch", "%u", bell->kb_pitch); put_value(proc, "kb_volume", "%lu", bell->kb_volume); put_struct_timeval(proc, "kb_duration", PF_LOCADDR, (vir_bytes)&bell->kb_duration); return IF_ALL; case KIOCSLEDS: if ((leds = (struct kio_leds *)ptr) == NULL) return IF_OUT; put_flags(proc, "kl_bits", kbd_leds, COUNT(kbd_leds), "0x%x", leds->kl_bits); return IF_ALL; case PCI_IOC_CFGREAD: if ((pci_cfgreg = (struct pciio_cfgreg *)ptr) == NULL) return IF_IN; put_ptr(proc, "reg", (vir_bytes)pci_cfgreg->reg); put_value(proc, "val", "%08x", pci_cfgreg->val); return IF_ALL; case PCI_IOC_CFGWRITE: if ((pci_cfgreg = (struct pciio_cfgreg *)ptr) == NULL) return IF_OUT; put_ptr(proc, "reg", (vir_bytes)pci_cfgreg->reg); put_value(proc, "val", "%08x", pci_cfgreg->val); return IF_ALL; case PCI_IOC_BDF_CFGREAD: if ((pci_bdf_cfgreg = (struct pciio_bdf_cfgreg *)ptr) == NULL) return IF_IN; put_value(proc, "bus", "%u", pci_bdf_cfgreg->bus); put_value(proc, "device", "%u", pci_bdf_cfgreg->device); put_value(proc, "function", "%u", pci_bdf_cfgreg->function); put_ptr(proc, "cfgreg.reg", (vir_bytes)pci_bdf_cfgreg->cfgreg.reg); put_value(proc, "cfgreg.val", "%08x", pci_bdf_cfgreg->cfgreg.val); return IF_ALL; case PCI_IOC_BDF_CFGWRITE: if ((pci_bdf_cfgreg = (struct pciio_bdf_cfgreg *)ptr) == NULL) return IF_OUT; put_value(proc, "bus", "%u", pci_bdf_cfgreg->bus); put_value(proc, "device", "%u", pci_bdf_cfgreg->device); put_value(proc, "function", "%u", pci_bdf_cfgreg->function); put_ptr(proc, "cfgreg.reg", (vir_bytes)pci_bdf_cfgreg->cfgreg.reg); put_value(proc, "cfgreg.val", "%08x", pci_bdf_cfgreg->cfgreg.val); return IF_ALL; case PCI_IOC_BUSINFO: if ((pci_businfo = (struct pciio_businfo *)ptr) == NULL) return IF_IN; put_value(proc, "busno", "%u", pci_businfo->busno); put_value(proc, "maxdevs", "%u", pci_businfo->maxdevs); return IF_ALL; case PCI_IOC_MAP: if ((pci_iomap = (struct pciio_map *)ptr) == NULL) return IF_OUT|IF_IN; put_value(proc, "flags", "%x", pci_iomap->flags); put_value(proc, "phys_offset", "%08x", pci_iomap->phys_offset); put_value(proc, "size", "%zu", pci_iomap->size); put_value(proc, "readonly", "%x", pci_iomap->readonly); if (IF_IN == dir) put_ptr(proc, "vaddr_ret", (vir_bytes)pci_iomap->vaddr_ret); return IF_ALL; case PCI_IOC_UNMAP: if ((pci_iomap = (struct pciio_map *)ptr) == NULL) return IF_OUT; put_ptr(proc, "vaddr", (vir_bytes)pci_iomap->vaddr); return IF_ALL; case PCI_IOC_RESERVE: if ((pci_acl = (struct pciio_acl *)ptr) == NULL) return IF_OUT; put_value(proc, "domain", "%u", pci_acl->domain); put_value(proc, "bus", "%u", pci_acl->bus); put_value(proc, "device", "%u", pci_acl->device); put_value(proc, "function", "%u", pci_acl->function); return IF_ALL; case PCI_IOC_RELEASE: if ((pci_acl = (struct pciio_acl *)ptr) == NULL) return IF_OUT; put_value(proc, "domain", "%u", pci_acl->domain); put_value(proc, "bus", "%u", pci_acl->bus); put_value(proc, "device", "%u", pci_acl->device); put_value(proc, "function", "%u", pci_acl->function); return IF_ALL; default: return 0; } }
int yylook(void) { int state; int c = 0; state = 0; yylen = 0; while(1) { /* printf("State = %d\n", state); */ switch(state) { case 0 : if((c = nextchar()) == 0) return (0); /* Process delimeters */ if (c == '\n') { state = 0; yylen = 0; /* last_id = 0;*/ } else if (isspace(c) || (c=='\\')) { state = 0; yylen = 0; /* last_id = 0; */ } else if ((isalpha(c)) || (c == '_')) state = 7; else if (c == '$') state = 75; /* Look for single character symbols */ else if (c == '(') return (LPAREN); else if (c == ')') return (RPAREN); else if (c == ';') return (SEMI); else if (c == ',') return (COMMA); else if (c == '*') return (STAR); else if (c == '}') { num_brace--; if (num_brace < 0) { Swig_error(cparse_file, cparse_line, "Syntax error. Extraneous '}'\n"); state = 0; num_brace = 0; } else { return (RBRACE); } } else if (c == '{') { last_brace = num_brace; num_brace++; return (LBRACE); } else if (c == '=') return (EQUAL); else if (c == '+') return (PLUS); else if (c == '-') return (MINUS); else if (c == '&') { state = 300; } else if (c == '|') { state = 301; } else if (c == '^') return (XOR); else if (c == '<') state = 60; else if (c == '>') state = 61; else if (c == '~') { return (NOT); } else if (c == '!') return (LNOT); else if (c == '\\') { state = 99; } else if (c == '[') return (LBRACKET); else if (c == ']') return (RBRACKET); /* Look for multi-character sequences */ else if (c == '/') state = 1; /* Comment (maybe) */ else if (c == '\"') state = 2; /* Possibly a string */ else if (c == '#') state = 3; /* CPP */ else if (c == '%') state = 4; /* Directive */ else if (c == '@') state = 4; /* Objective C keyword */ else if (c == ':') state = 5; /* maybe double colon */ else if (c == '0') state = 83; /* An octal or hex value */ else if (c == '\'') state = 9; /* A character constant */ else if (c == '.') state = 100; /* Maybe a number, maybe just a period */ else if (c == '`') { state = 200; /* Back-tick type */ yylen = 0; } else if (isdigit(c)) state = 8; /* A numerical value */ else state = 99; break; case 1: /* Comment block */ if ((c = nextchar()) == 0) return(0); if (c == '/') { comment_start = cparse_line; Clear(comment); state = 10; /* C++ style comment */ } else if (c == '*') { comment_start = cparse_line; Clear(comment); state = 12; /* C style comment */ } else { retract(1); return(SLASH); } break; case 300: /* & or && */ if ((c = nextchar()) == 0) return(AND); if (c == '&') return(LAND); else { retract(1); return(AND); } case 301: /* | or || */ if ((c = nextchar()) == 0) return(OR); if (c == '|') return(LOR); else { retract(1); return(OR); } case 10: /* C++ style comment */ if ((c = nextchar()) == 0) { Swig_error(cparse_file,-1, "Unterminated comment detected.\n"); return 0; } if (c == '\n') { Putc(c,comment); /* Add the comment to documentation */ /* yycomment(Char(comment),comment_start, column_start);*/ yylen = 0; state = 0; } else { state = 10; Putc(c,comment); yylen = 0; } break; case 12: /* C style comment block */ if ((c = nextchar()) == 0) { Swig_error(cparse_file,-1,"Unterminated comment detected.\n"); return 0; } if (c == '*') { state = 13; } else { Putc(c,comment); yylen = 0; state = 12; } break; case 13: /* Still in C style comment */ if ((c = nextchar()) == 0) { Swig_error(cparse_file,-1,"Unterminated comment detected.\n"); return 0; } if (c == '*') { Putc(c,comment); state = 13; } else if (c == '/') { /* Look for locator markers */ { char *loc = Char(comment); if (Len(comment)) { if ((*loc == '@') && (*(loc+Len(comment)-1) == '@')) { /* Locator */ scanner_locator(comment); } } } /* yycomment(Char(comment),comment_start,column_start); */ yylen = 0; state = 0; } else { Putc('*',comment); Putc(c,comment); yylen = 0; state = 12; } break; case 2: /* Processing a string */ if ((c = nextchar()) == 0) { Swig_error(cparse_file,-1, "Unterminated string detected.\n"); return 0; } if (c == '\"') { yytext[yylen-1] = 0; yylval.id = Swig_copy_string(yytext+1); return(STRING); } else if (c == '\\') { yylen--; get_escape(); break; } else state = 2; break; case 3: /* a CPP directive */ if (( c= nextchar()) == 0) return 0; if (c == '\n') { retract(1); yytext[yylen] = 0; yylval.id = yytext; return(POUND); } break; case 4: /* A wrapper generator directive (maybe) */ if (( c= nextchar()) == 0) return 0; if (c == '{') { state = 40; /* Include block */ Clear(header); cparse_start_line = cparse_line; } else if ((isalpha(c)) || (c == '_')) state = 7; else if (c == '}') { Swig_error(cparse_file,cparse_line, "Misplaced %%}.\n"); return 0; } else { retract(1); return(MODULO); } break; case 40: /* Process an include block */ if ((c = nextchar()) == 0) { Swig_error(cparse_file,-1, "Unterminated include block detected.\n"); return 0; } yylen = 0; if (c == '%') state = 41; else { Putc(c,header); yylen = 0; state = 40; } break; case 41: /* Still processing include block */ if ((c = nextchar()) == 0) { Swig_error(cparse_file,-1, "Unterminated include block detected.\n"); return 0; } if (c == '}') { yylval.str = NewString(header); return(HBLOCK); } else { Putc('%',header); Putc(c,header); yylen = 0; state = 40; } break; case 5: /* Maybe a double colon */ if (( c= nextchar()) == 0) return 0; if ( c == ':') { state = 51; } else { retract(1); return COLON; } break; case 51: /* Maybe a ::*, ::~, or :: */ if (( c = nextchar()) == 0) return 0; if (c == '*') { return DSTAR; } else if (c == '~') { return DCNOT; } else if (isspace(c)) { /* Keep scanning ahead. Might be :: * or :: ~ */ } else { retract(1); if (!last_id) { retract(2); return NONID; } else { return DCOLON; } } break; case 60: /* shift operators */ if ((c = nextchar()) == 0) return (0); if (c == '<') return LSHIFT; else { retract(1); return LESSTHAN; } break; case 61: if ((c = nextchar()) == 0) return (0); if (c == '>') return RSHIFT; else { retract(1); return GREATERTHAN; } break; case 7: /* Identifier */ if ((c = nextchar()) == 0) return(0); if (isalnum(c) || (c == '_') || (c == '.') || (c == '$')) { state = 7; } else { retract(1); return(ID); } break; case 75: /* Special identifier $*/ if ((c = nextchar()) == 0) return(0); if (isalnum(c) || (c == '_') || (c == '*') || (c == '&')) { state = 7; } else { retract(1); return(ID); } break; case 8: /* A numerical digit */ if ((c = nextchar()) == 0) return(0); if (c == '.') {state = 81;} else if ((c == 'e') || (c == 'E')) {state = 86;} else if ((c == 'f') || (c == 'F')) { return(NUM_FLOAT); } else if (isdigit(c)) { state = 8;} else if ((c == 'l') || (c == 'L')) { state = 87; } else if ((c == 'u') || (c == 'U')) { state = 88; } else { retract(1); return(NUM_INT); } break; case 81: /* A floating pointer number of some sort */ if ((c = nextchar()) == 0) return(0); if (isdigit(c)) state = 81; else if ((c == 'e') || (c == 'E')) state = 82; else if ((c == 'f') || (c == 'F') || (c == 'l') || (c == 'L')) { return(NUM_FLOAT); } else { retract(1); return(NUM_FLOAT); } break; case 82: if ((c = nextchar()) == 0) return(0); if ((isdigit(c)) || (c == '-') || (c == '+')) state = 86; else { retract(2); yytext[yylen-1] = 0; return(NUM_INT); } break; case 83: /* Might be a hexidecimal or octal number */ if ((c = nextchar()) == 0) return(0); if (isdigit(c)) state = 84; else if ((c == 'x') || (c == 'X')) state = 85; else if (c == '.') state = 81; else if ((c == 'l') || (c == 'L')) { state = 87; } else if ((c == 'u') || (c == 'U')) { state = 88; } else { retract(1); return(NUM_INT); } break; case 84: /* This is an octal number */ if ((c = nextchar()) == 0) return (0); if (isdigit(c)) state = 84; else if ((c == 'l') || (c == 'L')) { state = 87; } else if ((c == 'u') || (c == 'U')) { state = 88; } else { retract(1); return(NUM_INT); } break; case 85: /* This is an hex number */ if ((c = nextchar()) == 0) return (0); if ((isdigit(c)) || (c=='a') || (c=='b') || (c=='c') || (c=='d') || (c=='e') || (c=='f') || (c=='A') || (c=='B') || (c=='C') || (c=='D') || (c=='E') || (c=='F')) state = 85; else if ((c == 'l') || (c == 'L')) { state = 87; } else if ((c == 'u') || (c == 'U')) { state = 88; } else { retract(1); return(NUM_INT); } break; case 86: /* Rest of floating point number */ if ((c = nextchar()) == 0) return (0); if (isdigit(c)) state = 86; else if ((c == 'f') || (c == 'F') || (c == 'l') || (c == 'L')) { return(NUM_FLOAT); } else { retract(1); return(NUM_FLOAT); } /* Parse a character constant. ie. 'a' */ break; case 87 : /* A long integer of some sort */ if ((c = nextchar()) == 0) return (NUM_LONG); if ((c == 'u') || (c == 'U')) { return(NUM_ULONG); } else if ((c == 'l') || (c == 'L')) { state = 870; } else { retract(1); return(NUM_LONG); } break; case 870: if ((c = nextchar()) == 0) return (NUM_LONGLONG); if ((c == 'u') || (c == 'U')) { return (NUM_ULONGLONG); } else { retract(1); return(NUM_LONGLONG); } case 88: /* An unsigned integer of some sort */ if ((c = nextchar()) == 0) return (NUM_UNSIGNED); if ((c == 'l') || (c == 'L')) { state = 880; } else { retract(1); return(NUM_UNSIGNED); } break; case 880: if ((c = nextchar()) == 0) return (NUM_ULONG); if ((c == 'l') || (c == 'L')) return (NUM_ULONGLONG); else { retract(1); return(NUM_ULONG); } case 9: if ((c = nextchar()) == 0) return (0); if (c == '\\') { yylen--; get_escape(); } else if (c == '\'') { yytext[yylen-1] = 0; yylval.str = NewString(yytext+1); if (yylen == 2) { Swig_error(cparse_file, cparse_line, "Empty character constant\n"); } return(CHARCONST); } break; case 100: if ((c = nextchar()) == 0) return (0); if (isdigit(c)) state = 81; else { retract(1); return(PERIOD); } break; case 200: if ((c = nextchar()) == 0) return (0); if (c == '`') { yytext[yylen-1] = 0; yylval.type = NewString(yytext); return(TYPE_RAW); } break; default: Swig_error(cparse_file, cparse_line, "Illegal character '%c'=%d.\n",c,c); state = 0; return(ILLEGAL); } } }