[Refdb-cvs] CVS: refdb/src refdbda.c,1.31,1.32
Status: Beta
Brought to you by:
mhoenicka
|
From: Markus H. <mho...@us...> - 2003-12-26 01:02:09
|
Update of /cvsroot/refdb/refdb/src
In directory sc8-pr-cvs1:/tmp/cvs-serv29282
Modified Files:
refdbda.c
Log Message:
listdb() now returns only RefDB reference databases; new function is_reference_database()
Index: refdbda.c
===================================================================
RCS file: /cvsroot/refdb/refdb/src/refdbda.c,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -U2 -r1.31 -r1.32
--- refdbda.c 24 Dec 2003 21:47:31 -0000 1.31
+++ refdbda.c 26 Dec 2003 01:02:05 -0000 1.32
@@ -72,4 +72,5 @@
/* forward declarations of local functions */
+static int is_reference_database(struct CLIENT_REQUEST* ptr_clrequest, const char* dbname);
static int daemon_started_by_init(void);
static int daemon_started_by_inetd(void);
@@ -583,14 +584,16 @@
dbname = dbi_result_get_string_idx(dbires, 1);
if (dbname) {
- if (ptr_clrequest->n_cgi) {
- iwrite(ptr_clrequest->fd, "<tr><td class=\"result\"><input type=\"radio\" name=\"selectdb\" value=\"", 66);
- }
- iwrite(ptr_clrequest->fd, dbname, strlen(dbname));
- if (ptr_clrequest->n_cgi) {
- iwrite(ptr_clrequest->fd, "\">", 2);
+ if (is_reference_database(ptr_clrequest, dbname)) {
+ if (ptr_clrequest->n_cgi) {
+ iwrite(ptr_clrequest->fd, "<tr><td class=\"result\"><input type=\"radio\" name=\"selectdb\" value=\"", 66);
+ }
iwrite(ptr_clrequest->fd, dbname, strlen(dbname));
- iwrite(ptr_clrequest->fd, "</td></tr>", 10);
+ if (ptr_clrequest->n_cgi) {
+ iwrite(ptr_clrequest->fd, "\">", 2);
+ iwrite(ptr_clrequest->fd, dbname, strlen(dbname));
+ iwrite(ptr_clrequest->fd, "</td></tr>", 10);
+ }
+ iwrite(ptr_clrequest->fd, "\n", sizeof(char));
}
- iwrite(ptr_clrequest->fd, "\n", sizeof(char));
}
}
@@ -606,4 +609,58 @@
iwrite(ptr_clrequest->fd, connerr.text, connerr.length);
}
+}
+
+/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ is_reference_database(): checks whether a database is a RefDB
+ reference database
+
+ int is_reference_database returns 1 if the database is a RefDB database,
+ 0 if not
+
+ struct CLIENT_REQUEST* ptr_clrequest ptr to structure with client info
+
+ const char* dbname ptr to a string containing the database name
+
+ ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
+static int is_reference_database(struct CLIENT_REQUEST* ptr_clrequest, const char* dbname) {
+ dbi_conn conn_ref;
+ dbi_result dbires;
+ char sql_command[128];
+ const char* app;
+ const char* type;
+ int close_conn_ref = 0;
+ int retval = 0;
+
+ if ((conn_ref = connect_to_db(ptr_clrequest, dbname)) == NULL) {
+ /* can't access */
+ return 0;
+ }
+
+ sprintf(sql_command, "SELECT meta_app,meta_type from t_meta");
+
+ LOG_PRINT(LOG_DEBUG, sql_command);
+ dbires = dbi_conn_query(conn_ref, sql_command);
+
+ if (!dbires) {
+ goto Finish;
+ }
+
+ if (!dbi_result_next_row(dbires)) {
+ goto Finish;
+ }
+
+ app = dbi_result_get_string(dbires, "meta_app");
+ type = dbi_result_get_string(dbires, "meta_type");
+
+ if (!strcmp(app, "refdb")) {
+ retval = 1;
+ }
+
+ Finish:
+ if (close_conn_ref) {
+ dbi_conn_close(conn_ref);
+ }
+
+ return retval;
}
|