apr_date.h 3.6 KB

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