apr_time.inc 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  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_TIME_H
  17. //#define APR_TIME_H
  18. {**
  19. * @file apr_time.h
  20. * @brief APR Time Library
  21. *}
  22. //#include "apr.h"
  23. //#include "apr_pools.h"
  24. //#include "apr_errno.h"
  25. (**
  26. * @defgroup apr_time Time Routines
  27. * @ingroup APR
  28. * @{
  29. *)
  30. //** month names */
  31. //APR_DECLARE_DATA extern const char apr_month_snames[12][4];
  32. //** day names */
  33. //APR_DECLARE_DATA extern const char apr_day_snames[7][4];
  34. type
  35. //** number of microseconds since 00:00:00 january 1, 1970 UTC */
  36. //typedef apr_int64_t apr_time_t;
  37. apr_time_t = apr_int64_t;
  38. Papr_time_t = ^apr_time_t;
  39. //** mechanism to properly type apr_time_t literals */
  40. //#define APR_TIME_C(val) APR_INT64_C(val)
  41. //** mechanism to properly print apr_time_t values */
  42. //#define APR_TIME_T_FMT APR_INT64_T_FMT
  43. //** intervals for I/O timeouts, in microseconds */
  44. //typedef apr_int64_t apr_interval_time_t;
  45. apr_interval_time_t = apr_int64_t;
  46. Papr_interval_time_t = ^apr_interval_time_t;
  47. //** short interval for I/O timeouts, in microseconds */
  48. //typedef apr_int32_t apr_short_interval_time_t;
  49. apr_short_interval_time_t = apr_int32_t;
  50. {
  51. /** number of microseconds per second */
  52. #define APR_USEC_PER_SEC APR_TIME_C(1000000)
  53. /** @return apr_time_t as a second */
  54. #define apr_time_sec(time) ((time) / APR_USEC_PER_SEC)
  55. /** @return apr_time_t as a usec */
  56. #define apr_time_usec(time) ((time) % APR_USEC_PER_SEC)
  57. /** @return apr_time_t as a msec */
  58. #define apr_time_msec(time) (((time) / 1000) % 1000)
  59. /** @return apr_time_t as a msec */
  60. #define apr_time_as_msec(time) ((time) / 1000)
  61. /** @return milliseconds as an apr_time_t */
  62. #define apr_time_from_msec(msec) ((apr_time_t)(msec) * 1000)
  63. /** @return seconds as an apr_time_t */
  64. #define apr_time_from_sec(sec) ((apr_time_t)(sec) * APR_USEC_PER_SEC)
  65. /** @return a second and usec combination as an apr_time_t */
  66. #define apr_time_make(sec, usec) ((apr_time_t)(sec) * APR_USEC_PER_SEC \
  67. + (apr_time_t)(usec))
  68. }
  69. {**
  70. * @return the current time
  71. *}
  72. //APR_DECLARE(apr_time_t) apr_time_now(void);
  73. function apr_time_now: apr_time_t;
  74. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  75. external LibAPR name LibNamePrefix + 'apr_time_now' + LibSuff0;
  76. //** @see apr_time_exp_t */
  77. //typedef struct apr_time_exp_t apr_time_exp_t;
  78. type
  79. Papr_time_exp_t = ^apr_time_exp_t;
  80. {**
  81. * a structure similar to ANSI struct tm with the following differences:
  82. * - tm_usec isn't an ANSI field
  83. * - tm_gmtoff isn't an ANSI field (it's a bsdism)
  84. *}
  85. apr_time_exp_t = record
  86. //** microseconds past tm_sec */
  87. tm_usec: apr_int32_t;
  88. //** (0-61) seconds past tm_min */
  89. tm_sec: apr_int32_t;
  90. //** (0-59) minutes past tm_hour */
  91. tm_min: apr_int32_t;
  92. //** (0-23) hours past midnight */
  93. tm_hour: apr_int32_t;
  94. //** (1-31) day of the month */
  95. tm_mday: apr_int32_t;
  96. //** (0-11) month of the year */
  97. tm_mon: apr_int32_t;
  98. //** year since 1900 */
  99. tm_year: apr_int32_t;
  100. //** (0-6) days since sunday */
  101. tm_wday: apr_int32_t;
  102. //** (0-365) days since jan 1 */
  103. tm_yday: apr_int32_t;
  104. //** daylight saving time */
  105. tm_isdst: apr_int32_t;
  106. //** seconds east of UTC */
  107. tm_gmtoff: apr_int32_t;
  108. end;
  109. {**
  110. * convert an ansi time_t to an apr_time_t
  111. * @param result the resulting apr_time_t
  112. * @param input the time_t to convert
  113. *}
  114. //APR_DECLARE(apr_status_t) apr_time_ansi_put(apr_time_t *result,
  115. // time_t input);
  116. function apr_time_ansi_put(result: Papr_time_t;
  117. input: time_t): apr_status_t;
  118. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  119. external LibAPR name LibNamePrefix + 'apr_time_ansi_put' + LibSuff12;//time_t is 64bit so it is 12
  120. {**
  121. * convert a time to its human readable components using an offset
  122. * from GMT
  123. * @param result the exploded time
  124. * @param input the time to explode
  125. * @param offs the number of seconds offset to apply
  126. *}
  127. //APR_DECLARE(apr_status_t) apr_time_exp_tz(apr_time_exp_t *result,
  128. // apr_time_t input,
  129. // apr_int32_t offs);
  130. function apr_time_exp_tz(result_: Papr_time_exp_t;
  131. input_: apr_time_t;
  132. offs: apr_int32_t): apr_status_t;
  133. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  134. external LibAPR name LibNamePrefix + 'apr_time_exp_tz' + LibSuff16;//apr_time_t is 64bit so it is 16
  135. {**
  136. * convert a time to its human readable components in GMT timezone
  137. * @param result the exploded time
  138. * @param input the time to explode
  139. *}
  140. //APR_DECLARE(apr_status_t) apr_time_exp_gmt(apr_time_exp_t *result,
  141. // apr_time_t input);
  142. function apr_time_exp_gmt(result_: Papr_time_exp_t;
  143. input_: apr_time_t): apr_status_t;
  144. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  145. external LibAPR name LibNamePrefix + 'apr_time_exp_gmt' + LibSuff12;//apr_time_t is 64bit so it is 12
  146. {**
  147. * convert a time to its human readable components in local timezone
  148. * @param result the exploded time
  149. * @param input the time to explode
  150. *}
  151. //APR_DECLARE(apr_status_t) apr_time_exp_lt(apr_time_exp_t *result,
  152. // apr_time_t input);
  153. function apr_time_exp_lt(result_: Papr_time_exp_t;
  154. input_: apr_time_t): apr_status_t;
  155. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  156. external LibAPR name LibNamePrefix + 'apr_time_exp_lt' + LibSuff12;//apr_time_t is 64bit so it is 12
  157. {**
  158. * Convert time value from human readable format to a numeric apr_time_t
  159. * e.g. elapsed usec since epoch
  160. * @param result the resulting imploded time
  161. * @param input the input exploded time
  162. *}
  163. //APR_DECLARE(apr_status_t) apr_time_exp_get(apr_time_t *result,
  164. // apr_time_exp_t *input);
  165. function apr_time_exp_get(result_: Papr_time_t;
  166. input_: Papr_time_exp_t): apr_status_t;
  167. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  168. external LibAPR name LibNamePrefix + 'apr_time_exp_get' + LibSuff8;
  169. {**
  170. * Convert time value from human readable format to a numeric apr_time_t that
  171. * always represents GMT
  172. * @param result the resulting imploded time
  173. * @param input the input exploded time
  174. *}
  175. //APR_DECLARE(apr_status_t) apr_time_exp_gmt_get(apr_time_t *result,
  176. // apr_time_exp_t *input);
  177. function apr_time_exp_gmt_get(result_: Papr_time_t;
  178. input_: Papr_time_exp_t): apr_status_t;
  179. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  180. external LibAPR name LibNamePrefix + 'apr_time_exp_gmt_get' + LibSuff8;
  181. {**
  182. * Sleep for the specified number of micro-seconds.
  183. * @param t desired amount of time to sleep.
  184. * @warning May sleep for longer than the specified time.
  185. *}
  186. //APR_DECLARE(void) apr_sleep(apr_interval_time_t t);
  187. procedure apr_sleep(t: apr_interval_time_t);
  188. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  189. external LibAPR name LibNamePrefix + 'apr_sleep' + LibSuff8;//apr_interval_time_t is 64bit, so it is 8
  190. //** length of a RFC822 Date */
  191. //#define APR_RFC822_DATE_LEN (30)
  192. const APR_RFC822_DATE_LEN = (30);
  193. {**
  194. * apr_rfc822_date formats dates in the RFC822
  195. * format in an efficient manner. It is a fixed length
  196. * format which requires the indicated amount of storage,
  197. * including the trailing NUL terminator.
  198. * @param date_str String to write to.
  199. * @param t the time to convert
  200. *}
  201. //APR_DECLARE(apr_status_t) apr_rfc822_date(char *date_str, apr_time_t t);
  202. function apr_rfc822_date(date_str: PChar; t: apr_time_t): apr_status_t;
  203. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  204. external LibAPR name LibNamePrefix + 'apr_rfc822_date' + LibSuff12;//apr_time_t is 64bit so it is 12
  205. //** length of a CTIME date */
  206. //#define APR_CTIME_LEN (25)
  207. const APR_CTIME_LEN = (25);
  208. {**
  209. * apr_ctime formats dates in the ctime() format
  210. * in an efficient manner. it is a fixed length format
  211. * and requires the indicated amount of storage including
  212. * the trailing NUL terminator.
  213. * Unlike ANSI/ISO C ctime(), apr_ctime() does not include
  214. * a \n at the end of the string.
  215. * @param date_str String to write to.
  216. * @param t the time to convert
  217. *}
  218. //APR_DECLARE(apr_status_t) apr_ctime(char *date_str, apr_time_t t);
  219. function apr_ctime(date_str: PChar; t: apr_time_t): apr_status_t;
  220. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  221. external LibAPR name LibNamePrefix + 'apr_ctime' + LibSuff12;//apr_time_t is 64bit so it is 12
  222. {**
  223. * formats the exploded time according to the format specified
  224. * @param s string to write to
  225. * @param retsize The length of the returned string
  226. * @param max The maximum length of the string
  227. * @param format The format for the time string
  228. * @param tm The time to convert
  229. *}
  230. //APR_DECLARE(apr_status_t) apr_strftime(char *s, apr_size_t *retsize,
  231. // apr_size_t max, const char *format,
  232. // apr_time_exp_t *tm);
  233. function apr_strftime(s: PChar;
  234. retsize, max: apr_size_t;
  235. const format_: PChar;
  236. tm: Papr_time_exp_t): apr_status_t;
  237. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  238. external LibAPR name LibNamePrefix + 'apr_strftime' + LibSuff20;
  239. {**
  240. * Improve the clock resolution for the lifetime of the given pool.
  241. * Generally this is only desireable on benchmarking and other very
  242. * time-sensitive applications, and has no impact on most platforms.
  243. * @param p The pool to associate the finer clock resolution
  244. *}
  245. //APR_DECLARE(void) apr_time_clock_hires(apr_pool_t *p);
  246. procedure apr_time_clock_hires(p: Papr_pool_t);
  247. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  248. external LibAPR name LibNamePrefix + 'apr_time_clock_hires' + LibSuff4;
  249. (** @} *)
  250. //#endif /* ! APR_TIME_H */