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