Beautiful startup banners in vivid color
authorArt Cancro <ajc@citadel.org>
Mon, 17 Jul 2023 20:10:55 +0000 (11:10 -0900)
committerArt Cancro <ajc@citadel.org>
Mon, 17 Jul 2023 20:10:55 +0000 (11:10 -0900)
citadel/utils/ctdldump.c
citadel/utils/ctdlload.c

index fd7eead1f0e32323b57643b7d660e83ed7d0d750..7e84a0df7e20c22f99ebe91ec40ca1071536eab9 100644 (file)
@@ -67,10 +67,10 @@ DB_ENV *open_dbenv(char *dirname) {
        int dbversion_major, dbversion_minor, dbversion_patch;
 
        fprintf(stderr,
-               "db: open_dbenv() starting\n"
-               "db:    Linked zlib: %s\n"
-               "db: Compiled libdb: %s\n"
-               "db:   Linked libdb: %s\n",
+               "ctdldump: open_dbenv() starting\n"
+               "ctdldump:    Linked zlib: %s\n"
+               "ctdldump: Compiled libdb: %s\n"
+               "ctdldump:   Linked libdb: %s\n",
                zlibVersion(),
                DB_VERSION_STRING,
                db_version(&dbversion_major, &dbversion_minor, &dbversion_patch)
@@ -81,42 +81,42 @@ DB_ENV *open_dbenv(char *dirname) {
        int compiled_db_version = ( (DB_VERSION_MAJOR * 1000000) + (DB_VERSION_MINOR * 1000) + (DB_VERSION_PATCH) );
        int linked_db_version = ( (dbversion_major * 1000000) + (dbversion_minor * 1000) + (dbversion_patch) );
        if (compiled_db_version > linked_db_version) {
-               fprintf(stderr, "db: ctdldump is running with a version of libdb older than the one with which it was compiled.\n"
-                       "db: This is an invalid configuration.  ctdldump will now exit to prevent data loss.");
+               fprintf(stderr, "ctdldump: ctdldump is running with a version of libdb older than the one with which it was compiled.\n"
+                       "ctdldump: This is an invalid configuration.  ctdldump will now exit to prevent data loss.");
                exit(CTDLEXIT_DB);
        }
 
-       fprintf(stderr, "db: Setting up DB environment\n");
+       fprintf(stderr, "ctdldump: Setting up DB environment\n");
        ret = db_env_create(&dbenv, 0);
        if (ret) {
-               fprintf(stderr, "db: db_env_create: %s\n", db_strerror(ret));
-               fprintf(stderr, "db: exit code %d\n", ret);
+               fprintf(stderr, "ctdldump: db_env_create: %s\n", db_strerror(ret));
+               fprintf(stderr, "ctdldump: exit code %d\n", ret);
                exit(CTDLEXIT_DB);
        }
 
        // We want to specify the shared memory buffer pool cachesize, but everything else is the default.
        ret = dbenv->set_cachesize(dbenv, 0, 64 * 1024, 0);
        if (ret) {
-               fprintf(stderr, "db: set_cachesize: %s\n", db_strerror(ret));
+               fprintf(stderr, "ctdldump: set_cachesize: %s\n", db_strerror(ret));
                dbenv->close(dbenv, 0);
-               fprintf(stderr, "db: exit code %d\n", ret);
+               fprintf(stderr, "ctdldump: exit code %d\n", ret);
                exit(CTDLEXIT_DB);
        }
 
        if ((ret = dbenv->set_lk_detect(dbenv, DB_LOCK_DEFAULT))) {
-               fprintf(stderr, "db: set_lk_detect: %s\n", db_strerror(ret));
+               fprintf(stderr, "ctdldump: set_lk_detect: %s\n", db_strerror(ret));
                dbenv->close(dbenv, 0);
-               fprintf(stderr, "db: exit code %d\n", ret);
+               fprintf(stderr, "ctdldump: exit code %d\n", ret);
                exit(CTDLEXIT_DB);
        }
 
        flags = DB_CREATE | DB_INIT_MPOOL | DB_PRIVATE | DB_INIT_LOG;
-       fprintf(stderr, "db: dbenv open(dir=%s, flags=%d)\n", dirname, flags);
+       fprintf(stderr, "ctdldump: dbenv open(dir=%s, flags=%d)\n", dirname, flags);
        ret = dbenv->open(dbenv, dirname, flags, 0);
        if (ret) {
-               fprintf(stderr, "db: dbenv->open: %s\n", db_strerror(ret));
+               fprintf(stderr, "ctdldump: dbenv->open: %s\n", db_strerror(ret));
                dbenv->close(dbenv, 0);
-               fprintf(stderr, "db: exit code %d\n", ret);
+               fprintf(stderr, "ctdldump: exit code %d\n", ret);
                exit(CTDLEXIT_DB);
        }
 
@@ -127,7 +127,7 @@ DB_ENV *open_dbenv(char *dirname) {
 void close_dbenv(DB_ENV *dbenv) {
        int ret = dbenv->close(dbenv, 0);
        if (ret) {
-               fprintf(stderr, "db: dbenv->close: %s\n", db_strerror(ret));
+               fprintf(stderr, "ctdldump: dbenv->close: %s\n", db_strerror(ret));
        }
 }
 
@@ -384,23 +384,23 @@ void export_table(int which_cdb, DB_ENV *src_dbenv) {
        // create a database handle for the source table
        ret = db_create(&src_dbp, src_dbenv, 0);
        if (ret) {
-               fprintf(stderr, "db: db_create: %s\n", db_strerror(ret));
-               fprintf(stderr, "db: exit code %d\n", ret);
+               fprintf(stderr, "ctdldump: db_create: %s\n", db_strerror(ret));
+               fprintf(stderr, "ctdldump: exit code %d\n", ret);
                exit(CTDLEXIT_DB);
        }
 
        // open the file containing the source table
        ret = src_dbp->open(src_dbp, NULL, dbfilename, NULL, DB_BTREE, 0, 0600);
        if (ret) {
-               fprintf(stderr, "db: db_open: %s\n", db_strerror(ret));
-               fprintf(stderr, "db: exit code %d\n", ret);
+               fprintf(stderr, "ctdldump: db_open: %s\n", db_strerror(ret));
+               fprintf(stderr, "ctdldump: exit code %d\n", ret);
                exit(CTDLEXIT_DB);
        }
 
        // Acquire a cursor to read the source table
        if ((ret = src_dbp->cursor(src_dbp, NULL, &src_dbcp, 0)) != 0) {
-               fprintf(stderr, "db: db_cursor: %s\n", db_strerror(ret));
-               fprintf(stderr, "db: exit code %d\n", ret);
+               fprintf(stderr, "ctdldump: db_cursor: %s\n", db_strerror(ret));
+               fprintf(stderr, "ctdldump: exit code %d\n", ret);
                exit(CTDLEXIT_DB);
        }
 
@@ -436,7 +436,7 @@ void export_table(int which_cdb, DB_ENV *src_dbenv) {
                                                (const Bytef *)in_data.data+sizeof(struct CtdlCompressHeader),
                                                (uLong)comp.compressed_len);
                                if (ret != Z_OK) {
-                                       fprintf(stderr, "db: uncompress() error %d\n", ret);
+                                       fprintf(stderr, "ctdldump: uncompress() error %d\n", ret);
                                        exit(CTDLEXIT_DB);
                                }
                        }
@@ -455,7 +455,7 @@ void export_table(int which_cdb, DB_ENV *src_dbenv) {
        // ...and close the database (table)
        ret = src_dbp->close(src_dbp, 0);
        if (ret) {
-               fprintf(stderr, "db: db_close: %s\n", db_strerror(ret));
+               fprintf(stderr, "ctdldump: db_close: %s\n", db_strerror(ret));
        }
 
 
@@ -469,6 +469,14 @@ int main(int argc, char **argv) {
        int confirmed = 0;
        static DB_ENV *src_dbenv;               // Source DB environment (global)
 
+       // display the greeting
+       fprintf(stderr, "\033[44m\033[30m \033[K\033[0m\n"
+                       "\033[44m\033[30m DB Dump utility for Citadel \033[K\033[0m\n"
+                       "\033[44m\033[30m Copyright (c) 2023 by citadel.org et al.  \033[K\033[0m\n"
+                       "\033[44m\033[30m This program is open source software.  Use, duplication, or disclosure \033[K\033[0m\n"
+                       "\033[44m\033[30m is subject to the terms of the GNU General Public license v3. \033[K\033[0m\n"
+                       "\033[44m\033[30m \033[K\033[0m\n");
+
        // Parse command line
        int a;
        while ((a = getopt(argc, argv, "h:y")) != EOF) {
@@ -486,10 +494,10 @@ int main(int argc, char **argv) {
        }
 
        if (confirmed == 1) {
-               fprintf(stderr, "You have specified the [-y] flag, so processing will continue.\n");
+               fprintf(stderr, "ctdldump: You have specified the [-y] flag, so processing will continue.\n");
        }
        else {
-               fprintf(stderr, "Please read [ https://www.citadel.org/ctdldump.html ] to learn how to proceed.\n");
+               fprintf(stderr, "ctdldump: Please read [ https://www.citadel.org/ctdldump.html ] to learn how to proceed.\n");
                exit(0);
        }
 
index b948d5a3f763bc891bdeabfb61ae5f7e8bd8cb3f..267c4db4419668dc2be5b716423f2b70f057b617 100644 (file)
@@ -610,6 +610,14 @@ int main(int argc, char **argv) {
        int confirmed = 0;
        static DB_ENV *dst_dbenv;               // Source DB environment (global)
 
+       // display the greeting
+       fprintf(stderr, "\033[42m\033[30m \033[K\033[0m\n"
+                       "\033[42m\033[30m DB Load utility for Citadel \033[K\033[0m\n"
+                       "\033[42m\033[30m Copyright (c) 2023 by citadel.org et al.  \033[K\033[0m\n"
+                       "\033[42m\033[30m This program is open source software.  Use, duplication, or disclosure \033[K\033[0m\n"
+                       "\033[42m\033[30m is subject to the terms of the GNU General Public license v3. \033[K\033[0m\n"
+                       "\033[42m\033[30m \033[K\033[0m\n");
+
        // Parse command line
        int a;
        while ((a = getopt(argc, argv, "h:y")) != EOF) {
@@ -627,10 +635,10 @@ int main(int argc, char **argv) {
        }
 
        if (confirmed == 1) {
-               fprintf(stderr,"You have specified the [-y] flag, so processing will continue.\n");
+               fprintf(stderr, "ctdlload: You have specified the [-y] flag, so processing will continue.\n");
        }
        else {
-               fprintf(stderr,"Please read [ https://www.citadel.org/ctdlload.html ] to learn how to proceed.\n");
+               fprintf(stderr, "ctdlload: Please read [ https://www.citadel.org/ctdlload.html ] to learn how to proceed.\n");
                exit(0);
        }