1 -- Copyright (c) 1992-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 -- 20-01-2009 : ABD Integration support of system fonts (using FTGL and FreeType)
25 -- Version Date Purpose
26 -- 1.1 24/06/92 Operating System Dependent tools
30 -- Windows NT 30/09/96 ( EUG )
31 ---Purpose: Set of Operating Sytem Dependent Tools
32 -- (O)perating (S)ystem (D)ependent
42 exception OSDError inherits Failure from Standard ;
45 ---Purpose: This is in fact a pointer to a function.
46 -- This is not an "enumeration" but a trick to solve an omission
48 --- C++: alias "typedef int (* OSD_Function)(...);"
50 enumeration OEMType is Unavailable,SUN,DEC,SGI,NEC,MAC,PC,HP,IBM,VAX,LIN,AIX;
51 ---Purpose: This is set of possible machine types
52 -- used in OSD_Host::MachineType
54 enumeration SysType is Unknown,Default,UnixBSD, UnixSystemV, VMS, OS2,
55 OSF, MacOs, Taligent, WindowsNT, LinuxREDHAT,Aix;
56 ---Purpose: Thisd is a set of possible system types.
57 -- 'Default' means SysType of machine operating this process.
58 -- This can be used with the Path class.
59 -- All UNIX-like are grouped under "UnixBSD" or "UnixSystemV".
60 -- Such systems are Solaris, NexTOS ...
61 -- A category of systems accept MSDOS-like path such as
64 enumeration FromWhere is FromBeginning, FromHere, FromEnd;
65 ---Purpose: Used by OSD_File in the method Seek.
67 enumeration LockType is NoLock, ReadLock, WriteLock, ExclusiveLock;
68 ---Purpose: locks for files.
69 -- NoLock is the default value when opening a file.
71 -- ReadLock allows only one reading of the file at a time.
73 -- WriteLock prevents others writing into a file(excepted the user
74 -- who puts the lock)but allows everybody to read.
76 -- ExclusiveLock prevents reading and writing except for the
77 -- current user of the file.
78 -- So ExclusiveLock means only one user on the file and this
79 -- user is the one who puts the lock.
81 enumeration SingleProtection is None,R,W,RW,X,RX,WX,RWX,D,RD,WD,RWD,XD,RXD,WXD,RWXD;
82 ---Purpose: Access rights for files.
83 -- R means Read, W means Write, X means eXecute and D means Delete.
84 -- On UNIX, the right to Delete is combined with Write access.
85 -- So if "W"rite is not set and "D"elete is, "W"rite will be set
86 -- and if "W" is set, "D" will be too.
88 enumeration OpenMode is ReadOnly, WriteOnly, ReadWrite;
89 ---Purpose: Specifies the file open mode.
91 enumeration LoadMode is RTLD_LAZY, RTLD_NOW;
92 ---Purpose: This enumeration is used to load shareable libraries.
94 enumeration KindFile is FILE, DIRECTORY, LINK, SOCKET, UNKNOWN;
95 ---Purpose: Specifies the type of files.
97 --ABD Integration support of system fonts (using FTGL and FreeType)
98 enumeration FontAspect is FA_Undefined, FA_Regular, FA_Bold, FA_Italic, FA_BoldItalic;
99 ---Purpose: Specifies aspect of system font.
101 private enumeration WhoAmI is WDirectory, WDirectoryIterator,
102 WEnvironment, WFile, WFileNode, WFileIterator, WMailBox,
103 WPath, WProcess, WProtection, WSemaphore, WHost, WDisk,
104 WChronometer, WSharedMemory, WTimer, WPackage, WPrinter,
105 WEnvironmentIterator;
106 ---Purpose: Allows great accuracy for error management.
111 ---Purpose: Accurate management of OSD specific errors.
114 ---Purpose: Gets and sets protection attributes of 'system , user ,
115 -- group, and world'.
118 ---Purpose: Manages independent system path translation.
120 deferred class FileNode;
121 ---Purpose: A set of file/directory manipulation tools.
124 ---Purpose: A set of disk oriented tools.
127 ---Purpose: A set of file oriented tools.
130 ---Purpose: Searches for child files in current directory.
133 ---Purpose: A set of directory oriented tools
135 class DirectoryIterator;
136 ---Purpose: Searches sub-directories in current directory.
139 ---Purpose: Measures time elapsed for performance program tests.
140 -- Measures CPU time consumed by a method call.
143 ---Purpose: Measures the effective time elapsed for a method call.
146 ---Purpose: Selects a printer (used by File).
149 ---Purpose: Carries information about a host.
150 -- System version ,host name, nodename ...
153 ---Purpose: Manages environment variables.
155 class EnvironmentIterator;
156 ---Purpose: Get all environment variables.
159 ---Purpose: Process specific oriented tools
162 ---Purpose: Manages shared memory.
165 ---Purpose: Manages semaphores.
167 -- class Mutex is alias Mutex from Standard;
168 ---Purpose: Mutex object to synchronize threads within one process
171 ---Purpose: Manages asynchronous mail boxes.
174 ---Purpose: Provides tools to load a shared library
175 -- and retrieve the address of an entry point.
178 imported ThreadFunction;
180 ---Purpose: A tool to manage threads
182 --ABD Integration support of system fonts (using FTGL and FreeType)
183 imported NListOfSystemFont;
189 ---Purpose: Convertion of CString to Real and reciprocally
192 ---Purpose: Manages locale.
195 -----------------------------------------------
196 -- UNIX specific exceptions and enumeration --
197 -----------------------------------------------
199 exception Signal inherits Failure from Standard;
200 exception SIGHUP inherits Signal;
201 exception SIGINT inherits Signal;
202 exception SIGQUIT inherits Signal;
203 exception SIGILL inherits Signal;
204 exception SIGKILL inherits Signal;
205 exception SIGBUS inherits Signal;
206 exception SIGSEGV inherits Signal;
207 exception SIGSYS inherits Signal;
210 enumeration Signals is
212 -- The "posix" signals.
214 S_SIGHUP, -- "hangup."
215 S_SIGINT, -- "interrupt."
216 S_SIGQUIT, -- "quit."
217 S_SIGILL, -- "illegal instruction."
218 S_SIGKILL, -- "kill."
219 S_SIGBUS, -- "bus error."
220 S_SIGSEGV, -- "segmentation violation."
221 S_SIGSYS, -- "bad argument to system call."
222 S_SIGFPE, -- "floating point exception."
223 S_FPE_FLTDIV_TRAP, -- "floating/decimal divide by zero."
224 S_FPE_INTDIV_TRAP, -- "integer divide by zero."
225 S_FPE_FLTOVF_TRAP, -- "floating overflow."
226 S_FPE_INTOVF_TRAP, -- "integer overflow."
227 S_FPE_FLTUND_TRAP, -- "floating underflow."
228 S_FPE_FLTINEX_TRAP -- "floating inexact result."
231 ----------------------------------------
232 -- Exceptions ( Windows NT specific ) --
233 ----------------------------------------
235 exception Exception inherits Failure from Standard;
237 exception Exception_ACCESS_VIOLATION inherits Exception;
238 exception Exception_ARRAY_BOUNDS_EXCEEDED inherits Exception;
239 exception Exception_FLT_DENORMAL_OPERAND inherits Exception;
240 exception Exception_FLT_DIVIDE_BY_ZERO inherits Exception;
241 exception Exception_FLT_INEXACT_RESULT inherits Exception;
242 exception Exception_FLT_INVALID_OPERATION inherits Exception;
243 exception Exception_FLT_OVERFLOW inherits Exception;
244 exception Exception_FLT_STACK_CHECK inherits Exception;
245 exception Exception_FLT_UNDERFLOW inherits Exception;
246 exception Exception_ILLEGAL_INSTRUCTION inherits Exception;
247 exception Exception_IN_PAGE_ERROR inherits Exception;
248 exception Exception_INT_DIVIDE_BY_ZERO inherits Exception;
249 exception Exception_INT_OVERFLOW inherits Exception;
250 exception Exception_INVALID_DISPOSITION inherits Exception;
251 exception Exception_NONCONTINUABLE_EXCEPTION inherits Exception;
252 exception Exception_PRIV_INSTRUCTION inherits Exception;
253 exception Exception_STACK_OVERFLOW inherits Exception;
254 exception Exception_STATUS_NO_MEMORY inherits Exception; -- generating by 'HeapAlloc'
255 exception Exception_CTRL_BREAK inherits Exception; -- generating by 'Ctrl-C' keystroke
257 ----------------------------------------------
258 -- Handler and SegvHandler (UNIX specific ) --
259 ----------------------------------------------
262 -- Handler(aSignal: Signals; aCode: Signals)
265 Handler(aSignal: Signals; aSigInfo: Address; aContext: Address)
267 -- 1) Raise a exception when aSignal is a floating point signal.
268 -- aSignal is SIGFPE.
270 -- (FPE: Floating Point Exception)
271 -- (FLT: FLoaTing operation.)
272 -- (INT: INTeger operation.)
273 -- (DIV: DIVided by zero.)
275 -- (INEX: INEXact operation.)
277 -- FPE_FLTDIV_TRAP (the exception "DivideByZero" is raised.)
278 -- FPE_INTDIV_TRAP (the exception "DivideByZero" is raised.)
280 -- FPE_FLTOVF_TRAP (the exception "Overflow" is raised.)
281 -- FPE_INTOVF_TRAP (the exception "Overflow" is raised.)
283 -- FPE_FLTINEX_TRAP (the exception "NumericError" is raised.)
285 -- 2) Display the signal name, and call "exit" with signal number for
286 -- a "Hardware" signal.
302 SegvHandler(aSignal: Signals; aSigInfo: Address; aContext: Address)
304 -- Handle access to null object and segmentation violation
311 ---------------------------------------
312 -- WntHandler (Windows NT specific ) --
313 ---------------------------------------
315 WntHandler ( exceptionInfo : Address from Standard )
316 returns Integer from Standard
320 Exception_ACCESS_VIOLATION,
321 Exception_ARRAY_BOUNDS_EXCEEDED,
322 Exception_FLT_DENORMAL_OPERAND,
323 Exception_FLT_DIVIDE_BY_ZERO,
324 Exception_FLT_INEXACT_RESULT,
325 Exception_FLT_INVALID_OPERATION,
326 Exception_FLT_OVERFLOW,
327 Exception_FLT_STACK_CHECK,
328 Exception_FLT_UNDERFLOW,
329 Exception_ILLEGAL_INSTRUCTION,
330 Exception_IN_PAGE_ERROR,
331 Exception_INVALID_DISPOSITION,
332 Exception_NONCONTINUABLE_EXCEPTION,
333 Exception_PRIV_INSTRUCTION,
334 Exception_STACK_OVERFLOW,
335 Exception_STATUS_NO_MEMORY
338 -- 1) Raises an exception if the exception due to floating point errors.
339 -- Flosting point errors:
340 -- EXCEPTION_FLT_DENORMAL_OPERAND
341 -- EXCEPTION_FLT_DIVIDE_BY_ZERO
342 -- EXCEPTION_FLT_INEXACT_RESULT
343 -- EXCEPTION_FLT_INVALID_OPERATION
344 -- EXCEPTOPN_FLT_OVERFLOW
345 -- EXCEPTION_FLT_STACK_CHECK
346 -- EXCEPTION_FLT_UNDERFLOW
347 -- 2) Displays a message box 'Continue' - 'Debugger' - 'Stop' if the environment
348 -- variable 'CSF_EXCEPTION_PROMPT' is set and takes appropriate action.
349 -- Raises an exception otherwise.
351 SetSignal(aFloatingSignal: Boolean = Standard_True);
353 -- 1) Arms some floating point signals, and sets a "Handler" for them.
354 -- 2) Sets a "Handler" for the "Hardware" signals.
355 -- For Win32 users: under VC++ you can control which method of handling
356 -- exceptions is used by means of UseSETranslator method before calling
360 -- Some "Data Base Managers" use their own "Handler" for the signals
361 -- such as "SIGSEGV". So if a "Handler" is set for a signal it will
362 -- not be replaced by Standard "Handler". It is managed by OBJS
363 -- preprocessor definition.
367 AvailableMemory returns Integer from Standard;
368 ---Purpose: Returns available memory in Kilobytes.
371 SecSleep(aDelay: Integer from Standard);
372 ---Purpose: Commands the process to sleep for a number of seconds.
375 MilliSecSleep(aDelay: Integer from Standard);
376 ---Purpose: Commands the process to sleep for a number of milliseconds
379 RealToCString(aReal: Real; aString:out PCharacter)
382 -- Converts aReal into aCstring in exponential format with a period as
383 -- decimal point, no thousand separator and no grouping of digits.
384 -- The conversion is independant from the current locale
387 CStringToReal(aString: CString; aReal: out Real) returns Boolean ;
389 -- Converts aCstring representing a real with a period as
390 -- decimal point, no thousand separator and no grouping of digits
392 -- The conversion is independant from the current locale.
395 IsDivisible(aDividend, aDivisor: Real from Standard)
396 returns Boolean from Standard;
397 ---Purpose: Tests if the quotient theDividend/theDivisor
401 GetExponent(aReal: Real from Standard)
402 returns Integer from Standard;
403 ---Purpose: Returns the exponent in base 2 of a floating-point number.
406 GetMantissa(aReal: Real from Standard)
407 returns Real from Standard;
408 ---Purpose: Returns the mantissa of a floating-point number.
411 -------------------------
412 -- Windows NT specific --
413 -------------------------
415 ControlBreak raises Exception_CTRL_BREAK;
416 ---Purpose: since Windows NT does not support 'SIGINT' signal like UNIX,
417 -- then this method checks whether Ctrl-Break keystroke was or
418 -- not. If yes then raises Exception_CTRL_BREAK.
420 UseSETranslator(useSE : Boolean);
421 ---Purpose: Defines whether SetSignal must use _se_translator_function or
422 -- SetUnhandledExceptionFilter and signal to catch system
423 -- exceptions. The default behaviour is to use SE translator.
424 -- Warning: Using SE translator method SetSignal should be called for each
425 -- new created thread, while using the alternative method
426 -- the exception handler is established once for the whole
427 -- process and all its threads.
428 -- This function takes effect only under VC++ compiler.
430 UseSETranslator returns Boolean;
431 ---Purpose: Returns the current value of the flag set by above method.