git » nmdb » commit 12ad5b5

nmdb: Log the filename and the backend used after opening the database

author Alberto Bertogli
2010-05-03 06:44:41 UTC
committer Alberto Bertogli
2010-05-03 07:19:02 UTC
parent 7a9df926c59558f2b17b46cd163d5ec81040ba58

nmdb: Log the filename and the backend used after opening the database

Signed-off-by: Alberto Bertogli <albertito@blitiri.com.ar>

nmdb/be.c +16 -0
nmdb/be.h +3 -0
nmdb/main.c +2 -0

diff --git a/nmdb/be.c b/nmdb/be.c
index 01f3d9a..d1349e4 100644
--- a/nmdb/be.c
+++ b/nmdb/be.c
@@ -43,3 +43,19 @@ enum backend_type be_type_from_str(const char *name)
 	return BE_UNKNOWN;
 }
 
+
+const char *be_str_from_type(enum backend_type type)
+{
+	if (type == BE_QDBM)
+		return "qdbm";
+	if (type == BE_BDB)
+		return "bdb";
+	if (type == BE_TC)
+		return "tc";
+	if (type == BE_TDB)
+		return "tdb";
+	if (type == BE_NULL)
+		return "null";
+	return "unknown";
+}
+
diff --git a/nmdb/be.h b/nmdb/be.h
index 8c40fa5..37a8210 100644
--- a/nmdb/be.h
+++ b/nmdb/be.h
@@ -40,6 +40,9 @@ struct db_conn *db_open(enum backend_type type, const char *name, int flags);
 /* Returns the backend type for the given name. */
 enum backend_type be_type_from_str(const char *name);
 
+/* Returns the backend name for the given type. */
+const char *be_str_from_type(enum backend_type type);
+
 /* String containing a list of all supported backends */
 #if BE_ENABLE_QDBM
   #define _QDBM_SUPP "qdbm "
diff --git a/nmdb/main.c b/nmdb/main.c
index 2790112..abb8d52 100644
--- a/nmdb/main.c
+++ b/nmdb/main.c
@@ -213,6 +213,8 @@ int main(int argc, char **argv)
 		errlog("Error opening DB");
 		return 1;
 	}
+	wlog("Opened database \"%s\" with %s backend\n", settings.dbname,
+		be_str_from_type(settings.backend));
 
 	if (!settings.foreground) {
 		pid = fork();