github.com/krum110487/go-htaccess@v0.0.0-20240316004156-60641c8e7598/tests/data/apache_2_4_58/include/util_time.h (about)

     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  /**
    18   * @file  util_time.h
    19   * @brief Apache date-time handling functions
    20   *
    21   * @defgroup APACHE_CORE_TIME Date-time handling functions
    22   * @ingroup  APACHE_CORE
    23   * @{
    24   */
    25  
    26  #ifndef APACHE_UTIL_TIME_H
    27  #define APACHE_UTIL_TIME_H
    28  
    29  #include "apr.h"
    30  #include "apr_time.h"
    31  #include "httpd.h"
    32  
    33  #ifdef __cplusplus
    34  extern "C" {
    35  #endif
    36  
    37  /* Maximum delta from the current time, in seconds, for a past time
    38   * to qualify as "recent" for use in the ap_explode_recent_*() functions:
    39   * (Must be a power of two minus one!)
    40   */
    41  #define AP_TIME_RECENT_THRESHOLD 15
    42  
    43  /* Options for ap_recent_ctime_ex */
    44  /* No extension */
    45  #define AP_CTIME_OPTION_NONE    0x0
    46  /* Add sub second timestamps with micro second resolution */
    47  #define AP_CTIME_OPTION_USEC    0x1
    48  /* Use more compact ISO 8601 format */
    49  #define AP_CTIME_OPTION_COMPACT 0x2
    50  /* Add timezone offset from GMT ([+-]hhmm) */
    51  #define AP_CTIME_OPTION_GMTOFF  0x4
    52  
    53  
    54  /**
    55   * convert a recent time to its human readable components in local timezone
    56   * @param tm the exploded time
    57   * @param t the time to explode: MUST be within the last
    58   *          AP_TIME_RECENT_THRESHOLD seconds
    59   * @note This is a faster alternative to apr_time_exp_lt that uses
    60   *       a cache of pre-exploded time structures.  It is useful for things
    61   *       that need to explode the current time multiple times per second,
    62   *       like loggers.
    63   * @return APR_SUCCESS iff successful
    64   */
    65  AP_DECLARE(apr_status_t) ap_explode_recent_localtime(apr_time_exp_t *tm,
    66                                                       apr_time_t t);
    67  
    68  /**
    69   * convert a recent time to its human readable components in GMT timezone
    70   * @param tm the exploded time
    71   * @param t the time to explode: MUST be within the last
    72   *          AP_TIME_RECENT_THRESHOLD seconds
    73   * @note This is a faster alternative to apr_time_exp_gmt that uses
    74   *       a cache of pre-exploded time structures.  It is useful for things
    75   *       that need to explode the current time multiple times per second,
    76   *       like loggers.
    77   * @return APR_SUCCESS iff successful
    78   */
    79  AP_DECLARE(apr_status_t) ap_explode_recent_gmt(apr_time_exp_t *tm,
    80                                                 apr_time_t t);
    81  
    82  
    83  /**
    84   * format a recent timestamp in the ctime() format.
    85   * @param date_str String to write to.
    86   * @param t the time to convert
    87   * @note Consider using ap_recent_ctime_ex instead.
    88   * @return APR_SUCCESS iff successful
    89   */
    90  AP_DECLARE(apr_status_t) ap_recent_ctime(char *date_str, apr_time_t t);
    91  
    92  
    93  /**
    94   * format a recent timestamp in an extended ctime() format.
    95   * @param date_str String to write to.
    96   * @param t the time to convert
    97   * @param option Additional formatting options (AP_CTIME_OPTION_*).
    98   * @param len Pointer to an int containing the length of the provided buffer.
    99   *        On successful return it contains the number of bytes written to the
   100   *        buffer (including trailing NUL byte).
   101   * @return APR_SUCCESS iff successful, APR_ENOMEM if buffer was to short.
   102   */
   103  AP_DECLARE(apr_status_t) ap_recent_ctime_ex(char *date_str, apr_time_t t,
   104                                              int option, int *len);
   105  
   106  
   107  /**
   108   * format a recent timestamp in the RFC822 format
   109   * @param date_str String to write to (must have length >= APR_RFC822_DATE_LEN)
   110   * @param t the time to convert
   111   */
   112  AP_DECLARE(apr_status_t) ap_recent_rfc822_date(char *date_str, apr_time_t t);
   113  
   114  #ifdef __cplusplus
   115  }
   116  #endif
   117  
   118  #endif  /* !APACHE_UTIL_TIME_H */
   119  /** @} */