xref: /openbmc/u-boot/cmd/license.c (revision b9553986)
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 <malloc.h>
10 
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[])
15 {
16 	char *dst;
17 	unsigned long len = data_size;
18 	int ret = CMD_RET_SUCCESS;
19 
20 	dst = malloc(data_size + 1);
21 	if (!dst)
22 		return CMD_RET_FAILURE;
23 
24 	ret = gunzip(dst, data_size, (unsigned char *)data_gz, &len);
25 	if (ret) {
26 		printf("Error uncompressing license text\n");
27 		ret = CMD_RET_FAILURE;
28 		goto free;
29 	}
30 
31 	dst[data_size] = 0;
32 	puts(dst);
33 
34 free:
35 	free(dst);
36 
37 	return ret;
38 }
39 
40 U_BOOT_CMD(
41 	license, 1, 1, do_license,
42 	"print GPL license text",
43 	""
44 );
45