Skip to content

jpmens/cdbc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 

Repository files navigation

CDBC: CouchDB C API

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:

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.

Function reference

CDBC *cdbc_new(char *url);

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
}

void cdbc_free(CDBC *);

int cdbc_request(CDBC *, char *);

char *cdbc_body(CDBC *, size_t *length);

size_t cdbc_body_length(CDBC *cd);

int cdbc_body_tofile(CDBC *, FILE *);

int cdbc_usedb(CDBC *, char *);

int cdbc_get(CDBC *cd, char *docid);

int cdbc_create(CDBC *cd, char *docid, char *json);

int cdbc_create_js(CDBC *cd, char *docid, json_t *js);

json_t *cdbc_get_js(CDBC *cd, char *docid);

char *cdbc_get_js_string(CDBC *cd, char *field);

int cdbc_get_js_integer(CDBC *cd, char *field);

int cdbc_view_walk(CDBC *cd, int (*func)(CDBC *, json_t *rowobj), char *ddoc, char *view, char *arg, ...);

char *cdbc_lasturl(CDBC *cd);

About

C library for the CouchDB API

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages