int main() { INIT_EXCEPTIONS(); puts ("Testing stack unwinding and illegal rethrow out of main."); foo foo_main ("Main"); #ifdef MUST_EXIT signal (SIGABRT, catch_abort); #endif try { foo foo_try ("Try"); throw (Exception()); } catch (Exception &,e) { puts ("Caught exception."); foo foo_catch ("Catch"); rethrow; } end_try; }
int main() { INIT_EXCEPTIONS(); #ifdef MUST_EXIT signal (SIGABRT, catch_abort); #endif puts ("Throw with no exception..."); rethrow; }
int main (int, char *[]) { INIT_EXCEPTIONS(); UAS_Common::initialize (); UAS_List<UAS_String> locList = UAS_Common::rootLocators (); for (int i = 0; i < locList.length(); i ++) { UAS_String &cur = locList[i]; UAS_Pointer<UAS_Common> curDoc = UAS_Common::create(cur); UAS_Pointer<UAS_Collection> curCol = (UAS_Collection *) ((UAS_Common *) curDoc); printLocs (curCol->root(), 0); curDoc = curCol->root(); curCol = 0; UAS_Common::destroy (curDoc); } UAS_Common::finalize (); return 0; }
int main() { INIT_EXCEPTIONS(); #ifdef MUST_EXIT signal (SIGABRT, catch_abort); #endif set_terminate (terminate_handler); try { puts ("Trying something"); throw (Exception()); } end_try; }
int main() { INIT_EXCEPTIONS(); #ifdef MUST_EXIT signal (SIGABRT, catch_abort); #endif printf ("Sucking up a lot of memory to test internal allocator.\n"); try { // Should run out of memory trying to allocate this one. throw (BigException()); } catch (Exception &,e) { puts ("Caught an exception reference"); } catch (Exception *,e)
int main() { INIT_EXCEPTIONS(); puts ("Testing throw from error handler."); #ifdef MUST_EXIT signal (SIGABRT, catch_abort); #endif Exceptions::set_error_handler (error_handler); try { puts ("Trying something"); throw (Exception()); } end_try; }
int main() { INIT_EXCEPTIONS(); #ifdef MUST_EXIT signal (SIGABRT, catch_abort); #endif puts ("Testing nested try in catch."); try { foo bar; throw (Exception()); } catch (Exception &,e) { puts ("Cleaning up"); cleanup(); } end_try; }
int main() { INIT_EXCEPTIONS(); printf ("Sizeof Destructable = %d\n", (int)sizeof (Destructable)); puts ("Test of throw from multiple member constructor."); #ifdef MUST_EXIT signal (SIGABRT, catch_abort); #endif try { do_something(); } // Do it right in this section. catch (ErrorString &,e) { puts ("Caught exception back in main."); puts (e.msg); } catch (Exception &,e)
//------------------------------------------------ main(int argc, char **argv) { INIT_EXCEPTIONS(); OLIAS_DB mmdb_handle; info_lib *InfoLib; char checkVersionStr [ 16 ]; char installVersionStr [ 16 ]; char locatorStr[64]; dbgLevel = dbgInit(); try { if ( argc < 2 ) { cerr << "Usage : valBase checkBase installBase\n"; exit (1); } char *checkBaseStr = argv[1]; char *installBaseStr = argv[2]; DBG(10) cerr << "(DEBUG) checkBase = " << checkBaseStr << endl; DBG(10) cerr << "(DEBUG) installBase = " << installBaseStr << endl; // first construct the info_base ptr for installBase InfoLib = mmdb_handle.openInfoLib(getenv("MMDB_PATH")); assert ( InfoLib != NULL ); info_base *installBase = InfoLib->get_info_base ( installBaseStr ); if ( !installBase ) throw(stringException("NULL infobase ptr for installation infobase")); // construct the info_base ptr for checkBase info_base *checkBase = InfoLib->get_info_base ( checkBaseStr ); if ( !checkBase ) throw(stringException("NULL infobase ptr for check infobase")); // check the data version number mm_version &checkVersion = checkBase->data_version(); short major_version_check = checkVersion.major_version(); short minor_version_check = checkVersion.minor_version(); sprintf ( checkVersionStr, "%d%d", major_version_check, minor_version_check ); int checkVersionNum = atoi ( checkVersionStr ); DBG(10) cerr << "(DEBUG) checkBaseVersion = " << checkVersionNum << endl; mm_version &installVersion = installBase->data_version(); short major_version_install = installVersion.major_version(); short minor_version_install = installVersion.minor_version(); sprintf ( installVersionStr, "%d%d", major_version_install, minor_version_install ); int installVersionNum = atoi ( installVersionStr ); DBG(10) cerr << "(DEBUG) installVersionNum = " << installVersionNum << endl; // Now perform the version checking if ( installVersionNum == 10 ) { if ( checkVersionNum >= 11 ) { cerr << "(ERROR) Data version mismatch\n"; cerr << " " << checkBaseStr << " version = " << major_version_check << "." << minor_version_check << endl; cerr << " " << installBaseStr << " version = " << major_version_install << "." << minor_version_install << endl; exit ( 1 ); } } else if ( checkVersionNum == 10 ) { if ( installVersionNum >= 11 ) { cerr << "(ERROR) Data version mismatch\n"; cerr << " " << checkBaseStr << " version = " << major_version_check << "." << minor_version_check << endl; cerr << " " << installBaseStr << " version = " << major_version_install << "." << minor_version_install << endl; exit ( 1 ); } } // Now to check locators iterator *it = checkBase->first(LOCATOR_SET_NAME, LOCATOR_CODE ); int DupLocFound=0; while ( *it ) { locator_smart_ptr x(checkBase, checkBase->get_oid(*it)); strcpy ( locatorStr, x.inside_node_locator_str() ); DBG(10) cerr << "(DEBUG) locatorStr = " << locatorStr << endl; // check this locator value with the installation infobase locator_smart_ptr loc(installBase, locatorStr); if (! strcmp(loc.inside_node_locator_str(), locatorStr)) { cerr << "(ERROR) Duplicate locator [ " << locatorStr << " ] found in " << installBaseStr << endl; DupLocFound = 1; } checkBase->next(*it); } // clean up phase delete it; delete InfoLib; if ( DupLocFound ) { exit ( 1 ); } exit (0); } catch ( mmdbException &, e ) { debug(cerr, e ); abort(); } end_try; }
main(int argc, char **argv) { INIT_EXCEPTIONS(); set_new_handler ( FreeStoreException ); int ret = 1; const char *progname = argv[0]; int compressed = 0; #ifdef FISH_DEBUG DBUG_PROCESS(argv[0]); if(getenv("FISH_DBUG")) DBUG_PUSH(getenv("FISH_DBUG")); #endif argv++; argc--; while(argc > 0 && argv[0][0] == '-'){ const char *opt = argv[0]; argv++; argc--; if(strcmp(opt, "-compressed") == 0){ compressed = 1; } else{ usage(progname); } } if(argc == 2){ char *bookcaseDir = argv[0]; char *infobaseDir = argv[1]; try{ BookCaseDB db(bookcaseDir); const char *infolibDir; const char *bcname; split_path(infobaseDir, infolibDir, bcname); OLIAS_DB mmdb_handle; info_lib *mmdb = mmdb_handle.openInfoLib(infolibDir, bcname); // 30 will be enough for now #define COMPRESSED_AGENT_SIZE 30 char comp_agent[ COMPRESSED_AGENT_SIZE ]; if ( compressed ) { for ( int i = 0; i < COMPRESSED_AGENT_SIZE; i++ ) { comp_agent[i] = 0; } ostrstream str_buf( comp_agent, COMPRESSED_AGENT_SIZE ); info_base *bcptr = mmdb->get_info_base(bcname); handler *x = (bcptr->get_obj_dict()).get_handler( form("%s.%s", bcname, "ps.dict")); x->its_oid().asciiOut(str_buf); } hashTable<CC_String, BTCollectable> hd(hash_func); locator_table( db, hd); /* throw exception if duplicate locator is found */ DBTable *nodeMeta = db.table(BookCaseDB::NodeMeta, DB::READ); DBCursor node_cursor( *nodeMeta ); writeCCF(db, mmdb, bcname); writeBooks(db, mmdb, bcname, &node_cursor, compressed, comp_agent, hd); writeLCF(db, mmdb, bcname, hd); hd.clearAndDestroy(); ret = 0; } catch(PosixError&, pe){ fprintf(stderr, "%s: error on %s: %s\n", progname, bookcaseDir, pe.msg()); } catch(Unexpected&, pe) {
//--------------------------------------------------------------------- int main(int argc, char **argv) { INIT_EXCEPTIONS(); /* can't seem to get C++ initialization stuff to do this... */ OLAF::init(); set_new_handler( FreeStoreException ); int ret = 1; #ifdef FISH_DEBUG DBUG_PROCESS(argv[0]); if(getenv("FISH_DBUG")) DBUG_PUSH(getenv("FISH_DBUG")); #endif if(argc == 4){ const char *toc_option = argv[1]; const char *infolib = argv[2]; const char *srcdir = argv[3]; Dispatch::tmpdir = infolib; Dispatch::srcdir = srcdir; if ( !strcmp(toc_option, "toc") ) { Dispatch::tocgen_only = 1; } else if ( !strcmp(toc_option, "all") ) { Dispatch::tocgen_only = 0; } else { fprintf(stderr, "usage: NodeParse [ tocgen_only | all ] <database-dir> <source-dir>\n"); exit(1); } /* * Add the . directory as a default if the file is not found in scrdir */ SearchPath *sptable = new SearchPath( srcdir, ".", 0 ); Dispatch::search_path_table = sptable; Task *t = new BookCaseTask( infolib ); Stack<int> *istack = new Stack<int>; Dispatch::setRoot(t, istack); mtry{ extern int yylex(); yylex(); ret = 0; } mcatch(Unexpected&, u) { mtry { Dispatch::tok->reportError(Token::User, Token::Fatal, "markup error: %s", u.msg()); } mcatch(ErrorReported&, e) { if ( e.f_severity == Token::Fatal ) { exit(1); } }end_try; } mcatch(PosixError&, pe) { fprintf(stderr, "(ERROR) %s\n", pe.msg() ); exit(1); }
main(int argc, char** argv ) { INIT_EXCEPTIONS(); StyleSheet ss ; g_validation_mode = true; if ( argc != 4 && argc != 3 ) { cerr << form("usage: %s online|hardcopy styleSheetFile [FeatureDefinitionFile]\n", argv[0]); quit(1); } try { if ( strcasecmp(argv[1], "hardcopy") == 0 ) gRenderer = new RendererHCV(); else if ( strcasecmp(argv[1], "online") == 0 ) gRenderer = 0; else { cerr << form("bad validation option: %s\n", argv[1]); quit(1); } if ( argc == 4 ) { defStream = new fstream(argv[3], ios::in); if ( !( *defStream ) ) { cerr << form("bad feature definition file name: %s\n", argv[3]); quit(1); } } else { char* path = getenv("DTINFO_HOME"); if ( path == 0 ) { cerr << "DTINFO_HOME is undefined.\n"; quit(1); } char* spec_file_path = form("%s/infolib/etc/%s.feature.spec", path, argv[1]); defStream = new fstream(spec_file_path, ios::in); if ( !( *defStream ) ) { cerr << form("bad feature definition file name: %s", spec_file_path); quit(1); } } defStream -> unsetf(ios::skipws); g_FeatureDefDictionary = new featureDefDictionary(); *defStream >> *g_FeatureDefDictionary; //cerr << *g_FeatureDefDictionary; } catch_any() { cerr << "\nfeature definition has error.\n"; quit(1); } end_try; try { fstream* styleStream = new fstream(argv[2], ios::in); if ( !(*styleStream) ) { cerr << form("bad stylesheet file name: %s\n", argv[2]); quit(1); } styleStream -> unsetf(ios::skipws); g_stylein = styleStream; int ok = styleparse(); delete styleStream; if ( ok != 0 || g_hasSemanticError == true ) { report_error_location(); quit(1); } //debug(cerr, *gPathTab); } catch_any() { report_error_location(); quit(1); } end_try; MESSAGE(cerr, "\nThe style sheet is ok."); quit(0); }