blob: 161663ff29c64173d3bb62f52c7aecdabdef80ab [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Harald Welte5708dbf2008-07-09 22:30:30 +08002/*
3 * (C) Copyright 2007 by OpenMoko, Inc.
4 * Author: Harald Welte <laforge@openmoko.org>
Harald Welte5708dbf2008-07-09 22:30:30 +08005 */
6
Harald Welte5708dbf2008-07-09 22:30:30 +08007#include <command.h>
Simon Glass1a974af2019-08-01 09:46:36 -06008#include <gzip.h>
Harald Welte5708dbf2008-07-09 22:30:30 +08009#include <malloc.h>
Harald Welte5708dbf2008-07-09 22:30:30 +080010
Masahiro Yamada81680332017-01-30 11:12:08 +090011#include "license_data_gz.h"
12#include "license_data_size.h"
13
Simon Glassed38aef2020-05-10 11:40:03 -060014static int do_license(struct cmd_tbl *cmdtp, int flag, int argc,
15 char *const argv[])
Harald Welte5708dbf2008-07-09 22:30:30 +080016{
Masahiro Yamada81680332017-01-30 11:12:08 +090017 char *dst;
18 unsigned long len = data_size;
19 int ret = CMD_RET_SUCCESS;
Harald Welte5708dbf2008-07-09 22:30:30 +080020
Masahiro Yamada81680332017-01-30 11:12:08 +090021 dst = malloc(data_size + 1);
Harald Welte5708dbf2008-07-09 22:30:30 +080022 if (!dst)
Masahiro Yamada81680332017-01-30 11:12:08 +090023 return CMD_RET_FAILURE;
Harald Welte5708dbf2008-07-09 22:30:30 +080024
Masahiro Yamada81680332017-01-30 11:12:08 +090025 ret = gunzip(dst, data_size, (unsigned char *)data_gz, &len);
26 if (ret) {
Harald Welte5708dbf2008-07-09 22:30:30 +080027 printf("Error uncompressing license text\n");
Masahiro Yamada81680332017-01-30 11:12:08 +090028 ret = CMD_RET_FAILURE;
29 goto free;
Harald Welte5708dbf2008-07-09 22:30:30 +080030 }
Masahiro Yamada81680332017-01-30 11:12:08 +090031
32 dst[data_size] = 0;
Harald Welte5708dbf2008-07-09 22:30:30 +080033 puts(dst);
Masahiro Yamada81680332017-01-30 11:12:08 +090034
35free:
Harald Welte5708dbf2008-07-09 22:30:30 +080036 free(dst);
37
Masahiro Yamada81680332017-01-30 11:12:08 +090038 return ret;
Harald Welte5708dbf2008-07-09 22:30:30 +080039}
40
Frans Meulenbroeks7675a092010-07-31 15:01:53 +020041U_BOOT_CMD(
42 license, 1, 1, do_license,
Wolfgang Denkc54781c2009-05-24 17:06:54 +020043 "print GPL license text",
44 ""
45);