1 /*
2 **  Licensed to the Apache Software Foundation (ASF) under one or more
3 ** contributor license agreements.  See the NOTICE file distributed with
4 ** this work for additional information regarding copyright ownership.
5 ** The ASF licenses this file to You under the Apache License, Version 2.0
6 ** (the "License"); you may not use this file except in compliance with
7 ** the License.  You may obtain a copy of the License at
8 **
9 **      http://www.apache.org/licenses/LICENSE-2.0
10 **
11 **  Unless required by applicable law or agreed to in writing, software
12 **  distributed under the License is distributed on an "AS IS" BASIS,
13 **  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 **  See the License for the specific language governing permissions and
15 **  limitations under the License.
16 */
17 
18 #ifndef APREQ_ERROR_H
19 #define APREQ_ERROR_H
20 
21 #include "apr_errno.h"
22 #include "apreq.h"
23 
24 #ifdef  __cplusplus
25  extern "C" {
26 #endif
27 
28 /**
29  * apreq's wrapper around apr_strerror();
30  * recognizes APREQ_ERROR_* status codes.
31  */
32 APREQ_DECLARE(char *)
33 apreq_strerror(apr_status_t s, char *buf, apr_size_t bufsize);
34 
35 /**
36  * @file apreq_error.h
37  * @brief Error status codes.
38  * @ingroup libapreq2
39  *
40  * Define the APREQ_ error codes.
41  */
42 
43 #ifndef APR_EBADARG
44 /**
45  * Bad Arguments return value
46  * @see APR_BADARG
47  */
48 #define APR_EBADARG                APR_BADARG   /* XXX: don't use APR_BADARG */
49 #endif
50 
51 /** Internal apreq error. */
52 #define APREQ_ERROR_GENERAL        APR_OS_START_USERERR
53 /** Attempted to perform unsafe action with tainted data. */
54 #define APREQ_ERROR_TAINTED        (APREQ_ERROR_GENERAL + 1)
55 /** Parsing interrupted. */
56 #define APREQ_ERROR_INTERRUPT      (APREQ_ERROR_GENERAL + 2)
57 
58 /** Invalid input data. */
59 #define APREQ_ERROR_BADDATA        (APREQ_ERROR_GENERAL  + 10)
60 /** Invalid character. */
61 #define APREQ_ERROR_BADCHAR        (APREQ_ERROR_BADDATA  +  1)
62 /** Invalid byte sequence. */
63 #define APREQ_ERROR_BADSEQ         (APREQ_ERROR_BADDATA  +  2)
64 /** Invalid attribute. */
65 #define APREQ_ERROR_BADATTR        (APREQ_ERROR_BADDATA  +  3)
66 /** Invalid header. */
67 #define APREQ_ERROR_BADHEADER      (APREQ_ERROR_BADDATA  +  4)
68 /** Invalid utf8 encoding. */
69 #define APREQ_ERROR_BADUTF8        (APREQ_ERROR_BADDATA  +  5)
70 
71 /** Missing input data. */
72 #define APREQ_ERROR_NODATA         (APREQ_ERROR_GENERAL  + 20)
73 /** Missing required token. */
74 #define APREQ_ERROR_NOTOKEN        (APREQ_ERROR_NODATA   +  1)
75 /** Missing attribute. */
76 #define APREQ_ERROR_NOATTR         (APREQ_ERROR_NODATA   +  2)
77 /** Missing header. */
78 #define APREQ_ERROR_NOHEADER       (APREQ_ERROR_NODATA   +  3)
79 /** Missing parser. */
80 #define APREQ_ERROR_NOPARSER       (APREQ_ERROR_NODATA   +  4)
81 
82 
83 /** Conflicting information. */
84 #define APREQ_ERROR_MISMATCH       (APREQ_ERROR_GENERAL  + 30)
85 /** Exceeds configured maximum limit. */
86 #define APREQ_ERROR_OVERLIMIT      (APREQ_ERROR_MISMATCH +  1)
87 /** Below configured minimum limit. */
88 #define APREQ_ERROR_UNDERLIMIT     (APREQ_ERROR_MISMATCH +  2)
89 /** Setting already configured. */
90 #define APREQ_ERROR_NOTEMPTY       (APREQ_ERROR_MISMATCH +  3)
91 
92 
93 #ifdef __cplusplus
94  }
95 #endif
96 
97 #endif /* APREQ_ERROR_H */
98