]> git.tuebingen.mpg.de Git - paraslash.git/blobdiff - mysql_selector.c
Merge ../paraslash.fml/paraslash
[paraslash.git] / mysql_selector.c
index f1c49aa5c7b9689a06f370bae72a85f42aa6738b..0eb19bc58da2f7d78681a793efb746cc0b14bc00 100644 (file)
@@ -766,7 +766,7 @@ out:
  */
 static char *get_selector_info(char *name)
 {
-       char *meta = NULL, *atts = NULL, *info, *dir = NULL, *query, *stream = NULL;
+       char *meta, *atts, *info, *dir, *query, *stream;
        void *result = NULL;
        MYSQL_ROW row = NULL;
 
@@ -792,14 +792,10 @@ write:
                stream, meta, 
                (result && row && row[0])? row[0] : "(no score)",
                atts);
-       if (dir)
-               free(dir);
-       if (meta)
-               free(meta);
-       if (atts)
-               free(atts);
-       if (stream)
-               free(stream);
+       free(dir);
+       free(meta);
+       free(atts);
+       free(stream);
        if (result)
                mysql_free_result(result);
        return info;
@@ -2156,8 +2152,15 @@ static void shutdown_connection(void)
 /**
  * the init function of the mysql-based audio file selector
  *
- * Check the command line options and initialize all function pointers of \a db.
- * Connect to the mysql server and initialize the info string.
+ * \param db pointer to the struct to initialize
+ *
+ * Check the command line options and initialize all function pointers of \a
+ * db.  Connect to the mysql server and initialize the info string.
+ *
+ * \return This function returns success even if it could not connect
+ * to the mysql server. This is because the connect is expected to fail
+ * if there the paraslash database is not yet created. This gives the
+ * user a chance to send the "cdb" to create the database.
  *
  * \sa struct audio_file_selector, misc_meta_data::selector_info,
  * random_selector.c
@@ -2171,7 +2174,7 @@ int mysql_selector_init(struct audio_file_selector *db)
        if (!conf.mysql_audio_file_dir_given)
                return -E_NO_AF_DIR;
        db->name = "mysql";
-       db->cmd_list = cmds;
+       db->cmd_list = mysql_selector_cmds;
        db->get_audio_file_list = server_get_audio_file_list;
        db->update_audio_file = update_audio_file_server_handler;
        db->shutdown = shutdown_connection;