From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id RAA06455; Sat, 21 Feb 2004 17:28:34 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id RAA06722 for ; Sat, 21 Feb 2004 17:28:33 +0100 (MET) Received: from aomori.annexia.org (annexia.force9.co.uk [212.56.101.183]) by concorde.inria.fr (8.12.10/8.12.10) with ESMTP id i1LGSWae018558 for ; Sat, 21 Feb 2004 17:28:33 +0100 Received: from rich by aomori.annexia.org with local (Exim 3.36 #1 (Debian)) id 1AuZzU-0005N6-00 for ; Sat, 21 Feb 2004 16:28:32 +0000 Date: Sat, 21 Feb 2004 16:28:32 +0000 To: caml-list@inria.fr Subject: [Caml-list] Reading into a string from C code Message-ID: <20040221162832.GA20238@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.4i From: Richard Jones X-Miltered: at concorde by Joe's j-chkmail ("http://j-chkmail.ensmp.fr")! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; camlprim:01 camlparam:01 val:01 char:01 buffer:01 val:01 buffer:01 camlreturn:01 char:01 vectors:01 hashes:01 funcs:01 allocator:01 ltd:98 caml:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk 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