changeset 4612:8a7752f1c662

Rename the audtool source files to be saner.
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 05 Jun 2008 01:27:43 +0300
parents 895297e46ee3
children 4e9859e8af94
files src/audtool/Makefile src/audtool/audtool_handlers_equalizer.c src/audtool/audtool_handlers_playback.c src/audtool/audtool_handlers_playlist.c src/audtool/audtool_handlers_playqueue.c src/audtool/audtool_handlers_vitals.c src/audtool/audtool_main.c src/audtool/audtool_report.c src/audtool/handlers_equalizer.c src/audtool/handlers_playback.c src/audtool/handlers_playlist.c src/audtool/handlers_playqueue.c src/audtool/handlers_vitals.c src/audtool/main.c src/audtool/report.c
diffstat 15 files changed, 1290 insertions(+), 1290 deletions(-) [+]
line wrap: on
line diff
--- a/src/audtool/Makefile	Thu Jun 05 01:25:22 2008 +0300
+++ b/src/audtool/Makefile	Thu Jun 05 01:27:43 2008 +0300
@@ -1,12 +1,12 @@
 PROG = audtool
-SRCS = audtool_main.c				\
-       audtool_handlers_general.c	\
-       audtool_handlers_playback.c	\
-       audtool_handlers_playlist.c	\
-       audtool_handlers_playqueue.c	\
-       audtool_handlers_vitals.c	\
-       audtool_handlers_equalizer.c	\
-       audtool_report.c
+SRCS = main.c				\
+       handlers_general.c	\
+       handlers_playback.c	\
+       handlers_playlist.c	\
+       handlers_playqueue.c	\
+       handlers_vitals.c	\
+       handlers_equalizer.c	\
+       report.c
 
 include ../../buildsys.mk
 include ../../extra.mk
