Sean MacLennan <sean.maclennan(a)pika.ca> writes:
I am currently working on a very simple interface to PostgreSQL
using the libpq library. I have hacked up some code as a module to
give me the C to lisp interface (included in the first attachment).
A PostgreSQL interface already exists. Have you overlooked it, or do
you intentionally build your own (for whatever reasons)?
#if 0
#define make_conn(conn) make_int((long)conn)
#define make_result(res) make_int((long)res)
#define PGCONN(conn) ((PGconn*)XINT(conn))
#define PGRESULT(res) ((PGresult*)XINT(res))
#else
#define make_conn(conn) ((Lisp_Object)(((long)conn) | Lisp_Type_Int_Bit))
#define make_result(res) ((Lisp_Object)(((long)res) | Lisp_Type_Int_Bit))
#define PGCONN(conn) ((PGconn*)((long)conn & ~Lisp_Type_Int_Bit))
#define PGRESULT(res) ((PGresult*)((long)res & ~Lisp_Type_Int_Bit))
#endif
No, this is not the way to do it. Take a look at
DEFINE_LRECORD_IMPLEMENTATION.
The file ldap.c should be educational because it is fairly simple and
it also wraps some C structures into Lisp objects.