0027197: Configuration - fix compilation issues when using mingw
[occt.git] / src / Draw / Draw_Main.cxx
1 // Created on: 1999-12-30
2 // Created by: Roman LYGIN
3 // Copyright (c) 1999-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 //
6 // This file is part of Open CASCADE Technology software library.
7 //
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
13 //
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
16
17 // *******************************************************************
18 //    RLN  06 January 2000
19 // *******************************************************************
20 // This file is built from former NTMain.pxx duplicated in many executables
21 // extending DRAW Test Harness.
22 // Now is implemented only in one instance.
23
24 // Differences between CAS.CADE versions:
25 //  - in C21 Draw_Appli is defined in Draw.cxx (DRAW UL) and calls externally
26 // defined Draw_InitAppli. Moreover, on WNT Draw_Appli was not declared as 
27 // Standard_EXPORT and therefore it has to be duplicated explicitly in this
28 // code as in Draw.cxx.
29 //  - in C30 Draw_Appli accepts Draw_InitAppli as parameter which is given to
30 // it in each executable. Draw_Appli is declared as Standard_EXPORT and
31 // therefore it needs not to be duplicated.
32
33 // To have only one instance of this file and to call it from all the executables
34 // thereare defined macros in .hxx that replace main/WinMain functions and which
35 // calls _main_/_WinMain_ defined in this file with specified Draw_InitAppli.
36 // To avoid Unresolved symbols on WNT, Draw_InitAppli is explicitly defined in this
37 // is initialized by main/_WinMain_.  
38
39 // WARNING: Although versions C21 and C30 are synchronised as much as they can,
40 // there are two versions of this file for both configurations. This is explained by:
41 // - Standard_IMPOR is differently defined,
42 // - Draw_Appli is differently declared.
43
44 #ifdef _WIN32
45 #include <windows.h> /* SW_SHOW */
46 #endif
47
48 #include <Draw_Main.hxx>
49 #include <stdlib.h>
50 #include <string.h>
51 #include <Draw_Appli.hxx>
52 #include <OSD.hxx>
53
54 #include <tcl.h>
55
56 #ifdef _WIN32
57 #include <sys/stat.h>
58 #include <Draw_Window.hxx>
59
60 #include <stdio.h>
61 #include <io.h>
62 #include <fcntl.h>
63
64 extern Draw_Viewer dout;
65
66 // extern Standard_IMPORT Standard_Boolean Draw_Interprete(char* command); //for C21
67 Standard_IMPORT Standard_Boolean Draw_Interprete(const char* command); //for C30
68 // true if complete command
69
70 // necessary for WNT in C21 only
71 static FDraw_InitAppli theDraw_InitAppli; //pointer to the Draw_InitAppli
72 #endif
73
74 #ifdef _WIN32
75 //=======================================================================
76 //NOTE: OCC11
77 //     On Windows NT, both console (UNIX-like) and windowed (classical on 
78 //     WNT, with three separated windows - input, output and graphic)
79 //     modes are supported.
80 //     Depending on compilation mode of executable (CONSOLE or WINDOWS),
81 //     either _main_ or _WinMain_ becomes entry point;
82 //     the further different behaviour of DRAW is determined by variable 
83 //     Draw_IsConsoleSubsystem which is set by _main_ only
84 //=======================================================================
85
86   
87 extern Standard_Boolean Draw_IsConsoleSubsystem;
88
89 //=======================================================================
90 //function : _main_
91 //purpose  : 
92 //=======================================================================
93
94 Standard_Integer _main_ (int /*argc*/, char* argv[], char* /*envp*/[], const FDraw_InitAppli fDraw_InitAppli)
95 {
96   Draw_IsConsoleSubsystem = Standard_True;
97   //return _WinMain_(::GetModuleHandle(NULL), NULL, GetCommandLine(), SW_SHOW, fDraw_InitAppli);
98   theDraw_InitAppli = fDraw_InitAppli;
99   //ParseCommandLine(GetCommandLine());
100
101   // MKV 01.02.05
102 #if ((TCL_MAJOR_VERSION > 8) || ((TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION >= 4)))
103   Tcl_FindExecutable(argv[0]);
104 #endif
105
106   Draw_Appli(::GetModuleHandle(NULL), NULL, GetCommandLine(), SW_SHOW, fDraw_InitAppli);
107   return 0;
108
109 }
110
111 //=======================================================================
112 //function : _WinMain_
113 //purpose  : 
114 //=======================================================================
115
116 Standard_Integer _WinMain_ (HINSTANCE /*hInstance*/, HINSTANCE /*hPrevinstance*/, LPSTR /*lpCmdLine*/, int /*nCmdShow*/, const FDraw_InitAppli /*fDraw_InitAppli*/)
117 {
118 //  theDraw_InitAppli = fDraw_InitAppli;
119 //  ParseCommandLine (lpCmdLine);
120 //  Draw_Appli(hInstance, hPrevinstance, lpCmdLine, nCmdShow, Draw_InitAppli); // for C30;
121   return 0;
122 }
123 #else
124 //=======================================================================
125 //function : _main_
126 //purpose  : 
127 //=======================================================================
128
129 Standard_Integer _main_ (Standard_Integer argc, char* argv[], const FDraw_InitAppli fDraw_InitAppli)
130 {
131   // MKV 01.02.05
132 #if ((TCL_MAJOR_VERSION > 8) || ((TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION >= 4)))
133   Tcl_FindExecutable(argv[0]);
134 #endif
135   Draw_Appli(argc, argv, fDraw_InitAppli);
136   return 0;
137 }
138 #endif
139