summaryrefslogtreecommitdiff
path: root/src/OSD/OSD_Error.cxx
blob: c760666063f29fb9f1b2dd51232c39e3c2488547 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846

#ifndef WNT

#include <OSD_Error.ixx>
#include <OSD_ErrorList.hxx>
#include <stdio.h>

/* Created by Stephan GARNAUD (ARM) 1992 for Matra Datavision */

OSD_Error::OSD_Error(){
 myErrno = 0;
}


void OSD_Error::Reset(){
 myErrno = 0;
}

Standard_Boolean OSD_Error::Failed()const{
 if (myErrno == 0) return (Standard_False);
              else return (Standard_True);
}



void OSD_Error::SetValue(const Standard_Integer errcode,
                         const Standard_Integer from,
                         const TCollection_AsciiString& message){
 myErrno = errcode;
 myCode  = (OSD_WhoAmI)from;
 myMessage = message;
}



Standard_Integer OSD_Error::Error()const{
 return(extCode);
}

 
void OSD_Error::Perror() {
 TCollection_AsciiString buffer;

 if (myErrno == 0) return;

 buffer += " :\n ";
 extCode = ERR_SURPRISE;

 switch (myErrno){
  case EBADF  :
   switch (myCode){
    case OSD_WFile:
      buffer += "Invalid file descriptor or bad mode";
      extCode = ERR_FBADF;
      break;
     case OSD_WMailBox:
      buffer += "Invalid mail box identification";
      extCode = ERR_MBADF;
      break;
    default:
      break;
    }
    break;


#ifdef SUN
  case EBADMSG:
   switch (myCode){
    case OSD_WFile:
     buffer += 
     "The message waiting to be read on stream is not a data message";
     extCode = ERR_FBADMSG;
     break;
    default:
      break;
   }
   break;
#endif

  case EINVAL: 
   switch (myCode){
    case OSD_WFileNode:
      buffer += "Can't unlink '.' or '..'";
      extCode = ERR_FNINVAL;
      break;
    case OSD_WFile:
      buffer += "Invalid file descriptor";
      extCode = ERR_FINVAL;
      break;
    case OSD_WMailBox :
      buffer += "Internal error : invalid arguments";
      extCode = ERR_MINVAL;
      break;
    default :
      buffer += "User error : Bad parameter";
      extCode = ERR_INVAL;
      break;
   }
   break;
#if !defined(sun) && !defined(SOLARIS)
  case EDQUOT :
   switch (myCode){
    case OSD_WDirectory:
    case OSD_WFileNode:
    case OSD_WFile :
     buffer += "Exceed quota of disk blocks";
     extCode = ERR_QUOT;
     break;
    default:
      break;
   }
   break;
#endif

#ifdef SUN
  case EDEADLK:
   switch (myCode){
    case OSD_WFile:
     buffer += "Lock is already blocked by another process";
     extCode = ERR_FDEADLK;
     break;
#ifndef DEB
    default:
      break;
#endif
   }
   break;
#endif

  case ENOLCK:
   switch (myCode){
    case OSD_WFile:
     buffer += "No more file lock entries available";
     extCode = ERR_FNOLCK;
     break;
    default:
      break;
   }
   break;
  case EOPNOTSUPP:
   switch (myCode){
    case OSD_WFile:
     buffer += "File descriptor doesn't refer to a file";
     extCode = ERR_FWFD;
     break;
    default:
     break;
   }
   break;
  case EACCES: 
    buffer += "Permission denied";
    extCode = ERR_ACCESS;
    break;
  case EBUSY:
   switch (myCode){
    case OSD_WFileNode:
     buffer += "Still used by system or a process";
     extCode = ERR_FNBUSY;
     break;
    default:
      break;
   }
   break;
  case ERANGE:
   switch (myCode){
    case OSD_WFile:
     buffer += "Not enough or too many bytes written";
     extCode = ERR_FRANGE;
     break;
    case OSD_WSemaphore:
    case OSD_WSharedMemory:
     buffer += "system overflow value.\n";
     buffer += "Try to reconfigure Kernel with greater values";
     extCode = ERR_RANGE;
     break;
    default:
      break;
   }
   break;
  case EPERM: 
   switch (myCode){
    case OSD_WPackage:
     buffer += "Permission denied";
     extCode = ERR_PPERM;
     break;
    case OSD_WFileNode:
     buffer += "Permission denied or can't unlink directory";
     extCode = ERR_FPERM;
     break;
    case OSD_WMailBox :
     buffer += "User error : processes using mail boxes must ";
     buffer += "be\nused by the same user";
     extCode = ERR_MPERM;
     break;
    default : 
     buffer += "abnormal error : you modified OSD library";
     extCode = ERR_PERM;
     break;
    }
    break;
  case EROFS:
   switch (myCode){
    case OSD_WFileNode:
    case OSD_WFile:
     buffer += "Read only file system";
     extCode = ERR_ROFS;
     break;
    default:
     break;
   }
   break;
  case ENXIO:
  case EIO :
   switch (myCode){
    case OSD_WDirectory:
    case OSD_WFileNode:
     buffer += "I/O error";
     extCode = ERR_IO;
     break;
    case OSD_WFile :
     buffer += "I/O error or Hang up from terminal";
     extCode = ERR_FIO;
     break;
    default:
     break;
   }
   break;
  case EISDIR :
   switch (myCode){
    case OSD_WFileNode:
    case OSD_WFile :
     buffer += "The File is a Directory";
     extCode = ERR_ISDIR;
     break;
    default:
     break;
    }
    break;

#ifdef SUN
  case EWOULDBLOCK:
   switch (myCode){
    case OSD_WFile:
     buffer += "File is locked";
     extCode = ERR_FLOCKED;
     break;
#ifndef DEB
    default:
     break;
#endif
   }
   break;
#endif

#ifdef IRIX4
  case EWOULDBLOCK:
   switch (myCode){
    case OSD_WFile:
     buffer += "File is locked";
     extCode = ERR_FLOCKED;
     break;
#ifndef DEB
    default:
     break;
#endif
   }
   break;
#endif

  case EAGAIN:
   switch (myCode){
    case OSD_WFile:
     buffer += "No data ready to be read/written";
     extCode = ERR_FAGAIN;
     break;
    default:
     break;
   }
   break;
  case ENOTDIR:
   switch(myCode){
    case OSD_WDirectory:
    case OSD_WFileNode:
    case OSD_WFile:
     buffer += "A component of path is not a Directory";
     extCode = ERR_NOTDIR;
     break;
    default:
     break;
   }
   break;
  case EMLINK:
   switch (myCode){
    case OSD_WDirectory:
    buffer += "Too many links";
    extCode = ERR_DMLINK;
    break;
    default:
     break;
   }
   break;
  case ELOOP :
   switch (myCode){
    case OSD_WDirectory:
    case OSD_WFileNode:
    case OSD_WFile :
     buffer += "Too many symbolic links";
     break;
    default:
     break;
   }
   break;
  case EFAULT:
   buffer += "User error : arguments point to an illegal address";
   extCode = ERR_FAULT;
   break;
  case EFBIG:
   switch (myCode){
    case OSD_WFile:
     buffer += "Exceed process's file size limit or the maximum file size";
     extCode = ERR_FFBIG; 
     break;
    case OSD_WSemaphore:
     buffer += "Internal error : wrong number for this semaphore";
     extCode = ERR_SFBIG;
     break;
    default:
     break;
   }
   break;
  case EINTR:
   buffer += "operation breaked by a signal";
   extCode = ERR_INTR;
   break;
  case EIDRM: 
   buffer += "Semaphore externaly removed from system";
   extCode = ERR_SIDRM;
   break;
  case ENOMEM: 
   buffer += "Not enough memory";
   extCode = ERR_NOMEM;
   break;
  case EMFILE : 
   switch(myCode){   
    case OSD_WFile :
       buffer += "Too many file descriptors are currently in use by this process";
       extCode = ERR_FMFILE;
       break;
    case OSD_WMailBox :
       buffer += "Too many mail boxes opened";
       extCode = ERR_MMFILE;
       break;
    case OSD_WSharedMemory :
       buffer += "The number of shared memory segments attached to the calling process \nwould exceed the system imposed limit.\n";
       buffer += "Try to reconfigure Kernel with greater values";
       extCode = ERR_SMMFILE;
       break;
    default:
     break;
    }
    break;
  case ENAMETOOLONG :
   buffer += "File name too long";
   extCode = ERR_NAMETOOLONG;
   break;
  case ENFILE :
   switch (myCode){
    case OSD_WFile:
     buffer += "Too many files are currently open in the system";
     extCode = ERR_FNFILE;
     break;
    default:
     break;
   }
   break;
  case EXDEV:
   switch (myCode){
    case OSD_WFileNode:
     buffer += "The link named by path2 and the file named by path1 are\n";
     buffer += "on different logical devices (file systems)";
     extCode = ERR_FNXDEV;
     break;
    default:
     break;
   }
   break;
  case ENOENT:
   switch (myCode){
    case OSD_WFileNode:
    case OSD_WFile:
     if (myMessage != "Open") buffer += "File doesn't exist or";
      buffer += "Invalid path (empty string)";
     extCode = ERR_NOENT;
     break;
    case OSD_WDirectory:
     buffer += "A component of the path prefix of path does not exist";
     extCode = ERR_DNOENT;
     break;
    case OSD_WSemaphore:
    case OSD_WSharedMemory:
     buffer += "User error : Has not been created";
     extCode = ERR_SNOENT;
     break;
    default:
     break;
    }
    break;
  case ENOSPC: {
   switch (myCode){
    case OSD_WDirectory:
    case OSD_WFile:
     buffer += "No more free space on file system";
     extCode = ERR_FNOSPC;
     break;
    case OSD_WSharedMemory: {
     buffer += "You exceed number of shared memory allowed.\n";
     buffer += "Try to reconfigure Kernel with greater values";
     extCode = ERR_SMNOSPC;
     break;
   }
    default:
     break;
   }
   break;
 }

//
// AIX maps ENOTEMPTY to EEXIST.  Move this case block to
// the EEXIST case block.
//
#if (!defined(_AIX)) && (!defined(AIX))
  case ENOTEMPTY:
   switch (myCode){
    case OSD_WFileNode:
     buffer += "Directory not empty";
     extCode = ERR_FNNOTEMPTY;
     break;
    default:
     break;
   }
   break;
#endif

  case EEXIST: 
   switch(myCode){
    case OSD_WFileNode:
     buffer += "Directory not empty";
     extCode = ERR_FNNOTEMPTY;
     break;
    case OSD_WFile:
     buffer += "OSD_Create and OSD_Exclude are set and the named file exists";
     extCode = ERR_FEXIST;
     break;
    default:
     buffer += "Identifier already exists for this key";
     extCode = ERR_EXIST;
     break;
   }
   break;
  case E2BIG: 
   buffer += "Too many Semaphore/Shared memory for a process.";
   buffer += "Reconfigure Kernel with greater values";
   extCode = ERR_TOOBIG;
   break;
  case ESRCH  : 
   switch (myCode){
    case OSD_WMailBox :
     buffer += "Server process is dead.\n";
     buffer += "There is no more process to communicate with";
     extCode = ERR_MSRCH;
     break;
    default:
     break;
    }
    break;
   default: {
     Standard_Character buf[255];
     //
     sprintf(buf,"%sUnknowm error #%d",buffer.ToCString(),myErrno);
     TCollection_AsciiString interm(buf);
     buffer = interm;
     extCode = ERR_UNKNOWN;
   }
 }
 buffer += ".\n\n";
 OSD_OSDError::Raise (buffer.ToCString());
}

