| 1 |
|
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
#include "cddefines.h" |
|---|
| 6 |
#include "cddrive.h" |
|---|
| 7 |
|
|---|
| 8 |
int main( int argc, char *argv[] ) |
|---|
| 9 |
{ |
|---|
| 10 |
DEBUG_ENTRY( "main()" ); |
|---|
| 11 |
|
|---|
| 12 |
try { |
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
bool lgBad; |
|---|
| 19 |
long nleft; |
|---|
| 20 |
char Version[200]; |
|---|
| 21 |
|
|---|
| 22 |
|
|---|
| 23 |
for( int i=0; i < 1; ++i ) |
|---|
| 24 |
{ |
|---|
| 25 |
|
|---|
| 26 |
cdInit(); |
|---|
| 27 |
cdVersion( Version ); |
|---|
| 28 |
|
|---|
| 29 |
|
|---|
| 30 |
nleft = cdRead( "test" ); |
|---|
| 31 |
|
|---|
| 32 |
lgBad = cdDrive(); |
|---|
| 33 |
} |
|---|
| 34 |
|
|---|
| 35 |
cdEXIT(lgBad); |
|---|
| 36 |
|
|---|
| 37 |
|
|---|
| 38 |
|
|---|
| 39 |
} |
|---|
| 40 |
|
|---|
| 41 |
catch( bad_alloc ) |
|---|
| 42 |
{ |
|---|
| 43 |
fprintf( ioQQQ, " DISASTER - A memory allocation has failed. Bailing out...\n" ); |
|---|
| 44 |
cdExit(EXIT_FAILURE); |
|---|
| 45 |
} |
|---|
| 46 |
catch( out_of_range& e ) |
|---|
| 47 |
{ |
|---|
| 48 |
fprintf( ioQQQ, " DISASTER - An out_of_range exception was caught, what() = %s. Bailing out...\n", |
|---|
| 49 |
e.what() ); |
|---|
| 50 |
cdExit(EXIT_FAILURE); |
|---|
| 51 |
} |
|---|
| 52 |
catch( bad_assert& e ) |
|---|
| 53 |
{ |
|---|
| 54 |
MyAssert( e.file(), e.line() ); |
|---|
| 55 |
cdExit(EXIT_FAILURE); |
|---|
| 56 |
} |
|---|
| 57 |
#ifdef CATCH_SIGNAL |
|---|
| 58 |
catch( bad_signal& e ) |
|---|
| 59 |
{ |
|---|
| 60 |
if( ioQQQ != NULL ) |
|---|
| 61 |
{ |
|---|
| 62 |
if( e.sig() == SIGINT ) |
|---|
| 63 |
fprintf( ioQQQ, " User interrupt request. Bailing out...\n" ); |
|---|
| 64 |
else if( e.sig() == SIGTERM ) |
|---|
| 65 |
fprintf( ioQQQ, " Termination request. Bailing out...\n" ); |
|---|
| 66 |
else if( e.sig() == SIGILL ) |
|---|
| 67 |
fprintf( ioQQQ, " DISASTER - An illegal instruction was found. Bailing out...\n" ); |
|---|
| 68 |
else if( e.sig() == SIGFPE ) |
|---|
| 69 |
fprintf( ioQQQ, " DISASTER - A floating point exception occurred. Bailing out...\n" ); |
|---|
| 70 |
else if( e.sig() == SIGSEGV ) |
|---|
| 71 |
fprintf( ioQQQ, " DISASTER - A segmentation violation occurred. Bailing out...\n" ); |
|---|
| 72 |
# ifdef SIGBUS |
|---|
| 73 |
else if( e.sig() == SIGBUS ) |
|---|
| 74 |
fprintf( ioQQQ, " DISASTER - A bus error occurred. Bailing out...\n" ); |
|---|
| 75 |
# endif |
|---|
| 76 |
else |
|---|
| 77 |
fprintf( ioQQQ, " DISASTER - A signal %d was caught. Bailing out...\n", e.sig() ); |
|---|
| 78 |
|
|---|
| 79 |
} |
|---|
| 80 |
cdExit(EXIT_FAILURE); |
|---|
| 81 |
} |
|---|
| 82 |
#endif |
|---|
| 83 |
catch( cloudy_exit& e ) |
|---|
| 84 |
{ |
|---|
| 85 |
if( ioQQQ != NULL ) |
|---|
| 86 |
{ |
|---|
| 87 |
ostringstream oss; |
|---|
| 88 |
oss << " [Stop in " << e.routine(); |
|---|
| 89 |
oss << " at " << e.file() << ":" << e.line(); |
|---|
| 90 |
if( e.exit_status() == 0 ) |
|---|
| 91 |
oss << ", Cloudy exited OK]"; |
|---|
| 92 |
else |
|---|
| 93 |
oss << ", something went wrong]"; |
|---|
| 94 |
fprintf( ioQQQ, "%s\n", oss.str().c_str() ); |
|---|
| 95 |
} |
|---|
| 96 |
cdExit(e.exit_status()); |
|---|
| 97 |
} |
|---|
| 98 |
catch( exception& e ) |
|---|
| 99 |
{ |
|---|
| 100 |
fprintf( ioQQQ, " DISASTER - An unknown exception was caught, what() = %s. Bailing out...\n", |
|---|
| 101 |
e.what() ); |
|---|
| 102 |
cdExit(EXIT_FAILURE); |
|---|
| 103 |
} |
|---|
| 104 |
|
|---|
| 105 |
catch( ... ) |
|---|
| 106 |
{ |
|---|
| 107 |
fprintf( ioQQQ, " DISASTER - An unknown exception was caught. Bailing out...\n" ); |
|---|
| 108 |
cdExit(EXIT_FAILURE); |
|---|
| 109 |
} |
|---|
| 110 |
} |
|---|