blob: 1c0794f09527facd183fa0054388f4970a175bea [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Harald Welte0a823aa2008-07-09 22:30:30 +08002/*
3 * (C) Copyright 2007 by OpenMoko, Inc.
4 * Author: Harald Welte <laforge@openmoko.org>
Harald Welte0a823aa2008-07-09 22:30:30 +08005 */
6
7#include <common.h>
Harald Welte0a823aa2008-07-09 22:30:30 +08008#include <command.h>
9#include <malloc.h>
Harald Welte0a823aa2008-07-09 22:30:30 +080010
Masahiro Yamadad726f222017-01-30 11:12:08 +090011#include "license_data_gz.h"
12#include "license_data_size.h"
13
14static int do_license(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
Harald Welte0a823aa2008-07-09 22:30:30 +080015{
Masahiro Yamadad726f222017-01-30 11:12:08 +090016 char *dst;
17 unsigned long len = data_size;
18 int ret = CMD_RET_SUCCESS;
Harald Welte0a823aa2008-07-09 22:30:30 +080019
Masahiro Yamadad726f222017-01-30 11:12:08 +090020 dst = malloc(data_size + 1);
Harald Welte0a823aa2008-07-09 22:30:30 +080021 if (!dst)
Masahiro Yamadad726f222017-01-30 11:12:08 +090022 return CMD_RET_FAILURE;
Harald Welte0a823aa2008-07-09 22:30:30 +080023
Masahiro Yamadad726f222017-01-30 11:12:08 +090024 ret = gunzip(dst, data_size, (unsigned char *)data_gz, &len);
25 if (ret) {
Harald Welte0a823aa2008-07-09 22:30:30 +080026 printf("Error uncompressing license text\n");
Masahiro Yamadad726f222017-01-30 11:12:08 +090027 ret = CMD_RET_FAILURE;
28 goto free;
Harald Welte0a823aa2008-07-09 22:30:30 +080029 }
Masahiro Yamadad726f222017-01-30 11:12:08 +090030
31 dst[data_size] = 0;
Harald Welte0a823aa2008-07-09 22:30:30 +080032 puts(dst);
Masahiro Yamadad726f222017-01-30 11:12:08 +090033
34free:
Harald Welte0a823aa2008-07-09 22:30:30 +080035 free(dst);
36
Masahiro Yamadad726f222017-01-30 11:12:08 +090037 return ret;
Harald Welte0a823aa2008-07-09 22:30:30 +080038}
39
Frans Meulenbroeks388a29d2010-07-31 15:01:53 +020040U_BOOT_CMD(
41 license, 1, 1, do_license,
Wolfgang Denka89c33d2009-05-24 17:06:54 +020042 "print GPL license text",
43 ""
44);