mirror of
https://github.com/SuperBFG7/ympd
synced 2024-11-26 06:47:17 +00:00
fix handling of commas in library item names
This commit is contained in:
parent
4295d15874
commit
97bdc9aa97
@ -34,6 +34,14 @@ const char * mpd_cmd_strs[] = {
|
|||||||
MPD_CMDS(GEN_STR)
|
MPD_CMDS(GEN_STR)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
char * get_arg1 (char *p) {
|
||||||
|
return strchr(p, ',') + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
char * get_arg2 (char *p) {
|
||||||
|
return get_arg1(get_arg1(p));
|
||||||
|
}
|
||||||
|
|
||||||
static inline enum mpd_cmd_ids get_cmd_id(char *cmd)
|
static inline enum mpd_cmd_ids get_cmd_id(char *cmd)
|
||||||
{
|
{
|
||||||
for(int i = 0; i < sizeof(mpd_cmd_strs)/sizeof(mpd_cmd_strs[0]); i++)
|
for(int i = 0; i < sizeof(mpd_cmd_strs)/sizeof(mpd_cmd_strs[0]); i++)
|
||||||
@ -143,7 +151,9 @@ int callback_mpd(struct mg_connection *c)
|
|||||||
if((token = strtok(NULL, ",")) == NULL)
|
if((token = strtok(NULL, ",")) == NULL)
|
||||||
goto out_browse;
|
goto out_browse;
|
||||||
|
|
||||||
n = mpd_put_browse(mpd.buf, token, uint_buf);
|
free(p_charbuf);
|
||||||
|
p_charbuf = strdup(c->content);
|
||||||
|
n = mpd_put_browse(mpd.buf, get_arg2(p_charbuf), uint_buf);
|
||||||
out_browse:
|
out_browse:
|
||||||
free(p_charbuf);
|
free(p_charbuf);
|
||||||
break;
|
break;
|
||||||
@ -155,7 +165,9 @@ out_browse:
|
|||||||
if((token = strtok(NULL, ",")) == NULL)
|
if((token = strtok(NULL, ",")) == NULL)
|
||||||
goto out_add_track;
|
goto out_add_track;
|
||||||
|
|
||||||
mpd_run_add(mpd.conn, token);
|
free(p_charbuf);
|
||||||
|
p_charbuf = strdup(c->content);
|
||||||
|
mpd_run_add(mpd.conn, get_arg1(p_charbuf));
|
||||||
out_add_track:
|
out_add_track:
|
||||||
free(p_charbuf);
|
free(p_charbuf);
|
||||||
break;
|
break;
|
||||||
@ -167,7 +179,9 @@ out_add_track:
|
|||||||
if((token = strtok(NULL, ",")) == NULL)
|
if((token = strtok(NULL, ",")) == NULL)
|
||||||
goto out_play_track;
|
goto out_play_track;
|
||||||
|
|
||||||
int_buf = mpd_run_add_id(mpd.conn, token);
|
free(p_charbuf);
|
||||||
|
p_charbuf = strdup(c->content);
|
||||||
|
int_buf = mpd_run_add_id(mpd.conn, get_arg1(p_charbuf));
|
||||||
if(int_buf != -1)
|
if(int_buf != -1)
|
||||||
mpd_run_play_id(mpd.conn, int_buf);
|
mpd_run_play_id(mpd.conn, int_buf);
|
||||||
out_play_track:
|
out_play_track:
|
||||||
@ -181,7 +195,9 @@ out_play_track:
|
|||||||
if((token = strtok(NULL, ",")) == NULL)
|
if((token = strtok(NULL, ",")) == NULL)
|
||||||
goto out_playlist;
|
goto out_playlist;
|
||||||
|
|
||||||
mpd_run_load(mpd.conn, token);
|
free(p_charbuf);
|
||||||
|
p_charbuf = strdup(c->content);
|
||||||
|
mpd_run_load(mpd.conn, get_arg1(p_charbuf));
|
||||||
out_playlist:
|
out_playlist:
|
||||||
free(p_charbuf);
|
free(p_charbuf);
|
||||||
break;
|
break;
|
||||||
@ -193,7 +209,9 @@ out_playlist:
|
|||||||
if((token = strtok(NULL, ",")) == NULL)
|
if((token = strtok(NULL, ",")) == NULL)
|
||||||
goto out_save_queue;
|
goto out_save_queue;
|
||||||
|
|
||||||
mpd_run_save(mpd.conn, token);
|
free(p_charbuf);
|
||||||
|
p_charbuf = strdup(c->content);
|
||||||
|
mpd_run_save(mpd.conn, get_arg1(p_charbuf));
|
||||||
out_save_queue:
|
out_save_queue:
|
||||||
free(p_charbuf);
|
free(p_charbuf);
|
||||||
break;
|
break;
|
||||||
@ -205,7 +223,9 @@ out_save_queue:
|
|||||||
if((token = strtok(NULL, ",")) == NULL)
|
if((token = strtok(NULL, ",")) == NULL)
|
||||||
goto out_search;
|
goto out_search;
|
||||||
|
|
||||||
n = mpd_search(mpd.buf, token);
|
free(p_charbuf);
|
||||||
|
p_charbuf = strdup(c->content);
|
||||||
|
n = mpd_search(mpd.buf, get_arg1(p_charbuf));
|
||||||
out_search:
|
out_search:
|
||||||
free(p_charbuf);
|
free(p_charbuf);
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user