mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-05-06 10:36:12 +03:00
License statement text corrected; compiler warnings caused by Bison 2.41 disabled for MSVC; a few other compiler warnings on 54-bit Windows eliminated by appropriate type cast Wrong license statements corrected in several files. Copyright and license statements added in XSD and GLSL files. Copyright year updated in some files. Obsolete documentation files removed from DrawResources.
148 lines
3.4 KiB
C++
148 lines
3.4 KiB
C++
// Copyright (c) 1991-1999 Matra Datavision
|
|
// Copyright (c) 1999-2014 OPEN CASCADE SAS
|
|
//
|
|
// This file is part of Open CASCADE Technology software library.
|
|
//
|
|
// This library is free software; you can redistribute it and/or modify it under
|
|
// the terms of the GNU Lesser General Public License version 2.1 as published
|
|
// by the Free Software Foundation, with special exception defined in the file
|
|
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
|
// distribution for complete text of the license and disclaimer of any warranty.
|
|
//
|
|
// Alternatively, this file may be used under the terms of Open CASCADE
|
|
// commercial license or contractual agreement.
|
|
|
|
#if defined (__osf__ ) || defined ( DECOSF1 )
|
|
int DECOSF1_a_horreur_du_vide_a_la_compilation;
|
|
#endif
|
|
#if defined ( __hpux ) || defined ( HPUX )
|
|
int HPUX_a_horreur_du_vide_a_la_compilation;
|
|
#endif
|
|
|
|
#ifdef WNT
|
|
|
|
#define STRICT
|
|
#include <windows.h>
|
|
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
|
|
#include <InterfaceGraphic_wntio.hxx>
|
|
|
|
typedef struct _env {
|
|
|
|
DWORD len;
|
|
char* ptr;
|
|
|
|
} ENV, *PENV;
|
|
|
|
static DWORD tlsIndex;
|
|
|
|
class Init_ {
|
|
|
|
public:
|
|
|
|
Init_ () { tlsIndex = TlsAlloc (); }
|
|
|
|
}; // end Init_
|
|
|
|
static Init_ init;
|
|
|
|
int cPrintf ( char* fmt, ... ) {
|
|
|
|
static BOOL first = TRUE;
|
|
static HANDLE hConsole = NULL;
|
|
|
|
char buffer[ 256 ];
|
|
va_list argptr;
|
|
int cnt;
|
|
DWORD lpcchWritten;
|
|
|
|
if ( first ) {
|
|
hConsole = GetStdHandle ( STD_OUTPUT_HANDLE );
|
|
if ( hConsole == NULL ) {
|
|
AllocConsole ();
|
|
hConsole = GetStdHandle ( STD_OUTPUT_HANDLE );
|
|
} /* end if */
|
|
|
|
first = FALSE;
|
|
|
|
} /* end if */
|
|
|
|
va_start( argptr, fmt );
|
|
cnt = vsprintf ( buffer, fmt, argptr );
|
|
va_end ( argptr );
|
|
WriteConsole ( hConsole, buffer, (DWORD) strlen ( buffer ), &lpcchWritten, NULL );
|
|
return cnt;
|
|
|
|
} /* end cPrintf */
|
|
|
|
int fcPrintf ( int /*dummy*/, char* fmt, ... ) {
|
|
|
|
static BOOL first = TRUE;
|
|
static HANDLE hConsole = NULL;
|
|
|
|
char buffer[ 256 ];
|
|
va_list argptr;
|
|
int cnt;
|
|
DWORD lpcchWritten;
|
|
|
|
if ( first ) {
|
|
hConsole = GetStdHandle ( STD_OUTPUT_HANDLE );
|
|
if ( hConsole == NULL ) {
|
|
AllocConsole ();
|
|
hConsole = GetStdHandle ( STD_OUTPUT_HANDLE );
|
|
} /* end if */
|
|
|
|
first = FALSE;
|
|
} /* end if */
|
|
|
|
va_start( argptr, fmt );
|
|
cnt = vsprintf ( buffer, fmt, argptr );
|
|
va_end ( argptr );
|
|
WriteConsole ( hConsole, buffer, (DWORD )strlen ( buffer ), &lpcchWritten, NULL );
|
|
|
|
return cnt;
|
|
|
|
} /* end fcPrintf */
|
|
|
|
char* GetEnv ( char* name ) {
|
|
|
|
DWORD dwLen;
|
|
PENV env = ( PENV )TlsGetValue ( tlsIndex );
|
|
|
|
if ( env == NULL ) {
|
|
env = ( PENV )HeapAlloc (
|
|
GetProcessHeap (), HEAP_GENERATE_EXCEPTIONS | HEAP_ZERO_MEMORY,
|
|
( DWORD )sizeof ( ENV )
|
|
);
|
|
TlsSetValue ( tlsIndex, ( LPVOID )env );
|
|
} /* end if */
|
|
|
|
SetLastError ( ERROR_SUCCESS );
|
|
dwLen = GetEnvironmentVariable ( name, NULL, 0 );
|
|
|
|
if ( dwLen == 0 && GetLastError () != ERROR_SUCCESS ) return NULL;
|
|
|
|
++dwLen;
|
|
|
|
if ( env -> len < dwLen ) {
|
|
if ( env -> ptr != NULL )
|
|
env -> ptr = ( char* )HeapReAlloc (
|
|
GetProcessHeap (), HEAP_GENERATE_EXCEPTIONS | HEAP_ZERO_MEMORY,
|
|
env -> ptr, dwLen
|
|
);
|
|
else
|
|
env -> ptr = ( char* )HeapAlloc (
|
|
GetProcessHeap (), HEAP_GENERATE_EXCEPTIONS | HEAP_ZERO_MEMORY,
|
|
dwLen
|
|
);
|
|
env -> len = dwLen;
|
|
} /* end if */
|
|
|
|
GetEnvironmentVariable ( name, env -> ptr, dwLen );
|
|
return env -> ptr;
|
|
|
|
} /* end GetEnv */
|
|
#endif /* WNT */
|