return ret;
}
-static char *escape_blob(char* old, int size)
+static char *escape_blob(const char* old, int size)
{
char *new;
return new;
}
-static char *escape_str(char* old)
+static char *escape_str(const char* old)
{
return escape_blob(old, strlen(old));
}
/*
* new attribute
*/
-static int com_na(__unused int fd, int argc, char *argv[])
+static int com_na(__a_unused int fd, int argc, char *argv[])
{
char *q, *tmp;
int ret;
/*
* delete attribute
*/
-static int com_da(__unused int fd, int argc, char *argv[])
+static int com_da(__a_unused int fd, int argc, char *argv[])
{
char *q, *tmp;
int ret;
/*
* list all attributes
*/
-static int com_laa(int fd, int argc, __unused char *argv[])
+static int com_laa(int fd, int argc, __a_unused char *argv[])
{
void *result;
int ret;
/*
* remove/add entries
*/
-static int com_rm_ne(__unused int fd, int argc, char *argv[])
+static int com_rm_ne(__a_unused int fd, int argc, char *argv[])
{
int ne = !strcmp(argv[0], "ne");
int i, ret;
/*
* mv: rename entry
*/
-static int com_mv(__unused int fd, int argc, char *argv[])
+static int com_mv(__a_unused int fd, int argc, char *argv[])
{
char *q, *dn, *ebn1 = NULL, *ebn2 = NULL, *edn = NULL;
int ret;
* picass: associate pic to audio file
* snp: set numplayed
*/
-static int com_set(__unused int fd, int argc, char *argv[])
+static int com_set(__a_unused int fd, int argc, char *argv[])
{
char *q, *ebn;
long unsigned id;
/*
* picch: change entry's name in pics table
*/
-static int com_picch(__unused int fd, int argc, char *argv[])
+static int com_picch(__a_unused int fd, int argc, char *argv[])
{
int ret;
long unsigned id;
/*
* piclist: print list of pics in db
*/
-static int com_piclist(__unused int fd, int argc, __unused char *argv[])
+static int com_piclist(__a_unused int fd, int argc, __a_unused char *argv[])
{
void *result = NULL;
MYSQL_ROW row;
}
/* strdel */
-static int com_strdel(__unused int fd, int argc, char *argv[])
+static int com_strdel(__a_unused int fd, int argc, char *argv[])
{
char *q, *tmp;
int ret;
/*
* summary
*/
-static int com_summary(__unused int fd, int argc, __unused char *argv[])
+static int com_summary(__a_unused int fd, int argc, __a_unused char *argv[])
{
MYSQL_ROW row;
MYSQL_ROW row2;
ret = real_query(q);
free(q);
out:
- if (ebn)
- free(ebn);
+ free(ebn);
return ret;
}
+
/* If called as child, mmd_lock must be held */
static void update_mmd(char *info)
{
update_audio_file(name);
}
-static int com_us(__unused int fd, int argc, char *argv[])
+static int com_us(__a_unused int fd, int argc, char *argv[])
{
char *tmp;
int ret;
}
/* select previous/next stream */
-static int com_ps(__unused int fd, int argc, char *argv[])
+static int com_ps(__a_unused int fd, int argc, char *argv[])
{
char *query, *stream = get_current_stream();
void *result = get_result("select name from streams");
}
/* streams */
-static int com_streams(int fd, int argc, __unused char *argv[])
+static int com_streams(int fd, int argc, __a_unused char *argv[])
{
unsigned int num_rows;
int i, ret = -E_NORESULT;
/*
* verify / clean
*/
-static int com_vrfy(int fd, int argc, __unused char *argv[])
+static int com_vrfy(int fd, int argc, __a_unused char *argv[])
{
char *query;
int ret, vrfy_mode = strcmp(argv[0], "clean");
{
int ret = -E_TMPFILE;
char *msg = make_message("%s\t%s\n", dir, name);
-
if (fputs(msg, out_file) != EOF)
ret = 1;
free(msg);
/*
* update database
*/
-static int com_upd(int fd, int argc, __unused char *argv[])
+static int com_upd(int fd, int argc, __a_unused char *argv[])
{
char *tempname = NULL, *query = NULL;
int ret, out_fd = -1, num = 0;
goto out;
if ((ret = real_query("delete from dir")) < 0)
goto out;
- query = make_message("load data infile '%s' into table dir "
+ query = make_message("load data infile '%s' ignore into table dir "
"fields terminated by '\t' lines terminated by '\n' "
"(dir, name)", tempname);
ret = real_query(query);
goto out;
}
while ((row = mysql_fetch_row(result))) {
+ char *erow;
ret = -E_NOROW;
if (!row[0])
goto out;
send_va_buffer(fd, "new entry: %s\n", row[0]);
+ erow = escape_str(row[0]);
query = make_message("insert into data (name, pic_id) values "
- "('%s','%s')", row[0], "1");
+ "('%s','%s')", erow, "1");
+ free(erow);
ret = real_query(query);
free(query);
if (ret < 0)
free(stream);
query = make_message("%s limit %d", tmp, num);
free(tmp);
- if (!query)
- goto err_out;
result = get_result(query);
+ free(query);
if (!result)
goto err_out;
num_rows = mysql_num_rows(result);
free(list);
list = NULL;
success:
- if (query)
- free(query);
if (result)
mysql_free_result(result);
return list;