changeset 1688:d6d8e3cd23c5

Branch merge.
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 06 Sep 2007 03:03:03 +0300
parents d158ce84fda7 (diff) 75b8e7737bcd (current diff)
children 4dfc5a28d681
files src/modplug/modplugbmp.cxx src/sid/xmms-sid.c
diffstat 28 files changed, 365 insertions(+), 395 deletions(-) [+]
line wrap: on
line diff
--- a/src/aac/src/libmp4.c	Thu Sep 06 02:52:33 2007 +0300
+++ b/src/aac/src/libmp4.c	Thu Sep 06 03:03:03 2007 +0300
@@ -329,11 +329,11 @@
     {
         g_free(mp4cb);
 
-        tuple_associate_string(ti, "title", vfs_get_metadata(mp4fh, "track-name"));
-        tuple_associate_string(ti, "album", vfs_get_metadata(mp4fh, "stream-name"));
+        tuple_associate_string(ti, FIELD_TITLE, NULL, vfs_get_metadata(mp4fh, "track-name"));
+        tuple_associate_string(ti, FIELD_ALBUM, NULL, vfs_get_metadata(mp4fh, "stream-name"));
 
-        tuple_associate_string(ti, "codec", "Advanced Audio Coding (AAC)");
-        tuple_associate_string(ti, "quality", "lossy");
+        tuple_associate_string(ti, FIELD_CODEC, NULL, "Advanced Audio Coding (AAC)");
+        tuple_associate_string(ti, FIELD_QUALITY, NULL, "lossy");
 
         vfs_fclose(mp4fh);
         return ti;
@@ -389,45 +389,45 @@
         faacDecClose(decoder);
 
         msDuration = ((float)numSamples * (float)(framesize - 1.0)/(float)samplerate) * 1000;
-        tuple_associate_int(ti, "length", msDuration);
+        tuple_associate_int(ti, FIELD_LENGTH, NULL, msDuration);
 
         mp4ff_meta_get_title(mp4file, &tmpval);
         if (tmpval)
         {
-            tuple_associate_string(ti, "title", tmpval);
+            tuple_associate_string(ti, FIELD_TITLE, NULL, tmpval);
             free(tmpval);
         }
 
         mp4ff_meta_get_album(mp4file, &tmpval);
         if (tmpval)
         {
-            tuple_associate_string(ti, "album", tmpval);
+            tuple_associate_string(ti, FIELD_ALBUM, NULL, tmpval);
             free(tmpval);
         }
 
         mp4ff_meta_get_artist(mp4file, &tmpval);
         if (tmpval)
         {
-            tuple_associate_string(ti, "artist", tmpval);
+            tuple_associate_string(ti, FIELD_ARTIST, NULL, tmpval);
             free(tmpval);
         }
 
         mp4ff_meta_get_genre(mp4file, &tmpval);
         if (tmpval)
         {
-            tuple_associate_string(ti, "genre", tmpval);
+            tuple_associate_string(ti, FIELD_GENRE, NULL, tmpval);
             free(tmpval);
         }
 
         mp4ff_meta_get_date(mp4file, &tmpval);
         if (tmpval)
         {
-            tuple_associate_int(ti, "year", atoi(tmpval));
+            tuple_associate_int(ti, FIELD_YEAR, NULL, atoi(tmpval));
             free(tmpval);
         }
 
-        tuple_associate_string(ti, "codec", "Advanced Audio Coding (AAC)");
-        tuple_associate_string(ti, "quality", "lossy");
+        tuple_associate_string(ti, FIELD_CODEC, NULL, "Advanced Audio Coding (AAC)");
+        tuple_associate_string(ti, FIELD_QUALITY, NULL, "lossy");
 
         free (mp4cb);
         vfs_fclose(mp4fh);
--- a/src/adplug/adplug-xmms.cc	Thu Sep 06 02:52:33 2007 +0300
+++ b/src/adplug/adplug-xmms.cc	Thu Sep 06 03:03:03 2007 +0300
@@ -694,16 +694,16 @@
   {
     Tuple *ti = tuple_new_from_filename(filename);
     if (! p->getauthor().empty())
-      tuple_associate_string(ti, "artist", p->getauthor().c_str());
+      tuple_associate_string(ti, FIELD_ARTIST, NULL, p->getauthor().c_str());
     if (! p->gettitle().empty())
-      tuple_associate_string(ti, "title", p->gettitle().c_str());
+      tuple_associate_string(ti, FIELD_TITLE, NULL, p->gettitle().c_str());
     else if (! p->getdesc().empty())
-      tuple_associate_string(ti, "title", p->getdesc().c_str());
+      tuple_associate_string(ti, FIELD_TITLE, NULL, p->getdesc().c_str());
     else
-      tuple_associate_string(ti, "title", g_path_get_basename(filename));
-    tuple_associate_string(ti, "codec", p->gettype().c_str());
-    tuple_associate_string(ti, "quality", "sequenced");
-    tuple_associate_int(ti, "length", p->songlength (plr.subsong));
+      tuple_associate_string(ti, FIELD_TITLE, NULL, g_path_get_basename(filename));
+    tuple_associate_string(ti, FIELD_CODEC, NULL, p->gettype().c_str());
+    tuple_associate_string(ti, FIELD_QUALITY, NULL, "sequenced");
+    tuple_associate_int(ti, FIELD_LENGTH, NULL, p->songlength (plr.subsong));
     delete p;
     return ti;
   }
@@ -715,7 +715,7 @@
 {
   char* result = tuple_formatter_make_title_string(ti, get_gentitle_format());
   if ( result )
-    *length = tuple_get_int(ti, "length");
+    *length = tuple_get_int(ti, FIELD_LENGTH, NULL);
   tuple_free((void *) ti);
 
   return result;
--- a/src/alac/plugin.c	Thu Sep 06 02:52:33 2007 +0300
+++ b/src/alac/plugin.c	Thu Sep 06 03:03:03 2007 +0300
@@ -122,20 +122,20 @@
     Tuple *ti = tuple_new_from_filename(path);
 
     if (demux_res->tuple.art != NULL)
-        tuple_associate_string(ti, "artist", demux_res->tuple.art);
+        tuple_associate_string(ti, FIELD_ARTIST, NULL, demux_res->tuple.art);
     if (demux_res->tuple.nam != NULL)
-        tuple_associate_string(ti, "title", demux_res->tuple.nam);
+        tuple_associate_string(ti, FIELD_TITLE, NULL, demux_res->tuple.nam);
     if (demux_res->tuple.alb != NULL)
-        tuple_associate_string(ti, "album", demux_res->tuple.alb);
+        tuple_associate_string(ti, FIELD_ALBUM, NULL, demux_res->tuple.alb);
     if (demux_res->tuple.gen != NULL)
-        tuple_associate_string(ti, "genre", demux_res->tuple.gen);
+        tuple_associate_string(ti, FIELD_GENRE, NULL, demux_res->tuple.gen);
     if (demux_res->tuple.cmt != NULL)
-        tuple_associate_string(ti, "comment", demux_res->tuple.cmt);
+        tuple_associate_string(ti, FIELD_COMMENT, NULL, demux_res->tuple.cmt);
     if (demux_res->tuple.day != NULL)
-        tuple_associate_int(ti, "year", atoi(demux_res->tuple.day));
+        tuple_associate_int(ti, FIELD_YEAR, NULL, atoi(demux_res->tuple.day));
 
-    tuple_associate_string(ti, "codec", "Apple Lossless (ALAC)");
-    tuple_associate_string(ti, "quality", "lossless");
+    tuple_associate_string(ti, FIELD_CODEC, NULL, "Apple Lossless (ALAC)");
+    tuple_associate_string(ti, FIELD_QUALITY, NULL, "lossless");
 
     return ti;
 }
--- a/src/console/Audacious_Driver.cxx	Thu Sep 06 02:52:33 2007 +0300
+++ b/src/console/Audacious_Driver.cxx	Thu Sep 06 03:03:03 2007 +0300
@@ -208,23 +208,23 @@
 	Tuple* ti = tuple_new();
 	if ( ti )
 	{
-		tuple_associate_string(ti, "file-name", g_path_get_basename(path));
-		tuple_associate_string(ti, "file-path", g_path_get_dirname(path));
-		tuple_associate_string(ti, "artist", info.author);
-		tuple_associate_string(ti, "album", info.game);
-		tuple_associate_string(ti, "game", info.game);
-		tuple_associate_string(ti, "title", info.song ? info.song : g_path_get_basename(path));
+		tuple_associate_string(ti, FIELD_FILE_NAME, NULL, g_path_get_basename(path));
+		tuple_associate_string(ti, FIELD_FILE_PATH, NULL, g_path_get_dirname(path));
+		tuple_associate_string(ti, FIELD_ARTIST, NULL, info.author);
+		tuple_associate_string(ti, FIELD_ALBUM, NULL, info.game);
+		tuple_associate_string(ti, -1, "game", info.game);
+		tuple_associate_string(ti, FIELD_TITLE, NULL, info.song ? info.song : g_path_get_basename(path));
 		if ( info.track_count > 1 )
 		{
-			tuple_associate_int(ti, "track-number", track + 1);
-			tuple_associate_int(ti, "subsong", track);
+			tuple_associate_int(ti, FIELD_TRACK_NUMBER, NULL, track + 1);
+			tuple_associate_int(ti, -1, "subsong", track);
 		}
-		tuple_associate_string(ti, "copyright", info.copyright);
-		tuple_associate_string(ti, "console", info.system);
-		tuple_associate_string(ti, "codec", info.system);
-		tuple_associate_string(ti, "quality", "sequenced");
-		tuple_associate_string(ti, "dumper", info.dumper);
-		tuple_associate_string(ti, "comment", info.comment);
+		tuple_associate_string(ti, FIELD_COPYRIGHT, NULL, info.copyright);
+		tuple_associate_string(ti, -1, "console", info.system);
+		tuple_associate_string(ti, FIELD_CODEC, NULL, info.system);
+		tuple_associate_string(ti, FIELD_QUALITY, NULL, "sequenced");
+		tuple_associate_string(ti, -1, "dumper", info.dumper);
+		tuple_associate_string(ti, FIELD_COMMENT, NULL, info.comment);
 
 		int length = info.length;
 		if ( length <= 0 )
@@ -233,7 +233,7 @@
 			length = audcfg.loop_length * 1000;
 		else if ( length >= fade_threshold )
 			length += fade_length;
-		tuple_associate_int(ti, "length", length);
+		tuple_associate_int(ti, FIELD_LENGTH, NULL, length);
 	}
 	return ti;
 }
@@ -242,7 +242,7 @@
 {
 	char* result = tuple_formatter_make_title_string(ti, get_gentitle_format());
 	if ( result )
-		*length = tuple_get_int(ti, "length");
+		*length = tuple_get_int(ti, FIELD_LENGTH, NULL);
 	tuple_free((void *) ti);
 
 	return result;
--- a/src/cue/cuesheet.c	Thu Sep 06 02:52:33 2007 +0300
+++ b/src/cue/cuesheet.c	Thu Sep 06 03:03:03 2007 +0300
@@ -240,11 +240,11 @@
 	return get_tuple_uri(uri);
 }
 
-static void _tuple_copy_field(Tuple *tuple, Tuple *tuple2, const gchar *field)
+static void _tuple_copy_field(Tuple *tuple, Tuple *tuple2, const gint nfield, const gchar *field)
 {
-    const gchar *str = tuple_get_string(tuple, field);
-    tuple_disassociate(tuple2, field);
-    tuple_associate_string(tuple2, field, str);
+    const gchar *str = tuple_get_string(tuple, nfield, field);
+    tuple_disassociate(tuple2, nfield, field);
+    tuple_associate_string(tuple2, nfield, field, str);
 }
 
 static Tuple *get_tuple_uri(gchar *uri)
@@ -289,26 +289,26 @@
 
     out = tuple_new();
 
