1 /* Licensed to the Apache Software Foundation (ASF) under one or more
2 * contributor license agreements. See the NOTICE file distributed with
3 * this work for additional information regarding copyright ownership.
4 * The ASF licenses this file to You under the Apache License, Version 2.0
5 * (the "License"); you may not use this file except in compliance with
6 * the License. You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #include "apreq_error.h"
18 #include "apr_strings.h"
21 * stuffbuffer - like apr_cpystrn() but returns the address of the
22 * dest buffer instead of the address of the terminating '\0'
24 static char *stuffbuffer(char *buf, apr_size_t bufsize, const char *s)
26 apr_cpystrn(buf,s,bufsize);
30 static const char *apreq_error_string(apr_status_t statcode)
35 /* 0's: generic error status codes */
37 case APREQ_ERROR_GENERAL:
38 return "Internal apreq error";
40 case APREQ_ERROR_TAINTED:
41 return "Attempt to perform unsafe action with tainted data";
44 /* 10's: malformed input */
46 case APREQ_ERROR_BADDATA:
47 return "Malformed input data";
49 case APREQ_ERROR_BADCHAR:
50 return "Invalid character";
52 case APREQ_ERROR_BADSEQ:
53 return "Invalid byte sequence";
55 case APREQ_ERROR_BADATTR:
56 return "Unrecognized attribute";
58 case APREQ_ERROR_BADHEADER:
59 return "Malformed header string";
62 /* 20's: missing input */
64 case APREQ_ERROR_NODATA:
65 return "Missing input data";
67 case APREQ_ERROR_NOTOKEN:
68 return "Expected token not present";
70 case APREQ_ERROR_NOATTR:
71 return "Missing attribute";
73 case APREQ_ERROR_NOHEADER:
74 return "Missing header";
76 case APREQ_ERROR_NOPARSER:
77 return "Missing parser";
80 /* 30's: configuration conflicts */
82 case APREQ_ERROR_MISMATCH:
83 return "Conflicting information";
85 case APREQ_ERROR_OVERLIMIT:
86 return "Exceeds configured maximum limit";
88 case APREQ_ERROR_NOTEMPTY:
89 return "Setting already configured";
93 return "Error string not yet specified by apreq";
98 APREQ_DECLARE(char *) apreq_strerror(apr_status_t statcode, char *buf,
101 if (statcode < APR_OS_START_USERERR || statcode >= APR_OS_START_EAIERR)
102 return apr_strerror(statcode, buf, bufsize);
103 return stuffbuffer(buf, bufsize, apreq_error_string(statcode));