Version 3.4.2
[yelp.git] / tests / test-lzma.c
blob76af37d8f968d6746e0e0a1acee3674c55c2cd54
1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * Copyright (C) 2009 Shaun McCance <shaunm@gnome.org
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation; either version 2 of the
8 * License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
15 * You should have received a copy of the GNU General Public
16 * License along with this program; if not, write to the
17 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 * Boston, MA 02111-1307, USA.
20 * Author: Shaun McCance <shaunm@gnome.org
23 #include <config.h>
24 #include <stdio.h>
25 #include <string.h>
27 #include <gio/gio.h>
29 #include "yelp-lzma-decompressor.h"
31 int
32 main (int argc, char **argv)
34 GConverter *converter;
35 GFile *file;
36 GFileInputStream *file_stream;
37 GInputStream *stream;
38 gchar buf[1024];
39 gssize bytes;
41 if (argc < 2) {
42 g_printerr ("Usage: test-lzma FILE\n");
43 return 1;
46 g_type_init ();
48 file = g_file_new_for_path (argv[1]);
49 file_stream = g_file_read (file, NULL, NULL);
50 converter = yelp_lzma_decompressor_new ();
51 stream = g_converter_input_stream_new (file_stream, converter);
53 while ((bytes = g_input_stream_read (stream, buf, 1024, NULL, NULL)) > 0) {
54 gchar *out = g_strndup (buf, bytes);
55 puts (out);
56 g_free (out);
59 return 0;