1
0

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

1234567891011121314151617181920212223242526272829303132
  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:]]", errcode_a)) {
  14. if ((errcode_a[1] == "MIN_CODE_E") ||
  15. (errcode_a[1] == "WC_LAST_E") ||
  16. (errcode_a[1] == "MAX_CODE_E"))
  17. {
  18. next;
  19. }
  20. 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";
  21. printf("#undef %s\n#undef CONST_NUM_ERR_%s\n", errcode_a[1], errcode_a[1]) >> "wolfssl/debug-untrace-error-codes.h";
  22. }
  23. }
  24. END {
  25. print("") >> "wolfssl/debug-trace-error-codes.h";
  26. print("#endif /* WOLFSSL_DEBUG_TRACE_ERROR_CODES_H */") >> "wolfssl/debug-trace-error-codes.h";
  27. print("") >> "wolfssl/debug-untrace-error-codes.h";
  28. print("#endif /* WOLFSSL_DEBUG_TRACE_ERROR_CODES_H */") >> "wolfssl/debug-untrace-error-codes.h";
  29. }' wolfssl/wolfcrypt/error-crypt.h wolfssl/error-ssl.h