Warning: this is a work in progress, it is incomplete, and the API will change!
There are dozens of API implementations for CouchDB in all sorts of languages, but I've yet to find a decent C implementation, which is why I'm implementing one myself. I know of some attempts, but they haven't wow'ed me:
- Getting started with C on the CouchDB Wiki.
- Pillowtalk
The C_ouch_DB C library (which has nothing at all to do with ODBC -- I noticed joke only later), is a wrapper which uses Daniel Stenberg's libCurl for the HTTP transport, and Petri Lehtinen's Jansson, a C library for encoding, decoding and manipulating JSON data.
I chose Jansson over other JSON C implementations because I particulary liked its interface, and it worked out of the box for me.
cdbc_new
creates a new CDBC object and allocates memory for it. The specified url
is associated with this connection object and should include scheme, host and, optionally a port separated by a colon. A single trailing slash in the URI is allowed.
CDBC *cd;
cd = cdbc_new("http://example.org:5984");
if (cd == NULL) {
// ... error
}