Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Harald Welte | 5708dbf | 2008-07-09 22:30:30 +0800 | [diff] [blame] | 2 | /* |
| 3 | * (C) Copyright 2007 by OpenMoko, Inc. |
| 4 | * Author: Harald Welte <laforge@openmoko.org> |
Harald Welte | 5708dbf | 2008-07-09 22:30:30 +0800 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | #include <common.h> |
Harald Welte | 5708dbf | 2008-07-09 22:30:30 +0800 | [diff] [blame] | 8 | #include <command.h> |
| 9 | #include <malloc.h> |
Harald Welte | 5708dbf | 2008-07-09 22:30:30 +0800 | [diff] [blame] | 10 | |
Masahiro Yamada | 8168033 | 2017-01-30 11:12:08 +0900 | [diff] [blame] | 11 | #include "license_data_gz.h" |
| 12 | #include "license_data_size.h" |
| 13 | |
| 14 | static int do_license(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
Harald Welte | 5708dbf | 2008-07-09 22:30:30 +0800 | [diff] [blame] | 15 | { |
Masahiro Yamada | 8168033 | 2017-01-30 11:12:08 +0900 | [diff] [blame] | 16 | char *dst; |
| 17 | unsigned long len = data_size; |
| 18 | int ret = CMD_RET_SUCCESS; |
Harald Welte | 5708dbf | 2008-07-09 22:30:30 +0800 | [diff] [blame] | 19 | |
Masahiro Yamada | 8168033 | 2017-01-30 11:12:08 +0900 | [diff] [blame] | 20 | dst = malloc(data_size + 1); |
Harald Welte | 5708dbf | 2008-07-09 22:30:30 +0800 | [diff] [blame] | 21 | if (!dst) |
Masahiro Yamada | 8168033 | 2017-01-30 11:12:08 +0900 | [diff] [blame] | 22 | return CMD_RET_FAILURE; |
Harald Welte | 5708dbf | 2008-07-09 22:30:30 +0800 | [diff] [blame] | 23 | |
Masahiro Yamada | 8168033 | 2017-01-30 11:12:08 +0900 | [diff] [blame] | 24 | ret = gunzip(dst, data_size, (unsigned char *)data_gz, &len); |
| 25 | if (ret) { |
Harald Welte | 5708dbf | 2008-07-09 22:30:30 +0800 | [diff] [blame] | 26 | printf("Error uncompressing license text\n"); |
Masahiro Yamada | 8168033 | 2017-01-30 11:12:08 +0900 | [diff] [blame] | 27 | ret = CMD_RET_FAILURE; |
| 28 | goto free; |
Harald Welte | 5708dbf | 2008-07-09 22:30:30 +0800 | [diff] [blame] | 29 | } |
Masahiro Yamada | 8168033 | 2017-01-30 11:12:08 +0900 | [diff] [blame] | 30 | |
| 31 | dst[data_size] = 0; |
Harald Welte | 5708dbf | 2008-07-09 22:30:30 +0800 | [diff] [blame] | 32 | puts(dst); |
Masahiro Yamada | 8168033 | 2017-01-30 11:12:08 +0900 | [diff] [blame] | 33 | |
| 34 | free: |
Harald Welte | 5708dbf | 2008-07-09 22:30:30 +0800 | [diff] [blame] | 35 | free(dst); |
| 36 | |
Masahiro Yamada | 8168033 | 2017-01-30 11:12:08 +0900 | [diff] [blame] | 37 | return ret; |
Harald Welte | 5708dbf | 2008-07-09 22:30:30 +0800 | [diff] [blame] | 38 | } |
| 39 | |
Frans Meulenbroeks | 7675a09 | 2010-07-31 15:01:53 +0200 | [diff] [blame] | 40 | U_BOOT_CMD( |
| 41 | license, 1, 1, do_license, |
Wolfgang Denk | c54781c | 2009-05-24 17:06:54 +0200 | [diff] [blame] | 42 | "print GPL license text", |
| 43 | "" |
| 44 | ); |