Re: grokking libgsf
- From: Morten Welinder <mortenw gnome org>
- To: Allin Cottrell <cottrell wfu edu>
- Cc: Gnumeric Dev List <gnumeric-list gnome org>, Jon K Hellan <hellan acm org>
- Subject: Re: grokking libgsf
- Date: Mon, 4 May 2009 12:06:37 -0400
You want something like this...
diff --git a/tests/test-cp-zip.c b/tests/test-cp-zip.c
index 5523f33..2169f78 100644
--- a/tests/test-cp-zip.c
+++ b/tests/test-cp-zip.c
@@ -26,16 +26,16 @@
#include <gsf/gsf-infile-zip.h>
#include <gsf/gsf-output-stdio.h>
+#include <gsf/gsf-outfile-stdio.h>
#include <gsf/gsf-outfile.h>
#include <gsf/gsf-outfile-zip.h>
#include <stdio.h>
static void
-clone (GsfInfile *in, GsfOutfile *out)
+clone (GsfInfile *in, GsfOutput *output)
{
GsfInput *input = GSF_INPUT (in);
- GsfOutput *output = GSF_OUTPUT (out);
if (gsf_input_size (input) > 0) {
size_t len;
@@ -54,6 +54,7 @@ clone (GsfInfile *in, GsfOutfile *out)
}
}
} else {
+ GsfOutfile *out = GSF_OUTFILE (output);
int i, n = gsf_infile_num_children (in);
for (i = 0 ; i < n; i++) {
int level;
@@ -83,14 +84,14 @@ clone (GsfInfile *in, GsfOutfile *out)
g_free (display_name);
output = gsf_outfile_new_child_full (out, name, is_dir,
- "compression-level", level,
NULL);
- clone (GSF_INFILE (input), GSF_OUTFILE (output));
+ clone (GSF_INFILE (input), output);
+
+ g_object_unref (input);
+ gsf_output_close (output);
+ g_object_unref (output);
}
}
- gsf_output_close (GSF_OUTPUT (out));
- g_object_unref (G_OBJECT (out));
- g_object_unref (G_OBJECT (in));
}
static int
@@ -98,7 +99,6 @@ test (char *argv[])
{
GsfInput *input;
GsfInfile *infile;
- GsfOutput *output;
GsfOutfile *outfile;
GError *err = NULL;
@@ -124,20 +124,11 @@ test (char *argv[])
return 1;
}
- output = gsf_output_stdio_new (argv[2], &err);
- if (output == NULL) {
-
- g_return_val_if_fail (err != NULL, 1);
-
- g_warning ("'%s' error: %s", argv[2], err->message);
- g_error_free (err);
- g_object_unref (G_OBJECT (infile));
- return 1;
- }
+ outfile = gsf_outfile_stdio_new (argv[2], &err);
+ clone (infile, GSF_OUTPUT (outfile));
- outfile = gsf_outfile_zip_new (output, &err);
- g_object_unref (G_OBJECT (output));
- clone (infile, outfile);
+ g_object_unref (outfile);
+ g_object_unref (infile);
return 0;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]