--- a/src/audtool/audtool_handlers_equalizer.c	Thu Jun 05 01:25:22 2008 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,155 +0,0 @@
-/*
- * Audtool2
- * Copyright (c) 2007 Audacious development team
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- *    this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * 3. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
- * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
- * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <stdlib.h>
-#include <string.h>
-#include <glib.h>
-#include <mowgli.h>
-#include <locale.h>
-#include "libaudclient/audctrl.h"
-#include "audtool.h"
-
-void equalizer_get_eq(gint argc, gchar **argv)
-{
-    double preamp;
-    GArray *bands;
-    int i;
-
-    audacious_remote_get_eq(dbus_proxy, &preamp, &bands);
-
-    audtool_report("preamp = %.2f", preamp);
-    for(i=0; i<10; i++){
-        printf("%.2f ", g_array_index(bands, gdouble, i));
-    }
-    printf("\n");
-    g_array_free(bands, TRUE);
-}
-
-void equalizer_get_eq_preamp(gint argc, gchar **argv)
-{
-    audtool_report("preamp = %.2f", audacious_remote_get_eq_preamp(dbus_proxy));
-}
-
-void equalizer_get_eq_band(gint argc, gchar **argv)
-{
-    int band;
-
-    if (argc < 2)
-    {
-        audtool_whine_args(argv[0], "<band>");
-        exit(1);
-    }
-
-    band = atoi(argv[1]);
-
-    /* FIXME, XXX, TODO: we should have a function for requesting
-     * the actual number of bands, if we support dynamic amount some day ...
-     * -- ccr
-     */
-    if (band < 0 || band > 9)
-    {
-        audtool_whine("band number out of range\n");
-        exit(1);
-    }
-    
-    audtool_report("band %d = %.2f", band, audacious_remote_get_eq_band(dbus_proxy, band));
-    
-}
-
-void equalizer_set_eq(gint argc, gchar **argv)
-{
-    gdouble preamp;
-    GArray *bands = g_array_sized_new(FALSE, FALSE, sizeof(gdouble), 10);
-    int i;
-
-    if (argc < 12)
-    {
-        audtool_whine_args(argv[0], "<preamp> <band0> <band1> <band2> <band3> <band4> <band5> <band6> <band7> <band8> <band9>");
-        exit(1);
-    }
-
-    preamp = atof(argv[1]);
-    
-    for(i=0; i<10; i++){
-        gdouble val = atof(argv[i+2]);
-        g_array_append_val(bands, val);
-    }
-    
-    audacious_remote_set_eq(dbus_proxy, preamp, bands);
-}
-
-void equalizer_set_eq_preamp(gint argc, gchar **argv)
-{
-    gdouble preamp;
-
-    if (argc < 2)
-    {
-        audtool_whine_args(argv[0], "<preamp>");
-        exit(1);
-    }
-
-    preamp = atof(argv[1]);
-
-    audacious_remote_set_eq_preamp(dbus_proxy, preamp);
-}
-
-void equalizer_set_eq_band(gint argc, gchar **argv)
-{
-    int band;
-    gdouble preamp;
-
-    if (argc < 3)
-    {
-        audtool_whine_args(argv[0], "<band> <value>");
-        exit(1);
-    }
-
-    band = atoi(argv[1]);
-    preamp = atof(argv[2]);
-
-    audacious_remote_set_eq_band(dbus_proxy, band, preamp);
-}
-
-void equalizer_active(gint argc, gchar **argv)
-{
-    if (argc < 2)
-    {
-        audtool_whine_args(argv[0], "<on/off>");
-        exit(1);
-    }
-
-    if (!g_ascii_strcasecmp(argv[1], "on")) {
-        audacious_remote_eq_activate(dbus_proxy, TRUE);
-    }
-    else if (!g_ascii_strcasecmp(argv[1], "off")) {
-        audacious_remote_eq_activate(dbus_proxy, FALSE);
-    }
-}
--- a/src/audtool/audtool_handlers_playback.c	Thu Jun 05 01:25:22 2008 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,141 +0,0 @@
-/*
- * Audtool2
- * Copyright (c) 2007 Audacious development team
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- *    this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * 3. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
- * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
- * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <stdlib.h>
-#include <string.h>
-#include <glib.h>
-#include <mowgli.h>
-#include <locale.h>
-#include "libaudclient/audctrl.h"
-#include "audtool.h"
-
-void playback_play(gint argc, gchar **argv)
-{
-	audacious_remote_play(dbus_proxy);
-}
-
-void playback_pause(gint argc, gchar **argv)
-{
-	audacious_remote_pause(dbus_proxy);
-}
-
-void playback_playpause(gint argc, gchar **argv)
-{
-	if (audacious_remote_is_playing(dbus_proxy))
-	{
-		audacious_remote_pause(dbus_proxy);
-	}
-	else
-	{
-		audacious_remote_play(dbus_proxy);
-	}
-}
-
-void playback_stop(gint argc, gchar **argv)
-{
-	audacious_remote_stop(dbus_proxy);
-}
-
-void playback_playing(gint argc, gchar **argv)
-{
-	if (!audacious_remote_is_paused(dbus_proxy))
-	{
-		exit(!audacious_remote_is_playing(dbus_proxy));
-	}
-	else
-	{
-		exit(1);
-	}
-}
-
-void playback_paused(gint argc, gchar **argv)
-{
-	exit(!audacious_remote_is_paused(dbus_proxy));
-}
-
-void playback_stopped(gint argc, gchar **argv)
-{
-	if (!audacious_remote_is_playing(dbus_proxy) && !audacious_remote_is_paused(dbus_proxy))
-	{
-		exit(0);
-	}
-	else
-	{
-		exit(1);
-	}
-}
-
-void playback_status(gint argc, gchar **argv)
-{
-	if (audacious_remote_is_paused(dbus_proxy))
-	{
-		audtool_report("paused");
-		return;
-	}
-	else if (audacious_remote_is_playing(dbus_proxy))
-	{
-		audtool_report("playing");
-		return;
-	}
-	else
-	{
-		audtool_report("stopped");
-		return;
-	}
-}
-
-void playback_seek(gint argc, gchar **argv)
-{
-	if (argc < 2)
-	{
-		audtool_whine_args(argv[0], "<position>");
-		exit(1);
-	}
-
-	audacious_remote_jump_to_time(dbus_proxy, atoi(argv[1]) * 1000);
-}
-
-void playback_seek_relative(gint argc, gchar **argv)
-{
-	gint oldtime, newtime, diff;
-
-	if (argc < 2)
-	{
-		audtool_whine_args(argv[0], "<position>");
-		exit(1);
-	}
-
-	oldtime = audacious_remote_get_output_time(dbus_proxy);
-	diff = atoi(argv[1]) * 1000;
-	newtime = oldtime + diff;
-
-	audacious_remote_jump_to_time(dbus_proxy, newtime);
-}
--- a/src/audtool/audtool_handlers_playlist.c	Thu Jun 05 01:25:22 2008 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,354 +0,0 @@
-/*
- * Audtool2
- * Copyright (c) 2007 Audacious development team
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- *    this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * 3. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
- * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
- * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <stdlib.h>
-#include <string.h>
-#include <glib.h>
-#include <mowgli.h>
-#include <locale.h>
-#include "libaudclient/audctrl.h"
-#include "audtool.h"
-
-void playlist_reverse(gint argc, gchar **argv)
-{
-	audacious_remote_playlist_prev(dbus_proxy);
-}
-
-void playlist_advance(gint argc, gchar **argv)
-{
-	audacious_remote_playlist_next(dbus_proxy);
-}
-
-
-gint check_args_playlist_pos(gint argc, gchar **argv)
-{
-	gint playpos;
-
-	if (argc < 2)
-	{
-		audtool_whine_args(argv[0], "<position>");
-		exit(1);
-	}
-
-	playpos = atoi(argv[1]);
-
-	if (playpos < 1 || playpos > audacious_remote_get_playlist_length(dbus_proxy))
-	{
-		audtool_whine("invalid playlist position %d ('%s')\n", playpos, argv[1]);
-		exit(2);
-	}
-	
-	return playpos;
-}
-
-
-static gchar * construct_uri(gchar *string)
-{
-    gchar *filename = g_strdup(string);
-    gchar *tmp, *path;
-    gchar *uri = NULL;
-
-    // case 1: filename is raw full path or uri
-    if (filename[0] == '/' || strstr(filename, "://")) {
-        uri = g_filename_to_uri(filename, NULL, NULL);
-        if(!uri) {
-            uri = g_strdup(filename);
-        }
-        g_free(filename);
-    }
-    // case 2: filename is not raw full path nor uri.
-    // make full path with pwd. (using g_build_filename)
-    else {
-        path = g_get_current_dir();
-        tmp = g_build_filename(path, filename, NULL);
-        g_free(path); g_free(filename);
-        uri = g_filename_to_uri(tmp, NULL, NULL);
-        g_free(tmp);
-    }
-
-    return uri;
-}
-
-void playlist_add_url_string(gint argc, gchar **argv)
-{
-    gchar *uri;
-
-	if (argc < 2)
-	{
-		audtool_whine_args(argv[0], "<url>");
-		exit(1);
-	}
-
-    uri = construct_uri(argv[1]);
-    if (uri) {
-        audacious_remote_playlist_add_url_string(dbus_proxy, uri);
-    }
-    g_free(uri);
-}
-
-void playlist_delete(gint argc, gchar **argv)
-{
-    gint playpos = check_args_playlist_pos(argc, argv);
-	audacious_remote_playlist_delete(dbus_proxy, playpos - 1);
-}
-
-void playlist_length(gint argc, gchar **argv)
-{
-	gint i;
-
-	i = audacious_remote_get_playlist_length(dbus_proxy);
-
-	audtool_report("%d", i);
-}
-
-void playlist_song(gint argc, gchar **argv)
-{
-    gint playpos = check_args_playlist_pos(argc, argv);
-	gchar *song;
-
-	song = audacious_remote_get_playlist_title(dbus_proxy, playpos - 1);
-	audtool_report("%s", song);
-}
-
-
-void playlist_song_length(gint argc, gchar **argv)
-{
-    gint playpos = check_args_playlist_pos(argc, argv);
-	gint frames, length;
-
-	frames = audacious_remote_get_playlist_time(dbus_proxy, playpos - 1);
-	length = frames / 1000;
-
-	audtool_report("%d:%.2d", length / 60, length % 60);
-}
-
-void playlist_song_length_seconds(gint argc, gchar **argv)
-{
-    gint playpos = check_args_playlist_pos(argc, argv);
-	gint frames, length;
-
-	frames = audacious_remote_get_playlist_time(dbus_proxy, playpos - 1);
-	length = frames / 1000;
-
-	audtool_report("%d", length);
-}
-
-void playlist_song_length_frames(gint argc, gchar **argv)
-{
-    gint playpos = check_args_playlist_pos(argc, argv);
-	gint frames;
-
-	frames = audacious_remote_get_playlist_time(dbus_proxy, playpos - 1);
-
-	audtool_report("%d", frames);
-}
-
-void playlist_display(gint argc, gchar **argv)
-{
-	gint i, ii, frames, length, total;
-	gchar *songname;
-	gchar *fmt = NULL, *p;
-	gint column;
-
-	i = audacious_remote_get_playlist_length(dbus_proxy);
-
-	audtool_report("%d track%s.", i, i != 1 ? "s" : "");
-
-	total = 0;
-
-	for (ii = 0; ii < i; ii++)
-	{
-		songname = audacious_remote_get_playlist_title(dbus_proxy, ii);
-		frames = audacious_remote_get_playlist_time(dbus_proxy, ii);
-		length = frames / 1000;
-		total += length;
-
-		/* adjust width for multi byte characters */
-		column = 60;
-		if(songname){
-			p = songname;
-			while(*p){
-				gint stride;
-				stride = g_utf8_next_char(p) - p;
-				if(g_unichar_iswide(g_utf8_get_char(p))
-				   || g_unichar_iswide_cjk(g_utf8_get_char(p))
-                                ){
-					column += (stride - 2);
-				}
-				else {
-					column += (stride - 1);
-				}
-				p = g_utf8_next_char(p);
-			}
-
-		}
-
-		fmt = g_strdup_printf("%%4d | %%-%ds | %%d:%%.2d", column);
-		audtool_report(fmt, ii + 1, songname, length / 60, length % 60);
-		g_free(fmt);
-	}
-
-	audtool_report("Total length: %d:%.2d", total / 60, total % 60);
-}
-
-void playlist_position(gint argc, gchar **argv)
-{
-	gint i;
-
-	i = audacious_remote_get_playlist_pos(dbus_proxy);
-
-	audtool_report("%d", i + 1);
-}
-
-void playlist_song_filename(gint argc, gchar **argv)
-{
-    gint playpos = check_args_playlist_pos(argc, argv);
-
-	audtool_report("%s", audacious_remote_get_playlist_file(dbus_proxy, playpos - 1));
-}
-
-void playlist_jump(gint argc, gchar **argv)
-{
-    gint playpos = check_args_playlist_pos(argc, argv);
-
-	audacious_remote_set_playlist_pos(dbus_proxy, playpos - 1);
-}
-
-void playlist_clear(gint argc, gchar **argv)
-{
-	audacious_remote_stop(dbus_proxy);
-	audacious_remote_playlist_clear(dbus_proxy);
-}
-
-void playlist_repeat_status(gint argc, gchar **argv)
-{
-	if (audacious_remote_is_repeat(dbus_proxy))
-	{
-		audtool_report("on");
-	}
-	else
-	{
-		audtool_report("off");
-	}
-}
-
-void playlist_repeat_toggle(gint argc, gchar **argv)
-{
-	audacious_remote_toggle_repeat(dbus_proxy);
-}
-
-void playlist_shuffle_status(gint argc, gchar **argv)
-{
-	if (audacious_remote_is_shuffle(dbus_proxy))
-	{
-		audtool_report("on");
-	}
-	else
-	{
-		audtool_report("off");
-	}
-}
-
-void playlist_shuffle_toggle(gint argc, gchar **argv)
-{
-	audacious_remote_toggle_shuffle(dbus_proxy);
-}
-
-void playlist_tuple_field_data(gint argc, gchar **argv)
-{
-    gint i;
-	gchar *data;
-
-	if (argc < 3)
-	{
-		audtool_whine_args(argv[0], "<fieldname> <position>");
-		audtool_whine("  - fieldname example choices include but are not limited to:\n");
-		audtool_whine("      artist, album, title, track-number, year, date,\n");
-		audtool_whine("      genre, comment, file-name, file-ext, file-path,\n");
-		audtool_whine("      length, formatter, custom, mtime\n");
-		exit(1);
-	}
-
-	i = atoi(argv[2]);
-
-	if (i < 1 || i > audacious_remote_get_playlist_length(dbus_proxy))
-	{
-		audtool_whine("invalid playlist position %d\n", i);
-		exit(1);
-	}
-
-	if (!(data = audacious_get_tuple_field_data(dbus_proxy, argv[1], i - 1)))
-	{
-		return;
-	}
-	
-	audtool_report("%s", data);
-
-	g_free(data);
-}
-
-void playlist_ins_url_string(gint argc, gchar **argv)
-{
-    gint pos = -1;
-    gchar *uri;
-
-    if (argc < 3)
-    {
-        audtool_whine_args(argv[0], "<url> <position>");
-        exit(1);
-    }
-
-    pos = atoi(argv[2]) - 1;
-    if(pos >= 0) {
-        uri = construct_uri(argv[1]);
-        if (uri) {
-            audacious_remote_playlist_ins_url_string(dbus_proxy, uri, pos);
-        }
-        g_free(uri);
-    }
-}
-
-void playlist_enqueue_to_temp(gint argc, gchar **argv)
-{
-    gchar *uri;
-
-    if (argc < 2)
-    {
-        audtool_whine_args(argv[0], "<url>");
-        exit(1);
-    }
-
-    uri = construct_uri(argv[1]);
-    if (uri) {
-        audacious_remote_playlist_enqueue_to_temp(dbus_proxy, uri);
-    }
-    g_free(uri);
-}
--- a/src/audtool/audtool_handlers_playqueue.c	Thu Jun 05 01:25:22 2008 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,152 +0,0 @@
-/*
- * Audtool2
- * Copyright (c) 2007 Audacious development team
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- *    this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * 3. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
- * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
- * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <stdlib.h>
-#include <string.h>
-#include <glib.h>
-#include <mowgli.h>
-#include <locale.h>
-#include "libaudclient/audctrl.h"
-#include "audtool.h"
-
-void playqueue_add(gint argc, gchar **argv)
-{
-	gint i = check_args_playlist_pos(argc, argv);
-
-	if (!(audacious_remote_playqueue_is_queued(dbus_proxy, i - 1)))
-		audacious_remote_playqueue_add(dbus_proxy, i - 1);
-}
-
-void playqueue_remove(gint argc, gchar **argv)
-{
-	gint i = check_args_playlist_pos(argc, argv);
-
-	if (audacious_remote_playqueue_is_queued(dbus_proxy, i - 1))
-		audacious_remote_playqueue_remove(dbus_proxy, i - 1);
-}
-
-void playqueue_is_queued(gint argc, gchar **argv)
-{
-	gint i = check_args_playlist_pos(argc, argv);
-
-    if (audacious_remote_playqueue_is_queued(dbus_proxy, i - 1)) {
-        audtool_report("OK");
-        exit(0);
-    }
-    else
-        exit(1);
-}
-
-void playqueue_get_queue_position(gint argc, gchar **argv)
-{
-	gint pos, i = check_args_playlist_pos(argc, argv);
-
-	pos = audacious_remote_get_playqueue_queue_position(dbus_proxy, i - 1) + 1;
-
-	if (pos < 1)
-		return;
-
-	audtool_report("%d", pos);
-}
-
-void playqueue_get_list_position(gint argc, gchar **argv)
-{
-	gint pos, i = check_args_playlist_pos(argc, argv);
-
-	pos = audacious_remote_get_playqueue_list_position(dbus_proxy, i - 1) + 1;
-
-	if (pos < 1)
-		return;
-
-	audtool_report("%d", pos);
-}
-
-void playqueue_display(gint argc, gchar **argv)
-{
-	gint i, ii, position, frames, length, total;
-	gchar *songname;
-	gchar *fmt = NULL, *p;
-	gint column;
-	
-	i = audacious_remote_get_playqueue_length(dbus_proxy);
-
-	audtool_report("%d queued tracks.", i);
-
-	total = 0;
-
-	for (ii = 0; ii < i; ii++)
-	{
-		position = audacious_remote_get_playqueue_list_position(dbus_proxy, ii);
-		songname = audacious_remote_get_playlist_title(dbus_proxy, position);
-		frames = audacious_remote_get_playlist_time(dbus_proxy, position);
-		length = frames / 1000;
-		total += length;
-
-		/* adjust width for multi byte characters */
-		column = 60;
-		if(songname) {
-			p = songname;
-			while(*p){
-				gint stride;
-				stride = g_utf8_next_char(p) - p;
-				if(g_unichar_iswide(g_utf8_get_char(p))
-				   || g_unichar_iswide_cjk(g_utf8_get_char(p))
-				){
-					column += (stride - 2);
-				}
-				else {
-					column += (stride - 1);
-				}
-				p = g_utf8_next_char(p);
-			}
-		}
-
-		fmt = g_strdup_printf("%%4d | %%4d | %%-%ds | %%d:%%.2d", column);
-		audtool_report(fmt, ii + 1, position + 1, songname, length / 60, length % 60);
-		g_free(fmt);
-	}
-
-	audtool_report("Total length: %d:%.2d", total / 60, total % 60);
-}
-
-void playqueue_length(gint argc, gchar **argv)
-{
-	gint i;
-
-	i = audacious_remote_get_playqueue_length(dbus_proxy);
-
-	audtool_report("%d", i);
-}
-
-void playqueue_clear(gint argc, gchar **argv)
-{
-	audacious_remote_playqueue_clear(dbus_proxy);
-}
--- a/src/audtool/audtool_handlers_vitals.c	Thu Jun 05 01:25:22 2008 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,193 +0,0 @@
-/*
- * Audtool2
- * Copyright (c) 2007 Audacious development team
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- *    this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * 3. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
- * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
- * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <stdlib.h>
-#include <string.h>
-#include <glib.h>
-#include <mowgli.h>
-#include <locale.h>
-#include "libaudclient/audctrl.h"
-#include "audtool.h"
-
-void get_current_song(gint argc, gchar **argv)
-{
-	gint playpos = audacious_remote_get_playlist_pos(dbus_proxy);
-	gchar *song = audacious_remote_get_playlist_title(dbus_proxy, playpos);
-
-	if (!song)
-	{
-		audtool_report("No song playing.");
-		return;
-	}
-
-	audtool_report("%s", song);
-}
-
-void get_current_song_filename(gint argc, gchar **argv)
-{
-	gint playpos = audacious_remote_get_playlist_pos(dbus_proxy);
-	gchar *file = audacious_remote_get_playlist_file(dbus_proxy, playpos);
-
-	if (!file)
-	{
-		audtool_report("No song playing.");
-		return;
-	}
-        
-	audtool_report("%s", file);
-}
-
-void get_current_song_output_length(gint argc, gchar **argv)
-{
-	gint frames = audacious_remote_get_output_time(dbus_proxy);
-	gint length = frames / 1000;
-
-	audtool_report("%d:%.2d", length / 60, length % 60);
-}
-
-void get_current_song_output_length_seconds(gint argc, gchar **argv)
-{
-	gint frames = audacious_remote_get_output_time(dbus_proxy);
-	gint length = frames / 1000;
-
-	audtool_report("%d", length);
-}
-
-void get_current_song_output_length_frames(gint argc, gchar **argv)
-{
-	gint frames = audacious_remote_get_output_time(dbus_proxy);
-
-	audtool_report("%d", frames);
-}
-
-void get_current_song_length(gint argc, gchar **argv)
-{
-	gint playpos = audacious_remote_get_playlist_pos(dbus_proxy);
-	gint frames = audacious_remote_get_playlist_time(dbus_proxy, playpos);
-	gint length = frames / 1000;
-
-	audtool_report("%d:%.2d", length / 60, length % 60);
-}
-
-void get_current_song_length_seconds(gint argc, gchar **argv)
-{
-	gint playpos = audacious_remote_get_playlist_pos(dbus_proxy);
-	gint frames = audacious_remote_get_playlist_time(dbus_proxy, playpos);
-	gint length = frames / 1000;
-
-	audtool_report("%d", length);
-}
-
-void get_current_song_length_frames(gint argc, gchar **argv)
-{
-	gint playpos = audacious_remote_get_playlist_pos(dbus_proxy);
-	gint frames = audacious_remote_get_playlist_time(dbus_proxy, playpos);
-
-	audtool_report("%d", frames);
-}
-
-void get_current_song_bitrate(gint argc, gchar **argv)
-{
-	gint rate, freq, nch;
-
-	audacious_remote_get_info(dbus_proxy, &rate, &freq, &nch);
-
-	audtool_report("%d", rate);
-}
-
-void get_current_song_bitrate_kbps(gint argc, gchar **argv)
-{
-	gint rate, freq, nch;
-
-	audacious_remote_get_info(dbus_proxy, &rate, &freq, &nch);
-
-	audtool_report("%d", rate / 1000);
-}
-
-void get_current_song_frequency(gint argc, gchar **argv)
-{
-	gint rate, freq, nch;
-
-	audacious_remote_get_info(dbus_proxy, &rate, &freq, &nch);
-
-	audtool_report("%d", freq);
-}
-
-void get_current_song_frequency_khz(gint argc, gchar **argv)
-{
-	gint rate, freq, nch;
-
-	audacious_remote_get_info(dbus_proxy, &rate, &freq, &nch);
-
-	audtool_report("%0.1f", (gfloat) freq / 1000);
-}
-
-void get_current_song_channels(gint argc, gchar **argv)
-{
-	gint rate, freq, nch;
-
-	audacious_remote_get_info(dbus_proxy, &rate, &freq, &nch);
-
-	audtool_report("%d", nch);
-}
-
-void get_current_song_tuple_field_data(gint argc, gchar **argv)
-{
-	gchar *data;
-
-	if (argc < 2)
-	{
-		audtool_whine_args(argv[0], "<fieldname>");
-		audtool_whine("  - fieldname example choices include but are not limited to:\n");
-		audtool_whine("      artist, album, title, track-number, year, date,\n");
-		audtool_whine("      genre, comment, file-name, file-ext, file-path,\n");
-		audtool_whine("      length, formatter, custom, mtime\n");
-		exit(1);
-	}
-
-	if (!(data = audacious_get_tuple_field_data(dbus_proxy, argv[1], audacious_remote_get_playlist_pos(dbus_proxy))))
-	{
-		return;
-	}
-	
-	audtool_report("%s", data);
-
-	g_free(data);
-}
-
-void get_current_song_info(gint argc, gchar **argv)
-{
-    gint rate, freq, nch;
-
-    audacious_remote_get_info(dbus_proxy, &rate, &freq, &nch);
-    audtool_report("rate = %d freq = %d nch = %d", rate, freq, nch);
-}
-
--- a/src/audtool/audtool_main.c	Thu Jun 05 01:25:22 2008 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,209 +0,0 @@
-/*
- * Audtool2
- * Copyright (c) 2007 Audacious development team
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- *    this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * 3. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
- * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
- * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <stdlib.h>
-#include <string.h>
-#include <glib.h>
-#include <mowgli.h>
-#include <locale.h>
-#include "libaudclient/audctrl.h"
-#include "audtool.h"
-
-struct commandhandler handlers[] = {
-	{"<sep>", NULL, "Vital information", 0},
-	{"current-song", get_current_song, "returns current song title", 0},
-	{"current-song-filename", get_current_song_filename, "returns current song filename", 0},
-	{"current-song-length", get_current_song_length, "returns current song length", 0},
-	{"current-song-length-seconds", get_current_song_length_seconds, "returns current song length in seconds", 0},
-	{"current-song-length-frames", get_current_song_length_frames, "returns current song length in frames", 0},
-	{"current-song-output-length", get_current_song_output_length, "returns current song output length", 0},
-	{"current-song-output-length-seconds", get_current_song_output_length_seconds, "returns current song output length in seconds", 0},
-	{"current-song-output-length-frames", get_current_song_output_length_frames, "returns current song output length in frames", 0},
-	{"current-song-bitrate", get_current_song_bitrate, "returns current song bitrate in bits per second", 0},
-	{"current-song-bitrate-kbps", get_current_song_bitrate_kbps, "returns current song bitrate in kilobits per second", 0},
-	{"current-song-frequency", get_current_song_frequency, "returns current song frequency in hertz", 0},
-	{"current-song-frequency-khz", get_current_song_frequency_khz, "returns current song frequency in kilohertz", 0},
-	{"current-song-channels", get_current_song_channels, "returns current song channels", 0},
-	{"current-song-tuple-data", get_current_song_tuple_field_data, "returns the value of a tuple field for the current song", 1},
-    {"current-song-info", get_current_song_info, "returns current song bitrate, frequency and channels", 0},
-
-
-	{"<sep>", NULL, "Playlist manipulation", 0},
-	{"playlist-advance", playlist_advance, "go to the next song in the playlist", 0},
-	{"playlist-reverse", playlist_reverse, "go to the previous song in the playlist", 0},
-	{"playlist-addurl", playlist_add_url_string, "adds a url to the playlist", 1},
-    {"playlist-insurl", playlist_ins_url_string, "inserts a url at specified position in the playlist", 2},
-	{"playlist-addurl-to-new-playlist", playlist_enqueue_to_temp, "adds a url to the newly created playlist", 1},
-	{"playlist-delete", playlist_delete, "deletes a song from the playlist", 1},
-	{"playlist-length", playlist_length, "returns the total length of the playlist", 0},
-	{"playlist-song", playlist_song, "returns the title of a song in the playlist", 1},
-	{"playlist-song-filename", playlist_song_filename, "returns the filename of a song in the playlist", 1},
-	{"playlist-song-length", playlist_song_length, "returns the length of a song in the playlist", 1},
-	{"playlist-song-length-seconds", playlist_song_length_seconds, "returns the length of a song in the playlist in seconds", 1},
-	{"playlist-song-length-frames", playlist_song_length_frames, "returns the length of a song in the playlist in frames", 1},
-	{"playlist-display", playlist_display, "returns the entire playlist", 0},
-	{"playlist-position", playlist_position, "returns the position in the playlist", 0},
-	{"playlist-jump", playlist_jump, "jumps to a position in the playlist", 1},
-	{"playlist-clear", playlist_clear, "clears the playlist", 0},
-	{"playlist-repeat-status", playlist_repeat_status, "returns the status of playlist repeat", 0},
-	{"playlist-repeat-toggle", playlist_repeat_toggle, "toggles playlist repeat", 0},
-	{"playlist-shuffle-status", playlist_shuffle_status, "returns the status of playlist shuffle", 0},
-	{"playlist-shuffle-toggle", playlist_shuffle_toggle, "toggles playlist shuffle", 0},
-	{"playlist-tuple-data", playlist_tuple_field_data, "returns the value of a tuple field for a song in the playlist", 2},
-
-
-	{"<sep>", NULL, "Playqueue manipulation", 0},
-	{"playqueue-add", playqueue_add, "adds a song to the playqueue", 1},
-	{"playqueue-remove", playqueue_remove, "removes a song from the playqueue", 1},
-	{"playqueue-is-queued", playqueue_is_queued, "returns OK if a song is queued", 1},
-	{"playqueue-get-queue-position", playqueue_get_queue_position, "returns the playqueue position of a song in the given poition in the playlist", 1},
-	{"playqueue-get-list-position", playqueue_get_list_position, "returns the playlist position of a song in the given position in the playqueue", 1},
-	{"playqueue-length", playqueue_length, "returns the length of the playqueue", 0},
-	{"playqueue-display", playqueue_display, "returns a list of currently-queued songs", 0},
-	{"playqueue-clear", playqueue_clear, "clears the playqueue", 0},
-
-
-	{"<sep>", NULL, "Playback manipulation", 0},
-	{"playback-play", playback_play, "starts/unpauses song playback", 0},
-	{"playback-pause", playback_pause, "(un)pauses song playback", 0},
-	{"playback-playpause", playback_playpause, "plays/(un)pauses song playback", 0},
-	{"playback-stop", playback_stop, "stops song playback", 0},
-	{"playback-playing", playback_playing, "returns OK if audacious is playing", 0},
-	{"playback-paused", playback_paused, "returns OK if audacious is paused", 0},
-	{"playback-stopped", playback_stopped, "returns OK if audacious is stopped", 0},
-	{"playback-status", playback_status, "returns the playback status", 0},
-	{"playback-seek", playback_seek, "performs an absolute seek", 1},
-	{"playback-seek-relative", playback_seek_relative, "performs a seek relative to the current position", 1},
-
-
-	{"<sep>", NULL, "Volume control", 0},
-	{"get-volume", get_volume, "returns the current volume level in percent", 0},
-	{"set-volume", set_volume, "sets the current volume level in percent", 1},
-
-
-	{"<sep>", NULL, "Equalizer manipulation", 0},
-    {"equalizer-activate", equalizer_active, "activates/deactivates the equalizer", 1},
-    {"equalizer-get", equalizer_get_eq, "gets the equalizer settings", 0},
-    {"equalizer-set", equalizer_set_eq, "sets the equalizer settings", 11},
-    {"equalizer-get-preamp", equalizer_get_eq_preamp, "gets the equalizer pre-amplification", 0},
-    {"equalizer-set-preamp", equalizer_set_eq_preamp, "sets the equalizer pre-amplification", 1},
-    {"equalizer-get-band", equalizer_get_eq_band, "gets the equalizer value in specified band", 1},
-    {"equalizer-set-band", equalizer_set_eq_band, "sets the equalizer value in the specified band", 2},
-
-
-	{"<sep>", NULL, "Miscellaneous", 0},
-	{"mainwin-show", mainwin_show, "shows/hides the main window", 1},
-	{"playlist-show", playlist_show, "shows/hides the playlist window", 1},
-	{"equalizer-show", equalizer_show, "shows/hides the equalizer window", 1},
-
-	{"filebrowser-show", show_filebrowser, "shows/hides the filebrowser", 1},
-	{"jumptofile-show", show_jtf_window, "shows/hides the jump to file window", 1},
-	{"preferences-show", show_preferences_window, "shows/hides the preferences window", 1},
-	{"about-show", show_about_window, "shows/hides the about window", 1},
-
-	{"activate", activate, "activates and raises audacious", 0},
-	{"always-on-top", toggle_aot, "on/off always on top", 1},
-    {"get-skin", get_skin, "gets skin", 0},
-    {"set-skin", set_skin, "sets skin", 1},
-    {"version", get_version, "shows audaciuos version", 0},
-	{"shutdown", shutdown_audacious_server, "shuts down audacious", 0},
-
-
-	{"<sep>", NULL, "Help system", 0},
-	{"list-handlers", get_handlers_list, "shows handlers list", 0},
-	{"help", get_handlers_list, "shows handlers list", 0},
-
-    
-	{NULL, NULL, NULL, 0}
-};
-
-mowgli_error_context_t *e = NULL;
-DBusGProxy *dbus_proxy = NULL;
-static DBusGConnection *connection = NULL;
-
-static void audtool_connect(void)
-{
-	GError *error = NULL;
-
-	mowgli_error_context_push(e, "While attempting to connect to the D-Bus session bus");
-	connection = dbus_g_bus_get(DBUS_BUS_SESSION, &error);
-
-	if (connection == NULL)
-		mowgli_error_context_display_with_error(e, ":\n  * ", g_strdup_printf("D-Bus Error: %s", error->message));
-
-	mowgli_error_context_pop(e);
-
-	dbus_proxy = dbus_g_proxy_new_for_name(connection, AUDACIOUS_DBUS_SERVICE,
-                                           AUDACIOUS_DBUS_PATH,
-                                           AUDACIOUS_DBUS_INTERFACE);
-}
-
-gint main(gint argc, gchar **argv)
-{
-	gint i, j = 0, k = 0;
-
-	setlocale(LC_CTYPE, "");
-	g_type_init();
-	mowgli_init();
-
-	e = mowgli_error_context_create();
-	mowgli_error_context_push(e, "In program %s", argv[0]);
-
-	audtool_connect();
-
-	mowgli_error_context_push(e, "While processing the commandline");
-
-	if (argc < 2)
-		mowgli_error_context_display_with_error(e, ":\n  * ", "not enough parameters, use \'audtool help\' for more information.");
-
-	for (j = 1; j < argc; j++)
-	{
-		for (i = 0; handlers[i].name != NULL; i++)
-		{
-			if ((!g_ascii_strcasecmp(handlers[i].name, argv[j]) ||
-			     !g_ascii_strcasecmp(g_strconcat("--", handlers[i].name, NULL), argv[j]))
-			    && g_ascii_strcasecmp("<sep>", handlers[i].name))
-  			{
-				int numargs = handlers[i].args + 1 < argc - 1 ? handlers[i].args + 1 : argc - 1;
-				handlers[i].handler(numargs, &argv[j]);
-				j += handlers[i].args;
-				k++;
-				if(j >= argc)
-					break;
-			}
-		}
-	}
-
-	if (k == 0)
-		mowgli_error_context_display_with_error(e, ":\n  * ", g_strdup_printf("Unknown command '%s' encountered, use \'audtool help\' for a command list.", argv[1]));
-
-	return 0;
-}
--- a/src/audtool/audtool_report.c	Thu Jun 05 01:25:22 2008 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,78 +0,0 @@
-/*
- * Audtool2
- * Copyright (c) 2007 Audacious development team
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- *    this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * 3. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
- * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
- * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <stdlib.h>
-#include <string.h>
-#include <glib.h>
-#include <mowgli.h>
-#include <locale.h>
-#include "libaudclient/audctrl.h"
-#include "audtool.h"
-
-void audtool_report(const gchar *str, ...)
-{
-	gchar *buf;
-	va_list va;
-
-	va_start(va, str);
-	buf = g_strdup_vprintf(str, va);
-	va_end(va);
-
-	g_print("%s\n", buf);
-	g_free(buf);
-}
-
-void audtool_whine(const gchar *str, ...)
-{
-	gchar *buf;
-	va_list va;
-
-	va_start(va, str);
-	buf = g_strdup_vprintf(str, va);
-	va_end(va);
-
-	g_printerr("audtool: %s", buf);
-	g_free(buf);
-}
-
-void audtool_whine_args(const gchar *name, const gchar *fmt, ...)
-{
-	gchar *buf;
-	va_list va;
-
-	va_start(va, fmt);
-	buf = g_strdup_vprintf(fmt, va);
-	va_end(va);
-
-	g_printerr("audtool: Invalid parameters for %s\n", name);
-	g_printerr(" syntax: %s %s\n", name, buf);
-	g_free(buf);
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/audtool/handlers_equalizer.c	Thu Jun 05 01:27:43 2008 +0300
@@ -0,0 +1,155 @@
+/*
+ * Audtool2
+ * Copyright (c) 2007 Audacious development team
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ *    this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <stdlib.h>
+#include <string.h>
+#include <glib.h>
+#include <mowgli.h>
+#include <locale.h>
+#include "libaudclient/audctrl.h"
+#include "audtool.h"
+
+void equalizer_get_eq(gint argc, gchar **argv)
+{
+    double preamp;
+    GArray *bands;
+    int i;
+
+    audacious_remote_get_eq(dbus_proxy, &preamp, &bands);
+
+    audtool_report("preamp = %.2f", preamp);
+    for(i=0; i<10; i++){
+        printf("%.2f ", g_array_index(bands, gdouble, i));
+    }
+    printf("\n");
+    g_array_free(bands, TRUE);
+}
+
+void equalizer_get_eq_preamp(gint argc, gchar **argv)
+{
+    audtool_report("preamp = %.2f", audacious_remote_get_eq_preamp(dbus_proxy));
+}
+
+void equalizer_get_eq_band(gint argc, gchar **argv)
+{
+    int band;
+
+    if (argc < 2)
+    {
+        audtool_whine_args(argv[0], "<band>");
+        exit(1);
+    }
+
+    band = atoi(argv[1]);
+
+    /* FIXME, XXX, TODO: we should have a function for requesting
+     * the actual number of bands, if we support dynamic amount some day ...
+     * -- ccr
+     */
+    if (band < 0 || band > 9)
+    {
+        audtool_whine("band number out of range\n");
+        exit(1);
+    }
+    
+    audtool_report("band %d = %.2f", band, audacious_remote_get_eq_band(dbus_proxy, band));
+    
+}
+
+void equalizer_set_eq(gint argc, gchar **argv)
+{
+    gdouble preamp;
+    GArray *bands = g_array_sized_new(FALSE, FALSE, sizeof(gdouble), 10);
+    int i;
+
+    if (argc < 12)
+    {
+        audtool_whine_args(argv[0], "<preamp> <band0> <band1> <band2> <band3> <band4> <band5> <band6> <band7> <band8> <band9>");
+        exit(1);
+    }
+
+    preamp = atof(argv[1]);
+    
+    for(i=0; i<10; i++){
+        gdouble val = atof(argv[i+2]);
+        g_array_append_val(bands, val);
+    }
+    
+    audacious_remote_set_eq(dbus_proxy, preamp, bands);
+}
+
+void equalizer_set_eq_preamp(gint argc, gchar **argv)
+{
+    gdouble preamp;
+
+    if (argc < 2)
+    {
+        audtool_whine_args(argv[0], "<preamp>");
+        exit(1);
+    }
+
+    preamp = atof(argv[1]);
+
+    audacious_remote_set_eq_preamp(dbus_proxy, preamp);
+}
+
+void equalizer_set_eq_band(gint argc, gchar **argv)
+{
+    int band;
+    gdouble preamp;
+
+    if (argc < 3)
+    {
+        audtool_whine_args(argv[0], "<band> <value>");
+        exit(1);
+    }
+
+    band = atoi(argv[1]);
+    preamp = atof(argv[2]);
+
+    audacious_remote_set_eq_band(dbus_proxy, band, preamp);
+}
+
+void equalizer_active(gint argc, gchar **argv)
+{
+    if (argc < 2)
+    {
+        audtool_whine_args(argv[0], "<on/off>");
+        exit(1);
+    }
+
+    if (!g_ascii_strcasecmp(argv[1], "on")) {
+        audacious_remote_eq_activate(dbus_proxy, TRUE);
+    }
+    else if (!g_ascii_strcasecmp(argv[1], "off")) {
+        audacious_remote_eq_activate(dbus_proxy, FALSE);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/audtool/handlers_playback.c	Thu Jun 05 01:27:43 2008 +0300
@@ -0,0 +1,141 @@
+/*
+ * Audtool2
+ * Copyright (c) 2007 Audacious development team
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ *    this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <stdlib.h>
+#include <string.h>
+#include <glib.h>
+#include <mowgli.h>
+#include <locale.h>
+#include "libaudclient/audctrl.h"
+#include "audtool.h"
+
+void playback_play(gint argc, gchar **argv)
+{
+	audacious_remote_play(dbus_proxy);
+}
+
+void playback_pause(gint argc, gchar **argv)
+{
+	audacious_remote_pause(dbus_proxy);
+}
+
+void playback_playpause(gint argc, gchar **argv)
+{
+	if (audacious_remote_is_playing(dbus_proxy))
+	{
+		audacious_remote_pause(dbus_proxy);
+	}
+	else
+	{
+		audacious_remote_play(dbus_proxy);
+	}
+}
+
+void playback_stop(gint argc, gchar **argv)
+{
+	audacious_remote_stop(dbus_proxy);
+}
+
+void playback_playing(gint argc, gchar **argv)
+{
+	if (!audacious_remote_is_paused(dbus_proxy))
+	{
+		exit(!audacious_remote_is_playing(dbus_proxy));
+	}
+	else
+	{
+		exit(1);
+	}
+}
+
+void playback_paused(gint argc, gchar **argv)
+{
+	exit(!audacious_remote_is_paused(dbus_proxy));
+}
+
+void playback_stopped(gint argc, gchar **argv)
+{
+	if (!audacious_remote_is_playing(dbus_proxy) && !audacious_remote_is_paused(dbus_proxy))
+	{
+		exit(0);
+	}
+	else
+	{
+		exit(1);
+	}
+}
+
+void playback_status(gint argc, gchar **argv)
+{
+	if (audacious_remote_is_paused(dbus_proxy))
+	{
+		audtool_report("paused");
+		return;
+	}
+	else if (audacious_remote_is_playing(dbus_proxy))
+	{
+		audtool_report("playing");
+		return;
+	}
+	else
+	{
+		audtool_report("stopped");
+		return;
+	}
+}
+
+void playback_seek(gint argc, gchar **argv)
+{
+	if (argc < 2)
+	{
+		audtool_whine_args(argv[0], "<position>");
+		exit(1);
+	}
+
+	audacious_remote_jump_to_time(dbus_proxy, atoi(argv[1]) * 1000);
+}
+
+void playback_seek_relative(gint argc, gchar **argv)
+{
+	gint oldtime, newtime, diff;
+
+	if (argc < 2)
+	{
+		audtool_whine_args(argv[0], "<position>");
+		exit(1);
+	}
+
+	oldtime = audacious_remote_get_output_time(dbus_proxy);
+	diff = atoi(argv[1]) * 1000;
+	newtime = oldtime + diff;
+
+	audacious_remote_jump_to_time(dbus_proxy, newtime);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/audtool/handlers_playlist.c	Thu Jun 05 01:27:43 2008 +0300
@@ -0,0 +1,354 @@
+/*
+ * Audtool2
+ * Copyright (c) 2007 Audacious development team
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ *    this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <stdlib.h>
+#include <string.h>
+#include <glib.h>
+#include <mowgli.h>
+#include <locale.h>
+#include "libaudclient/audctrl.h"
+#include "audtool.h"
+
+void playlist_reverse(gint argc, gchar **argv)
+{
+	audacious_remote_playlist_prev(dbus_proxy);
+}
+
+void playlist_advance(gint argc, gchar **argv)
+{
+	audacious_remote_playlist_next(dbus_proxy);
+}
+
+
+gint check_args_playlist_pos(gint argc, gchar **argv)
+{
+	gint playpos;
+
+	if (argc < 2)
+	{
+		audtool_whine_args(argv[0], "<position>");
+		exit(1);
+	}
+
+	playpos = atoi(argv[1]);
+
+	if (playpos < 1 || playpos > audacious_remote_get_playlist_length(dbus_proxy))
+	{
+		audtool_whine("invalid playlist position %d ('%s')\n", playpos, argv[1]);
+		exit(2);
+	}
+	
+	return playpos;
+}
+
+
+static gchar * construct_uri(gchar *string)
+{
+    gchar *filename = g_strdup(string);
+    gchar *tmp, *path;
+    gchar *uri = NULL;
+
+    // case 1: filename is raw full path or uri
+    if (filename[0] == '/' || strstr(filename, "://")) {
+        uri = g_filename_to_uri(filename, NULL, NULL);
+        if(!uri) {
+            uri = g_strdup(filename);
+        }
+        g_free(filename);
+    }
+    // case 2: filename is not raw full path nor uri.
+    // make full path with pwd. (using g_build_filename)
+    else {
+        path = g_get_current_dir();
+        tmp = g_build_filename(path, filename, NULL);
+        g_free(path); g_free(filename);
+        uri = g_filename_to_uri(tmp, NULL, NULL);
+        g_free(tmp);
+    }
+
+    return uri;
+}
+
+void playlist_add_url_string(gint argc, gchar **argv)
+{
+    gchar *uri;
+
+	if (argc < 2)
+	{
+		audtool_whine_args(argv[0], "<url>");
+		exit(1);
+	}
+
+    uri = construct_uri(argv[1]);
+    if (uri) {
+        audacious_remote_playlist_add_url_string(dbus_proxy, uri);
+    }
+    g_free(uri);
+}
+
+void playlist_delete(gint argc, gchar **argv)
+{
+    gint playpos = check_args_playlist_pos(argc, argv);
+	audacious_remote_playlist_delete(dbus_proxy, playpos - 1);
+}
+
+void playlist_length(gint argc, gchar **argv)
+{
+	gint i;
+
+	i = audacious_remote_get_playlist_length(dbus_proxy);
+
+	audtool_report("%d", i);
+}
+
+void playlist_song(gint argc, gchar **argv)
+{
+    gint playpos = check_args_playlist_pos(argc, argv);
+	gchar *song;
+
+	song = audacious_remote_get_playlist_title(dbus_proxy, playpos - 1);
+	audtool_report("%s", song);
+}
+
+
+void playlist_song_length(gint argc, gchar **argv)
+{
+    gint playpos = check_args_playlist_pos(argc, argv);
+	gint frames, length;
+
+	frames = audacious_remote_get_playlist_time(dbus_proxy, playpos - 1);
+	length = frames / 1000;
+
+	audtool_report("%d:%.2d", length / 60, length % 60);
+}
+
+void playlist_song_length_seconds(gint argc, gchar **argv)
+{
+    gint playpos = check_args_playlist_pos(argc, argv);
+	gint frames, length;
+
+	frames = audacious_remote_get_playlist_time(dbus_proxy, playpos - 1);
+	length = frames / 1000;
+
+	audtool_report("%d", length);
+}
+
+void playlist_song_length_frames(gint argc, gchar **argv)
+{
+    gint playpos = check_args_playlist_pos(argc, argv);
+	gint frames;
+
+	frames = audacious_remote_get_playlist_time(dbus_proxy, playpos - 1);
+
+	audtool_report("%d", frames);
+}
+
+void playlist_display(gint argc, gchar **argv)
+{
+	gint i, ii, frames, length, total;
+	gchar *songname;
+	gchar *fmt = NULL, *p;
+	gint column;
+
+	i = audacious_remote_get_playlist_length(dbus_proxy);
+
+	audtool_report("%d track%s.", i, i != 1 ? "s" : "");
+
+	total = 0;
+
+	for (ii = 0; ii < i; ii++)
+	{
+		songname = audacious_remote_get_playlist_title(dbus_proxy, ii);
+		frames = audacious_remote_get_playlist_time(dbus_proxy, ii);
+		length = frames / 1000;
+		total += length;
+
+		/* adjust width for multi byte characters */
+		column = 60;
+		if(songname){
+			p = songname;
+			while(*p){
+				gint stride;
+				stride = g_utf8_next_char(p) - p;
+				if(g_unichar_iswide(g_utf8_get_char(p))
+				   || g_unichar_iswide_cjk(g_utf8_get_char(p))
+                                ){
+					column += (stride - 2);
+				}
+				else {
+					column += (stride - 1);
+				}
+				p = g_utf8_next_char(p);
+			}
+
+		}
+
+		fmt = g_strdup_printf("%%4d | %%-%ds | %%d:%%.2d", column);
+		audtool_report(fmt, ii + 1, songname, length / 60, length % 60);
+		g_free(fmt);
+	}
+
+	audtool_report("Total length: %d:%.2d", total / 60, total % 60);
+}
+
+void playlist_position(gint argc, gchar **argv)
+{
+	gint i;
+
+	i = audacious_remote_get_playlist_pos(dbus_proxy);
+
+	audtool_report("%d", i + 1);
+}
+
+void playlist_song_filename(gint argc, gchar **argv)
+{
+    gint playpos = check_args_playlist_pos(argc, argv);
+
+	audtool_report("%s", audacious_remote_get_playlist_file(dbus_proxy, playpos - 1));
+}
+
+void playlist_jump(gint argc, gchar **argv)
+{
+    gint playpos = check_args_playlist_pos(argc, argv);
+
+	audacious_remote_set_playlist_pos(dbus_proxy, playpos - 1);
+}
+
+void playlist_clear(gint argc, gchar **argv)
+{
+	audacious_remote_stop(dbus_proxy);
+	audacious_remote_playlist_clear(dbus_proxy);
+}
+
+void playlist_repeat_status(gint argc, gchar **argv)
+{
+	if (audacious_remote_is_repeat(dbus_proxy))
+	{
+		audtool_report("on");
+	}
+	else
+	{
+		audtool_report("off");
+	}
+}
+
+void playlist_repeat_toggle(gint argc, gchar **argv)
+{
+	audacious_remote_toggle_repeat(dbus_proxy);
+}
+
+void playlist_shuffle_status(gint argc, gchar **argv)
+{
+	if (audacious_remote_is_shuffle(dbus_proxy))
+	{
+		audtool_report("on");
+	}
+	else
+	{
+		audtool_report("off");
+	}
+}
+
+void playlist_shuffle_toggle(gint argc, gchar **argv)
+{
+	audacious_remote_toggle_shuffle(dbus_proxy);
+}
+
+void playlist_tuple_field_data(gint argc, gchar **argv)
+{
+    gint i;
+	gchar *data;
+
+	if (argc < 3)
+	{
+		audtool_whine_args(argv[0], "<fieldname> <position>");
+		audtool_whine("  - fieldname example choices include but are not limited to:\n");
+		audtool_whine("      artist, album, title, track-number, year, date,\n");
+		audtool_whine("      genre, comment, file-name, file-ext, file-path,\n");
+		audtool_whine("      length, formatter, custom, mtime\n");
+		exit(1);
+	}
+
+	i = atoi(argv[2]);
+
+	if (i < 1 || i > audacious_remote_get_playlist_length(dbus_proxy))
+	{
+		audtool_whine("invalid playlist position %d\n", i);
+		exit(1);
+	}
+
+	if (!(data = audacious_get_tuple_field_data(dbus_proxy, argv[1], i - 1)))
+	{
+		return;
+	}
+	
+	audtool_report("%s", data);
+
+	g_free(data);
+}
+
+void playlist_ins_url_string(gint argc, gchar **argv)
+{
+    gint pos = -1;
+    gchar *uri;
+
+    if (argc < 3)
+    {
+        audtool_whine_args(argv[0], "<url> <position>");
+        exit(1);
+    }
+
+    pos = atoi(argv[2]) - 1;
+    if(pos >= 0) {
+        uri = construct_uri(argv[1]);
+        if (uri) {
+            audacious_remote_playlist_ins_url_string(dbus_proxy, uri, pos);
+        }
+        g_free(uri);
+    }
+}
+
+void playlist_enqueue_to_temp(gint argc, gchar **argv)
+{
+    gchar *uri;
+
+    if (argc < 2)
+    {
+        audtool_whine_args(argv[0], "<url>");
+        exit(1);
+    }
+
+    uri = construct_uri(argv[1]);
+    if (uri) {
+        audacious_remote_playlist_enqueue_to_temp(dbus_proxy, uri);
+    }
+    g_free(uri);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/audtool/handlers_playqueue.c	Thu Jun 05 01:27:43 2008 +0300
@@ -0,0 +1,152 @@
+/*
+ * Audtool2
+ * Copyright (c) 2007 Audacious development team
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ *    this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <stdlib.h>
+#include <string.h>
+#include <glib.h>
+#include <mowgli.h>
+#include <locale.h>
+#include "libaudclient/audctrl.h"
+#include "audtool.h"
+
+void playqueue_add(gint argc, gchar **argv)
+{
+	gint i = check_args_playlist_pos(argc, argv);
+
+	if (!(audacious_remote_playqueue_is_queued(dbus_proxy, i - 1)))
+		audacious_remote_playqueue_add(dbus_proxy, i - 1);
+}
+
+void playqueue_remove(gint argc, gchar **argv)
+{
+	gint i = check_args_playlist_pos(argc, argv);
+
+	if (audacious_remote_playqueue_is_queued(dbus_proxy, i - 1))
+		audacious_remote_playqueue_remove(dbus_proxy, i - 1);
+}
+
+void playqueue_is_queued(gint argc, gchar **argv)
+{
+	gint i = check_args_playlist_pos(argc, argv);
+
+    if (audacious_remote_playqueue_is_queued(dbus_proxy, i - 1)) {
+        audtool_report("OK");
+        exit(0);
+    }
+    else
+        exit(1);
+}
+
+void playqueue_get_queue_position(gint argc, gchar **argv)
+{
+	gint pos, i = check_args_playlist_pos(argc, argv);
+
+	pos = audacious_remote_get_playqueue_queue_position(dbus_proxy, i - 1) + 1;
+
+	if (pos < 1)
+		return;
+
+	audtool_report("%d", pos);
+}
+
+void playqueue_get_list_position(gint argc, gchar **argv)
+{
+	gint pos, i = check_args_playlist_pos(argc, argv);
+
+	pos = audacious_remote_get_playqueue_list_position(dbus_proxy, i - 1) + 1;
+
+	if (pos < 1)
+		return;
+
+	audtool_report("%d", pos);
+}
+
+void playqueue_display(gint argc, gchar **argv)
+{
+	gint i, ii, position, frames, length, total;
+	gchar *songname;
+	gchar *fmt = NULL, *p;
+	gint column;
+	
+	i = audacious_remote_get_playqueue_length(dbus_proxy);
+
+	audtool_report("%d queued tracks.", i);
+
+	total = 0;
+
+	for (ii = 0; ii < i; ii++)
+	{
+		position = audacious_remote_get_playqueue_list_position(dbus_proxy, ii);
+		songname = audacious_remote_get_playlist_title(dbus_proxy, position);
+		frames = audacious_remote_get_playlist_time(dbus_proxy, position);
+		length = frames / 1000;
+		total += length;
+
+		/* adjust width for multi byte characters */
+		column = 60;
+		if(songname) {
+			p = songname;
+			while(*p){
+				gint stride;
+				stride = g_utf8_next_char(p) - p;
+				if(g_unichar_iswide(g_utf8_get_char(p))
+				   || g_unichar_iswide_cjk(g_utf8_get_char(p))
+				){
+					column += (stride - 2);
+				}
+				else {
+					column += (stride - 1);
+				}
+				p = g_utf8_next_char(p);
+			}
+		}
+
+		fmt = g_strdup_printf("%%4d | %%4d | %%-%ds | %%d:%%.2d", column);
+		audtool_report(fmt, ii + 1, position + 1, songname, length / 60, length % 60);
+		g_free(fmt);
+	}
+
+	audtool_report("Total length: %d:%.2d", total / 60, total % 60);
+}
+
+void playqueue_length(gint argc, gchar **argv)
+{
+	gint i;
+
+	i = audacious_remote_get_playqueue_length(dbus_proxy);
+
+	audtool_report("%d", i);
+}
+
+void playqueue_clear(gint argc, gchar **argv)
+{
+	audacious_remote_playqueue_clear(dbus_proxy);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/audtool/handlers_vitals.c	Thu Jun 05 01:27:43 2008 +0300
@@ -0,0 +1,193 @@
+/*
+ * Audtool2
+ * Copyright (c) 2007 Audacious development team
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ *    this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <stdlib.h>
+#include <string.h>
+#include <glib.h>
+#include <mowgli.h>
+#include <locale.h>
+#include "libaudclient/audctrl.h"
+#include "audtool.h"
+
+void get_current_song(gint argc, gchar **argv)
+{
+	gint playpos = audacious_remote_get_playlist_pos(dbus_proxy);
+	gchar *song = audacious_remote_get_playlist_title(dbus_proxy, playpos);
+
+	if (!song)
+	{
+		audtool_report("No song playing.");
+		return;
+	}
+
+	audtool_report("%s", song);
+}
+
+void get_current_song_filename(gint argc, gchar **argv)
+{
+	gint playpos = audacious_remote_get_playlist_pos(dbus_proxy);
+	gchar *file = audacious_remote_get_playlist_file(dbus_proxy, playpos);
+
+	if (!file)
+	{
+		audtool_report("No song playing.");
+		return;
+	}
+        
+	audtool_report("%s", file);
+}
+
+void get_current_song_output_length(gint argc, gchar **argv)
+{
+	gint frames = audacious_remote_get_output_time(dbus_proxy);
+	gint length = frames / 1000;
+
+	audtool_report("%d:%.2d", length / 60, length % 60);
+}
+
+void get_current_song_output_length_seconds(gint argc, gchar **argv)
+{
+	gint frames = audacious_remote_get_output_time(dbus_proxy);
+	gint length = frames / 1000;
+
+	audtool_report("%d", length);
+}
+
+void get_current_song_output_length_frames(gint argc, gchar **argv)
+{
+	gint frames = audacious_remote_get_output_time(dbus_proxy);
+
+	audtool_report("%d", frames);
+}
+
+void get_current_song_length(gint argc, gchar **argv)
+{
+	gint playpos = audacious_remote_get_playlist_pos(dbus_proxy);
+	gint frames = audacious_remote_get_playlist_time(dbus_proxy, playpos);
+	gint length = frames / 1000;
+
+	audtool_report("%d:%.2d", length / 60, length % 60);
+}
+
+void get_current_song_length_seconds(gint argc, gchar **argv)
+{
+	gint playpos = audacious_remote_get_playlist_pos(dbus_proxy);
+	gint frames = audacious_remote_get_playlist_time(dbus_proxy, playpos);
+	gint length = frames / 1000;
+
+	audtool_report("%d", length);
+}
+
+void get_current_song_length_frames(gint argc, gchar **argv)
+{
+	gint playpos = audacious_remote_get_playlist_pos(dbus_proxy);
+	gint frames = audacious_remote_get_playlist_time(dbus_proxy, playpos);
+
+	audtool_report("%d", frames);
+}
+
+void get_current_song_bitrate(gint argc, gchar **argv)
+{
+	gint rate, freq, nch;
+
+	audacious_remote_get_info(dbus_proxy, &rate, &freq, &nch);
+
+	audtool_report("%d", rate);
+}
+
+void get_current_song_bitrate_kbps(gint argc, gchar **argv)
+{
+	gint rate, freq, nch;
+
+	audacious_remote_get_info(dbus_proxy, &rate, &freq, &nch);
+
+	audtool_report("%d", rate / 1000);
+}
+
+void get_current_song_frequency(gint argc, gchar **argv)
+{
+	gint rate, freq, nch;
+
+	audacious_remote_get_info(dbus_proxy, &rate, &freq, &nch);
+
+	audtool_report("%d", freq);
+}
+
+void get_current_song_frequency_khz(gint argc, gchar **argv)
+{
+	gint rate, freq, nch;
+
+	audacious_remote_get_info(dbus_proxy, &rate, &freq, &nch);
+
+	audtool_report("%0.1f", (gfloat) freq / 1000);
+}
+
+void get_current_song_channels(gint argc, gchar **argv)
+{
+	gint rate, freq, nch;
+
+	audacious_remote_get_info(dbus_proxy, &rate, &freq, &nch);
+
+	audtool_report("%d", nch);
+}
+
+void get_current_song_tuple_field_data(gint argc, gchar **argv)
+{
+	gchar *data;
+
+	if (argc < 2)
+	{
+		audtool_whine_args(argv[0], "<fieldname>");
+		audtool_whine("  - fieldname example choices include but are not limited to:\n");
+		audtool_whine("      artist, album, title, track-number, year, date,\n");
+		audtool_whine("      genre, comment, file-name, file-ext, file-path,\n");
+		audtool_whine("      length, formatter, custom, mtime\n");
+		exit(1);
+	}
+
+	if (!(data = audacious_get_tuple_field_data(dbus_proxy, argv[1], audacious_remote_get_playlist_pos(dbus_proxy))))
+	{
+		return;
+	}
+	
+	audtool_report("%s", data);
+
+	g_free(data);
+}
+
+void get_current_song_info(gint argc, gchar **argv)
+{
+    gint rate, freq, nch;
+
+    audacious_remote_get_info(dbus_proxy, &rate, &freq, &nch);
+    audtool_report("rate = %d freq = %d nch = %d", rate, freq, nch);
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/audtool/main.c	Thu Jun 05 01:27:43 2008 +0300
@@ -0,0 +1,209 @@
+/*
+ * Audtool2
+ * Copyright (c) 2007 Audacious development team
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ *    this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <stdlib.h>
+#include <string.h>
+#include <glib.h>
+#include <mowgli.h>
+#include <locale.h>
+#include "libaudclient/audctrl.h"
+#include "audtool.h"
+
+struct commandhandler handlers[] = {
+	{"<sep>", NULL, "Vital information", 0},
+	{"current-song", get_current_song, "returns current song title", 0},
+	{"current-song-filename", get_current_song_filename, "returns current song filename", 0},
+	{"current-song-length", get_current_song_length, "returns current song length", 0},
+	{"current-song-length-seconds", get_current_song_length_seconds, "returns current song length in seconds", 0},
+	{"current-song-length-frames", get_current_song_length_frames, "returns current song length in frames", 0},
+	{"current-song-output-length", get_current_song_output_length, "returns current song output length", 0},
+	{"current-song-output-length-seconds", get_current_song_output_length_seconds, "returns current song output length in seconds", 0},
+	{"current-song-output-length-frames", get_current_song_output_length_frames, "returns current song output length in frames", 0},
+	{"current-song-bitrate", get_current_song_bitrate, "returns current song bitrate in bits per second", 0},
+	{"current-song-bitrate-kbps", get_current_song_bitrate_kbps, "returns current song bitrate in kilobits per second", 0},
+	{"current-song-frequency", get_current_song_frequency, "returns current song frequency in hertz", 0},
+	{"current-song-frequency-khz", get_current_song_frequency_khz, "returns current song frequency in kilohertz", 0},
+	{"current-song-channels", get_current_song_channels, "returns current song channels", 0},
+	{"current-song-tuple-data", get_current_song_tuple_field_data, "returns the value of a tuple field for the current song", 1},
+    {"current-song-info", get_current_song_info, "returns current song bitrate, frequency and channels", 0},
+
+
+	{"<sep>", NULL, "Playlist manipulation", 0},
+	{"playlist-advance", playlist_advance, "go to the next song in the playlist", 0},
+	{"playlist-reverse", playlist_reverse, "go to the previous song in the playlist", 0},
+	{"playlist-addurl", playlist_add_url_string, "adds a url to the playlist", 1},
+    {"playlist-insurl", playlist_ins_url_string, "inserts a url at specified position in the playlist", 2},
+	{"playlist-addurl-to-new-playlist", playlist_enqueue_to_temp, "adds a url to the newly created playlist", 1},
+	{"playlist-delete", playlist_delete, "deletes a song from the playlist", 1},
+	{"playlist-length", playlist_length, "returns the total length of the playlist", 0},
+	{"playlist-song", playlist_song, "returns the title of a song in the playlist", 1},
+	{"playlist-song-filename", playlist_song_filename, "returns the filename of a song in the playlist", 1},
+	{"playlist-song-length", playlist_song_length, "returns the length of a song in the playlist", 1},
+	{"playlist-song-length-seconds", playlist_song_length_seconds, "returns the length of a song in the playlist in seconds", 1},
+	{"playlist-song-length-frames", playlist_song_length_frames, "returns the length of a song in the playlist in frames", 1},
+	{"playlist-display", playlist_display, "returns the entire playlist", 0},
+	{"playlist-position", playlist_position, "returns the position in the playlist", 0},
+	{"playlist-jump", playlist_jump, "jumps to a position in the playlist", 1},
+	{"playlist-clear", playlist_clear, "clears the playlist", 0},
+	{"playlist-repeat-status", playlist_repeat_status, "returns the status of playlist repeat", 0},
+	{"playlist-repeat-toggle", playlist_repeat_toggle, "toggles playlist repeat", 0},
+	{"playlist-shuffle-status", playlist_shuffle_status, "returns the status of playlist shuffle", 0},
+	{"playlist-shuffle-toggle", playlist_shuffle_toggle, "toggles playlist shuffle", 0},
+	{"playlist-tuple-data", playlist_tuple_field_data, "returns the value of a tuple field for a song in the playlist", 2},
+
+
+	{"<sep>", NULL, "Playqueue manipulation", 0},
+	{"playqueue-add", playqueue_add, "adds a song to the playqueue", 1},
+	{"playqueue-remove", playqueue_remove, "removes a song from the playqueue", 1},
+	{"playqueue-is-queued", playqueue_is_queued, "returns OK if a song is queued", 1},
+	{"playqueue-get-queue-position", playqueue_get_queue_position, "returns the playqueue position of a song in the given poition in the playlist", 1},
+	{"playqueue-get-list-position", playqueue_get_list_position, "returns the playlist position of a song in the given position in the playqueue", 1},
+	{"playqueue-length", playqueue_length, "returns the length of the playqueue", 0},
+	{"playqueue-display", playqueue_display, "returns a list of currently-queued songs", 0},
+	{"playqueue-clear", playqueue_clear, "clears the playqueue", 0},
+
+
+	{"<sep>", NULL, "Playback manipulation", 0},
+	{"playback-play", playback_play, "starts/unpauses song playback", 0},
+	{"playback-pause", playback_pause, "(un)pauses song playback", 0},
+	{"playback-playpause", playback_playpause, "plays/(un)pauses song playback", 0},
+	{"playback-stop", playback_stop, "stops song playback", 0},
+	{"playback-playing", playback_playing, "returns OK if audacious is playing", 0},
+	{"playback-paused", playback_paused, "returns OK if audacious is paused", 0},
+	{"playback-stopped", playback_stopped, "returns OK if audacious is stopped", 0},
+	{"playback-status", playback_status, "returns the playback status", 0},
+	{"playback-seek", playback_seek, "performs an absolute seek", 1},
+	{"playback-seek-relative", playback_seek_relative, "performs a seek relative to the current position", 1},
+
+
+	{"<sep>", NULL, "Volume control", 0},
+	{"get-volume", get_volume, "returns the current volume level in percent", 0},
+	{"set-volume", set_volume, "sets the current volume level in percent", 1},
+
+
+	{"<sep>", NULL, "Equalizer manipulation", 0},
+    {"equalizer-activate", equalizer_active, "activates/deactivates the equalizer", 1},
+    {"equalizer-get", equalizer_get_eq, "gets the equalizer settings", 0},
+    {"equalizer-set", equalizer_set_eq, "sets the equalizer settings", 11},
+    {"equalizer-get-preamp", equalizer_get_eq_preamp, "gets the equalizer pre-amplification", 0},
+    {"equalizer-set-preamp", equalizer_set_eq_preamp, "sets the equalizer pre-amplification", 1},
+    {"equalizer-get-band", equalizer_get_eq_band, "gets the equalizer value in specified band", 1},
+    {"equalizer-set-band", equalizer_set_eq_band, "sets the equalizer value in the specified band", 2},
+
+
+	{"<sep>", NULL, "Miscellaneous", 0},
+	{"mainwin-show", mainwin_show, "shows/hides the main window", 1},
+	{"playlist-show", playlist_show, "shows/hides the playlist window", 1},
+	{"equalizer-show", equalizer_show, "shows/hides the equalizer window", 1},
+
+	{"filebrowser-show", show_filebrowser, "shows/hides the filebrowser", 1},
+	{"jumptofile-show", show_jtf_window, "shows/hides the jump to file window", 1},
+	{"preferences-show", show_preferences_window, "shows/hides the preferences window", 1},
+	{"about-show", show_about_window, "shows/hides the about window", 1},
+
+	{"activate", activate, "activates and raises audacious", 0},
+	{"always-on-top", toggle_aot, "on/off always on top", 1},
+    {"get-skin", get_skin, "gets skin", 0},
+    {"set-skin", set_skin, "sets skin", 1},
+    {"version", get_version, "shows audaciuos version", 0},
+	{"shutdown", shutdown_audacious_server, "shuts down audacious", 0},
+
+
+	{"<sep>", NULL, "Help system", 0},
+	{"list-handlers", get_handlers_list, "shows handlers list", 0},
+	{"help", get_handlers_list, "shows handlers list", 0},
+
+    
+	{NULL, NULL, NULL, 0}
+};
+
+mowgli_error_context_t *e = NULL;
+DBusGProxy *dbus_proxy = NULL;
+static DBusGConnection *connection = NULL;
+
+static void audtool_connect(void)
+{
+	GError *error = NULL;
+
+	mowgli_error_context_push(e, "While attempting to connect to the D-Bus session bus");
+	connection = dbus_g_bus_get(DBUS_BUS_SESSION, &error);
+
+	if (connection == NULL)
+		mowgli_error_context_display_with_error(e, ":\n  * ", g_strdup_printf("D-Bus Error: %s", error->message));
+
+	mowgli_error_context_pop(e);
+
+	dbus_proxy = dbus_g_proxy_new_for_name(connection, AUDACIOUS_DBUS_SERVICE,
+                                           AUDACIOUS_DBUS_PATH,
+                                           AUDACIOUS_DBUS_INTERFACE);
+}
+
+gint main(gint argc, gchar **argv)
+{
+	gint i, j = 0, k = 0;
+
+	setlocale(LC_CTYPE, "");
+	g_type_init();
+	mowgli_init();
+
+	e = mowgli_error_context_create();
+	mowgli_error_context_push(e, "In program %s", argv[0]);
+
+	audtool_connect();
+
+	mowgli_error_context_push(e, "While processing the commandline");
+
+	if (argc < 2)
+		mowgli_error_context_display_with_error(e, ":\n  * ", "not enough parameters, use \'audtool help\' for more information.");
+
+	for (j = 1; j < argc; j++)
+	{
+		for (i = 0; handlers[i].name != NULL; i++)
+		{
+			if ((!g_ascii_strcasecmp(handlers[i].name, argv[j]) ||
+			     !g_ascii_strcasecmp(g_strconcat("--", handlers[i].name, NULL), argv[j]))
+			    && g_ascii_strcasecmp("<sep>", handlers[i].name))
+  			{
+				int numargs = handlers[i].args + 1 < argc - 1 ? handlers[i].args + 1 : argc - 1;
+				handlers[i].handler(numargs, &argv[j]);
+				j += handlers[i].args;
+				k++;
+				if(j >= argc)
+					break;
+			}
+		}
+	}
+
+	if (k == 0)
+		mowgli_error_context_display_with_error(e, ":\n  * ", g_strdup_printf("Unknown command '%s' encountered, use \'audtool help\' for a command list.", argv[1]));
+
+	return 0;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/audtool/report.c	Thu Jun 05 01:27:43 2008 +0300
@@ -0,0 +1,78 @@
+/*
+ * Audtool2
+ * Copyright (c) 2007 Audacious development team
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ *    this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <stdlib.h>
+#include <string.h>
+#include <glib.h>
+#include <mowgli.h>
+#include <locale.h>
+#include "libaudclient/audctrl.h"
+#include "audtool.h"
+
+void audtool_report(const gchar *str, ...)
+{
+	gchar *buf;
+	va_list va;
+
+	va_start(va, str);
+	buf = g_strdup_vprintf(str, va);
+	va_end(va);
+
+	g_print("%s\n", buf);
+	g_free(buf);
+}
+
+void audtool_whine(const gchar *str, ...)
+{
+	gchar *buf;
+	va_list va;
+
+	va_start(va, str);
+	buf = g_strdup_vprintf(str, va);
+	va_end(va);
+
+	g_printerr("audtool: %s", buf);
+	g_free(buf);
+}
+
+void audtool_whine_args(const gchar *name, const gchar *fmt, ...)
+{
+	gchar *buf;
+	va_list va;
+
+	va_start(va, fmt);
+	buf = g_strdup_vprintf(fmt, va);
+	va_end(va);
+
+	g_printerr("audtool: Invalid parameters for %s\n", name);
+	g_printerr(" syntax: %s %s\n", name, buf);
+	g_free(buf);
+}