From: Richard Jones <rich@annexia.org>
To: caml-list@inria.fr
Subject: [Caml-list] Reading into a string from C code
Date: Sat, 21 Feb 2004 16:28:32 +0000 [thread overview]
Message-ID: <20040221162832.GA20238@redhat.com> (raw)
This is my wrapper around the Apache ap_get_client_block call:
CAMLprim value
mod_caml_request_get_client_block (value rv, value str)
{
CAMLparam2 (rv, str);
request_rec *r = Request_rec_val (rv);
int n = string_length (str);
char *buffer = String_val (str);
int i = ap_get_client_block (r, buffer, n);
if (i == -1) raise_http_error (HTTP_INTERNAL_SERVER_ERROR);
CAMLreturn (Val_int (i));
}
ap_get_client_block is prototyped as:
long ap_get_client_block (request_rec *, char *buffer, int buffer_size);
Its job is to read up to buffer_size bytes into buffer and return the
number of bytes actually written into this buffer.
Is my wrapper correct? Can I call String_val (str) and then write
into that buffer in order to write into the string? I suspect not,
actually, since although it works most of the time, I seem to be
getting some data corruption errors occasionally.
Rich.
--
Richard Jones. http://www.annexia.org/ http://www.j-london.com/
Merjis Ltd. http://www.merjis.com/ - improving website return on investment
C2LIB is a library of basic Perl/STL-like types for C. Vectors, hashes,
trees, string funcs, pool allocator: http://www.annexia.org/freeware/c2lib/
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
reply other threads:[~2004-02-21 16:28 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20040221162832.GA20238@redhat.com \
--to=rich@annexia.org \
--cc=caml-list@inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox