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 | |
Tom Rini | abb9a04 | 2024-05-18 20:20:43 -0600 | [diff] [blame] | 7 | #include <common.h> |
Harald Welte | 5708dbf | 2008-07-09 22:30:30 +0800 | [diff] [blame] | 8 | #include <command.h> |
Simon Glass | 1a974af | 2019-08-01 09:46:36 -0600 | [diff] [blame] | 9 | #include <gzip.h> |
Harald Welte | 5708dbf | 2008-07-09 22:30:30 +0800 | [diff] [blame] | 10 | #include <malloc.h> |
Harald Welte | 5708dbf | 2008-07-09 22:30:30 +0800 | [diff] [blame] | 11 | |
Masahiro Yamada | 8168033 | 2017-01-30 11:12:08 +0900 | [diff] [blame] | 12 | #include "license_data_gz.h" |
| 13 | #include "license_data_size.h" |
| 14 | |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 15 | static int do_license(struct cmd_tbl *cmdtp, int flag, int argc, |
| 16 | char *const argv[]) |
Harald Welte | 5708dbf | 2008-07-09 22:30:30 +0800 | [diff] [blame] | 17 | { |
Masahiro Yamada | 8168033 | 2017-01-30 11:12:08 +0900 | [diff] [blame] | 18 | char *dst; |
| 19 | unsigned long len = data_size; |
| 20 | int ret = CMD_RET_SUCCESS; |
Harald Welte | 5708dbf | 2008-07-09 22:30:30 +0800 | [diff] [blame] | 21 | |
Masahiro Yamada | 8168033 | 2017-01-30 11:12:08 +0900 | [diff] [blame] | 22 | dst = malloc(data_size + 1); |
Harald Welte | 5708dbf | 2008-07-09 22:30:30 +0800 | [diff] [blame] | 23 | if (!dst) |
Masahiro Yamada | 8168033 | 2017-01-30 11:12:08 +0900 | [diff] [blame] | 24 | return CMD_RET_FAILURE; |
Harald Welte | 5708dbf | 2008-07-09 22:30:30 +0800 | [diff] [blame] | 25 | |
Masahiro Yamada | 8168033 | 2017-01-30 11:12:08 +0900 | [diff] [blame] | 26 | ret = gunzip(dst, data_size, (unsigned char *)data_gz, &len); |
| 27 | if (ret) { |
Harald Welte | 5708dbf | 2008-07-09 22:30:30 +0800 | [diff] [blame] | 28 | printf("Error uncompressing license text\n"); |
Masahiro Yamada | 8168033 | 2017-01-30 11:12:08 +0900 | [diff] [blame] | 29 | ret = CMD_RET_FAILURE; |
| 30 | goto free; |
Harald Welte | 5708dbf | 2008-07-09 22:30:30 +0800 | [diff] [blame] | 31 | } |
Masahiro Yamada | 8168033 | 2017-01-30 11:12:08 +0900 | [diff] [blame] | 32 | |
| 33 | dst[data_size] = 0; |
Harald Welte | 5708dbf | 2008-07-09 22:30:30 +0800 | [diff] [blame] | 34 | puts(dst); |
Masahiro Yamada | 8168033 | 2017-01-30 11:12:08 +0900 | [diff] [blame] | 35 | |
| 36 | free: |
Harald Welte | 5708dbf | 2008-07-09 22:30:30 +0800 | [diff] [blame] | 37 | free(dst); |
| 38 | |
Masahiro Yamada | 8168033 | 2017-01-30 11:12:08 +0900 | [diff] [blame] | 39 | return ret; |
Harald Welte | 5708dbf | 2008-07-09 22:30:30 +0800 | [diff] [blame] | 40 | } |
| 41 | |
Frans Meulenbroeks | 7675a09 | 2010-07-31 15:01:53 +0200 | [diff] [blame] | 42 | U_BOOT_CMD( |
| 43 | license, 1, 1, do_license, |
Wolfgang Denk | c54781c | 2009-05-24 17:06:54 +0200 | [diff] [blame] | 44 | "print GPL license text", |
| 45 | "" |
| 46 | ); |