blob: 29fc8aa9a41fba47c0851680ec6a2c0fc2470f21 [file] [log] [blame]
Harald Welte0a823aa2008-07-09 22:30:30 +08001/*
2 * (C) Copyright 2007 by OpenMoko, Inc.
3 * Author: Harald Welte <laforge@openmoko.org>
4 *
Wolfgang Denk1a459662013-07-08 09:37:19 +02005 * SPDX-License-Identifier: GPL-2.0+
Harald Welte0a823aa2008-07-09 22:30:30 +08006 */
7
8#include <common.h>
Harald Welte0a823aa2008-07-09 22:30:30 +08009#include <command.h>
10#include <malloc.h>
Harald Welte0a823aa2008-07-09 22:30:30 +080011
Masahiro Yamadad726f222017-01-30 11:12:08 +090012#include "license_data_gz.h"
13#include "license_data_size.h"
14
15static int do_license(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
Harald Welte0a823aa2008-07-09 22:30:30 +080016{
Masahiro Yamadad726f222017-01-30 11:12:08 +090017 char *dst;
18 unsigned long len = data_size;
19 int ret = CMD_RET_SUCCESS;
Harald Welte0a823aa2008-07-09 22:30:30 +080020
Masahiro Yamadad726f222017-01-30 11:12:08 +090021 dst = malloc(data_size + 1);
Harald Welte0a823aa2008-07-09 22:30:30 +080022 if (!dst)
Masahiro Yamadad726f222017-01-30 11:12:08 +090023 return CMD_RET_FAILURE;
Harald Welte0a823aa2008-07-09 22:30:30 +080024
Masahiro Yamadad726f222017-01-30 11:12:08 +090025 ret = gunzip(dst, data_size, (unsigned char *)data_gz, &len);
26 if (ret) {
Harald Welte0a823aa2008-07-09 22:30:30 +080027 printf("Error uncompressing license text\n");
Masahiro Yamadad726f222017-01-30 11:12:08 +090028 ret = CMD_RET_FAILURE;
29 goto free;
Harald Welte0a823aa2008-07-09 22:30:30 +080030 }
Masahiro Yamadad726f222017-01-30 11:12:08 +090031
32 dst[data_size] = 0;
Harald Welte0a823aa2008-07-09 22:30:30 +080033 puts(dst);
Masahiro Yamadad726f222017-01-30 11:12:08 +090034
35free:
Harald Welte0a823aa2008-07-09 22:30:30 +080036 free(dst);
37
Masahiro Yamadad726f222017-01-30 11:12:08 +090038 return ret;
Harald Welte0a823aa2008-07-09 22:30:30 +080039}
40
Frans Meulenbroeks388a29d2010-07-31 15:01:53 +020041U_BOOT_CMD(
42 license, 1, 1, do_license,
Wolfgang Denka89c33d2009-05-24 17:06:54 +020043 "print GPL license text",
44 ""
45);