From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: weis Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id SAA18706 for caml-redistribution@pauillac.inria.fr; Wed, 23 Feb 2000 18:55:23 +0100 (MET) Resent-Message-Id: <200002231755.SAA18706@pauillac.inria.fr> Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id SAA17027 for ; Wed, 23 Feb 2000 18:54:29 +0100 (MET) Received: from davidb.org (adsl-216-103-8-60.dsl.sndg02.pacbell.net [216.103.8.60]) by nez-perce.inria.fr (8.8.7/8.8.7) with SMTP id SAA24675 for ; Wed, 23 Feb 2000 18:54:27 +0100 (MET) Received: (qmail 20650 invoked by uid 403); 23 Feb 2000 17:54:25 -0000 Date: Wed, 23 Feb 2000 09:54:25 -0800 From: David Brown To: caml-list@inria.fr Subject: CamlIDL and string options. Message-ID: <20000223095425.A20631@davidb.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii User-Agent: Mutt/1.0i Resent-From: weis@pauillac.inria.fr Resent-Date: Wed, 23 Feb 2000 18:55:23 +0100 Resent-To: caml-redistribution@pauillac.inria.fr I'm trying to write a camlidl interface for a function that returns a char *. I want the ML result to be a string option. If the returned pointer is null, then return None, otherwise return the string it points to in Some. I can make it work, but only by writing my own c2ml routine: value field_to_ml (one_field *_c2, camlidl_ctx _ctx) { value _v1; value _v3; if ((*_c2) == NULL) { _v1 = Val_int(0); } else { _v3 = copy_string (*_c2); Begin_root(_v3) _v1 = camlidl_alloc_small(1, 0); Field(_v1, 0) = _v3; End_roots(); } return _v1; } Ideally, I would like to be able to use another field to get the length, but that function needs another argument that the interface function gets as an argument. -------------------------------------------------- In actuality, the function is more complicated than even this. It actually returns a char**. There is a function available that returns the number of char*'s in it. There is another function that returns the length of each char* (provided they aren't NULL). The other possibility is that someone else has already written an interface of MySQL, and I'm duplicating their effort. Dave Brown