[Klone-users] Download files
moises acuna
moises.acuna at gmail.com
Wed Jul 29 13:46:00 EDT 2009
Hi Thomas,
it worked nicely,
thank you very much!
2009/7/28 thomas fossati <tho at koanlogic.com>
> Hi Moises,
>
> On Jul 28, 2009, at 7:54 PM, moises acuna wrote:
>
> Hello all,
> 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:
> [SNIP]
> Expecting for comments and thanks in advanced.
>
>
> the following POC kl1 hopefully does what you need:
>
> <%!
> #include <u/libu.h>
>
> #define TEST_FN "/tmp/test"
> %><%
> size_t rb;
> char buf[1024];
> FILE *target = NULL;
>
> target = fopen(TEST_FN, "r");
> warn_err_sifm (target == NULL, "%s", TEST_FN);
>
> while ((rb = fread(buf, 1, sizeof buf, target)) != 0)
> (void) io_write(out, buf, rb);
>
> warn_if (!feof(target) && ferror(target));
>
> // fall through
> err:
> if (target)
> fclose(target);
> return;
> %>
>
> ciao, t.
>
> 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.
>
> PS2: try to avoid "read" as a variable name as it's already taken by the
> syscall.
>
> _______________________________________________
> Klone-users mailing list
> Klone-users at koanlogic.com
> http://koanlogic.com/cgi-bin/mailman/listinfo/klone-users
>
>
--
Moisés AAC
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://koanlogic.com/pipermail/klone-users/attachments/20090729/40d78b29/attachment.htm
More information about the klone-users
mailing list