error_parser.h 2.9 KB

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