Hacker News new | past | comments | ask | show | jobs | submit login
Gzip and Zip File Extraction from stdin
2 points by textmode on Jan 4, 2023 | hide | past | favorite

   /* remove HTTP headers from multiple gzip or single zip from stdin */

    int fileno(FILE *); 
    #define jmp (yy_start) = 1 + 2 *
    #define echo do{if(fwrite(yytext,(size_t)yyleng,1,yyout)){}}while(0)

   xa "\x1f\x8b"    
   /* GZIP magic number */
   xb "\x50\x4B\x03\x04"
   /* ZIP magic number */

   %s xa
   %option noyywrap noinput nounput
   %%
   {xa}|{xb} echo;jmp xa;
   <xa>"HTTP" jmp 0;
   <xa>.|\n echo;
   \n|.
   %%
   int main(){ yylex();exit(0);}



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: