summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 1678180)
raw | patch | inline | side by side (parent: 1678180)
author | Kalle Wallin <kaw@linux.se> | |
Sun, 5 Jun 2005 21:34:52 +0000 (21:34 +0000) | ||
committer | Kalle Wallin <kaw@linux.se> | |
Sun, 5 Jun 2005 21:34:52 +0000 (21:34 +0000) |
src/libmpdclient.c | patch | blob | history | |
src/libmpdclient.h | patch | blob | history |
diff --git a/src/libmpdclient.c b/src/libmpdclient.c
index e93b3947e9e4a5804c090a1f4be5bcd7f948be1a..bc1c1d6e709817eabe932b17672a8a0ff1c5c60a 100644 (file)
--- a/src/libmpdclient.c
+++ b/src/libmpdclient.c
}
#endif
-
-char * mpd_sanitizeArg(const char * arg) {
+static char * mpd_sanitizeArg(const char * arg) {
size_t i;
- int count=0;
char * ret;
-
- for(i=0;i<strlen(arg);i++) {
- if(arg[i]=='"' || arg[i]=='\\') count++;
+ register const char *c;
+ register char *rc;
+
+ /*
+ unsigned int count = 0;
+
+ c = arg;
+ for(i = strlen(arg); i != 0; --i) {
+ if(*c=='"' || *c=='\\') count++;
+ c++;
}
-
ret = malloc(strlen(arg)+count+1);
-
- count = 0;
- for(i=0;i<strlen(arg)+1;i++) {
- if(arg[i]=='"' || arg[i]=='\\') {
- ret[i+count] = '\\';
- count++;
- }
- ret[i+count] = arg[i];
+ */
+ /* instead of counting in that loop above, just
+ * use a bit more memory and half running time
+ */
+ ret = malloc(strlen(arg) * 2 + 1);
+
+ c = arg;
+ rc = ret;
+ for(i = strlen(arg)+1; i != 0; --i) {
+ if(*c=='"' || *c=='\\')
+ *rc++ = '\\';
+ *(rc++) = *(c++);
}
return ret;
song->title = NULL;
song->name = NULL;
song->date = NULL;
+ /* added by Qball */
+ song->genre = NULL;
+ song->composer = NULL;
+
song->time = MPD_SONG_NO_TIME;
song->pos = MPD_SONG_NO_NUM;
song->id = MPD_SONG_NO_ID;
if(song->track) free(song->track);
if(song->name) free(song->name);
if(song->date) free(song->date);
+ if(song->genre) free(song->genre);
+ if(song->composer) free(song->composer);
}
mpd_Song * mpd_newSong() {
if(song->track) ret->track = strdup(song->track);
if(song->name) ret->name = strdup(song->name);
if(song->date) ret->date = strdup(song->date);
+ if(song->genre) ret->genre= strdup(song->genre);
+ if(song->composer) ret->composer= strdup(song->composer);
ret->time = song->time;
ret->pos = song->pos;
ret->id = song->id;
strcmp(re->name, "Date") == 0) {
entity->info.song->date = strdup(re->value);
}
+ else if(!entity->info.song->genre &&
+ strcmp(re->name, "Genre") == 0) {
+ entity->info.song->genre = strdup(re->value);
+ }
+ else if(!entity->info.song->composer &&
+ strcmp(re->name, "Composer") == 0) {
+ entity->info.song->composer = strdup(re->value);
+ }
+
}
else if(entity->type == MPD_INFO_ENTITY_TYPE_DIRECTORY) {
}
diff --git a/src/libmpdclient.h b/src/libmpdclient.h
index 9298a09c28ed5e79c6f9c6c305db588caa954cbb..79a94d8ee3ea5ab35945bc56324de332cd5aa46e 100644 (file)
--- a/src/libmpdclient.h
+++ b/src/libmpdclient.h
char * name;
/* date */
char *date;
+
+ /* added by qball */
+ char *genre;
+ char *composer;
+
/* length of song in seconds, check that it is not MPD_SONG_NO_TIME */
int time;
/* if plchanges/playlistinfo/playlistid used, is the position of the
/* songNum of -1, means to display the whole list */
void mpd_sendPlaylistInfoCommand(mpd_Connection * connection, int songNum);
+/* songId of -1, means to display the whole list */
+void mpd_sendPlaylistIdCommand(mpd_Connection * connection, int songId);
+
/* use this to get the changes in the playlist since version _playlist_ */
void mpd_sendPlChangesCommand(mpd_Connection * connection, long long playlist);