license.c 805 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
  13. {
  14. char *dst;
  15. unsigned long len = data_size;
  16. int ret = CMD_RET_SUCCESS;
  17. dst = malloc(data_size + 1);
  18. if (!dst)
  19. return CMD_RET_FAILURE;
  20. ret = gunzip(dst, data_size, (unsigned char *)data_gz, &len);
  21. if (ret) {
  22. printf("Error uncompressing license text\n");
  23. ret = CMD_RET_FAILURE;
  24. goto free;
  25. }
  26. dst[data_size] = 0;
  27. puts(dst);
  28. free:
  29. free(dst);
  30. return ret;
  31. }
  32. U_BOOT_CMD(
  33. license, 1, 1, do_license,
  34. "print GPL license text",
  35. ""
  36. );