00001 /* Licensed to the Apache Software Foundation (ASF) under one or more 00002 * contributor license agreements. See the NOTICE file distributed with 00003 * this work for additional information regarding copyright ownership. 00004 * The ASF licenses this file to You under the Apache License, Version 2.0 00005 * (the "License"); you may not use this file except in compliance with 00006 * the License. You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 00017 #ifndef APR_DATE_H 00018 #define APR_DATE_H 00019 00020 /** 00021 * @file apr_date.h 00022 * @brief APR-UTIL date routines 00023 */ 00024 00025 /** 00026 * @defgroup APR_Util_Date Date routines 00027 * @ingroup APR_Util 00028 * @{ 00029 */ 00030 00031 /* 00032 * apr_date.h: prototypes for date parsing utility routines 00033 */ 00034 00035 #include "apu.h" 00036 #include "apr_time.h" 00037 00038 #ifdef __cplusplus 00039 extern "C" { 00040 #endif 00041 00042 /** A bad date. */ 00043 #define APR_DATE_BAD ((apr_time_t)0) 00044 00045 /** 00046 * Compare a string to a mask 00047 * @param data The string to compare 00048 * @param mask Mask characters (arbitrary maximum is 256 characters): 00049 * <PRE> 00050 * '\@' - uppercase letter 00051 * '\$' - lowercase letter 00052 * '\&' - hex digit 00053 * '#' - digit 00054 * '~' - digit or space 00055 * '*' - swallow remaining characters 00056 * </PRE> 00057 * @remark The mask tests for an exact match for any other character 00058 * @return 1 if the string matches, 0 otherwise 00059 */ 00060 APU_DECLARE(int) apr_date_checkmask(const char *data, const char *mask); 00061 00062 /** 00063 * Parses an HTTP date in one of three standard forms: 00064 * <PRE> 00065 * Sun, 06 Nov 1994 08:49:37 GMT ; RFC 822, updated by RFC 1123 00066 * Sunday, 06-Nov-94 08:49:37 GMT ; RFC 850, obsoleted by RFC 1036 00067 * Sun Nov 6 08:49:37 1994 ; ANSI C's asctime() format 00068 * </PRE> 00069 * @param date The date in one of the three formats above 00070 * @return the apr_time_t number of microseconds since 1 Jan 1970 GMT, or 00071 * 0 if this would be out of range or if the date is invalid. 00072 */ 00073 APU_DECLARE(apr_time_t) apr_date_parse_http(const char *date); 00074 00075 /** 00076 * Parses a string resembling an RFC 822 date. This is meant to be 00077 * leinent in its parsing of dates. Hence, this will parse a wider 00078 * range of dates than apr_date_parse_http. 00079 * 00080 * The prominent mailer (or poster, if mailer is unknown) that has 00081 * been seen in the wild is included for the unknown formats. 00082 * <PRE> 00083 * Sun, 06 Nov 1994 08:49:37 GMT ; RFC 822, updated by RFC 1123 00084 * Sunday, 06-Nov-94 08:49:37 GMT ; RFC 850, obsoleted by RFC 1036 00085 * Sun Nov 6 08:49:37 1994 ; ANSI C's asctime() format 00086 * Sun, 6 Nov 1994 08:49:37 GMT ; RFC 822, updated by RFC 1123 00087 * Sun, 06 Nov 94 08:49:37 GMT ; RFC 822 00088 * Sun, 6 Nov 94 08:49:37 GMT ; RFC 822 00089 * Sun, 06 Nov 94 08:49 GMT ; Unknown [drtr\@ast.cam.ac.uk] 00090 * Sun, 6 Nov 94 08:49 GMT ; Unknown [drtr\@ast.cam.ac.uk] 00091 * Sun, 06 Nov 94 8:49:37 GMT ; Unknown [Elm 70.85] 00092 * Sun, 6 Nov 94 8:49:37 GMT ; Unknown [Elm 70.85] 00093 * </PRE> 00094 * 00095 * @param date The date in one of the formats above 00096 * @return the apr_time_t number of microseconds since 1 Jan 1970 GMT, or 00097 * 0 if this would be out of range or if the date is invalid. 00098 */ 00099 APU_DECLARE(apr_time_t) apr_date_parse_rfc(const char *date); 00100 00101 /** @} */ 00102 #ifdef __cplusplus 00103 } 00104 #endif 00105 00106 #endif /* !APR_DATE_H */