1 // Copyright (c) 1991-1999 Matra Datavision
2 // Copyright (c) 1999-2014 OPEN CASCADE SAS
4 // This file is part of Open CASCADE Technology software library.
6 // This library is free software; you can redistribute it and/or modify it under
7 // the terms of the GNU Lesser General Public License version 2.1 as published
8 // by the Free Software Foundation, with special exception defined in the file
9 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
10 // distribution for complete text of the license and disclaimer of any warranty.
12 // Alternatively, this file may be used under the terms of Open CASCADE
13 // commercial license or contractual agreement.
15 #if defined (__osf__ ) || defined ( DECOSF1 )
16 int DECOSF1_a_horreur_du_vide_a_la_compilation;
18 #if defined ( __hpux ) || defined ( HPUX )
19 int HPUX_a_horreur_du_vide_a_la_compilation;
30 #include <InterfaceGraphic_wntio.hxx>
39 static DWORD tlsIndex;
45 Init_ () { tlsIndex = TlsAlloc (); }
51 int cPrintf ( char* fmt, ... ) {
53 static BOOL first = TRUE;
54 static HANDLE hConsole = NULL;
62 hConsole = GetStdHandle ( STD_OUTPUT_HANDLE );
63 if ( hConsole == NULL ) {
65 hConsole = GetStdHandle ( STD_OUTPUT_HANDLE );
72 va_start( argptr, fmt );
73 cnt = vsprintf ( buffer, fmt, argptr );
75 WriteConsole ( hConsole, buffer, (DWORD) strlen ( buffer ), &lpcchWritten, NULL );
80 int fcPrintf ( int /*dummy*/, char* fmt, ... ) {
82 static BOOL first = TRUE;
83 static HANDLE hConsole = NULL;
91 hConsole = GetStdHandle ( STD_OUTPUT_HANDLE );
92 if ( hConsole == NULL ) {
94 hConsole = GetStdHandle ( STD_OUTPUT_HANDLE );
100 va_start( argptr, fmt );
101 cnt = vsprintf ( buffer, fmt, argptr );
103 WriteConsole ( hConsole, buffer, (DWORD )strlen ( buffer ), &lpcchWritten, NULL );
109 char* GetEnv ( char* name ) {
112 PENV env = ( PENV )TlsGetValue ( tlsIndex );
115 env = ( PENV )HeapAlloc (
116 GetProcessHeap (), HEAP_GENERATE_EXCEPTIONS | HEAP_ZERO_MEMORY,
117 ( DWORD )sizeof ( ENV )
119 TlsSetValue ( tlsIndex, ( LPVOID )env );
122 SetLastError ( ERROR_SUCCESS );
123 dwLen = GetEnvironmentVariable ( name, NULL, 0 );
125 if ( dwLen == 0 && GetLastError () != ERROR_SUCCESS ) return NULL;
129 if ( env -> len < dwLen ) {
130 if ( env -> ptr != NULL )
131 env -> ptr = ( char* )HeapReAlloc (
132 GetProcessHeap (), HEAP_GENERATE_EXCEPTIONS | HEAP_ZERO_MEMORY,
136 env -> ptr = ( char* )HeapAlloc (
137 GetProcessHeap (), HEAP_GENERATE_EXCEPTIONS | HEAP_ZERO_MEMORY,
143 GetEnvironmentVariable ( name, env -> ptr, dwLen );