0024275: Cppcheck warnings on uninitialized class members
[occt.git] / src / OSD / OSD_Error.cxx
CommitLineData
b311480e 1// Copyright (c) 1998-1999 Matra Datavision
2// Copyright (c) 1999-2012 OPEN CASCADE SAS
3//
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.
8//
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.
11//
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.
18
7fd59977 19
20#ifndef WNT
21
22#include <OSD_Error.ixx>
23#include <OSD_ErrorList.hxx>
24#include <stdio.h>
25
26/* Created by Stephan GARNAUD (ARM) 1992 for Matra Datavision */
27
28OSD_Error::OSD_Error(){
29 myErrno = 0;
30}
31
32
33void OSD_Error::Reset(){
34 myErrno = 0;
35}
36
37Standard_Boolean OSD_Error::Failed()const{
38 if (myErrno == 0) return (Standard_False);
39 else return (Standard_True);
40}
41
42
43
44void OSD_Error::SetValue(const Standard_Integer errcode,
45 const Standard_Integer from,
46 const TCollection_AsciiString& message){
47 myErrno = errcode;
48 myCode = (OSD_WhoAmI)from;
49 myMessage = message;
50}
51
52
53
54Standard_Integer OSD_Error::Error()const{
55 return(extCode);
56}
57
58
59void OSD_Error::Perror() {
60 TCollection_AsciiString buffer;
61
62 if (myErrno == 0) return;
63
64 buffer += " :\n ";
65 extCode = ERR_SURPRISE;
66
67 switch (myErrno){
68 case EBADF :
69 switch (myCode){
70 case OSD_WFile:
71 buffer += "Invalid file descriptor or bad mode";
72 extCode = ERR_FBADF;
73 break;
74 case OSD_WMailBox:
75 buffer += "Invalid mail box identification";
76 extCode = ERR_MBADF;
77 break;
78 default:
79 break;
80 }
81 break;
82
83
84#ifdef SUN
85 case EBADMSG:
86 switch (myCode){
87 case OSD_WFile:
88 buffer +=
89 "The message waiting to be read on stream is not a data message";
90 extCode = ERR_FBADMSG;
91 break;
92 default:
93 break;
94 }
95 break;
96#endif
97
98 case EINVAL:
99 switch (myCode){
100 case OSD_WFileNode:
101 buffer += "Can't unlink '.' or '..'";
102 extCode = ERR_FNINVAL;
103 break;
104 case OSD_WFile:
105 buffer += "Invalid file descriptor";
106 extCode = ERR_FINVAL;
107 break;
108 case OSD_WMailBox :
109 buffer += "Internal error : invalid arguments";
110 extCode = ERR_MINVAL;
111 break;
112 default :
113 buffer += "User error : Bad parameter";
114 extCode = ERR_INVAL;
115 break;
116 }
117 break;
118#if !defined(sun) && !defined(SOLARIS)
119 case EDQUOT :
120 switch (myCode){
121 case OSD_WDirectory:
122 case OSD_WFileNode:
123 case OSD_WFile :
124 buffer += "Exceed quota of disk blocks";
125 extCode = ERR_QUOT;
126 break;
127 default:
128 break;
129 }
130 break;
131#endif
132
133#ifdef SUN
134 case EDEADLK:
135 switch (myCode){
136 case OSD_WFile:
137 buffer += "Lock is already blocked by another process";
138 extCode = ERR_FDEADLK;
139 break;
7fd59977 140 default:
141 break;
7fd59977 142 }
143 break;
144#endif
145
146 case ENOLCK:
147 switch (myCode){
148 case OSD_WFile:
149 buffer += "No more file lock entries available";
150 extCode = ERR_FNOLCK;
151 break;
152 default:
153 break;
154 }
155 break;
156 case EOPNOTSUPP:
157 switch (myCode){
158 case OSD_WFile:
159 buffer += "File descriptor doesn't refer to a file";
160 extCode = ERR_FWFD;
161 break;
162 default:
163 break;
164 }
165 break;
166 case EACCES:
167 buffer += "Permission denied";
168 extCode = ERR_ACCESS;
169 break;
170 case EBUSY:
171 switch (myCode){
172 case OSD_WFileNode:
173 buffer += "Still used by system or a process";
174 extCode = ERR_FNBUSY;
175 break;
176 default:
177 break;
178 }
179 break;
180 case ERANGE:
181 switch (myCode){
182 case OSD_WFile:
183 buffer += "Not enough or too many bytes written";
184 extCode = ERR_FRANGE;
185 break;
186 case OSD_WSemaphore:
187 case OSD_WSharedMemory:
188 buffer += "system overflow value.\n";
189 buffer += "Try to reconfigure Kernel with greater values";
190 extCode = ERR_RANGE;
191 break;
192 default:
193 break;
194 }
195 break;
196 case EPERM:
197 switch (myCode){
198 case OSD_WPackage:
199 buffer += "Permission denied";
200 extCode = ERR_PPERM;
201 break;
202 case OSD_WFileNode:
203 buffer += "Permission denied or can't unlink directory";
204 extCode = ERR_FPERM;
205 break;
206 case OSD_WMailBox :
207 buffer += "User error : processes using mail boxes must ";
208 buffer += "be\nused by the same user";
209 extCode = ERR_MPERM;
210 break;
211 default :
212 buffer += "abnormal error : you modified OSD library";
213 extCode = ERR_PERM;
214 break;
215 }
216 break;
217 case EROFS:
218 switch (myCode){
219 case OSD_WFileNode:
220 case OSD_WFile:
221 buffer += "Read only file system";
222 extCode = ERR_ROFS;
223 break;
224 default:
225 break;
226 }
227 break;
228 case ENXIO:
229 case EIO :
230 switch (myCode){
231 case OSD_WDirectory:
232 case OSD_WFileNode:
233 buffer += "I/O error";
234 extCode = ERR_IO;
235 break;
236 case OSD_WFile :
237 buffer += "I/O error or Hang up from terminal";
238 extCode = ERR_FIO;
239 break;
240 default:
241 break;
242 }
243 break;
244 case EISDIR :
245 switch (myCode){
246 case OSD_WFileNode:
247 case OSD_WFile :
248 buffer += "The File is a Directory";
249 extCode = ERR_ISDIR;
250 break;
251 default:
252 break;
253 }
254 break;
255
256#ifdef SUN
257 case EWOULDBLOCK:
258 switch (myCode){
259 case OSD_WFile:
260 buffer += "File is locked";
261 extCode = ERR_FLOCKED;
262 break;
7fd59977 263 default:
264 break;
7fd59977 265 }
266 break;
267#endif
268
269#ifdef IRIX4
270 case EWOULDBLOCK:
271 switch (myCode){
272 case OSD_WFile:
273 buffer += "File is locked";
274 extCode = ERR_FLOCKED;
275 break;
7fd59977 276 default:
277 break;
7fd59977 278 }
279 break;
280#endif
281
282 case EAGAIN:
283 switch (myCode){
284 case OSD_WFile:
285 buffer += "No data ready to be read/written";
286 extCode = ERR_FAGAIN;
287 break;
288 default:
289 break;
290 }
291 break;
292 case ENOTDIR:
293 switch(myCode){
294 case OSD_WDirectory:
295 case OSD_WFileNode:
296 case OSD_WFile:
297 buffer += "A component of path is not a Directory";
298 extCode = ERR_NOTDIR;
299 break;
300 default:
301 break;
302 }
303 break;
304 case EMLINK:
305 switch (myCode){
306 case OSD_WDirectory:
307 buffer += "Too many links";
308 extCode = ERR_DMLINK;
309 break;
310 default:
311 break;
312 }
313 break;
314 case ELOOP :
315 switch (myCode){
316 case OSD_WDirectory:
317 case OSD_WFileNode:
318 case OSD_WFile :
319 buffer += "Too many symbolic links";
320 break;
321 default:
322 break;
323 }
324 break;
325 case EFAULT:
326 buffer += "User error : arguments point to an illegal address";
327 extCode = ERR_FAULT;
328 break;
329 case EFBIG:
330 switch (myCode){
331 case OSD_WFile:
332 buffer += "Exceed process's file size limit or the maximum file size";
333 extCode = ERR_FFBIG;
334 break;
335 case OSD_WSemaphore:
336 buffer += "Internal error : wrong number for this semaphore";
337 extCode = ERR_SFBIG;
338 break;
339 default:
340 break;
341 }
342 break;
343 case EINTR:
344 buffer += "operation breaked by a signal";
345 extCode = ERR_INTR;
346 break;
347 case EIDRM:
348 buffer += "Semaphore externaly removed from system";
349 extCode = ERR_SIDRM;
350 break;
351 case ENOMEM:
352 buffer += "Not enough memory";
353 extCode = ERR_NOMEM;
354 break;
355 case EMFILE :
356 switch(myCode){
357 case OSD_WFile :
358 buffer += "Too many file descriptors are currently in use by this process";
359 extCode = ERR_FMFILE;
360 break;
361 case OSD_WMailBox :
362 buffer += "Too many mail boxes opened";
363 extCode = ERR_MMFILE;
364 break;
365 case OSD_WSharedMemory :
366 buffer += "The number of shared memory segments attached to the calling process \nwould exceed the system imposed limit.\n";
367 buffer += "Try to reconfigure Kernel with greater values";
368 extCode = ERR_SMMFILE;
369 break;
370 default:
371 break;
372 }
373 break;
374 case ENAMETOOLONG :
375 buffer += "File name too long";
376 extCode = ERR_NAMETOOLONG;
377 break;
378 case ENFILE :
379 switch (myCode){
380 case OSD_WFile:
381 buffer += "Too many files are currently open in the system";
382 extCode = ERR_FNFILE;
383 break;
384 default:
385 break;
386 }
387 break;
388 case EXDEV:
389 switch (myCode){
390 case OSD_WFileNode:
391 buffer += "The link named by path2 and the file named by path1 are\n";
392 buffer += "on different logical devices (file systems)";
393 extCode = ERR_FNXDEV;
394 break;
395 default:
396 break;
397 }
398 break;
399 case ENOENT:
400 switch (myCode){
401 case OSD_WFileNode:
402 case OSD_WFile:
403 if (myMessage != "Open") buffer += "File doesn't exist or";
404 buffer += "Invalid path (empty string)";
405 extCode = ERR_NOENT;
406 break;
407 case OSD_WDirectory:
408 buffer += "A component of the path prefix of path does not exist";
409 extCode = ERR_DNOENT;
410 break;
411 case OSD_WSemaphore:
412 case OSD_WSharedMemory:
413 buffer += "User error : Has not been created";
414 extCode = ERR_SNOENT;
415 break;
416 default:
417 break;
418 }
419 break;
420 case ENOSPC: {
421 switch (myCode){
422 case OSD_WDirectory:
423 case OSD_WFile:
424 buffer += "No more free space on file system";
425 extCode = ERR_FNOSPC;
426 break;
427 case OSD_WSharedMemory: {
428 buffer += "You exceed number of shared memory allowed.\n";
429 buffer += "Try to reconfigure Kernel with greater values";
430 extCode = ERR_SMNOSPC;
431 break;
432 }
433 default:
434 break;
435 }
436 break;
437 }
438
439//
440// AIX maps ENOTEMPTY to EEXIST. Move this case block to
441// the EEXIST case block.
442//
443#if (!defined(_AIX)) && (!defined(AIX))
444 case ENOTEMPTY:
445 switch (myCode){
446 case OSD_WFileNode:
447 buffer += "Directory not empty";
448 extCode = ERR_FNNOTEMPTY;
449 break;
450 default:
451 break;
452 }
453 break;
454#endif
455
456 case EEXIST:
457 switch(myCode){
458 case OSD_WFileNode:
459 buffer += "Directory not empty";
460 extCode = ERR_FNNOTEMPTY;
461 break;
462 case OSD_WFile:
463 buffer += "OSD_Create and OSD_Exclude are set and the named file exists";
464 extCode = ERR_FEXIST;
465 break;
466 default:
467 buffer += "Identifier already exists for this key";
468 extCode = ERR_EXIST;
469 break;
470 }
471 break;
472 case E2BIG:
473 buffer += "Too many Semaphore/Shared memory for a process.";
474 buffer += "Reconfigure Kernel with greater values";
475 extCode = ERR_TOOBIG;
476 break;
477 case ESRCH :
478 switch (myCode){
479 case OSD_WMailBox :
480 buffer += "Server process is dead.\n";
481 buffer += "There is no more process to communicate with";
482 extCode = ERR_MSRCH;
483 break;
484 default:
485 break;
486 }
487 break;
488 default: {
489 Standard_Character buf[255];
490 //
491 sprintf(buf,"%sUnknowm error #%d",buffer.ToCString(),myErrno);
492 TCollection_AsciiString interm(buf);
493 buffer = interm;
494 extCode = ERR_UNKNOWN;
495 }
496 }
497 buffer += ".\n\n";
498 OSD_OSDError::Raise (buffer.ToCString());
499}
500
501#else
502
503//------------------------------------------------------------------------
504//------------------- Windows NT sources for OSD_Error ------------------
505//------------------------------------------------------------------------
506
507#define STRICT
508#include <OSD_Error.hxx>
509#include <OSD_ErrorList.hxx>
510
511#include <windows.h>
512
513typedef struct _error_table {
514
515 DWORD wnt_error;
516 Standard_Integer csf_error;
517
518 } ERROR_TABLE;
519
520static int fPrefix = 1;
521static ostream* errorStream = &cerr;
522
523static ERROR_TABLE commErrorTable [] = {
524
525 { ERROR_INVALID_FUNCTION, ERR_INVAL },
526 { ERROR_FILE_NOT_FOUND, ERR_NOENT },
527 { ERROR_PATH_NOT_FOUND, ERR_NOENT },
528 { ERROR_ACCESS_DENIED, ERR_ACCESS },
529 { ERROR_ARENA_TRASHED, ERR_NOMEM },
530 { ERROR_NOT_ENOUGH_MEMORY, ERR_NOMEM },
531 { ERROR_INVALID_BLOCK, ERR_NOMEM },
532 { ERROR_BAD_ENVIRONMENT, ERR_TOOBIG },
533 { ERROR_INVALID_ACCESS, ERR_INVAL },
534 { ERROR_INVALID_DATA, ERR_INVAL },
535 { ERROR_INVALID_DRIVE, ERR_NOENT },
536 { ERROR_CURRENT_DIRECTORY, ERR_ACCESS },
537 { ERROR_NO_MORE_FILES, ERR_NOENT },
538 { ERROR_LOCK_VIOLATION, ERR_ACCESS },
539 { ERROR_SHARING_VIOLATION, ERR_ACCESS },
540 { ERROR_BAD_NETPATH, ERR_NOENT },
541 { ERROR_NETWORK_ACCESS_DENIED, ERR_ACCESS },
542 { ERROR_BAD_NET_NAME, ERR_NOENT },
543 { ERROR_FILE_EXISTS, ERR_EXIST },
544 { ERROR_CANNOT_MAKE, ERR_ACCESS },
545 { ERROR_FAIL_I24, ERR_ACCESS },
546 { ERROR_INVALID_PARAMETER, ERR_INVAL },
547 { ERROR_DRIVE_LOCKED, ERR_ACCESS },
548 { ERROR_INVALID_HANDLE, ERR_INVAL },
549 { ERROR_NEGATIVE_SEEK, ERR_INVAL },
550 { ERROR_SEEK_ON_DEVICE, ERR_ACCESS },
551 { ERROR_NOT_LOCKED, ERR_ACCESS },
552 { ERROR_BAD_PATHNAME, ERR_NOENT },
553 { ERROR_LOCK_FAILED, ERR_ACCESS },
554 { ERROR_ALREADY_EXISTS, ERR_EXIST },
555 { ERROR_FILENAME_EXCED_RANGE, ERR_NOENT },
556 { ERROR_NOT_ENOUGH_QUOTA, ERR_QUOT },
557 { ERROR_IO_DEVICE, ERR_IO },
558 { ERROR_INVALID_BLOCK, ERR_FAULT },
559 { ERROR_BAD_THREADID_ADDR, ERR_FAULT },
560 { ERROR_INVALID_ADDRESS, ERR_FAULT },
561 { ERROR_MAPPED_ALIGNMENT, ERR_FAULT },
562 { ERROR_BUFFER_OVERFLOW, ERR_NAMETOOLONG }
563
564};
565
f24125b9 566#define COMM_ERR_TABLE_SIZE (int)(sizeof(commErrorTable) / sizeof(commErrorTable[0]))
7fd59977 567
568static ERROR_TABLE dirErrorTable[] = {
569
570 { ERROR_FILE_NOT_FOUND, ERR_NOENT },
571 { ERROR_PATH_NOT_FOUND, ERR_NOENT },
572 { ERROR_INVALID_DRIVE, ERR_NOENT },
573 { ERROR_NO_MORE_FILES, ERR_NOENT },
574 { ERROR_BAD_NETPATH, ERR_NOENT },
575 { ERROR_BAD_NET_NAME, ERR_NOENT },
576 { ERROR_BAD_PATHNAME, ERR_NOENT },
577 { ERROR_FILENAME_EXCED_RANGE, ERR_NOENT }
578
579};
580
f24125b9 581#define DIR_ERR_TABLE_SIZE (int)(sizeof(dirErrorTable) / sizeof(dirErrorTable[0]))
7fd59977 582
583static ERROR_TABLE fileErrorTable[] = {
584
585 { ERROR_INVALID_HANDLE, ERR_FBADF },
586 { ERROR_INVALID_TARGET_HANDLE, ERR_FBADF },
587 { ERROR_DIRECT_ACCESS_HANDLE, ERR_FBADF },
588 { ERROR_FILE_EXISTS, ERR_EXIST },
589 { ERROR_ALREADY_EXISTS, ERR_EXIST },
590 { ERROR_TOO_MANY_OPEN_FILES, ERR_FMFILE },
591 { ERROR_INVALID_FUNCTION, ERR_FINVAL },
592 { ERROR_INVALID_ACCESS, ERR_FINVAL },
593 { ERROR_INVALID_DATA, ERR_FINVAL },
594 { ERROR_INVALID_PARAMETER, ERR_FINVAL },
595 { ERROR_INVALID_HANDLE, ERR_FINVAL },
596 { ERROR_NEGATIVE_SEEK, ERR_FINVAL },
597 { ERROR_IO_PENDING, ERR_FAGAIN },
598 { ERROR_WRITE_FAULT, ERR_FIO },
599 { ERROR_READ_FAULT, ERR_FIO },
600 { ERROR_NET_WRITE_FAULT, ERR_FIO },
601 { ERROR_IO_DEVICE, ERR_FIO },
602 { ERROR_LOCK_VIOLATION, ERR_FLOCKED },
603 { ERROR_LOCK_FAILED, ERR_FLOCKED }
604
605};
606
607#define FILE_ERR_TABLE_SIZE ( sizeof ( fileErrorTable ) / sizeof ( fileErrorTable[ 0 ] ) )
608
609static ERROR_TABLE fileNodeErrorTable[] = {
610
611 { ERROR_INVALID_FUNCTION, ERR_FNINVAL },
612 { ERROR_INVALID_ACCESS, ERR_FNINVAL },
613 { ERROR_INVALID_DATA, ERR_FNINVAL },
614 { ERROR_INVALID_PARAMETER, ERR_FNINVAL },
615 { ERROR_INVALID_HANDLE, ERR_FNINVAL },
616 { ERROR_NEGATIVE_SEEK, ERR_FNINVAL },
617 { ERROR_DISK_FULL, ERR_FNOSPC },
618 { ERROR_DIR_NOT_EMPTY, ERR_FNNOTEMPTY },
619 { ERROR_NOT_SAME_DEVICE, ERR_FNXDEV }
620
621};
622
f24125b9 623#define FILE_NODE_ERR_TABLE_SIZE (int)(sizeof(fileNodeErrorTable) / sizeof(fileNodeErrorTable[0]))
7fd59977 624
625static Standard_Integer _get_comm_error ( DWORD );
626
c24d4017 627OSD_Error :: OSD_Error () :
628 myCode((OSD_WhoAmI)0),
629 extCode(0)
630{
7fd59977 631 Reset ();
7fd59977 632} // end constructor ( 1 )
633
634void OSD_Error :: Perror () {
635
d9b81fa5 636 if (errorStream == NULL)
637 return;
638
7fd59977 639 Standard_Character buff[ 32 ];
640 Standard_CString ptr;
641
642 if ( fPrefix ) {
643
644 lstrcpy ( buff, TEXT( "Error ( " ) );
645
646 switch ( myCode ) {
647
648 case OSD_WDirectoryIterator:
649
650 ptr = TEXT( "OSD_DirectoryIterator" );
651
652 break;
653
654 case OSD_WDirectory:
655
656 ptr = TEXT( "OSD_Directory" );
657
658 break;
659
660 case OSD_WFileIterator:
661
662 ptr = TEXT( "OSD_FileIterator" );
663
664 break;
665
666 case OSD_WFile:
667
668 ptr = TEXT( "OSD_File" );
669
670 break;
671
672 case OSD_WFileNode:
673
674 ptr = TEXT( "OSD_FileNode" );
675
676 break;
677
678 case OSD_WHost:
679
680 ptr = TEXT( "OSD_Host" );
681
682 break;
683
684 case OSD_WProcess:
685
686 ptr = TEXT( "OSD_Environment" );
687
688 break;
689
690 case OSD_WEnvironmentIterator:
691
692 ptr = TEXT( "OSD_EnvironmentIterator" );
693
694 break;
695
696 case OSD_WEnvironment:
697
698 ptr = TEXT( "OSD_Environment" );
699
700 break;
701
702 case OSD_WSharedMemory:
703
704 ptr = TEXT( "OSD_SharedMemory" );
705
706 break;
707
708 case OSD_WDisk:
709
710 ptr = TEXT( "OSD_Disk" );
711
712 break;
713
714 default:
715
716 ptr = TEXT( "Unknown" );
717
718 } // end switch
719
720 lstrcat ( buff, ptr );
721 lstrcat ( buff, TEXT( " )" ) );
722 ( *errorStream ) << buff;
723
724 } // end if ( fPrefix . . . )
725
726 ( *errorStream ) << TEXT( ": " ) << myMessage.ToCString () << endl << flush;
727
728} // end OSD_Error :: Perror
729
730void OSD_Error :: SetValue (
731 const Standard_Integer Errcode,
732 const Standard_Integer From,
733 const TCollection_AsciiString& Message
734 ) {
735
736 int i;
737
738 myErrno = Errcode;
739 myCode = ( OSD_WhoAmI )From;
740 myMessage = Message;
741
742 switch ( From ) {
743
744 case OSD_WDirectory:
745
746 for ( i = 0; i < DIR_ERR_TABLE_SIZE; ++i )
747
748 if ( dirErrorTable[ i ].wnt_error == ( DWORD )Errcode ) {
749
750 extCode = dirErrorTable[ i ].csf_error;
751 break;
752
753 } // end if
754
755 if ( i == DIR_ERR_TABLE_SIZE ) extCode = _get_comm_error ( Errcode );
756
757 break;
758
759 case OSD_WFile:
760
761 for ( i = 0; i < FILE_ERR_TABLE_SIZE; ++i )
762
763 if ( fileErrorTable[ i ].wnt_error == ( DWORD )Errcode ) {
764
765 extCode = fileErrorTable[ i ].csf_error;
766 break;
767
768 } // end if
769
770 if ( i == FILE_ERR_TABLE_SIZE ) extCode = _get_comm_error ( Errcode );
771
772 break;
773
774 case OSD_WFileNode:
775
776 for ( i = 0; i < FILE_NODE_ERR_TABLE_SIZE; ++i )
777
778 if ( fileNodeErrorTable[ i ].wnt_error == ( DWORD )Errcode ) {
779
780 extCode = fileNodeErrorTable[ i ].csf_error;
781 break;
782
783 } // end if
784
785 if ( i == FILE_NODE_ERR_TABLE_SIZE ) extCode = _get_comm_error ( Errcode );
786
787 break;
788
789 default:
790
791 extCode = _get_comm_error ( Errcode );
792
793 } // end switch
794
795} // end OSD_Error :: SetValue
796
797Standard_Integer OSD_Error :: Error () const {
798
799 return extCode;
800
801} // end OSD_Error :: Error
802
803Standard_Boolean OSD_Error :: Failed () const {
804
805 return myErrno == ERROR_SUCCESS ? Standard_False : Standard_True;
806
807} // end OSD_Error :: Failed
808
809void OSD_Error :: Reset () {
810
811 myErrno = ERROR_SUCCESS;
d9b81fa5 812 if (errorStream != NULL)
813 {
814 ( *errorStream ).clear ();
815 ( *errorStream ).seekp ( 0 );
816 ( *errorStream ).clear ();
817 }
7fd59977 818
819} // end OSD_Error :: Reset
820
821void SetErrorStream ( ostream* errStream ) {
822
823 errorStream = errStream;
824
825} // end SetErrorStream
826
827void EnablePrefix ( int fEnable ) {
828
829 fPrefix = fEnable;
830
831} // end EnablePrefix
832
833int ErrorPrefix ( void ) {
834
835 return fPrefix;
836
837} // end ErrorPrefix
838
839ostream* ErrorStream ( void ) {
840
841 return errorStream;
842
843} // end ErrorStream
844
845static Standard_Integer _get_comm_error ( DWORD dwCode ) {
846
847 int i;
848 Standard_Integer retVal = ERR_SURPRISE;
849
850 for ( i = 0; i < COMM_ERR_TABLE_SIZE; ++i )
851
852 if ( commErrorTable[ i ].wnt_error == ( DWORD )dwCode ) {
853
854 retVal = commErrorTable[ i ].csf_error;
855 break;
856
857 } // end if
858
859 return retVal;
860
861} // end _get_comm_error
862
863#endif