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

12345678910111213141516171819202122232425262728293031323334353637383940
  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_FIRST_E") ||
  20. (errcode_a[1] == "WC_LAST_E") ||
  21. (errcode_a[1] == "WOLFSSL_FIRST_E") ||
  22. (errcode_a[1] == "WOLFSSL_LAST_E"))
  23. {
  24. next;
  25. }
  26. 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";
  27. printf("#undef %s\n#undef CONST_NUM_ERR_%s\n", errcode_a[1], errcode_a[1]) >> "wolfssl/debug-untrace-error-codes.h";
  28. }
  29. }
  30. END {
  31. print("") >> "wolfssl/debug-trace-error-codes.h";
  32. print("#endif /* WOLFSSL_DEBUG_TRACE_ERROR_CODES_H */") >> "wolfssl/debug-trace-error-codes.h";
  33. print("") >> "wolfssl/debug-untrace-error-codes.h";
  34. print("#endif /* WOLFSSL_DEBUG_TRACE_ERROR_CODES_H */") >> "wolfssl/debug-untrace-error-codes.h";
  35. }' wolfssl/wolfcrypt/error-crypt.h wolfssl/error-ssl.h