-    _tuple_copy_field(phys_tuple, out, "file-path");
-    _tuple_copy_field(phys_tuple, out, "file-name");
-    _tuple_copy_field(phys_tuple, out, "file-ext");
-    _tuple_copy_field(phys_tuple, out, "codec");
-    _tuple_copy_field(phys_tuple, out, "quality");
-    _tuple_copy_field(phys_tuple, out, "copyright");
-    _tuple_copy_field(phys_tuple, out, "comment");
+    _tuple_copy_field(phys_tuple, out, FIELD_FILE_PATH, NULL);
+    _tuple_copy_field(phys_tuple, out, FIELD_FILE_NAME, NULL);
+    _tuple_copy_field(phys_tuple, out, FIELD_FILE_EXT, NULL);
+    _tuple_copy_field(phys_tuple, out, FIELD_CODEC, NULL);
+    _tuple_copy_field(phys_tuple, out, FIELD_QUALITY, NULL);
+    _tuple_copy_field(phys_tuple, out, FIELD_COPYRIGHT, NULL);
+    _tuple_copy_field(phys_tuple, out, FIELD_COMMENT, NULL);
 
-    tuple_associate_int(out, "length", tuple_get_int(phys_tuple, "length"));
+    tuple_associate_int(out, FIELD_LENGTH, NULL, tuple_get_int(phys_tuple, FIELD_LENGTH, NULL));
 
     tuple_free(phys_tuple);
 
-    tuple_associate_string(out, "title", cue_tracks[track].title);
-    tuple_associate_string(out, "artist", cue_tracks[track].performer ?
+    tuple_associate_string(out, FIELD_TITLE, NULL, cue_tracks[track].title);
+    tuple_associate_string(out, FIELD_ARTIST, NULL, cue_tracks[track].performer ?
 				  cue_tracks[track].performer : cue_performer);
-    tuple_associate_string(out, "album", cue_title);
-    tuple_associate_string(out, "genre", cue_genre);
+    tuple_associate_string(out, FIELD_ALBUM, NULL, cue_title);
+    tuple_associate_string(out, FIELD_GENRE, NULL, cue_genre);
     if(cue_year)
-        tuple_associate_int(out, "year", atoi(cue_year));
-    tuple_associate_int(out, "track-number", track + 1);
+        tuple_associate_int(out, FIELD_YEAR, NULL, atoi(cue_year));
+    tuple_associate_int(out, FIELD_TRACK_NUMBER, NULL, track + 1);
 
     return out;
 }
@@ -330,7 +330,7 @@
 	g_return_if_fail(tuple != NULL);
 
 	*title = tuple_formatter_make_title_string(tuple, get_gentitle_format());
-	*length = tuple_get_int(tuple, "length");
+	*length = tuple_get_int(tuple, FIELD_LENGTH, NULL);
 
 	tuple_free(tuple);
 }
--- a/src/filewriter/filewriter.c	Thu Sep 06 02:52:33 2007 +0300
+++ b/src/filewriter/filewriter.c	Thu Sep 06 03:03:03 2007 +0300
@@ -189,6 +189,7 @@
 static gint file_open(AFormat fmt, gint rate, gint nch)
 {
     gchar *filename = NULL, *temp = NULL;
+    const gchar *directory;
     gint pos;
     gint rv;
     Playlist *playlist;
@@ -228,7 +229,7 @@
     }
     if (filename == NULL)
     {
-        filename = g_strdup(tuple_get_string(tuple, "file-name"));
+        filename = g_strdup(tuple_get_string(tuple, FIELD_FILE_NAME, NULL));
         if (!use_suffix)
             if ((temp = strrchr(filename, '.')) != NULL)
                 *temp = '\0';
@@ -239,10 +240,8 @@
 
     if (prependnumber)
     {
-        gint number;
-        if (tuple && tuple_get_int(tuple, "track-number"))
-            number = tuple_get_int(tuple, "track-number");
-        else
+        gint number = tuple_get_int(tuple, FIELD_TRACK_NUMBER, NULL);
+        if (!tuple || !number)
             number = pos + 1;
 
         temp = g_strdup_printf("%.02d %s", number, filename);
@@ -250,15 +249,13 @@
         filename = temp;
     }
 
-    gchar *directory;
     if (save_original)
-        directory = g_strdup(tuple_get_string(tuple, "file-path"));
+        directory = tuple_get_string(tuple, FIELD_FILE_PATH, NULL);
     else
-        directory = g_strdup(file_path);
+        directory = file_path;
 
     temp = g_strdup_printf("file://%s/%s.%s",
                            directory, filename, fileext_str[fileext]);
-    g_free(directory);
     g_free(filename);
     filename = temp;
 
--- a/src/filewriter/flac.c	Thu Sep 06 02:52:33 2007 +0300
+++ b/src/filewriter/flac.c	Thu Sep 06 03:03:03 2007 +0300
@@ -107,14 +107,14 @@
 
         meta = FLAC__metadata_object_new(FLAC__METADATA_TYPE_VORBIS_COMMENT);
 
-        INSERT_VORBIS_COMMENT(tuple_get_string(tuple, "title"), "title=%s");
-        INSERT_VORBIS_COMMENT(tuple_get_string(tuple, "artist"), "artist=%s");
-        INSERT_VORBIS_COMMENT(tuple_get_string(tuple, "album"), "album=%s");
-        INSERT_VORBIS_COMMENT(tuple_get_string(tuple, "genre"), "genre=%s");
-        INSERT_VORBIS_COMMENT(tuple_get_string(tuple, "comment"), "comment=%s");
-        INSERT_VORBIS_COMMENT(tuple_get_string(tuple, "date"), "date=%s");
-        INSERT_VORBIS_COMMENT(tuple_get_int(tuple, "year"), "year=%d");
-        INSERT_VORBIS_COMMENT(tuple_get_int(tuple, "track-number"), "tracknumber=%d");
+        INSERT_VORBIS_COMMENT(tuple_get_string(tuple, FIELD_TITLE, NULL), "title=%s");
+        INSERT_VORBIS_COMMENT(tuple_get_string(tuple, FIELD_ARTIST, NULL), "artist=%s");
+        INSERT_VORBIS_COMMENT(tuple_get_string(tuple, FIELD_ALBUM, NULL), "album=%s");
+        INSERT_VORBIS_COMMENT(tuple_get_string(tuple, FIELD_GENRE, NULL), "genre=%s");
+        INSERT_VORBIS_COMMENT(tuple_get_string(tuple, FIELD_COMMENT, NULL), "comment=%s");
+        INSERT_VORBIS_COMMENT(tuple_get_string(tuple, FIELD_DATE, NULL), "date=%s");
+        INSERT_VORBIS_COMMENT(tuple_get_int(tuple, FIELD_YEAR, NULL), "year=%d");
+        INSERT_VORBIS_COMMENT(tuple_get_int(tuple, FIELD_TRACK_NUMBER, NULL), "tracknumber=%d");
 
         FLAC__stream_encoder_set_metadata(flac_encoder, &meta, 1);
     }
