blob: 1c0794f09527facd183fa0054388f4970a175bea [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
7#include <common.h>
Harald Welte5708dbf2008-07-09 22:30:30 +08008#include <command.h>
9#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
14static int do_license(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
Harald Welte5708dbf2008-07-09 22:30:30 +080015{
Masahiro Yamada81680332017-01-30 11:12:08 +090016 char *dst;
17 unsigned long len = data_size;
18 int ret = CMD_RET_SUCCESS;
Harald Welte5708dbf2008-07-09 22:30:30 +080019
Masahiro Yamada81680332017-01-30 11:12:08 +090020 dst = malloc(data_size + 1);
Harald Welte5708dbf2008-07-09 22:30:30 +080021 if (!dst)
Masahiro Yamada81680332017-01-30 11:12:08 +090022 return CMD_RET_FAILURE;
Harald Welte5708dbf2008-07-09 22:30:30 +080023
Masahiro Yamada81680332017-01-30 11:12:08 +090024 ret = gunzip(dst, data_size, (unsigned char *)data_gz, &len);
25 if (ret) {
Harald Welte5708dbf2008-07-09 22:30:30 +080026 printf("Error uncompressing license text\n");
Masahiro Yamada81680332017-01-30 11:12:08 +090027 ret = CMD_RET_FAILURE;
28 goto free;
Harald Welte5708dbf2008-07-09 22:30:30 +080029 }
Masahiro Yamada81680332017-01-30 11:12:08 +090030
31 dst[data_size] = 0;
Harald Welte5708dbf2008-07-09 22:30:30 +080032 puts(dst);
Masahiro Yamada81680332017-01-30 11:12:08 +090033
34free:
Harald Welte5708dbf2008-07-09 22:30:30 +080035 free(dst);
36
Masahiro Yamada81680332017-01-30 11:12:08 +090037 return ret;
Harald Welte5708dbf2008-07-09 22:30:30 +080038}
39
Frans Meulenbroeks7675a092010-07-31 15:01:53 +020040U_BOOT_CMD(
41 license, 1, 1, do_license,
Wolfgang Denkc54781c2009-05-24 17:06:54 +020042 "print GPL license text",
43 ""
44);