home *** CD-ROM | disk | FTP | other *** search
/ H4CK3R 14 / hacker14.iso / programacao / cwin / c.exe / $INSTDIR / include / time.h < prev    next >
Encoding:
C/C++ Source or Header  |  2003-12-15  |  5.3 KB  |  221 lines

  1. /* 
  2.  * time.h
  3.  *
  4.  * Date and time functions and types.
  5.  *
  6.  * This file is part of the Mingw32 package.
  7.  *
  8.  * Contributors:
  9.  *  Created by Colin Peters <colin@bird.fu.is.saga-u.ac.jp>
  10.  *
  11.  *  THIS SOFTWARE IS NOT COPYRIGHTED
  12.  *
  13.  *  This source code is offered for use in the public domain. You may
  14.  *  use, modify or distribute it freely.
  15.  *
  16.  *  This code is distributed in the hope that it will be useful but
  17.  *  WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
  18.  *  DISCLAIMED. This includes but is not limited to warranties of
  19.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  20.  *
  21.  * $Revision: 1.5 $
  22.  * $Author: earnie $
  23.  * $Date: 2002/11/12 15:29:40 $
  24.  *
  25.  */
  26.  
  27. #ifndef    _TIME_H_
  28. #define    _TIME_H_
  29.  
  30. /* All the headers include this file. */
  31. #include <_mingw.h>
  32.  
  33. #define __need_wchar_t
  34. #define __need_size_t
  35. #define __need_NULL
  36. #ifndef RC_INVOKED
  37. #include <stddef.h>
  38. #endif    /* Not RC_INVOKED */
  39.  
  40. /*
  41.  * Need a definition of time_t.
  42.  */
  43. #include <sys/types.h>
  44.  
  45. /*
  46.  * Number of clock ticks per second. A clock tick is the unit by which
  47.  * processor time is measured and is returned by 'clock'.
  48.  */
  49. #define    CLOCKS_PER_SEC    ((clock_t)1000)
  50. #define    CLK_TCK        CLOCKS_PER_SEC
  51.  
  52.  
  53. #ifndef RC_INVOKED
  54.  
  55. /*
  56.  * A type for storing the current time and date. This is the number of
  57.  * seconds since midnight Jan 1, 1970.
  58.  * NOTE: Normally this is defined by the above include of sys/types.h
  59.  */
  60. #ifndef _TIME_T_DEFINED
  61. typedef    long    time_t;
  62. #define _TIME_T_DEFINED
  63. #endif
  64.  
  65. /*
  66.  * A type for measuring processor time (in clock ticks).
  67.  */
  68. #ifndef _CLOCK_T_DEFINED
  69. typedef    long    clock_t;
  70. #define _CLOCK_T_DEFINED
  71. #endif
  72.  
  73.  
  74. /*
  75.  * A structure for storing all kinds of useful information about the
  76.  * current (or another) time.
  77.  */
  78. struct tm
  79. {
  80.     int    tm_sec;        /* Seconds: 0-59 (K&R says 0-61?) */
  81.     int    tm_min;        /* Minutes: 0-59 */
  82.     int    tm_hour;    /* Hours since midnight: 0-23 */
  83.     int    tm_mday;    /* Day of the month: 1-31 */
  84.     int    tm_mon;        /* Months *since* january: 0-11 */
  85.     int    tm_year;    /* Years since 1900 */
  86.     int    tm_wday;    /* Days since Sunday (0-6) */
  87.     int    tm_yday;    /* Days since Jan. 1: 0-365 */
  88.     int    tm_isdst;    /* +1 Daylight Savings Time, 0 No DST,
  89.                  * -1 don't know */
  90. };
  91.  
  92. #ifdef    __cplusplus
  93. extern "C" {
  94. #endif
  95.  
  96. clock_t    clock (void);
  97. time_t    time (time_t*);
  98. double    difftime (time_t, time_t);
  99. time_t    mktime (struct tm*);
  100.  
  101. /*
  102.  * These functions write to and return pointers to static buffers that may
  103.  * be overwritten by other function calls. Yikes!
  104.  *
  105.  * NOTE: localtime, and perhaps the others of the four functions grouped
  106.  * below may return NULL if their argument is not 'acceptable'. Also note
  107.  * that calling asctime with a NULL pointer will produce an Invalid Page
  108.  * Fault and crap out your program. Guess how I know. Hint: stat called on
  109.  * a directory gives 'invalid' times in st_atime etc...
  110.  */
  111. char*        asctime (const struct tm*);
  112. char*        ctime (const time_t*);
  113. struct tm*    gmtime (const time_t*);
  114. struct tm*    localtime (const time_t*);
  115.  
  116.  
  117. size_t    strftime (char*, size_t, const char*, const struct tm*);
  118.  
  119. size_t    wcsftime (wchar_t*, size_t, const wchar_t*, const struct tm*);
  120.  
  121. #ifndef __STRICT_ANSI__
  122. extern void    _tzset (void);
  123.  
  124. #ifndef _NO_OLDNAMES
  125. extern void    tzset (void);
  126. #endif
  127.  
  128. size_t    strftime(char*, size_t, const char*, const struct tm*);
  129. char*    _strdate(char*);
  130. char*    _strtime(char*);
  131.  
  132. #endif    /* Not __STRICT_ANSI__ */
  133.  
  134. /*
  135.  * _daylight: non zero if daylight savings time is used.
  136.  * _timezone: difference in seconds between GMT and local time.
  137.  * _tzname: standard/daylight savings time zone names (an array with two
  138.  *          elements).
  139.  */
  140. #ifdef __MSVCRT__
  141.  
  142. /* These are for compatibility with pre-VC 5.0 suppied MSVCRT. */
  143. extern int*    __p__daylight (void);
  144. extern long*    __p__timezone (void);
  145. extern char**    __p__tzname (void);
  146.  
  147. __MINGW_IMPORT int    _daylight;
  148. __MINGW_IMPORT long    _timezone;
  149. __MINGW_IMPORT char     *_tzname[2];
  150.  
  151. #else /* not __MSVCRT (ie. crtdll) */
  152.  
  153. #ifndef __DECLSPEC_SUPPORTED
  154.  
  155. extern int*    _imp___daylight_dll;
  156. extern long*    _imp___timezone_dll;
  157. extern char**    _imp___tzname;
  158.  
  159. #define _daylight    (*_imp___daylight_dll)
  160. #define _timezone    (*_imp___timezone_dll)
  161. #define _tzname        (*_imp___tzname)
  162.  
  163. #else /* __DECLSPEC_SUPPORTED */
  164.  
  165. __MINGW_IMPORT int    _daylight_dll;
  166. __MINGW_IMPORT long    _timezone_dll;
  167. __MINGW_IMPORT char*    _tzname[2];
  168.  
  169. #define _daylight    _daylight_dll
  170. #define _timezone    _timezone_dll
  171.  
  172. #endif /* __DECLSPEC_SUPPORTED */
  173.  
  174. #endif /* not __MSVCRT__ */
  175.  
  176. #ifndef _NO_OLDNAMES
  177.  
  178. #ifdef __MSVCRT__
  179.  
  180. /* These go in the oldnames import library for MSVCRT. */
  181. __MINGW_IMPORT int    daylight;
  182. __MINGW_IMPORT long    timezone;
  183. __MINGW_IMPORT char     *tzname[2];
  184.  
  185. #ifndef _WTIME_DEFINED
  186.  
  187. /* wide function prototypes, also declared in wchar.h */
  188.  
  189. wchar_t *    _wasctime(const struct tm*);
  190. wchar_t *    _wctime(const time_t*);
  191. wchar_t*    _wstrdate(wchar_t*);
  192. wchar_t*    _wstrtime(wchar_t*);
  193.  
  194. #define _WTIME_DEFINED
  195. #endif /* _WTIME_DEFINED */ 
  196.  
  197.  
  198. #else /* not __MSVCRT__ */
  199.  
  200. /* CRTDLL is royally messed up when it comes to these macros.
  201.    TODO: import and alias these via oldnames import library instead 
  202.    of macros.  */
  203.  
  204. #define daylight        _daylight
  205. /* NOTE: timezone not defined because it would conflict with sys/timeb.h.
  206.    Also, tzname used to a be macro, but now it's in moldname. */
  207. __MINGW_IMPORT char     *tzname[2];
  208.  
  209. #endif /* not __MSVCRT__ */
  210.  
  211. #endif    /* Not _NO_OLDNAMES */
  212.  
  213. #ifdef    __cplusplus
  214. }
  215. #endif
  216.  
  217. #endif    /* Not RC_INVOKED */
  218.  
  219. #endif    /* Not _TIME_H_ */
  220.  
  221.