From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,6492e5e798269d9 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-07-07 07:14:24 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!fu-berlin.de!uni-berlin.de!61.11.230.176!not-for-mail From: Andreas Almroth Newsgroups: comp.lang.ada Subject: Re: sqlite binding Date: Mon, 07 Jul 2003 15:16:39 +0100 Message-ID: References: NNTP-Posting-Host: 61.11.230.176 Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Trace: fu-berlin.de 1057587262 3539817 61.11.230.176 (16 [198985]) User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.4) Gecko/20030624 X-Accept-Language: en-us, en In-Reply-To: X-Enigmail-Version: 0.76.1.0 X-Enigmail-Supports: pgp-inline, pgp-mime Xref: archiver1.google.com comp.lang.ada:40104 Date: 2003-07-07T15:16:39+01:00 List-Id: Ching Bon Lam wrote: > hello everyone, > > I've been trying to make some sort of sqlite binding. SQLite itself is at > http://www.sqlite.org/ . For now i just want to import the core api > consisting of three functions (taken from sqlite.h): > > -- Code ----------------------------------------------------------------- > > sqlite *sqlite_open(const char *filename, int mode, char **errmsg); > function Sqlite_Open(Filename : in Interfaces.C.Strings.Chars_Ptr; mode : Interfaces.C.Int; Errmsg : access interfaces.C.Strings.Chars_Ptr) return Sqlite_T; pragma Import(C,Sqlite_Open,"sqlite_open); > void sqlite_close(sqlite *); > > int sqlite_exec( > sqlite*, /* An open database */ > const char *sql, /* SQL to be executed */ > sqlite_callback, /* Callback function */ > void *, /* 1st argument to callback function */ > char **errmsg /* Error msg written here */ > ); > > ------------------------------------------------------------------------- > > with: > > -- Code ----------------------------------------------------------------- > > typedef struct sqlite sqlite; /* opaque struct */ > typedef int (*sqlite_callback)(void*,int,char**, char**); > > ------------------------------------------------------------------------- > > What I did till now is: > > -- Code ----------------------------------------------------------------- > > -- typedef struct sqlite sqlite; /* opaque struct */ > subtype sqlite is Interfaces.C.Extensions.opaque_structure_def; > Without knowing the details, but I would probably use System.Address as pointer, so; type Sqlite_T is System.Address; This takes that you will never access anything within the record, and only reference it as pointer. As for the callback, you define a type for the callback pointer; type Sqlite_Callback_T is access function(P : System.Address; I : Interfaces.C.Int; C1 : System.Address; C2 : System.Address) return Interfaces.C.Int; OK,ok, using System.Address is a bit of a hack, but one should probably look into using access interfaces.c.strings.chars_ptr instead. Could make it easier instead of using System.Address_To_Access_Conversions feature... > ------------------------------------------------------------------------- > > i don't know how to do the rest with the tons of pointers as arguments.. > if someone would give me some pointers/guidance/hints, i would be really > grateful. > > greetings, > CBL Cheers, Andreas