aboutsummaryrefslogtreecommitdiffstats
path: root/test/run_input.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-11-14 23:53:04 +0100
committerMax Kellermann <max@duempel.org>2009-12-15 23:12:11 +0100
commit228b03edf8513aa1cdaf4e4647279cc580245555 (patch)
tree7f5b03a9727fb8c371885469296eb7f49f6fa68b /test/run_input.c
parentd000d31355c824a076324b647a3f056aab9ddabe (diff)
downloadmpd-228b03edf8513aa1cdaf4e4647279cc580245555.tar.gz
mpd-228b03edf8513aa1cdaf4e4647279cc580245555.tar.xz
mpd-228b03edf8513aa1cdaf4e4647279cc580245555.zip
input_stream: return errors with GError
Diffstat (limited to '')
-rw-r--r--test/run_input.c27
1 files changed, 21 insertions, 6 deletions
diff --git a/test/run_input.c b/test/run_input.c
index bd66a1b1a..a7423a2e7 100644
--- a/test/run_input.c
+++ b/test/run_input.c
@@ -45,6 +45,7 @@ my_log_func(const gchar *log_domain, G_GNUC_UNUSED GLogLevelFlags log_level,
static int
dump_input_stream(struct input_stream *is)
{
+ GError *error = NULL;
char buffer[4096];
size_t num_read;
ssize_t num_written;
@@ -52,10 +53,13 @@ dump_input_stream(struct input_stream *is)
/* wait until the stream becomes ready */
while (!is->ready) {
- int ret = input_stream_buffer(is);
- if (ret < 0)
+ int ret = input_stream_buffer(is, &error);
+ if (ret < 0) {
/* error */
+ g_warning("%s", error->message);
+ g_error_free(error);
return 2;
+ }
if (ret == 0)
/* nothing was buffered - wait */
@@ -77,9 +81,16 @@ dump_input_stream(struct input_stream *is)
tag_free(tag);
}
- num_read = input_stream_read(is, buffer, sizeof(buffer));
- if (num_read == 0)
+ num_read = input_stream_read(is, buffer, sizeof(buffer),
+ &error);
+ if (num_read == 0) {
+ if (error != NULL) {
+ g_warning("%s", error->message);
+ g_error_free(error);
+ }
+
break;
+ }
num_written = write(1, buffer, num_read);
if (num_written <= 0)
@@ -122,11 +133,15 @@ int main(int argc, char **argv)
/* open the stream and dump it */
- if (input_stream_open(&is, argv[1])) {
+ if (input_stream_open(&is, argv[1], &error)) {
ret = dump_input_stream(&is);
input_stream_close(&is);
} else {
- g_printerr("input_stream_open() failed\n");
+ if (error != NULL) {
+ g_warning("%s", error->message);
+ g_error_free(error);
+ } else
+ g_printerr("input_stream_open() failed\n");
ret = 2;
}