%{ #define YY_INPUT(buf,result,max_size) \ { int digit ; \ int c = getc( yyin ) ; \ result = c == EOF ? 0 : 1 ; \ if( c == '%' ) { \ c = getc( yyin ) ; \ digit = c >= 'A' ? (( c & 0xdf ) - 'A' ) + 10 : c - '0' ; \ digit *= 16 ; \ c = getc( yyin ) ; \ digit += c >= 'A' ? (( c & 0xdf ) - 'A' ) + 10 : c - '0' ; \ buf[0] = (char) digit ; \ } \ else if( c == '+' ) \ buf[0] = ' ' ; \ else \ buf[0] = (char) c ; \ } %} WS [ \t] %% "answer4-2=A"\&? { send_file( "ans4-2.wronga" ) ; return( 1 ) ; } "answer4-2=B"\&? { send_file( "ans4-2.wrongb" ) ; return( 1 ) ; } "answer4-2=C"\&? { send_file( "ans4-2.wrongc" ) ; return( 1 ) ; } "answer4-2=D"\&? { send_file( "ans4-2.right" ) ; return( 1 ) ; } %% #include main() { if( !yylex()) send_file( "ans4-2.none" ) ; } send_file( s ) char *s ; { FILE *fp ; char buf[81] ; printf( "Content-type: text/html\n\n" ) ; fp = fopen( s, "r" ) ; if( fp ) { while( fgets( buf, 80, fp )) { printf( "%s", buf ) ; } fclose( fp ) ; } }