caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Reading into a string from C code
@ 2004-02-21 16:28 Richard Jones
  0 siblings, 0 replies; only message in thread
From: Richard Jones @ 2004-02-21 16:28 UTC (permalink / raw)
  To: caml-list

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


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2004-02-21 16:28 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-02-21 16:28 [Caml-list] Reading into a string from C code Richard Jones

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).