Fixed some issues found by winapi_check.
[wine] / dlls / kernel / time.c
1 /*
2  * Win32 kernel functions
3  *
4  * Copyright 1995 Martin von Loewis and Cameron Heide
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  */
20
21 #include <string.h>
22 #include <unistd.h>
23 #include <stdlib.h>
24 #include <sys/time.h>
25 #include <sys/times.h>
26 #include "file.h"
27 #include "ntddk.h"
28 #include "winerror.h"
29 #include "winnls.h"
30 #include "wine/unicode.h"
31 #include "wine/debug.h"
32
33 WINE_DEFAULT_DEBUG_CHANNEL(win32);
34
35 /* maximum time adjustment in seconds for SetLocalTime and SetSystemTime */
36 #define SETTIME_MAX_ADJUST 120
37
38
39 /* This structure is used to store strings that represent all of the time zones
40    in the world. (This is used to help GetTimeZoneInformation)
41 */
42 struct tagTZ_INFO
43 {
44     const char *psTZFromUnix;
45     WCHAR psTZWindows[32];
46     int bias;
47     int dst;
48 };
49
50 static const struct tagTZ_INFO TZ_INFO[] =
51 {
52    {"MHT", 
53     {'D','a','t','e','l','i','n','e',' ','S','t','a','n','d','a','r','d',' ','T','i','m','e','\0'},
54     -720, 0},
55    {"SST", 
56     {'S','a','m','o','a',' ','S','t','a','n','d','a','r','d',' ','T','i','m','e','\0'},
57     660, 0},
58    {"HST",
59     {'H','a','w','a','i','i','a','n',' ','S','t','a','n','d','a','r','d',' ','T','i','m','e','\0'},
60     600, 0},
61    {"AKDT", 
62     {'A','l','a','s','k','a','n',' ','S','t','a','n','d','a','r','d',' ','T','i','m','e','\0'},
63     480, 1},
64    {"PDT", 
65     {'P','a','c','i','f','i','c',' ','S','t','a','n','d','a','r','d',' ','T','i','m','e','\0'},
66     420, 1},
67    {"MST",
68     {'U','S',' ','M','o','u','n','t','a','i','n',' ','S','t','a','n','d','a','r','d',' ','T','i','m','e','\0'},
69     420, 0},
70    {"MDT",
71     {'M','o','u','n','t','a','i','n',' ','S','t','a','n','d','a','r','d',' ','T','i','m','e','\0'},
72     360, 1},
73    {"CST",
74     {'C','e','n','t','r','a','l',' ','A','m','e','r','i','c','a',' ','S','t','a','n','d','a','r','d',' ','T','i','m','e','\0'},
75     360, 0},
76    {"CDT",
77     {'C','e','n','t','r','a','l',' ','S','t','a','n','d','a','r','d',' ','T','i','m','e','\0'},
78     300, 1},
79    {"COT",
80     {'S','A',' ','P','a','c','i','f','i','c',' ','S','t','a','n','d','a','r','d',' ','T','i','m','e','\0'},
81     300, 0},
82    {"EDT",
83     {'E','a','s','t','e','r','n',' ','S','t','a','n','d','a','r','d',' ','T','i','m','e','\0'},
84      240, 1},
85    {"EST",
86     {'U','S',' ','E','a','s','t','e','r','n',' ','S','t','a','n','d','a','r','d',' ','T','i','m','e','\0'},
87     300, 0},
88    {"ADT",
89     {'A','t','l','a','n','t','i','c',' ','S','t','a','n','d','a','r','d',' ','T','i','m','e','\0'},
90     180, 1},
91    {"VET",
92     {'S','A',' ','W','e','s','t','e','r','n',' ','S','t','a','n','d','a','r','d',' ','T','i','m','e','\0'},
93      240, 0},
94    {"CLT",
95     {'P','a','c','i','f','i','c',' ','S','A',' ','S','t','a','n','d','a','r','d',' ','T','i','m','e','\0'},
96      240, 0},
97    {"NDT",
98     {'N','e','w','f','o','u','n','d','l','a','n','d',' ','S','t','a','n','d','a','r','d',' ','T','i','m','e','\0'},
99     150, 1},
100    {"BRT",
101     {'E','.',' ','S','o','u','t','h',' ','A','m','e','r','i','c','a',' ','S','t','a','n','d','a','r','d',' ','T','i','m','e','\0'},
102     180, 0},
103    {"ART",
104     {'S','A',' ','E','a','s','t','e','r','n',' ','S','t','a','n','d','a','r','d',' ','T','i','m','e','\0'},
105     180, 0},
106    {"WGST",
107     {'G','r','e','e','n','l','a','n','d',' ','S','t','a','n','d','a','r','d',' ','T','i','m','e','\0'},
108     120, 1},
109    {"GST",
110     {'M','i','d','-','A','t','l','a','n','t','i','c',' ','S','t','a','n','d','a','r','d',' ','T','i','m','e','\0'},
111     120, 0},
112    {"AZOST",
113     {'A','z','o','r','e','s',' ','S','t','a','n','d','a','r','d',' ','T','i','m','e','\0'},
114     0, 1},
115    {"CVT",
116     {'C','a','p','e',' ','V','e','r','d','e',' ','S','t','a','n','d','a','r','d',' ','T','i','m','e','\0'},
117     60, 0},
118    {"WET",
119     {'G','r','e','e','n','w','i','c','h',' ','S','t','a','n','d','a','r','d',' ','T','i','m','e','\0'},
120     0, 0},
121    {"BST",
122     {'G','M','T',' ','S','t','a','n','d','a','r','d',' ','T','i','m','e','\0'},
123     -60, 1},
124    {"GMT",
125     {'G','M','T',' ','S','t','a','n','d','a','r','d',' ','T','i','m','e','\0'},
126     0, 0},
127    {"CEST",
128     {'C','e','n','t','r','a','l',' ','E','u','r','o','p','e',' ','S','t','a','n','d','a','r','d',' ','T','i','m','e','\0'},
129     -120, 1},
130    {"WAT",
131     {'W','.',' ','C','e','n','t','r','a','l',' ','A','f','r','i','c','a',' ','S','t','a','n','d','a','r','d',' ','T','i','m','e','\0'},
132     -60, 0},
133    {"EEST",
134     {'E','.',' ','E','u','r','o','p','e',' ','S','t','a','n','d','a','r','d',' ','T','i','m','e','\0'},
135     -180, 1},
136    {"EET",
137     {'E','g','y','p','t',' ','S','t','a','n','d','a','r','d',' ','T','i','m','e','\0'},
138     -120, 0},
139    {"CAT",
140     {'S','o','u','t','h',' ','A','f','r','i','c','a',' ','S','t','a','n','d','a','r','d',' ','T','i','m','e','\0'},
141     -120, 0},
142    {"IST",
143     {'I','s','r','a','e','l',' ','S','t','a','n','d','a','r','d',' ','T','i','m','e','\0'},
144     -120, 0},
145    {"ADT",
146     {'A','r','a','b','i','c',' ','S','t','a','n','d','a','r','d',' ','T','i','m','e','\0'},
147     -240, 1},
148    {"AST",
149     {'A','r','a','b',' ','S','t','a','n','d','a','r','d',' ','T','i','m','e','\0'},
150     -180, 0},
151    {"MSD",
152     {'R','u','s','s','i','a','n',' ','S','t','a','n','d','a','r','d',' ','T','i','m','e','\0'},
153     -240, 1},
154    {"EAT",
155     {'E','.',' ','A','f','r','i','c','a',' ','S','t','a','n','d','a','r','d',' ','T','i','m','e','\0'},
156     -180, 0},
157    {"IRST",
158     {'I','r','a','n',' ','S','t','a','n','d','a','r','d',' ','T','i','m','e','\0'},
159     -270, 1},
160    {"GST",
161     {'A','r','a','b','i','a','n',' ','S','t','a','n','d','a','r','d',' ','T','i','m','e','\0'},
162     -240, 0},
163    {"AZST",
164     {'C','a','u','c','a','s','u','s',' ','S','t','a','n','d','a','r','d',' ','T','i','m','e','\0'},
165     -300, 1},
166    {"AFT",
167     {'A','f','g','h','a','n','i','s','t','a','n',' ','S','t','a','n','d','a','r','d',' ','T','i','m','e','\0'},
168     -270, 0},
169    {"YEKST",
170     {'E','k','a','t','e','r','i','n','b','u','r','g',' ','S','t','a','n','d','a','r','d',' ','T','i','m','e','\0'},
171     -360, 1},
172    {"PKT",
173     {'W','e','s','t',' ','A','s','i','a',' ','S','t','a','n','d','a','r','d',' ','T','i','m','e','\0'},
174     -300, 0},
175    {"IST",
176     {'I','n','d','i','a',' ','S','t','a','n','d','a','r','d',' ','T','i','m','e','\0'},
177     -330, 0},
178    {"NPT",
179     {'N','e','p','a','l',' ','S','t','a','n','d','a','r','d',' ','T','i','m','e','\0'},
180     -345, 0},
181    {"ALMST",
182     {'N','.',' ','C','e','n','t','r','a','l',' ','A','s','i','a',' ','S','t','a','n','d','a','r','d',' ','T','i','m','e','\0'},
183     -420, 1},
184    {"BDT",
185     {'C','e','n','t','r','a','l',' ','A','s','i','a',' ','S','t','a','n','d','a','r','d',' ','T','i','m','e','\0'},
186     -360, 0},
187    {"LKT",
188     {'S','r','i',' ','L','a','n','k','a',' ','S','t','a','n','d','a','r','d',' ','T','i','m','e','\0'},
189     -360, 0},
190    {"MMT",
191     {'M','y','a','n','m','a','r',' ','S','t','a','n','d','a','r','d',' ','T','i','m','e','\0'},
192     -390, 0},
193    {"ICT",
194     {'S','E',' ','A','s','i','a',' ','S','t','a','n','d','a','r','d',' ','T','i','m','e','\0'},
195     -420, 0},
196    {"KRAST",
197     {'N','o','r','t','h',' ','A','s','i','a',' ','S','t','a','n','d','a','r','d',' ','T','i','m','e','\0'},
198     -480, 1},
199    {"CST",
200     {'C','h','i','n','a',' ','S','t','a','n','d','a','r','d',' ','T','i','m','e','\0'},
201     -480, 0},
202    {"IRKST",
203     {'N','o','r','t','h',' ','A','s','i','a',' ','E','a','s','t',' ','S','t','a','n','d','a','r','d',' ','T','i','m','e','\0'},
204     -540, 1},
205    {"SGT",
206     {'M','a','l','a','y',' ','P','e','n','i','n','s','u','l','a',' ','S','t','a','n','d','a','r','d',' ','T','i','m','e','\0'},
207     -480, 0},
208    {"WST",
209     {'W','.',' ','A','u','s','t','r','a','l','i','a',' ','S','t','a','n','d','a','r','d',' ','T','i','m','e','\0'},
210     -480, 0},
211    {"JST",
212     {'T','o','k','y','o',' ','S','t','a','n','d','a','r','d',' ','T','i','m','e','\0'},
213     -540, 0},
214    {"KST",
215     {'K','o','r','e','a',' ','S','t','a','n','d','a','r','d',' ','T','i','m','e','\0'},
216     -540, 0},
217    {"YAKST",
218     {'Y','a','k','u','t','s','k',' ','S','t','a','n','d','a','r','d',' ','T','i','m','e','\0'},
219     -600, 1},
220    {"CST",
221     {'C','e','n','.',' ','A','u','s','t','r','a','l','i','a',' ','S','t','a','n','d','a','r','d',' ','T','i','m','e','\0'},
222     -570, 0},
223    {"EST",
224     {'E','.',' ','A','u','s','t','r','a','l','i','a',' ','S','t','a','n','d','a','r','d',' ','T','i','m','e','\0'},
225     -600, 0},
226    {"GST",
227     {'W','e','s','t',' ','P','a','c','i','f','i','c',' ','S','t','a','n','d','a','r','d',' ','T','i','m','e','\0'},
228     -600, 0},
229    {"VLAST",
230     {'V','l','a','d','i','v','o','s','t','o','k',' ','S','t','a','n','d','a','r','d',' ','T','i','m','e','\0'},
231     -660, 1},
232    {"MAGST",
233     {'C','e','n','t','r','a','l',' ','P','a','c','i','f','i','c',' ','S','t','a','n','d','a','r','d',' ','T','i','m','e','\0'},
234     -720, 1},
235    {"NZST",
236     {'N','e','w',' ','Z','e','a','l','a','n','d',' ','S','t','a','n','d','a','r','d',' ','T','i','m','e','\0'},
237     -720, 0},
238    {"FJT",
239     {'F','i','j','i',' ','S','t','a','n','d','a','r','d',' ','T','i','m','e','\0'},
240     -720, 0},
241    {"TOT",
242     {'T','o','n','g','a',' ','S','t','a','n','d','a','r','d',' ','T','i','m','e','\0'},
243     -780, 0}
244 };
245
246 /* TIME_GetTZAsStr: helper function that returns the given timezone as a string.
247    This could be done with a hash table instead of merely iterating through
248    a table, however with the small amount of entries (60 or so) I didn't think
249    it was worth it. */
250 static const WCHAR* TIME_GetTZAsStr (time_t utc, int bias, int dst)
251 {
252    char psTZName[7];
253    struct tm *ptm = localtime(&utc);
254    int i;
255
256    if (!strftime (psTZName, 7, "%Z", ptm))
257       return (NULL);
258
259    for (i=0; i<(sizeof(TZ_INFO) / sizeof(struct tagTZ_INFO)); i++) 
260    {
261       if ( strcmp(TZ_INFO[i].psTZFromUnix, psTZName) == 0 &&
262            TZ_INFO[i].bias == bias &&
263            TZ_INFO[i].dst == dst
264          )
265             return TZ_INFO[i].psTZWindows;
266    }
267
268    return (NULL);
269 }
270
271
272 /* TIME_GetBias: helper function calculates delta local time from UTC */
273 static int TIME_GetBias( time_t utc, int *pdaylight)
274 {
275     struct tm *ptm = localtime(&utc);
276     *pdaylight = ptm->tm_isdst; /* daylight for local timezone */
277     ptm = gmtime(&utc);
278     ptm->tm_isdst = *pdaylight; /* use local daylight, not that of Greenwich */
279     return (int)(utc-mktime(ptm));
280 }
281
282
283 /***********************************************************************
284  *              SetLocalTime            (KERNEL32.@)
285  *
286  *  Sets the local time using current time zone and daylight
287  *  savings settings.
288  *
289  * RETURNS
290  *
291  *  True if the time was set, false if the time was invalid or the
292  *  necessary permissions were not held.
293  */
294 BOOL WINAPI SetLocalTime(
295     const SYSTEMTIME *systime) /* [in] The desired local time. */
296 {
297     struct timeval tv;
298     struct tm t;
299     time_t sec;
300     time_t oldsec=time(NULL);
301     int err;
302
303     /* get the number of seconds */
304     t.tm_sec = systime->wSecond;
305     t.tm_min = systime->wMinute;
306     t.tm_hour = systime->wHour;
307     t.tm_mday = systime->wDay;
308     t.tm_mon = systime->wMonth - 1;
309     t.tm_year = systime->wYear - 1900;
310     t.tm_isdst = -1;
311     sec = mktime (&t);
312
313     /* set the new time */
314     tv.tv_sec = sec;
315     tv.tv_usec = systime->wMilliseconds * 1000;
316
317     /* error and sanity check*/
318     if( sec == (time_t)-1 || abs((int)(sec-oldsec)) > SETTIME_MAX_ADJUST ){
319         err = 1;
320         SetLastError(ERROR_INVALID_PARAMETER);
321     } else {
322         err=settimeofday(&tv, NULL); /* 0 is OK, -1 is error */
323         if(err == 0)
324             return TRUE;
325         SetLastError(ERROR_PRIVILEGE_NOT_HELD);
326     }
327     ERR("Cannot set time to %d/%d/%d %d:%d:%d Time adjustment %ld %s\n",
328             systime->wYear, systime->wMonth, systime->wDay, systime->wHour,
329             systime->wMinute, systime->wSecond,
330             sec-oldsec, err == -1 ? "No Permission" : 
331                 sec==(time_t)-1 ? "" : "is too large." );
332     return FALSE;
333 }
334
335
336 /***********************************************************************
337  *           GetSystemTimeAdjustment     (KERNEL32.@)
338  *
339  *  Indicates the period between clock interrupt and the amount the clock
340  *  is adjusted each interrupt so as to keep it insync with an external source.
341  *
342  * RETURNS
343  *
344  *  Always returns true.
345  *
346  * BUGS
347  *
348  *  Only the special case of disabled time adjustments is supported.
349  *  (also the signature is wrong it should have a return type of BOOL)
350  */
351 DWORD WINAPI GetSystemTimeAdjustment(
352     LPDWORD lpTimeAdjustment,         /* [out] The clock adjustment per interupt in 100's of nanoseconds. */
353     LPDWORD lpTimeIncrement,          /* [out] The time between clock interupts in 100's of nanoseconds. */
354     LPBOOL  lpTimeAdjustmentDisabled) /* [out] The clock synchonisation has been disabled. */
355 {
356     *lpTimeAdjustment = 0;
357     *lpTimeIncrement = 0;
358     *lpTimeAdjustmentDisabled = TRUE;
359     return TRUE;
360 }
361
362
363 /***********************************************************************
364  *              SetSystemTime            (KERNEL32.@)
365  *
366  *  Sets the system time (utc).
367  *
368  * RETURNS
369  *
370  *  True if the time was set, false if the time was invalid or the
371  *  necessary permissions were not held.
372  */
373 BOOL WINAPI SetSystemTime(
374     const SYSTEMTIME *systime) /* [in] The desired system time. */
375 {
376     struct timeval tv;
377     struct timezone tz;
378     struct tm t;
379     time_t sec, oldsec;
380     int dst, bias;
381     int err;
382
383     /* call gettimeofday to get the current timezone */
384     gettimeofday(&tv, &tz);
385     oldsec=tv.tv_sec;
386     /* get delta local time from utc */
387     bias=TIME_GetBias(oldsec,&dst);
388
389     /* get the number of seconds */
390     t.tm_sec = systime->wSecond;
391     t.tm_min = systime->wMinute;
392     t.tm_hour = systime->wHour;
393     t.tm_mday = systime->wDay;
394     t.tm_mon = systime->wMonth - 1;
395     t.tm_year = systime->wYear - 1900;
396     t.tm_isdst = dst;
397     sec = mktime (&t);
398     /* correct for timezone and daylight */
399     sec += bias;
400
401     /* set the new time */
402     tv.tv_sec = sec;
403     tv.tv_usec = systime->wMilliseconds * 1000;
404
405     /* error and sanity check*/
406     if( sec == (time_t)-1 || abs((int)(sec-oldsec)) > SETTIME_MAX_ADJUST ){
407         err = 1;
408         SetLastError(ERROR_INVALID_PARAMETER);
409     } else {
410         err=settimeofday(&tv, NULL); /* 0 is OK, -1 is error */
411         if(err == 0)
412             return TRUE;
413         SetLastError(ERROR_PRIVILEGE_NOT_HELD);
414     }
415     ERR("Cannot set time to %d/%d/%d %d:%d:%d Time adjustment %ld %s\n",
416             systime->wYear, systime->wMonth, systime->wDay, systime->wHour,
417             systime->wMinute, systime->wSecond,
418             sec-oldsec, err == -1 ? "No Permission" :
419                 sec==(time_t)-1 ? "" : "is too large." );
420     return FALSE;
421 }
422
423
424 /***********************************************************************
425  *              GetTimeZoneInformation  (KERNEL32.@)
426  *
427  *  Fills in the a time zone information structure with values based on
428  *  the current local time.
429  *
430  * RETURNS
431  *
432  *  The daylight savings time standard or TIME_ZONE_ID_INVALID if the call failed.
433  */
434 DWORD WINAPI GetTimeZoneInformation(
435     LPTIME_ZONE_INFORMATION tzinfo) /* [out] The time zone structure to be filled in. */
436 {
437     time_t gmt;
438     int bias, daylight;
439     const WCHAR *psTZ;
440
441
442     memset(tzinfo, 0, sizeof(TIME_ZONE_INFORMATION));
443
444     gmt = time(NULL);
445     bias=TIME_GetBias(gmt,&daylight);
446
447     tzinfo->Bias = -bias / 60;
448     tzinfo->StandardBias = 0;
449     tzinfo->DaylightBias = -60;
450     psTZ = TIME_GetTZAsStr (gmt, (-bias/60), daylight);
451     if (psTZ) strcpyW( tzinfo->StandardName, psTZ );
452     return TIME_ZONE_ID_STANDARD;
453 }
454
455
456 /***********************************************************************
457  *              SetTimeZoneInformation  (KERNEL32.@)
458  *
459  *  Set the local time zone with values based on the time zone structure.
460  *
461  * RETURNS
462  *
463  *  True on successful setting of the time zone.
464  *
465  * BUGS
466  *
467  *  Use the obsolete unix timezone structure and tz_dsttime member.
468  */
469 BOOL WINAPI SetTimeZoneInformation(
470     const LPTIME_ZONE_INFORMATION tzinfo) /* [in] The new time zone. */
471 {
472     struct timezone tz;
473
474     tz.tz_minuteswest = tzinfo->Bias;
475 #ifdef DST_NONE
476     tz.tz_dsttime = DST_NONE;
477 #else
478     tz.tz_dsttime = 0;
479 #endif
480     return !settimeofday(NULL, &tz);
481 }
482
483
484 /***********************************************************************
485  *              SystemTimeToTzSpecificLocalTime  (KERNEL32.@)
486  *
487  *  Converts the system time (utc) to the local time in the specified time zone.
488  *
489  * RETURNS
490  *
491  *  Returns true when the local time was calculated.
492  *
493  * BUGS
494  *
495  *  Does not handle daylight savings time adjustments correctly.
496  */
497 BOOL WINAPI SystemTimeToTzSpecificLocalTime(
498     LPTIME_ZONE_INFORMATION lpTimeZoneInformation, /* [in] The desired time zone. */
499     LPSYSTEMTIME            lpUniversalTime,       /* [in] The utc time to base local time on. */
500     LPSYSTEMTIME            lpLocalTime)           /* [out] The local time in the time zone. */
501 {
502   FIXME(":stub\n");
503   SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
504        return FALSE;
505 }
506
507
508 /***********************************************************************
509  *              GetSystemTimeAsFileTime  (KERNEL32.@)
510  *
511  *  Fills in a file time structure with the current time in UTC format.
512  */
513 VOID WINAPI GetSystemTimeAsFileTime(
514     LPFILETIME time) /* [out] The file time struct to be filled with the system time. */
515 {
516     NtQuerySystemTime( (LARGE_INTEGER *)time );
517 }
518
519
520 /*********************************************************************
521  *      TIME_ClockTimeToFileTime    (olorin@fandra.org, 20-Sep-1998)
522  *
523  *  Used by GetProcessTimes to convert clock_t into FILETIME.
524  *
525  *      Differences to UnixTimeToFileTime:
526  *          1) Divided by CLK_TCK
527  *          2) Time is relative. There is no 'starting date', so there is 
528  *             no need in offset correction, like in UnixTimeToFileTime
529  */
530 static void TIME_ClockTimeToFileTime(clock_t unix_time, LPFILETIME filetime)
531 {
532     LONGLONG secs = RtlEnlargedUnsignedMultiply( unix_time, 10000000 );
533     ((LARGE_INTEGER *)filetime)->QuadPart = RtlExtendedLargeIntegerDivide( secs, CLK_TCK, NULL );
534 }
535
536 /*********************************************************************
537  *      GetProcessTimes                         (KERNEL32.@)
538  *
539  *  Returns the user and kernel execution times of a process,
540  *  along with the creation and exit times if known.
541  *
542  *  olorin@fandra.org:
543  *  Would be nice to subtract the cpu time, used by Wine at startup.
544  *  Also, there is a need to separate times used by different applications.
545  *
546  * RETURNS
547  *
548  *  Always returns true.
549  *
550  * BUGS
551  *
552  *  lpCreationTime, lpExitTime are NOT INITIALIZED.
553  */
554 BOOL WINAPI GetProcessTimes(
555     HANDLE     hprocess,       /* [in] The process to be queried (obtained from PROCESS_QUERY_INFORMATION). */
556     LPFILETIME lpCreationTime, /* [out] The creation time of the process. */
557     LPFILETIME lpExitTime,     /* [out] The exit time of the process if exited. */
558     LPFILETIME lpKernelTime,   /* [out] The time spent in kernal routines in 100's of nanoseconds. */
559     LPFILETIME lpUserTime)     /* [out] The time spent in user routines in 100's of nanoseconds. */
560 {
561     struct tms tms;
562
563     times(&tms);
564     TIME_ClockTimeToFileTime(tms.tms_utime,lpUserTime);
565     TIME_ClockTimeToFileTime(tms.tms_stime,lpKernelTime);
566     return TRUE;
567 }
568
569 /*********************************************************************
570  *      GetCalendarInfoA                                (KERNEL32.@)
571  *
572  */
573 int WINAPI GetCalendarInfoA(LCID Locale, CALID Calendar, CALTYPE CalType,
574                             LPSTR lpCalData, int cchData, LPDWORD lpValue)
575 {
576     FIXME("(%08lx,%08lx,%08lx,%p,%d,%p): stub\n", 
577           Locale, Calendar, CalType, lpCalData, cchData, lpValue);
578     /* dont have the #define values for those */
579
580     FIXME("\t");
581     /*
582     if (CalType & CAL_NOUSEROVERRIDE)
583         MESSAGE("CAL_NOUSEROVERRIDE|");
584     if (CalType & CAL_RETURN_NUMBER)
585         MESSAGE("CAL_RETURN_NUMBER|");
586     if (CalType & CAL_USE_CP_ACP)
587         MESSAGE("CAL_USE_CP_ACP|");
588     */
589
590     /*switch (CalType & ~(CAL_NOUSEROVERRIDE|CAL_RETURN_NUMBER|CAL_USE_CP_ACP)) {*/
591     switch (CalType & 0xffff) {
592 #define X(x) case x: MESSAGE(#x"\n");break;
593         X(CAL_ICALINTVALUE)
594         X(CAL_SCALNAME)
595         X(CAL_IYEAROFFSETRANGE)
596         X(CAL_SERASTRING)
597         X(CAL_SSHORTDATE)
598         X(CAL_SLONGDATE)
599         X(CAL_SDAYNAME1)
600         X(CAL_SDAYNAME2)
601         X(CAL_SDAYNAME3)
602         X(CAL_SDAYNAME4)
603         X(CAL_SDAYNAME5)
604         X(CAL_SDAYNAME6)
605         X(CAL_SDAYNAME7)
606         X(CAL_SABBREVDAYNAME1)
607         X(CAL_SABBREVDAYNAME2)
608         X(CAL_SABBREVDAYNAME3)
609         X(CAL_SABBREVDAYNAME4)
610         X(CAL_SABBREVDAYNAME5)
611         X(CAL_SABBREVDAYNAME6)
612         X(CAL_SABBREVDAYNAME7)
613         X(CAL_SMONTHNAME1)
614         X(CAL_SMONTHNAME2)
615         X(CAL_SMONTHNAME3)
616         X(CAL_SMONTHNAME4)
617         X(CAL_SMONTHNAME5)
618         X(CAL_SMONTHNAME6)
619         X(CAL_SMONTHNAME7)
620         X(CAL_SMONTHNAME8)
621         X(CAL_SMONTHNAME9)
622         X(CAL_SMONTHNAME10)
623         X(CAL_SMONTHNAME11)
624         X(CAL_SMONTHNAME12)
625         X(CAL_SMONTHNAME13)
626         X(CAL_SABBREVMONTHNAME1)
627         X(CAL_SABBREVMONTHNAME2)
628         X(CAL_SABBREVMONTHNAME3)
629         X(CAL_SABBREVMONTHNAME4)
630         X(CAL_SABBREVMONTHNAME5)
631         X(CAL_SABBREVMONTHNAME6)
632         X(CAL_SABBREVMONTHNAME7)
633         X(CAL_SABBREVMONTHNAME8)
634         X(CAL_SABBREVMONTHNAME9)
635         X(CAL_SABBREVMONTHNAME10)
636         X(CAL_SABBREVMONTHNAME11)
637         X(CAL_SABBREVMONTHNAME12)
638         X(CAL_SABBREVMONTHNAME13)
639         X(CAL_SYEARMONTH)
640 #undef X
641         default: MESSAGE("Unknown caltype %ld\n",CalType & 0xffff);
642                  return E_FAIL;
643     }
644     return 0;
645 }
646
647 /*********************************************************************
648  *      GetCalendarInfoW                                (KERNEL32.@)
649  *
650  */
651 int WINAPI GetCalendarInfoW(LCID Locale, CALID Calendar, CALTYPE CalType,
652                             LPWSTR lpCalData, int cchData, LPDWORD lpValue)
653 {       
654     FIXME("(%08lx,%08lx,%08lx,%p,%d,%p): stub\n", 
655           Locale, Calendar, CalType, lpCalData, cchData, lpValue);
656     return 0;
657 }
658
659 /*********************************************************************
660  *      SetCalendarInfoA                                (KERNEL32.@)
661  *
662  */
663 int WINAPI      SetCalendarInfoA(LCID Locale, CALID Calendar, CALTYPE CalType, LPCSTR lpCalData)
664 {
665     FIXME("(%08lx,%08lx,%08lx,%s): stub\n", 
666           Locale, Calendar, CalType, debugstr_a(lpCalData));
667     return 0;
668 }
669
670 /*********************************************************************
671  *      SetCalendarInfoW                                (KERNEL32.@)
672  *
673  */
674 int WINAPI      SetCalendarInfoW(LCID Locale, CALID Calendar, CALTYPE CalType, LPCWSTR lpCalData)
675 {
676     FIXME("(%08lx,%08lx,%08lx,%s): stub\n", 
677           Locale, Calendar, CalType, debugstr_w(lpCalData));
678     return 0;
679 }
680