├── analyse.o ├── convert.h ├── erreurs.c ├── erreurs.o ├── exit_if.c ├── exit_if.o ├── vecteur.c ├── vecteur.o ├── list_exist.o ├── papers ├── 51-160-1-PB.pdf ├── Software-Security.pdf └── laszlo_obfuscating.pdf ├── classe.h ├── cons.h ├── erreurs.h ├── instancier.h ├── list_exist.h ├── vecteur.h ├── Makefile ├── exit_if.h ├── list_exist.c ├── Readme.txt ├── analyse.l └── lex.yy.c /analyse.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khaleghsalehi/COBFU/HEAD/analyse.o -------------------------------------------------------------------------------- /convert.h: -------------------------------------------------------------------------------- 1 | #ifndef H_CONVERT 2 | #define H_CONVERT 3 | 4 | #endif 5 | -------------------------------------------------------------------------------- /erreurs.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khaleghsalehi/COBFU/HEAD/erreurs.c -------------------------------------------------------------------------------- /erreurs.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khaleghsalehi/COBFU/HEAD/erreurs.o -------------------------------------------------------------------------------- /exit_if.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khaleghsalehi/COBFU/HEAD/exit_if.c -------------------------------------------------------------------------------- /exit_if.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khaleghsalehi/COBFU/HEAD/exit_if.o -------------------------------------------------------------------------------- /vecteur.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khaleghsalehi/COBFU/HEAD/vecteur.c -------------------------------------------------------------------------------- /vecteur.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khaleghsalehi/COBFU/HEAD/vecteur.o -------------------------------------------------------------------------------- /list_exist.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khaleghsalehi/COBFU/HEAD/list_exist.o -------------------------------------------------------------------------------- /papers/51-160-1-PB.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khaleghsalehi/COBFU/HEAD/papers/51-160-1-PB.pdf -------------------------------------------------------------------------------- /papers/Software-Security.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khaleghsalehi/COBFU/HEAD/papers/Software-Security.pdf -------------------------------------------------------------------------------- /papers/laszlo_obfuscating.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khaleghsalehi/COBFU/HEAD/papers/laszlo_obfuscating.pdf -------------------------------------------------------------------------------- /classe.h: -------------------------------------------------------------------------------- 1 | #ifndef CLASSE_H 2 | #define CLASSE_H 3 | 4 | #define CLASSE(c_ident) typedef struct c_ident *c_ident 5 | 6 | #endif /* CLASSE_H */ 7 | -------------------------------------------------------------------------------- /cons.h: -------------------------------------------------------------------------------- 1 | #ifndef H_CONS 2 | #define H_CONS 3 | 4 | typedef struct cons 5 | { 6 | char * first; 7 | char * second; 8 | int toSave; 9 | } cons; 10 | 11 | #endif 12 | -------------------------------------------------------------------------------- /erreurs.h: -------------------------------------------------------------------------------- 1 | #ifndef ERREURS_H 2 | #define ERREURS_H 3 | 4 | extern char *err_malloc; 5 | extern char *err_calloc; 6 | extern char *err_realloc; 7 | 8 | #endif /* ERREURS_H */ 9 | -------------------------------------------------------------------------------- /instancier.h: -------------------------------------------------------------------------------- 1 | #ifndef INSTANCIER_H 2 | #define INSTANCIER_H 3 | 4 | #include 5 | #include 6 | 7 | #include "exit_if.h" 8 | 9 | #define INSTANCIER(c_ident) \ 10 | c_ident recv = malloc(sizeof(struct c_ident));\ 11 | EXIT_IF(recv==NULL, "erreur instanciation: " #c_ident) 12 | 13 | #endif /* INSTANCIER_H */ 14 | -------------------------------------------------------------------------------- /list_exist.h: -------------------------------------------------------------------------------- 1 | #ifndef H_LIST_EXIST 2 | #define H_LIST_EXIST 3 | #include "vecteur.h" 4 | #include "cons.h" 5 | 6 | typedef vecteur list_exist; 7 | 8 | extern list_exist create(); 9 | extern cons * get_from_key(list_exist list, char * key, int isAuto, int byPass); 10 | extern void delete(list_exist list); 11 | extern void saveToFile(list_exist list, char * filename); 12 | 13 | #endif 14 | 15 | -------------------------------------------------------------------------------- /vecteur.h: -------------------------------------------------------------------------------- 1 | #ifndef VECTEUR_H 2 | #define VECTEUR_H 3 | 4 | #include "classe.h" 5 | 6 | CLASSE(vecteur); 7 | 8 | extern vecteur vecteur_faire(void); 9 | extern void vecteur_defaire(vecteur); 10 | extern void vecteur_ecrire(vecteur, int, void *); 11 | extern void *vecteur_lire(vecteur, int); 12 | extern int vecteur_nombre_elements(vecteur); 13 | extern void vecteur_mode_bavard(vecteur, int); 14 | 15 | #endif /* VECTEUR_H */ 16 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | CC=gcc 2 | CFLAGS=-g -Wall -Werror 3 | LDFLAGS= 4 | 5 | OBJS=erreurs.o exit_if.o list_exist.o vecteur.o analyse.o 6 | HEAD=erreurs.h exit_if.h list_exist.h vecteur.h classe.h cons.h instancier.h 7 | 8 | all:gram 9 | erreurs.o:erreurs.c 10 | exit_if.o:exit_if.c 11 | list_exist.o:list_exist.c 12 | vecteur.o:vecteur.c 13 | gen: 14 | lex analyse.l 15 | analyse.o:gen lex.yy.c 16 | gram:$(OBJS) gen 17 | $(CC) $(OBJS) $(HEAD) -o gram 18 | clean: 19 | rm -fr $(OBJS) lex.yy.c gram 20 | -------------------------------------------------------------------------------- /exit_if.h: -------------------------------------------------------------------------------- 1 | #ifndef EXIT_IF_H 2 | #define EXIT_IF_H 3 | 4 | #include 5 | 6 | #define EXIT_IF(expression, message) \ 7 | exit_if(__FILE__, __LINE__, expression, #expression, message) 8 | 9 | #define PERROR_AND_EXIT() \ 10 | perror_and_exit(__FILE__ ":" PERROR__STRING(__LINE__) ":") 11 | #define PERROR__STRING(n) PERROR___STRING(n) 12 | #define PERROR___STRING(n) #n 13 | 14 | extern void exit_if(char *fichier, int ligne, bool condition, 15 | char *code, char *message); 16 | extern char *exit_message; 17 | extern void perror_and_exit(char *localisation); 18 | 19 | #endif /* EXIT_IF_H */ 20 | -------------------------------------------------------------------------------- /list_exist.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include "list_exist.h" 6 | #include "vecteur.h" 7 | #include "cons.h" 8 | #include "erreurs.h" 9 | #include "exit_if.h" 10 | 11 | list_exist create() 12 | { 13 | srand(time(NULL)); 14 | return vecteur_faire(); 15 | } 16 | 17 | static cons * is_in(list_exist list, char * key, int n) 18 | { 19 | int i = 0; 20 | for(i = 0; i < vecteur_nombre_elements(list); i++) 21 | { 22 | cons * tmp = vecteur_lire(list, i); 23 | switch(n) 24 | { 25 | case 0: 26 | { 27 | if(!strcmp(tmp->first, key)) 28 | return tmp; 29 | break; 30 | } 31 | case 1: 32 | { 33 | if(!strcmp(tmp->second, key)) 34 | return tmp; 35 | break; 36 | } 37 | } 38 | } 39 | return NULL; 40 | } 41 | 42 | // On suppose afirst = s; 65 | res->second = next; 66 | res->toSave = 1; 67 | return res; 68 | } 69 | 70 | cons * get_from_key(list_exist list, char * key, int isAuto, int byPass) 71 | { 72 | cons * res = is_in(list, key, 0); 73 | if(res == NULL) 74 | { 75 | char question = 'y'; 76 | if(!isAuto && strlen(key) > 3) 77 | { 78 | printf("Do you want to obfuscate %s?(y/n)\n", key); 79 | question = getchar(); 80 | while(getchar() != '\n'); 81 | } 82 | if(question == 'n' || strlen(key) < 3) 83 | { 84 | char *sec = malloc(sizeof(*sec)*(strlen(key)+1)); 85 | EXIT_IF(sec == NULL, err_malloc); 86 | memcpy(sec, key, sizeof(*sec)*(strlen(key)+1)); 87 | res = malloc(sizeof(*res)); 88 | res->first = key; 89 | res->second = sec; 90 | byPass = 1; 91 | } 92 | else 93 | { 94 | res = generate_cons(list, key); 95 | } 96 | res->toSave = !byPass; 97 | vecteur_ecrire(list, vecteur_nombre_elements(list), res); 98 | } 99 | else if(byPass) 100 | { 101 | res->toSave = !byPass; 102 | } 103 | return res; 104 | } 105 | 106 | void delete(list_exist list) 107 | { 108 | int i = 0; 109 | for(i = 0; i < vecteur_nombre_elements(list); i++) 110 | { 111 | cons * tmp = vecteur_lire(list, i); 112 | free(tmp->first); 113 | free(tmp->second); 114 | free(tmp); 115 | } 116 | 117 | vecteur_defaire(list); 118 | } 119 | 120 | 121 | void saveToFile(list_exist list, char * filename) 122 | { 123 | FILE * file = fopen(filename, "w"); 124 | int i = 0; 125 | int fileSize = vecteur_nombre_elements(list); 126 | fprintf(file, "#ifndef H_CONVERT\n#define H_CONVERT\n\n"); 127 | for(i = 0; i < fileSize; i++) 128 | { 129 | cons * tmp = vecteur_lire(list, i); 130 | if(tmp->toSave) 131 | fprintf(file, "#define %s %s \n", tmp->second, tmp->first); 132 | } 133 | fprintf(file, "#endif\n"); 134 | fclose(file); 135 | } 136 | -------------------------------------------------------------------------------- /Readme.txt: -------------------------------------------------------------------------------- 1 | Welcome to COBFU 2 | ================ 3 | 4 | Brief introduction: 5 | 6 | COBFU is an open source/research based project for Software Security. This project mainly and not limited for source code obfuscation 7 | has been programmed with C/C++, the next view rigor on total sloution for Java/C/C++ plus . Currently COBFU under research and implementation 8 | phase. Source code obfuscation, intuitively, is a the "Defense in Depth" concept in software security, hope to make complexity during reverse 9 | engineering both in Static and Dynamic analyses. obfuscation is not actual definition for software security, indeed, it is providing a security 10 | through obscurity. This is an undeniable fact the authors have a talk with deep point of view in their works[papers/books/publications] 11 | 12 | Simple architecture: 13 | 14 | +---------+ 15 | [C/C++ Source code]------> | COBFU |-------> [Obfuscated C/C++ code] 16 | +---------+ 17 | \ 18 | \ 19 | \ 20 | +-------------------------------------------+ 21 | | flex(The Fast Lexical Analyzer) parse the | 22 | | source code and obfuscation algorithms | 23 | | apply here, the result is a obfuscated | 24 | | source code(Spaghetti Code) | 25 | +-------------------------------------------+ 26 | 27 | 28 | How it works: 29 | you can find out some good and valuable information in attached papers, everything is defined with details. 30 | Methods for source code obfuscation: 31 | 1. Layout Transformation 32 | 2. Data type Transformation 33 | 3. CFG (Control Flow graph) Transformation 34 | 35 | 36 | 37 | 38 | Warning: COBFU for C/C++ is not completed yet, don't use it in your real projects or any operational environment, NOW! 39 | This project started few days ago (21 May 2014), so there is challenges and we hope resolve issues as soon. 40 | if you have any concern to resolve or help us; please contact us via khaleghsalehi@gmail.com 41 | The main idea for COBFU listed below: 42 | 1. Layout transformation 43 | 2. Data type transformation 44 | 3. CFG (Control Flow graph) transformation 45 | 46 | According to attached papers, you can find out some valuable information for design and implement strong obfuscation system. 47 | I am busy on research for CFG best practices, algorithm & implementation now ... 48 | 49 | Current issue: 50 | [1] at CFG chapter , problem in stack returned value in (CFG), uninvited droped last semicolon(;) 51 | [2] in Layout Transformation. original printf("") functions parser have a problem, other state with format string work correctly, now 52 | 53 | 54 | Try this source code for current under-develop version: 55 | ================================================ 56 | 57 | #include 58 | /* 59 | Please enter key manualy in obfuscate source code, this issue wil resole as soon :-) :-P 60 | */ 61 | void main(){ 62 | int i,j; 63 | 64 | printf("The current value for j is a %d\n",j); 65 | scanf("%d",&j); 66 | i=1; 67 | while(i<=j) 68 | { 69 | if(i>=0){ 70 | printf("The i value is a %d\n",i); 71 | printf("The j value is a %d\n",j); 72 | 73 | }//End of if 74 | i++; /* Problem number 1 is here, after obfuscation you must add ; in obfuscate code for i++ */ 75 | }/* End of while */ 76 | } 77 | 78 | How to run[Refrence::https://github.com/ryarnyah/AnalyseC]: 79 | To compile you need flex: 80 | Debian/Ubuntu: 81 | apt-get install flex 82 | 83 | How it work: 84 | $ make 85 | $ ./gram file.c file1.h <...> 86 | $ ls 87 | file.c file.c_ file1.h file1.h_ convert.h gram 88 | $ # file with '_' is obfuscated 89 | $ # file convert.h have all obfuscation connections 90 | $ # to compile 91 | $ gcc file.c_ file1.h convert.h -o file 92 | $ ./file 93 | 94 | To test it: 95 | $ ./gram arithmetique.c 96 | $ ls 97 | arithmetique.c.c arithmetique.c_ gram convert.h 98 | $ gcc arithmetique.c.c_ convert.h -std=c99 -o test 99 | $ ./test 100 | Usage : ./a.out [nbr] [nbr] 101 | 102 | 12 Jul 2014, 14:59" 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | -------------------------------------------------------------------------------- /analyse.l: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | This program is free software: you can redistribute it and/or modify 4 | it under the terms of the GNU General Public License as published by 5 | the Free Software Foundation, either version 3 of the License, or 6 | (at your option) any later version. 7 | This program is distributed in the hope that it will be useful, 8 | but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | GNU General Public License for more details. 11 | You should have received a copy of the GNU General Public License 12 | along with this program. If not, see 13 | *************************************************************************** 14 | COBFU, C/C++ obfuscator 15 | Authors & contribute : 16 | Ryarbyah{ 17 | Main Authors: 18 | https://github.com/ryarnyah/AnalyseC 19 | C Obfuscator; http://not2do4programing.wordpress.com/ 20 | } 21 | Khalegh{ 22 | Continues: 23 | https://github.com/khaleghsalehi/COBFU 24 | Khalegh Salehi 25 | Email:khaleghsalehi@gmail.com 26 | } 27 | Note: 28 | [+] Add \ to break the line in c source code 29 | */ 30 | D [0-9] 31 | L [a-zA-Z_] 32 | H [a-fA-F0-9] 33 | E [Ee][+-]?{D}+ 34 | FS (f|F|l|L) 35 | IS (u|U|l|L)* 36 | EXCLUDE "fprintf"|"memcpy"|"exit"|"malloc"|"free"|"calloc"|"realloc"|"assert"|"memset"|"longjmp"|"setjmp"|"strcmp"|"strncmp"|"strcpy"|"strncpy"|"rand"|"srand"|"time"|"strlen"|"NULL"|"stdin"|"stderr"|"EXIT_SUCCESS"|"EXIT_FAILURE"|"main"|"argc"|"argv"|"atoi"|"atof"|"strtol"|"true"|"false"|"bool"|"ssize_t"|"size_t"|"O_RDONLY"|"SEEK_END"|"SEEK_SET"|"O_WRONLY"|"O_TRUNC"|"O_CREAT"|"DEBUG"|"__FILE__"|"__FUNCTION__"|"__LINE__"|"write"|"read"|"close"|"lseek"|"seek"|"perror"|"open" 37 | 38 | %{ 39 | #include 40 | #include 41 | #include "cons.h" 42 | #include 43 | #include "list_exist.h" 44 | #include 45 | char *parse_akolad(); 46 | //char *parse_parantez(); 47 | void parse_while(); 48 | void count(); 49 | void comment(); 50 | void newprintf(); 51 | void newscanf(); 52 | void changedigit(); 53 | static list_exist list; 54 | static FILE * currentFile = NULL; 55 | static int isAuto = 1; 56 | static int byPass = 0; 57 | //define global variable for parse_akolad 58 | char buff11[1000]; 59 | char polbuff11[1000]; 60 | %} 61 | 62 | %% 63 | "while" { parse_while();} 64 | "/*" { comment();} 65 | "printf" { newprintf();} 66 | "scanf" { newscanf();} 67 | "auto" { fprintf(currentFile, "%s", yytext); } 68 | "size_t" { fprintf(currentFile, "%s", yytext); } 69 | "off_t" { fprintf(currentFile, "%s", yytext); } 70 | "break" { fprintf(currentFile, "%s", yytext); } 71 | "case" { fprintf(currentFile, "%s", yytext); } 72 | "char" { fprintf(currentFile, "%s", yytext); } 73 | "const" { fprintf(currentFile, "%s", yytext); } 74 | "continue" { fprintf(currentFile, "%s", yytext); } 75 | "default" { fprintf(currentFile, "%s", yytext); } 76 | "do" { fprintf(currentFile, "%s", yytext); } 77 | "double" { fprintf(currentFile, "%s", yytext); } 78 | "else" { fprintf(currentFile, "%s", yytext); } 79 | "enum" { fprintf(currentFile, "%s", yytext); } 80 | "extern" { fprintf(currentFile, "%s", yytext); } 81 | "float" { fprintf(currentFile, "%s", yytext); } 82 | "for" { fprintf(currentFile, "%s", yytext); } 83 | "goto" { fprintf(currentFile, "%s", yytext); } 84 | "if" { fprintf(currentFile, "%s", yytext); } 85 | "int" { fprintf(currentFile, "%s", yytext); } 86 | "long" { fprintf(currentFile, "%s", yytext); } 87 | "register" { fprintf(currentFile, "%s", yytext); } 88 | "return" { fprintf(currentFile, "%s", yytext); } 89 | "short" { fprintf(currentFile, "%s", yytext); } 90 | "signed" { fprintf(currentFile, "%s", yytext); } 91 | "sizeof" { fprintf(currentFile, "%s", yytext); } 92 | "static" { fprintf(currentFile, "%s", yytext); } 93 | "struct" { fprintf(currentFile, "%s", yytext); } 94 | "switch" { fprintf(currentFile, "%s", yytext); } 95 | "typedef" { fprintf(currentFile, "%s", yytext); } 96 | "union" { fprintf(currentFile, "%s", yytext); } 97 | "unsigned" { fprintf(currentFile, "%s", yytext); } 98 | "void" { fprintf(currentFile, "%s", yytext); } 99 | "volatile" { fprintf(currentFile, "%s", yytext); } 100 | {EXCLUDE} { fprintf(currentFile, "%s", yytext); } 101 | {L}({L}|{D})* { char * reso = malloc(sizeof(char)*(strlen(yytext) + 1)); memcpy(reso, yytext, sizeof(char)*(strlen(yytext) + 1));cons * res = get_from_key(list, reso, isAuto, byPass); fprintf(currentFile, "%s", res->second); if(byPass==1)byPass=0;} 102 | #"define"|"ifdef"|"ifndef" {fprintf(currentFile, "%s", yytext);byPass=1;} 103 | #{L}({L}|{D})* {fprintf(currentFile, "%s", yytext);} 104 | \<{L}({L}|{D}|\/)*".h"\> {fprintf(currentFile, "%s", yytext);} 105 | 106 | 0[xX]{H}+{IS}? { fprintf(currentFile, "%s", yytext); } 107 | 0{D}+{IS}? { fprintf(currentFile, "%s", yytext); } 108 | {D}+{IS}? { changedigit(); } 109 | '(\\.|[^\\'])+' { fprintf(currentFile, "%s", "Digit yytext"); } 110 | 111 | {D}+{E}{FS}? { changedigit(); } 112 | {D}*"."{D}+({E})?{FS}? { changedigit(); } 113 | {D}+"."{D}*({E})?{FS}? { changedigit(); } 114 | \"(\\.|[^\\"])*\" { fprintf(currentFile, "%s", yytext); } 115 | ">>=" { fprintf(currentFile, "%s", yytext); } 116 | "<<=" { fprintf(currentFile, "%s", yytext); } 117 | "+=" { fprintf(currentFile, "%s", yytext); } 118 | "-=" { fprintf(currentFile, "%s", yytext); } 119 | "*=" { fprintf(currentFile, "%s", yytext); } 120 | "/=" { fprintf(currentFile, "%s", yytext); } 121 | "%=" { fprintf(currentFile, "%s", yytext); } 122 | "&=" { fprintf(currentFile, "%s", yytext); } 123 | "^=" { fprintf(currentFile, "%s", yytext); } 124 | "|=" { fprintf(currentFile, "%s", yytext); } 125 | ">>" { fprintf(currentFile, "%s", yytext); } 126 | "<<" { fprintf(currentFile, "%s", yytext); } 127 | "++" { fprintf(currentFile, "%s", yytext); } 128 | "--" { fprintf(currentFile, "%s", yytext); } 129 | "->" { fprintf(currentFile, "%s", yytext); } 130 | "&&" { fprintf(currentFile, "%s", yytext); } 131 | "||" { fprintf(currentFile, "%s", yytext); } 132 | "<=" { fprintf(currentFile, "%s", yytext); } 133 | ">=" { fprintf(currentFile, "%s", yytext); } 134 | "==" { fprintf(currentFile, "%s", yytext); } 135 | "!=" { fprintf(currentFile, "%s", yytext); } 136 | ";" { fprintf(currentFile, "%s", yytext); } 137 | "{" { fprintf(currentFile, "%s", yytext); } 138 | "}" { fprintf(currentFile, "%s", yytext); } 139 | "," { fprintf(currentFile, "%s", yytext); } 140 | ":" { fprintf(currentFile, "%s", yytext); } 141 | "=" { fprintf(currentFile, "%s", yytext); } 142 | "(" { fprintf(currentFile, "%s", yytext); } 143 | ")" { fprintf(currentFile, "%s", yytext); } 144 | "[" { fprintf(currentFile, "%s", yytext); } 145 | "]" { fprintf(currentFile, "%s", yytext); } 146 | "." { fprintf(currentFile, "%s", yytext); } 147 | "&" { fprintf(currentFile, "%s", yytext); } 148 | "!" { fprintf(currentFile, "%s", yytext); } 149 | "~" { fprintf(currentFile, "%s", yytext); } 150 | "-" { fprintf(currentFile, "%s", yytext); } 151 | "+" { fprintf(currentFile, "%s", yytext); } 152 | "*" { fprintf(currentFile, "%s", yytext); } 153 | "/" { fprintf(currentFile, "%s", yytext); } 154 | "%" { fprintf(currentFile, "%s", yytext); } 155 | "<" { fprintf(currentFile, "%s", yytext); } 156 | ">" { fprintf(currentFile, "%s", yytext); } 157 | "^" { fprintf(currentFile, "%s", yytext); } 158 | "|" { fprintf(currentFile, "%s", yytext); } 159 | "?" { fprintf(currentFile, "%s", yytext); } 160 | [\t\n] { fprintf(currentFile, "%s", ""); } 161 | [ \v\f] { fprintf(currentFile, "%s", yytext); } 162 | . { /* ignore bad characters */ fprintf(currentFile, "%s", yytext); } 163 | 164 | %% 165 | 166 | int yywrap() 167 | { 168 | return 1; 169 | } 170 | 171 | //zx 172 | void parse_while() 173 | { 174 | int i,arg; 175 | char ako[1]=""; 176 | char swname[100]=""; 177 | for(i=0;i<=1000;i++) 178 | { 179 | buff11[i]='\0'; 180 | polbuff11[i]='\0'; 181 | } 182 | 183 | /**/ 184 | /*Creat random name for switch case var*/ 185 | char charset[] = "0123456789" 186 | "abcdefghijklmnopqrstuvwxyz" 187 | "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; 188 | char prefix[]="_"; 189 | swname[0]=prefix[0]; 190 | swname[1]=prefix[0]; 191 | i=2; 192 | while (i<=8) { 193 | size_t index = (double) rand() / RAND_MAX * (sizeof charset - 1); 194 | swname[i] =charset[index]; 195 | i++; 196 | } 197 | swname[11] ='\0'; 198 | 199 | for(i=0;i<10;i++) 200 | printf("%c",swname[i]); 201 | /* End name generation */ 202 | printf("\n\n"); 203 | 204 | 205 | 206 | 207 | parse_akolad(); 208 | arg=0; 209 | i=0; 210 | strcpy(ako,"{"); 211 | 212 | 213 | 214 | // TEMP for test, remove here 215 | 216 | i=0; 217 | printf("\n------------------------\n"); 218 | for(i=0;i<=15;i++) 219 | printf("[%d][%c]-",i,polbuff11[i]); 220 | printf("\n------------------------\n"); 221 | 222 | 223 | 224 | //TEMP for test 225 | i=0; 226 | while(polbuff11[i]!=ako[0]) 227 | { 228 | printf("%c",polbuff11[i]); 229 | i++; 230 | arg++; 231 | } 232 | // 233 | //printf("Index is a -> %d\n",k); 234 | // 235 | 236 | 237 | 238 | 239 | fprintf(currentFile,"%s","__OoOoOl1l1l=1;\nwhile(__OoOoOl1l1l!=0){\nswitch(__OoOoOl1l1l)\n{\ncase 1:{__OoOoOl1l1l=2;break;}\ncase 2:\n{"); 240 | fprintf(currentFile,"%s","\n\tif"); 241 | for (i=0;i<=arg-1;i++) 242 | fprintf(currentFile,"%c",polbuff11[i]); 243 | fprintf(currentFile,"%s","\n\t\t{__OoOoOl1l1l=3;break;}"); 244 | fprintf(currentFile,"%s","\n\tif(!"); 245 | for(i=0;i<=arg-1;i++) 246 | fprintf(currentFile,"%c",polbuff11[i]); 247 | fprintf(currentFile,"%s" ,")\n\t\t{__OoOoOl1l1l=0;break;}\nbreak;}\ncase 3:\n{\n"); 248 | 249 | 250 | i=arg+1; 251 | while(polbuff11[i]!='\0') 252 | // for (i=arg+1;i<1000;i++) 253 | { 254 | fprintf(currentFile,"%c",polbuff11[i]); 255 | i++; 256 | } 257 | 258 | fprintf(currentFile,"%s","\n\n__OoOoOl1l1l=2;break;}\n}"); // check for removed {, remember 259 | }// End of parse while function. 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | char *parse_akolad() 269 | { 270 | char c1; 271 | while((c1 = input()) !='}') 272 | { 273 | sprintf(buff11,"%c",c1); 274 | strcat(polbuff11,buff11); 275 | parse_akolad(); 276 | return 0; 277 | } 278 | strcat(polbuff11,"}"); 279 | return polbuff11; 280 | } 281 | 282 | 283 | 284 | 285 | 286 | /******************************** 287 | Remove the comments by // 288 | *********************************/ 289 | /* 290 | How to use gcc preprocessors to remove all comment in c source code 291 | gcc -fpreprocessed -dD -E test.c 292 | */ 293 | 294 | /*Comment by myself*/ 295 | void comment() 296 | { 297 | char c, c1; 298 | 299 | loop: 300 | while ((c = input()) != '*' && c != 0) 301 | ;//putchar(c); 302 | 303 | if ((c1 = input()) != '/' && c != 0) 304 | { 305 | unput(c1); 306 | goto loop; 307 | } 308 | 309 | if (c != 0) 310 | ;//putchar(c1); 311 | } 312 | /******************************************** 313 | ********************************************/ 314 | void changedigit() 315 | { 316 | float rp1,rp2,digit; 317 | int rndx; 318 | //float poldigit; 319 | //int poldigit,rndx,rp1,rp2,digit; 320 | 321 | //zz 322 | srand(time(NULL)); 323 | rndx=rand()%10000000+1; 324 | printf("%d",rndx); 325 | digit=atoi(yytext); 326 | rp1=(digit)-rndx; 327 | rp2=(digit-rp1)+rndx; 328 | // poldigit=(rp1+rp2-rndx); 329 | fprintf(currentFile, "((((%f)+(%f))-((%d))))",rp1,rp2,rndx); // the prantez help to complex exprestion 330 | // fprintf(currentFile, "%f+%f-%d",rp1,rp2,rndx); // the prantez help to complex exprestion 331 | 332 | 333 | } 334 | /******************************************** 335 | ********************************************/ 336 | /* 337 | START scanf FUNCTION 338 | 339 | */ 340 | void newscanf() 341 | { 342 | char c,c1; 343 | int code,code2; 344 | char binstr[1000]=""; 345 | char repo[1000]="",hexrepo[1000]=""; 346 | while ((c=input())!='(' && c !=0) 347 | unput(c); 348 | while ((c1=input()) !=',' && c!=0){ 349 | code=(int)c1; 350 | if(code==92){ // Find Slash character 351 | sprintf(hexrepo,"%s","\\"); 352 | strcat(repo,hexrepo); 353 | c1=input();//Next 354 | sprintf(hexrepo,"%c",c1); 355 | strcat(repo,hexrepo); 356 | continue;} 357 | //zz 358 | 359 | if(code==37){ // Find % character & figureout printf format string 360 | sprintf(hexrepo,"%s","\%"); 361 | strcat(repo,hexrepo); 362 | c1=input();//Next 363 | code2=(int)c1; 364 | while (((int)code2!=100) && ((int)code2!=99) && ((int)code2!=102) && ((int)code2!=115) && ((int)code2!=105) ) 365 | { 366 | sprintf(hexrepo,"%c",c1); 367 | strcat(repo,hexrepo); 368 | c1=input(); 369 | code2=(int)c1; 370 | //continue; 371 | } 372 | if ( code2==105 || code2==99 || code2==102 || code2==115 || code2==100 ) 373 | { 374 | sprintf(hexrepo,"%c",c1); 375 | strcat(repo,hexrepo); 376 | // c1=input(); 377 | continue; 378 | } 379 | 380 | } // End of % checkup 381 | 382 | if(code!=34){ // Ignore " character 383 | sprintf(hexrepo,"\\x%x", c1); 384 | strcat(repo,hexrepo); 385 | } 386 | } // End of while II 387 | 388 | sprintf(binstr, "%s%s%s", "scanf(\"",repo,"\","); 389 | fprintf(currentFile, "%s", binstr); 390 | printf("%s",yytext); 391 | printf("\n"); 392 | } 393 | 394 | /* 395 | END Scanf FUNCTION 396 | 397 | */ 398 | 399 | /******************************************** 400 | ********************************************/ 401 | 402 | 403 | 404 | 405 | /* 406 | START PRINTF FUNCTION 407 | printf([message/format specific],variable) 408 | printf(" [%[Dig].[Dig]f,d,i,c,s,[a-z][A-Z][0-9][!@#$%^&*()_+]",v1,v2,..,v(n-1),v(n)) 409 | Where v1,v2,..,v(n-1),v(n-2) must be changed and replaced. 410 | 411 | 412 | */ 413 | 414 | 415 | 416 | /*********************************** 417 | 418 | Orginal syntax : 419 | printf("[Printf format type/message]",var1,var2,...varn); 420 | So: 421 | printf(part I,Part II) 422 | Obfuscation details: 423 | while(c1=input!=')') 424 | buff=buff+c1; // buff is a string contain all string befor last ) in printf(.....) 425 | // Part I 426 | index=find-last-str-postion(buff,"); 427 | messagebuff="printf('") 428 | for(i=0;i<=index,i++) 429 | messagebuff=messagebuff+buff[i] 430 | for(i=0;i"\") 433 | write(hex(messagebuff[i])); 434 | else // format type string... 435 | { 436 | 437 | while(messagebuff[i]<> d,s,o,... ) 438 | { 439 | write(messagebuff[i]; 440 | i++; // For example \3.33f 441 | } 442 | write(mesaagebuff[i++?]; / for example \n --> n 443 | } 444 | } 445 | for(i=index;i<=len(buff);i++) // write Part II 446 | write(buff[i]); 447 | write(")"); 448 | This approach have a problem during parsing becuase this example parsing not completely for example printf(" my name is a(a) ",..... 449 | when parsing parse until a) and drop esle... 450 | 451 | ************************************/ 452 | 453 | 454 | 455 | void newprintf() 456 | { 457 | char c,c1; 458 | int i,code,code2; 459 | char binstr[1000]=""; 460 | char repo[1000]="",hexrepo[1000]=""; 461 | /* 462 | CHECK FOR SIMPLE printf, work such as simple echo 463 | Example: 464 | printf("Hello World") 465 | */ 466 | 467 | 468 | /* 469 | CHECK FOR ADVANCED printf, 470 | Example: 471 | printf("\n\n%d%3.1f",i,j); 472 | */ 473 | for(i=0;i<100;i++) 474 | printf("%c",yytext[i]); 475 | while ((c=input())!='(' && c !=0) 476 | unput(c); 477 | while ((c1=input()) !=',' && c!=0){ 478 | code=(int)c1; 479 | if(code==92){ // Find Slash character 480 | sprintf(hexrepo,"%s","\\"); 481 | strcat(repo,hexrepo); 482 | c1=input();//Next 483 | sprintf(hexrepo,"%c",c1); 484 | strcat(repo,hexrepo); 485 | continue;} 486 | //zz 487 | 488 | if(code==37){ // Find % character & figureout printf format string 489 | sprintf(hexrepo,"%s","\%"); 490 | strcat(repo,hexrepo); 491 | c1=input();//Next 492 | code2=(int)c1; 493 | while (((int)code2!=100) && ((int)code2!=99) && ((int)code2!=102) && ((int)code2!=115) && ((int)code2!=105) ) 494 | { 495 | sprintf(hexrepo,"%c",c1); 496 | strcat(repo,hexrepo); 497 | c1=input(); 498 | code2=(int)c1; 499 | //continue; 500 | } 501 | if ( code2==105 || code2==99 || code2==102 || code2==115 || code2==100 ) 502 | { 503 | sprintf(hexrepo,"%c",c1); 504 | strcat(repo,hexrepo); 505 | // c1=input(); 506 | continue; 507 | } 508 | 509 | } // End of % checkup 510 | 511 | if(code!=34){ // Ignore " character 512 | sprintf(hexrepo,"\\x%x", c1); 513 | strcat(repo,hexrepo); 514 | } 515 | } // End of while II 516 | 517 | sprintf(binstr, "%s%s%s", "printf(\"",repo,"\","); 518 | fprintf(currentFile, "%s", binstr); 519 | printf("%s",yytext); 520 | printf("\n"); 521 | } 522 | 523 | /* 524 | END PRINTF FUNCTION 525 | 526 | */ 527 | 528 | 529 | 530 | int column = 0; 531 | 532 | void count() 533 | { 534 | int i; 535 | 536 | for (i = 0; yytext[i] != '\0'; i++) 537 | if (yytext[i] == '\n') 538 | column = 0; 539 | else if (yytext[i] == '\t') 540 | column += 8 - (column % 8); 541 | else 542 | column++; 543 | 544 | ECHO; 545 | } 546 | 547 | static void usage(char * s) 548 | { 549 | fprintf(stderr, "Usage: %s [-m(manuel)] \n", s); 550 | exit(1); 551 | } 552 | 553 | int main(int argc, char **argv) 554 | { 555 | 556 | 557 | if(argc < 2) 558 | usage(argv[0]); 559 | list = create(); 560 | int i = 1; 561 | if(strlen(argv[1]) == 2 && argv[1][1] == 'm') 562 | { 563 | isAuto = 0; 564 | i = 2; 565 | printf("is not auto"); 566 | } 567 | for(; i < argc; i++) 568 | { 569 | char tmp[strlen(argv[i]) + 2]; 570 | memcpy(tmp, argv[i], sizeof(char)*(strlen(argv[i]))); 571 | tmp[strlen(argv[i])] = '_'; 572 | tmp[strlen(argv[i]) + 1] = '\0'; 573 | currentFile = fopen(tmp, "w"); 574 | if(currentFile == NULL) 575 | { 576 | perror("fopen"); 577 | return 1; 578 | } 579 | yyin = fopen(argv[i], "r"); 580 | if(yyin == NULL) 581 | { 582 | perror("fopen"); 583 | return 1; 584 | } 585 | fprintf(currentFile, "#include \"convert.h\"\n"); 586 | yylex(); 587 | fclose(currentFile); 588 | fclose(yyin); 589 | currentFile = NULL; 590 | yyin = NULL; 591 | } 592 | saveToFile(list, "convert.h"); 593 | delete(list); 594 | return 0; 595 | } 596 | -------------------------------------------------------------------------------- /lex.yy.c: -------------------------------------------------------------------------------- 1 | 2 | #line 3 "lex.yy.c" 3 | 4 | #define YY_INT_ALIGNED short int 5 | 6 | /* A lexical scanner generated by flex */ 7 | 8 | #define FLEX_SCANNER 9 | #define YY_FLEX_MAJOR_VERSION 2 10 | #define YY_FLEX_MINOR_VERSION 5 11 | #define YY_FLEX_SUBMINOR_VERSION 35 12 | #if YY_FLEX_SUBMINOR_VERSION > 0 13 | #define FLEX_BETA 14 | #endif 15 | 16 | /* First, we deal with platform-specific or compiler-specific issues. */ 17 | 18 | /* begin standard C headers. */ 19 | #include 20 | #include 21 | #include 22 | #include 23 | 24 | /* end standard C headers. */ 25 | 26 | /* flex integer type definitions */ 27 | 28 | #ifndef FLEXINT_H 29 | #define FLEXINT_H 30 | 31 | /* C99 systems have . Non-C99 systems may or may not. */ 32 | 33 | #if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L 34 | 35 | /* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, 36 | * if you want the limit (max/min) macros for int types. 37 | */ 38 | #ifndef __STDC_LIMIT_MACROS 39 | #define __STDC_LIMIT_MACROS 1 40 | #endif 41 | 42 | #include 43 | typedef int8_t flex_int8_t; 44 | typedef uint8_t flex_uint8_t; 45 | typedef int16_t flex_int16_t; 46 | typedef uint16_t flex_uint16_t; 47 | typedef int32_t flex_int32_t; 48 | typedef uint32_t flex_uint32_t; 49 | #else 50 | typedef signed char flex_int8_t; 51 | typedef short int flex_int16_t; 52 | typedef int flex_int32_t; 53 | typedef unsigned char flex_uint8_t; 54 | typedef unsigned short int flex_uint16_t; 55 | typedef unsigned int flex_uint32_t; 56 | 57 | /* Limits of integral types. */ 58 | #ifndef INT8_MIN 59 | #define INT8_MIN (-128) 60 | #endif 61 | #ifndef INT16_MIN 62 | #define INT16_MIN (-32767-1) 63 | #endif 64 | #ifndef INT32_MIN 65 | #define INT32_MIN (-2147483647-1) 66 | #endif 67 | #ifndef INT8_MAX 68 | #define INT8_MAX (127) 69 | #endif 70 | #ifndef INT16_MAX 71 | #define INT16_MAX (32767) 72 | #endif 73 | #ifndef INT32_MAX 74 | #define INT32_MAX (2147483647) 75 | #endif 76 | #ifndef UINT8_MAX 77 | #define UINT8_MAX (255U) 78 | #endif 79 | #ifndef UINT16_MAX 80 | #define UINT16_MAX (65535U) 81 | #endif 82 | #ifndef UINT32_MAX 83 | #define UINT32_MAX (4294967295U) 84 | #endif 85 | 86 | #endif /* ! C99 */ 87 | 88 | #endif /* ! FLEXINT_H */ 89 | 90 | #ifdef __cplusplus 91 | 92 | /* The "const" storage-class-modifier is valid. */ 93 | #define YY_USE_CONST 94 | 95 | #else /* ! __cplusplus */ 96 | 97 | /* C99 requires __STDC__ to be defined as 1. */ 98 | #if defined (__STDC__) 99 | 100 | #define YY_USE_CONST 101 | 102 | #endif /* defined (__STDC__) */ 103 | #endif /* ! __cplusplus */ 104 | 105 | #ifdef YY_USE_CONST 106 | #define yyconst const 107 | #else 108 | #define yyconst 109 | #endif 110 | 111 | /* Returned upon end-of-file. */ 112 | #define YY_NULL 0 113 | 114 | /* Promotes a possibly negative, possibly signed char to an unsigned 115 | * integer for use as an array index. If the signed char is negative, 116 | * we want to instead treat it as an 8-bit unsigned char, hence the 117 | * double cast. 118 | */ 119 | #define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) 120 | 121 | /* Enter a start condition. This macro really ought to take a parameter, 122 | * but we do it the disgusting crufty way forced on us by the ()-less 123 | * definition of BEGIN. 124 | */ 125 | #define BEGIN (yy_start) = 1 + 2 * 126 | 127 | /* Translate the current start state into a value that can be later handed 128 | * to BEGIN to return to the state. The YYSTATE alias is for lex 129 | * compatibility. 130 | */ 131 | #define YY_START (((yy_start) - 1) / 2) 132 | #define YYSTATE YY_START 133 | 134 | /* Action number for EOF rule of a given start state. */ 135 | #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) 136 | 137 | /* Special action meaning "start processing a new file". */ 138 | #define YY_NEW_FILE yyrestart(yyin ) 139 | 140 | #define YY_END_OF_BUFFER_CHAR 0 141 | 142 | /* Size of default input buffer. */ 143 | #ifndef YY_BUF_SIZE 144 | #ifdef __ia64__ 145 | /* On IA-64, the buffer size is 16k, not 8k. 146 | * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case. 147 | * Ditto for the __ia64__ case accordingly. 148 | */ 149 | #define YY_BUF_SIZE 32768 150 | #else 151 | #define YY_BUF_SIZE 16384 152 | #endif /* __ia64__ */ 153 | #endif 154 | 155 | /* The state buf must be large enough to hold one state per character in the main buffer. 156 | */ 157 | #define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) 158 | 159 | #ifndef YY_TYPEDEF_YY_BUFFER_STATE 160 | #define YY_TYPEDEF_YY_BUFFER_STATE 161 | typedef struct yy_buffer_state *YY_BUFFER_STATE; 162 | #endif 163 | 164 | extern int yyleng; 165 | 166 | extern FILE *yyin, *yyout; 167 | 168 | #define EOB_ACT_CONTINUE_SCAN 0 169 | #define EOB_ACT_END_OF_FILE 1 170 | #define EOB_ACT_LAST_MATCH 2 171 | 172 | #define YY_LESS_LINENO(n) 173 | 174 | /* Return all but the first "n" matched characters back to the input stream. */ 175 | #define yyless(n) \ 176 | do \ 177 | { \ 178 | /* Undo effects of setting up yytext. */ \ 179 | int yyless_macro_arg = (n); \ 180 | YY_LESS_LINENO(yyless_macro_arg);\ 181 | *yy_cp = (yy_hold_char); \ 182 | YY_RESTORE_YY_MORE_OFFSET \ 183 | (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ 184 | YY_DO_BEFORE_ACTION; /* set up yytext again */ \ 185 | } \ 186 | while ( 0 ) 187 | 188 | #define unput(c) yyunput( c, (yytext_ptr) ) 189 | 190 | #ifndef YY_TYPEDEF_YY_SIZE_T 191 | #define YY_TYPEDEF_YY_SIZE_T 192 | typedef size_t yy_size_t; 193 | #endif 194 | 195 | #ifndef YY_STRUCT_YY_BUFFER_STATE 196 | #define YY_STRUCT_YY_BUFFER_STATE 197 | struct yy_buffer_state 198 | { 199 | FILE *yy_input_file; 200 | 201 | char *yy_ch_buf; /* input buffer */ 202 | char *yy_buf_pos; /* current position in input buffer */ 203 | 204 | /* Size of input buffer in bytes, not including room for EOB 205 | * characters. 206 | */ 207 | yy_size_t yy_buf_size; 208 | 209 | /* Number of characters read into yy_ch_buf, not including EOB 210 | * characters. 211 | */ 212 | int yy_n_chars; 213 | 214 | /* Whether we "own" the buffer - i.e., we know we created it, 215 | * and can realloc() it to grow it, and should free() it to 216 | * delete it. 217 | */ 218 | int yy_is_our_buffer; 219 | 220 | /* Whether this is an "interactive" input source; if so, and 221 | * if we're using stdio for input, then we want to use getc() 222 | * instead of fread(), to make sure we stop fetching input after 223 | * each newline. 224 | */ 225 | int yy_is_interactive; 226 | 227 | /* Whether we're considered to be at the beginning of a line. 228 | * If so, '^' rules will be active on the next match, otherwise 229 | * not. 230 | */ 231 | int yy_at_bol; 232 | 233 | int yy_bs_lineno; /**< The line count. */ 234 | int yy_bs_column; /**< The column count. */ 235 | 236 | /* Whether to try to fill the input buffer when we reach the 237 | * end of it. 238 | */ 239 | int yy_fill_buffer; 240 | 241 | int yy_buffer_status; 242 | 243 | #define YY_BUFFER_NEW 0 244 | #define YY_BUFFER_NORMAL 1 245 | /* When an EOF's been seen but there's still some text to process 246 | * then we mark the buffer as YY_EOF_PENDING, to indicate that we 247 | * shouldn't try reading from the input source any more. We might 248 | * still have a bunch of tokens to match, though, because of 249 | * possible backing-up. 250 | * 251 | * When we actually see the EOF, we change the status to "new" 252 | * (via yyrestart()), so that the user can continue scanning by 253 | * just pointing yyin at a new input file. 254 | */ 255 | #define YY_BUFFER_EOF_PENDING 2 256 | 257 | }; 258 | #endif /* !YY_STRUCT_YY_BUFFER_STATE */ 259 | 260 | /* Stack of input buffers. */ 261 | static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */ 262 | static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */ 263 | static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */ 264 | 265 | /* We provide macros for accessing buffer states in case in the 266 | * future we want to put the buffer states in a more general 267 | * "scanner state". 268 | * 269 | * Returns the top of the stack, or NULL. 270 | */ 271 | #define YY_CURRENT_BUFFER ( (yy_buffer_stack) \ 272 | ? (yy_buffer_stack)[(yy_buffer_stack_top)] \ 273 | : NULL) 274 | 275 | /* Same as previous macro, but useful when we know that the buffer stack is not 276 | * NULL or when we need an lvalue. For internal use only. 277 | */ 278 | #define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)] 279 | 280 | /* yy_hold_char holds the character lost when yytext is formed. */ 281 | static char yy_hold_char; 282 | static int yy_n_chars; /* number of characters read into yy_ch_buf */ 283 | int yyleng; 284 | 285 | /* Points to current character in buffer. */ 286 | static char *yy_c_buf_p = (char *) 0; 287 | static int yy_init = 0; /* whether we need to initialize */ 288 | static int yy_start = 0; /* start state number */ 289 | 290 | /* Flag which is used to allow yywrap()'s to do buffer switches 291 | * instead of setting up a fresh yyin. A bit of a hack ... 292 | */ 293 | static int yy_did_buffer_switch_on_eof; 294 | 295 | void yyrestart (FILE *input_file ); 296 | void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ); 297 | YY_BUFFER_STATE yy_create_buffer (FILE *file,int size ); 298 | void yy_delete_buffer (YY_BUFFER_STATE b ); 299 | void yy_flush_buffer (YY_BUFFER_STATE b ); 300 | void yypush_buffer_state (YY_BUFFER_STATE new_buffer ); 301 | void yypop_buffer_state (void ); 302 | 303 | static void yyensure_buffer_stack (void ); 304 | static void yy_load_buffer_state (void ); 305 | static void yy_init_buffer (YY_BUFFER_STATE b,FILE *file ); 306 | 307 | #define YY_FLUSH_BUFFER yy_flush_buffer(YY_CURRENT_BUFFER ) 308 | 309 | YY_BUFFER_STATE yy_scan_buffer (char *base,yy_size_t size ); 310 | YY_BUFFER_STATE yy_scan_string (yyconst char *yy_str ); 311 | YY_BUFFER_STATE yy_scan_bytes (yyconst char *bytes,int len ); 312 | 313 | void *yyalloc (yy_size_t ); 314 | void *yyrealloc (void *,yy_size_t ); 315 | void yyfree (void * ); 316 | 317 | #define yy_new_buffer yy_create_buffer 318 | 319 | #define yy_set_interactive(is_interactive) \ 320 | { \ 321 | if ( ! YY_CURRENT_BUFFER ){ \ 322 | yyensure_buffer_stack (); \ 323 | YY_CURRENT_BUFFER_LVALUE = \ 324 | yy_create_buffer(yyin,YY_BUF_SIZE ); \ 325 | } \ 326 | YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ 327 | } 328 | 329 | #define yy_set_bol(at_bol) \ 330 | { \ 331 | if ( ! YY_CURRENT_BUFFER ){\ 332 | yyensure_buffer_stack (); \ 333 | YY_CURRENT_BUFFER_LVALUE = \ 334 | yy_create_buffer(yyin,YY_BUF_SIZE ); \ 335 | } \ 336 | YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ 337 | } 338 | 339 | #define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) 340 | 341 | /* Begin user sect3 */ 342 | 343 | typedef unsigned char YY_CHAR; 344 | 345 | FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0; 346 | 347 | typedef int yy_state_type; 348 | 349 | extern int yylineno; 350 | 351 | int yylineno = 1; 352 | 353 | extern char *yytext; 354 | #define yytext_ptr yytext 355 | 356 | static yy_state_type yy_get_previous_state (void ); 357 | static yy_state_type yy_try_NUL_trans (yy_state_type current_state ); 358 | static int yy_get_next_buffer (void ); 359 | static void yy_fatal_error (yyconst char msg[] ); 360 | 361 | /* Done after the current pattern has been matched and before the 362 | * corresponding action - sets up yytext. 363 | */ 364 | #define YY_DO_BEFORE_ACTION \ 365 | (yytext_ptr) = yy_bp; \ 366 | yyleng = (size_t) (yy_cp - yy_bp); \ 367 | (yy_hold_char) = *yy_cp; \ 368 | *yy_cp = '\0'; \ 369 | (yy_c_buf_p) = yy_cp; 370 | 371 | #define YY_NUM_RULES 99 372 | #define YY_END_OF_BUFFER 100 373 | /* This struct is not used in this scanner, 374 | but its presence is necessary. */ 375 | struct yy_trans_info 376 | { 377 | flex_int32_t yy_verify; 378 | flex_int32_t yy_nxt; 379 | }; 380 | static yyconst flex_int16_t yy_accept[436] = 381 | { 0, 382 | 0, 0, 100, 98, 96, 96, 97, 84, 98, 98, 383 | 90, 83, 98, 78, 79, 88, 87, 75, 86, 82, 384 | 89, 45, 45, 76, 72, 91, 77, 92, 95, 39, 385 | 39, 39, 39, 39, 39, 80, 81, 93, 39, 39, 386 | 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 387 | 39, 39, 39, 39, 39, 39, 39, 73, 94, 74, 388 | 85, 71, 0, 50, 0, 41, 41, 57, 66, 58, 389 | 0, 0, 55, 63, 53, 64, 54, 65, 48, 2, 390 | 56, 49, 44, 0, 45, 0, 45, 62, 68, 0, 391 | 70, 69, 61, 39, 39, 39, 39, 39, 39, 59, 392 | 393 | 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 394 | 39, 39, 14, 39, 39, 39, 39, 39, 39, 39, 395 | 39, 39, 22, 39, 39, 39, 39, 39, 39, 39, 396 | 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 397 | 39, 39, 39, 39, 39, 39, 39, 39, 39, 60, 398 | 67, 41, 41, 46, 0, 48, 48, 0, 49, 44, 399 | 0, 47, 43, 52, 0, 0, 51, 39, 39, 39, 400 | 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 401 | 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 402 | 39, 39, 39, 39, 39, 39, 20, 39, 39, 39, 403 | 404 | 39, 39, 23, 39, 39, 39, 39, 39, 39, 39, 405 | 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 406 | 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 407 | 39, 39, 39, 39, 39, 39, 39, 41, 0, 48, 408 | 0, 48, 0, 49, 47, 43, 0, 39, 39, 38, 409 | 39, 39, 39, 39, 39, 39, 39, 39, 39, 5, 410 | 39, 39, 9, 10, 39, 39, 39, 39, 39, 16, 411 | 17, 39, 39, 39, 39, 21, 39, 39, 24, 39, 412 | 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 413 | 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 414 | 415 | 39, 39, 39, 39, 39, 39, 39, 39, 36, 39, 416 | 39, 39, 41, 0, 48, 42, 39, 39, 39, 39, 417 | 39, 39, 39, 39, 39, 39, 8, 39, 11, 39, 418 | 39, 39, 39, 19, 39, 39, 39, 39, 39, 39, 419 | 39, 7, 39, 39, 39, 39, 39, 4, 39, 27, 420 | 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 421 | 39, 39, 39, 39, 34, 39, 39, 1, 41, 39, 422 | 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 423 | 39, 39, 15, 18, 39, 39, 3, 39, 39, 26, 424 | 28, 6, 29, 39, 30, 39, 39, 31, 32, 39, 425 | 426 | 39, 39, 40, 39, 39, 39, 39, 39, 39, 39, 427 | 39, 39, 39, 13, 39, 33, 39, 39, 39, 39, 428 | 39, 12, 25, 35, 37, 39, 39, 39, 39, 39, 429 | 39, 39, 39, 39, 0 430 | } ; 431 | 432 | static yyconst flex_int32_t yy_ec[256] = 433 | { 0, 434 | 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 435 | 4, 4, 1, 1, 1, 1, 1, 1, 1, 1, 436 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 437 | 1, 4, 5, 6, 7, 1, 8, 9, 10, 11, 438 | 12, 13, 14, 15, 16, 17, 18, 19, 20, 20, 439 | 20, 20, 20, 20, 20, 20, 20, 21, 22, 23, 440 | 24, 25, 26, 1, 27, 28, 29, 30, 31, 32, 441 | 33, 34, 35, 34, 36, 37, 34, 38, 39, 34, 442 | 34, 40, 41, 42, 43, 34, 44, 45, 46, 34, 443 | 47, 48, 49, 50, 51, 1, 52, 53, 54, 55, 444 | 445 | 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 446 | 66, 67, 34, 68, 69, 70, 71, 72, 73, 74, 447 | 75, 76, 77, 78, 79, 80, 1, 1, 1, 1, 448 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 449 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 450 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 451 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 452 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 453 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 454 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 455 | 456 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 457 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 458 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 459 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 460 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 461 | 1, 1, 1, 1, 1 462 | } ; 463 | 464 | static yyconst flex_int32_t yy_meta[81] = 465 | { 0, 466 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 467 | 1, 1, 1, 1, 1, 1, 3, 3, 4, 4, 468 | 1, 1, 5, 5, 1, 1, 6, 6, 6, 6, 469 | 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 470 | 7, 7, 7, 7, 7, 7, 1, 1, 1, 1, 471 | 7, 6, 6, 6, 6, 6, 6, 7, 7, 7, 472 | 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 473 | 7, 7, 7, 7, 7, 7, 1, 1, 1, 1 474 | } ; 475 | 476 | static yyconst flex_int16_t yy_base[444] = 477 | { 0, 478 | 0, 0, 637, 638, 638, 638, 638, 612, 75, 580, 479 | 610, 73, 585, 638, 638, 608, 69, 638, 70, 65, 480 | 74, 71, 87, 638, 638, 76, 607, 85, 638, 0, 481 | 599, 584, 585, 576, 595, 638, 638, 601, 573, 51, 482 | 35, 73, 49, 63, 81, 557, 81, 23, 61, 74, 483 | 84, 99, 100, 97, 557, 555, 94, 638, 88, 638, 484 | 638, 638, 123, 638, 617, 0, 563, 638, 638, 638, 485 | 151, 164, 638, 638, 638, 638, 638, 638, 144, 638, 486 | 638, 158, 166, 168, 155, 0, 193, 594, 638, 600, 487 | 638, 638, 592, 0, 587, 579, 576, 162, 581, 638, 488 | 489 | 179, 553, 541, 543, 538, 541, 550, 154, 553, 538, 490 | 538, 545, 530, 531, 528, 165, 535, 531, 528, 527, 491 | 538, 523, 173, 522, 526, 534, 133, 525, 531, 531, 492 | 518, 525, 519, 175, 531, 124, 516, 174, 529, 520, 493 | 179, 519, 514, 506, 509, 179, 145, 515, 514, 638, 494 | 638, 0, 516, 638, 238, 638, 240, 247, 638, 231, 495 | 200, 250, 238, 638, 513, 554, 638, 527, 527, 531, 496 | 527, 536, 525, 524, 527, 208, 527, 190, 505, 216, 497 | 494, 496, 506, 494, 500, 487, 485, 171, 501, 499, 498 | 495, 486, 479, 492, 478, 494, 0, 485, 488, 477, 499 | 500 | 486, 486, 0, 482, 483, 473, 474, 42, 485, 470, 501 | 466, 468, 477, 223, 471, 459, 464, 466, 466, 458, 502 | 460, 468, 458, 446, 451, 186, 235, 450, 463, 462, 503 | 461, 450, 455, 459, 461, 449, 441, 450, 260, 291, 504 | 298, 638, 264, 300, 638, 278, 484, 475, 456, 0, 505 | 475, 466, 461, 464, 451, 464, 462, 461, 430, 0, 506 | 435, 430, 0, 0, 439, 424, 433, 421, 428, 0, 507 | 0, 422, 433, 418, 422, 0, 429, 429, 423, 421, 508 | 416, 414, 424, 409, 412, 407, 413, 406, 406, 416, 509 | 408, 401, 414, 242, 414, 412, 407, 398, 400, 221, 510 | 511 | 408, 409, 396, 407, 406, 404, 393, 399, 0, 386, 512 | 399, 398, 388, 271, 307, 638, 263, 425, 413, 412, 513 | 411, 224, 417, 418, 415, 375, 0, 390, 0, 378, 514 | 379, 385, 375, 0, 369, 0, 381, 373, 382, 360, 515 | 364, 0, 365, 375, 365, 360, 364, 0, 361, 0, 516 | 372, 356, 368, 373, 369, 354, 354, 345, 354, 258, 517 | 355, 347, 357, 359, 0, 349, 353, 0, 356, 384, 518 | 367, 367, 371, 378, 369, 365, 368, 344, 349, 330, 519 | 298, 298, 0, 0, 310, 299, 0, 311, 306, 0, 520 | 0, 0, 0, 291, 0, 293, 284, 0, 0, 301, 521 | 522 | 300, 292, 0, 318, 323, 305, 304, 317, 304, 294, 523 | 308, 291, 284, 0, 270, 0, 281, 279, 297, 304, 524 | 292, 0, 0, 0, 0, 287, 298, 286, 276, 258, 525 | 241, 222, 138, 84, 638, 370, 372, 379, 382, 386, 526 | 390, 394, 398 527 | } ; 528 | 529 | static yyconst flex_int16_t yy_def[444] = 530 | { 0, 531 | 435, 1, 435, 435, 435, 435, 435, 435, 436, 437, 532 | 435, 435, 438, 435, 435, 435, 435, 435, 435, 435, 533 | 435, 435, 435, 435, 435, 439, 435, 435, 435, 440, 534 | 440, 440, 440, 440, 440, 435, 435, 435, 440, 440, 535 | 440, 440, 440, 440, 440, 440, 440, 440, 440, 440, 536 | 440, 440, 440, 440, 440, 440, 440, 435, 435, 435, 537 | 435, 435, 436, 435, 436, 441, 441, 435, 435, 435, 538 | 438, 438, 435, 435, 435, 435, 435, 435, 435, 435, 539 | 435, 435, 435, 435, 435, 442, 435, 435, 435, 443, 540 | 435, 435, 435, 440, 440, 440, 440, 440, 440, 435, 541 | 542 | 440, 440, 440, 440, 440, 440, 440, 440, 440, 440, 543 | 440, 440, 440, 440, 440, 440, 440, 440, 440, 440, 544 | 440, 440, 440, 440, 440, 440, 440, 440, 440, 440, 545 | 440, 440, 440, 440, 440, 440, 440, 440, 440, 440, 546 | 440, 440, 440, 440, 440, 440, 440, 440, 440, 435, 547 | 435, 441, 441, 435, 435, 435, 435, 435, 435, 435, 548 | 435, 435, 442, 435, 435, 443, 435, 440, 440, 440, 549 | 440, 440, 440, 440, 440, 440, 440, 440, 440, 440, 550 | 440, 440, 440, 440, 440, 440, 440, 440, 440, 440, 551 | 440, 440, 440, 440, 440, 440, 440, 440, 440, 440, 552 | 553 | 440, 440, 440, 440, 440, 440, 440, 440, 440, 440, 554 | 440, 440, 440, 440, 440, 440, 440, 440, 440, 440, 555 | 440, 440, 440, 440, 440, 440, 440, 440, 440, 440, 556 | 440, 440, 440, 440, 440, 440, 440, 441, 435, 435, 557 | 435, 435, 435, 435, 435, 435, 435, 440, 440, 440, 558 | 440, 440, 440, 440, 440, 440, 440, 440, 440, 440, 559 | 440, 440, 440, 440, 440, 440, 440, 440, 440, 440, 560 | 440, 440, 440, 440, 440, 440, 440, 440, 440, 440, 561 | 440, 440, 440, 440, 440, 440, 440, 440, 440, 440, 562 | 440, 440, 440, 440, 440, 440, 440, 440, 440, 440, 563 | 564 | 440, 440, 440, 440, 440, 440, 440, 440, 440, 440, 565 | 440, 440, 441, 435, 435, 435, 440, 440, 440, 440, 566 | 440, 440, 440, 440, 440, 440, 440, 440, 440, 440, 567 | 440, 440, 440, 440, 440, 440, 440, 440, 440, 440, 568 | 440, 440, 440, 440, 440, 440, 440, 440, 440, 440, 569 | 440, 440, 440, 440, 440, 440, 440, 440, 440, 440, 570 | 440, 440, 440, 440, 440, 440, 440, 440, 441, 440, 571 | 440, 440, 440, 440, 440, 440, 440, 440, 440, 440, 572 | 440, 440, 440, 440, 440, 440, 440, 440, 440, 440, 573 | 440, 440, 440, 440, 440, 440, 440, 440, 440, 440, 574 | 575 | 440, 440, 441, 440, 440, 440, 440, 440, 440, 440, 576 | 440, 440, 440, 440, 440, 440, 440, 440, 440, 440, 577 | 440, 440, 440, 440, 440, 440, 440, 440, 440, 440, 578 | 440, 440, 440, 440, 0, 435, 435, 435, 435, 435, 579 | 435, 435, 435 580 | } ; 581 | 582 | static yyconst flex_int16_t yy_nxt[719] = 583 | { 0, 584 | 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 585 | 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 586 | 24, 25, 26, 27, 28, 29, 30, 30, 30, 31, 587 | 32, 30, 30, 30, 30, 30, 30, 33, 34, 30, 588 | 35, 30, 30, 30, 30, 30, 36, 4, 37, 38, 589 | 39, 40, 41, 42, 43, 44, 45, 46, 30, 47, 590 | 30, 30, 48, 49, 30, 50, 51, 52, 53, 54, 591 | 55, 56, 57, 30, 30, 30, 58, 59, 60, 61, 592 | 64, 69, 74, 79, 79, 76, 80, 82, 125, 83, 593 | 83, 126, 75, 77, 78, 282, 70, 81, 88, 89, 594 | 595 | 106, 84, 107, 82, 112, 87, 87, 85, 92, 93, 596 | 283, 150, 127, 85, 113, 86, 128, 84, 102, 103, 597 | 104, 105, 65, 85, 108, 114, 84, 115, 64, 85, 598 | 129, 109, 117, 85, 250, 110, 116, 123, 111, 131, 599 | 130, 85, 84, 118, 86, 124, 119, 120, 121, 85, 600 | 133, 132, 148, 135, 134, 136, 143, 85, 137, 138, 601 | 154, 149, 79, 79, 144, 151, 435, 139, 140, 141, 602 | 65, 145, 142, 71, 155, 156, 157, 157, 250, 218, 603 | 156, 161, 82, 161, 83, 83, 162, 162, 158, 159, 604 | 171, 85, 206, 219, 159, 207, 84, 85, 72, 155, 605 | 606 | 156, 172, 160, 173, 234, 174, 156, 235, 160, 82, 607 | 176, 87, 87, 158, 159, 177, 184, 85, 162, 162, 608 | 159, 84, 185, 84, 193, 85, 214, 201, 160, 85, 609 | 225, 221, 215, 226, 194, 85, 160, 202, 232, 266, 610 | 267, 298, 256, 250, 216, 299, 227, 233, 84, 222, 611 | 257, 239, 250, 239, 376, 85, 240, 240, 157, 157, 612 | 243, 250, 243, 85, 377, 244, 244, 160, 162, 162, 613 | 241, 242, 250, 160, 246, 250, 242, 250, 240, 240, 614 | 246, 245, 244, 244, 357, 287, 245, 358, 300, 315, 615 | 315, 434, 352, 160, 370, 241, 242, 301, 433, 302, 616 | 617 | 246, 160, 242, 371, 303, 304, 245, 353, 246, 240, 618 | 240, 314, 245, 314, 246, 432, 315, 315, 244, 244, 619 | 246, 396, 156, 431, 397, 315, 315, 156, 430, 429, 620 | 428, 159, 427, 426, 425, 424, 159, 423, 242, 422, 621 | 246, 250, 421, 242, 250, 250, 250, 156, 246, 250, 622 | 250, 420, 419, 156, 418, 417, 159, 416, 250, 250, 623 | 250, 415, 159, 242, 250, 250, 250, 414, 413, 242, 624 | 63, 63, 63, 63, 63, 63, 63, 66, 66, 71, 625 | 412, 71, 71, 71, 71, 71, 90, 90, 90, 94, 626 | 411, 94, 94, 152, 410, 152, 152, 163, 409, 163, 627 | 628 | 166, 166, 408, 166, 166, 407, 250, 406, 250, 405, 629 | 404, 403, 402, 401, 400, 399, 398, 250, 250, 250, 630 | 250, 250, 395, 394, 393, 392, 391, 250, 390, 389, 631 | 388, 387, 250, 250, 250, 250, 386, 336, 385, 384, 632 | 383, 382, 381, 250, 250, 380, 379, 378, 375, 374, 633 | 373, 372, 369, 250, 368, 367, 366, 365, 364, 363, 634 | 362, 361, 360, 359, 250, 356, 355, 354, 250, 351, 635 | 350, 349, 348, 347, 346, 345, 344, 343, 342, 341, 636 | 340, 339, 250, 338, 337, 336, 335, 334, 250, 333, 637 | 332, 331, 330, 329, 250, 328, 327, 326, 325, 324, 638 | 639 | 323, 322, 321, 320, 319, 318, 317, 250, 316, 313, 640 | 312, 311, 310, 309, 308, 307, 306, 250, 250, 305, 641 | 297, 296, 295, 294, 293, 292, 291, 250, 290, 289, 642 | 288, 250, 286, 285, 250, 284, 281, 250, 280, 279, 643 | 278, 277, 276, 250, 275, 274, 273, 272, 250, 271, 644 | 270, 269, 268, 265, 264, 263, 262, 261, 250, 260, 645 | 259, 258, 255, 254, 253, 252, 251, 250, 249, 248, 646 | 165, 247, 238, 237, 236, 231, 230, 229, 228, 224, 647 | 223, 220, 217, 213, 212, 211, 210, 209, 208, 205, 648 | 204, 203, 200, 199, 198, 197, 196, 195, 192, 191, 649 | 650 | 190, 189, 188, 187, 186, 183, 182, 181, 180, 179, 651 | 178, 175, 170, 169, 168, 167, 165, 164, 153, 435, 652 | 147, 146, 122, 101, 100, 99, 98, 97, 96, 95, 653 | 91, 73, 72, 68, 67, 62, 435, 3, 435, 435, 654 | 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 655 | 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 656 | 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 657 | 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 658 | 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 659 | 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 660 | 661 | 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 662 | 435, 435, 435, 435, 435, 435, 435, 435 663 | } ; 664 | 665 | static yyconst flex_int16_t yy_chk[719] = 666 | { 0, 667 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 668 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 669 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 670 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 671 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 672 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 673 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 674 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 675 | 9, 12, 17, 20, 20, 19, 21, 22, 48, 22, 676 | 22, 48, 17, 19, 19, 208, 12, 21, 26, 26, 677 | 678 | 41, 22, 41, 23, 43, 23, 23, 22, 28, 28, 679 | 208, 59, 49, 22, 43, 22, 49, 23, 40, 40, 680 | 40, 40, 9, 23, 42, 44, 22, 44, 63, 23, 681 | 50, 42, 45, 22, 434, 42, 44, 47, 42, 51, 682 | 50, 22, 23, 45, 22, 47, 45, 45, 45, 23, 683 | 52, 51, 57, 53, 52, 53, 54, 23, 53, 53, 684 | 71, 57, 79, 79, 54, 59, 72, 53, 53, 53, 685 | 63, 54, 53, 72, 79, 79, 82, 82, 433, 136, 686 | 79, 84, 83, 84, 83, 83, 84, 84, 82, 82, 687 | 98, 85, 127, 136, 82, 127, 83, 85, 71, 79, 688 | 689 | 79, 98, 83, 98, 147, 98, 79, 147, 83, 87, 690 | 101, 87, 87, 82, 82, 101, 108, 85, 161, 161, 691 | 82, 83, 108, 87, 116, 85, 134, 123, 83, 87, 692 | 141, 138, 134, 141, 116, 87, 83, 123, 146, 188, 693 | 188, 226, 176, 178, 134, 226, 141, 146, 87, 138, 694 | 176, 155, 432, 155, 322, 87, 155, 155, 157, 157, 695 | 158, 178, 158, 87, 322, 158, 158, 160, 162, 162, 696 | 157, 157, 180, 160, 163, 180, 157, 214, 239, 239, 697 | 163, 162, 243, 243, 300, 214, 162, 300, 227, 314, 698 | 314, 431, 294, 160, 317, 157, 157, 227, 430, 227, 699 | 700 | 163, 160, 157, 317, 227, 227, 162, 294, 163, 240, 701 | 240, 241, 162, 241, 246, 429, 241, 241, 244, 244, 702 | 246, 360, 240, 428, 360, 315, 315, 240, 427, 426, 703 | 421, 244, 420, 419, 418, 417, 244, 415, 315, 413, 704 | 246, 412, 411, 315, 410, 409, 408, 240, 246, 407, 705 | 406, 405, 404, 240, 402, 401, 244, 400, 397, 396, 706 | 394, 389, 244, 315, 388, 386, 385, 382, 381, 315, 707 | 436, 436, 436, 436, 436, 436, 436, 437, 437, 438, 708 | 380, 438, 438, 438, 438, 438, 439, 439, 439, 440, 709 | 379, 440, 440, 441, 378, 441, 441, 442, 377, 442, 710 | 711 | 443, 443, 376, 443, 443, 375, 374, 373, 372, 371, 712 | 370, 369, 367, 366, 364, 363, 362, 361, 359, 358, 713 | 357, 356, 355, 354, 353, 352, 351, 349, 347, 346, 714 | 345, 344, 343, 341, 340, 339, 338, 337, 335, 333, 715 | 332, 331, 330, 328, 326, 325, 324, 323, 321, 320, 716 | 319, 318, 313, 312, 311, 310, 308, 307, 306, 305, 717 | 304, 303, 302, 301, 299, 298, 297, 296, 295, 293, 718 | 292, 291, 290, 289, 288, 287, 286, 285, 284, 283, 719 | 282, 281, 280, 279, 278, 277, 275, 274, 273, 272, 720 | 269, 268, 267, 266, 265, 262, 261, 259, 258, 257, 721 | 722 | 256, 255, 254, 253, 252, 251, 249, 248, 247, 238, 723 | 237, 236, 235, 234, 233, 232, 231, 230, 229, 228, 724 | 225, 224, 223, 222, 221, 220, 219, 218, 217, 216, 725 | 215, 213, 212, 211, 210, 209, 207, 206, 205, 204, 726 | 202, 201, 200, 199, 198, 196, 195, 194, 193, 192, 727 | 191, 190, 189, 187, 186, 185, 184, 183, 182, 181, 728 | 179, 177, 175, 174, 173, 172, 171, 170, 169, 168, 729 | 166, 165, 153, 149, 148, 145, 144, 143, 142, 140, 730 | 139, 137, 135, 133, 132, 131, 130, 129, 128, 126, 731 | 125, 124, 122, 121, 120, 119, 118, 117, 115, 114, 732 | 733 | 113, 112, 111, 110, 109, 107, 106, 105, 104, 103, 734 | 102, 99, 97, 96, 95, 93, 90, 88, 67, 65, 735 | 56, 55, 46, 39, 38, 35, 34, 33, 32, 31, 736 | 27, 16, 13, 11, 10, 8, 3, 435, 435, 435, 737 | 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 738 | 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 739 | 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 740 | 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 741 | 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 742 | 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 743 | 744 | 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, 745 | 435, 435, 435, 435, 435, 435, 435, 435 746 | } ; 747 | 748 | static yy_state_type yy_last_accepting_state; 749 | static char *yy_last_accepting_cpos; 750 | 751 | extern int yy_flex_debug; 752 | int yy_flex_debug = 0; 753 | 754 | /* The intent behind this definition is that it'll catch 755 | * any uses of REJECT which flex missed. 756 | */ 757 | #define REJECT reject_used_but_not_detected 758 | #define yymore() yymore_used_but_not_detected 759 | #define YY_MORE_ADJ 0 760 | #define YY_RESTORE_YY_MORE_OFFSET 761 | char *yytext; 762 | #line 1 "analyse.l" 763 | /* 764 | 765 | This program is free software: you can redistribute it and/or modify 766 | it under the terms of the GNU General Public License as published by 767 | the Free Software Foundation, either version 3 of the License, or 768 | (at your option) any later version. 769 | This program is distributed in the hope that it will be useful, 770 | but WITHOUT ANY WARRANTY; without even the implied warranty of 771 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 772 | GNU General Public License for more details. 773 | You should have received a copy of the GNU General Public License 774 | along with this program. If not, see 775 | *************************************************************************** 776 | COBFU, C/C++ obfuscator 777 | Authors & contribute : 778 | Ryarbyah{ 779 | Main Authors: 780 | https://github.com/ryarnyah/AnalyseC 781 | C Obfuscator; http://not2do4programing.wordpress.com/ 782 | } 783 | Khalegh{ 784 | Continues: 785 | https://github.com/khaleghsalehi/COBFU 786 | Khalegh Salehi 787 | Email:khaleghsalehi@gmail.com 788 | } 789 | Note: 790 | [+] Add \ to break the line in c source code 791 | */ 792 | #line 39 "analyse.l" 793 | #include 794 | #include 795 | #include "cons.h" 796 | #include 797 | #include "list_exist.h" 798 | #include 799 | char *parse_akolad(); 800 | //char *parse_parantez(); 801 | void parse_while(); 802 | void count(); 803 | void comment(); 804 | void newprintf(); 805 | void newscanf(); 806 | void changedigit(); 807 | static list_exist list; 808 | static FILE * currentFile = NULL; 809 | static int isAuto = 1; 810 | static int byPass = 0; 811 | //define global variable for parse_akolad 812 | char buff11[1000]; 813 | char polbuff11[1000]; 814 | #line 815 "lex.yy.c" 815 | 816 | #define INITIAL 0 817 | 818 | #ifndef YY_NO_UNISTD_H 819 | /* Special case for "unistd.h", since it is non-ANSI. We include it way 820 | * down here because we want the user's section 1 to have been scanned first. 821 | * The user has a chance to override it with an option. 822 | */ 823 | #include 824 | #endif 825 | 826 | #ifndef YY_EXTRA_TYPE 827 | #define YY_EXTRA_TYPE void * 828 | #endif 829 | 830 | static int yy_init_globals (void ); 831 | 832 | /* Accessor methods to globals. 833 | These are made visible to non-reentrant scanners for convenience. */ 834 | 835 | int yylex_destroy (void ); 836 | 837 | int yyget_debug (void ); 838 | 839 | void yyset_debug (int debug_flag ); 840 | 841 | YY_EXTRA_TYPE yyget_extra (void ); 842 | 843 | void yyset_extra (YY_EXTRA_TYPE user_defined ); 844 | 845 | FILE *yyget_in (void ); 846 | 847 | void yyset_in (FILE * in_str ); 848 | 849 | FILE *yyget_out (void ); 850 | 851 | void yyset_out (FILE * out_str ); 852 | 853 | int yyget_leng (void ); 854 | 855 | char *yyget_text (void ); 856 | 857 | int yyget_lineno (void ); 858 | 859 | void yyset_lineno (int line_number ); 860 | 861 | /* Macros after this point can all be overridden by user definitions in 862 | * section 1. 863 | */ 864 | 865 | #ifndef YY_SKIP_YYWRAP 866 | #ifdef __cplusplus 867 | extern "C" int yywrap (void ); 868 | #else 869 | extern int yywrap (void ); 870 | #endif 871 | #endif 872 | 873 | static void yyunput (int c,char *buf_ptr ); 874 | 875 | #ifndef yytext_ptr 876 | static void yy_flex_strncpy (char *,yyconst char *,int ); 877 | #endif 878 | 879 | #ifdef YY_NEED_STRLEN 880 | static int yy_flex_strlen (yyconst char * ); 881 | #endif 882 | 883 | #ifndef YY_NO_INPUT 884 | 885 | #ifdef __cplusplus 886 | static int yyinput (void ); 887 | #else 888 | static int input (void ); 889 | #endif 890 | 891 | #endif 892 | 893 | /* Amount of stuff to slurp up with each read. */ 894 | #ifndef YY_READ_BUF_SIZE 895 | #ifdef __ia64__ 896 | /* On IA-64, the buffer size is 16k, not 8k */ 897 | #define YY_READ_BUF_SIZE 16384 898 | #else 899 | #define YY_READ_BUF_SIZE 8192 900 | #endif /* __ia64__ */ 901 | #endif 902 | 903 | /* Copy whatever the last rule matched to the standard output. */ 904 | #ifndef ECHO 905 | /* This used to be an fputs(), but since the string might contain NUL's, 906 | * we now use fwrite(). 907 | */ 908 | #define ECHO do { if (fwrite( yytext, yyleng, 1, yyout )) {} } while (0) 909 | #endif 910 | 911 | /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, 912 | * is returned in "result". 913 | */ 914 | #ifndef YY_INPUT 915 | #define YY_INPUT(buf,result,max_size) \ 916 | if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ 917 | { \ 918 | int c = '*'; \ 919 | size_t n; \ 920 | for ( n = 0; n < max_size && \ 921 | (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ 922 | buf[n] = (char) c; \ 923 | if ( c == '\n' ) \ 924 | buf[n++] = (char) c; \ 925 | if ( c == EOF && ferror( yyin ) ) \ 926 | YY_FATAL_ERROR( "input in flex scanner failed" ); \ 927 | result = n; \ 928 | } \ 929 | else \ 930 | { \ 931 | errno=0; \ 932 | while ( (result = fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \ 933 | { \ 934 | if( errno != EINTR) \ 935 | { \ 936 | YY_FATAL_ERROR( "input in flex scanner failed" ); \ 937 | break; \ 938 | } \ 939 | errno=0; \ 940 | clearerr(yyin); \ 941 | } \ 942 | }\ 943 | \ 944 | 945 | #endif 946 | 947 | /* No semi-colon after return; correct usage is to write "yyterminate();" - 948 | * we don't want an extra ';' after the "return" because that will cause 949 | * some compilers to complain about unreachable statements. 950 | */ 951 | #ifndef yyterminate 952 | #define yyterminate() return YY_NULL 953 | #endif 954 | 955 | /* Number of entries by which start-condition stack grows. */ 956 | #ifndef YY_START_STACK_INCR 957 | #define YY_START_STACK_INCR 25 958 | #endif 959 | 960 | /* Report a fatal error. */ 961 | #ifndef YY_FATAL_ERROR 962 | #define YY_FATAL_ERROR(msg) yy_fatal_error( msg ) 963 | #endif 964 | 965 | /* end tables serialization structures and prototypes */ 966 | 967 | /* Default declaration of generated scanner - a define so the user can 968 | * easily add parameters. 969 | */ 970 | #ifndef YY_DECL 971 | #define YY_DECL_IS_OURS 1 972 | 973 | extern int yylex (void); 974 | 975 | #define YY_DECL int yylex (void) 976 | #endif /* !YY_DECL */ 977 | 978 | /* Code executed at the beginning of each rule, after yytext and yyleng 979 | * have been set up. 980 | */ 981 | #ifndef YY_USER_ACTION 982 | #define YY_USER_ACTION 983 | #endif 984 | 985 | /* Code executed at the end of each rule. */ 986 | #ifndef YY_BREAK 987 | #define YY_BREAK break; 988 | #endif 989 | 990 | #define YY_RULE_SETUP \ 991 | YY_USER_ACTION 992 | 993 | /** The main scanner function which does all the work. 994 | */ 995 | YY_DECL 996 | { 997 | register yy_state_type yy_current_state; 998 | register char *yy_cp, *yy_bp; 999 | register int yy_act; 1000 | 1001 | #line 62 "analyse.l" 1002 | 1003 | #line 1004 "lex.yy.c" 1004 | 1005 | if ( !(yy_init) ) 1006 | { 1007 | (yy_init) = 1; 1008 | 1009 | #ifdef YY_USER_INIT 1010 | YY_USER_INIT; 1011 | #endif 1012 | 1013 | if ( ! (yy_start) ) 1014 | (yy_start) = 1; /* first start state */ 1015 | 1016 | if ( ! yyin ) 1017 | yyin = stdin; 1018 | 1019 | if ( ! yyout ) 1020 | yyout = stdout; 1021 | 1022 | if ( ! YY_CURRENT_BUFFER ) { 1023 | yyensure_buffer_stack (); 1024 | YY_CURRENT_BUFFER_LVALUE = 1025 | yy_create_buffer(yyin,YY_BUF_SIZE ); 1026 | } 1027 | 1028 | yy_load_buffer_state( ); 1029 | } 1030 | 1031 | while ( 1 ) /* loops until end-of-file is reached */ 1032 | { 1033 | yy_cp = (yy_c_buf_p); 1034 | 1035 | /* Support of yytext. */ 1036 | *yy_cp = (yy_hold_char); 1037 | 1038 | /* yy_bp points to the position in yy_ch_buf of the start of 1039 | * the current run. 1040 | */ 1041 | yy_bp = yy_cp; 1042 | 1043 | yy_current_state = (yy_start); 1044 | yy_match: 1045 | do 1046 | { 1047 | register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; 1048 | if ( yy_accept[yy_current_state] ) 1049 | { 1050 | (yy_last_accepting_state) = yy_current_state; 1051 | (yy_last_accepting_cpos) = yy_cp; 1052 | } 1053 | while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) 1054 | { 1055 | yy_current_state = (int) yy_def[yy_current_state]; 1056 | if ( yy_current_state >= 436 ) 1057 | yy_c = yy_meta[(unsigned int) yy_c]; 1058 | } 1059 | yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; 1060 | ++yy_cp; 1061 | } 1062 | while ( yy_base[yy_current_state] != 638 ); 1063 | 1064 | yy_find_action: 1065 | yy_act = yy_accept[yy_current_state]; 1066 | if ( yy_act == 0 ) 1067 | { /* have to back up */ 1068 | yy_cp = (yy_last_accepting_cpos); 1069 | yy_current_state = (yy_last_accepting_state); 1070 | yy_act = yy_accept[yy_current_state]; 1071 | } 1072 | 1073 | YY_DO_BEFORE_ACTION; 1074 | 1075 | do_action: /* This label is used only to access EOF actions. */ 1076 | 1077 | switch ( yy_act ) 1078 | { /* beginning of action switch */ 1079 | case 0: /* must back up */ 1080 | /* undo the effects of YY_DO_BEFORE_ACTION */ 1081 | *yy_cp = (yy_hold_char); 1082 | yy_cp = (yy_last_accepting_cpos); 1083 | yy_current_state = (yy_last_accepting_state); 1084 | goto yy_find_action; 1085 | 1086 | case 1: 1087 | YY_RULE_SETUP 1088 | #line 63 "analyse.l" 1089 | { parse_while();} 1090 | YY_BREAK 1091 | case 2: 1092 | YY_RULE_SETUP 1093 | #line 64 "analyse.l" 1094 | { comment();} 1095 | YY_BREAK 1096 | case 3: 1097 | YY_RULE_SETUP 1098 | #line 65 "analyse.l" 1099 | { newprintf();} 1100 | YY_BREAK 1101 | case 4: 1102 | YY_RULE_SETUP 1103 | #line 66 "analyse.l" 1104 | { newscanf();} 1105 | YY_BREAK 1106 | case 5: 1107 | YY_RULE_SETUP 1108 | #line 67 "analyse.l" 1109 | { fprintf(currentFile, "%s", yytext); } 1110 | YY_BREAK 1111 | case 6: 1112 | YY_RULE_SETUP 1113 | #line 68 "analyse.l" 1114 | { fprintf(currentFile, "%s", yytext); } 1115 | YY_BREAK 1116 | case 7: 1117 | YY_RULE_SETUP 1118 | #line 69 "analyse.l" 1119 | { fprintf(currentFile, "%s", yytext); } 1120 | YY_BREAK 1121 | case 8: 1122 | YY_RULE_SETUP 1123 | #line 70 "analyse.l" 1124 | { fprintf(currentFile, "%s", yytext); } 1125 | YY_BREAK 1126 | case 9: 1127 | YY_RULE_SETUP 1128 | #line 71 "analyse.l" 1129 | { fprintf(currentFile, "%s", yytext); } 1130 | YY_BREAK 1131 | case 10: 1132 | YY_RULE_SETUP 1133 | #line 72 "analyse.l" 1134 | { fprintf(currentFile, "%s", yytext); } 1135 | YY_BREAK 1136 | case 11: 1137 | YY_RULE_SETUP 1138 | #line 73 "analyse.l" 1139 | { fprintf(currentFile, "%s", yytext); } 1140 | YY_BREAK 1141 | case 12: 1142 | YY_RULE_SETUP 1143 | #line 74 "analyse.l" 1144 | { fprintf(currentFile, "%s", yytext); } 1145 | YY_BREAK 1146 | case 13: 1147 | YY_RULE_SETUP 1148 | #line 75 "analyse.l" 1149 | { fprintf(currentFile, "%s", yytext); } 1150 | YY_BREAK 1151 | case 14: 1152 | YY_RULE_SETUP 1153 | #line 76 "analyse.l" 1154 | { fprintf(currentFile, "%s", yytext); } 1155 | YY_BREAK 1156 | case 15: 1157 | YY_RULE_SETUP 1158 | #line 77 "analyse.l" 1159 | { fprintf(currentFile, "%s", yytext); } 1160 | YY_BREAK 1161 | case 16: 1162 | YY_RULE_SETUP 1163 | #line 78 "analyse.l" 1164 | { fprintf(currentFile, "%s", yytext); } 1165 | YY_BREAK 1166 | case 17: 1167 | YY_RULE_SETUP 1168 | #line 79 "analyse.l" 1169 | { fprintf(currentFile, "%s", yytext); } 1170 | YY_BREAK 1171 | case 18: 1172 | YY_RULE_SETUP 1173 | #line 80 "analyse.l" 1174 | { fprintf(currentFile, "%s", yytext); } 1175 | YY_BREAK 1176 | case 19: 1177 | YY_RULE_SETUP 1178 | #line 81 "analyse.l" 1179 | { fprintf(currentFile, "%s", yytext); } 1180 | YY_BREAK 1181 | case 20: 1182 | YY_RULE_SETUP 1183 | #line 82 "analyse.l" 1184 | { fprintf(currentFile, "%s", yytext); } 1185 | YY_BREAK 1186 | case 21: 1187 | YY_RULE_SETUP 1188 | #line 83 "analyse.l" 1189 | { fprintf(currentFile, "%s", yytext); } 1190 | YY_BREAK 1191 | case 22: 1192 | YY_RULE_SETUP 1193 | #line 84 "analyse.l" 1194 | { fprintf(currentFile, "%s", yytext); } 1195 | YY_BREAK 1196 | case 23: 1197 | YY_RULE_SETUP 1198 | #line 85 "analyse.l" 1199 | { fprintf(currentFile, "%s", yytext); } 1200 | YY_BREAK 1201 | case 24: 1202 | YY_RULE_SETUP 1203 | #line 86 "analyse.l" 1204 | { fprintf(currentFile, "%s", yytext); } 1205 | YY_BREAK 1206 | case 25: 1207 | YY_RULE_SETUP 1208 | #line 87 "analyse.l" 1209 | { fprintf(currentFile, "%s", yytext); } 1210 | YY_BREAK 1211 | case 26: 1212 | YY_RULE_SETUP 1213 | #line 88 "analyse.l" 1214 | { fprintf(currentFile, "%s", yytext); } 1215 | YY_BREAK 1216 | case 27: 1217 | YY_RULE_SETUP 1218 | #line 89 "analyse.l" 1219 | { fprintf(currentFile, "%s", yytext); } 1220 | YY_BREAK 1221 | case 28: 1222 | YY_RULE_SETUP 1223 | #line 90 "analyse.l" 1224 | { fprintf(currentFile, "%s", yytext); } 1225 | YY_BREAK 1226 | case 29: 1227 | YY_RULE_SETUP 1228 | #line 91 "analyse.l" 1229 | { fprintf(currentFile, "%s", yytext); } 1230 | YY_BREAK 1231 | case 30: 1232 | YY_RULE_SETUP 1233 | #line 92 "analyse.l" 1234 | { fprintf(currentFile, "%s", yytext); } 1235 | YY_BREAK 1236 | case 31: 1237 | YY_RULE_SETUP 1238 | #line 93 "analyse.l" 1239 | { fprintf(currentFile, "%s", yytext); } 1240 | YY_BREAK 1241 | case 32: 1242 | YY_RULE_SETUP 1243 | #line 94 "analyse.l" 1244 | { fprintf(currentFile, "%s", yytext); } 1245 | YY_BREAK 1246 | case 33: 1247 | YY_RULE_SETUP 1248 | #line 95 "analyse.l" 1249 | { fprintf(currentFile, "%s", yytext); } 1250 | YY_BREAK 1251 | case 34: 1252 | YY_RULE_SETUP 1253 | #line 96 "analyse.l" 1254 | { fprintf(currentFile, "%s", yytext); } 1255 | YY_BREAK 1256 | case 35: 1257 | YY_RULE_SETUP 1258 | #line 97 "analyse.l" 1259 | { fprintf(currentFile, "%s", yytext); } 1260 | YY_BREAK 1261 | case 36: 1262 | YY_RULE_SETUP 1263 | #line 98 "analyse.l" 1264 | { fprintf(currentFile, "%s", yytext); } 1265 | YY_BREAK 1266 | case 37: 1267 | YY_RULE_SETUP 1268 | #line 99 "analyse.l" 1269 | { fprintf(currentFile, "%s", yytext); } 1270 | YY_BREAK 1271 | case 38: 1272 | YY_RULE_SETUP 1273 | #line 100 "analyse.l" 1274 | { fprintf(currentFile, "%s", yytext); } 1275 | YY_BREAK 1276 | case 39: 1277 | YY_RULE_SETUP 1278 | #line 101 "analyse.l" 1279 | { char * reso = malloc(sizeof(char)*(strlen(yytext) + 1)); memcpy(reso, yytext, sizeof(char)*(strlen(yytext) + 1));cons * res = get_from_key(list, reso, isAuto, byPass); fprintf(currentFile, "%s", res->second); if(byPass==1)byPass=0;} 1280 | YY_BREAK 1281 | case 40: 1282 | YY_RULE_SETUP 1283 | #line 102 "analyse.l" 1284 | {fprintf(currentFile, "%s", yytext);byPass=1;} 1285 | YY_BREAK 1286 | case 41: 1287 | YY_RULE_SETUP 1288 | #line 103 "analyse.l" 1289 | {fprintf(currentFile, "%s", yytext);} 1290 | YY_BREAK 1291 | case 42: 1292 | YY_RULE_SETUP 1293 | #line 104 "analyse.l" 1294 | {fprintf(currentFile, "%s", yytext);} 1295 | YY_BREAK 1296 | case 43: 1297 | YY_RULE_SETUP 1298 | #line 106 "analyse.l" 1299 | { fprintf(currentFile, "%s", yytext); } 1300 | YY_BREAK 1301 | case 44: 1302 | YY_RULE_SETUP 1303 | #line 107 "analyse.l" 1304 | { fprintf(currentFile, "%s", yytext); } 1305 | YY_BREAK 1306 | case 45: 1307 | YY_RULE_SETUP 1308 | #line 108 "analyse.l" 1309 | { changedigit(); } 1310 | YY_BREAK 1311 | case 46: 1312 | /* rule 46 can match eol */ 1313 | YY_RULE_SETUP 1314 | #line 109 "analyse.l" 1315 | { fprintf(currentFile, "%s", "Digit yytext"); } 1316 | YY_BREAK 1317 | case 47: 1318 | YY_RULE_SETUP 1319 | #line 111 "analyse.l" 1320 | { changedigit(); } 1321 | YY_BREAK 1322 | case 48: 1323 | YY_RULE_SETUP 1324 | #line 112 "analyse.l" 1325 | { changedigit(); } 1326 | YY_BREAK 1327 | case 49: 1328 | YY_RULE_SETUP 1329 | #line 113 "analyse.l" 1330 | { changedigit(); } 1331 | YY_BREAK 1332 | case 50: 1333 | /* rule 50 can match eol */ 1334 | YY_RULE_SETUP 1335 | #line 114 "analyse.l" 1336 | { fprintf(currentFile, "%s", yytext); } 1337 | YY_BREAK 1338 | case 51: 1339 | YY_RULE_SETUP 1340 | #line 115 "analyse.l" 1341 | { fprintf(currentFile, "%s", yytext); } 1342 | YY_BREAK 1343 | case 52: 1344 | YY_RULE_SETUP 1345 | #line 116 "analyse.l" 1346 | { fprintf(currentFile, "%s", yytext); } 1347 | YY_BREAK 1348 | case 53: 1349 | YY_RULE_SETUP 1350 | #line 117 "analyse.l" 1351 | { fprintf(currentFile, "%s", yytext); } 1352 | YY_BREAK 1353 | case 54: 1354 | YY_RULE_SETUP 1355 | #line 118 "analyse.l" 1356 | { fprintf(currentFile, "%s", yytext); } 1357 | YY_BREAK 1358 | case 55: 1359 | YY_RULE_SETUP 1360 | #line 119 "analyse.l" 1361 | { fprintf(currentFile, "%s", yytext); } 1362 | YY_BREAK 1363 | case 56: 1364 | YY_RULE_SETUP 1365 | #line 120 "analyse.l" 1366 | { fprintf(currentFile, "%s", yytext); } 1367 | YY_BREAK 1368 | case 57: 1369 | YY_RULE_SETUP 1370 | #line 121 "analyse.l" 1371 | { fprintf(currentFile, "%s", yytext); } 1372 | YY_BREAK 1373 | case 58: 1374 | YY_RULE_SETUP 1375 | #line 122 "analyse.l" 1376 | { fprintf(currentFile, "%s", yytext); } 1377 | YY_BREAK 1378 | case 59: 1379 | YY_RULE_SETUP 1380 | #line 123 "analyse.l" 1381 | { fprintf(currentFile, "%s", yytext); } 1382 | YY_BREAK 1383 | case 60: 1384 | YY_RULE_SETUP 1385 | #line 124 "analyse.l" 1386 | { fprintf(currentFile, "%s", yytext); } 1387 | YY_BREAK 1388 | case 61: 1389 | YY_RULE_SETUP 1390 | #line 125 "analyse.l" 1391 | { fprintf(currentFile, "%s", yytext); } 1392 | YY_BREAK 1393 | case 62: 1394 | YY_RULE_SETUP 1395 | #line 126 "analyse.l" 1396 | { fprintf(currentFile, "%s", yytext); } 1397 | YY_BREAK 1398 | case 63: 1399 | YY_RULE_SETUP 1400 | #line 127 "analyse.l" 1401 | { fprintf(currentFile, "%s", yytext); } 1402 | YY_BREAK 1403 | case 64: 1404 | YY_RULE_SETUP 1405 | #line 128 "analyse.l" 1406 | { fprintf(currentFile, "%s", yytext); } 1407 | YY_BREAK 1408 | case 65: 1409 | YY_RULE_SETUP 1410 | #line 129 "analyse.l" 1411 | { fprintf(currentFile, "%s", yytext); } 1412 | YY_BREAK 1413 | case 66: 1414 | YY_RULE_SETUP 1415 | #line 130 "analyse.l" 1416 | { fprintf(currentFile, "%s", yytext); } 1417 | YY_BREAK 1418 | case 67: 1419 | YY_RULE_SETUP 1420 | #line 131 "analyse.l" 1421 | { fprintf(currentFile, "%s", yytext); } 1422 | YY_BREAK 1423 | case 68: 1424 | YY_RULE_SETUP 1425 | #line 132 "analyse.l" 1426 | { fprintf(currentFile, "%s", yytext); } 1427 | YY_BREAK 1428 | case 69: 1429 | YY_RULE_SETUP 1430 | #line 133 "analyse.l" 1431 | { fprintf(currentFile, "%s", yytext); } 1432 | YY_BREAK 1433 | case 70: 1434 | YY_RULE_SETUP 1435 | #line 134 "analyse.l" 1436 | { fprintf(currentFile, "%s", yytext); } 1437 | YY_BREAK 1438 | case 71: 1439 | YY_RULE_SETUP 1440 | #line 135 "analyse.l" 1441 | { fprintf(currentFile, "%s", yytext); } 1442 | YY_BREAK 1443 | case 72: 1444 | YY_RULE_SETUP 1445 | #line 136 "analyse.l" 1446 | { fprintf(currentFile, "%s", yytext); } 1447 | YY_BREAK 1448 | case 73: 1449 | YY_RULE_SETUP 1450 | #line 137 "analyse.l" 1451 | { fprintf(currentFile, "%s", yytext); } 1452 | YY_BREAK 1453 | case 74: 1454 | YY_RULE_SETUP 1455 | #line 138 "analyse.l" 1456 | { fprintf(currentFile, "%s", yytext); } 1457 | YY_BREAK 1458 | case 75: 1459 | YY_RULE_SETUP 1460 | #line 139 "analyse.l" 1461 | { fprintf(currentFile, "%s", yytext); } 1462 | YY_BREAK 1463 | case 76: 1464 | YY_RULE_SETUP 1465 | #line 140 "analyse.l" 1466 | { fprintf(currentFile, "%s", yytext); } 1467 | YY_BREAK 1468 | case 77: 1469 | YY_RULE_SETUP 1470 | #line 141 "analyse.l" 1471 | { fprintf(currentFile, "%s", yytext); } 1472 | YY_BREAK 1473 | case 78: 1474 | YY_RULE_SETUP 1475 | #line 142 "analyse.l" 1476 | { fprintf(currentFile, "%s", yytext); } 1477 | YY_BREAK 1478 | case 79: 1479 | YY_RULE_SETUP 1480 | #line 143 "analyse.l" 1481 | { fprintf(currentFile, "%s", yytext); } 1482 | YY_BREAK 1483 | case 80: 1484 | YY_RULE_SETUP 1485 | #line 144 "analyse.l" 1486 | { fprintf(currentFile, "%s", yytext); } 1487 | YY_BREAK 1488 | case 81: 1489 | YY_RULE_SETUP 1490 | #line 145 "analyse.l" 1491 | { fprintf(currentFile, "%s", yytext); } 1492 | YY_BREAK 1493 | case 82: 1494 | YY_RULE_SETUP 1495 | #line 146 "analyse.l" 1496 | { fprintf(currentFile, "%s", yytext); } 1497 | YY_BREAK 1498 | case 83: 1499 | YY_RULE_SETUP 1500 | #line 147 "analyse.l" 1501 | { fprintf(currentFile, "%s", yytext); } 1502 | YY_BREAK 1503 | case 84: 1504 | YY_RULE_SETUP 1505 | #line 148 "analyse.l" 1506 | { fprintf(currentFile, "%s", yytext); } 1507 | YY_BREAK 1508 | case 85: 1509 | YY_RULE_SETUP 1510 | #line 149 "analyse.l" 1511 | { fprintf(currentFile, "%s", yytext); } 1512 | YY_BREAK 1513 | case 86: 1514 | YY_RULE_SETUP 1515 | #line 150 "analyse.l" 1516 | { fprintf(currentFile, "%s", yytext); } 1517 | YY_BREAK 1518 | case 87: 1519 | YY_RULE_SETUP 1520 | #line 151 "analyse.l" 1521 | { fprintf(currentFile, "%s", yytext); } 1522 | YY_BREAK 1523 | case 88: 1524 | YY_RULE_SETUP 1525 | #line 152 "analyse.l" 1526 | { fprintf(currentFile, "%s", yytext); } 1527 | YY_BREAK 1528 | case 89: 1529 | YY_RULE_SETUP 1530 | #line 153 "analyse.l" 1531 | { fprintf(currentFile, "%s", yytext); } 1532 | YY_BREAK 1533 | case 90: 1534 | YY_RULE_SETUP 1535 | #line 154 "analyse.l" 1536 | { fprintf(currentFile, "%s", yytext); } 1537 | YY_BREAK 1538 | case 91: 1539 | YY_RULE_SETUP 1540 | #line 155 "analyse.l" 1541 | { fprintf(currentFile, "%s", yytext); } 1542 | YY_BREAK 1543 | case 92: 1544 | YY_RULE_SETUP 1545 | #line 156 "analyse.l" 1546 | { fprintf(currentFile, "%s", yytext); } 1547 | YY_BREAK 1548 | case 93: 1549 | YY_RULE_SETUP 1550 | #line 157 "analyse.l" 1551 | { fprintf(currentFile, "%s", yytext); } 1552 | YY_BREAK 1553 | case 94: 1554 | YY_RULE_SETUP 1555 | #line 158 "analyse.l" 1556 | { fprintf(currentFile, "%s", yytext); } 1557 | YY_BREAK 1558 | case 95: 1559 | YY_RULE_SETUP 1560 | #line 159 "analyse.l" 1561 | { fprintf(currentFile, "%s", yytext); } 1562 | YY_BREAK 1563 | case 96: 1564 | /* rule 96 can match eol */ 1565 | YY_RULE_SETUP 1566 | #line 160 "analyse.l" 1567 | { fprintf(currentFile, "%s", ""); } 1568 | YY_BREAK 1569 | case 97: 1570 | YY_RULE_SETUP 1571 | #line 161 "analyse.l" 1572 | { fprintf(currentFile, "%s", yytext); } 1573 | YY_BREAK 1574 | case 98: 1575 | YY_RULE_SETUP 1576 | #line 162 "analyse.l" 1577 | { /* ignore bad characters */ fprintf(currentFile, "%s", yytext); } 1578 | YY_BREAK 1579 | case 99: 1580 | YY_RULE_SETUP 1581 | #line 164 "analyse.l" 1582 | ECHO; 1583 | YY_BREAK 1584 | #line 1585 "lex.yy.c" 1585 | case YY_STATE_EOF(INITIAL): 1586 | yyterminate(); 1587 | 1588 | case YY_END_OF_BUFFER: 1589 | { 1590 | /* Amount of text matched not including the EOB char. */ 1591 | int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1; 1592 | 1593 | /* Undo the effects of YY_DO_BEFORE_ACTION. */ 1594 | *yy_cp = (yy_hold_char); 1595 | YY_RESTORE_YY_MORE_OFFSET 1596 | 1597 | if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) 1598 | { 1599 | /* We're scanning a new file or input source. It's 1600 | * possible that this happened because the user 1601 | * just pointed yyin at a new source and called 1602 | * yylex(). If so, then we have to assure 1603 | * consistency between YY_CURRENT_BUFFER and our 1604 | * globals. Here is the right place to do so, because 1605 | * this is the first action (other than possibly a 1606 | * back-up) that will match for the new input source. 1607 | */ 1608 | (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; 1609 | YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin; 1610 | YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; 1611 | } 1612 | 1613 | /* Note that here we test for yy_c_buf_p "<=" to the position 1614 | * of the first EOB in the buffer, since yy_c_buf_p will 1615 | * already have been incremented past the NUL character 1616 | * (since all states make transitions on EOB to the 1617 | * end-of-buffer state). Contrast this with the test 1618 | * in input(). 1619 | */ 1620 | if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) 1621 | { /* This was really a NUL. */ 1622 | yy_state_type yy_next_state; 1623 | 1624 | (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text; 1625 | 1626 | yy_current_state = yy_get_previous_state( ); 1627 | 1628 | /* Okay, we're now positioned to make the NUL 1629 | * transition. We couldn't have 1630 | * yy_get_previous_state() go ahead and do it 1631 | * for us because it doesn't know how to deal 1632 | * with the possibility of jamming (and we don't 1633 | * want to build jamming into it because then it 1634 | * will run more slowly). 1635 | */ 1636 | 1637 | yy_next_state = yy_try_NUL_trans( yy_current_state ); 1638 | 1639 | yy_bp = (yytext_ptr) + YY_MORE_ADJ; 1640 | 1641 | if ( yy_next_state ) 1642 | { 1643 | /* Consume the NUL. */ 1644 | yy_cp = ++(yy_c_buf_p); 1645 | yy_current_state = yy_next_state; 1646 | goto yy_match; 1647 | } 1648 | 1649 | else 1650 | { 1651 | yy_cp = (yy_c_buf_p); 1652 | goto yy_find_action; 1653 | } 1654 | } 1655 | 1656 | else switch ( yy_get_next_buffer( ) ) 1657 | { 1658 | case EOB_ACT_END_OF_FILE: 1659 | { 1660 | (yy_did_buffer_switch_on_eof) = 0; 1661 | 1662 | if ( yywrap( ) ) 1663 | { 1664 | /* Note: because we've taken care in 1665 | * yy_get_next_buffer() to have set up 1666 | * yytext, we can now set up 1667 | * yy_c_buf_p so that if some total 1668 | * hoser (like flex itself) wants to 1669 | * call the scanner after we return the 1670 | * YY_NULL, it'll still work - another 1671 | * YY_NULL will get returned. 1672 | */ 1673 | (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ; 1674 | 1675 | yy_act = YY_STATE_EOF(YY_START); 1676 | goto do_action; 1677 | } 1678 | 1679 | else 1680 | { 1681 | if ( ! (yy_did_buffer_switch_on_eof) ) 1682 | YY_NEW_FILE; 1683 | } 1684 | break; 1685 | } 1686 | 1687 | case EOB_ACT_CONTINUE_SCAN: 1688 | (yy_c_buf_p) = 1689 | (yytext_ptr) + yy_amount_of_matched_text; 1690 | 1691 | yy_current_state = yy_get_previous_state( ); 1692 | 1693 | yy_cp = (yy_c_buf_p); 1694 | yy_bp = (yytext_ptr) + YY_MORE_ADJ; 1695 | goto yy_match; 1696 | 1697 | case EOB_ACT_LAST_MATCH: 1698 | (yy_c_buf_p) = 1699 | &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)]; 1700 | 1701 | yy_current_state = yy_get_previous_state( ); 1702 | 1703 | yy_cp = (yy_c_buf_p); 1704 | yy_bp = (yytext_ptr) + YY_MORE_ADJ; 1705 | goto yy_find_action; 1706 | } 1707 | break; 1708 | } 1709 | 1710 | default: 1711 | YY_FATAL_ERROR( 1712 | "fatal flex scanner internal error--no action found" ); 1713 | } /* end of action switch */ 1714 | } /* end of scanning one token */ 1715 | } /* end of yylex */ 1716 | 1717 | /* yy_get_next_buffer - try to read in a new buffer 1718 | * 1719 | * Returns a code representing an action: 1720 | * EOB_ACT_LAST_MATCH - 1721 | * EOB_ACT_CONTINUE_SCAN - continue scanning from current position 1722 | * EOB_ACT_END_OF_FILE - end of file 1723 | */ 1724 | static int yy_get_next_buffer (void) 1725 | { 1726 | register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; 1727 | register char *source = (yytext_ptr); 1728 | register int number_to_move, i; 1729 | int ret_val; 1730 | 1731 | if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] ) 1732 | YY_FATAL_ERROR( 1733 | "fatal flex scanner internal error--end of buffer missed" ); 1734 | 1735 | if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) 1736 | { /* Don't try to fill the buffer, so this is an EOF. */ 1737 | if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 ) 1738 | { 1739 | /* We matched a single character, the EOB, so 1740 | * treat this as a final EOF. 1741 | */ 1742 | return EOB_ACT_END_OF_FILE; 1743 | } 1744 | 1745 | else 1746 | { 1747 | /* We matched some text prior to the EOB, first 1748 | * process it. 1749 | */ 1750 | return EOB_ACT_LAST_MATCH; 1751 | } 1752 | } 1753 | 1754 | /* Try to read more data. */ 1755 | 1756 | /* First move last chars to start of buffer. */ 1757 | number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1; 1758 | 1759 | for ( i = 0; i < number_to_move; ++i ) 1760 | *(dest++) = *(source++); 1761 | 1762 | if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) 1763 | /* don't do the read, it's not guaranteed to return an EOF, 1764 | * just force an EOF 1765 | */ 1766 | YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0; 1767 | 1768 | else 1769 | { 1770 | int num_to_read = 1771 | YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; 1772 | 1773 | while ( num_to_read <= 0 ) 1774 | { /* Not enough room in the buffer - grow it. */ 1775 | 1776 | /* just a shorter name for the current buffer */ 1777 | YY_BUFFER_STATE b = YY_CURRENT_BUFFER; 1778 | 1779 | int yy_c_buf_p_offset = 1780 | (int) ((yy_c_buf_p) - b->yy_ch_buf); 1781 | 1782 | if ( b->yy_is_our_buffer ) 1783 | { 1784 | int new_size = b->yy_buf_size * 2; 1785 | 1786 | if ( new_size <= 0 ) 1787 | b->yy_buf_size += b->yy_buf_size / 8; 1788 | else 1789 | b->yy_buf_size *= 2; 1790 | 1791 | b->yy_ch_buf = (char *) 1792 | /* Include room in for 2 EOB chars. */ 1793 | yyrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ); 1794 | } 1795 | else 1796 | /* Can't grow it, we don't own it. */ 1797 | b->yy_ch_buf = 0; 1798 | 1799 | if ( ! b->yy_ch_buf ) 1800 | YY_FATAL_ERROR( 1801 | "fatal error - scanner input buffer overflow" ); 1802 | 1803 | (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset]; 1804 | 1805 | num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - 1806 | number_to_move - 1; 1807 | 1808 | } 1809 | 1810 | if ( num_to_read > YY_READ_BUF_SIZE ) 1811 | num_to_read = YY_READ_BUF_SIZE; 1812 | 1813 | /* Read in more data. */ 1814 | YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), 1815 | (yy_n_chars), (size_t) num_to_read ); 1816 | 1817 | YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); 1818 | } 1819 | 1820 | if ( (yy_n_chars) == 0 ) 1821 | { 1822 | if ( number_to_move == YY_MORE_ADJ ) 1823 | { 1824 | ret_val = EOB_ACT_END_OF_FILE; 1825 | yyrestart(yyin ); 1826 | } 1827 | 1828 | else 1829 | { 1830 | ret_val = EOB_ACT_LAST_MATCH; 1831 | YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = 1832 | YY_BUFFER_EOF_PENDING; 1833 | } 1834 | } 1835 | 1836 | else 1837 | ret_val = EOB_ACT_CONTINUE_SCAN; 1838 | 1839 | if ((yy_size_t) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { 1840 | /* Extend the array by 50%, plus the number we really need. */ 1841 | yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1); 1842 | YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ); 1843 | if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) 1844 | YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); 1845 | } 1846 | 1847 | (yy_n_chars) += number_to_move; 1848 | YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR; 1849 | YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR; 1850 | 1851 | (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; 1852 | 1853 | return ret_val; 1854 | } 1855 | 1856 | /* yy_get_previous_state - get the state just before the EOB char was reached */ 1857 | 1858 | static yy_state_type yy_get_previous_state (void) 1859 | { 1860 | register yy_state_type yy_current_state; 1861 | register char *yy_cp; 1862 | 1863 | yy_current_state = (yy_start); 1864 | 1865 | for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp ) 1866 | { 1867 | register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); 1868 | if ( yy_accept[yy_current_state] ) 1869 | { 1870 | (yy_last_accepting_state) = yy_current_state; 1871 | (yy_last_accepting_cpos) = yy_cp; 1872 | } 1873 | while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) 1874 | { 1875 | yy_current_state = (int) yy_def[yy_current_state]; 1876 | if ( yy_current_state >= 436 ) 1877 | yy_c = yy_meta[(unsigned int) yy_c]; 1878 | } 1879 | yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; 1880 | } 1881 | 1882 | return yy_current_state; 1883 | } 1884 | 1885 | /* yy_try_NUL_trans - try to make a transition on the NUL character 1886 | * 1887 | * synopsis 1888 | * next_state = yy_try_NUL_trans( current_state ); 1889 | */ 1890 | static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state ) 1891 | { 1892 | register int yy_is_jam; 1893 | register char *yy_cp = (yy_c_buf_p); 1894 | 1895 | register YY_CHAR yy_c = 1; 1896 | if ( yy_accept[yy_current_state] ) 1897 | { 1898 | (yy_last_accepting_state) = yy_current_state; 1899 | (yy_last_accepting_cpos) = yy_cp; 1900 | } 1901 | while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) 1902 | { 1903 | yy_current_state = (int) yy_def[yy_current_state]; 1904 | if ( yy_current_state >= 436 ) 1905 | yy_c = yy_meta[(unsigned int) yy_c]; 1906 | } 1907 | yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; 1908 | yy_is_jam = (yy_current_state == 435); 1909 | 1910 | return yy_is_jam ? 0 : yy_current_state; 1911 | } 1912 | 1913 | static void yyunput (int c, register char * yy_bp ) 1914 | { 1915 | register char *yy_cp; 1916 | 1917 | yy_cp = (yy_c_buf_p); 1918 | 1919 | /* undo effects of setting up yytext */ 1920 | *yy_cp = (yy_hold_char); 1921 | 1922 | if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) 1923 | { /* need to shift things up to make room */ 1924 | /* +2 for EOB chars. */ 1925 | register int number_to_move = (yy_n_chars) + 2; 1926 | register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[ 1927 | YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2]; 1928 | register char *source = 1929 | &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]; 1930 | 1931 | while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) 1932 | *--dest = *--source; 1933 | 1934 | yy_cp += (int) (dest - source); 1935 | yy_bp += (int) (dest - source); 1936 | YY_CURRENT_BUFFER_LVALUE->yy_n_chars = 1937 | (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_buf_size; 1938 | 1939 | if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) 1940 | YY_FATAL_ERROR( "flex scanner push-back overflow" ); 1941 | } 1942 | 1943 | *--yy_cp = (char) c; 1944 | 1945 | (yytext_ptr) = yy_bp; 1946 | (yy_hold_char) = *yy_cp; 1947 | (yy_c_buf_p) = yy_cp; 1948 | } 1949 | 1950 | #ifndef YY_NO_INPUT 1951 | #ifdef __cplusplus 1952 | static int yyinput (void) 1953 | #else 1954 | static int input (void) 1955 | #endif 1956 | 1957 | { 1958 | int c; 1959 | 1960 | *(yy_c_buf_p) = (yy_hold_char); 1961 | 1962 | if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR ) 1963 | { 1964 | /* yy_c_buf_p now points to the character we want to return. 1965 | * If this occurs *before* the EOB characters, then it's a 1966 | * valid NUL; if not, then we've hit the end of the buffer. 1967 | */ 1968 | if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) 1969 | /* This was really a NUL. */ 1970 | *(yy_c_buf_p) = '\0'; 1971 | 1972 | else 1973 | { /* need more input */ 1974 | int offset = (yy_c_buf_p) - (yytext_ptr); 1975 | ++(yy_c_buf_p); 1976 | 1977 | switch ( yy_get_next_buffer( ) ) 1978 | { 1979 | case EOB_ACT_LAST_MATCH: 1980 | /* This happens because yy_g_n_b() 1981 | * sees that we've accumulated a 1982 | * token and flags that we need to 1983 | * try matching the token before 1984 | * proceeding. But for input(), 1985 | * there's no matching to consider. 1986 | * So convert the EOB_ACT_LAST_MATCH 1987 | * to EOB_ACT_END_OF_FILE. 1988 | */ 1989 | 1990 | /* Reset buffer status. */ 1991 | yyrestart(yyin ); 1992 | 1993 | /*FALLTHROUGH*/ 1994 | 1995 | case EOB_ACT_END_OF_FILE: 1996 | { 1997 | if ( yywrap( ) ) 1998 | return EOF; 1999 | 2000 | if ( ! (yy_did_buffer_switch_on_eof) ) 2001 | YY_NEW_FILE; 2002 | #ifdef __cplusplus 2003 | return yyinput(); 2004 | #else 2005 | return input(); 2006 | #endif 2007 | } 2008 | 2009 | case EOB_ACT_CONTINUE_SCAN: 2010 | (yy_c_buf_p) = (yytext_ptr) + offset; 2011 | break; 2012 | } 2013 | } 2014 | } 2015 | 2016 | c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */ 2017 | *(yy_c_buf_p) = '\0'; /* preserve yytext */ 2018 | (yy_hold_char) = *++(yy_c_buf_p); 2019 | 2020 | return c; 2021 | } 2022 | #endif /* ifndef YY_NO_INPUT */ 2023 | 2024 | /** Immediately switch to a different input stream. 2025 | * @param input_file A readable stream. 2026 | * 2027 | * @note This function does not reset the start condition to @c INITIAL . 2028 | */ 2029 | void yyrestart (FILE * input_file ) 2030 | { 2031 | 2032 | if ( ! YY_CURRENT_BUFFER ){ 2033 | yyensure_buffer_stack (); 2034 | YY_CURRENT_BUFFER_LVALUE = 2035 | yy_create_buffer(yyin,YY_BUF_SIZE ); 2036 | } 2037 | 2038 | yy_init_buffer(YY_CURRENT_BUFFER,input_file ); 2039 | yy_load_buffer_state( ); 2040 | } 2041 | 2042 | /** Switch to a different input buffer. 2043 | * @param new_buffer The new input buffer. 2044 | * 2045 | */ 2046 | void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ) 2047 | { 2048 | 2049 | /* TODO. We should be able to replace this entire function body 2050 | * with 2051 | * yypop_buffer_state(); 2052 | * yypush_buffer_state(new_buffer); 2053 | */ 2054 | yyensure_buffer_stack (); 2055 | if ( YY_CURRENT_BUFFER == new_buffer ) 2056 | return; 2057 | 2058 | if ( YY_CURRENT_BUFFER ) 2059 | { 2060 | /* Flush out information for old buffer. */ 2061 | *(yy_c_buf_p) = (yy_hold_char); 2062 | YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); 2063 | YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); 2064 | } 2065 | 2066 | YY_CURRENT_BUFFER_LVALUE = new_buffer; 2067 | yy_load_buffer_state( ); 2068 | 2069 | /* We don't actually know whether we did this switch during 2070 | * EOF (yywrap()) processing, but the only time this flag 2071 | * is looked at is after yywrap() is called, so it's safe 2072 | * to go ahead and always set it. 2073 | */ 2074 | (yy_did_buffer_switch_on_eof) = 1; 2075 | } 2076 | 2077 | static void yy_load_buffer_state (void) 2078 | { 2079 | (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; 2080 | (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; 2081 | yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; 2082 | (yy_hold_char) = *(yy_c_buf_p); 2083 | } 2084 | 2085 | /** Allocate and initialize an input buffer state. 2086 | * @param file A readable stream. 2087 | * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. 2088 | * 2089 | * @return the allocated buffer state. 2090 | */ 2091 | YY_BUFFER_STATE yy_create_buffer (FILE * file, int size ) 2092 | { 2093 | YY_BUFFER_STATE b; 2094 | 2095 | b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state ) ); 2096 | if ( ! b ) 2097 | YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); 2098 | 2099 | b->yy_buf_size = size; 2100 | 2101 | /* yy_ch_buf has to be 2 characters longer than the size given because 2102 | * we need to put in 2 end-of-buffer characters. 2103 | */ 2104 | b->yy_ch_buf = (char *) yyalloc(b->yy_buf_size + 2 ); 2105 | if ( ! b->yy_ch_buf ) 2106 | YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); 2107 | 2108 | b->yy_is_our_buffer = 1; 2109 | 2110 | yy_init_buffer(b,file ); 2111 | 2112 | return b; 2113 | } 2114 | 2115 | /** Destroy the buffer. 2116 | * @param b a buffer created with yy_create_buffer() 2117 | * 2118 | */ 2119 | void yy_delete_buffer (YY_BUFFER_STATE b ) 2120 | { 2121 | 2122 | if ( ! b ) 2123 | return; 2124 | 2125 | if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ 2126 | YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; 2127 | 2128 | if ( b->yy_is_our_buffer ) 2129 | yyfree((void *) b->yy_ch_buf ); 2130 | 2131 | yyfree((void *) b ); 2132 | } 2133 | 2134 | #ifndef __cplusplus 2135 | extern int isatty (int ); 2136 | #endif /* __cplusplus */ 2137 | 2138 | /* Initializes or reinitializes a buffer. 2139 | * This function is sometimes called more than once on the same buffer, 2140 | * such as during a yyrestart() or at EOF. 2141 | */ 2142 | static void yy_init_buffer (YY_BUFFER_STATE b, FILE * file ) 2143 | 2144 | { 2145 | int oerrno = errno; 2146 | 2147 | yy_flush_buffer(b ); 2148 | 2149 | b->yy_input_file = file; 2150 | b->yy_fill_buffer = 1; 2151 | 2152 | /* If b is the current buffer, then yy_init_buffer was _probably_ 2153 | * called from yyrestart() or through yy_get_next_buffer. 2154 | * In that case, we don't want to reset the lineno or column. 2155 | */ 2156 | if (b != YY_CURRENT_BUFFER){ 2157 | b->yy_bs_lineno = 1; 2158 | b->yy_bs_column = 0; 2159 | } 2160 | 2161 | b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; 2162 | 2163 | errno = oerrno; 2164 | } 2165 | 2166 | /** Discard all buffered characters. On the next scan, YY_INPUT will be called. 2167 | * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. 2168 | * 2169 | */ 2170 | void yy_flush_buffer (YY_BUFFER_STATE b ) 2171 | { 2172 | if ( ! b ) 2173 | return; 2174 | 2175 | b->yy_n_chars = 0; 2176 | 2177 | /* We always need two end-of-buffer characters. The first causes 2178 | * a transition to the end-of-buffer state. The second causes 2179 | * a jam in that state. 2180 | */ 2181 | b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; 2182 | b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; 2183 | 2184 | b->yy_buf_pos = &b->yy_ch_buf[0]; 2185 | 2186 | b->yy_at_bol = 1; 2187 | b->yy_buffer_status = YY_BUFFER_NEW; 2188 | 2189 | if ( b == YY_CURRENT_BUFFER ) 2190 | yy_load_buffer_state( ); 2191 | } 2192 | 2193 | /** Pushes the new state onto the stack. The new state becomes 2194 | * the current state. This function will allocate the stack 2195 | * if necessary. 2196 | * @param new_buffer The new state. 2197 | * 2198 | */ 2199 | void yypush_buffer_state (YY_BUFFER_STATE new_buffer ) 2200 | { 2201 | if (new_buffer == NULL) 2202 | return; 2203 | 2204 | yyensure_buffer_stack(); 2205 | 2206 | /* This block is copied from yy_switch_to_buffer. */ 2207 | if ( YY_CURRENT_BUFFER ) 2208 | { 2209 | /* Flush out information for old buffer. */ 2210 | *(yy_c_buf_p) = (yy_hold_char); 2211 | YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); 2212 | YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); 2213 | } 2214 | 2215 | /* Only push if top exists. Otherwise, replace top. */ 2216 | if (YY_CURRENT_BUFFER) 2217 | (yy_buffer_stack_top)++; 2218 | YY_CURRENT_BUFFER_LVALUE = new_buffer; 2219 | 2220 | /* copied from yy_switch_to_buffer. */ 2221 | yy_load_buffer_state( ); 2222 | (yy_did_buffer_switch_on_eof) = 1; 2223 | } 2224 | 2225 | /** Removes and deletes the top of the stack, if present. 2226 | * The next element becomes the new top. 2227 | * 2228 | */ 2229 | void yypop_buffer_state (void) 2230 | { 2231 | if (!YY_CURRENT_BUFFER) 2232 | return; 2233 | 2234 | yy_delete_buffer(YY_CURRENT_BUFFER ); 2235 | YY_CURRENT_BUFFER_LVALUE = NULL; 2236 | if ((yy_buffer_stack_top) > 0) 2237 | --(yy_buffer_stack_top); 2238 | 2239 | if (YY_CURRENT_BUFFER) { 2240 | yy_load_buffer_state( ); 2241 | (yy_did_buffer_switch_on_eof) = 1; 2242 | } 2243 | } 2244 | 2245 | /* Allocates the stack if it does not exist. 2246 | * Guarantees space for at least one push. 2247 | */ 2248 | static void yyensure_buffer_stack (void) 2249 | { 2250 | int num_to_alloc; 2251 | 2252 | if (!(yy_buffer_stack)) { 2253 | 2254 | /* First allocation is just for 2 elements, since we don't know if this 2255 | * scanner will even need a stack. We use 2 instead of 1 to avoid an 2256 | * immediate realloc on the next call. 2257 | */ 2258 | num_to_alloc = 1; 2259 | (yy_buffer_stack) = (struct yy_buffer_state**)yyalloc 2260 | (num_to_alloc * sizeof(struct yy_buffer_state*) 2261 | ); 2262 | if ( ! (yy_buffer_stack) ) 2263 | YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); 2264 | 2265 | memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*)); 2266 | 2267 | (yy_buffer_stack_max) = num_to_alloc; 2268 | (yy_buffer_stack_top) = 0; 2269 | return; 2270 | } 2271 | 2272 | if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){ 2273 | 2274 | /* Increase the buffer to prepare for a possible push. */ 2275 | int grow_size = 8 /* arbitrary grow size */; 2276 | 2277 | num_to_alloc = (yy_buffer_stack_max) + grow_size; 2278 | (yy_buffer_stack) = (struct yy_buffer_state**)yyrealloc 2279 | ((yy_buffer_stack), 2280 | num_to_alloc * sizeof(struct yy_buffer_state*) 2281 | ); 2282 | if ( ! (yy_buffer_stack) ) 2283 | YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); 2284 | 2285 | /* zero only the new slots.*/ 2286 | memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*)); 2287 | (yy_buffer_stack_max) = num_to_alloc; 2288 | } 2289 | } 2290 | 2291 | /** Setup the input buffer state to scan directly from a user-specified character buffer. 2292 | * @param base the character buffer 2293 | * @param size the size in bytes of the character buffer 2294 | * 2295 | * @return the newly allocated buffer state object. 2296 | */ 2297 | YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size ) 2298 | { 2299 | YY_BUFFER_STATE b; 2300 | 2301 | if ( size < 2 || 2302 | base[size-2] != YY_END_OF_BUFFER_CHAR || 2303 | base[size-1] != YY_END_OF_BUFFER_CHAR ) 2304 | /* They forgot to leave room for the EOB's. */ 2305 | return 0; 2306 | 2307 | b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state ) ); 2308 | if ( ! b ) 2309 | YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" ); 2310 | 2311 | b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */ 2312 | b->yy_buf_pos = b->yy_ch_buf = base; 2313 | b->yy_is_our_buffer = 0; 2314 | b->yy_input_file = 0; 2315 | b->yy_n_chars = b->yy_buf_size; 2316 | b->yy_is_interactive = 0; 2317 | b->yy_at_bol = 1; 2318 | b->yy_fill_buffer = 0; 2319 | b->yy_buffer_status = YY_BUFFER_NEW; 2320 | 2321 | yy_switch_to_buffer(b ); 2322 | 2323 | return b; 2324 | } 2325 | 2326 | /** Setup the input buffer state to scan a string. The next call to yylex() will 2327 | * scan from a @e copy of @a str. 2328 | * @param yystr a NUL-terminated string to scan 2329 | * 2330 | * @return the newly allocated buffer state object. 2331 | * @note If you want to scan bytes that may contain NUL values, then use 2332 | * yy_scan_bytes() instead. 2333 | */ 2334 | YY_BUFFER_STATE yy_scan_string (yyconst char * yystr ) 2335 | { 2336 | 2337 | return yy_scan_bytes(yystr,strlen(yystr) ); 2338 | } 2339 | 2340 | /** Setup the input buffer state to scan the given bytes. The next call to yylex() will 2341 | * scan from a @e copy of @a bytes. 2342 | * @param yybytes the byte buffer to scan 2343 | * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes. 2344 | * 2345 | * @return the newly allocated buffer state object. 2346 | */ 2347 | YY_BUFFER_STATE yy_scan_bytes (yyconst char * yybytes, int _yybytes_len ) 2348 | { 2349 | YY_BUFFER_STATE b; 2350 | char *buf; 2351 | yy_size_t n; 2352 | int i; 2353 | 2354 | /* Get memory for full buffer, including space for trailing EOB's. */ 2355 | n = _yybytes_len + 2; 2356 | buf = (char *) yyalloc(n ); 2357 | if ( ! buf ) 2358 | YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); 2359 | 2360 | for ( i = 0; i < _yybytes_len; ++i ) 2361 | buf[i] = yybytes[i]; 2362 | 2363 | buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR; 2364 | 2365 | b = yy_scan_buffer(buf,n ); 2366 | if ( ! b ) 2367 | YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" ); 2368 | 2369 | /* It's okay to grow etc. this buffer, and we should throw it 2370 | * away when we're done. 2371 | */ 2372 | b->yy_is_our_buffer = 1; 2373 | 2374 | return b; 2375 | } 2376 | 2377 | #ifndef YY_EXIT_FAILURE 2378 | #define YY_EXIT_FAILURE 2 2379 | #endif 2380 | 2381 | static void yy_fatal_error (yyconst char* msg ) 2382 | { 2383 | (void) fprintf( stderr, "%s\n", msg ); 2384 | exit( YY_EXIT_FAILURE ); 2385 | } 2386 | 2387 | /* Redefine yyless() so it works in section 3 code. */ 2388 | 2389 | #undef yyless 2390 | #define yyless(n) \ 2391 | do \ 2392 | { \ 2393 | /* Undo effects of setting up yytext. */ \ 2394 | int yyless_macro_arg = (n); \ 2395 | YY_LESS_LINENO(yyless_macro_arg);\ 2396 | yytext[yyleng] = (yy_hold_char); \ 2397 | (yy_c_buf_p) = yytext + yyless_macro_arg; \ 2398 | (yy_hold_char) = *(yy_c_buf_p); \ 2399 | *(yy_c_buf_p) = '\0'; \ 2400 | yyleng = yyless_macro_arg; \ 2401 | } \ 2402 | while ( 0 ) 2403 | 2404 | /* Accessor methods (get/set functions) to struct members. */ 2405 | 2406 | /** Get the current line number. 2407 | * 2408 | */ 2409 | int yyget_lineno (void) 2410 | { 2411 | 2412 | return yylineno; 2413 | } 2414 | 2415 | /** Get the input stream. 2416 | * 2417 | */ 2418 | FILE *yyget_in (void) 2419 | { 2420 | return yyin; 2421 | } 2422 | 2423 | /** Get the output stream. 2424 | * 2425 | */ 2426 | FILE *yyget_out (void) 2427 | { 2428 | return yyout; 2429 | } 2430 | 2431 | /** Get the length of the current token. 2432 | * 2433 | */ 2434 | int yyget_leng (void) 2435 | { 2436 | return yyleng; 2437 | } 2438 | 2439 | /** Get the current token. 2440 | * 2441 | */ 2442 | 2443 | char *yyget_text (void) 2444 | { 2445 | return yytext; 2446 | } 2447 | 2448 | /** Set the current line number. 2449 | * @param line_number 2450 | * 2451 | */ 2452 | void yyset_lineno (int line_number ) 2453 | { 2454 | 2455 | yylineno = line_number; 2456 | } 2457 | 2458 | /** Set the input stream. This does not discard the current 2459 | * input buffer. 2460 | * @param in_str A readable stream. 2461 | * 2462 | * @see yy_switch_to_buffer 2463 | */ 2464 | void yyset_in (FILE * in_str ) 2465 | { 2466 | yyin = in_str ; 2467 | } 2468 | 2469 | void yyset_out (FILE * out_str ) 2470 | { 2471 | yyout = out_str ; 2472 | } 2473 | 2474 | int yyget_debug (void) 2475 | { 2476 | return yy_flex_debug; 2477 | } 2478 | 2479 | void yyset_debug (int bdebug ) 2480 | { 2481 | yy_flex_debug = bdebug ; 2482 | } 2483 | 2484 | static int yy_init_globals (void) 2485 | { 2486 | /* Initialization is the same as for the non-reentrant scanner. 2487 | * This function is called from yylex_destroy(), so don't allocate here. 2488 | */ 2489 | 2490 | (yy_buffer_stack) = 0; 2491 | (yy_buffer_stack_top) = 0; 2492 | (yy_buffer_stack_max) = 0; 2493 | (yy_c_buf_p) = (char *) 0; 2494 | (yy_init) = 0; 2495 | (yy_start) = 0; 2496 | 2497 | /* Defined in main.c */ 2498 | #ifdef YY_STDINIT 2499 | yyin = stdin; 2500 | yyout = stdout; 2501 | #else 2502 | yyin = (FILE *) 0; 2503 | yyout = (FILE *) 0; 2504 | #endif 2505 | 2506 | /* For future reference: Set errno on error, since we are called by 2507 | * yylex_init() 2508 | */ 2509 | return 0; 2510 | } 2511 | 2512 | /* yylex_destroy is for both reentrant and non-reentrant scanners. */ 2513 | int yylex_destroy (void) 2514 | { 2515 | 2516 | /* Pop the buffer stack, destroying each element. */ 2517 | while(YY_CURRENT_BUFFER){ 2518 | yy_delete_buffer(YY_CURRENT_BUFFER ); 2519 | YY_CURRENT_BUFFER_LVALUE = NULL; 2520 | yypop_buffer_state(); 2521 | } 2522 | 2523 | /* Destroy the stack itself. */ 2524 | yyfree((yy_buffer_stack) ); 2525 | (yy_buffer_stack) = NULL; 2526 | 2527 | /* Reset the globals. This is important in a non-reentrant scanner so the next time 2528 | * yylex() is called, initialization will occur. */ 2529 | yy_init_globals( ); 2530 | 2531 | return 0; 2532 | } 2533 | 2534 | /* 2535 | * Internal utility routines. 2536 | */ 2537 | 2538 | #ifndef yytext_ptr 2539 | static void yy_flex_strncpy (char* s1, yyconst char * s2, int n ) 2540 | { 2541 | register int i; 2542 | for ( i = 0; i < n; ++i ) 2543 | s1[i] = s2[i]; 2544 | } 2545 | #endif 2546 | 2547 | #ifdef YY_NEED_STRLEN 2548 | static int yy_flex_strlen (yyconst char * s ) 2549 | { 2550 | register int n; 2551 | for ( n = 0; s[n]; ++n ) 2552 | ; 2553 | 2554 | return n; 2555 | } 2556 | #endif 2557 | 2558 | void *yyalloc (yy_size_t size ) 2559 | { 2560 | return (void *) malloc( size ); 2561 | } 2562 | 2563 | void *yyrealloc (void * ptr, yy_size_t size ) 2564 | { 2565 | /* The cast to (char *) in the following accommodates both 2566 | * implementations that use char* generic pointers, and those 2567 | * that use void* generic pointers. It works with the latter 2568 | * because both ANSI C and C++ allow castless assignment from 2569 | * any pointer type to void*, and deal with argument conversions 2570 | * as though doing an assignment. 2571 | */ 2572 | return (void *) realloc( (char *) ptr, size ); 2573 | } 2574 | 2575 | void yyfree (void * ptr ) 2576 | { 2577 | free( (char *) ptr ); /* see yyrealloc() for (char *) cast */ 2578 | } 2579 | 2580 | #define YYTABLES_NAME "yytables" 2581 | 2582 | #line 164 "analyse.l" 2583 | 2584 | 2585 | 2586 | int yywrap() 2587 | { 2588 | return 1; 2589 | } 2590 | 2591 | //zx 2592 | void parse_while() 2593 | { 2594 | int i,arg; 2595 | char ako[1]=""; 2596 | char swname[100]=""; 2597 | for(i=0;i<=1000;i++) 2598 | { 2599 | buff11[i]='\0'; 2600 | polbuff11[i]='\0'; 2601 | } 2602 | 2603 | /**/ 2604 | /*Creat random name for switch case var*/ 2605 | char charset[] = "0123456789" 2606 | "abcdefghijklmnopqrstuvwxyz" 2607 | "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; 2608 | char prefix[]="_"; 2609 | swname[0]=prefix[0]; 2610 | swname[1]=prefix[0]; 2611 | i=2; 2612 | while (i<=8) { 2613 | size_t index = (double) rand() / RAND_MAX * (sizeof charset - 1); 2614 | swname[i] =charset[index]; 2615 | i++; 2616 | } 2617 | swname[11] ='\0'; 2618 | 2619 | for(i=0;i<10;i++) 2620 | printf("%c",swname[i]); 2621 | /* End name generation */ 2622 | printf("\n\n"); 2623 | 2624 | 2625 | 2626 | 2627 | parse_akolad(); 2628 | arg=0; 2629 | i=0; 2630 | strcpy(ako,"{"); 2631 | 2632 | 2633 | 2634 | // TEMP for test, remove here 2635 | 2636 | i=0; 2637 | printf("\n------------------------\n"); 2638 | for(i=0;i<=15;i++) 2639 | printf("[%d][%c]-",i,polbuff11[i]); 2640 | printf("\n------------------------\n"); 2641 | 2642 | 2643 | 2644 | //TEMP for test 2645 | i=0; 2646 | while(polbuff11[i]!=ako[0]) 2647 | { 2648 | printf("%c",polbuff11[i]); 2649 | i++; 2650 | arg++; 2651 | } 2652 | // 2653 | //printf("Index is a -> %d\n",k); 2654 | // 2655 | 2656 | 2657 | 2658 | 2659 | fprintf(currentFile,"%s","__OoOoOl1l1l=1;\nwhile(__OoOoOl1l1l!=0){\nswitch(__OoOoOl1l1l)\n{\ncase 1:{__OoOoOl1l1l=2;break;}\ncase 2:\n{"); 2660 | fprintf(currentFile,"%s","\n\tif"); 2661 | for (i=0;i<=arg-1;i++) 2662 | fprintf(currentFile,"%c",polbuff11[i]); 2663 | fprintf(currentFile,"%s","\n\t\t{__OoOoOl1l1l=3;break;}"); 2664 | fprintf(currentFile,"%s","\n\tif(!"); 2665 | for(i=0;i<=arg-1;i++) 2666 | fprintf(currentFile,"%c",polbuff11[i]); 2667 | fprintf(currentFile,"%s" ,")\n\t\t{__OoOoOl1l1l=0;break;}\nbreak;}\ncase 3:\n{\n"); 2668 | 2669 | 2670 | i=arg+1; 2671 | while(polbuff11[i]!='\0') 2672 | // for (i=arg+1;i<1000;i++) 2673 | { 2674 | fprintf(currentFile,"%c",polbuff11[i]); 2675 | i++; 2676 | } 2677 | 2678 | fprintf(currentFile,"%s","\n\n__OoOoOl1l1l=2;break;}\n}"); // check for removed {, remember 2679 | }// End of parse while function. 2680 | 2681 | 2682 | 2683 | 2684 | 2685 | 2686 | 2687 | 2688 | char *parse_akolad() 2689 | { 2690 | char c1; 2691 | while((c1 = input()) !='}') 2692 | { 2693 | sprintf(buff11,"%c",c1); 2694 | strcat(polbuff11,buff11); 2695 | parse_akolad(); 2696 | return 0; 2697 | } 2698 | strcat(polbuff11,"}"); 2699 | return polbuff11; 2700 | } 2701 | 2702 | 2703 | 2704 | 2705 | 2706 | /******************************** 2707 | Remove the comments by // 2708 | *********************************/ 2709 | /* 2710 | How to use gcc preprocessors to remove all comment in c source code 2711 | gcc -fpreprocessed -dD -E test.c 2712 | */ 2713 | 2714 | /*Comment by myself*/ 2715 | void comment() 2716 | { 2717 | char c, c1; 2718 | 2719 | loop: 2720 | while ((c = input()) != '*' && c != 0) 2721 | ;//putchar(c); 2722 | 2723 | if ((c1 = input()) != '/' && c != 0) 2724 | { 2725 | unput(c1); 2726 | goto loop; 2727 | } 2728 | 2729 | if (c != 0) 2730 | ;//putchar(c1); 2731 | } 2732 | /******************************************** 2733 | ********************************************/ 2734 | void changedigit() 2735 | { 2736 | float rp1,rp2,digit; 2737 | int rndx; 2738 | //float poldigit; 2739 | //int poldigit,rndx,rp1,rp2,digit; 2740 | 2741 | //zz 2742 | srand(time(NULL)); 2743 | rndx=rand()%10000000+1; 2744 | printf("%d",rndx); 2745 | digit=atoi(yytext); 2746 | rp1=(digit)-rndx; 2747 | rp2=(digit-rp1)+rndx; 2748 | // poldigit=(rp1+rp2-rndx); 2749 | fprintf(currentFile, "((((%f)+(%f))-((%d))))",rp1,rp2,rndx); // the prantez help to complex exprestion 2750 | // fprintf(currentFile, "%f+%f-%d",rp1,rp2,rndx); // the prantez help to complex exprestion 2751 | 2752 | 2753 | } 2754 | /******************************************** 2755 | ********************************************/ 2756 | /* 2757 | START scanf FUNCTION 2758 | 2759 | */ 2760 | void newscanf() 2761 | { 2762 | char c,c1; 2763 | int code,code2; 2764 | char binstr[1000]=""; 2765 | char repo[1000]="",hexrepo[1000]=""; 2766 | while ((c=input())!='(' && c !=0) 2767 | unput(c); 2768 | while ((c1=input()) !=',' && c!=0){ 2769 | code=(int)c1; 2770 | if(code==92){ // Find Slash character 2771 | sprintf(hexrepo,"%s","\\"); 2772 | strcat(repo,hexrepo); 2773 | c1=input();//Next 2774 | sprintf(hexrepo,"%c",c1); 2775 | strcat(repo,hexrepo); 2776 | continue;} 2777 | //zz 2778 | 2779 | if(code==37){ // Find % character & figureout printf format string 2780 | sprintf(hexrepo,"%s","\%"); 2781 | strcat(repo,hexrepo); 2782 | c1=input();//Next 2783 | code2=(int)c1; 2784 | while (((int)code2!=100) && ((int)code2!=99) && ((int)code2!=102) && ((int)code2!=115) && ((int)code2!=105) ) 2785 | { 2786 | sprintf(hexrepo,"%c",c1); 2787 | strcat(repo,hexrepo); 2788 | c1=input(); 2789 | code2=(int)c1; 2790 | //continue; 2791 | } 2792 | if ( code2==105 || code2==99 || code2==102 || code2==115 || code2==100 ) 2793 | { 2794 | sprintf(hexrepo,"%c",c1); 2795 | strcat(repo,hexrepo); 2796 | // c1=input(); 2797 | continue; 2798 | } 2799 | 2800 | } // End of % checkup 2801 | 2802 | if(code!=34){ // Ignore " character 2803 | sprintf(hexrepo,"\\x%x", c1); 2804 | strcat(repo,hexrepo); 2805 | } 2806 | } // End of while II 2807 | 2808 | sprintf(binstr, "%s%s%s", "scanf(\"",repo,"\","); 2809 | fprintf(currentFile, "%s", binstr); 2810 | printf("%s",yytext); 2811 | printf("\n"); 2812 | } 2813 | 2814 | /* 2815 | END Scanf FUNCTION 2816 | 2817 | */ 2818 | 2819 | /******************************************** 2820 | ********************************************/ 2821 | 2822 | 2823 | 2824 | 2825 | /* 2826 | START PRINTF FUNCTION 2827 | printf([message/format specific],variable) 2828 | printf(" [%[Dig].[Dig]f,d,i,c,s,[a-z][A-Z][0-9][!@#$%^&*()_+]",v1,v2,..,v(n-1),v(n)) 2829 | Where v1,v2,..,v(n-1),v(n-2) must be changed and replaced. 2830 | 2831 | 2832 | */ 2833 | 2834 | 2835 | 2836 | /*********************************** 2837 | 2838 | Orginal syntax : 2839 | printf("[Printf format type/message]",var1,var2,...varn); 2840 | So: 2841 | printf(part I,Part II) 2842 | Obfuscation details: 2843 | while(c1=input!=')') 2844 | buff=buff+c1; // buff is a string contain all string befor last ) in printf(.....) 2845 | // Part I 2846 | index=find-last-str-postion(buff,"); 2847 | messagebuff="printf('") 2848 | for(i=0;i<=index,i++) 2849 | messagebuff=messagebuff+buff[i] 2850 | for(i=0;i"\") 2853 | write(hex(messagebuff[i])); 2854 | else // format type string... 2855 | { 2856 | 2857 | while(messagebuff[i]<> d,s,o,... ) 2858 | { 2859 | write(messagebuff[i]; 2860 | i++; // For example \3.33f 2861 | } 2862 | write(mesaagebuff[i++?]; / for example \n --> n 2863 | } 2864 | } 2865 | for(i=index;i<=len(buff);i++) // write Part II 2866 | write(buff[i]); 2867 | write(")"); 2868 | This approach have a problem during parsing becuase this example parsing not completely for example printf(" my name is a(a) ",..... 2869 | when parsing parse until a) and drop esle... 2870 | 2871 | ************************************/ 2872 | 2873 | 2874 | 2875 | void newprintf() 2876 | { 2877 | char c,c1; 2878 | int i,code,code2; 2879 | char binstr[1000]=""; 2880 | char repo[1000]="",hexrepo[1000]=""; 2881 | /* 2882 | CHECK FOR SIMPLE printf, work such as simple echo 2883 | Example: 2884 | printf("Hello World") 2885 | */ 2886 | 2887 | 2888 | /* 2889 | CHECK FOR ADVANCED printf, 2890 | Example: 2891 | printf("\n\n%d%3.1f",i,j); 2892 | */ 2893 | for(i=0;i<100;i++) 2894 | printf("%c",yytext[i]); 2895 | while ((c=input())!='(' && c !=0) 2896 | unput(c); 2897 | while ((c1=input()) !=',' && c!=0){ 2898 | code=(int)c1; 2899 | if(code==92){ // Find Slash character 2900 | sprintf(hexrepo,"%s","\\"); 2901 | strcat(repo,hexrepo); 2902 | c1=input();//Next 2903 | sprintf(hexrepo,"%c",c1); 2904 | strcat(repo,hexrepo); 2905 | continue;} 2906 | //zz 2907 | 2908 | if(code==37){ // Find % character & figureout printf format string 2909 | sprintf(hexrepo,"%s","\%"); 2910 | strcat(repo,hexrepo); 2911 | c1=input();//Next 2912 | code2=(int)c1; 2913 | while (((int)code2!=100) && ((int)code2!=99) && ((int)code2!=102) && ((int)code2!=115) && ((int)code2!=105) ) 2914 | { 2915 | sprintf(hexrepo,"%c",c1); 2916 | strcat(repo,hexrepo); 2917 | c1=input(); 2918 | code2=(int)c1; 2919 | //continue; 2920 | } 2921 | if ( code2==105 || code2==99 || code2==102 || code2==115 || code2==100 ) 2922 | { 2923 | sprintf(hexrepo,"%c",c1); 2924 | strcat(repo,hexrepo); 2925 | // c1=input(); 2926 | continue; 2927 | } 2928 | 2929 | } // End of % checkup 2930 | 2931 | if(code!=34){ // Ignore " character 2932 | sprintf(hexrepo,"\\x%x", c1); 2933 | strcat(repo,hexrepo); 2934 | } 2935 | } // End of while II 2936 | 2937 | sprintf(binstr, "%s%s%s", "printf(\"",repo,"\","); 2938 | fprintf(currentFile, "%s", binstr); 2939 | printf("%s",yytext); 2940 | printf("\n"); 2941 | } 2942 | 2943 | /* 2944 | END PRINTF FUNCTION 2945 | 2946 | */ 2947 | 2948 | 2949 | 2950 | int column = 0; 2951 | 2952 | void count() 2953 | { 2954 | int i; 2955 | 2956 | for (i = 0; yytext[i] != '\0'; i++) 2957 | if (yytext[i] == '\n') 2958 | column = 0; 2959 | else if (yytext[i] == '\t') 2960 | column += 8 - (column % 8); 2961 | else 2962 | column++; 2963 | 2964 | ECHO; 2965 | } 2966 | 2967 | static void usage(char * s) 2968 | { 2969 | fprintf(stderr, "Usage: %s [-m(manuel)] \n", s); 2970 | exit(1); 2971 | } 2972 | 2973 | int main(int argc, char **argv) 2974 | { 2975 | 2976 | 2977 | if(argc < 2) 2978 | usage(argv[0]); 2979 | list = create(); 2980 | int i = 1; 2981 | if(strlen(argv[1]) == 2 && argv[1][1] == 'm') 2982 | { 2983 | isAuto = 0; 2984 | i = 2; 2985 | printf("is not auto"); 2986 | } 2987 | for(; i < argc; i++) 2988 | { 2989 | char tmp[strlen(argv[i]) + 2]; 2990 | memcpy(tmp, argv[i], sizeof(char)*(strlen(argv[i]))); 2991 | tmp[strlen(argv[i])] = '_'; 2992 | tmp[strlen(argv[i]) + 1] = '\0'; 2993 | currentFile = fopen(tmp, "w"); 2994 | if(currentFile == NULL) 2995 | { 2996 | perror("fopen"); 2997 | return 1; 2998 | } 2999 | yyin = fopen(argv[i], "r"); 3000 | if(yyin == NULL) 3001 | { 3002 | perror("fopen"); 3003 | return 1; 3004 | } 3005 | fprintf(currentFile, "#include \"convert.h\"\n"); 3006 | yylex(); 3007 | fclose(currentFile); 3008 | fclose(yyin); 3009 | currentFile = NULL; 3010 | yyin = NULL; 3011 | } 3012 | saveToFile(list, "convert.h"); 3013 | delete(list); 3014 | return 0; 3015 | } 3016 | 3017 | --------------------------------------------------------------------------------