-static void init_dbtool(void)
-{
- int i;
-
- mmd->dbt_change = -1; /* no change nec., set to new dbt num by com_cdt */
- if (!dblist[1].name)
- goto random;
- if (conf.dbtool_given) {
- for (i = 0; dblist[i].name; i++) {
- if (strcmp(dblist[i].name, conf.dbtool_arg))
- continue;
- PARA_NOTICE_LOG("initializing %s database tool\n",
- dblist[i].name);
- if (dblist[i].init(&dblist[i]) < 0) {
- PARA_WARNING_LOG("init %s failed",
- dblist[i].name);
- goto random;
- }
- mmd->dbt_num = i;
- return;
- }
- PARA_WARNING_LOG("%s", "no such dbtool, switching to random\n");
- goto random;
- }
- /* use the first dbtool that works
- * (assuming that random always works)
- */
- for (i = 1; dblist[i].name; i++) {
- int ret = dblist[i].init(&dblist[i]);
- if (ret >= 0) {
- PARA_INFO_LOG("initialized %s\n", dblist[i].name);
- mmd->dbt_num = i;
- return;
- }
- PARA_CRIT_LOG("%s init failed: %s\n", dblist[i].name,
- PARA_STRERROR(-ret));
- }
-random:
- mmd->dbt_num = 0;
- dblist[0].init(&dblist[0]); /* always successful */
-}
-