CVS: refdb/src refdbdref.c,1.40,1.41

Markus Hoenicka <[email protected]>
Newsgroups gmane.text.refdb.devel
Message-ID <[email protected]>
Update of /cvsroot/refdb/refdb/src
In directory sc8-pr-cvs1:/tmp/cvs-serv1864/src

Modified Files:
	refdbdref.c 
Log Message:
whichdb now returns number of notes; use content instead of note

Index: refdbdref.c
===================================================================
RCS file: /cvsroot/refdb/refdb/src/refdbdref.c,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -U2 -r1.40 -r1.41
--- refdbdref.c	19 Nov 2003 23:35:54 -0000	1.40
+++ refdbdref.c	21 Dec 2003 23:14:08 -0000	1.41
@@ -78,4 +78,6 @@
   unsigned long long numrefs;
   unsigned long long maxid;
+  unsigned long long numnotes;
+  unsigned long long maxnid;
   unsigned short fieldtype;
   int numbyte;
@@ -117,8 +119,30 @@
   numrefs = my_dbi_result_get_idval_idx(dbires, 1); /* 1-base index */
   maxid = my_dbi_result_get_idval_idx(dbires, 2);
-  /* The returned integers are quads (8byte) */
-  sprintf(return_msg, "Current database: %s\nNumber of references: "ULLSPEC"\nHighest reference ID: "ULLSPEC"\n", ptr_clrequest->current_db, (unsigned long long)numrefs, (unsigned long long)maxid);
   dbi_result_free(dbires);
 
+  dbires = dbi_conn_query(conn, "SELECT COUNT(*), MAX(note_id) FROM t_note");
+  if (!dbires) {
+    iwrite(ptr_clrequest->fd, "cannot get row count\n", 21);
+    dbi_conn_close(conn);
+    free(return_msg);
+    LOG_PRINT(LOG_WARNING, "Cannot get row count");
+    return 0;
+  }
+
+  if (!dbi_result_next_row(dbires)) {
+    iwrite(ptr_clrequest->fd, "whichdb failed\n", 15);
+    dbi_conn_close(conn);
+    LOG_PRINT(LOG_WARNING, "whichdb query error");
+    free(return_msg);
+    return 0;
+  }
+    
+  numnotes = my_dbi_result_get_idval_idx(dbires, 1); /* 1-base index */
+  maxnid = my_dbi_result_get_idval_idx(dbires, 2);
+  dbi_result_free(dbires);
+
+  /* The returned integers are quads (8byte) */
+  sprintf(return_msg, "Current database: %s\nNumber of references: "ULLSPEC"\nHighest reference ID: "ULLSPEC"\nNumber of notes: "ULLSPEC"\nHighest note ID: "ULLSPEC"\n", ptr_clrequest->current_db, (unsigned long long)numrefs, (unsigned long long)maxid, (unsigned long long)numnotes, (unsigned long long)maxnid);
+
   numbyte = iwrite(ptr_clrequest->fd, return_msg, strlen(return_msg));
   if (numbyte == -1) {
@@ -553,5 +577,5 @@
   const char scanfields[2][5][19] = {
     {"refdb_abstract", "refdb_title", "refdb_booktitle", "refdb_title_series", ""},
-    {"note_title", "note_note", ""}};
+    {"note_title", "note_content", ""}};
 
   dbi_conn conn;
@@ -591,5 +615,5 @@
     }
     else {
-      strcpy(sql_command, "SELECT note_id,note_title,note_note FROM t_note WHERE note_id IN (");
+      strcpy(sql_command, "SELECT note_id,note_title,note_content FROM t_note WHERE note_id IN (");
     }
 
@@ -638,5 +662,5 @@
     }
     else {
-      strcpy(sql_command, "SELECT note_id,note_title,note_note FROM t_note WHERE note_id>0");
+      strcpy(sql_command, "SELECT note_id,note_title,note_content FROM t_note WHERE note_id>0");
     }
   }    



-------------------------------------------------------
This SF.net email is sponsored by: IBM Linux Tutorials.
Become an expert in LINUX or just sharpen your skills.  Sign up for IBM's
Free Linux Tutorials.  Learn everything from the bash shell to sys admin.
Click now! http://ads.osdn.com/?ad_id=1278&alloc_id=3371&op=click
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.