blob: 15411b5a92d56ed09fd3e878c1d8032b8305c114 [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>
Simon Glass0c670fc2019-08-01 09:46:36 -06009#include <gzip.h>
Harald Welte0a823aa2008-07-09 22:30:30 +080010#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
Simon Glass09140112020-05-10 11:40:03 -060015static int do_license(struct cmd_tbl *cmdtp, int flag, int argc,
16 char *const argv[])
Harald Welte0a823aa2008-07-09 22:30:30 +080017{
Masahiro Yamadad726f222017-01-30 11:12:08 +090018 char *dst;
19 unsigned long len = data_size;
20 int ret = CMD_RET_SUCCESS;
Harald Welte0a823aa2008-07-09 22:30:30 +080021
Masahiro Yamadad726f222017-01-30 11:12:08 +090022 dst = malloc(data_size + 1);
Harald Welte0a823aa2008-07-09 22:30:30 +080023 if (!dst)
Masahiro Yamadad726f222017-01-30 11:12:08 +090024 return CMD_RET_FAILURE;
Harald Welte0a823aa2008-07-09 22:30:30 +080025
Masahiro Yamadad726f222017-01-30 11:12:08 +090026 ret = gunzip(dst, data_size, (unsigned char *)data_gz, &len);
27 if (ret) {
Harald Welte0a823aa2008-07-09 22:30:30 +080028 printf("Error uncompressing license text\n");
Masahiro Yamadad726f222017-01-30 11:12:08 +090029 ret = CMD_RET_FAILURE;
30 goto free;
Harald Welte0a823aa2008-07-09 22:30:30 +080031 }
Masahiro Yamadad726f222017-01-30 11:12:08 +090032
33 dst[data_size] = 0;
Harald Welte0a823aa2008-07-09 22:30:30 +080034 puts(dst);
Masahiro Yamadad726f222017-01-30 11:12:08 +090035
36free:
Harald Welte0a823aa2008-07-09 22:30:30 +080037 free(dst);
38
Masahiro Yamadad726f222017-01-30 11:12:08 +090039 return ret;
Harald Welte0a823aa2008-07-09 22:30:30 +080040}
41
Frans Meulenbroeks388a29d2010-07-31 15:01:53 +020042U_BOOT_CMD(
43 license, 1, 1, do_license,
Wolfgang Denka89c33d2009-05-24 17:06:54 +020044 "print GPL license text",
45 ""
46);