#else

//------------------------------------------------------------------------
//-------------------  Windows NT sources for OSD_Error ------------------
//------------------------------------------------------------------------

#define STRICT
#include <OSD_Error.hxx>
#include <OSD_ErrorList.hxx>

#include <windows.h>

typedef struct _error_table {

                DWORD            wnt_error;
                Standard_Integer csf_error;

               } ERROR_TABLE;

static int      fPrefix     = 1;
static ostream* errorStream = &cerr;

static ERROR_TABLE commErrorTable [] = {

 { ERROR_INVALID_FUNCTION,      ERR_INVAL       },
 { ERROR_FILE_NOT_FOUND,        ERR_NOENT       },
 { ERROR_PATH_NOT_FOUND,        ERR_NOENT       },
 { ERROR_ACCESS_DENIED,         ERR_ACCESS      },
 { ERROR_ARENA_TRASHED,         ERR_NOMEM       },
 { ERROR_NOT_ENOUGH_MEMORY,     ERR_NOMEM       },
 { ERROR_INVALID_BLOCK,         ERR_NOMEM       },
 { ERROR_BAD_ENVIRONMENT,       ERR_TOOBIG      },
 { ERROR_INVALID_ACCESS,        ERR_INVAL       },
 { ERROR_INVALID_DATA,          ERR_INVAL       },
 { ERROR_INVALID_DRIVE,         ERR_NOENT       },
 { ERROR_CURRENT_DIRECTORY,     ERR_ACCESS      },
 { ERROR_NO_MORE_FILES,         ERR_NOENT       },
 { ERROR_LOCK_VIOLATION,        ERR_ACCESS      },
 { ERROR_SHARING_VIOLATION,     ERR_ACCESS      },
 { ERROR_BAD_NETPATH,           ERR_NOENT       },
 { ERROR_NETWORK_ACCESS_DENIED, ERR_ACCESS      },
 { ERROR_BAD_NET_NAME,          ERR_NOENT       },
 { ERROR_FILE_EXISTS,           ERR_EXIST       },
 { ERROR_CANNOT_MAKE,           ERR_ACCESS      },
 { ERROR_FAIL_I24,              ERR_ACCESS      },
 { ERROR_INVALID_PARAMETER,     ERR_INVAL       },
 { ERROR_DRIVE_LOCKED,          ERR_ACCESS      },
 { ERROR_INVALID_HANDLE,        ERR_INVAL       },
 { ERROR_NEGATIVE_SEEK,         ERR_INVAL       },
 { ERROR_SEEK_ON_DEVICE,        ERR_ACCESS      },
 { ERROR_NOT_LOCKED,            ERR_ACCESS      },
 { ERROR_BAD_PATHNAME,          ERR_NOENT       },
 { ERROR_LOCK_FAILED,           ERR_ACCESS      },
 { ERROR_ALREADY_EXISTS,        ERR_EXIST       },
 { ERROR_FILENAME_EXCED_RANGE,  ERR_NOENT       },
 { ERROR_NOT_ENOUGH_QUOTA,      ERR_QUOT        },
 { ERROR_IO_DEVICE,             ERR_IO          },
 { ERROR_INVALID_BLOCK,         ERR_FAULT       },
 { ERROR_BAD_THREADID_ADDR,     ERR_FAULT       },
 { ERROR_INVALID_ADDRESS,       ERR_FAULT       },
 { ERROR_MAPPED_ALIGNMENT,      ERR_FAULT       },
 { ERROR_BUFFER_OVERFLOW,       ERR_NAMETOOLONG }

};

