1 /** **************************************************************************
2  * error_parser.h
3  *
4  * Copyright 2008 Bryan Ischo <bryan@ischo.com>
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 
33 #ifndef ERROR_PARSER_H
34 #define ERROR_PARSER_H
35 
36 #include "libs3.h"
37 #include "simplexml.h"
38 #include "string_buffer.h"
39 
40 
41 #define EXTRA_DETAILS_SIZE 8
42 
43 typedef struct ErrorParser
44 {
45     // This is the S3ErrorDetails that this ErrorParser fills in from the
46     // data that it parses
47     S3ErrorDetails s3ErrorDetails;
48 
49     // This is the error XML parser
50     SimpleXml errorXmlParser;
51 
52     // Set to 1 after the first call to add
53     int errorXmlParserInitialized;
54 
55     // Used to buffer the S3 Error Code as it is read in
56     string_buffer(code, 1024);
57 
58     // Used to buffer the S3 Error Message as it is read in
59     string_buffer(message, 1024);
60 
61     // Used to buffer the S3 Error Resource as it is read in
62     string_buffer(resource, 1024);
63 
64     // Used to buffer the S3 Error Further Details as it is read in
65     string_buffer(furtherDetails, 1024);
66 
67     // The extra details; we support up to EXTRA_DETAILS_SIZE of them
68     S3NameValue extraDetails[EXTRA_DETAILS_SIZE];
69 
70     // This is the buffer from which the names and values used in extraDetails
71     // are allocated
72     string_multibuffer(extraDetailsNamesValues, EXTRA_DETAILS_SIZE * 1024);
73 } ErrorParser;
74 
75 
76 // Always call this
77 void error_parser_initialize(ErrorParser *errorParser);
78 
79 S3Status error_parser_add(ErrorParser *errorParser, char *buffer,
80                           int bufferSize);
81 
82 void error_parser_convert_status(ErrorParser *errorParser, S3Status *status);
83 
84 // Always call this
85 void error_parser_deinitialize(ErrorParser *errorParser);
86 
87 
88 #endif /* ERROR_PARSER_H */
89