]> jfr.im git - irc/thales.git/commitdiff
added capability to change mysql port
authorklausweiss <klausweiss>
Sat, 3 Feb 2007 11:59:14 +0000 (11:59 +0000)
committerklausweiss <klausweiss>
Sat, 3 Feb 2007 11:59:14 +0000 (11:59 +0000)
src/conf.c
src/db.c
src/main.c

index 774ab9380140eece52d7a48489b2063a25400df3..cfadddf9ba454f01c7640c107470e3ab698ff9c8 100644 (file)
@@ -61,7 +61,7 @@ Directive directives[] = {
        {"ServerDesc", {{PARAM_STRING, 0, &ServerDesc}}},
        {"ServerName", {{PARAM_STRING, 0, &ServerName}}},
        {"MysqlServer", {{PARAM_STRING, 0, &MysqlServer}}},
-       {"MysqlPort", {{PARAM_PORT, 0, &MysqlPort}}},
+       {"MysqlPort", {{PARAM_POSINT, 0, &MysqlPort}}}, 
        {"MysqlDatabase", {{PARAM_STRING, 0, &MysqlDatabase}}},
        {"MysqlUser", {{PARAM_STRING, 0, &MysqlUser}}},
        {"MysqlPassword", {{PARAM_STRING, 0, &MysqlPassword}}},
index 5e18ee00b314cd6026a61045b6bb5cc46aeabc62..29eb45b2d37b7e1e4ff7515340fbfa4168904ee2 100644 (file)
--- a/src/db.c
+++ b/src/db.c
@@ -65,9 +65,11 @@ void db_connect()
                mysql_close(myptr);
        /* connecting to MySQL */
        myptr = mysql_init(NULL);
-       if (!mysql_real_connect
-                (myptr, MysqlServer, MysqlUser, MysqlPassword, MysqlDatabase, *MysqlPort,
-                 NULL, 0))
+
+
+       if (mysql_real_connect
+                (myptr, MysqlServer, MysqlUser, MysqlPassword, MysqlDatabase, MysqlPort,
+                 NULL, 0) == NULL)
                fatal("Failed to connect to database : %s\n", mysql_error(myptr));
 
        /* Cleaning up the database */
index 9161cbc4f4556f14b7773e77efb921c433c7423b..53f5166998fc1e54ff3e9281ed81275be6ae11ed 100644 (file)
@@ -100,6 +100,7 @@ int main(int argc, char **argv)
   char *ch1, *ch2;
   int opt = 0;
   int opt_index = 0;
+  int config = 0;
 
   static struct option thales_options[] =
     {
@@ -115,7 +116,7 @@ int main(int argc, char **argv)
   /* record start time */
   start_time = time(NULL);
   
-  opt = getopt_long(argc, argv, "chvVd",
+  opt = getopt_long(argc, argv, "c:hvVd",
                    thales_options, &opt_index);
 
   while(opt != EOF)
@@ -127,6 +128,8 @@ int main(int argc, char **argv)
            {
              exit(EXIT_FAILURE);
            }
+
+         config = 1;
          break;
 
        case 'd':
@@ -154,10 +157,15 @@ int main(int argc, char **argv)
          usage();
        }
       
-      opt = getopt_long(argc, argv, "hvVc:",
+      opt = getopt_long(argc, argv, "hvVdc:",
                        thales_options, &opt_index);
     }
 
+  if(config == 0)
+    {
+      fprintf(stderr, "Error: no configuration file loaded!\n");
+      exit(EXIT_FAILURE);
+    }
 
  
   /* Open logfile, and complain if we didn't. */