#define COMM_ERR_TABLE_SIZE (  sizeof ( commErrorTable ) / sizeof ( commErrorTable[ 0 ] )  )

static ERROR_TABLE dirErrorTable[] = {

 { ERROR_FILE_NOT_FOUND,       ERR_NOENT },
 { ERROR_PATH_NOT_FOUND,       ERR_NOENT },
 { ERROR_INVALID_DRIVE,        ERR_NOENT },
 { ERROR_NO_MORE_FILES,        ERR_NOENT },
 { ERROR_BAD_NETPATH,          ERR_NOENT },
 { ERROR_BAD_NET_NAME,         ERR_NOENT },
 { ERROR_BAD_PATHNAME,         ERR_NOENT },
 { ERROR_FILENAME_EXCED_RANGE, ERR_NOENT }

};

#define DIR_ERR_TABLE_SIZE (  sizeof ( dirErrorTable ) / sizeof ( dirErrorTable[ 0 ] )  )

static ERROR_TABLE fileErrorTable[] = {

 { ERROR_INVALID_HANDLE,        ERR_FBADF   },
 { ERROR_INVALID_TARGET_HANDLE, ERR_FBADF   },
 { ERROR_DIRECT_ACCESS_HANDLE,  ERR_FBADF   },
 { ERROR_FILE_EXISTS,           ERR_EXIST   },
 { ERROR_ALREADY_EXISTS,        ERR_EXIST   },
 { ERROR_TOO_MANY_OPEN_FILES,   ERR_FMFILE  },
 { ERROR_INVALID_FUNCTION,      ERR_FINVAL  },
 { ERROR_INVALID_ACCESS,        ERR_FINVAL  },
 { ERROR_INVALID_DATA,          ERR_FINVAL  },
 { ERROR_INVALID_PARAMETER,     ERR_FINVAL  },
 { ERROR_INVALID_HANDLE,        ERR_FINVAL  },
 { ERROR_NEGATIVE_SEEK,         ERR_FINVAL  },
 { ERROR_IO_PENDING,            ERR_FAGAIN  },
 { ERROR_WRITE_FAULT,           ERR_FIO     },
 { ERROR_READ_FAULT,            ERR_FIO     },
 { ERROR_NET_WRITE_FAULT,       ERR_FIO     },
 { ERROR_IO_DEVICE,             ERR_FIO     },
 { ERROR_LOCK_VIOLATION,        ERR_FLOCKED },
 { ERROR_LOCK_FAILED,           ERR_FLOCKED }

};

