<br>Hi Thomas, <br>it worked nicely, <br><br>thank you very much!<br><div class="gmail_quote">2009/7/28 thomas fossati <span dir="ltr"><<a href="mailto:tho@koanlogic.com">tho@koanlogic.com</a>></span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div style=""><div>Hi Moises,</div><div><div class="im"><div><br></div><div>On Jul 28, 2009, at 7:54 PM, moises acuna wrote:</div></div><blockquote type="cite"><div class="im">Hello all,<br>my problem is this, my embedded web application generates binary files and the user is capable to download them. I'm doing it like this:<br>
</div>[SNIP]<div class="im"><br>Expecting for comments and thanks in advanced. <br></div></blockquote><div><font color="#144fae"><br></font></div></div><div>the following POC kl1 hopefully does what you need:</div><div><br>
</div><div><div><%!</div><div> #include <u/libu.h></div><div><br></div><div> #define TEST_FN "/tmp/test"</div><div>%><%</div><div> size_t rb;</div><div> char buf[1024];</div><div> FILE *target = NULL;</div>
<div><br></div><div> target = fopen(TEST_FN, "r");</div><div> warn_err_sifm (target == NULL, "%s", TEST_FN);</div><div><br></div><div> while ((rb = fread(buf, 1, sizeof buf, target)) != 0)</div>
<div> (void) io_write(out, buf, rb);</div><div><br></div><div> warn_if (!feof(target) && ferror(target));</div><div><br></div><div> // fall through</div><div>err:</div><div> if (target)</div><div> fclose(target);</div>
<div> return;</div><div>%></div><div><br></div><div>ciao, t.</div></div><br><div><div><div>PS: the '0xA 0xD' stuff gets in because you probably don't stick '%><%' together: the kl1 parser interprets the new line literally which is clearly not what you want when pushing raw files.</div>
<div><br></div><div>PS2: try to avoid "read" as a variable name as it's already taken by the syscall.</div></div></div></div><br>_______________________________________________<br>
Klone-users mailing list<br>
<a href="mailto:Klone-users@koanlogic.com">Klone-users@koanlogic.com</a><br>
<a href="http://koanlogic.com/cgi-bin/mailman/listinfo/klone-users" target="_blank">http://koanlogic.com/cgi-bin/mailman/listinfo/klone-users</a><br>
<br></blockquote></div><br><br clear="all"><br>-- <br>Moisés AAC<br>