1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * Copyright (C) 2009  Shaun McCance  <shaunm@gnome.org
4  *
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.
9  *
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.
14  *
15  * You should have received a copy of the GNU General Public
16  * License along with this program; if not, see <http://www.gnu.org/licenses/>.
17  *
18  * Author: Shaun McCance <shaunm@gnome.org
19  */
20 
21 #include <config.h>
22 #include <stdio.h>
23 #include <string.h>
24 
25 #include <gio/gio.h>
26 
27 #include "yelp-lzma-decompressor.h"
28 
29 int
main(int argc,char ** argv)30 main (int argc, char **argv)
31 {
32     GConverter *converter;
33     GFile *file;
34     GFileInputStream *file_stream;
35     GInputStream *stream;
36     gchar buf[1024];
37     gssize bytes;
38 
39     if (argc < 2) {
40         g_printerr ("Usage: test-lzma FILE\n");
41         return 1;
42     }
43 
44     file = g_file_new_for_path (argv[1]);
45     file_stream = g_file_read (file, NULL, NULL);
46     converter = G_CONVERTER (yelp_lzma_decompressor_new ());
47     stream = g_converter_input_stream_new (G_INPUT_STREAM (file_stream),
48                                            converter);
49 
50     while ((bytes = g_input_stream_read (stream, buf, 1024, NULL, NULL)) > 0) {
51         gchar *out = g_strndup (buf, bytes);
52         puts (out);
53         g_free (out);
54     }
55 
56     return 0;
57 }
58