#define FILE_ERR_TABLE_SIZE (  sizeof ( fileErrorTable ) / sizeof ( fileErrorTable[ 0 ] )  )

static ERROR_TABLE fileNodeErrorTable[] = {

 { ERROR_INVALID_FUNCTION,      ERR_FNINVAL    },
 { ERROR_INVALID_ACCESS,        ERR_FNINVAL    },
 { ERROR_INVALID_DATA,          ERR_FNINVAL    },
 { ERROR_INVALID_PARAMETER,     ERR_FNINVAL    },
 { ERROR_INVALID_HANDLE,        ERR_FNINVAL    },
 { ERROR_NEGATIVE_SEEK,         ERR_FNINVAL    },
 { ERROR_DISK_FULL,             ERR_FNOSPC     },
 { ERROR_DIR_NOT_EMPTY,         ERR_FNNOTEMPTY },
 { ERROR_NOT_SAME_DEVICE,       ERR_FNXDEV     }

};

#define FILE_NODE_ERR_TABLE_SIZE (  sizeof ( fileNodeErrorTable ) /    \
                                    sizeof ( fileNodeErrorTable[ 0 ] ) \
                                 )

static Standard_Integer _get_comm_error ( DWORD );

OSD_Error :: OSD_Error () {

 Reset ();

}  // end constructor ( 1 )