--- a/src/filewriter/mp3.c	Thu Sep 06 02:52:33 2007 +0300
+++ b/src/filewriter/mp3.c	Thu Sep 06 03:03:03 2007 +0300
@@ -207,24 +207,24 @@
     if (tuple) {
         /* XXX write UTF-8 even though libmp3lame does id3v2.3. --yaz */
 #ifdef DEBUG
-        g_print("track_name = %s\n", tuple_get_string(tuple, "title"));
+        g_print("track_name = %s\n", tuple_get_string(tuple, FIELD_TITLE, NULL));
 #endif
-        lameid3.track_name = g_strdup(tuple_get_string(tuple, "title"));
+        lameid3.track_name = g_strdup(tuple_get_string(tuple, FIELD_TITLE, NULL));
         id3tag_set_title(gfp, lameid3.track_name);
 
-        lameid3.performer = g_strdup(tuple_get_string(tuple, "artist"));
+        lameid3.performer = g_strdup(tuple_get_string(tuple, FIELD_ARTIST, NULL));
         id3tag_set_artist(gfp, lameid3.performer);
 
-        lameid3.album_name = g_strdup(tuple_get_string(tuple, "album"));
+        lameid3.album_name = g_strdup(tuple_get_string(tuple, FIELD_ALBUM, NULL));
         id3tag_set_album(gfp, lameid3.album_name);
 
-        lameid3.genre = g_strdup(tuple_get_string(tuple, "genre"));
+        lameid3.genre = g_strdup(tuple_get_string(tuple, FIELD_GENRE, NULL));
         id3tag_set_genre(gfp, lameid3.genre);
 
-        lameid3.year = g_strdup_printf("%d", tuple_get_int(tuple, "year"));
+        lameid3.year = g_strdup_printf("%d", tuple_get_int(tuple, FIELD_YEAR, NULL));
         id3tag_set_year(gfp, lameid3.year);
 
-        lameid3.track_number = g_strdup_printf("%d", tuple_get_int(tuple, "track-number"));
+        lameid3.track_number = g_strdup_printf("%d", tuple_get_int(tuple, FIELD_TRACK_NUMBER, NULL));
         id3tag_set_track(gfp, lameid3.track_number);
 
         //        id3tag_write_v1(gfp);
--- a/src/filewriter/vorbis.c	Thu Sep 06 02:52:33 2007 +0300
+++ b/src/filewriter/vorbis.c	Thu Sep 06 03:03:03 2007 +0300
@@ -85,32 +85,32 @@
     if (tuple)
     {
         const gchar *scratch;
+        gchar tmpstr[32];
+        gint scrint;
 
-        if ((scratch = tuple_get_string(tuple, "title")))
+        if ((scratch = tuple_get_string(tuple, FIELD_TITLE, NULL)))
             vorbis_comment_add_tag(&vc, "title", (gchar *) scratch);
-        if ((scratch = tuple_get_string(tuple, "artist")))
+        if ((scratch = tuple_get_string(tuple, FIELD_ARTIST, NULL)))
             vorbis_comment_add_tag(&vc, "artist", (gchar *) scratch);
-        if ((scratch = tuple_get_string(tuple, "album")))
+        if ((scratch = tuple_get_string(tuple, FIELD_ALBUM, NULL)))
             vorbis_comment_add_tag(&vc, "album", (gchar *) scratch);
-        if ((scratch = tuple_get_string(tuple, "genre")))
+        if ((scratch = tuple_get_string(tuple, FIELD_GENRE, NULL)))
             vorbis_comment_add_tag(&vc, "genre", (gchar *) scratch);
-        if ((scratch = tuple_get_string(tuple, "date")))
+        if ((scratch = tuple_get_string(tuple, FIELD_DATE, NULL)))
             vorbis_comment_add_tag(&vc, "date", (gchar *) scratch);
-        if ((scratch = tuple_get_string(tuple, "comment")))
+        if ((scratch = tuple_get_string(tuple, FIELD_COMMENT, NULL)))
             vorbis_comment_add_tag(&vc, "comment", (gchar *) scratch);
 
-        if (tuple_get_int(tuple, "track-number"))
+        if ((scrint = tuple_get_int(tuple, FIELD_TRACK_NUMBER, NULL)))
         {
-            gchar *tmp = g_strdup_printf("%d", tuple_get_int(tuple, "track-number"));
-            vorbis_comment_add_tag(&vc, "tracknumber", tmp);
-            g_free(tmp);
+            g_snprintf(tmpstr, sizeof(tmpstr), "%d", scrint);
+            vorbis_comment_add_tag(&vc, "tracknumber", tmpstr);
         }
 
-        if (tuple_get_int(tuple, "year"))
+        if ((scrint = tuple_get_int(tuple, FIELD_YEAR, NULL)))
         {
-            gchar *tmp = g_strdup_printf("%d", tuple_get_int(tuple, "year"));
-            vorbis_comment_add_tag(&vc, "year", tmp);
-            g_free(tmp);
+            g_snprintf(tmpstr, sizeof(tmpstr), "%d", scrint);
+            vorbis_comment_add_tag(&vc, "year", tmpstr);
         }
     }
 
--- a/src/flacng/tools.c	Thu Sep 06 02:52:33 2007 +0300
+++ b/src/flacng/tools.c	Thu Sep 06 03:03:03 2007 +0300
@@ -241,29 +241,29 @@
 
     out = tuple_new_from_filename(filename);
 
-    tuple_associate_string(out, "codec", "Free Lossless Audio Codec (FLAC)");
-    tuple_associate_string(out, "quality", "lossless");
+    tuple_associate_string(out, FIELD_CODEC, NULL, "Free Lossless Audio Codec (FLAC)");
+    tuple_associate_string(out, FIELD_CODEC, NULL, "lossless");
 
-    tuple_associate_string(out, "artist", info->comment.artist);
-    tuple_associate_string(out, "title", info->comment.title);
-    tuple_associate_string(out, "album", info->comment.album);
-    tuple_associate_string(out, "genre", info->comment.genre);
+    tuple_associate_string(out, FIELD_ARTIST, NULL, info->comment.artist);
+    tuple_associate_string(out, FIELD_TITLE, NULL, info->comment.title);
+    tuple_associate_string(out, FIELD_ALBUM, NULL, info->comment.album);
+    tuple_associate_string(out, FIELD_GENRE, NULL, info->comment.genre);
 
     if (info->comment.tracknumber != NULL)
-        tuple_associate_int(out, "track-number", atoi(info->comment.tracknumber));
+        tuple_associate_int(out, FIELD_TRACK_NUMBER, NULL, atoi(info->comment.tracknumber));
 
     if (info->comment.date != NULL)
-        tuple_associate_int(out, "year", atoi(info->comment.date));
+        tuple_associate_int(out, FIELD_YEAR, NULL, atoi(info->comment.date));
 
     /*
      * Calculate the stream length (milliseconds)
      */
     if (0 == info->stream.samplerate) {
         _ERROR("Invalid sample rate for stream!");
-        tuple_associate_int(out, "length", -1);
+        tuple_associate_int(out, FIELD_LENGTH, NULL, -1);
     } else {
-        tuple_associate_int(out, "length", (info->stream.samples / info->stream.samplerate) * 1000);
-        _DEBUG("Stream length: %d seconds", tuple_get_int(out, "length"));
+        tuple_associate_int(out, FIELD_LENGTH, NULL, (info->stream.samples / info->stream.samplerate) * 1000);
+        _DEBUG("Stream length: %d seconds", tuple_get_int(out, FIELD_LENGTH, NULL));
     }
 
     _DEBUG("Tuple created: [%p]", out);
--- a/src/madplug/decoder.c	Thu Sep 06 02:52:33 2007 +0300
+++ b/src/madplug/decoder.c	Thu Sep 06 03:03:03 2007 +0300
@@ -192,7 +192,7 @@
     info->duration = mad_timer_zero; // should be cleared before loop, if we use it as break condition.
 
     if(info->fileinfo_request == TRUE) {
-        tuple_associate_int(info->tuple, "length", -1);
+        tuple_associate_int(info->tuple, FIELD_LENGTH, NULL, -1);
         info->fileinfo_request = FALSE;
     }
 
@@ -270,10 +270,10 @@
             g_message("size = %d", stream.next_frame - stream.this_frame);
 #endif
 #endif
-            if(tuple_get_int(info->tuple, "length") == -1)
+            if(tuple_get_int(info->tuple, FIELD_LENGTH, NULL) == -1)
                 mad_timer_add(&info->duration, header.duration);
             else {
-                gint length = tuple_get_int(info->tuple, "length");
+                gint length = tuple_get_int(info->tuple, FIELD_LENGTH, NULL);
 
                 info->duration.seconds = length / 1000;
                 info->duration.fraction = length % 1000;
@@ -357,7 +357,7 @@
 #ifdef DEBUG
                 g_message("info->frames = %d", info->frames);
 #endif
-                if(tuple_get_int(info->tuple, "length") == -1) {
+                if(tuple_get_int(info->tuple, FIELD_LENGTH, NULL) == -1) {
                     if(xing_bitrate > 0.0) {
                         /* calc duration with xing info */
                         double tmp = 8 * (double)info->xing.bytes * 1000 / xing_bitrate;
@@ -371,7 +371,7 @@
                     }
                 }
                 else {
-                    gint length = tuple_get_int(info->tuple, "length");
+                    gint length = tuple_get_int(info->tuple, FIELD_LENGTH, NULL);
 
                     info->duration.seconds = length / 1000;
                     info->duration.fraction = length % 1000;
--- a/src/madplug/input.c	Thu Sep 06 02:52:33 2007 +0300
+++ b/src/madplug/input.c	Thu Sep 06 03:03:03 2007 +0300
@@ -322,12 +322,12 @@
     return rtn;
 }
 
-static void input_set_and_free_tag(struct id3_tag *tag, Tuple *tuple, const gchar *frame, const gchar *tuple_name)
+static void input_set_and_free_tag(struct id3_tag *tag, Tuple *tuple, const gchar *frame, const gint nfield)
 {
     gchar *scratch = input_id3_get_string(tag, frame);
 
-    tuple_associate_string(tuple, tuple_name, scratch);
-    tuple_associate_string(tuple, frame, scratch);
+    tuple_associate_string(tuple, nfield, NULL, scratch);
+    tuple_associate_string(tuple, -1, frame, scratch);
 
     g_free(scratch);
 }
@@ -339,7 +339,7 @@
     if (info->tuple == NULL) {
         tuple = tuple_new();
         info->tuple = tuple;
-        tuple_associate_int(info->tuple, "length", -1);
+        tuple_associate_int(info->tuple, FIELD_LENGTH, NULL, -1);
     }
 }
 
@@ -349,19 +349,17 @@
 static void input_read_tag(struct mad_info_t *info)
 {
     gchar *string = NULL;
-    gchar *realfn = NULL;
     Tuple *tuple;
     glong curpos = 0;
 
 #ifdef DEBUG
     g_message("f: input_read_tag");
 #endif
-    if (info->tuple == NULL) {
-        tuple = tuple_new();
-        info->tuple = tuple;
-    }
-    else
-        tuple = info->tuple;
+    if (info->tuple != NULL)
+        tuple_free(info->tuple);
+        
+    tuple = tuple_new_from_filename(info->filename);
+    info->tuple = tuple;
 
     if(info->infile) {
         curpos = vfs_ftell(info->infile);
@@ -386,15 +384,15 @@
         return;
     }
 
-    input_set_and_free_tag(info->tag, tuple, ID3_FRAME_ARTIST, "artist");
-    input_set_and_free_tag(info->tag, tuple, ID3_FRAME_TITLE, "title");
-    input_set_and_free_tag(info->tag, tuple, ID3_FRAME_ALBUM, "album");
-    input_set_and_free_tag(info->tag, tuple, ID3_FRAME_GENRE, "genre");
-    input_set_and_free_tag(info->tag, tuple, ID3_FRAME_COMMENT, "comment");
+    input_set_and_free_tag(info->tag, tuple, ID3_FRAME_ARTIST, FIELD_ARTIST);
+    input_set_and_free_tag(info->tag, tuple, ID3_FRAME_TITLE, FIELD_TITLE);
+    input_set_and_free_tag(info->tag, tuple, ID3_FRAME_ALBUM, FIELD_ALBUM);
+    input_set_and_free_tag(info->tag, tuple, ID3_FRAME_GENRE, FIELD_GENRE);
+    input_set_and_free_tag(info->tag, tuple, ID3_FRAME_COMMENT, FIELD_COMMENT);
 
     string = input_id3_get_string(info->tag, ID3_FRAME_TRACK);
     if (string) {
-        tuple_associate_int(tuple, "track-number", atoi(string));
+        tuple_associate_int(tuple, FIELD_TRACK_NUMBER, NULL, atoi(string));
         g_free(string);
         string = NULL;
     }
@@ -406,7 +404,7 @@
         string = input_id3_get_string(info->tag, "TYER");
 
     if (string) {
-        tuple_associate_int(tuple, "year", atoi(string));
+        tuple_associate_int(tuple, FIELD_YEAR, NULL, atoi(string));
         g_free(string);
         string = NULL;
     }
@@ -414,7 +412,7 @@
     // length
     string = input_id3_get_string(info->tag, "TLEN");
     if (string) {
-        tuple_associate_int(tuple, "length", atoi(string));
+        tuple_associate_int(tuple, FIELD_LENGTH, NULL, atoi(string));
 #ifdef DEBUG
         g_message("input_read_tag: TLEN = %d", atoi(string));
 #endif	
@@ -422,25 +420,8 @@
         string = NULL;
     }
     
-    realfn = g_filename_from_uri(info->filename, NULL, NULL);
-    
-    string = g_strdup(g_basename(realfn ? realfn : info->filename));
-    tuple_associate_string(tuple, "file-name", string);
-    g_free(string);
-
-    string = g_path_get_dirname(realfn ? realfn : info->filename);
-    tuple_associate_string(tuple, "file-path", string);
-    g_free(string);
-
-    if ((string = strrchr(realfn ? realfn : info->filename, '.'))) {
-        *string = '\0';         // make filename end at dot.
-        tuple_associate_string(tuple, "file-ext", string + 1);
-    }
-
-    g_free(realfn); realfn = NULL;
-
-    tuple_associate_string(tuple, "codec", "MPEG Audio (MP3)");
-    tuple_associate_string(tuple, "quality", "lossy");
+    tuple_associate_string(tuple, FIELD_CODEC, NULL, "MPEG Audio (MP3)");
+    tuple_associate_string(tuple, FIELD_QUALITY, NULL, "lossy");
 
     info->title = tuple_formatter_make_title_string(tuple, audmad_config.title_override == TRUE ?
         audmad_config.id3_format : get_gentitle_format());
@@ -470,8 +451,8 @@
 
         g_free(info->title);
         info->title = NULL;
-        tuple_disassociate(info->tuple, "title");
-        tuple_disassociate(info->tuple, "album");
+        tuple_disassociate(info->tuple, FIELD_TITLE, NULL);
+        tuple_disassociate(info->tuple, FIELD_ALBUM, NULL);
 
         tmp = vfs_get_metadata(info->infile, "track-name");
         if(tmp){
@@ -479,7 +460,7 @@
             gchar *scratch;
 
             scratch = str_to_utf8(tmp);
-            tuple_associate_string(info->tuple, "title", scratch);
+            tuple_associate_string(info->tuple, FIELD_TITLE, NULL, scratch);
             g_free(scratch);
 
             g_free(tmp);
@@ -492,8 +473,8 @@
             gchar *scratch;
 
             scratch = str_to_utf8(tmp);
-            tuple_associate_string(info->tuple, "album", scratch);
-            tuple_associate_string(info->tuple, "stream", scratch);
+            tuple_associate_string(info->tuple, FIELD_ALBUM, NULL, scratch);
+            tuple_associate_string(info->tuple, -1, "stream", scratch);
             g_free(scratch);
 
             g_free(tmp);
--- a/src/madplug/plugin.c	Thu Sep 06 02:52:33 2007 +0300
+++ b/src/madplug/plugin.c	Thu Sep 06 03:03:03 2007 +0300
@@ -516,14 +516,14 @@
     }
 
     if (input_get_info(&myinfo, info.remote ? TRUE : audmad_config.fast_play_time_calc) == TRUE) {
-        if(tuple_get_string(myinfo.tuple, "track-name"))
-            *title = g_strdup(tuple_get_string(myinfo.tuple, "track-name"));
+        if(tuple_get_string(myinfo.tuple, -1, "track-name"))
+            *title = g_strdup(tuple_get_string(myinfo.tuple, -1, "track-name"));
         else
             *title = g_strdup(url);
-        if(tuple_get_int(myinfo.tuple, "length") == -1)
+        if(tuple_get_int(myinfo.tuple, FIELD_LENGTH, NULL) == -1)
             *length = mad_timer_count(myinfo.duration, MAD_UNITS_MILLISECONDS);
         else
-            *length = tuple_get_int(myinfo.tuple, "length");
+            *length = tuple_get_int(myinfo.tuple, FIELD_LENGTH, NULL);
     }
     else {
         *title = g_strdup(url);
@@ -553,10 +553,10 @@
     }
 
     if (input_get_info(&myinfo, info.remote ? TRUE : audmad_config.fast_play_time_calc) == TRUE) {
-        if(tuple_get_int(myinfo.tuple, "length") == -1)
+        if(tuple_get_int(myinfo.tuple, FIELD_LENGTH, NULL) == -1)
             *length = mad_timer_count(myinfo.duration, MAD_UNITS_MILLISECONDS);
         else
-            *length = tuple_get_int(myinfo.tuple, "length");
+            *length = tuple_get_int(myinfo.tuple, FIELD_LENGTH, NULL);
     }
     else {
         *length = -1;
@@ -629,9 +629,9 @@
 extern void audmad_get_file_info(char *filename);
 extern void audmad_configure();
 
-static void __set_and_free(Tuple *tuple, gchar *name, gchar *value)
+static void __set_and_free(Tuple *tuple, gint nfield, gchar *name, gchar *value)
 {
-    tuple_associate_string(tuple, name, value);
+    tuple_associate_string(tuple, nfield, name, value);
     g_free(value);
 }
 
@@ -657,7 +657,7 @@
     if(info.remote && mad_timer_count(info.duration, MAD_UNITS_SECONDS) <= 0){
         if((fd && vfs_is_streaming(fd)) || (info.playback && info.playback->playing)) {
             gchar *tmp = NULL;
-            tuple = tuple_new();
+            tuple = tuple_new_from_filename(filename);
 
 #ifdef DEBUG
             if(info.playback)
@@ -668,7 +668,7 @@
                 gchar *scratch;
 
                 scratch = str_to_utf8(tmp);
-                tuple_associate_string(tuple, "title", scratch);
+                tuple_associate_string(tuple, FIELD_TITLE, NULL, scratch);
                 g_free(tmp);
                 g_free(scratch);
 
@@ -679,7 +679,7 @@
                 gchar *scratch;
 
                 scratch = str_to_utf8(tmp);
-                tuple_associate_string(tuple, "title", scratch);
+                tuple_associate_string(tuple, FIELD_TITLE, NULL, scratch);
                 g_free(tmp);
                 g_free(scratch);
 
@@ -687,17 +687,11 @@
             }
 
 #ifdef DEBUG
-            g_message("audmad_get_song_tuple: track_name = %s", tuple_get_string(tuple, "track-name"));
-            g_message("audmad_get_song_tuple: stream_name = %s", tuple_get_string(tuple, "stream-name"));
+            g_message("audmad_get_song_tuple: track_name = %s", tuple_get_string(tuple, -1, "track-name"));
+            g_message("audmad_get_song_tuple: stream_name = %s", tuple_get_string(tuple, -1, "stream-name"));
 #endif
-            realfn = g_filename_from_uri(filename, NULL, NULL);
-            __set_and_free(tuple, "file-name", g_path_get_basename(realfn ? realfn : filename));
-            __set_and_free(tuple, "file-path", g_path_get_dirname(realfn ? realfn : filename));
-            tuple_associate_string(tuple, "file-ext", extname(realfn ? realfn : filename));
-            g_free(realfn); realfn = NULL;
-
-            tuple_associate_int(tuple, "length", -1);
-            tuple_associate_int(tuple, "mtime", 0); // this indicates streaming
+            tuple_associate_int(tuple, FIELD_LENGTH, NULL, -1);
+            tuple_associate_int(tuple, FIELD_MTIME, NULL, 0); // this indicates streaming
 #ifdef DEBUG
             g_message("get_song_tuple: remote: tuple");
 #endif
@@ -718,7 +712,7 @@
     }
 
     tuple = tuple_new();
-    tuple_associate_int(tuple, "length", -1);
+    tuple_associate_int(tuple, FIELD_LENGTH, NULL, -1);
 
     id3file = id3_file_vfsopen(fd, ID3_FILE_MODE_READONLY);
 
@@ -726,9 +720,9 @@
 
         tag = id3_file_tag(id3file);
         if (tag) {
-            __set_and_free(tuple, "artist", input_id3_get_string(tag, ID3_FRAME_ARTIST));
-            __set_and_free(tuple, "album", input_id3_get_string(tag, ID3_FRAME_ALBUM));
-            __set_and_free(tuple, "title", input_id3_get_string(tag, ID3_FRAME_TITLE));
+            __set_and_free(tuple, FIELD_ARTIST, NULL, input_id3_get_string(tag, ID3_FRAME_ARTIST));
+            __set_and_free(tuple, FIELD_ALBUM, NULL, input_id3_get_string(tag, ID3_FRAME_ALBUM));
+            __set_and_free(tuple, FIELD_TITLE, NULL, input_id3_get_string(tag, ID3_FRAME_TITLE));
 
             // year
             string = NULL;
@@ -737,22 +731,22 @@
                 string = input_id3_get_string(tag, "TYER");
 
             if (string) {
-                tuple_associate_int(tuple, "year", atoi(string));
+                tuple_associate_int(tuple, FIELD_YEAR, NULL, atoi(string));
                 g_free(string);
                 string = NULL;
             }
             realfn = g_filename_from_uri(filename, NULL, NULL);
-            __set_and_free(tuple, "file-name", g_path_get_basename(realfn ? realfn : filename));
-            __set_and_free(tuple, "file-path", g_path_get_dirname(realfn ? realfn : filename));
-            tuple_associate_string(tuple, "file-ext", extname(realfn ? realfn : filename));
+            __set_and_free(tuple, FIELD_FILE_NAME, NULL, g_path_get_basename(realfn ? realfn : filename));
+            __set_and_free(tuple, FIELD_FILE_PATH, NULL, g_path_get_dirname(realfn ? realfn : filename));
+            tuple_associate_string(tuple, FIELD_FILE_EXT, NULL, extname(realfn ? realfn : filename));
             g_free(realfn); realfn = NULL;
 
             // length
             string = input_id3_get_string(tag, "TLEN");
             if (string) {
-                tuple_associate_int(tuple, "length", atoi(string));
+                tuple_associate_int(tuple, FIELD_LENGTH, NULL, atoi(string));
 #ifdef DEBUG
-                g_message("get_song_tuple: TLEN = %d", tuple_get_int(tuple, "length"));
+                g_message("get_song_tuple: TLEN = %d", tuple_get_int(tuple, FIELD_LENGTH, NULL));
 #endif
                 g_free(string);
                 string = NULL;
@@ -761,46 +755,46 @@
                 char *dummy = NULL;
                 int length = 0;
                 audmad_get_song_length(filename, &length, fd);
-                tuple_associate_int(tuple, "length", length);
+                tuple_associate_int(tuple, FIELD_LENGTH, NULL, length);
                 g_free(dummy);
             }
 
             // track number
             string = input_id3_get_string(tag, ID3_FRAME_TRACK);
             if (string) {
-                tuple_associate_int(tuple, "track-number", atoi(string));
+                tuple_associate_int(tuple, FIELD_TRACK_NUMBER, NULL, atoi(string));
                 g_free(string);
                 string = NULL;
             }
             // genre
-            __set_and_free(tuple, "genre", input_id3_get_string(tag, ID3_FRAME_GENRE));
-            __set_and_free(tuple, "comment", input_id3_get_string(tag, ID3_FRAME_COMMENT));
+            __set_and_free(tuple, FIELD_GENRE, NULL, input_id3_get_string(tag, ID3_FRAME_GENRE));
+            __set_and_free(tuple, FIELD_COMMENT, NULL, input_id3_get_string(tag, ID3_FRAME_COMMENT));
 #ifdef DEBUG
-            g_message("genre = %s", tuple_get_string(tuple, "genre"));
+            g_message("genre = %s", tuple_get_string(tuple, FIELD_GENRE, NULL));
 #endif
         }
         id3_file_close(id3file);
     } // id3file
     else { // no id3tag
         realfn = g_filename_from_uri(filename, NULL, NULL);
-        __set_and_free(tuple, "file-name", g_path_get_basename(realfn ? realfn : filename));
-        __set_and_free(tuple, "file-path", g_path_get_dirname(realfn ? realfn : filename));
-        tuple_associate_string(tuple, "file-ext", extname(realfn ? realfn : filename));
+        __set_and_free(tuple, FIELD_FILE_NAME, NULL, g_path_get_basename(realfn ? realfn : filename));
+        __set_and_free(tuple, FIELD_FILE_PATH, NULL, g_path_get_dirname(realfn ? realfn : filename));
+        tuple_associate_string(tuple, FIELD_FILE_EXT, NULL, extname(realfn ? realfn : filename));
         g_free(realfn); realfn = NULL;
         // length
         {
             char *dummy = NULL;
             int length = 0;
-            if(tuple_get_int(tuple, "length") == -1) {
+            if(tuple_get_int(tuple, FIELD_LENGTH, NULL) == -1) {
                 audmad_get_song_length(filename, &length, fd);
-                tuple_associate_int(tuple, "length", length);
+                tuple_associate_int(tuple, FIELD_LENGTH, NULL, length);
             }
             g_free(dummy);
         }
     }
 
-    tuple_associate_string(tuple, "quality", "lossy");
-    tuple_associate_string(tuple, "codec", "MPEG Audio (MP3)");
+    tuple_associate_string(tuple, FIELD_QUALITY, NULL, "lossy");
+    tuple_associate_string(tuple, FIELD_CODEC, NULL, "MPEG Audio (MP3)");
 
     if(local_fd)
         vfs_fclose(fd);
--- a/src/modplug/modplugbmp.cxx	Thu Sep 06 02:52:33 2007 +0300
+++ b/src/modplug/modplugbmp.cxx	Thu Sep 06 03:03:03 2007 +0300
@@ -26,7 +26,7 @@
 {
         char* result = tuple_formatter_make_title_string(ti, get_gentitle_format());
         if ( result )
-                *length = tuple_get_int(ti, "length");
+                *length = tuple_get_int(ti, FIELD_LENGTH, NULL);
         tuple_free((void *) ti);
 
         return result;
@@ -519,7 +519,7 @@
 	Tuple *ti = tuple_new_from_filename(aFilename.c_str());
 	lSoundFile = new CSoundFile;
 	lSoundFile->Create((uchar*)lArchive->Map(), lArchive->Size());
-
+	
 	switch(lSoundFile->GetType())
         {
 	case MOD_TYPE_MOD:	tmps = "ProTracker"; break;
@@ -545,19 +545,18 @@
 	case MOD_TYPE_PSM:	tmps = "Protracker Studio Module"; break;
 	default:		tmps = "ModPlug unknown"; break;
 	}
-	tuple_associate_string(ti, "codec", tmps);
-	tuple_associate_string(ti, "quality", "sequenced");
-	tuple_associate_int(ti, "length", lSoundFile->GetSongTime() * 1000);
+	tuple_associate_string(ti, FIELD_CODEC, NULL, tmps);
+	tuple_associate_string(ti, FIELD_QUALITY, NULL, "sequenced");
+	tuple_associate_int(ti, FIELD_LENGTH, NULL, lSoundFile->GetSongTime() * 1000);
 
 	/* NOTICE! FIXME? This is actually incorrect. We _cannot_ know what charset
 	 * an arbitrary module file uses .. typically it is some DOS CP-variant,
 	 * except for true Amiga modules.
 	 */
 	tmps = str_to_utf8(lSoundFile->GetTitle());
-	tuple_associate_string(ti, "title", tmps);
+	tuple_associate_string(ti, FIELD_TITLE, NULL, lSoundFile->GetTitle());
 	g_free(tmps);
 	
-	
 	//unload the file
 	lSoundFile->Destroy();
 	delete lSoundFile;
--- a/src/scrobbler/fmt.c	Thu Sep 06 02:52:33 2007 +0300
+++ b/src/scrobbler/fmt.c	Thu Sep 06 03:03:03 2007 +0300
@@ -23,7 +23,7 @@
 	static char buf[30];
 
 	tm = gmt ? gmtime(&t) : localtime(&t);
-	snprintf(buf, sizeof(buf), "%d-%.2d-%.2d %.2d:%.2d:%.2d",
+	g_snprintf(buf, sizeof(buf), "%d-%.2d-%.2d %.2d:%.2d:%.2d",
 			tm->tm_year + 1900,
 			tm->tm_mon + 1,
 			tm->tm_mday,
--- a/src/scrobbler/gerpok.c	Thu Sep 06 02:52:33 2007 +0300
+++ b/src/scrobbler/gerpok.c	Thu Sep 06 03:03:03 2007 +0300
@@ -92,10 +92,10 @@
 
 	item = malloc(sizeof(item_t));
 
-	item->artist = fmt_escape(tuple_get_string(tuple, "artist"));
-	item->title = fmt_escape(tuple_get_string(tuple, "title"));
+	item->artist = fmt_escape(tuple_get_string(tuple, FIELD_ARTIST, NULL));
+	item->title = fmt_escape(tuple_get_string(tuple, FIELD_TITLE, NULL));
 	item->utctime = fmt_escape(fmt_timestr(time(NULL), 1));
-	snprintf(item->len, sizeof(item->len), "%d", len);
+	g_snprintf(item->len, sizeof(item->len), "%d", len);
 
 #ifdef NOTYET
 	if(tuple->mb == NULL)
@@ -106,7 +106,7 @@
 		item->mb = fmt_escape((char*)tuple->mb);
 #endif
 
-	if((album = tuple_get_string(tuple, "album")))
+	if((album = tuple_get_string(tuple, FIELD_ALBUM, NULL)))
 		item->album = fmt_escape("");
 	else
 		item->album = fmt_escape((char*) album);
@@ -412,7 +412,7 @@
 	char buf[4096];
 	CURL *curl;
 
-	snprintf(buf, sizeof(buf), "%s/?hs=true&p=%s&c=%s&v=%s&u=%s",
+	g_snprintf(buf, sizeof(buf), "%s/?hs=true&p=%s&c=%s&v=%s&u=%s",
 			SCROBBLER_HS_URL, SCROBBLER_VERSION,
 			SCROBBLER_CLI_ID, SCROBBLER_IMPLEMENTATION, gerpok_sc_username);
 
@@ -568,9 +568,9 @@
 
 static gchar *gerpok_sc_itemtag(char c, int n, char *str)
 {
-    static char buf[SCROBBLER_SB_MAXLEN]; 
-    snprintf(buf, SCROBBLER_SB_MAXLEN, "&%c[%d]=%s", c, n, str);
-    return buf;
+	static char buf[SCROBBLER_SB_MAXLEN]; 
+	g_snprintf(buf, SCROBBLER_SB_MAXLEN, "&%c[%d]=%s", c, n, str);
+	return buf;
 }
 
 #define cfa(f, l, n, v) \
@@ -748,7 +748,7 @@
 
 	cachesize = written = 0;
 
-	snprintf(buf, sizeof(buf), "%s/gerpokqueue.txt", audacious_get_localdir());
+	g_snprintf(buf, sizeof(buf), "%s/gerpokqueue.txt", audacious_get_localdir());
 
 	if (!(fd = fopen(buf, "r")))
 		return;
@@ -832,7 +832,7 @@
 		return;
 	}
 
-	snprintf(buf, sizeof(buf), "%s/gerpokqueue.txt", audacious_get_localdir());
+	g_snprintf(buf, sizeof(buf), "%s/gerpokqueue.txt", audacious_get_localdir());
 
 	if (!(fd = fopen(buf, "w")))
 	{
--- a/src/scrobbler/plugin.c	Thu Sep 06 02:52:33 2007 +0300
+++ b/src/scrobbler/plugin.c	Thu Sep 06 03:03:03 2007 +0300
@@ -243,16 +243,19 @@
 			if (tuple == NULL)
 				continue;
 
-			if (ishttp(tuple_get_string(tuple, "file-name")))
+			if (ishttp(tuple_get_string(tuple, FIELD_FILE_NAME, NULL)))
 				continue;
 
-			if(tuple_get_string(tuple, "artist") != NULL && tuple_get_string(tuple, "title") != NULL)
+			if (tuple_get_string(tuple, FIELD_ARTIST, NULL) != NULL &&
+				tuple_get_string(tuple, FIELD_TITLE, NULL) != NULL)
 			{
 				pdebug(fmt_vastr(
 					"submitting artist: %s, title: %s",
-					tuple_get_string(tuple, "artist"), tuple_get_string(tuple, "title")), DEBUG);
-				sc_addentry(m_scrobbler, tuple, tuple_get_int(tuple, "length") / 1000);
-				gerpok_sc_addentry(m_scrobbler, tuple, tuple_get_int(tuple, "length") / 1000);
+					tuple_get_string(tuple, FIELD_ARTIST, NULL),
+					tuple_get_string(tuple, FIELD_TITLE, NULL)), DEBUG);
+				
+				sc_addentry(m_scrobbler, tuple, tuple_get_int(tuple, FIELD_LENGTH, NULL) / 1000);
+				gerpok_sc_addentry(m_scrobbler, tuple, tuple_get_int(tuple, FIELD_LENGTH, NULL) / 1000);
 			}
 			else
 				pdebug("tuple does not contain an artist or a title, not submitting.", DEBUG);
--- a/src/scrobbler/scrobbler.c	Thu Sep 06 02:52:33 2007 +0300
+++ b/src/scrobbler/scrobbler.c	Thu Sep 06 03:03:03 2007 +0300
@@ -131,11 +131,12 @@
 
 	item = malloc(sizeof(item_t));
 
-	item->artist = fmt_escape(tuple_get_string(tuple, "artist"));
-	item->title = fmt_escape(tuple_get_string(tuple, "title"));
-	snprintf(item->utctime, sizeof(item->utctime), "%ld", time(NULL));
-	snprintf(item->len, sizeof(item->len), "%d", len);
-	snprintf(item->track, sizeof(item->track), "%d", tuple_get_int(tuple, "track-number"));
+	item->artist = fmt_escape(tuple_get_string(tuple, FIELD_ARTIST, NULL));
+	item->title = fmt_escape(tuple_get_string(tuple, FIELD_TITLE, NULL));
+	g_snprintf(item->utctime, sizeof(item->utctime), "%ld", time(NULL));
+	g_snprintf(item->len, sizeof(item->len), "%d", len);
+	g_snprintf(item->track, sizeof(item->track), "%d",
+		tuple_get_int(tuple, FIELD_TRACK_NUMBER, NULL));
 
 #ifdef NOTYET
 	if(tuple->mb == NULL)
@@ -146,7 +147,7 @@
 		item->mb = fmt_escape((char*)tuple->mb);
 #endif
 
-	if((album = tuple_get_string(tuple, "album")))
+	if((album = tuple_get_string(tuple, FIELD_ALBUM, NULL)))
 		item->album = fmt_escape("");
 	else
 		item->album = fmt_escape((char*) album);
@@ -442,7 +443,7 @@
 	hexify(auth, strlen(auth));
 	auth_tmp = g_strdup(sc_response_hash);
 
-	snprintf(buf, sizeof(buf), "%s/?hs=true&p=%s&c=%s&v=%s&u=%s&t=%ld&a=%s",
+	g_snprintf(buf, sizeof(buf), "%s/?hs=true&p=%s&c=%s&v=%s&u=%s&t=%ld&a=%s",
 			SCROBBLER_HS_URL, SCROBBLER_VERSION,
 			SCROBBLER_CLI_ID, SCROBBLER_IMPLEMENTATION, sc_username, time(NULL),
 			auth_tmp);
@@ -600,9 +601,9 @@
 
 static gchar *sc_itemtag(char c, int n, char *str)
 {
-    static char buf[SCROBBLER_SB_MAXLEN]; 
-    snprintf(buf, SCROBBLER_SB_MAXLEN, "&%c[%d]=%s", c, n, str);
-    return buf;
+	static char buf[SCROBBLER_SB_MAXLEN]; 
+	g_snprintf(buf, SCROBBLER_SB_MAXLEN, "&%c[%d]=%s", c, n, str);
+	return buf;
 }
 
 #define cfa(f, l, n, v) \
@@ -673,10 +674,11 @@
 	/*cfa(&post, &last, "debug", "failed");*/
 
 	entry = g_strdup_printf("s=%s&a=%s&t=%s&b=%s&l=%d&n=%d&m=", sc_session_id,
-		tuple_get_string(tuple, "artist"),
-		tuple_get_string(tuple, "title"),
-		tuple_get_string(tuple, "album") ? tuple_get_string(tuple, "album") : "",
-		tuple_get_int(tuple, "length") / 1000, tuple_get_int(tuple, "track-number"));
+		tuple_get_string(tuple, FIELD_ARTIST, NULL),
+		tuple_get_string(tuple, FIELD_TITLE, NULL),
+		tuple_get_string(tuple, FIELD_ALBUM, NULL) ? tuple_get_string(tuple, FIELD_ALBUM, NULL) : "",
+		tuple_get_int(tuple, FIELD_LENGTH, NULL) / 1000,
+		tuple_get_int(tuple, FIELD_TRACK_NUMBER, NULL));
 
 	curl_easy_setopt(curl, CURLOPT_POSTFIELDS, (char *) entry);
 	memset(sc_curl_errbuf, 0, sizeof(sc_curl_errbuf));
@@ -831,7 +833,7 @@
 
 	cachesize = written = 0;
 
-	snprintf(buf, sizeof(buf), "%s/scrobblerqueue.txt", audacious_get_localdir());
+	g_snprintf(buf, sizeof(buf), "%s/scrobblerqueue.txt", audacious_get_localdir());
 
 	if (!(fd = fopen(buf, "r")))
 		return;
@@ -883,9 +885,9 @@
 		{
 			Tuple *tuple = tuple_new();
 
-			tuple_associate_string(tuple, "artist", xmms_urldecode_plain(artist));
-			tuple_associate_string(tuple, "title", xmms_urldecode_plain(title));
-			tuple_associate_string(tuple, "album", xmms_urldecode_plain(album));
+			tuple_associate_string(tuple, FIELD_ARTIST, NULL, xmms_urldecode_plain(artist));
+			tuple_associate_string(tuple, FIELD_TITLE, NULL, xmms_urldecode_plain(title));
+			tuple_associate_string(tuple, FIELD_ALBUM, NULL, xmms_urldecode_plain(album));
 
 			item = q_put(tuple, atoi(len));
 
@@ -926,7 +928,7 @@
 		return;
 	}
 
-	snprintf(buf, sizeof(buf), "%s/scrobblerqueue.txt", audacious_get_localdir());
+	g_snprintf(buf, sizeof(buf), "%s/scrobblerqueue.txt", audacious_get_localdir());
 
 	if (!(fd = fopen(buf, "w")))
 	{
--- a/src/sexypsf/plugin.c	Thu Sep 06 02:52:33 2007 +0300
+++ b/src/sexypsf/plugin.c	Thu Sep 06 03:03:03 2007 +0300
@@ -227,18 +227,18 @@
 
     if (tmp->length) {
         tuple = tuple_new_from_filename(fn);
-	tuple_associate_int(tuple, "length", tmp->length);
-	tuple_associate_string(tuple, "artist", tmp->artist);
-	tuple_associate_string(tuple, "album", tmp->game);
-	tuple_associate_string(tuple, "game", tmp->game);
-        tuple_associate_string(tuple, "title", tmp->title);
-        tuple_associate_string(tuple, "genre", tmp->genre);
-        tuple_associate_string(tuple, "copyright", tmp->copyright);
-        tuple_associate_string(tuple, "quality", "sequenced");
-        tuple_associate_string(tuple, "codec", "PlayStation Audio");
-        tuple_associate_string(tuple, "console", "PlayStation");
-        tuple_associate_string(tuple, "dumper", tmp->psfby);
-        tuple_associate_string(tuple, "comment", tmp->comment);
+	tuple_associate_int(tuple, FIELD_LENGTH, NULL, tmp->length);
+	tuple_associate_string(tuple, FIELD_ARTIST, NULL, tmp->artist);
+	tuple_associate_string(tuple, FIELD_ALBUM, NULL, tmp->game);
+	tuple_associate_string(tuple, -1, "game", tmp->game);
+        tuple_associate_string(tuple, FIELD_TITLE, NULL, tmp->title);
+        tuple_associate_string(tuple, FIELD_GENRE, NULL, tmp->genre);
+        tuple_associate_string(tuple, FIELD_COPYRIGHT, NULL, tmp->copyright);
+        tuple_associate_string(tuple, FIELD_QUALITY, NULL, "sequenced");
+        tuple_associate_string(tuple, FIELD_CODEC, NULL, "PlayStation Audio");
+        tuple_associate_string(tuple, -1, "console", "PlayStation");
+        tuple_associate_string(tuple, -1, "dumper", tmp->psfby);
+        tuple_associate_string(tuple, FIELD_COMMENT, NULL, tmp->comment);
 
         sexypsf_freepsfinfo(tmp);
     }
--- a/src/sid/xmms-sid.c	Thu Sep 06 02:52:33 2007 +0300
+++ b/src/sid/xmms-sid.c	Thu Sep 06 03:03:03 2007 +0300
@@ -660,13 +660,13 @@
 {
 	gchar *tmpStr, tmpStr2[64];
 
-	tuple_associate_string(pResult, "title", pInfo->sidName);
-	tuple_associate_string(pResult, "artist", pInfo->sidComposer);
-	tuple_associate_string(pResult, "genre", "SID-tune");
-	tuple_associate_string(pResult, "copyright", pInfo->sidCopyright);
+	tuple_associate_string(pResult, FIELD_TITLE, NULL, pInfo->sidName);
+	tuple_associate_string(pResult, FIELD_ARTIST, NULL, pInfo->sidComposer);
+	tuple_associate_string(pResult, FIELD_GENRE, NULL, "SID-tune");
+	tuple_associate_string(pResult, FIELD_COPYRIGHT, NULL, pInfo->sidCopyright);
 
-	tuple_associate_int(pResult, "subtunes", pInfo->nsubTunes);
-	tuple_associate_string(pResult, "sid-format", pInfo->sidFormat);
+	tuple_associate_int(pResult, -1, "subtunes", pInfo->nsubTunes);
+	tuple_associate_string(pResult, -1, "sid-format", pInfo->sidFormat);
 
 	switch (pInfo->sidModel) {
 		case XS_SIDMODEL_6581: tmpStr = "6581"; break;
@@ -674,7 +674,7 @@
 		case XS_SIDMODEL_ANY: tmpStr = "ANY"; break;
 		default: tmpStr = "?"; break;
 	}
-	tuple_associate_string(pResult, "sid-model", tmpStr);
+	tuple_associate_string(pResult, -1, "sid-model", tmpStr);
 	
 	/* Get sub-tune information, if available */
 	if (subTune < 0 || pInfo->startTune > pInfo->nsubTunes)
@@ -682,7 +682,7 @@
 	
 	if ((subTune > 0) && (subTune <= pInfo->nsubTunes)) {
 		gint tmpInt = pInfo->subTunes[subTune - 1].tuneLength;
-		tuple_associate_int(pResult, "length", (tmpInt < 0) ? -1 : tmpInt * 1000);
+		tuple_associate_int(pResult, FIELD_LENGTH, NULL, (tmpInt < 0) ? -1 : tmpInt * 1000);
 		
 		tmpInt = pInfo->subTunes[subTune - 1].tuneSpeed;
 		if (tmpInt > 0) {
@@ -700,15 +700,15 @@
 		} else
 			tmpStr = "?";
 
-		tuple_associate_string(pResult, "sid-speed", tmpStr);
+		tuple_associate_string(pResult, -1, "sid-speed", tmpStr);
 	} else
 		subTune = 1;
 
-	tuple_associate_int(pResult, "subtune", subTune);
-	tuple_associate_int(pResult, "track-number", subTune);
+	tuple_associate_int(pResult, -1, "subtune", subTune);
+	tuple_associate_int(pResult, FIELD_TRACK_NUMBER, NULL, subTune);
 
 	if (xs_cfg.titleOverride)
-		tuple_associate_string(pResult, "formatter", xs_cfg.titleFormat);
+		tuple_associate_string(pResult, FIELD_FORMATTER, NULL, xs_cfg.titleFormat);
 }
 
 Tuple * xs_get_song_tuple(gchar *songFilename)
--- a/src/statusicon/si_ui.c	Thu Sep 06 02:52:33 2007 +0300
+++ b/src/statusicon/si_ui.c	Thu Sep 06 03:03:03 2007 +0300
@@ -150,7 +150,7 @@
     GtkWidget *popup = g_object_get_data( G_OBJECT(evbox) , "popup" );
 
     tuple = playlist_get_tuple( pl_active , pos );
-    if ( ( tuple == NULL ) || ( tuple_get_int(tuple, "length") < 1 ) )
+    if ( ( tuple == NULL ) || ( tuple_get_int(tuple, FIELD_LENGTH, NULL) < 1 ) )
     {
       gchar *title = playlist_get_songtitle( pl_active , pos );
       audacious_fileinfopopup_show_from_title( popup , title );
--- a/src/timidity/src/xmms-timidity.c	Thu Sep 06 02:52:33 2007 +0300
+++ b/src/timidity/src/xmms-timidity.c	Thu Sep 06 03:03:03 2007 +0300
@@ -312,7 +312,7 @@
 
 	title = tuple_formatter_make_title_string(input, get_gentitle_format());
 	if (title == NULL || *title == '\0')
-		title = g_strdup(tuple_get_string(input, "file-name"));
+		title = g_strdup(tuple_get_string(input, FIELD_FILE_NAME, NULL));
 
 	tuple_free(input);
 
--- a/src/tta/libtta.c	Thu Sep 06 02:52:33 2007 +0300
+++ b/src/tta/libtta.c	Thu Sep 06 03:03:03 2007 +0300
@@ -189,7 +189,7 @@
 	*title = NULL;
 
 	if ((tuple = get_song_tuple(filename)) != NULL) {
-    	    *length = tuple_get_int(tuple, "length");
+    	    *length = tuple_get_int(tuple, FIELD_LENGTH, NULL);
     	    *title = get_song_title(tuple);
 	}
 
@@ -577,30 +577,30 @@
 		if(open_tta_file(filename, ttainfo, 0) >= 0) {
 			tuple = tuple_new_from_filename(filename);
 
-			tuple_associate_string(tuple, "codec", "True Audio (TTA)");
-			tuple_associate_string(tuple, "quality", "lossless");
+			tuple_associate_string(tuple, FIELD_CODEC, NULL, "True Audio (TTA)");
+			tuple_associate_string(tuple, FIELD_QUALITY, NULL, "lossless");
 
 			if (ttainfo->ID3.id3has) {
 				if (ttainfo->ID3.artist)
-					tuple_associate_string(tuple, "artist", (gchar *) ttainfo->ID3.artist);
+					tuple_associate_string(tuple, FIELD_ARTIST, NULL, (gchar *) ttainfo->ID3.artist);
 
 				if (ttainfo->ID3.album)
-					tuple_associate_string(tuple, "album", (gchar *) ttainfo->ID3.album);
+					tuple_associate_string(tuple, FIELD_ALBUM, NULL, (gchar *) ttainfo->ID3.album);
 
 				if (ttainfo->ID3.title)
-					tuple_associate_string(tuple, "title", (gchar *) ttainfo->ID3.title);
+					tuple_associate_string(tuple, FIELD_TITLE, NULL, (gchar *) ttainfo->ID3.title);
 
 				if (ttainfo->ID3.year)
-					tuple_associate_int(tuple, "year", atoi((char *)ttainfo->ID3.year));
+					tuple_associate_int(tuple, FIELD_YEAR, NULL, atoi((char *)ttainfo->ID3.year));
 
 				if(ttainfo->ID3.track)
-					tuple_associate_int(tuple, "track-number", atoi((char *)ttainfo->ID3.track));
+					tuple_associate_int(tuple, FIELD_TRACK_NUMBER, NULL, atoi((char *)ttainfo->ID3.track));
 
 				if(ttainfo->ID3.genre)
-					tuple_associate_string(tuple, "genre", (gchar *) ttainfo->ID3.genre);
+					tuple_associate_string(tuple, FIELD_GENRE, NULL, (gchar *) ttainfo->ID3.genre);
 
 				if(ttainfo->ID3.comment)
-					tuple_associate_string(tuple, "comment", (gchar *) ttainfo->ID3.comment);
+					tuple_associate_string(tuple, FIELD_COMMENT, NULL, (gchar *) ttainfo->ID3.comment);
 			}
 			close_tta_file (ttainfo);
 		}
--- a/src/vorbis/vorbis.c	Thu Sep 06 02:52:33 2007 +0300
+++ b/src/vorbis/vorbis.c	Thu Sep 06 03:03:03 2007 +0300
@@ -607,7 +607,7 @@
 {
     Tuple *tuple = get_song_tuple(filename);
 
-    *length = tuple_get_int(tuple, "length");
+    *length = tuple_get_int(tuple, FIELD_LENGTH, NULL);
     *title = tuple_formatter_make_title_string(tuple, vorbis_cfg.tag_override ?
                                             vorbis_cfg.tag_format : get_gentitle_format());
 
@@ -730,13 +730,13 @@
     return 2 * ch * samples;
 }
 
-static void _tuple_associate_string(Tuple *tuple, const gchar *field, const gchar *string)
+static void _tuple_associate_string(Tuple *tuple, const gint nfield, const gchar *field, const gchar *string)
 {
-    gchar *str = str_to_utf8(string);
-
-    tuple_associate_string(tuple, field, str);
-
-    g_free(str);
+    if (string) {
+        gchar *str = str_to_utf8(string);
+        tuple_associate_string(tuple, nfield, field, str);
+        g_free(str);
+    }
 }
 
 /*
@@ -747,36 +747,34 @@
 {
     Tuple *tuple = NULL;
     vorbis_comment *comment;
-    gchar *realfn = NULL;
     tuple = tuple_new_from_filename(filename);
 
     /* Retrieve the length */
-    if (is_stream == FALSE)
-        tuple_associate_int(tuple, "length", ov_time_total(vorbisfile, -1) * 1000);
-    else
-        tuple_associate_int(tuple, "length", -1);
+    tuple_associate_int(tuple, FIELD_LENGTH, NULL,
+        is_stream ? -1 : (ov_time_total(vorbisfile, -1) * 1000));
 
     if ((comment = ov_comment(vorbisfile, -1))) {
-        _tuple_associate_string(tuple, "title", vorbis_comment_query(comment, "title", 0));
-        _tuple_associate_string(tuple, "artist", vorbis_comment_query(comment, "artist", 0));
-        _tuple_associate_string(tuple, "album", vorbis_comment_query(comment, "album", 0));
-        _tuple_associate_string(tuple, "date", vorbis_comment_query(comment, "date", 0));
-        _tuple_associate_string(tuple, "genre", vorbis_comment_query(comment, "genre", 0));
-        _tuple_associate_string(tuple, "comment", vorbis_comment_query(comment, "comment", 0));
+        gchar *tmps;
+        _tuple_associate_string(tuple, FIELD_TITLE, NULL, vorbis_comment_query(comment, "title", 0));
+        _tuple_associate_string(tuple, FIELD_ARTIST, NULL, vorbis_comment_query(comment, "artist", 0));
+        _tuple_associate_string(tuple, FIELD_ALBUM, NULL, vorbis_comment_query(comment, "album", 0));
+        _tuple_associate_string(tuple, -1, "date", vorbis_comment_query(comment, "date", 0));
+        _tuple_associate_string(tuple, FIELD_GENRE, NULL, vorbis_comment_query(comment, "genre", 0));
+        _tuple_associate_string(tuple, FIELD_COMMENT, NULL, vorbis_comment_query(comment, "comment", 0));
 
-        if (vorbis_comment_query(comment, "tracknumber", 0) != NULL)
-            tuple_associate_int(tuple, "track-number", 
-                atoi(vorbis_comment_query(comment, "tracknumber", 0)));
+        if ((tmps = vorbis_comment_query(comment, "tracknumber", 0)) != NULL)
+            tuple_associate_int(tuple, FIELD_TRACK_NUMBER, NULL, atoi(tmps));
 
-        tuple_associate_string(tuple, "quality", "lossy");
+        tuple_associate_string(tuple, FIELD_QUALITY, NULL, "lossy");
+
         if (comment && comment->vendor)
         {
             gchar *codec = g_strdup_printf("Ogg Vorbis [%s]", comment->vendor);
-            tuple_associate_string(tuple, "codec", codec);
+            tuple_associate_string(tuple, FIELD_CODEC, NULL, codec);
             g_free(codec);
         }
         else
-            tuple_associate_string(tuple, "codec", "Ogg Vorbis");
+            tuple_associate_string(tuple, FIELD_CODEC, NULL, "Ogg Vorbis");
     }
 
     return tuple;
@@ -836,8 +834,8 @@
     {
         gchar *old = displaytitle;
 
-        tuple_associate_string(input, "stream", tmp);
-        tuple_associate_string(input, "title", old);
+        tuple_associate_string(input, -1, "stream", tmp);
+        tuple_associate_string(input, FIELD_TITLE, NULL, old);
 
         displaytitle = tuple_formatter_process_string(input, "${?title:${title}}${?stream: (${stream})}");
 
--- a/src/vtx/vtx.c	Thu Sep 06 02:52:33 2007 +0300
+++ b/src/vtx/vtx.c	Thu Sep 06 03:03:03 2007 +0300
@@ -98,20 +98,20 @@
   Tuple *out = tuple_new_from_filename(filename);
   gchar *string;
 
-  tuple_associate_string(out, "artist", in->hdr.author);
-  tuple_associate_string(out, "title", in->hdr.title);
+  tuple_associate_string(out, FIELD_ARTIST, NULL, in->hdr.author);
+  tuple_associate_string(out, FIELD_TITLE, NULL, in->hdr.title);
 
-  tuple_associate_int(out, "length", in->hdr.regdata_size / 14 * 1000 / 50);
+  tuple_associate_int(out, FIELD_LENGTH, NULL, in->hdr.regdata_size / 14 * 1000 / 50);
 
-  tuple_associate_string(out, "genre", (in->hdr.chiptype == AYEMU_AY)? "AY chiptunes" : "YM chiptunes");
-  tuple_associate_string(out, "album", in->hdr.from);
-  tuple_associate_string(out, "game", in->hdr.from);
+  tuple_associate_string(out, FIELD_GENRE, NULL, (in->hdr.chiptype == AYEMU_AY)? "AY chiptunes" : "YM chiptunes");
+  tuple_associate_string(out, FIELD_ALBUM, NULL, in->hdr.from);
+  tuple_associate_string(out, -1, "game", in->hdr.from);
 
-  tuple_associate_string(out, "quality", "sequenced");
-  tuple_associate_string(out, "codec", in->hdr.tracker);
-  tuple_associate_string(out, "tracker", in->hdr.tracker);
+  tuple_associate_string(out, FIELD_QUALITY, NULL, "sequenced");
+  tuple_associate_string(out, FIELD_CODEC, NULL, in->hdr.tracker);
+  tuple_associate_string(out, -1, "tracker", in->hdr.tracker);
 
-  tuple_associate_int(out, "year", in->hdr.year);
+  tuple_associate_int(out, FIELD_YEAR, NULL, in->hdr.year);
 
   return out;
 }
@@ -299,7 +299,7 @@
     Tuple *ti = vtx_get_song_tuple_from_vtx(filename, &tmp);
 
     *title = tuple_formatter_process_string(ti, get_gentitle_format());
-    *length = tuple_get_int(ti, "length");
+    *length = tuple_get_int(ti, FIELD_LENGTH, NULL);
 
     ayemu_vtx_free (&tmp);
     tuple_free(ti);
--- a/src/wav/wav-sndfile.c	Thu Sep 06 02:52:33 2007 +0300
+++ b/src/wav/wav-sndfile.c	Thu Sep 06 03:03:03 2007 +0300
@@ -127,14 +127,14 @@
 	realfn = g_filename_from_uri(filename, NULL, NULL);
 	tmp_sndfile = sf_open (realfn ? realfn : filename, SFM_READ, &tmp_sfinfo);
 	if ( sf_get_string(tmp_sndfile, SF_STR_TITLE) == NULL)
-		tuple_associate_string(ti, "title", g_path_get_basename(realfn ? realfn : filename));
+		tuple_associate_string(ti, FIELD_TITLE, NULL, g_path_get_basename(realfn ? realfn : filename));
 	else
-		tuple_associate_string(ti, "title", sf_get_string(tmp_sndfile, SF_STR_TITLE));
+		tuple_associate_string(ti, FIELD_TITLE, NULL, sf_get_string(tmp_sndfile, SF_STR_TITLE));
 
-	tuple_associate_string(ti, "artist", sf_get_string(tmp_sndfile, SF_STR_ARTIST));
-	tuple_associate_string(ti, "comment", sf_get_string(tmp_sndfile, SF_STR_COMMENT));
-	tuple_associate_string(ti, "date", sf_get_string(tmp_sndfile, SF_STR_DATE));
-	tuple_associate_string(ti, "software", sf_get_string(tmp_sndfile, SF_STR_SOFTWARE));
+	tuple_associate_string(ti, FIELD_ARTIST, NULL, sf_get_string(tmp_sndfile, SF_STR_ARTIST));
+	tuple_associate_string(ti, FIELD_COMMENT, NULL, sf_get_string(tmp_sndfile, SF_STR_COMMENT));
+	tuple_associate_string(ti, -1, "date", sf_get_string(tmp_sndfile, SF_STR_DATE));
+	tuple_associate_string(ti, -1, "software", sf_get_string(tmp_sndfile, SF_STR_SOFTWARE));
 
 	g_free(realfn); realfn = NULL;
 
@@ -145,7 +145,7 @@
 	tmp_sndfile = NULL;
 
 	if (tmp_sfinfo.samplerate > 0)
-		tuple_associate_int(ti, "length", (int) ceil (1000.0 * tmp_sfinfo.frames / tmp_sfinfo.samplerate));
+		tuple_associate_int(ti, FIELD_LENGTH, NULL, (int) ceil (1000.0 * tmp_sfinfo.frames / tmp_sfinfo.samplerate));
 
 	switch (tmp_sfinfo.format & SF_FORMAT_TYPEMASK)
 	{
@@ -302,12 +302,12 @@
 		g_string_append_printf(codec_gs, "%s", format);
 	codec = g_strdup(codec_gs->str);
 	g_string_free(codec_gs, TRUE);
-	tuple_associate_string(ti, "codec", codec);
+	tuple_associate_string(ti, FIELD_CODEC, NULL, codec);
 
 	if (lossy != 0)
-		tuple_associate_string(ti, "quality", "lossy");
+		tuple_associate_string(ti, FIELD_QUALITY, NULL, "lossy");
 	else
-		tuple_associate_string(ti, "quality", "lossless");
+		tuple_associate_string(ti, FIELD_QUALITY, NULL, "lossless");
 }
 
 static gchar *get_title(char *filename)
@@ -321,7 +321,7 @@
 	if (*title == '\0')
 	{
 		g_free(title);
-		title = g_strdup(tuple_get_string(tuple, "file-name"));
+		title = g_strdup(tuple_get_string(tuple, FIELD_FILE_NAME, NULL));
 	}
 
 	tuple_free(tuple);
--- a/src/wma/wma.c	Thu Sep 06 02:52:33 2007 +0300
+++ b/src/wma/wma.c	Thu Sep 06 03:03:03 2007 +0300
@@ -243,6 +243,18 @@
     return ext;
 }
 
+static void _assoc_string(Tuple *tuple, const gint nfield, const gchar *str)
+{
+    if (strlen(str) > 0)
+        tuple_associate_string(tuple, nfield, NULL, str);
+}
+
+static void _assoc_int(Tuple *tuple, const gint nfield, const gint val)
+{
+    if (val > 0)
+        tuple_associate_int(tuple, nfield, NULL, val);
+}
+
 static Tuple *wma_get_song_tuple(gchar * filename)
 {
     Tuple *ti = tuple_new_from_filename(filename);
@@ -251,27 +263,19 @@
     if (av_open_input_file(&in, str_twenty_to_space(filename), NULL, 0, NULL) < 0)
 	return NULL;
 
-    tuple_associate_string(ti, "codec", "Windows Media Audio (WMA)");
-    tuple_associate_string(ti, "quality", "lossy");
+    tuple_associate_string(ti, FIELD_CODEC, NULL, "Windows Media Audio (WMA)");
+    tuple_associate_string(ti, FIELD_QUALITY, NULL, "lossy");
 
     av_find_stream_info(in);
 
-    if(strlen(in->title))
-        tuple_associate_string(ti, "title", in->title);
-    if(strlen(in->author))
-        tuple_associate_string(ti, "artist", in->author);
-    if(strlen(in->album))
-        tuple_associate_string(ti, "album", in->album);
-    if(strlen(in->comment))
-        tuple_associate_string(ti, "comment", in->comment);
-    if(strlen(in->genre))
-        tuple_associate_string(ti, "genre", in->genre);
-    if(in->year > 0)
-        tuple_associate_int(ti, "year", in->year);
-    if(in->track > 0)
-        tuple_associate_int(ti, "track", in->track);
-    if (in->duration)
-        tuple_associate_int(ti, "length", in->duration / 1000);
+    _assoc_string(ti, FIELD_TITLE, in->title);
+    _assoc_string(ti, FIELD_ARTIST, in->author);
+    _assoc_string(ti, FIELD_ALBUM, in->album);
+    _assoc_string(ti, FIELD_COMMENT, in->comment);
+    _assoc_string(ti, FIELD_GENRE, in->genre);
+    _assoc_int(ti, FIELD_YEAR, in->year);
+    _assoc_int(ti, FIELD_TRACK_NUMBER, in->track);
+    _assoc_int(ti, FIELD_LENGTH, in->duration / 1000);
 
     av_close_input_file(in);
 
@@ -283,25 +287,17 @@
     gchar *ret = NULL;
     Tuple *ti = tuple_new_from_filename(filename);
 
-    tuple_associate_string(ti, "codec", "Windows Media Audio (WMA)");
-    tuple_associate_string(ti, "quality", "lossy");
+    tuple_associate_string(ti, FIELD_CODEC, NULL, "Windows Media Audio (WMA)");
+    tuple_associate_string(ti, FIELD_QUALITY, NULL, "lossy");
 
-    if(strlen(in->title))
-        tuple_associate_string(ti, "title", in->title);
-    if(strlen(in->author))
-        tuple_associate_string(ti, "artist", in->author);
-    if(strlen(in->album))
-        tuple_associate_string(ti, "album", in->album);
-    if(strlen(in->comment))
-        tuple_associate_string(ti, "comment", in->comment);
-    if(strlen(in->genre))
-        tuple_associate_string(ti, "genre", in->genre);
-    if(in->year > 0)
-        tuple_associate_int(ti, "year", in->year);
-    if(in->track > 0)
-        tuple_associate_int(ti, "track", in->track);
-    if (in->duration)
-        tuple_associate_int(ti, "length", in->duration / 1000);
+    _assoc_string(ti, FIELD_TITLE, in->title);
+    _assoc_string(ti, FIELD_ARTIST, in->author);
+    _assoc_string(ti, FIELD_ALBUM, in->album);
+    _assoc_string(ti, FIELD_COMMENT, in->comment);
+    _assoc_string(ti, FIELD_GENRE, in->genre);
+    _assoc_int(ti, FIELD_YEAR, in->year);
+    _assoc_int(ti, FIELD_TRACK_NUMBER, in->track);
+    _assoc_int(ti, FIELD_LENGTH, in->duration / 1000);
     
     ret = tuple_formatter_make_title_string(ti, get_gentitle_format());
 
@@ -323,7 +319,7 @@
     if (tuple == NULL)
         return;
 
-    (*len_real) = tuple_get_int(tuple, "length");
+    (*len_real) = tuple_get_int(tuple, FIELD_LENGTH, NULL);
     (*title_real) = tuple_formatter_make_title_string(tuple, get_gentitle_format());
 }
 
--- a/src/xspf/xspf.c	Thu Sep 06 02:52:33 2007 +0300
+++ b/src/xspf/xspf.c	Thu Sep 06 03:03:03 2007 +0300
@@ -104,8 +104,8 @@
 
     tuple = tuple_new();
 
-    tuple_associate_int(tuple, "length", -1);
-    tuple_associate_int(tuple, "mtime", -1);          // mark as uninitialized.
+    tuple_associate_int(tuple, FIELD_LENGTH, NULL, -1);
+    tuple_associate_int(tuple, FIELD_MTIME, NULL, -1);          // mark as uninitialized.
 
     // creator, album, title, duration, trackNum, annotation, image, 
     for(nptr = track->children; nptr != NULL; nptr = nptr->next) {
@@ -126,37 +126,37 @@
         else if(nptr->type == XML_ELEMENT_NODE
                 && !xmlStrcmp(nptr->name, (xmlChar *)"title")) {
             xmlChar *str = xmlNodeGetContent(nptr);
-	    tuple_associate_string(tuple, "title", (gchar *) str);
+	    tuple_associate_string(tuple, FIELD_TITLE, NULL, (gchar *) str);
             xmlFree(str);
         }
         else if(nptr->type == XML_ELEMENT_NODE
                 && !xmlStrcmp(nptr->name, (xmlChar *)"creator")) {
             xmlChar *str = xmlNodeGetContent(nptr);
-	    tuple_associate_string(tuple, "artist", (gchar *) str);
+	    tuple_associate_string(tuple, FIELD_ARTIST, NULL, (gchar *) str);
             xmlFree(str);
         }
         else if(nptr->type == XML_ELEMENT_NODE
                 && !xmlStrcmp(nptr->name, (xmlChar *)"annotation")) {
             xmlChar *str = xmlNodeGetContent(nptr);
-            tuple_associate_string(tuple, "comment", (gchar *) str);
+            tuple_associate_string(tuple, FIELD_COMMENT, NULL, (gchar *) str);
             xmlFree(str);
         }
         else if(nptr->type == XML_ELEMENT_NODE
                 && !xmlStrcmp(nptr->name, (xmlChar *)"album")) {
             xmlChar *str = xmlNodeGetContent(nptr);
-	    tuple_associate_string(tuple, "album", (gchar *) str);
+	    tuple_associate_string(tuple, FIELD_ALBUM, NULL, (gchar *) str);
             xmlFree(str);
         }
         else if(nptr->type == XML_ELEMENT_NODE
                 && !xmlStrcmp(nptr->name, (xmlChar *)"trackNum")) {
             xmlChar *str = xmlNodeGetContent(nptr);
-            tuple_associate_int(tuple, "track-number", atol((char *)str));
+            tuple_associate_int(tuple, FIELD_TRACK_NUMBER, NULL, atol((char *)str));
             xmlFree(str);
         }
         else if(nptr->type == XML_ELEMENT_NODE
                 && !xmlStrcmp(nptr->name, (xmlChar *)"duration")) {
             xmlChar *str = xmlNodeGetContent(nptr);
-            tuple_associate_int(tuple, "length", atol((char *)str));
+            tuple_associate_int(tuple, FIELD_LENGTH, NULL, atol((char *)str));
             xmlFree(str);
         }
 
@@ -173,32 +173,32 @@
 
             if(!xmlStrcmp(rel, (xmlChar *)"year")) {
                 xmlChar *cont = xmlNodeGetContent(nptr);
-                tuple_associate_int(tuple, "year", atol((char *)cont));
+                tuple_associate_int(tuple, FIELD_YEAR, NULL, atol((char *)cont));
                 xmlFree(cont);
                 continue;
             }
             else if(!xmlStrcmp(rel, (xmlChar *)"date")) {
                 xmlChar *cont = xmlNodeGetContent(nptr);
-                tuple_associate_string(tuple, "date", (gchar *) cont);
+                tuple_associate_string(tuple, FIELD_DATE, NULL, (gchar *) cont);
                 xmlFree(cont);
                 continue;
             }
             else if(!xmlStrcmp(rel, (xmlChar *)"genre")) {
                 xmlChar *cont = xmlNodeGetContent(nptr);
-                tuple_associate_string(tuple, "genre", (gchar *) cont);
+                tuple_associate_string(tuple, FIELD_GENRE, NULL, (gchar *) cont);
                 xmlFree(cont);
                 continue;
             }
             else if(!xmlStrcmp(rel, (xmlChar *)"formatter")) {
                 xmlChar *cont = xmlNodeGetContent(nptr);
-                tuple_associate_string(tuple, "formatter", (gchar *) cont);
+                tuple_associate_string(tuple, FIELD_FORMATTER, NULL, (gchar *) cont);
                 xmlFree(cont);
                 continue;
             }
             else if(!xmlStrcmp(rel, (xmlChar *)"mtime")) {
                 xmlChar *str = NULL;
                 str = xmlNodeGetContent(nptr);
-                tuple_associate_int(tuple, "mtime", atoll((char *)str));
+                tuple_associate_int(tuple, FIELD_MTIME, NULL, atoll((char *)str));
                 xmlFree(str);
                 continue;
             }
@@ -213,18 +213,18 @@
         gchar *scratch;
 
         scratch = g_path_get_basename(location);
-        tuple_associate_string(tuple, "file-name", scratch);
+        tuple_associate_string(tuple, FIELD_FILE_NAME, NULL, scratch);
         g_free(scratch);
 
         scratch = g_path_get_dirname(location);
-        tuple_associate_string(tuple, "file-path", scratch);
+        tuple_associate_string(tuple, FIELD_FILE_PATH, NULL, scratch);
         g_free(scratch);
 
 #ifdef DEBUG
-        printf("xspf: tuple->file_name = %s\n", tuple_get_string(tuple, "file-name"));
-        printf("xspf: tuple->file_path = %s\n", tuple_get_string(tuple, "file-path"));
+        printf("xspf: tuple->file_name = %s\n", tuple_get_string(tuple, FIELD_FILE_NAME, NULL));
+        printf("xspf: tuple->file_path = %s\n", tuple_get_string(tuple, FIELD_FILE_PATH, NULL));
 #endif
-        tuple_associate_string(tuple, "file-ext", strrchr(location, '.'));
+        tuple_associate_string(tuple, FIELD_FILE_EXT, NULL, strrchr(location, '.'));
         // add file to playlist
         uri = g_filename_to_uri(location, NULL, NULL);
         // uri would be NULL if location is already uri. --yaz
@@ -512,42 +512,42 @@
         /* do we have a tuple? */
         if(entry->tuple != NULL) {
 
-            if((scratch = tuple_get_string(entry->tuple, "title")) != NULL &&
+            if((scratch = tuple_get_string(entry->tuple, FIELD_TITLE, NULL)) != NULL &&
                 g_utf8_validate(scratch, -1, NULL)) {
                 tmp = xmlNewNode(NULL, (xmlChar *)"title");
                 xmlAddChild(tmp, xmlNewText((xmlChar *) scratch));
                 xmlAddChild(track, tmp);
             }
 
-            if((scratch = tuple_get_string(entry->tuple, "artist")) != NULL &&
+            if((scratch = tuple_get_string(entry->tuple, FIELD_ARTIST, NULL)) != NULL &&
                 g_utf8_validate(scratch, -1, NULL)) {
                 tmp = xmlNewNode(NULL, (xmlChar *)"creator");
                 xmlAddChild(tmp, xmlNewText((xmlChar *) scratch));
                 xmlAddChild(track, tmp);
             }
 
-            if((scratch = tuple_get_string(entry->tuple, "comment")) != NULL &&
+            if((scratch = tuple_get_string(entry->tuple, FIELD_COMMENT, NULL)) != NULL &&
                 g_utf8_validate(scratch, -1, NULL)) {
                 tmp = xmlNewNode(NULL, (xmlChar *)"annotation");
                 xmlAddChild(tmp, xmlNewText((xmlChar *) scratch));
                 xmlAddChild(track, tmp);
             }
 
-            if((scratch = tuple_get_string(entry->tuple, "album")) != NULL &&
+            if((scratch = tuple_get_string(entry->tuple, FIELD_ALBUM, NULL)) != NULL &&
                 g_utf8_validate(scratch, -1, NULL)) {
                 tmp = xmlNewNode(NULL, (xmlChar *)"album");
                 xmlAddChild(tmp, xmlNewText((xmlChar *) scratch));
                 xmlAddChild(track, tmp);
             }
 
-            if((tmpi = tuple_get_int(entry->tuple, "track-number")) != 0) {
+            if((tmpi = tuple_get_int(entry->tuple, FIELD_TRACK_NUMBER, NULL)) != 0) {
                 tmp = xmlNewNode(NULL, (xmlChar *)"trackNum");
                 g_snprintf(tmps, sizeof(tmps), "%d", tmpi);
                 xmlAddChild(tmp, xmlNewText((xmlChar *) tmps));
                 xmlAddChild(track, tmp);
             }
 
-            if((tmpi = tuple_get_int(entry->tuple, "length")) > 0) {
+            if((tmpi = tuple_get_int(entry->tuple, FIELD_LENGTH, NULL)) > 0) {
                 tmp = xmlNewNode(NULL, (xmlChar *)"duration");
                 g_snprintf(tmps, sizeof(tmps), "%d", tmpi);
                 xmlAddChild(tmp, xmlNewText((xmlChar *) tmps));
@@ -560,7 +560,7 @@
             // year, date, genre, formatter, mtime
             //
 
-            if((tmpi = tuple_get_int(entry->tuple, "year")) != 0) {
+            if((tmpi = tuple_get_int(entry->tuple, FIELD_YEAR, NULL)) != 0) {
                 tmp = xmlNewNode(NULL, (xmlChar *)"meta");
                 xmlSetProp(tmp, (xmlChar *)"rel", (xmlChar *)"year");
                 g_snprintf(tmps, sizeof(tmps), "%d", tmpi);
@@ -568,7 +568,7 @@
                 xmlAddChild(track, tmp);
             }
 
-            if((scratch = tuple_get_string(entry->tuple, "date")) != NULL &&
+            if((scratch = tuple_get_string(entry->tuple, FIELD_DATE, NULL)) != NULL &&
                 g_utf8_validate(scratch, -1, NULL)) {
                 tmp = xmlNewNode(NULL, (xmlChar *)"meta");
                 xmlSetProp(tmp, (xmlChar *)"rel", (xmlChar *)"date");
@@ -576,7 +576,7 @@
                 xmlAddChild(track, tmp);
             }
 
-            if((scratch = tuple_get_string(entry->tuple, "genre")) != NULL &&
+            if((scratch = tuple_get_string(entry->tuple, FIELD_GENRE, NULL)) != NULL &&
                 g_utf8_validate(scratch, -1, NULL)) {
                 tmp = xmlNewNode(NULL, (xmlChar *)"meta");
                 xmlSetProp(tmp, (xmlChar *)"rel", (xmlChar *)"genre");
@@ -584,7 +584,7 @@
                 xmlAddChild(track, tmp);
             }
 
-            if((scratch = tuple_get_string(entry->tuple, "formatter")) != NULL &&
+            if((scratch = tuple_get_string(entry->tuple, FIELD_FORMATTER, NULL)) != NULL &&
                 g_utf8_validate(scratch, -1, NULL)) {
                 tmp = xmlNewNode(NULL, (xmlChar *)"meta");
                 xmlSetProp(tmp, (xmlChar *)"rel", (xmlChar *)"formatter");
@@ -595,7 +595,7 @@
             // mtime: write mtime unconditionally to support staticlist.
             tmp = xmlNewNode(NULL, (xmlChar *)"meta");
             xmlSetProp(tmp, (xmlChar *)"rel", (xmlChar *)"mtime");
-            g_snprintf(tmps, sizeof(tmps), "%ld", (long) tuple_get_int(entry->tuple, "mtime"));
+            g_snprintf(tmps, sizeof(tmps), "%ld", (long) tuple_get_int(entry->tuple, FIELD_MTIME, NULL));
             xmlAddChild(tmp, xmlNewText((xmlChar *) tmps));
             xmlAddChild(track, tmp);
         }                       /* tuple */