PageRenderTime 54ms CodeModel.GetById 27ms RepoModel.GetById 0ms app.codeStats 0ms

/lib_polarssl/scripts/data_files/error.fmt

https://bitbucket.org/xixs/lua
Oracle Forms | 109 lines | 84 code | 25 blank | 0 comment | 0 complexity | 80efb3a6af4b4a01b5d1cb997579b222 MD5 | raw file
Possible License(s): Zlib, BSD-3-Clause, CC0-1.0, GPL-3.0, GPL-2.0, CPL-1.0, MPL-2.0-no-copyleft-exception, LGPL-2.0, LGPL-2.1, LGPL-3.0, 0BSD, Cube
  1. /*
  2. * Error message information
  3. *
  4. * Copyright (C) 2006-2012, Brainspark B.V.
  5. *
  6. * This file is part of PolarSSL (http://www.polarssl.org)
  7. * Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
  8. *
  9. * All rights reserved.
  10. *
  11. * This program is free software; you can redistribute it and/or modify
  12. * it under the terms of the GNU General Public License as published by
  13. * the Free Software Foundation; either version 2 of the License, or
  14. * (at your option) any later version.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU General Public License along
  22. * with this program; if not, write to the Free Software Foundation, Inc.,
  23. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  24. */
  25. #include "polarssl/config.h"
  26. #if defined(POLARSSL_ERROR_C)
  27. #include "polarssl/error.h"
  28. HEADER_INCLUDED
  29. #include <string.h>
  30. #if defined _MSC_VER && !defined snprintf
  31. #define snprintf _snprintf
  32. #endif
  33. void error_strerror( int ret, char *buf, size_t buflen )
  34. {
  35. size_t len;
  36. int use_ret;
  37. memset( buf, 0x00, buflen );
  38. if( ret < 0 )
  39. ret = -ret;
  40. if( ret & 0xFF80 )
  41. {
  42. use_ret = ret & 0xFF80;
  43. // High level error codes
  44. //
  45. HIGH_LEVEL_CODE_CHECKS
  46. if( strlen( buf ) == 0 )
  47. snprintf( buf, buflen, "UNKNOWN ERROR CODE (%04X)", use_ret );
  48. }
  49. use_ret = ret & ~0xFF80;
  50. if( use_ret == 0 )
  51. return;
  52. // If high level code is present, make a concatenation between both
  53. // error strings.
  54. //
  55. len = strlen( buf );
  56. if( len > 0 )
  57. {
  58. if( buflen - len < 5 )
  59. return;
  60. snprintf( buf + len, buflen - len, " : " );
  61. buf += len + 3;
  62. buflen -= len + 3;
  63. }
  64. // Low level error codes
  65. //
  66. LOW_LEVEL_CODE_CHECKS
  67. if( strlen( buf ) != 0 )
  68. return;
  69. snprintf( buf, buflen, "UNKNOWN ERROR CODE (%04X)", use_ret );
  70. }
  71. #else /* POLARSSL_ERROR_C */
  72. #if defined(POLARSSL_ERROR_STRERROR_DUMMY)
  73. #include <string.h>
  74. /*
  75. * Provide an non-function in case POLARSSL_ERROR_C is not defined
  76. */
  77. void error_strerror( int ret, char *buf, size_t buflen )
  78. {
  79. ((void) ret);
  80. if( buflen > 0 )
  81. buf[0] = '\0';
  82. }
  83. #endif /* POLARSSL_ERROR_STRERROR_DUMMY */
  84. #endif /* POLARSSL_ERROR_C */