TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Chunked-transfer decoding from stdin yy045

1 pointsby textmodeover 2 years ago

1 comment

textmodeover 2 years ago
<p><pre><code> &#x2F;* chunked transfer decoding *&#x2F; #define echo do{if(fwrite(yytext,(size_t)yyleng,1,yyout)){}}while(0) #define jmp (yy_start) = 1 + 2 * int fileno (FILE *); int ischunked,chunksize,count; xa &quot;\15&quot;|&quot;\12&quot; xb &quot;\15\12&quot; xc &quot;HTTP&#x2F;0.9&quot;|&quot;HTTP&#x2F;1.0&quot;|&quot;HTTP&#x2F;1.1&quot; xd [Cc][Hh][Uu][Nn][Kk][Ee][Dd] xe [0-9a-fA-F]+\r\n xf [0-9a-fA-F]*\r\n %option noyywrap nounput noinput %s xb xc xd xe xf %% ^{xc} echo;ischunked=0;jmp xc; &lt;xc&gt;^transfer-encoding: echo;jmp xb; &lt;xb&gt;\r\n\r\n echo;jmp xe; &lt;xb&gt;{xd} echo;ischunked=1; &lt;xe&gt;{xf}|{xe} { count=0; if(ischunked==1) {chunksize=strtol(yytext,NULL,16); jmp xd;}; }; &lt;xd&gt;{xb} jmp xf; &lt;xd&gt;. { count++; if(count==chunksize)jmp xe; echo; }; &lt;xf&gt;^[A-Fa-f0-9]+{xa} &lt;xf&gt;{xa}+[A-Fa-f0-9]+{xa} &lt;xf&gt;{xb}[A-Fa-f0-9]+{xb} %% int main(){ yylex();exit(0);}</code></pre>