error_parser.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /** **************************************************************************
  2. * error_parser.h
  3. *
  4. * Copyright 2008 Bryan Ischo <[email protected]>
  5. *
  6. * This file is part of libs3.
  7. *
  8. * libs3 is free software: you can redistribute it and/or modify it under the
  9. * terms of the GNU Lesser General Public License as published by the Free
  10. * Software Foundation, version 3 of the License.
  11. *
  12. * In addition, as a special exception, the copyright holders give
  13. * permission to link the code of this library and its programs with the
  14. * OpenSSL library, and distribute linked combinations including the two.
  15. *
  16. * libs3 is distributed in the hope that it will be useful, but WITHOUT ANY
  17. * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  18. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  19. * details.
  20. *
  21. * You should have received a copy of the GNU Lesser General Public License
  22. * version 3 along with libs3, in a file named COPYING. If not, see
  23. * <http://www.gnu.org/licenses/>.
  24. *
  25. ************************************************************************** **/
  26. #ifndef ERROR_PARSER_H
  27. #define ERROR_PARSER_H
  28. #include "libs3.h"
  29. #include "simplexml.h"
  30. #include "string_buffer.h"
  31. #define EXTRA_DETAILS_SIZE 8
  32. typedef struct ErrorParser
  33. {
  34. // This is the S3ErrorDetails that this ErrorParser fills in from the
  35. // data that it parses
  36. S3ErrorDetails s3ErrorDetails;
  37. // This is the error XML parser
  38. SimpleXml errorXmlParser;
  39. // Set to 1 after the first call to add
  40. int errorXmlParserInitialized;
  41. // Used to buffer the S3 Error Code as it is read in
  42. string_buffer(code, 1024);
  43. // Used to buffer the S3 Error Message as it is read in
  44. string_buffer(message, 1024);
  45. // Used to buffer the S3 Error Resource as it is read in
  46. string_buffer(resource, 1024);
  47. // Used to buffer the S3 Error Further Details as it is read in
  48. string_buffer(furtherDetails, 1024);
  49. // The extra details; we support up to EXTRA_DETAILS_SIZE of them
  50. S3NameValue extraDetails[EXTRA_DETAILS_SIZE];
  51. // This is the buffer from which the names and values used in extraDetails
  52. // are allocated
  53. string_multibuffer(extraDetailsNamesValues, EXTRA_DETAILS_SIZE * 1024);
  54. } ErrorParser;
  55. // Always call this
  56. void error_parser_initialize(ErrorParser *errorParser);
  57. S3Status error_parser_add(ErrorParser *errorParser, const /*WINSCP (const)*/ char *buffer,
  58. int bufferSize);
  59. void error_parser_convert_status(ErrorParser *errorParser, S3Status *status);
  60. // Always call this
  61. void error_parser_deinitialize(ErrorParser *errorParser);
  62. #endif /* ERROR_PARSER_H */