annotate libtests/0026/prog1.c @ 399:a65b31660804 api-inversion

Invert audioDB::dump / audiodb_dump(). No real API/ABI breakages, modulo the disappearance of audiodb_dump_withdir() (which really should have been audiodb_dump() itself from the start). There were of course ABI breakages in the previous commits. The dodgy thing in this patch is the horribleness of audiodb_dump() itself; there must be a better way of writing it, or at least abstracting some of the body into individual functional pieces. The declaration block at the top tells its own story. We also need to alter the way that audioDB::status handles the adb; rather than having a local variable, use the C++ audioDB object instance field and only open the database if necessary -- then everything has a consistent view.
author mas01cr
date Thu, 27 Nov 2008 15:19:49 +0000
parents 94c18f128ce8
children e072aa1611f5 342822c2d49a
rev   line source
mas01ik@355 1 #include <stdio.h>
mas01ik@355 2 #include <stdlib.h>
mas01ik@355 3 #include <string.h>
mas01ik@355 4 #include <sysexits.h>
mas01ik@355 5 #include <fcntl.h>
mas01ik@355 6 #include <dirent.h>
mas01ik@355 7 #include <unistd.h>
mas01ik@355 8 #include <sys/stat.h>
mas01ik@355 9 /*
mas01ik@355 10 * * #define NDEBUG
mas01ik@355 11 * * */
mas01ik@355 12 #include <assert.h>
mas01ik@355 13
mas01ik@355 14 #include "../../audioDB_API.h"
mas01ik@355 15 #include "../test_utils_lib.h"
mas01ik@355 16
mas01ik@355 17
mas01ik@355 18 int main(int argc, char **argv){
mas01ik@355 19
mas01ik@355 20 int returnval=0;
mas01ik@355 21 adb_ptr mydbp={0};
mas01ik@355 22 // int ivals[10];
mas01ik@355 23 // double dvals[10];
mas01ik@355 24 // adbinsert myinsert={0};
mas01ik@355 25 // unsigned int myerr=0;
mas01ik@355 26 char * databasename="testdb";
mas01ik@355 27 // adbquery myadbquery={0};
mas01ik@355 28 // adbqueryresult myadbqueryresult={0};
mas01ik@355 29 // adbquery myadbquery2={0};
mas01ik@355 30 // adbqueryresult myadbqueryresult2={0};
mas01ik@355 31 int myerror=0;
mas01ik@355 32
mas01ik@355 33
mas01ik@355 34 /* remove old directory */
mas01ik@355 35 //if [ -f testdb ]; then rm -f testdb; fi
mas01ik@355 36 clean_remove_db(databasename);
mas01ik@355 37
mas01ik@355 38 /* create new db */
mas01ik@355 39 //${AUDIODB} -N -d testdb
mas01ik@355 40 mydbp=audiodb_create(databasename,0,0,0);
mas01ik@355 41
mas01ik@355 42 /* power flag on */
mas01ik@355 43 //${AUDIODB} -P -d testdb
mas01ik@355 44 //${AUDIODB} -d testdb -P
mas01ik@355 45 myerror=audiodb_power(mydbp);
mas01ik@355 46 if (myerror){
mas01ik@355 47 returnval=-1;
mas01ik@355 48 }
mas01ik@355 49
mas01ik@355 50 //# should fail (no db given)
mas01ik@355 51 //expect_clean_error_exit ${AUDIODB} -P
mas01ik@355 52 /* not relevent, API wouldn't compile */
mas01ik@355 53
mas01ik@355 54 return(returnval);
mas01ik@355 55 }
mas01ik@355 56