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 | |
28 | OSD_Error::OSD_Error(){ |
29 | myErrno = 0; |
30 | } |
31 | |
32 | |
33 | void OSD_Error::Reset(){ |
34 | myErrno = 0; |
35 | } |
36 | |
37 | Standard_Boolean OSD_Error::Failed()const{ |
38 | if (myErrno == 0) return (Standard_False); |
39 | else return (Standard_True); |
40 | } |
41 | |
42 | |
43 | |
44 | void 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 | |
54 | Standard_Integer OSD_Error::Error()const{ |
55 | return(extCode); |
56 | } |
57 | |
58 | |
59 | void 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 | |
513 | typedef struct _error_table { |
514 | |
515 | DWORD wnt_error; |
516 | Standard_Integer csf_error; |
517 | |
518 | } ERROR_TABLE; |
519 | |
520 | static int fPrefix = 1; |
521 | static ostream* errorStream = &cerr; |
522 | |
523 | static 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 | |
566 | #define COMM_ERR_TABLE_SIZE ( sizeof ( commErrorTable ) / sizeof ( commErrorTable[ 0 ] ) ) |
567 | |
568 | static 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 | |
581 | #define DIR_ERR_TABLE_SIZE ( sizeof ( dirErrorTable ) / sizeof ( dirErrorTable[ 0 ] ) ) |
582 | |
583 | static 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 | |
609 | static 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 | |
623 | #define FILE_NODE_ERR_TABLE_SIZE ( sizeof ( fileNodeErrorTable ) / \ |
624 | sizeof ( fileNodeErrorTable[ 0 ] ) \ |
625 | ) |
626 | |
627 | static Standard_Integer _get_comm_error ( DWORD ); |
628 | |
629 | OSD_Error :: OSD_Error () { |
630 | |
631 | Reset (); |
632 | |
633 | } // end constructor ( 1 ) |
634 | |
635 | void OSD_Error :: Perror () { |
636 | |
637 | Standard_Character buff[ 32 ]; |
638 | Standard_CString ptr; |
639 | |
640 | if ( fPrefix ) { |
641 | |
642 | lstrcpy ( buff, TEXT( "Error ( " ) ); |
643 | |
644 | switch ( myCode ) { |
645 | |
646 | case OSD_WDirectoryIterator: |
647 | |
648 | ptr = TEXT( "OSD_DirectoryIterator" ); |
649 | |
650 | break; |
651 | |
652 | case OSD_WDirectory: |
653 | |
654 | ptr = TEXT( "OSD_Directory" ); |
655 | |
656 | break; |
657 | |
658 | case OSD_WFileIterator: |
659 | |
660 | ptr = TEXT( "OSD_FileIterator" ); |
661 | |
662 | break; |
663 | |
664 | case OSD_WFile: |
665 | |
666 | ptr = TEXT( "OSD_File" ); |
667 | |
668 | break; |
669 | |
670 | case OSD_WFileNode: |
671 | |
672 | ptr = TEXT( "OSD_FileNode" ); |
673 | |
674 | break; |
675 | |
676 | case OSD_WHost: |
677 | |
678 | ptr = TEXT( "OSD_Host" ); |
679 | |
680 | break; |
681 | |
682 | case OSD_WProcess: |
683 | |
684 | ptr = TEXT( "OSD_Environment" ); |
685 | |
686 | break; |
687 | |
688 | case OSD_WEnvironmentIterator: |
689 | |
690 | ptr = TEXT( "OSD_EnvironmentIterator" ); |
691 | |
692 | break; |
693 | |
694 | case OSD_WEnvironment: |
695 | |
696 | ptr = TEXT( "OSD_Environment" ); |
697 | |
698 | break; |
699 | |
700 | case OSD_WSharedMemory: |
701 | |
702 | ptr = TEXT( "OSD_SharedMemory" ); |
703 | |
704 | break; |
705 | |
706 | case OSD_WDisk: |
707 | |
708 | ptr = TEXT( "OSD_Disk" ); |
709 | |
710 | break; |
711 | |
712 | default: |
713 | |
714 | ptr = TEXT( "Unknown" ); |
715 | |
716 | } // end switch |
717 | |
718 | lstrcat ( buff, ptr ); |
719 | lstrcat ( buff, TEXT( " )" ) ); |
720 | ( *errorStream ) << buff; |
721 | |
722 | } // end if ( fPrefix . . . ) |
723 | |
724 | ( *errorStream ) << TEXT( ": " ) << myMessage.ToCString () << endl << flush; |
725 | |
726 | } // end OSD_Error :: Perror |
727 | |
728 | void OSD_Error :: SetValue ( |
729 | const Standard_Integer Errcode, |
730 | const Standard_Integer From, |
731 | const TCollection_AsciiString& Message |
732 | ) { |
733 | |
734 | int i; |
735 | |
736 | myErrno = Errcode; |
737 | myCode = ( OSD_WhoAmI )From; |
738 | myMessage = Message; |
739 | |
740 | switch ( From ) { |
741 | |
742 | case OSD_WDirectory: |
743 | |
744 | for ( i = 0; i < DIR_ERR_TABLE_SIZE; ++i ) |
745 | |
746 | if ( dirErrorTable[ i ].wnt_error == ( DWORD )Errcode ) { |
747 | |
748 | extCode = dirErrorTable[ i ].csf_error; |
749 | break; |
750 | |
751 | } // end if |
752 | |
753 | if ( i == DIR_ERR_TABLE_SIZE ) extCode = _get_comm_error ( Errcode ); |
754 | |
755 | break; |
756 | |
757 | case OSD_WFile: |
758 | |
759 | for ( i = 0; i < FILE_ERR_TABLE_SIZE; ++i ) |
760 | |
761 | if ( fileErrorTable[ i ].wnt_error == ( DWORD )Errcode ) { |
762 | |
763 | extCode = fileErrorTable[ i ].csf_error; |
764 | break; |
765 | |
766 | } // end if |
767 | |
768 | if ( i == FILE_ERR_TABLE_SIZE ) extCode = _get_comm_error ( Errcode ); |
769 | |
770 | break; |
771 | |
772 | case OSD_WFileNode: |
773 | |
774 | for ( i = 0; i < FILE_NODE_ERR_TABLE_SIZE; ++i ) |
775 | |
776 | if ( fileNodeErrorTable[ i ].wnt_error == ( DWORD )Errcode ) { |
777 | |
778 | extCode = fileNodeErrorTable[ i ].csf_error; |
779 | break; |
780 | |
781 | } // end if |
782 | |
783 | if ( i == FILE_NODE_ERR_TABLE_SIZE ) extCode = _get_comm_error ( Errcode ); |
784 | |
785 | break; |
786 | |
787 | default: |
788 | |
789 | extCode = _get_comm_error ( Errcode ); |
790 | |
791 | } // end switch |
792 | |
793 | } // end OSD_Error :: SetValue |
794 | |
795 | Standard_Integer OSD_Error :: Error () const { |
796 | |
797 | return extCode; |
798 | |
799 | } // end OSD_Error :: Error |
800 | |
801 | Standard_Boolean OSD_Error :: Failed () const { |
802 | |
803 | return myErrno == ERROR_SUCCESS ? Standard_False : Standard_True; |
804 | |
805 | } // end OSD_Error :: Failed |
806 | |
807 | void OSD_Error :: Reset () { |
808 | |
809 | myErrno = ERROR_SUCCESS; |
810 | ( *errorStream ).clear (); |
811 | ( *errorStream ).seekp ( 0 ); |
812 | ( *errorStream ).clear (); |
813 | |
814 | } // end OSD_Error :: Reset |
815 | |
816 | void SetErrorStream ( ostream* errStream ) { |
817 | |
818 | errorStream = errStream; |
819 | |
820 | } // end SetErrorStream |
821 | |
822 | void EnablePrefix ( int fEnable ) { |
823 | |
824 | fPrefix = fEnable; |
825 | |
826 | } // end EnablePrefix |
827 | |
828 | int ErrorPrefix ( void ) { |
829 | |
830 | return fPrefix; |
831 | |
832 | } // end ErrorPrefix |
833 | |
834 | ostream* ErrorStream ( void ) { |
835 | |
836 | return errorStream; |
837 | |
838 | } // end ErrorStream |
839 | |
840 | static Standard_Integer _get_comm_error ( DWORD dwCode ) { |
841 | |
842 | int i; |
843 | Standard_Integer retVal = ERR_SURPRISE; |
844 | |
845 | for ( i = 0; i < COMM_ERR_TABLE_SIZE; ++i ) |
846 | |
847 | if ( commErrorTable[ i ].wnt_error == ( DWORD )dwCode ) { |
848 | |
849 | retVal = commErrorTable[ i ].csf_error; |
850 | break; |
851 | |
852 | } // end if |
853 | |
854 | return retVal; |
855 | |
856 | } // end _get_comm_error |
857 | |
858 | #endif |