Blame view

cmd/license.c 805 Bytes
83d290c56   Tom Rini   SPDX: Convert all...
1
  // SPDX-License-Identifier: GPL-2.0+
0a823aa2a   Harald Welte   Add 'license' com...
2
3
4
  /*
   * (C) Copyright 2007 by OpenMoko, Inc.
   * Author: Harald Welte <laforge@openmoko.org>
0a823aa2a   Harald Welte   Add 'license' com...
5
6
7
   */
  
  #include <common.h>
0a823aa2a   Harald Welte   Add 'license' com...
8
  #include <command.h>
0c670fc14   Simon Glass   common: Move gzip...
9
  #include <gzip.h>
0a823aa2a   Harald Welte   Add 'license' com...
10
  #include <malloc.h>
0a823aa2a   Harald Welte   Add 'license' com...
11

d726f225f   Masahiro Yamada   cmd: rework "lice...
12
13
14
15
  #include "license_data_gz.h"
  #include "license_data_size.h"
  
  static int do_license(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
0a823aa2a   Harald Welte   Add 'license' com...
16
  {
d726f225f   Masahiro Yamada   cmd: rework "lice...
17
18
19
  	char *dst;
  	unsigned long len = data_size;
  	int ret = CMD_RET_SUCCESS;
0a823aa2a   Harald Welte   Add 'license' com...
20

d726f225f   Masahiro Yamada   cmd: rework "lice...
21
  	dst = malloc(data_size + 1);
0a823aa2a   Harald Welte   Add 'license' com...
22
  	if (!dst)
d726f225f   Masahiro Yamada   cmd: rework "lice...
23
  		return CMD_RET_FAILURE;
0a823aa2a   Harald Welte   Add 'license' com...
24

d726f225f   Masahiro Yamada   cmd: rework "lice...
25
26
  	ret = gunzip(dst, data_size, (unsigned char *)data_gz, &len);
  	if (ret) {
0a823aa2a   Harald Welte   Add 'license' com...
27
28
  		printf("Error uncompressing license text
  ");
d726f225f   Masahiro Yamada   cmd: rework "lice...
29
30
  		ret = CMD_RET_FAILURE;
  		goto free;
0a823aa2a   Harald Welte   Add 'license' com...
31
  	}
d726f225f   Masahiro Yamada   cmd: rework "lice...
32
33
  
  	dst[data_size] = 0;
0a823aa2a   Harald Welte   Add 'license' com...
34
  	puts(dst);
d726f225f   Masahiro Yamada   cmd: rework "lice...
35
36
  
  free:
0a823aa2a   Harald Welte   Add 'license' com...
37
  	free(dst);
d726f225f   Masahiro Yamada   cmd: rework "lice...
38
  	return ret;
0a823aa2a   Harald Welte   Add 'license' com...
39
  }
388a29d02   Frans Meulenbroeks   various cmd_* fil...
40
41
  U_BOOT_CMD(
  	license, 1, 1, do_license,
a89c33db9   Wolfgang Denk   General help mess...
42
43
44
  	"print GPL license text",
  	""
  );