1
0
mirror of https://github.com/SuperBFG7/ympd synced 2024-06-17 02:30:10 +00:00

fix: source code formating

This commit is contained in:
jcorporation 2018-07-24 23:58:29 +01:00
parent 83a3933056
commit a5bddf4b4a
3 changed files with 39 additions and 40 deletions

View File

@ -589,7 +589,7 @@ function webSocketConnect() {
} }
socket.onmessage = function got_packet(msg) { socket.onmessage = function got_packet(msg) {
if(msg.data === last_state || msg.data.length == 0) if (msg.data === last_state || msg.data.length == 0)
return; return;
try { try {
@ -606,7 +606,7 @@ function webSocketConnect() {
showNotification('myMPD lost connection to MPD', '', '', 'danger'); showNotification('myMPD lost connection to MPD', '', '', 'danger');
break; break;
case 'update_queue': case 'update_queue':
if(app.current.app === 'Queue') if (app.current.app === 'Queue')
getQueue(); getQueue();
break; break;
case 'song_change': case 'song_change':
@ -796,7 +796,7 @@ function parseState(obj) {
} else { } else {
domCache.volumeControl.classList.remove('hide'); domCache.volumeControl.classList.remove('hide');
domCache.volumePrct.innerText = obj.data.volume + ' %'; domCache.volumePrct.innerText = obj.data.volume + ' %';
if(obj.data.volume == 0) if (obj.data.volume == 0)
domCache.volumeIcon.innerText = 'volume_off'; domCache.volumeIcon.innerText = 'volume_off';
else if (obj.data.volume < 50) else if (obj.data.volume < 50)
domCache.volumeIcon.innerText = 'volume_down'; domCache.volumeIcon.innerText = 'volume_down';
@ -903,7 +903,7 @@ function parseQueue(obj) {
else else
tbody.append(row); tbody.append(row);
} }
var tr_length=tr.length - 1; var tr_length = tr.length - 1;
for (var i = tr_length; i >= nrItems; i --) { for (var i = tr_length; i >= nrItems; i --) {
tr[i].remove(); tr[i].remove();
} }
@ -973,7 +973,7 @@ function parseFilesystem(obj) {
else else
tbody.append(row); tbody.append(row);
} }
var tr_length=tr.length - 1; var tr_length = tr.length - 1;
for (var i = tr_length; i >= nrItems; i --) { for (var i = tr_length; i >= nrItems; i --) {
tr[i].remove(); tr[i].remove();
} }
@ -1060,7 +1060,7 @@ function parsePlaylists(obj) {
tbody.append(row); tbody.append(row);
} }
} }
var tr_length=tr.length - 1; var tr_length = tr.length - 1;
for (var i = tr_length; i >= nrItems; i --) { for (var i = tr_length; i >= nrItems; i --) {
tr[i].remove(); tr[i].remove();
} }
@ -1079,7 +1079,7 @@ function parsePlaylists(obj) {
} }
function parseListDBtags(obj) { function parseListDBtags(obj) {
if(app.current.app !== 'Browse' && app.current.tab !== 'Database' && app.current.view !== 'Artist') return; if (app.current.app !== 'Browse' && app.current.tab !== 'Database' && app.current.view !== 'Artist') return;
if (obj.tagtype == 'AlbumArtist') { if (obj.tagtype == 'AlbumArtist') {
document.getElementById('BrowseDatabaseAlbumCards').classList.add('hide'); document.getElementById('BrowseDatabaseAlbumCards').classList.add('hide');
@ -1148,7 +1148,7 @@ function parseListDBtags(obj) {
sendAPI({"cmd":"MPD_API_GET_ARTISTALBUMTITLES", "data": { "albumartist": obj.searchstr, "album": obj.data[i].value}}, parseListTitles); sendAPI({"cmd":"MPD_API_GET_ARTISTALBUMTITLES", "data": { "albumartist": obj.searchstr, "album": obj.data[i].value}}, parseListTitles);
} }
var cards_length=cards.length - 1; var cards_length = cards.length - 1;
for (var i = cards_length; i >= nrItems; i --) { for (var i = cards_length; i >= nrItems; i --) {
cards[i].remove(); cards[i].remove();
} }
@ -1491,7 +1491,7 @@ function updateDB() {
} }
function clickPlay() { function clickPlay() {
if( playstate != 'play') if (playstate != 'play')
sendAPI({"cmd": "MPD_API_SET_PLAY"}); sendAPI({"cmd": "MPD_API_SET_PLAY"});
else else
sendAPI({"cmd": "MPD_API_SET_PAUSE"}); sendAPI({"cmd": "MPD_API_SET_PAUSE"});
@ -1690,7 +1690,7 @@ function songChange(obj) {
document.getElementById('album-cover').style.backgroundImage = 'url("' + obj.data.cover + '")'; document.getElementById('album-cover').style.backgroundImage = 'url("' + obj.data.cover + '")';
if(typeof obj.data.artist != 'undefined' && obj.data.artist.length > 0 && obj.data.artist != '-') { if (typeof obj.data.artist != 'undefined' && obj.data.artist.length > 0 && obj.data.artist != '-') {
textNotification += obj.data.artist; textNotification += obj.data.artist;
htmlNotification += obj.data.artist; htmlNotification += obj.data.artist;
pageTitle += obj.data.artist + ' - '; pageTitle += obj.data.artist + ' - ';
@ -1698,7 +1698,7 @@ function songChange(obj) {
} else { } else {
document.getElementById('artist').innerText = ''; document.getElementById('artist').innerText = '';
} }
if(typeof obj.data.album != 'undefined' && obj.data.album.length > 0 && obj.data.album != '-') { if (typeof obj.data.album != 'undefined' && obj.data.album.length > 0 && obj.data.album != '-') {
textNotification += ' - ' + obj.data.album; textNotification += ' - ' + obj.data.album;
htmlNotification += '<br/>' + obj.data.album; htmlNotification += '<br/>' + obj.data.album;
document.getElementById('album').innerText = obj.data.album; document.getElementById('album').innerText = obj.data.album;
@ -1706,7 +1706,7 @@ function songChange(obj) {
else { else {
document.getElementById('album').innerText = ''; document.getElementById('album').innerText = '';
} }
if(typeof obj.data.title != 'undefined' && obj.data.title.length > 0) { if (typeof obj.data.title != 'undefined' && obj.data.title.length > 0) {
pageTitle += obj.data.title; pageTitle += obj.data.title;
document.getElementById('currenttrack').innerText = obj.data.title; document.getElementById('currenttrack').innerText = obj.data.title;
} else { } else {

View File

@ -46,7 +46,7 @@ const char * mpd_cmd_strs[] = {
static inline enum mpd_cmd_ids get_cmd_id(const char *cmd) static inline enum mpd_cmd_ids get_cmd_id(const 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++)
if(!strncmp(cmd, mpd_cmd_strs[i], strlen(mpd_cmd_strs[i]))) if (!strncmp(cmd, mpd_cmd_strs[i], strlen(mpd_cmd_strs[i])))
return i; return i;
return -1; return -1;
@ -73,7 +73,7 @@ void callback_mympd(struct mg_connection *nc, const struct mg_str msg)
else else
cmd_id = get_cmd_id("MPD_API_UNKNOWN"); cmd_id = get_cmd_id("MPD_API_UNKNOWN");
if(cmd_id == -1) if (cmd_id == -1)
cmd_id = get_cmd_id("MPD_API_UNKNOWN"); cmd_id = get_cmd_id("MPD_API_UNKNOWN");
switch(cmd_id) { switch(cmd_id) {
@ -342,7 +342,7 @@ void callback_mympd(struct mg_connection *nc, const struct mg_str msg)
je = json_scanf(msg.p, msg.len, "{ data: { uri:%Q } }", &p_charbuf1); je = json_scanf(msg.p, msg.len, "{ data: { uri:%Q } }", &p_charbuf1);
if (je == 1) { if (je == 1) {
int_buf = mpd_run_add_id(mpd.conn, p_charbuf1); int_buf = mpd_run_add_id(mpd.conn, p_charbuf1);
if(int_buf != -1) if (int_buf != -1)
mpd_run_play_id(mpd.conn, int_buf); mpd_run_play_id(mpd.conn, int_buf);
free(p_charbuf1); free(p_charbuf1);
n = snprintf(mpd.buf, MAX_SIZE, "{\"type\": \"result\", \"data\": \"ok\"}"); n = snprintf(mpd.buf, MAX_SIZE, "{\"type\": \"result\", \"data\": \"ok\"}");
@ -479,12 +479,12 @@ static int mympd_notify_callback(struct mg_connection *c, const char *param) {
return 0; return 0;
} }
if(!c->user_data) if (!c->user_data)
c->user_data = calloc(1, sizeof(struct t_mpd_client_session)); c->user_data = calloc(1, sizeof(struct t_mpd_client_session));
struct t_mpd_client_session *s = (struct t_mpd_client_session *)c->user_data; struct t_mpd_client_session *s = (struct t_mpd_client_session *)c->user_data;
if(mpd.conn_state != MPD_CONNECTED) { if (mpd.conn_state != MPD_CONNECTED) {
n=snprintf(mpd.buf, MAX_SIZE, "{\"type\":\"disconnected\"}"); n=snprintf(mpd.buf, MAX_SIZE, "{\"type\":\"disconnected\"}");
#ifdef DEBUG #ifdef DEBUG
fprintf(stdout,"Notify: disconnected\n"); fprintf(stdout,"Notify: disconnected\n");
@ -497,7 +497,7 @@ static int mympd_notify_callback(struct mg_connection *c, const char *param) {
#endif #endif
mg_send_websocket_frame(c, WEBSOCKET_OP_TEXT, mpd.buf, strlen(mpd.buf)); mg_send_websocket_frame(c, WEBSOCKET_OP_TEXT, mpd.buf, strlen(mpd.buf));
if(s->song_id != mpd.song_id) { if (s->song_id != mpd.song_id) {
n=mympd_put_current_song(mpd.buf); n=mympd_put_current_song(mpd.buf);
#ifdef DEBUG #ifdef DEBUG
fprintf(stdout,"Notify: %s\n",mpd.buf); fprintf(stdout,"Notify: %s\n",mpd.buf);
@ -506,7 +506,7 @@ static int mympd_notify_callback(struct mg_connection *c, const char *param) {
s->song_id = mpd.song_id; s->song_id = mpd.song_id;
} }
if(s->queue_version != mpd.queue_version) { if (s->queue_version != mpd.queue_version) {
n=snprintf(mpd.buf, MAX_SIZE, "{\"type\":\"update_queue\"}"); n=snprintf(mpd.buf, MAX_SIZE, "{\"type\":\"update_queue\"}");
#ifdef DEBUG #ifdef DEBUG
fprintf(stdout,"Notify: update_queue\n"); fprintf(stdout,"Notify: update_queue\n");
@ -539,7 +539,7 @@ void mympd_poll(struct mg_mgr *s) {
return; return;
} }
if(mpd.password && !mpd_run_password(mpd.conn, mpd.password)) { if (mpd.password && !mpd_run_password(mpd.conn, mpd.password)) {
fprintf(stderr, "MPD connection: %s\n", mpd_connection_get_error_message(mpd.conn)); fprintf(stderr, "MPD connection: %s\n", mpd_connection_get_error_message(mpd.conn));
for (struct mg_connection *c = mg_next(s, NULL); c != NULL; c = mg_next(s, c)) { for (struct mg_connection *c = mg_next(s, NULL); c != NULL; c = mg_next(s, c)) {
mympd_notify_callback(c, mpd_connection_get_error_message(mpd.conn)); mympd_notify_callback(c, mpd_connection_get_error_message(mpd.conn));
@ -558,7 +558,7 @@ void mympd_poll(struct mg_mgr *s) {
case MPD_DISCONNECT: case MPD_DISCONNECT:
case MPD_RECONNECT: case MPD_RECONNECT:
if(mpd.conn != NULL) if (mpd.conn != NULL)
mpd_connection_free(mpd.conn); mpd_connection_free(mpd.conn);
mpd.conn = NULL; mpd.conn = NULL;
mpd.conn_state = MPD_DISCONNECTED; mpd.conn_state = MPD_DISCONNECTED;
@ -670,7 +670,7 @@ int mympd_put_settings(char *buffer) {
int je; int je;
struct json_out out = JSON_OUT_BUF(buffer, MAX_SIZE); struct json_out out = JSON_OUT_BUF(buffer, MAX_SIZE);
struct mympd_state { int a; int b; } state = { .a = 0, .b = 0 }; struct mympd_state { int a; int b; } state = { .a = 0, .b = 0 };
if( access( mpd.statefile, F_OK ) != -1 ) { if (access( mpd.statefile, F_OK ) != -1 ) {
char *content = json_fread(mpd.statefile); char *content = json_fread(mpd.statefile);
je = json_scanf(content, strlen(content), "{notificationWeb: %d, notificationPage: %d}", &state.a, &state.b); je = json_scanf(content, strlen(content), "{notificationWeb: %d, notificationPage: %d}", &state.a, &state.b);
if (je != 2) { if (je != 2) {
@ -906,7 +906,7 @@ int mympd_put_browse(char *buffer, char *path, unsigned int offset, char *filter
const struct mpd_song *song; const struct mpd_song *song;
const struct mpd_directory *dir; const struct mpd_directory *dir;
entity_count ++; entity_count ++;
if(entity_count > offset && entity_count <= offset+MAX_ELEMENTS_PER_PAGE) { if (entity_count > offset && entity_count <= offset+MAX_ELEMENTS_PER_PAGE) {
switch (mpd_entity_get_type(entity)) { switch (mpd_entity_get_type(entity)) {
case MPD_ENTITY_TYPE_UNKNOWN: case MPD_ENTITY_TYPE_UNKNOWN:
entity_count --; entity_count --;
@ -1003,7 +1003,7 @@ int mympd_put_db_tag(char *buffer, unsigned int offset, char *mpdtagtype, char *
int len; int len;
struct json_out out = JSON_OUT_BUF(buffer, MAX_SIZE); struct json_out out = JSON_OUT_BUF(buffer, MAX_SIZE);
if(mpd_search_db_tags(mpd.conn, mpd_tag_name_parse(mpdtagtype)) == false) if (mpd_search_db_tags(mpd.conn, mpd_tag_name_parse(mpdtagtype)) == false)
RETURN_ERROR_AND_RECOVER("mpd_search_db_tags"); RETURN_ERROR_AND_RECOVER("mpd_search_db_tags");
if (mpd_tag_name_parse(mpdsearchtagtype) != MPD_TAG_UNKNOWN) { if (mpd_tag_name_parse(mpdsearchtagtype) != MPD_TAG_UNKNOWN) {
@ -1011,13 +1011,13 @@ int mympd_put_db_tag(char *buffer, unsigned int offset, char *mpdtagtype, char *
RETURN_ERROR_AND_RECOVER("mpd_search_add_tag_constraint"); RETURN_ERROR_AND_RECOVER("mpd_search_add_tag_constraint");
} }
if(mpd_search_commit(mpd.conn) == false) if (mpd_search_commit(mpd.conn) == false)
RETURN_ERROR_AND_RECOVER("mpd_search_commit"); RETURN_ERROR_AND_RECOVER("mpd_search_commit");
len = json_printf(&out, "{type: listDBtags, data: [ "); len = json_printf(&out, "{type: listDBtags, data: [ ");
while((pair = mpd_recv_pair_tag(mpd.conn, mpd_tag_name_parse(mpdtagtype))) != NULL) { while((pair = mpd_recv_pair_tag(mpd.conn, mpd_tag_name_parse(mpdtagtype))) != NULL) {
entity_count ++; entity_count ++;
if(entity_count > offset && entity_count <= offset+MAX_ELEMENTS_PER_PAGE) { if (entity_count > offset && entity_count <= offset+MAX_ELEMENTS_PER_PAGE) {
if (strncmp(filter,"-",1) == 0 || strncasecmp(filter,pair->value,1) == 0 || if (strncmp(filter,"-",1) == 0 || strncasecmp(filter,pair->value,1) == 0 ||
( strncmp(filter,"0",1) == 0 && isalpha(*pair->value) == 0 ) ( strncmp(filter,"0",1) == 0 && isalpha(*pair->value) == 0 )
) { ) {
@ -1056,7 +1056,7 @@ int mympd_put_songs_in_album(char *buffer, char *albumartist, char *album) {
char cover[500]; char cover[500];
struct json_out out = JSON_OUT_BUF(buffer, MAX_SIZE); struct json_out out = JSON_OUT_BUF(buffer, MAX_SIZE);
if(mpd_search_db_songs(mpd.conn, true) == false) { if (mpd_search_db_songs(mpd.conn, true) == false) {
RETURN_ERROR_AND_RECOVER("mpd_search_db_songs"); RETURN_ERROR_AND_RECOVER("mpd_search_db_songs");
} }
@ -1066,14 +1066,14 @@ int mympd_put_songs_in_album(char *buffer, char *albumartist, char *album) {
if (mpd_search_add_tag_constraint(mpd.conn, MPD_OPERATOR_DEFAULT, MPD_TAG_ALBUM, album) == false) if (mpd_search_add_tag_constraint(mpd.conn, MPD_OPERATOR_DEFAULT, MPD_TAG_ALBUM, album) == false)
RETURN_ERROR_AND_RECOVER("mpd_search_add_tag_constraint"); RETURN_ERROR_AND_RECOVER("mpd_search_add_tag_constraint");
if(mpd_search_commit(mpd.conn) == false) if (mpd_search_commit(mpd.conn) == false)
RETURN_ERROR_AND_RECOVER("mpd_search_commit"); RETURN_ERROR_AND_RECOVER("mpd_search_commit");
else { else {
len = json_printf(&out, "{ type: listTitles, data: [ "); len = json_printf(&out, "{ type: listTitles, data: [ ");
while((song = mpd_recv_song(mpd.conn)) != NULL) { while((song = mpd_recv_song(mpd.conn)) != NULL) {
entity_count ++; entity_count ++;
if(entity_count <= MAX_ELEMENTS_PER_PAGE) { if (entity_count <= MAX_ELEMENTS_PER_PAGE) {
if (entities_returned ++) len += json_printf(&out, ", "); if (entities_returned ++) len += json_printf(&out, ", ");
else mympd_get_cover(mpd_song_get_uri(song),cover,500); else mympd_get_cover(mpd_song_get_uri(song),cover,500);
len += json_printf(&out, "{ type: song, uri: %Q, duration: %d, title: %Q, track: %Q }", len += json_printf(&out, "{ type: song, uri: %Q, duration: %d, title: %Q, track: %Q }",
@ -1114,7 +1114,7 @@ int mympd_put_playlists(char *buffer, unsigned int offset, char *filter) {
while((pl = mpd_recv_playlist(mpd.conn)) != NULL) { while((pl = mpd_recv_playlist(mpd.conn)) != NULL) {
entity_count ++; entity_count ++;
if(entity_count > offset && entity_count <= offset+MAX_ELEMENTS_PER_PAGE) { if (entity_count > offset && entity_count <= offset+MAX_ELEMENTS_PER_PAGE) {
plpath = mpd_playlist_get_path(pl); plpath = mpd_playlist_get_path(pl);
if (strncmp(filter,"-",1) == 0 || strncasecmp(filter,plpath,1) == 0 || if (strncmp(filter,"-",1) == 0 || strncasecmp(filter,plpath,1) == 0 ||
( strncmp(filter,"0",1) == 0 && isalpha(*plpath) == 0 ) ( strncmp(filter,"0",1) == 0 && isalpha(*plpath) == 0 )
@ -1203,9 +1203,8 @@ int mympd_search(char *buffer, char *mpdtagtype, unsigned int offset, char *sear
int len; int len;
struct json_out out = JSON_OUT_BUF(buffer, MAX_SIZE); struct json_out out = JSON_OUT_BUF(buffer, MAX_SIZE);
if(mpd_search_db_songs(mpd.conn, false) == false) { if (mpd_search_db_songs(mpd.conn, false) == false)
RETURN_ERROR_AND_RECOVER("mpd_search_db_songs"); RETURN_ERROR_AND_RECOVER("mpd_search_db_songs");
}
if (mpd_tag_name_parse(mpdtagtype) != MPD_TAG_UNKNOWN) { if (mpd_tag_name_parse(mpdtagtype) != MPD_TAG_UNKNOWN) {
if (mpd_search_add_tag_constraint(mpd.conn, MPD_OPERATOR_DEFAULT, mpd_tag_name_parse(mpdtagtype), searchstr) == false) if (mpd_search_add_tag_constraint(mpd.conn, MPD_OPERATOR_DEFAULT, mpd_tag_name_parse(mpdtagtype), searchstr) == false)
@ -1216,14 +1215,14 @@ int mympd_search(char *buffer, char *mpdtagtype, unsigned int offset, char *sear
RETURN_ERROR_AND_RECOVER("mpd_search_add_any_tag_constraint"); RETURN_ERROR_AND_RECOVER("mpd_search_add_any_tag_constraint");
} }
if(mpd_search_commit(mpd.conn) == false) if (mpd_search_commit(mpd.conn) == false)
RETURN_ERROR_AND_RECOVER("mpd_search_commit"); RETURN_ERROR_AND_RECOVER("mpd_search_commit");
else { else {
len = json_printf(&out, "{ type: search, data: [ "); len = json_printf(&out, "{ type: search, data: [ ");
while((song = mpd_recv_song(mpd.conn)) != NULL) { while((song = mpd_recv_song(mpd.conn)) != NULL) {
entity_count ++; entity_count ++;
if(entity_count > offset && entity_count <= offset+MAX_ELEMENTS_PER_PAGE) { if (entity_count > offset && entity_count <= offset+MAX_ELEMENTS_PER_PAGE) {
if (entities_returned ++) len += json_printf(&out, ", "); if (entities_returned ++) len += json_printf(&out, ", ");
len += json_printf(&out, "{ type: song, uri: %Q, album: %Q, artist: %Q, duration: %d, title: %Q, name: %Q }", len += json_printf(&out, "{ type: song, uri: %Q, album: %Q, artist: %Q, duration: %d, title: %Q, name: %Q }",
mpd_song_get_uri(song), mpd_song_get_uri(song),
@ -1256,7 +1255,7 @@ int mympd_search_add(char *buffer,char *mpdtagtype, char *searchstr) {
struct json_out out = JSON_OUT_BUF(buffer, MAX_SIZE); struct json_out out = JSON_OUT_BUF(buffer, MAX_SIZE);
len = 0; len = 0;
if(mpd_search_add_db_songs(mpd.conn, false) == false) { if (mpd_search_add_db_songs(mpd.conn, false) == false) {
RETURN_ERROR_AND_RECOVER("mpd_search_add_db_songs"); RETURN_ERROR_AND_RECOVER("mpd_search_add_db_songs");
} }
@ -1269,7 +1268,7 @@ int mympd_search_add(char *buffer,char *mpdtagtype, char *searchstr) {
RETURN_ERROR_AND_RECOVER("mpd_search_add_any_tag_constraint"); RETURN_ERROR_AND_RECOVER("mpd_search_add_any_tag_constraint");
} }
if(mpd_search_commit(mpd.conn) == false) if (mpd_search_commit(mpd.conn) == false)
RETURN_ERROR_AND_RECOVER("mpd_search_commit"); RETURN_ERROR_AND_RECOVER("mpd_search_commit");
while((song = mpd_recv_song(mpd.conn)) != NULL) { while((song = mpd_recv_song(mpd.conn)) != NULL) {
@ -1288,7 +1287,7 @@ int mympd_search_queue(char *buffer, char *mpdtagtype, unsigned int offset, char
int len; int len;
struct json_out out = JSON_OUT_BUF(buffer, MAX_SIZE); struct json_out out = JSON_OUT_BUF(buffer, MAX_SIZE);
if(mpd_search_queue_songs(mpd.conn, false) == false) { if (mpd_search_queue_songs(mpd.conn, false) == false) {
RETURN_ERROR_AND_RECOVER("mpd_search_queue_songs"); RETURN_ERROR_AND_RECOVER("mpd_search_queue_songs");
} }
@ -1301,14 +1300,14 @@ int mympd_search_queue(char *buffer, char *mpdtagtype, unsigned int offset, char
RETURN_ERROR_AND_RECOVER("mpd_search_add_any_tag_constraint"); RETURN_ERROR_AND_RECOVER("mpd_search_add_any_tag_constraint");
} }
if(mpd_search_commit(mpd.conn) == false) if (mpd_search_commit(mpd.conn) == false)
RETURN_ERROR_AND_RECOVER("mpd_search_commit"); RETURN_ERROR_AND_RECOVER("mpd_search_commit");
else { else {
len = json_printf(&out, "{ type: queuesearch, data: [ "); len = json_printf(&out, "{ type: queuesearch, data: [ ");
while((song = mpd_recv_song(mpd.conn)) != NULL) { while((song = mpd_recv_song(mpd.conn)) != NULL) {
entity_count ++; entity_count ++;
if(entity_count > offset && entity_count <= offset+MAX_ELEMENTS_PER_PAGE) { if (entity_count > offset && entity_count <= offset+MAX_ELEMENTS_PER_PAGE) {
if (entities_returned ++) len += json_printf(&out, ", "); if (entities_returned ++) len += json_printf(&out, ", ");
len += json_printf(&out, "{ type: song, id: %d, pos: %d, album: %Q, artist: %Q, duration: %d, title: %Q }", len += json_printf(&out, "{ type: song, id: %d, pos: %d, album: %Q, artist: %Q, duration: %d, title: %Q }",
mpd_song_get_id(song), mpd_song_get_id(song),

View File

@ -249,7 +249,7 @@ int main(int argc, char **argv) {
} }
} }
if(run_as_user != NULL) { if (run_as_user != NULL) {
printf("Droping privileges\n"); printf("Droping privileges\n");
struct passwd *pw; struct passwd *pw;
if ((pw = getpwnam(run_as_user)) == NULL) { if ((pw = getpwnam(run_as_user)) == NULL) {