source: trunk/kitgen/8.x/blt/win/bltWinUtil.c

Last change on this file was 175, checked in by demin, 12 years ago

initial commit

File size: 1.9 KB
Line 
1/*
2 * bltWinUtil.c --
3 *
4 * This module contains WIN32 routines not included in the Tcl/Tk
5 * libraries.
6 *
7 * Copyright 1998 by Bell Labs Innovations for Lucent Technologies.
8 *
9 * Permission to use, copy, modify, and distribute this software and its
10 * documentation for any purpose and without fee is hereby granted, provided
11 * that the above copyright notice appear in all copies and that both that the
12 * copyright notice and warranty disclaimer appear in supporting documentation,
13 * and that the names of Lucent Technologies any of their entities not be used
14 * in advertising or publicity pertaining to distribution of the software
15 * without specific, written prior permission.
16 *
17 * Lucent Technologies disclaims all warranties with regard to this software,
18 * including all implied warranties of merchantability and fitness. In no event
19 * shall Lucent Technologies be liable for any special, indirect or
20 * consequential damages or any damages whatsoever resulting from loss of use,
21 * data or profits, whether in an action of contract, negligence or other
22 * tortuous action, arising out of or in connection with the use or performance
23 * of this software.
24 *
25 */
26
27#include <stdlib.h>
28
29#include "bltInt.h"
30
31double
32drand48(void)
33{
34 return (double) rand() / (double)RAND_MAX;
35}
36
37void
38srand48(long int seed)
39{
40 srand(seed);
41}
42
43int
44Blt_GetPlatformId(void)
45{
46 static int platformId = 0;
47
48 if (platformId == 0) {
49 OSVERSIONINFO opsysInfo;
50
51 opsysInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
52 if (GetVersionEx(&opsysInfo)) {
53 platformId = opsysInfo.dwPlatformId;
54 }
55 }
56 return platformId;
57}
58
59char *
60Blt_LastError(void)
61{
62 static char buffer[1024];
63 int length;
64
65 FormatMessage(
66 FORMAT_MESSAGE_FROM_SYSTEM,
67 NULL,
68 GetLastError(),
69 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), /* Default language */
70 buffer,
71 1024,
72 NULL);
73 length = strlen(buffer);
74 if (buffer[length - 2] == '\r') {
75 buffer[length - 2] = '\0';
76 }
77 return buffer;
78}
79
Note: See TracBrowser for help on using the repository browser.