1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * (C) Copyright 2007 by OpenMoko, Inc.
4  * Author: Harald Welte <laforge@openmoko.org>
5  */
6 
7 #include <common.h>
8 #include <command.h>
9 #include <gzip.h>
10 #include <malloc.h>
11 
12 #include "license_data_gz.h"
13 #include "license_data_size.h"
14 
do_license(struct cmd_tbl * cmdtp,int flag,int argc,char * const argv[])15 static int do_license(struct cmd_tbl *cmdtp, int flag, int argc,
16 		      char *const argv[])
17 {
18 	char *dst;
19 	unsigned long len = data_size;
20 	int ret = CMD_RET_SUCCESS;
21 
22 	dst = malloc(data_size + 1);
23 	if (!dst)
24 		return CMD_RET_FAILURE;
25 
26 	ret = gunzip(dst, data_size, (unsigned char *)data_gz, &len);
27 	if (ret) {
28 		printf("Error uncompressing license text\n");
29 		ret = CMD_RET_FAILURE;
30 		goto free;
31 	}
32 
33 	dst[data_size] = 0;
34 	puts(dst);
35 
36 free:
37 	free(dst);
38 
39 	return ret;
40 }
41 
42 U_BOOT_CMD(
43 	license, 1, 1, do_license,
44 	"print GPL license text",
45 	""
46 );
47