Apache Portable Runtime
Loading...
Searching...
No Matches
apr_date.h
Go to the documentation of this file.
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
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
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.
15 */
16
17#ifndef APR_DATE_H
18#define APR_DATE_H
19
20/**
21 * @file apr_date.h
22 * @brief APR-UTIL date routines
23 */
24
25/**
26 * @defgroup APR_Util_Date Date routines
27 * @ingroup APR
28 * @{
29 */
30
31/*
32 * apr_date.h: prototypes for date parsing utility routines
33 */
34
35#include "apu.h"
36#include "apr_time.h"
37
38#ifdef __cplusplus
39extern "C" {
40#endif
41
42/** A bad date. */
43#define APR_DATE_BAD ((apr_time_t)0)
44
45/**
46 * Compare a string to a mask
47 * @param data The string to compare
48 * @param mask Mask characters (arbitrary maximum is 256 characters):
49 * <PRE>
50 * '\@' - uppercase letter
51 * '\$' - lowercase letter
52 * '\&' - hex digit
53 * '#' - digit
54 * '~' - digit or space
55 * '*' - swallow remaining characters
56 * </PRE>
57 * @remark The mask tests for an exact match for any other character
58 * @return 1 if the string matches, 0 otherwise
59 */
60APR_DECLARE(int) apr_date_checkmask(const char *data, const char *mask);
61
62/**
63 * Parses an HTTP date in one of three standard forms:
64 * <PRE>
65 * Sun, 06 Nov 1994 08:49:37 GMT ; RFC 822, updated by RFC 1123
66 * Sunday, 06-Nov-94 08:49:37 GMT ; RFC 850, obsoleted by RFC 1036
67 * Sun Nov 6 08:49:37 1994 ; ANSI C's asctime() format
68 * </PRE>
69 * @param date The date in one of the three formats above
70 * @return the apr_time_t number of microseconds since 1 Jan 1970 GMT, or
71 * 0 if this would be out of range or if the date is invalid.
72 */
74
75/**
76 * Parses a string resembling an RFC 822 date. This is meant to be
77 * leinent in its parsing of dates. Hence, this will parse a wider
78 * range of dates than apr_date_parse_http.
79 *
80 * The prominent mailer (or poster, if mailer is unknown) that has
81 * been seen in the wild is included for the unknown formats.
82 * <PRE>
83 * Sun, 06 Nov 1994 08:49:37 GMT ; RFC 822, updated by RFC 1123
84 * Sunday, 06-Nov-94 08:49:37 GMT ; RFC 850, obsoleted by RFC 1036
85 * Sun Nov 6 08:49:37 1994 ; ANSI C's asctime() format
86 * Sun, 6 Nov 1994 08:49:37 GMT ; RFC 822, updated by RFC 1123
87 * Sun, 06 Nov 94 08:49:37 GMT ; RFC 822
88 * Sun, 6 Nov 94 08:49:37 GMT ; RFC 822
89 * Sun, 06 Nov 94 08:49 GMT ; Unknown [drtr\@ast.cam.ac.uk]
90 * Sun, 6 Nov 94 08:49 GMT ; Unknown [drtr\@ast.cam.ac.uk]
91 * Sun, 06 Nov 94 8:49:37 GMT ; Unknown [Elm 70.85]
92 * Sun, 6 Nov 94 8:49:37 GMT ; Unknown [Elm 70.85]
93 * </PRE>
94 *
95 * @param date The date in one of the formats above
96 * @return the apr_time_t number of microseconds since 1 Jan 1970 GMT, or
97 * 0 if this would be out of range or if the date is invalid.
98 */
100
101/** @} */
102#ifdef __cplusplus
103}
104#endif
105
106#endif /* !APR_DATE_H */
APR Time Library.
int apr_date_checkmask(const char *data, const char *mask)
apr_time_t apr_date_parse_rfc(const char *date)
apr_time_t apr_date_parse_http(const char *date)
#define APR_DECLARE(type)
Definition apr.h:523
apr_int64_t apr_time_t
Definition apr_time.h:45