C API for simultaneous access to several remote ACNUC databases

The API works by opening a remote ACNUC db, through calls to raa_acnucopen_alt, raa_acnucopen, or to raa_open_socket followed by raa_opendb. Then an opaque pointer to the just opened db is obtained by a call to raa_get_current_db. At any time, the API interface is directed to any open db by a call to raa_set_current_db(opaque_pointer).

A call to raa_get_list_open_dbs allows access to the chained list of opaque pointers to all currently opened dbs.

Programming example:
Link this with raa_acnuc.c, parser.c & misc_acnuc.c included in the source code.

#include "raa_acnuc.h"

int main(int argc, char **argv)
{
int err, rank, count, *tabranks, total, i;
char *p, *lname; 
void *db1, *db2, *db3;
struct chain_void *list; /* chain_void = {void *data; chain_void *next}  */

err = raa_acnucopen_alt("pbil.univ-lyon1.fr", 5558, "embl");
if(err != 0) exit(1);
db1 = raa_get_current_db();

err = raa_acnucopen_alt("pbil.univ-lyon1.fr", 5558, "genbank");
if(err != 0) exit(1);
db2 = raa_get_current_db();

err = raa_acnucopen_alt("pbil.univ-lyon1.fr", 5558, "swissprot");
if(err != 0) exit(1);
db3 = raa_get_current_db();

/* working with individually specified dbs: db1, db3 */
printf("   db name    # of E. coli seqs\n");
raa_set_current_db(db1);
raa_prep_acnuc_requete();
raa_proc_requete("sp=escherichia coli", NULL, "coliseqs", &rank, &count, NULL, NULL);
printf("%10s   %d\n", raa_get_open_dbname(db1), count);

raa_set_current_db(db3);
raa_prep_acnuc_requete();
raa_proc_requete("sp=escherichia coli", NULL, "coliseqs", &rank, &count, NULL, NULL);
printf("%10s   %d\n", raa_get_open_dbname(db3), count);
raa_proc_requete("sp=encephalitozoon", NULL, "cuniculi", &rank, &count, NULL, NULL);


/* working with all currently opened dbs */
printf("\n\nList of defined seq lists\ndb name    list name   seqs in list\n");
list = raa_get_list_open_dbs();
while(list != NULL) {
	raa_set_current_db(list->data);
	p = raa_get_open_dbname(list->data);
	total = raa_alllistranks(&tabranks);
	if(total == 0) printf("%10s  \n", p);
	for(i = 0; i < total; i++) {
		lname = raa_getliststate(tabranks[i], NULL, NULL, &count);
		printf("%10s  %s   %d\n", p, lname, count);
		}
	if(total > 0) free(tabranks);
	list = list->next;
	}

/* closing all opened dbs */
while ( (list = raa_get_list_open_dbs() ) != NULL ) {
		raa_set_current_db(list->data);
		raa_acnucclose();
		}
return 0;
}