arm start.c: Make runtime function address calculation tolerant for more compilers
[barebox-mini2440.git] / commands / unlzo.c
blob0b6dd4b9618c27433d75dcf6c9c2cd5563271bbc
1 /*
2 * unlzo.c - uncompress a lzo compressed file
4 * Copyright (c) 2010 Sascha Hauer <s.hauer@pengutronix.de>, Pengutronix
6 * See file CREDITS for list of people who contributed to this
7 * project.
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2
11 * as published by the Free Software Foundation.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 #include <common.h>
24 #include <command.h>
25 #include <errno.h>
26 #include <fcntl.h>
27 #include <fs.h>
28 #include <lzo.h>
30 static int do_unlzo(struct command *cmdtp, int argc, char *argv[])
32 int from, to, ret, retlen;
34 if (argc != 3)
35 return COMMAND_ERROR_USAGE;
37 from = open(argv[1], O_RDONLY);
38 if (from < 0) {
39 perror("open");
40 return 1;
43 to = open(argv[2], O_WRONLY | O_CREAT);
44 if (to < 0) {
45 perror("open");
46 ret = 1;
47 goto exit_close;
50 ret = unlzo(from, to, &retlen);
51 if (ret)
52 printf("failed to decompress\n");
54 close(to);
55 exit_close:
56 close(from);
57 return ret;
60 static const __maybe_unused char cmd_unlzo_help[] =
61 "Usage: unlzo <infile> <outfile>\n"
62 "Uncompress a lzo compressed file\n";
64 BAREBOX_CMD_START(unlzo)
65 .cmd = do_unlzo,
66 .usage = "lzop <infile> <outfile>",
67 BAREBOX_CMD_HELP(cmd_unlzo_help)
68 BAREBOX_CMD_END