1
0

gen-debug-trace-error-codes.sh 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #!/bin/sh
  2. awk '
  3. BEGIN {
  4. print("/* automatically generated, do not edit */") > "wolfssl/debug-trace-error-codes.h";
  5. print("#ifndef WOLFSSL_DEBUG_TRACE_ERROR_CODES_H") >> "wolfssl/debug-trace-error-codes.h";
  6. print("#define WOLFSSL_DEBUG_TRACE_ERROR_CODES_H") >> "wolfssl/debug-trace-error-codes.h";
  7. print("") >> "wolfssl/debug-trace-error-codes.h";
  8. print("/* automatically generated, do not edit */") > "wolfssl/debug-untrace-error-codes.h";
  9. print("#ifdef WOLFSSL_DEBUG_TRACE_ERROR_CODES_H") >> "wolfssl/debug-untrace-error-codes.h";
  10. print("#undef WOLFSSL_DEBUG_TRACE_ERROR_CODES_H") >> "wolfssl/debug-untrace-error-codes.h";
  11. }
  12. {
  13. if (match($0, "^[[:space:]]+([A-Z][A-Z0-9_]+)[[:space:]]*=[[:space:]]*(-[0-9]+)([,[:space:]]|$)")) {
  14. # for mawkward compatibility -- gawk allows errcode_a as the 3rd arg to match().
  15. gsub("^[[:space:]]+", "", $0);
  16. split($0, errcode_a, "[[:space:]=,]+");
  17. if ((errcode_a[1] == "MIN_CODE_E") ||
  18. (errcode_a[1] == "MAX_CODE_E") ||
  19. (errcode_a[1] ~ "WC.*MIN_CODE_E") ||
  20. (errcode_a[1] ~ "WC.*MAX_CODE_E") ||
  21. (errcode_a[1] ~ "WC.*_FIRST_E") ||
  22. (errcode_a[1] ~ "WC.*_LAST_E") ||
  23. (errcode_a[1] ~ "WOLFSSL.*_FIRST_E") ||
  24. (errcode_a[1] ~ "WOLFSSL.*_LAST_E"))
  25. {
  26. next;
  27. }
  28. printf("#define %s WC_ERR_TRACE(%s)\n#define CONST_NUM_ERR_%s (%s)\n", errcode_a[1], errcode_a[1], errcode_a[1], errcode_a[2]) >> "wolfssl/debug-trace-error-codes.h";
  29. printf("#undef %s\n#undef CONST_NUM_ERR_%s\n", errcode_a[1], errcode_a[1]) >> "wolfssl/debug-untrace-error-codes.h";
  30. }
  31. }
  32. END {
  33. print("") >> "wolfssl/debug-trace-error-codes.h";
  34. print("#endif /* WOLFSSL_DEBUG_TRACE_ERROR_CODES_H */") >> "wolfssl/debug-trace-error-codes.h";
  35. print("") >> "wolfssl/debug-untrace-error-codes.h";
  36. print("#endif /* WOLFSSL_DEBUG_TRACE_ERROR_CODES_H */") >> "wolfssl/debug-untrace-error-codes.h";
  37. }' wolfssl/wolfcrypt/error-crypt.h wolfssl/error-ssl.h