[Refdb-cvs] CVS: refdb/src dbfncs.h,1.6,1.7 dbfncs.c,1.15,1.16
Status: Beta
Brought to you by:
mhoenicka
From: Markus H. <mho...@us...> - 2004-05-17 23:23:43
|
Update of /cvsroot/refdb/refdb/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30769 Modified Files: dbfncs.h dbfncs.c Log Message: added function my_dbi_conn_get_dbtype() Index: dbfncs.h =================================================================== RCS file: /cvsroot/refdb/refdb/src/dbfncs.h,v retrieving revision 1.6 retrieving revision 1.7 diff -u -U2 -r1.6 -r1.7 --- dbfncs.h 25 Oct 2003 23:50:51 -0000 1.6 +++ dbfncs.h 17 May 2004 23:23:34 -0000 1.7 @@ -58,4 +58,5 @@ unsigned long long my_dbi_result_get_idval_idx(dbi_result dbires, unsigned long long idx); int my_dbi_conn_get_versioninfo(dbi_conn conn, struct VERSIONINFO* ptr_ver); +int my_dbi_conn_get_dbtype(dbi_conn conn); Index: dbfncs.c =================================================================== RCS file: /cvsroot/refdb/refdb/src/dbfncs.c,v retrieving revision 1.15 retrieving revision 1.16 diff -u -U2 -r1.15 -r1.16 --- dbfncs.c 29 Jan 2004 01:42:11 -0000 1.15 +++ dbfncs.c 17 May 2004 23:23:34 -0000 1.16 @@ -1745,4 +1745,41 @@ /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + my_dbi_conn_get_dbtype(): retrieves the type of a database + + int my_dbi_conn_get_dbtype returns 0 on error + RISX if risx database + MODS if mods database + + dbi_conn conn connection to a database engine + + ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ +int my_dbi_conn_get_dbtype(dbi_conn conn) { + char sql_command[] = "SELECT meta_type FROM t_meta"; + const char* type = NULL; + int n_retval = 0; + dbi_result dbires; + + dbires = dbi_conn_query(conn, sql_command); + LOG_PRINT(LOG_DEBUG, sql_command); + if (dbires) { + if (dbi_result_next_row(dbires)) { + type = dbi_result_get_string_idx(dbires, 1); /* 1-base index */ + } + dbi_result_free(dbires); + } + + if (type && *type) { + if (!strcmp(type, "risx")) { + n_retval = RISX; + } + else if (!strcmp(type, "mods")) { + n_retval = MODS; + } + } + + return n_retval; +} + +/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ set_cap_versioninfo(): sets version-specific info in dbcaps structure |