[cairo-commit] roadster/src db.c,1.36,1.37 main.c,1.35,1.36

Jeff Garrett commit at pdx.freedesktop.org
Fri Sep 7 23:23:47 PDT 2007


Committed by: jgarrett

Update of /cvs/cairo/roadster/src
In directory kemper:/tmp/cvs-serv10228/src

Modified Files:
	db.c main.c 
Log Message:
	* src/main.c: Add configuration for external MySQL server
	* configure.ac:
	* src/db.c: Remove MySQL embedded server


Index: db.c
===================================================================
RCS file: /cvs/cairo/roadster/src/db.c,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -d -r1.36 -r1.37
--- db.c	20 Oct 2005 06:56:22 -0000	1.36
+++ db.c	8 Sep 2007 06:23:45 -0000	1.37
@@ -22,12 +22,7 @@
  */
 
 #include <mysql.h>
-
-#define HAVE_MYSQL_EMBED
-
-#ifdef HAVE_MYSQL_EMBED
-# include <mysql_embed.h>
-#endif
+#include <glib.h>
 
 #include <stdlib.h>
 #include <gtk/gtk.h>
@@ -68,19 +63,9 @@
 // call once on program start-up
 void db_init()
 {
-#ifdef HAVE_MYSQL_EMBED
-	gchar* pszDataDir = g_strdup_printf("%s/.roadster/data", g_get_home_dir());
-	gchar* pszSetDataDirCommand = g_strdup_printf("--datadir=%s", pszDataDir);
 	gchar* pszSetQueryCacheSize = g_strdup_printf("--query-cache-size=%dMB", 40);
 	gchar* pszKeyBufferSize	= g_strdup_printf("--key-buffer-size=%dMB", 32);
 
-#ifdef USE_GNOME_VFS
-	// Create directory if it doesn't exist
-	if(GNOME_VFS_OK != gnome_vfs_make_directory(pszDataDir, 0700)) {
-		// no big deal, probably already exists (should we check?)
-	}
-#endif
-
 	gchar* apszServerOptions[] = {
 		"",	// program name -- unused
 
@@ -97,29 +82,20 @@
 		"--ft-stopword-file=''",	// non-existant stopword file. we don't want ANY stopwords (words that are ignored)
 
 		// Misc options
-		pszKeyBufferSize,
-		pszSetDataDirCommand
+		pszKeyBufferSize
 	};
 
-	// Initialize the embedded server
-	// NOTE: if not linked with libmysqld, this call will do nothing (but will succeed)
  	if(mysql_server_init(G_N_ELEMENTS(apszServerOptions), apszServerOptions, NULL) != 0) {
 		return;
 	}
-	g_free(pszDataDir);
-	g_free(pszSetDataDirCommand);
 	g_free(pszSetQueryCacheSize);
 	g_free(pszKeyBufferSize);
-#endif
 }
 
 // call once on program shut-down
 void db_deinit()
 {
-#ifdef HAVE_MYSQL_EMBED
-	// Close embedded server if present
 	mysql_server_end();
-#endif
 }
 
 gboolean db_query(const gchar* pszSQL, db_resultset_t** ppResultSet)

Index: main.c
===================================================================
RCS file: /cvs/cairo/roadster/src/main.c,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -d -r1.35 -r1.36
--- main.c	26 Oct 2005 05:04:53 -0000	1.35
+++ main.c	8 Sep 2007 06:23:45 -0000	1.36
@@ -132,6 +132,12 @@
 
 gboolean main_init(void)
 {
+	char *db_host = NULL, *db_user = NULL;
+	char *db_passwd = NULL, *db_dbname = NULL;
+	GKeyFile *keyfile;
+
+	char *conffile = g_strdup_printf("%s/.roadster/roadster.conf", g_get_home_dir());
+
 #ifdef USE_GNOME_VFS
 	if(!gnome_vfs_init()) {	
 		g_warning("gnome_vfs_init failed\n");
@@ -159,8 +165,16 @@
 	g_print("initializing db\n");
 	db_init();
 
+	keyfile = g_key_file_new();
+	if (g_key_file_load_from_file(keyfile, conffile, G_KEY_FILE_NONE, NULL))
+	{
+		db_host   = g_key_file_get_string(keyfile, "mysql", "host", NULL);
+		db_user   = g_key_file_get_string(keyfile, "mysql", "user", NULL);
+		db_passwd = g_key_file_get_string(keyfile, "mysql", "passwordd", NULL);
+		db_dbname = g_key_file_get_string(keyfile, "mysql", "database", NULL);
+	}
 	g_print("connecting to db\n");
-	db_connect(NULL, NULL, NULL, "");	// Connect to internal DB
+	db_connect(db_host, db_user, db_passwd, db_dbname);
 
 	g_print("creating database tables\n");
 	db_create_tables();



More information about the cairo-commit mailing list