GME  13
apr_time.h
Go to the documentation of this file.
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_TIME_H
00018 #define APR_TIME_H
00019 
00025 #include "apr.h"
00026 #include "apr_pools.h"
00027 #include "apr_errno.h"
00028 
00029 #ifdef __cplusplus
00030 extern "C" {
00031 #endif /* __cplusplus */
00032 
00040 APR_DECLARE_DATA extern const char apr_month_snames[12][4];
00042 APR_DECLARE_DATA extern const char apr_day_snames[7][4];
00043 
00044 
00046 typedef apr_int64_t apr_time_t;
00047 
00048 
00050 #define APR_TIME_C(val) APR_INT64_C(val)
00051 
00053 #define APR_TIME_T_FMT APR_INT64_T_FMT
00054 
00056 typedef apr_int64_t apr_interval_time_t;
00058 typedef apr_int32_t apr_short_interval_time_t;
00059 
00061 #define APR_USEC_PER_SEC APR_TIME_C(1000000)
00062 
00064 #define apr_time_sec(time) ((time) / APR_USEC_PER_SEC)
00065 
00067 #define apr_time_usec(time) ((time) % APR_USEC_PER_SEC)
00068 
00070 #define apr_time_msec(time) (((time) / 1000) % 1000)
00071 
00073 #define apr_time_as_msec(time) ((time) / 1000)
00074 
00076 #define apr_time_from_msec(msec) ((apr_time_t)(msec) * 1000)
00077 
00079 #define apr_time_from_sec(sec) ((apr_time_t)(sec) * APR_USEC_PER_SEC)
00080 
00082 #define apr_time_make(sec, usec) ((apr_time_t)(sec) * APR_USEC_PER_SEC \
00083                                 + (apr_time_t)(usec))
00084 
00088 APR_DECLARE(apr_time_t) apr_time_now(void);
00089 
00091 typedef struct apr_time_exp_t apr_time_exp_t;
00092 
00098 struct apr_time_exp_t {
00100     apr_int32_t tm_usec;
00102     apr_int32_t tm_sec;
00104     apr_int32_t tm_min;
00106     apr_int32_t tm_hour;
00108     apr_int32_t tm_mday;
00110     apr_int32_t tm_mon;
00112     apr_int32_t tm_year;
00114     apr_int32_t tm_wday;
00116     apr_int32_t tm_yday;
00118     apr_int32_t tm_isdst;
00120     apr_int32_t tm_gmtoff;
00121 };
00122 
00128 APR_DECLARE(apr_status_t) apr_time_ansi_put(apr_time_t *result, 
00129                                                     time_t input);
00130 
00138 APR_DECLARE(apr_status_t) apr_time_exp_tz(apr_time_exp_t *result,
00139                                           apr_time_t input,
00140                                           apr_int32_t offs);
00141 
00147 APR_DECLARE(apr_status_t) apr_time_exp_gmt(apr_time_exp_t *result, 
00148                                            apr_time_t input);
00149 
00155 APR_DECLARE(apr_status_t) apr_time_exp_lt(apr_time_exp_t *result, 
00156                                           apr_time_t input);
00157 
00164 APR_DECLARE(apr_status_t) apr_time_exp_get(apr_time_t *result, 
00165                                            apr_time_exp_t *input);
00166 
00173 APR_DECLARE(apr_status_t) apr_time_exp_gmt_get(apr_time_t *result, 
00174                                                apr_time_exp_t *input);
00175 
00181 APR_DECLARE(void) apr_sleep(apr_interval_time_t t);
00182 
00184 #define APR_RFC822_DATE_LEN (30)
00185 
00193 APR_DECLARE(apr_status_t) apr_rfc822_date(char *date_str, apr_time_t t);
00194 
00196 #define APR_CTIME_LEN (25)
00197 
00207 APR_DECLARE(apr_status_t) apr_ctime(char *date_str, apr_time_t t);
00208 
00217 APR_DECLARE(apr_status_t) apr_strftime(char *s, apr_size_t *retsize, 
00218                                        apr_size_t max, const char *format, 
00219                                        apr_time_exp_t *tm);
00220 
00227 APR_DECLARE(void) apr_time_clock_hires(apr_pool_t *p);
00228 
00231 #ifdef __cplusplus
00232 }
00233 #endif
00234 
00235 #endif  /* ! APR_TIME_H */