1 // Copyright (c) 1991-1999 Matra Datavision
2 // Copyright (c) 1999-2012 OPEN CASCADE SAS
4 // The content of this file is subject to the Open CASCADE Technology Public
5 // License Version 6.5 (the "License"). You may not use the content of this file
6 // except in compliance with the License. Please obtain a copy of the License
7 // at http://www.opencascade.org and read it completely before using this file.
9 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
10 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
12 // The Original Code and all software distributed under the License is
13 // distributed on an "AS IS" basis, without warranty of any kind, and the
14 // Initial Developer hereby disclaims all such warranties, including without
15 // limitation, any warranties of merchantability, fitness for a particular
16 // purpose or non-infringement. Please see the License for the specific terms
17 // and conditions governing the rights and limitations under the License.
20 #if defined (__osf__ ) || defined ( DECOSF1 )
21 int DECOSF1_a_horreur_du_vide_a_la_compilation;
23 #if defined ( __hpux ) || defined ( HPUX )
24 int HPUX_a_horreur_du_vide_a_la_compilation;
35 #include <InterfaceGraphic_wntio.hxx>
44 static DWORD tlsIndex;
50 Init_ () { tlsIndex = TlsAlloc (); }
56 int cPrintf ( char* fmt, ... ) {
58 static BOOL first = TRUE;
59 static HANDLE hConsole = NULL;
67 hConsole = GetStdHandle ( STD_OUTPUT_HANDLE );
68 if ( hConsole == NULL ) {
70 hConsole = GetStdHandle ( STD_OUTPUT_HANDLE );
77 va_start( argptr, fmt );
78 cnt = vsprintf ( buffer, fmt, argptr );
80 WriteConsole ( hConsole, buffer, strlen ( buffer ), &lpcchWritten, NULL );
85 int fcPrintf ( int /*dummy*/, char* fmt, ... ) {
87 static BOOL first = TRUE;
88 static HANDLE hConsole = NULL;
96 hConsole = GetStdHandle ( STD_OUTPUT_HANDLE );
97 if ( hConsole == NULL ) {
99 hConsole = GetStdHandle ( STD_OUTPUT_HANDLE );
105 va_start( argptr, fmt );
106 cnt = vsprintf ( buffer, fmt, argptr );
108 WriteConsole ( hConsole, buffer, strlen ( buffer ), &lpcchWritten, NULL );
114 char* GetEnv ( char* name ) {
117 PENV env = ( PENV )TlsGetValue ( tlsIndex );
120 env = ( PENV )HeapAlloc (
121 GetProcessHeap (), HEAP_GENERATE_EXCEPTIONS | HEAP_ZERO_MEMORY,
122 ( DWORD )sizeof ( ENV )
124 TlsSetValue ( tlsIndex, ( LPVOID )env );
127 SetLastError ( ERROR_SUCCESS );
128 dwLen = GetEnvironmentVariable ( name, NULL, 0 );
130 if ( dwLen == 0 && GetLastError () != ERROR_SUCCESS ) return NULL;
134 if ( env -> len < dwLen ) {
135 if ( env -> ptr != NULL )
136 env -> ptr = ( char* )HeapReAlloc (
137 GetProcessHeap (), HEAP_GENERATE_EXCEPTIONS | HEAP_ZERO_MEMORY,
141 env -> ptr = ( char* )HeapAlloc (
142 GetProcessHeap (), HEAP_GENERATE_EXCEPTIONS | HEAP_ZERO_MEMORY,
148 GetEnvironmentVariable ( name, env -> ptr, dwLen );