static void *mysql_ptr = NULL;
-
static int com_cam(int, int, char **);
static int com_cdb(int, int, char **);
static int com_cs(int, int, char **);
if (argc < 1)
return -E_MYSQL_SYNTAX;
- result = get_result(argv[1]);
+ result = get_result(argv[1]);
if (!result)
/* return success, because it's ok to have no results */
return 1;
mysql_free_result(result);
return NULL;
}
- mysql_data_seek(result, 4); /* skip Lastplayed, Numplayed... */
+ mysql_data_seek(result, 4); /* skip Lastplayed, Numplayed... */
return result;
}
q = make_message("select name, to_days(now()) - to_days(lastplayed) from "
"data%s%s%s order by lastplayed",
(argc < 1)? "" : " where ",
- (argc < 1)? "" : argv[1],
+ (argc < 1)? "" : argv[1],
(argc < 1)? "" : " = '1'");
- result = get_result(q);
+ result = get_result(q);
free(q);
if (!result)
return -E_NORESULT;
}
mysql_free_result(result);
ret = -E_NORESULT;
- result = get_result(query);
+ result = get_result(query);
if (!result)
goto out;
ret = -E_EMPTY_RESULT;
num_fields = mysql_num_fields(result);
if (num_fields < 5)
goto out;
- mysql_data_seek(result2, 4); /* skip Lastplayed, Numplayed... */
+ mysql_data_seek(result2, 4); /* skip Lastplayed, Numplayed... */
row = mysql_fetch_row(result);
ret = -E_NOROW;
if (!row)
goto out;
if (atts && (verbose || is_set))
atts = para_strcat(atts, verbose? "," : " ");
- if (is_set || verbose)
+ if (is_set || verbose)
atts = para_strcat(atts, row2[0]);
if (verbose)
atts = para_strcat(atts, is_set? "=\"1\"" : "=\"0\"");
- }
+ }
ret = 1;
out:
if (result2)
goto out;
q = make_message(verbose? verbose_fmt : fmt, ebn);
free(ebn);
- result = get_result(q);
+ result = get_result(q);
free(q);
if (!result)
goto out;
free(tmp2);
continue;
}
- if (!strcmp(command, "score:"))
+ if (!score && !strcmp(command, "score:"))
score = s_a_r_list(macro_list, arg);
}
if (!score) {
goto write_query;
}
select_clause = para_strdup(with_path?
- "select concat(dir.dir, '/', dir.name) from data, dir "
- "where dir.name = data.name "
- :
- "select name from data where name is not NULL");
+ "select concat(dir.dir, '/', dir.name) from data, dir "
+ "where dir.name = data.name "
+ :
+ "select name from data where name is not NULL");
order = make_message("order by -(%s)", score);
free(score);
if (accept_opts && deny_opts) {
* This is called from server and from some commands. Name must not be NULL
* Never returns NULL.
*/
-static char *get_dbinfo(char *name)
+static char *get_selector_info(char *name)
{
char *meta = NULL, *atts = NULL, *info, *dir = NULL, *query, *stream = NULL;
void *result = NULL;
argv[1]);
else
q = para_strdup("select name from data");
- result = get_result(q);
+ result = get_result(q);
free(q);
if (!result)
return -E_NORESULT;
char *buf = make_message(fmt, name);
int ret = -E_NORESULT;
- result = get_result(buf);
+ result = get_result(buf);
free(buf);
if (!result)
goto out;
static void update_mmd(char *info)
{
PARA_DEBUG_LOG("%s", "updating shared memory area\n");
- strncpy(mmd->dbinfo, info, MMD_INFO_SIZE - 1);
- mmd->dbinfo[MMD_INFO_SIZE - 1] = '\0';
+ strncpy(mmd->selector_info, info, MMD_INFO_SIZE - 1);
+ mmd->selector_info[MMD_INFO_SIZE - 1] = '\0';
}
static void update_audio_file_server_handler(char *name)
{
char *info;
- info = get_dbinfo(name);
+ info = get_selector_info(name);
update_mmd(info);
free(info);
update_audio_file(name);
return update_audio_file(argv[1]);
}
-static void refresh_mmd_dbinfo(void)
+static void refresh_selector_info(void)
{
char *name = get_current_audio_file();
char *info;
if (!name)
return;
- info = get_dbinfo(name);
+ info = get_selector_info(name);
free(name);
mmd_lock();
update_mmd(info);
else
i = match < num_rows - 1? match + 1 : 0;
ret = -E_NOROW;
- mysql_data_seek(result, i);
+ mysql_data_seek(result, i);
row = mysql_fetch_row(result);
if (!row || !row[0])
goto out;
"'current_stream'", row[0]);
ret = real_query(query);
free(query);
- refresh_mmd_dbinfo();
+ refresh_selector_info();
out:
free(stream);
if (result)
ret = change_stream(argv[1]);
if (ret < 0)
goto out;
- refresh_mmd_dbinfo();
+ refresh_selector_info();
}
if (csp) {
mmd_lock();
for (; argv[i] && ret >= 0; i++)
ret = update_atts(fd, argv[i], atts);
}
- refresh_mmd_dbinfo();
+ refresh_selector_info();
out:
return ret;
}
/* mmd lock must be held */
static void write_msg2mmd(int success)
{
- sprintf(mmd->dbinfo, "dbinfo1:%s\ndbinfo2:mysql-%s\ndbinfo3:\n",
+ sprintf(mmd->selector_info, "dbinfo1:%s\ndbinfo2:mysql-%s\ndbinfo3:\n",
success < 0? PARA_STRERROR(-success) :
"successfully connected to mysql server",
success < 0? "" : mysql_get_server_info(mysql_ptr));
* 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 dbinfo string.
+ * Connect to the mysql server and initialize the info string.
*
- * \sa struct audio_file_selector, misc_meta_data::dbinfo, random_selector.c
+ * \sa struct audio_file_selector, misc_meta_data::selector_info,
+ * random_selector.c
*/
int mysql_selector_init(struct audio_file_selector *db)
{