Project

General

Profile

LIBWDA

Web Data Access C API Library

Web Data Access C API Library

This document describes C API for Web Data Access services


/*
 * Abstract data types
 */
typedef void *Dataset;
typedef void *Tuple;

/*
 * Low level generic function which returns the whole buffer received
 * The buffer returned by this function needs to be freed with free(void *ptr) function call
 */
void *getHTTP(const char *url, const char *headers[], size_t nheaders, size_t *length, int *status);

/*
 * As the function above but with additional timeout parameter
 */
void *getHTTPWithTimeout(const char *url, const char *headers[], size_t nheaders, size_t *length, int timeout, int *status);

/*
 * Low level generic function which posts the whole buffer of given length
 */
void postHTTP(const char *url, const char *headers[], size_t nheaders, const char *data, size_t length, int *status);

void postHTTPsigned(const char *url, const char* password, const char *headers[], size_t nheaders, const char *data, size_t length, int *status);

void postHTTPsigned_retry(const char *url, const char* password, const char *headers[], size_t nheaders, 
                          const char *data, size_t length, int timeout, int *status);

/*
 * Low level generic functions which return the whole dataset
 */
Dataset getData(const char *url, const char *uagent, int *error);

Dataset getDataWithTimeout(const char *url, const char *uagent, int timeout, int *error);

Dataset muxGetDataWithTimeout(const char *url, const char *urls[], size_t nurls, const char *uagent, int timeout, int *error);

/*
 * Functions to work with the tuples in the dataset
 */
int getNtuples(Dataset dataset);            /* Returns number of tuples in the dataset  */

int getIndex(Dataset dataset);              /* Returns current index value in dataset   */

Tuple getTuple(Dataset dataset, int i);     /* Returns NULL if out of range             */

Tuple getFirstTuple(Dataset dataset);       /* Returns the first tuple in the dataset   */

Tuple getNextTuple(Dataset dataset);        /* Returns the next tuple if available      */

/*
 * Functions to work with the fields in the tuple
 */
int getNfields(Tuple tuple);                                    /* Returns the number of fields in tuple                */

long getLongValue(Tuple tuple, int position, int *error);       /* Returns integer from specified position in a tuple   */

double getDoubleValue(Tuple tuple, int position, int *error);   /* Returns float from specified position in a tuple     */

/* 
 * Copies a string from specified position in a tuple, returns string length        
 */
int getStringValue(Tuple tuple, int position, char *buffer, int buffer_size, int *error);   

/* 
 * Copies a double array from specified position in a tuple, returns actual array length  
 */
int getDoubleArray(Tuple tuple, int position, double *buffer, int buffer_size, int *error); 

/* 
 * Copies an integer array from specified position in a tuple, returns actual array length
 */
int getLongArray(Tuple tuple, int position, long *buffer, int buffer_size, int *error);

/*
 * Housekeeping functions
 */
int releaseDataset(Dataset dataset);        /* Releases memory allocated for dataset    */

int releaseTuple(Tuple tuple);              /* Releases memory allocated for tuple      */

long getHTTPstatus(Dataset dataset);        /* Returns HTTP status code                 */

char *getHTTPmessage(Dataset dataset);      /* Returns HTTP status message              */

Complete test code example

IFBeam Data Access API is written using LIBWDA. You can see sample code for IF Beam Database client here.

Where to get it from?

The library is available in UPD:

DATABASE=/ftp/upsdb

Product=libwda  Version=v2_23_0 Flavor=Linux64bit+2.6-2.12
Qualifiers="" Chain=""