void OSD_Error :: Perror () {

 Standard_Character buff[ 32 ];
 Standard_CString   ptr;

 if ( fPrefix ) {
 
  lstrcpy (  buff, TEXT( "Error ( " )  );

  switch ( myCode ) {
  
   case OSD_WDirectoryIterator:

    ptr = TEXT( "OSD_DirectoryIterator" );

   break;

   case OSD_WDirectory:

    ptr = TEXT( "OSD_Directory" );

   break;

   case OSD_WFileIterator:

    ptr = TEXT( "OSD_FileIterator" );

   break;

   case OSD_WFile:
  
    ptr = TEXT( "OSD_File" );

   break;

   case OSD_WFileNode:

    ptr = TEXT( "OSD_FileNode" );

   break;

   case OSD_WHost:

    ptr = TEXT( "OSD_Host" );

   break;

   case OSD_WProcess:

    ptr = TEXT( "OSD_Environment" );

   break;

   case OSD_WEnvironmentIterator:

    ptr = TEXT( "OSD_EnvironmentIterator" );

   break;

   case OSD_WEnvironment:

    ptr = TEXT( "OSD_Environment" );

   break;

   case OSD_WSharedMemory:

    ptr = TEXT( "OSD_SharedMemory" );

   break;

   case OSD_WDisk:

    ptr = TEXT( "OSD_Disk" );

   break;

   default:

    ptr = TEXT( "Unknown" );

  }  // end switch

  lstrcat ( buff, ptr );
  lstrcat (  buff, TEXT( " )" )  );
  ( *errorStream ) << buff;
 
 }  // end if ( fPrefix . . . )

 ( *errorStream ) << TEXT( ": " ) << myMessage.ToCString () << endl << flush;

}  // end OSD_Error :: Perror

