license.c 817 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * (C) Copyright 2007 by OpenMoko, Inc.
  4. * Author: Harald Welte <laforge@openmoko.org>
  5. */
  6. #include <common.h>
  7. #include <command.h>
  8. #include <gzip.h>
  9. #include <malloc.h>
  10. #include "license_data_gz.h"
  11. #include "license_data_size.h"
  12. static int do_license(struct cmd_tbl *cmdtp, int flag, int argc,
  13. char *const argv[])
  14. {
  15. char *dst;
  16. unsigned long len = data_size;
  17. int ret = CMD_RET_SUCCESS;
  18. dst = malloc(data_size + 1);
  19. if (!dst)
  20. return CMD_RET_FAILURE;
  21. ret = gunzip(dst, data_size, (unsigned char *)data_gz, &len);
  22. if (ret) {
  23. printf("Error uncompressing license text\n");
  24. ret = CMD_RET_FAILURE;
  25. goto free;
  26. }
  27. dst[data_size] = 0;
  28. puts(dst);
  29. free:
  30. free(dst);
  31. return ret;
  32. }
  33. U_BOOT_CMD(
  34. license, 1, 1, do_license,
  35. "print GPL license text",
  36. ""
  37. );