Logo Search packages:      
Sourcecode: libmpdclient version File versions  Download package

bool mpd_song_feed ( struct mpd_song song,
const struct mpd_pair pair 
)

Parses the pair, adding its information to the specified mpd_song object.

Returns:
true if the pair was parsed and added to the song (or if the pair was not understood and ignored), false if this pair is the beginning of the next song

Definition at line 351 of file song.c.

References mpd_song::finished, mpd_song_feed(), mpd_song_set_pos(), mpd_pair::name, and mpd_pair::value.

Referenced by mpd_entity_feed(), mpd_recv_song(), and mpd_song_feed().

{
      enum mpd_tag_type tag_type;

      assert(song != NULL);
      assert(!song->finished);
      assert(pair != NULL);
      assert(pair->name != NULL);
      assert(pair->value != NULL);

      if (strcmp(pair->name, "file") == 0) {
#ifndef NDEBUG
            song->finished = true;
#endif
            return false;
      }

      if (*pair->value == 0)
            return true;

      tag_type = mpd_tag_name_parse(pair->name);
      if (tag_type != MPD_TAG_UNKNOWN) {
            mpd_song_add_tag(song, tag_type, pair->value);
            return true;
      }

      if (strcmp(pair->name, "Time") == 0)
            mpd_song_set_duration(song, atoi(pair->value));
      else if (strcmp(pair->name, "Last-Modified") == 0)
            mpd_song_set_last_modified(song, iso8601_datetime_parse(pair->value));
      else if (strcmp(pair->name, "Pos") == 0)
            mpd_song_set_pos(song, atoi(pair->value));
      else if (strcmp(pair->name, "Id") == 0)
            mpd_song_set_id(song, atoi(pair->value));

      return true;
}


Generated by  Doxygen 1.6.0   Back to index