void OSD_Error :: SetValue (
                   const Standard_Integer Errcode,
                   const Standard_Integer From,
                   const TCollection_AsciiString& Message
                  ) {

 int i;

 myErrno   = Errcode;
 myCode    = ( OSD_WhoAmI )From;
 myMessage = Message;

 switch ( From ) {
 
  case OSD_WDirectory:

   for ( i = 0; i < DIR_ERR_TABLE_SIZE; ++i )

    if ( dirErrorTable[ i ].wnt_error == ( DWORD )Errcode ) {

     extCode = dirErrorTable[ i ].csf_error;
     break;

   }  // end if

  if ( i == DIR_ERR_TABLE_SIZE ) extCode = _get_comm_error ( Errcode );

  break;

  case OSD_WFile:

   for ( i = 0; i < FILE_ERR_TABLE_SIZE; ++i )

    if ( fileErrorTable[ i ].wnt_error == ( DWORD )Errcode ) {

     extCode = fileErrorTable[ i ].csf_error;
     break;

   }  // end if

  if ( i == FILE_ERR_TABLE_SIZE ) extCode = _get_comm_error ( Errcode );

  break;
 
  case OSD_WFileNode:

   for ( i = 0; i < FILE_NODE_ERR_TABLE_SIZE; ++i )

    if ( fileNodeErrorTable[ i ].wnt_error == ( DWORD )Errcode ) {

     extCode = fileNodeErrorTable[ i ].csf_error;
     break;

   }  // end if

  if ( i == FILE_NODE_ERR_TABLE_SIZE ) extCode = _get_comm_error ( Errcode );

  break;

  default:

   extCode = _get_comm_error ( Errcode );

 }  // end switch

}  // end OSD_Error :: SetValue

Standard_Integer OSD_Error :: Error () const {

 return extCode;

}  // end OSD_Error :: Error

Standard_Boolean OSD_Error :: Failed () const {

 return myErrno == ERROR_SUCCESS ? Standard_False : Standard_True;

}  // end OSD_Error :: Failed

void OSD_Error :: Reset () {

 myErrno = ERROR_SUCCESS; 
 ( *errorStream ).clear ();
 ( *errorStream ).seekp ( 0 );
 ( *errorStream ).clear ();

}  // end OSD_Error :: Reset

void SetErrorStream ( ostream* errStream ) {

 errorStream = errStream;

}  // end SetErrorStream

void EnablePrefix ( int fEnable ) {

 fPrefix = fEnable;

}  // end EnablePrefix

int ErrorPrefix ( void ) {

 return fPrefix;

}  // end ErrorPrefix

ostream* ErrorStream ( void ) {

 return errorStream;

}  // end ErrorStream

static Standard_Integer _get_comm_error ( DWORD dwCode ) {

 int              i;
 Standard_Integer retVal = ERR_SURPRISE;

 for ( i = 0; i < COMM_ERR_TABLE_SIZE; ++i )

  if ( commErrorTable[ i ].wnt_error == ( DWORD )dwCode ) {

   retVal = commErrorTable[ i ].csf_error;
   break;

  }  // end if

 return retVal;

}  // end _get_comm_error

#endif