1251876Speter/* Licensed to the Apache Software Foundation (ASF) under one or more
2251876Speter * contributor license agreements.  See the NOTICE file distributed with
3251876Speter * this work for additional information regarding copyright ownership.
4251876Speter * The ASF licenses this file to You under the Apache License, Version 2.0
5251876Speter * (the "License"); you may not use this file except in compliance with
6251876Speter * the License.  You may obtain a copy of the License at
7251876Speter *
8251876Speter *     http://www.apache.org/licenses/LICENSE-2.0
9251876Speter *
10251876Speter * Unless required by applicable law or agreed to in writing, software
11251876Speter * distributed under the License is distributed on an "AS IS" BASIS,
12251876Speter * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13251876Speter * See the License for the specific language governing permissions and
14251876Speter * limitations under the License.
15251876Speter */
16251876Speter
17251876Speter#ifndef APR_DATE_H
18251876Speter#define APR_DATE_H
19251876Speter
20251876Speter/**
21251876Speter * @file apr_date.h
22251876Speter * @brief APR-UTIL date routines
23251876Speter */
24251876Speter
25251876Speter/**
26251876Speter * @defgroup APR_Util_Date Date routines
27251876Speter * @ingroup APR_Util
28251876Speter * @{
29251876Speter */
30251876Speter
31251876Speter/*
32251876Speter * apr_date.h: prototypes for date parsing utility routines
33251876Speter */
34251876Speter
35251876Speter#include "apu.h"
36251876Speter#include "apr_time.h"
37251876Speter
38251876Speter#ifdef __cplusplus
39251876Speterextern "C" {
40251876Speter#endif
41251876Speter
42251876Speter/** A bad date. */
43251876Speter#define APR_DATE_BAD ((apr_time_t)0)
44251876Speter
45251876Speter/**
46251876Speter * Compare a string to a mask
47251876Speter * @param data The string to compare
48251876Speter * @param mask Mask characters (arbitrary maximum is 256 characters):
49251876Speter * <PRE>
50251876Speter *   '\@' - uppercase letter
51251876Speter *   '\$' - lowercase letter
52251876Speter *   '\&' - hex digit
53251876Speter *   '#' - digit
54251876Speter *   '~' - digit or space
55251876Speter *   '*' - swallow remaining characters
56251876Speter * </PRE>
57251876Speter * @remark The mask tests for an exact match for any other character
58251876Speter * @return 1 if the string matches, 0 otherwise
59251876Speter */
60251876SpeterAPU_DECLARE(int) apr_date_checkmask(const char *data, const char *mask);
61251876Speter
62251876Speter/**
63251876Speter * Parses an HTTP date in one of three standard forms:
64251876Speter * <PRE>
65251876Speter *     Sun, 06 Nov 1994 08:49:37 GMT  ; RFC 822, updated by RFC 1123
66251876Speter *     Sunday, 06-Nov-94 08:49:37 GMT ; RFC 850, obsoleted by RFC 1036
67251876Speter *     Sun Nov  6 08:49:37 1994       ; ANSI C's asctime() format
68251876Speter * </PRE>
69251876Speter * @param date The date in one of the three formats above
70251876Speter * @return the apr_time_t number of microseconds since 1 Jan 1970 GMT, or
71251876Speter *         0 if this would be out of range or if the date is invalid.
72251876Speter */
73251876SpeterAPU_DECLARE(apr_time_t) apr_date_parse_http(const char *date);
74251876Speter
75251876Speter/**
76251876Speter * Parses a string resembling an RFC 822 date.  This is meant to be
77251876Speter * leinent in its parsing of dates.  Hence, this will parse a wider
78251876Speter * range of dates than apr_date_parse_http.
79251876Speter *
80251876Speter * The prominent mailer (or poster, if mailer is unknown) that has
81251876Speter * been seen in the wild is included for the unknown formats.
82251876Speter * <PRE>
83251876Speter *     Sun, 06 Nov 1994 08:49:37 GMT  ; RFC 822, updated by RFC 1123
84251876Speter *     Sunday, 06-Nov-94 08:49:37 GMT ; RFC 850, obsoleted by RFC 1036
85251876Speter *     Sun Nov  6 08:49:37 1994       ; ANSI C's asctime() format
86251876Speter *     Sun, 6 Nov 1994 08:49:37 GMT   ; RFC 822, updated by RFC 1123
87251876Speter *     Sun, 06 Nov 94 08:49:37 GMT    ; RFC 822
88251876Speter *     Sun, 6 Nov 94 08:49:37 GMT     ; RFC 822
89251876Speter *     Sun, 06 Nov 94 08:49 GMT       ; Unknown [drtr\@ast.cam.ac.uk]
90251876Speter *     Sun, 6 Nov 94 08:49 GMT        ; Unknown [drtr\@ast.cam.ac.uk]
91251876Speter *     Sun, 06 Nov 94 8:49:37 GMT     ; Unknown [Elm 70.85]
92251876Speter *     Sun, 6 Nov 94 8:49:37 GMT      ; Unknown [Elm 70.85]
93251876Speter * </PRE>
94251876Speter *
95251876Speter * @param date The date in one of the formats above
96251876Speter * @return the apr_time_t number of microseconds since 1 Jan 1970 GMT, or
97251876Speter *         0 if this would be out of range or if the date is invalid.
98251876Speter */
99251876SpeterAPU_DECLARE(apr_time_t) apr_date_parse_rfc(const char *date);
100251876Speter
101251876Speter/** @} */
102251876Speter#ifdef __cplusplus
103251876Speter}
104251876Speter#endif
105251876Speter
106251876Speter#endif	/* !APR_DATE_H */
107