errcodes.c 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /* This Source Code Form is subject to the terms of the Mozilla Public
  3. * License, v. 2.0. If a copy of the MPL was not distributed with this
  4. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  5. /***********************************************************************
  6. **
  7. ** Name: errcodes.c
  8. **
  9. ** Description: print nspr error codes
  10. **
  11. */
  12. #include "prerror.h"
  13. #include "plgetopt.h"
  14. #include <stdio.h>
  15. static int _debug_on = 0;
  16. struct errinfo {
  17. PRErrorCode errcode;
  18. char *errname;
  19. };
  20. struct errinfo errcodes[] = {
  21. {PR_OUT_OF_MEMORY_ERROR, "PR_OUT_OF_MEMORY_ERROR"},
  22. {PR_BAD_DESCRIPTOR_ERROR, "PR_BAD_DESCRIPTOR_ERROR"},
  23. {PR_WOULD_BLOCK_ERROR, "PR_WOULD_BLOCK_ERROR"},
  24. {PR_ACCESS_FAULT_ERROR, "PR_ACCESS_FAULT_ERROR"},
  25. {PR_INVALID_METHOD_ERROR, "PR_INVALID_METHOD_ERROR"},
  26. {PR_ILLEGAL_ACCESS_ERROR, "PR_ILLEGAL_ACCESS_ERROR"},
  27. {PR_UNKNOWN_ERROR, "PR_UNKNOWN_ERROR"},
  28. {PR_PENDING_INTERRUPT_ERROR, "PR_PENDING_INTERRUPT_ERROR"},
  29. {PR_NOT_IMPLEMENTED_ERROR, "PR_NOT_IMPLEMENTED_ERROR"},
  30. {PR_IO_ERROR, "PR_IO_ERROR"},
  31. {PR_IO_TIMEOUT_ERROR, "PR_IO_TIMEOUT_ERROR"},
  32. {PR_IO_PENDING_ERROR, "PR_IO_PENDING_ERROR"},
  33. {PR_DIRECTORY_OPEN_ERROR, "PR_DIRECTORY_OPEN_ERROR"},
  34. {PR_INVALID_ARGUMENT_ERROR, "PR_INVALID_ARGUMENT_ERROR"},
  35. {PR_ADDRESS_NOT_AVAILABLE_ERROR, "PR_ADDRESS_NOT_AVAILABLE_ERROR"},
  36. {PR_ADDRESS_NOT_SUPPORTED_ERROR, "PR_ADDRESS_NOT_SUPPORTED_ERROR"},
  37. {PR_IS_CONNECTED_ERROR, "PR_IS_CONNECTED_ERROR"},
  38. {PR_BAD_ADDRESS_ERROR, "PR_BAD_ADDRESS_ERROR"},
  39. {PR_ADDRESS_IN_USE_ERROR, "PR_ADDRESS_IN_USE_ERROR"},
  40. {PR_CONNECT_REFUSED_ERROR, "PR_CONNECT_REFUSED_ERROR"},
  41. {PR_NETWORK_UNREACHABLE_ERROR, "PR_NETWORK_UNREACHABLE_ERROR"},
  42. {PR_CONNECT_TIMEOUT_ERROR, "PR_CONNECT_TIMEOUT_ERROR"},
  43. {PR_NOT_CONNECTED_ERROR, "PR_NOT_CONNECTED_ERROR"},
  44. {PR_LOAD_LIBRARY_ERROR, "PR_LOAD_LIBRARY_ERROR"},
  45. {PR_UNLOAD_LIBRARY_ERROR, "PR_UNLOAD_LIBRARY_ERROR"},
  46. {PR_FIND_SYMBOL_ERROR, "PR_FIND_SYMBOL_ERROR"},
  47. {PR_INSUFFICIENT_RESOURCES_ERROR, "PR_INSUFFICIENT_RESOURCES_ERROR"},
  48. {PR_DIRECTORY_LOOKUP_ERROR, "PR_DIRECTORY_LOOKUP_ERROR"},
  49. {PR_TPD_RANGE_ERROR, "PR_TPD_RANGE_ERROR"},
  50. {PR_PROC_DESC_TABLE_FULL_ERROR, "PR_PROC_DESC_TABLE_FULL_ERROR"},
  51. {PR_SYS_DESC_TABLE_FULL_ERROR, "PR_SYS_DESC_TABLE_FULL_ERROR"},
  52. {PR_NOT_SOCKET_ERROR, "PR_NOT_SOCKET_ERROR"},
  53. {PR_NOT_TCP_SOCKET_ERROR, "PR_NOT_TCP_SOCKET_ERROR"},
  54. {PR_SOCKET_ADDRESS_IS_BOUND_ERROR, "PR_SOCKET_ADDRESS_IS_BOUND_ERROR"},
  55. {PR_NO_ACCESS_RIGHTS_ERROR, "PR_NO_ACCESS_RIGHTS_ERROR"},
  56. {PR_OPERATION_NOT_SUPPORTED_ERROR, "PR_OPERATION_NOT_SUPPORTED_ERROR"},
  57. {PR_PROTOCOL_NOT_SUPPORTED_ERROR, "PR_PROTOCOL_NOT_SUPPORTED_ERROR"},
  58. {PR_REMOTE_FILE_ERROR, "PR_REMOTE_FILE_ERROR"},
  59. {PR_BUFFER_OVERFLOW_ERROR, "PR_BUFFER_OVERFLOW_ERROR"},
  60. {PR_CONNECT_RESET_ERROR, "PR_CONNECT_RESET_ERROR"},
  61. {PR_RANGE_ERROR, "PR_RANGE_ERROR"},
  62. {PR_DEADLOCK_ERROR, "PR_DEADLOCK_ERROR"},
  63. {PR_FILE_IS_LOCKED_ERROR, "PR_FILE_IS_LOCKED_ERROR"},
  64. {PR_FILE_TOO_BIG_ERROR, "PR_FILE_TOO_BIG_ERROR"},
  65. {PR_NO_DEVICE_SPACE_ERROR, "PR_NO_DEVICE_SPACE_ERROR"},
  66. {PR_PIPE_ERROR, "PR_PIPE_ERROR"},
  67. {PR_NO_SEEK_DEVICE_ERROR, "PR_NO_SEEK_DEVICE_ERROR"},
  68. {PR_IS_DIRECTORY_ERROR, "PR_IS_DIRECTORY_ERROR"},
  69. {PR_LOOP_ERROR, "PR_LOOP_ERROR"},
  70. {PR_NAME_TOO_LONG_ERROR, "PR_NAME_TOO_LONG_ERROR"},
  71. {PR_FILE_NOT_FOUND_ERROR, "PR_FILE_NOT_FOUND_ERROR"},
  72. {PR_NOT_DIRECTORY_ERROR, "PR_NOT_DIRECTORY_ERROR"},
  73. {PR_READ_ONLY_FILESYSTEM_ERROR, "PR_READ_ONLY_FILESYSTEM_ERROR"},
  74. {PR_DIRECTORY_NOT_EMPTY_ERROR, "PR_DIRECTORY_NOT_EMPTY_ERROR"},
  75. {PR_FILESYSTEM_MOUNTED_ERROR, "PR_FILESYSTEM_MOUNTED_ERROR"},
  76. {PR_NOT_SAME_DEVICE_ERROR, "PR_NOT_SAME_DEVICE_ERROR"},
  77. {PR_DIRECTORY_CORRUPTED_ERROR, "PR_DIRECTORY_CORRUPTED_ERROR"},
  78. {PR_FILE_EXISTS_ERROR, "PR_FILE_EXISTS_ERROR"},
  79. {PR_MAX_DIRECTORY_ENTRIES_ERROR, "PR_MAX_DIRECTORY_ENTRIES_ERROR"},
  80. {PR_INVALID_DEVICE_STATE_ERROR, "PR_INVALID_DEVICE_STATE_ERROR"},
  81. {PR_DEVICE_IS_LOCKED_ERROR, "PR_DEVICE_IS_LOCKED_ERROR"},
  82. {PR_NO_MORE_FILES_ERROR, "PR_NO_MORE_FILES_ERROR"},
  83. {PR_END_OF_FILE_ERROR, "PR_END_OF_FILE_ERROR"},
  84. {PR_FILE_SEEK_ERROR, "PR_FILE_SEEK_ERROR"},
  85. {PR_FILE_IS_BUSY_ERROR, "PR_FILE_IS_BUSY_ERROR"},
  86. {PR_IN_PROGRESS_ERROR, "PR_IN_PROGRESS_ERROR"},
  87. {PR_ALREADY_INITIATED_ERROR, "PR_ALREADY_INITIATED_ERROR"},
  88. {PR_GROUP_EMPTY_ERROR, "PR_GROUP_EMPTY_ERROR"},
  89. {PR_INVALID_STATE_ERROR, "PR_INVALID_STATE_ERROR"},
  90. {PR_NETWORK_DOWN_ERROR, "PR_NETWORK_DOWN_ERROR"},
  91. {PR_SOCKET_SHUTDOWN_ERROR, "PR_SOCKET_SHUTDOWN_ERROR"},
  92. {PR_CONNECT_ABORTED_ERROR, "PR_CONNECT_ABORTED_ERROR"},
  93. {PR_HOST_UNREACHABLE_ERROR, "PR_HOST_UNREACHABLE_ERROR"}
  94. };
  95. int main(int argc, char **argv)
  96. {
  97. int count, errnum;
  98. /*
  99. * -d debug mode
  100. */
  101. PLOptStatus os;
  102. PLOptState *opt = PL_CreateOptState(argc, argv, "d");
  103. while (PL_OPT_EOL != (os = PL_GetNextOpt(opt)))
  104. {
  105. if (PL_OPT_BAD == os) {
  106. continue;
  107. }
  108. switch (opt->option)
  109. {
  110. case 'd': /* debug mode */
  111. _debug_on = 1;
  112. break;
  113. default:
  114. break;
  115. }
  116. }
  117. PL_DestroyOptState(opt);
  118. count = sizeof(errcodes)/sizeof(errcodes[0]);
  119. printf("\nNumber of error codes = %d\n\n",count);
  120. for (errnum = 0; errnum < count; errnum++) {
  121. printf("%-40s = %d\n",errcodes[errnum].errname,
  122. errcodes[errnum].errcode);
  123. }
  124. return 0;
  125. }