summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShaun McCance <shaunm@gnome.org>2009-11-16 21:44:48 -0600
committerShaun McCance <shaunm@gnome.org>2009-11-16 21:44:48 -0600
commit6c21a73a4c884d4869a367e75eb570850aa475f1 (patch)
tree36ff22eae974cf94db8e0f6ab1f684bb02f8cedf
parente7c759c58158781daedf65933600ca9259a14bfa (diff)
downloadyelp-6c21a73a4c884d4869a367e75eb570850aa475f1.tar.gz
[libyelp] Adding yelp-io-channel to libyelp
This is only an internal implementation detail. I want to switch over to GIO. I'll need to create a GInputStream that automatically decodes to replace YelpIOChannel.
-rw-r--r--libyelp/Makefile.am1
-rw-r--r--libyelp/yelp-io-channel.c (renamed from src/yelp-io-channel.c)10
-rw-r--r--libyelp/yelp-io-channel.h (renamed from src/yelp-io-channel.h)0
-rw-r--r--tests/Makefile.am7
-rw-r--r--tests/test-io-channel.c50
-rw-r--r--tests/test-uri.c4
6 files changed, 65 insertions, 7 deletions
diff --git a/libyelp/Makefile.am b/libyelp/Makefile.am
index ed79d0cf..f6369189 100644
--- a/libyelp/Makefile.am
+++ b/libyelp/Makefile.am
@@ -5,6 +5,7 @@ libyelp_la_SOURCES = \
yelp-error.c \
yelp-docbook-document.c \
yelp-document.c \
+ yelp-io-channel.c \
yelp-location-entry.c \
yelp-mallard-document.c \
yelp-settings.c \
diff --git a/src/yelp-io-channel.c b/libyelp/yelp-io-channel.c
index b41a205f..47934d11 100644
--- a/src/yelp-io-channel.c
+++ b/libyelp/yelp-io-channel.c
@@ -121,11 +121,11 @@ yelp_io_channel_new_file (gchar *file,
if (!channel) {
if (error) {
- g_set_error (error, YELP_GERROR, YELP_GERROR_IO,
- _("The file ā€˜%sā€™ could not be read and decoded. "
- "The file may be compressed in an unsupported "
- "format."),
- file);
+ g_set_error (error, YELP_ERROR, YELP_ERROR_PROCESSING,
+ _("The file ā€˜%sā€™ could not be read and decoded. "
+ "The file may be compressed in an unsupported "
+ "format."),
+ file);
}
return NULL;
}
diff --git a/src/yelp-io-channel.h b/libyelp/yelp-io-channel.h
index ad2e0bfe..ad2e0bfe 100644
--- a/src/yelp-io-channel.h
+++ b/libyelp/yelp-io-channel.h
diff --git a/tests/Makefile.am b/tests/Makefile.am
index d305e349..02f1d98a 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -6,15 +6,22 @@ YELP_COMMON_CFLAGS = \
-I$(top_srcdir)/libyelp
YELP_COMMON_LDADD = \
$(YELP_LIBS) \
+ $(Z_LIBS) \
+ $(BZ_LIBS) \
+ $(LZMADEC_LIBS) \
$(top_builddir)/libyelp/libyelp.la
check_PROGRAMS = \
+ test-io-channel \
test-location-entry \
test-settings \
test-transform \
test-uri \
test-view
+test_io_channel_CFLAGS = $(YELP_COMMON_CFLAGS)
+test_io_channel_LDADD = $(YELP_COMMON_LDADD)
+
test_location_entry_CFLAGS = $(YELP_COMMON_CFLAGS)
test_location_entry_LDADD = $(YELP_COMMON_LDADD)
diff --git a/tests/test-io-channel.c b/tests/test-io-channel.c
new file mode 100644
index 00000000..f2e1dbce
--- /dev/null
+++ b/tests/test-io-channel.c
@@ -0,0 +1,50 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Copyright (C) 2009 Shaun McCance <shaunm@gnome.org
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Author: Shaun McCance <shaunm@gnome.org
+ */
+
+#include <config.h>
+#include <stdio.h>
+#include <string.h>
+
+#include <glib.h>
+
+#include "yelp-io-channel.h"
+
+int
+main (int argc, char **argv)
+{
+ GIOChannel *channel;
+ gchar *str;
+ gint len;
+
+ g_log_set_always_fatal (G_LOG_LEVEL_ERROR | G_LOG_LEVEL_CRITICAL);
+
+ if (argc < 2) {
+ g_printerr ("Usage: test-io-channel FILE\n");
+ return 1;
+ }
+
+ channel = yelp_io_channel_new_file (argv[1], NULL);
+ g_io_channel_read_to_end (channel, &str, &len, NULL);
+ printf ("%s\n", str);
+
+ return 0;
+}
diff --git a/tests/test-uri.c b/tests/test-uri.c
index bf295f06..869d9b1c 100644
--- a/tests/test-uri.c
+++ b/tests/test-uri.c
@@ -1,6 +1,6 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
- * Copyright (C) 2002 Mikael Hallendal <micke@imendio.com>
+ * Copyright (C) 2009 Shaun McCance <shaunm@gnome.org
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -17,7 +17,7 @@
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
- * Author: Mikael Hallendal <micke@imendio.com>
+ * Author: Shaun McCance <shaunm@gnome.org>
*/
#include <config.h>