コード例 #1
0
SkOSWindow::SkOSWindow(void* hWnd) : fHWND(hWnd)
{	
	static const EventTypeSpec  gTypes[] = {
		{ kEventClassKeyboard,  kEventRawKeyDown			},
        { kEventClassKeyboard,  kEventRawKeyUp              },
		{ kEventClassMouse,		kEventMouseDown				},
		{ kEventClassMouse,		kEventMouseDragged			},
		{ kEventClassMouse,		kEventMouseUp				},
		{ kEventClassTextInput, kEventTextInputUnicodeForKeyEvent   },
		{ kEventClassWindow,	kEventWindowBoundsChanged	},
		{ kEventClassWindow,	kEventWindowDrawContent		},
		{ SK_MacEventClass,		SK_MacEventKind				}
	};

	EventHandlerUPP handlerUPP = NewEventHandlerUPP(SkOSWindow::EventHandler);
	int				count = SK_ARRAY_COUNT(gTypes);
	OSStatus		result;

	result = InstallEventHandler(GetWindowEventTarget((WindowRef)hWnd), handlerUPP,
						count, gTypes, this, nil);
	SkASSERT(result == noErr);

	gCurrOSWin = this;
	gCurrEventQ = GetCurrentEventQueue();
	gEventTarget = GetWindowEventTarget((WindowRef)hWnd);

	static bool gOnce = true;
	if (gOnce) {
		gOnce = false;
		gPrevNewHandler = set_new_handler(sk_new_handler);
	}
}
コード例 #2
0
ファイル: server.cpp プロジェクト: acruikshank/mongo
    void setupSignalHandlers() {
        setupSIGTRAPforGDB();
        setupCoreSignals();

        signal(SIGTERM, sighandler);
        signal(SIGINT, sighandler);

#if defined(SIGQUIT)
        signal( SIGQUIT , printStackAndExit );
#endif
        signal( SIGSEGV , printStackAndExit );
        signal( SIGABRT , printStackAndExit );
        signal( SIGFPE , printStackAndExit );
#if defined(SIGBUS)
        signal( SIGBUS , printStackAndExit );
#endif
#if defined(SIGPIPE)
        signal( SIGPIPE , SIG_IGN );
#endif

#ifndef _WIN32
        sigemptyset( &asyncSignals );
        sigaddset( &asyncSignals, SIGUSR1 );
        startSignalProcessingThread();
#endif

        setWindowsUnhandledExceptionFilter();
        set_new_handler( my_new_handler );
    }
コード例 #3
0
ファイル: satin.cpp プロジェクト: alankstewart/satin-cpp
void Satin::gaussianCalculation(int inputPower, float smallSignalGain, char outputFile[]) {
	ofstream fd;
	double temp;
	double *expr;
	double zInc;
	double inputIntensity;
	double outputIntensity;
	double outputPower;
	float radius;
	int saturationIntensity;

	fd.open(outputFile, ios::in | ios::app);
	inputIntensity = 2 * inputPower / AREA;

	set_new_handler(noMemory);
	expr = new double[8 * 8001];

	for (int i = 0; i < 8001; i++) {
		zInc = ((double) i - 4000) / 25;
		expr[i] = zInc * 2 * DZ / (Z1 * Z1 + zInc * zInc);
	}

	for (saturationIntensity = 10000; saturationIntensity <= 25000; saturationIntensity += 1000) {
		outputPower = 0;
		temp = (double) saturationIntensity * (smallSignalGain / 32000) * DZ;

		for (radius = 0; radius <= 0.5; radius += DR) {
			outputIntensity = inputIntensity * exp(-2 * (radius * radius) / (RAD * RAD));

			for (int j = 0; j < 8001; j++) {
				outputIntensity *= (1 + temp / ((double) saturationIntensity + outputIntensity) - expr[j]);
			}

			outputPower += (outputIntensity * 2 * M_PI * radius * DR);
		}

		fd << setiosflags(ios::fixed)
		   << setprecision(1)
		   << inputPower
		   << "\t\t"
		   << setprecision(3)
		   << outputPower
		   << setiosflags(ios::fixed)
		   << setprecision(1)
		   << "\t\t"
		   << saturationIntensity
		   << "\t\t"
		   << setprecision(3)
		   << log(outputPower / inputPower)
		   << "\t\t"
		   << (outputPower - inputPower)
		   << "\n";
	}

	fd.flush();
	fd.close();
	delete expr;
}
コード例 #4
0
ファイル: error.cpp プロジェクト: bfilia/ivan
void globalerrorhandler::DeInstall()
{
#ifdef __DJGPP__
  for(int c = 0; c < SIGNALS; ++c)
    signal(Signal[c], OldSignal[c]);
#endif

  set_new_handler(OldNewHandler);
}
コード例 #5
0
ファイル: EMBeThread.cpp プロジェクト: ModeenF/Titan
status_t EMBeThread::ThreadEntry(void* obj)
{
	if(!obj)
		return B_ERROR;

	// Each thread must set the new handler individually
	// The new handler manages the reserve memory buffers
	// that are released when the system has run out of RAM
	set_new_handler(&(EMExceptionHandler::NewHandler));

	((EMBeThread*) obj)	-> Run();
	return B_OK;
}
コード例 #6
0
ファイル: main.c プロジェクト: rionda/datasetgenerator
int main(int argc, char **argv)
{

  set_new_handler(memory_err);
#ifndef DEBUG
  unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
#else
  unsigned seed = 0;
#endif
  seed_generator(seed);

  if (::strcmp(argv[1], "lit") == 0) {
    // For Rules
    TransPar par;

    get_args(par, argc, argv);   // get arguments
    gen_rules(par);              // generate rules (really, just transactions)
  }

  else if (::strcmp(argv[1], "seq") == 0) {
    // For Sequences
    SeqPar par;

    get_args(par, argc, argv);   // get arguments
    gen_seq(par);                // generate sequences
  }

  else if (::strcmp(argv[1], "tax") == 0) {
    // For Rules with Taxonomies
    TaxPar par;

    get_args(par, argc, argv);   // get arguments
    gen_taxrules(par);           // generate rules (really, just transactions)
  }

  else if (::strcmp(argv[1], "-version") == 0) {
	cout << VERSION << endl;
    return 0;
  }

  else {
    cerr << "Synthetic Data Generation, ";
	cerr << VERSION << endl;
    cerr << "Usage:  " << argv[0] << " lit|tax|seq [options]\n";
    cerr << "        " << argv[0] 
      << " lit|tax|seq -help     For more detailed list of options\n";
    return 1;
  }

  return 0;
}
コード例 #7
0
ファイル: cvpack.cpp プロジェクト: Azarien/open-watcom-v2
int main(int argc, char* argv[])
/******************************/
{
    char tmpFile[L_tmpnam];
    bool quiet;

    quiet = false;
    set_new_handler(outOfMemory);
    try {
        if( argc != 2 ) {
            if( argc == 3 && stricmp( argv[1], "/nologo" ) == 0 ) {
                quiet = true;
                argv[1] = argv[2];
            } else {
                cerr << CVpackUsage;
                return 1;
            }
        }
        if( !quiet ) {
            cout << CVpackHeader << endl;
        }
        ::ConvertFName(argv[1]);
        ifstream  fd(fName, ios::in | ios::binary);
        if ( !fd ) {
            throw FileError(fName);
        }
        tmpnam(tmpFile);
        CVpack packMaker(fd,tmpFile);
        //cerr << "calling packMaker.CreatePackExe()\n";
        //cerr.flush();

        packMaker.CreatePackExe();
        //cout << "cvpack, packMaker.CreatePackExe() OK\n";
        //cout.flush();

        fd.close();
        if ( remove(fName) ) {
            throw MiscError(strerror(errno));
        }
        if ( rename(tmpFile,fName) ) {
            throw MiscError(strerror(errno));
        }
    }
    catch (CVpackError& CVerr) {
        CVerr.ErrorPrint();
        remove(tmpFile);
        exit(1);
    }
    return 0;
}
コード例 #8
0
ファイル: main.C プロジェクト: Doom-Utils/xwadtools
int main (int argc, char** argv)
{
     set_new_handler (NoMemory);

     cerr << version_info << endl;
     if (argc > 3)
     {
          // -=- Read in PWAD directory -=- 
          //CPWad wad (XString(argv[1]) + XString(".WAD"));
	  CPWad wad = XString(argv[1]);

          // -=- All OK ? -=-
          if (!wad.Valid ())
          {
               cerr << "Failed Reading PWAD " << argv[1] << endl;
               exit (0);
          }

          XString map (argv[2]);
          int threshold = atoi (argv[3]);

          if ((threshold >= 32) && (threshold <= 4096))
          {
               CReject rej (wad, map);
               if (rej.Valid ())
               {
                    rej.RejectAll ();
                    cout << "Calculating Reject table...." << flush;
                    rej.RejectDefault (threshold);
                    cout << "Done." << endl;
          
                    cout << "Writing Reject table...." << flush;
                    wad.Write (rej.GetRejectData(), map, "REJECT");
                    cout << "Done." << endl;
               }
          }
          else
          {
               cerr << "Treshold must be between 32 and 4096" << endl;
          }
     }
     else
     {
          cerr << "USAGE: REJECT <WADNAME> <MAPNAME> <THRESHOLD>" << endl;
          cerr << "   eg: reject mywad e1m1 600" << endl;
     }
     return 0;
}
コード例 #9
0
ファイル: GENC.C プロジェクト: Mikelle02/GameMaker
ConfigData::ConfigData()
  {
  FILE *fp;
  set_new_handler(0);
  if ((fp=fopen("gm.cfg","rb"))!=NULL)
    {
    Cfg.Read(fp);
    fclose(fp);
    strcpy(WorkDir,WorkingDirectory);
    }
  else
    {
    for (uint i=0; i<MAXFILENAMELEN;i++)
      { WorkDir[i]=0; WorkingDirectory[i]=0; }
    }
  }
コード例 #10
0
ファイル: server.cpp プロジェクト: e-siedler/mongo
    void setupSignals( bool inFork ) {
        signal(SIGTERM, sighandler);
        signal(SIGINT, sighandler);

#if defined(SIGQUIT)
        signal( SIGQUIT , printStackAndExit );
#endif
        signal( SIGSEGV , printStackAndExit );
        signal( SIGABRT , printStackAndExit );
        signal( SIGFPE , printStackAndExit );
#if defined(SIGBUS)
        signal( SIGBUS , printStackAndExit );
#endif

        set_new_handler( my_new_handler );
    }
コード例 #11
0
ファイル: makeDeps.cpp プロジェクト: ztianjin/self
  void set_args(int& argc, char**& argv) {
    argc = ccommand(&argv);
#   ifdef TARGET_IS_SELF
          if (argc == 1) {
            static char *default_args[] = {
              "", "-100", "Platform_macosx", "includeDB", 
              ":::src:Platform_mac", ":::src:includeDB"};
            argc = sizeof(default_args) / sizeof(default_args[0]);
            argv = default_args;
          }
#   endif
    SIOUXSettings.autocloseonquit  = True;
    SIOUXSettings.asktosaveonclose = False;
    
    void fatal_on_new_error();
    set_new_handler(fatal_on_new_error);
  }
コード例 #12
0
ファイル: error.cpp プロジェクト: bfilia/ivan
void globalerrorhandler::Install()
{
  static truth AlreadyInstalled = false;

  if(!AlreadyInstalled)
  {
    AlreadyInstalled = true;
    OldNewHandler = set_new_handler(NewHandler);

#ifdef __DJGPP__
    for(int c = 0; c < SIGNALS; ++c)
      OldSignal[c] = signal(Signal[c], SignalHandler);
#endif

    atexit(globalerrorhandler::DeInstall);
  }
}
コード例 #13
0
ファイル: signal_handlers.cpp プロジェクト: BobWeinerJr/mongo
    void setupSignalHandlers() {
        set_terminate( myTerminate );
        set_new_handler( myNewHandler );

        // SIGABRT is the only signal we want handled by signal handlers on both windows and posix.
        invariant( signal(SIGABRT, abruptQuit) != SIG_ERR );

#ifdef _WIN32
        _set_purecall_handler( ::abort ); // TODO improve?
        setWindowsUnhandledExceptionFilter();
        massert(10297,
                "Couldn't register Windows Ctrl-C handler",
                SetConsoleCtrlHandler(static_cast<PHANDLER_ROUTINE>(CtrlHandler), TRUE));

#else
        invariant( signal(SIGHUP , SIG_IGN ) != SIG_ERR );
        invariant( signal(SIGUSR2, SIG_IGN ) != SIG_ERR );
        invariant( signal(SIGPIPE, SIG_IGN) != SIG_ERR );

        struct sigaction addrSignals;
        memset( &addrSignals, 0, sizeof( struct sigaction ) );
        addrSignals.sa_sigaction = abruptQuitWithAddrSignal;
        sigemptyset( &addrSignals.sa_mask );
        addrSignals.sa_flags = SA_SIGINFO;

        invariant( sigaction(SIGSEGV, &addrSignals, 0) == 0 );
        invariant( sigaction(SIGBUS, &addrSignals, 0) == 0 );
        invariant( sigaction(SIGILL, &addrSignals, 0) == 0 );
        invariant( sigaction(SIGFPE, &addrSignals, 0) == 0 );


        setupSIGTRAPforGDB();

        // asyncSignals is a global variable listing the signals that should be handled by the
        // interrupt thread, once it is started via startSignalProcessingThread().
        sigemptyset( &asyncSignals );
        sigaddset( &asyncSignals, SIGHUP );
        sigaddset( &asyncSignals, SIGINT );
        sigaddset( &asyncSignals, SIGTERM );
        sigaddset( &asyncSignals, SIGQUIT );
        sigaddset( &asyncSignals, SIGUSR1 );
        sigaddset( &asyncSignals, SIGXCPU );
#endif
    }
コード例 #14
0
ファイル: server.cpp プロジェクト: 2812140729/robomongo
    void setupSignals( bool inFork ) {
        signal(SIGTERM, sighandler);
        signal(SIGINT, sighandler);

#if defined(SIGQUIT)
        signal( SIGQUIT , printStackAndExit );
#endif
        signal( SIGSEGV , printStackAndExit );
        signal( SIGABRT , printStackAndExit );
        signal( SIGFPE , printStackAndExit );
#if defined(SIGBUS)
        signal( SIGBUS , printStackAndExit );
#endif
#if defined(SIGPIPE)
        signal( SIGPIPE , SIG_IGN );
#endif

        setWindowsUnhandledExceptionFilter();
        set_new_handler( my_new_handler );
    }
コード例 #15
0
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 *
 * NAME : main 
 *
 * DESCRIPTION : space-commander main 
 *
 *-----------------------------------------------------------------------------*/
int main() 
{
    validate();
    set_new_handler(&out_of_memory_handler);

    commander = new Net2Com(Dcom_w_net_r, Dnet_w_com_r, 
                                                    Icom_w_net_r, Inet_w_com_r);

    if (!commander) {
        memset(log_buffer,0,MAX_BUFFER_SIZE);
        snprintf(log_buffer, MAX_BUFFER_SIZE, "[ERROR] %s:%s:%d Failed in Net2Com instanciation\n", 
                                                __FILE__, __func__, __LINE__);
        return EXIT_FAILURE; /* watch-puppy will take care of 
                              * restarting space-commander
                              */
    }

    Shakespeare::log(Shakespeare::NOTICE, LOGNAME, 
                                            "Waiting commands from ground...");

    while (true) 
    {
        memset(info_buffer, 0, sizeof(char) * NET2COM_MAX_INFO_BUFFER_SIZE);
        int bytes = commander->ReadFromInfoPipe(info_buffer, NET2COM_MAX_INFO_BUFFER_SIZE);

        if (bytes > 0) {
            perform(bytes);
        }

        sleep(COMMANER_SLEEP_TIME);
    }

    if (commander) {
        delete commander;
        commander = 0;
    }

    return 0;
}
コード例 #16
0
// GameServer constructor
GameServer::GameServer()
{
   // Set the function for bad new call
   set_new_handler(badNew);

   // Open the input slot
   hInputSlot = createSlot(-1);

   if ( hInputSlot == INVALID_HANDLE_VALUE )
      exit(0);

   // Initialize all nodes to NULL.
   for ( int n = 0; n < MAX_NODE; n++ )
      {
      gNode[n] = NULL;
      }

   // Initialize the game's CRITICAL_SECTION object.
   InitializeCriticalSection(&csCritical);
      
   nCriticalCount = 0;
   nPlayersInGame = 0;
}
コード例 #17
0
ファイル: door.cpp プロジェクト: evanelias/tournament-trivia
void main(int argc, char *argv[])
#endif
{
   char szText[160];
   bool bSuccess;
   short nTries = 0;

   // Set results of what happens when a call to new fails
   set_new_handler(badNew);

   // Call the startup function
   #ifdef OD32
   startup(lpszCmdLine);
   #else
   startup(argc, argv);
   #endif

   Sleep(500);

   do
      {
      // Attempt to start up the door server process.  (No need to check if the door server process is already
      // running; it does that on its own and shuts down extra copies as needed)
      bSuccess = CreateProcess(DOOR_SERVER_EXE, NULL, NULL, NULL, false, DETACHED_PROCESS, NULL, NULL, new STARTUPINFO, new PROCESS_INFORMATION);
      Sleep(1000);
      nTries++;
      }  
   while ( bSuccess == false && nTries < 5 );

   // Get a handle on the door server's input mailslot
   hInputSlot = openSlot(-1);

   // Create this node's output mailslot.
   hOutputSlot = createSlot( getNode() );
 
   // If unable to open input slot, re-try up to 5 times (intial failure seems to happen on WinXP randomly)
   // If still failure, this indicates the door server is not running and could not be started, so shut down.
   nTries = 0;
   while (hInputSlot == INVALID_HANDLE_VALUE ) 
      {
      Sleep(500);
      hInputSlot = openSlot(-1);      
      if ( ++nTries > 5 )
         {
         local("Unable to start door: IPC error");
         exitDoor(1);
         }
      }

   // If the output slot for this node is already open, it means the node is already running the door.
   if ( hOutputSlot == INVALID_HANDLE_VALUE )
      {
      local("Unable to start door:  This node is already in use!");
      pausePrompt();
      exitDoor(1);
      }

   // Now that the mailslot handles were successful, call setupExitFunction() to register beforeExit() as the
   // function called upon exit.
   setupExitFunction();
      
   // Send an input message to the server, to tell it a user is trying to enter the game.  The user's info is
   // passed as a string in the format below.
   sprintf(szText, "%d&%c&%d&%s&%s", isSysop(), getGender(), getPlatform(), getAlias(), getRealName());
   sendInput(szText, IP_ENTER_GAME);

   // Handle I/O for the user
   while (1)
      {
      performIO();
      }   
}
コード例 #18
0
ファイル: main.cpp プロジェクト: shaobinzhang/powertop
int main(int argc, char **argv)
{
	int option_index;
	int c;
	char filename[4096];
	char workload[4096] = {0,};
	int  iterations = 1, auto_tune = 0;

	set_new_handler(out_of_memory);

	setlocale (LC_ALL, "");
	bindtextdomain (PACKAGE, LOCALEDIR);
	textdomain (PACKAGE);

	while (1) { /* parse commandline options */
		c = getopt_long (argc, argv, "ch:C:i:t:uVw:q", long_options, &option_index);
		/* Detect the end of the options. */
		if (c == -1)
			break;

		switch (c) {
			case 'V':
				print_version();
				exit(0);
				break;

			case 'e': /* Extech power analyzer support */
				checkroot();
				extech_power_meter(optarg ? optarg : "/dev/ttyUSB0");
				break;
			case 'u':
				print_usage();
				exit(0);
				break;
			case 'a':
				auto_tune = 1;
				leave_powertop = 1;
				break;
			case 'c':
				powertop_init();
				calibrate();
				break;

			case 'h': /* html report */
				reporttype = REPORT_HTML;
				sprintf(filename, "%s", optarg ? optarg : "powertop.html" );
				break;

			case 't':
				time_out = (optarg ? atoi(optarg) : 20);
				break;

			case 'i':
				iterations = (optarg ? atoi(optarg) : 1);
				break;

			case 'w': /* measure workload */
				sprintf(workload, "%s", optarg ? optarg :'\0' );
				break;
			case 'q':
				if(freopen("/dev/null", "a", stderr))
					fprintf(stderr, _("Quite mode failed!\n"));
				break;

			case 'C': /* csv report*/
				reporttype = REPORT_CSV;
				sprintf(filename, "%s", optarg ? optarg : "powertop.csv");
				break;
			case '?': /* Unknown option */
				/* getopt_long already printed an error message. */
				exit(0);
				break;
		}
	}

	powertop_init();

	if (reporttype != REPORT_OFF)
		make_report(time_out, workload, iterations, filename);

	if (debug_learning)
		printf("Learning debugging enabled\n");

	learn_parameters(250, 0);
	save_parameters("saved_parameters.powertop");


	if (debug_learning) {
	        learn_parameters(1000, 1);
		dump_parameter_bundle();
		end_pci_access();
		exit(0);
	}
	init_display();
	initialize_tuning();
	/* first one is short to not let the user wait too long */
	one_measurement(1, NULL);

	if (!auto_tune) {
		tuning_update_display();
		show_tab(0);
	} else {
		auto_toggle_tuning();
	}

	while (!leave_powertop) {
		show_cur_tab();
		one_measurement(time_out, NULL);
		learn_parameters(15, 0);
	}
	endwin();
	printf("%s\n", _("Leaving PowerTOP"));

	end_process_data();
	clear_process_data();
	end_cpu_data();
	clear_cpu_data();

	save_all_results("saved_results.powertop");
	save_parameters("saved_parameters.powertop");
	learn_parameters(500, 0);
	save_parameters("saved_parameters.powertop");
	end_pci_access();
	clear_tuning();
	reset_display();

	clean_shutdown();

	return 0;
}
コード例 #19
0
ファイル: motifspec.cpp プロジェクト: rakarnik/motifspec
int main(int argc, char *argv[]) {
	set_new_handler(alloc_error);

	if(argc < 6) {
		print_usage(cout);
		exit(0);
	}
	
	string seqfile;                       // file with sequences
	string exprfile;                      // file with expression data
	string subsetfile;                    // file with subset of sequence names to search
	string scorefile;                     // file with scores

	if(! GetArg2(argc, argv, "-s", seqfile)) {
		cerr << "Please specify sequence file\n\n";
		print_usage(cout);
		exit(0);
	}
	if(! GetArg2(argc, argv, "-o", outfile)) {
		cerr << "Please specify output file\n\n";
		print_usage(cout);
		exit(0);
	}
	
	int search_type = UNDEFINED;
	if(GetArg2(argc, argv, "-ex", exprfile)) {
		search_type = EXPRESSION;
	}
	if(GetArg2(argc, argv, "-su", subsetfile)) {
		search_type = SUBSET;
	}
	if(GetArg2(argc, argv, "-sc", scorefile)) {
		search_type = SCORE;
	}
	if(search_type == UNDEFINED) {
		cerr << "Please specify either an expression data file, a file with a subset of sequence names, or a file with sequence scores.\n\n";
		print_usage(cout);
		exit(0);
	}

	// Decide mode of running
	archive = false;
	if(! GetArg2(argc, argv, "-worker", worker)) {
		worker = -1;
		archive = true;
	}
	
	// Read parameters
	vector<string> seqs;
	cerr << "Reading sequence data from '" << seqfile << "'... ";
	get_fasta_fast(seqfile.c_str(), seqs, seq_nameset);
	cerr << "done.\n";
	ngenes = seq_nameset.size();
	
	npoints = 0;
	if(search_type == EXPRESSION) {
		cerr << "Reading expression data from '" << exprfile << "'... ";
		get_expr(exprfile.c_str(), expr, data_nameset);
		cerr << "done.\n";
		npoints = expr[0].size();
		nsubset = 0;
	} else if(search_type == SUBSET) {
		cerr << "Reading subset of sequences to search from '" << subsetfile << "'... ";
		get_list(subsetfile.c_str(), subset);
		cerr << "done.\n";
		npoints = 0;
		for(int i = 0; i < ngenes; i++) {
			vector<float> row(0);
			expr.push_back(row);
		}
		nsubset = subset.size();
		sort(subset.begin(), subset.end());
	} else if(search_type == SCORE) {
		cerr << "Reading sequence scores from '" << scorefile << "'... ";
		get_scores(scorefile.c_str(), scores, data_nameset);
		cerr << "done.\n";
		npoints = 1;
		nsubset = 0;
	}

	vector<vector <float> > newexpr;
	vector<float> newscores;
	if(search_type == EXPRESSION) {
		order_data_expr(newexpr);
	}
	if(search_type == SCORE) {
		order_data_scores(newscores);
	}

	if(search_type == EXPRESSION) {
		cerr << "Successfully read input files -- dataset size is " << ngenes << " sequences X " << npoints << " timepoints\n";
	} else if(search_type == SUBSET) {
		cerr << "Successfully read input files -- dataset size is " << ngenes << " sequences, with " << nsubset << " to be searched\n";
	} else if(search_type == SCORE) {
		cerr << "Successfully read input files -- dataset size is " << ngenes << " scored sequences\n";
	}

	cerr << "Setting up MotifSearch... ";
	if(! GetArg2(argc, argv, "-numcols", ncol)) ncol = 10;
	if(! GetArg2(argc, argv, "-order", order)) order = 0;
	if(! GetArg2(argc, argv, "-simcut", simcut)) simcut = 0.8;
	if(! GetArg2(argc, argv, "-maxm", maxm)) maxm = 20;
	MotifSearch* ms;
	if(search_type == EXPRESSION) {
		ms = new MotifSearchExpr(seq_nameset, seqs, ncol, order, simcut, maxm, newexpr, npoints);
	} else if(search_type == SCORE) {
		ms = new MotifSearchScore(seq_nameset, seqs, ncol, order, simcut, maxm, newscores);
	} else {
		ms = new MotifSearchSubset(seq_nameset, seqs, ncol, order, simcut, maxm, subset);
	}
	ms->modify_params(argc, argv);
	ms->set_final_params();
	ms->ace_initialize();
	cerr << "done.\n";
	cerr << "Random seed: " << ms->get_params().seed << '\n';

	if(archive) {
		cerr << "Running in archive mode...\n";
		string archinstr(outfile);
		archinstr.append(".ms");
		ifstream archin(archinstr.c_str());
		if(archin) {
			cerr << "Refreshing from existing archive file " << archinstr << "... ";
			ms->get_archive().read(archin);
			cerr << "done.\n";
		}
		while(true) {
			int found = read_motifs(ms);
			if(found > 0) output(ms);
			if(found < 50) sleep(10);
		}
	} else {
		cerr << "Running as worker " << worker << "...\n";
		int nruns = ms->positions_in_search_space()/(ms->get_params().expect * ncol);
		nruns *= ms->get_params().oversample;
		nruns /= ms->get_params().undersample;
		cerr << "Restarts planned: " << nruns << '\n';
		string archinstr(outfile);
		archinstr.append(".ms");
		string lockstr(outfile);
		lockstr.append(".lock");
		for(int j = 1; j <= nruns; j++) {
			if(j == 1 || j % 50 == 0 || search_type == SUBSET) {
				struct flock fl;
				int fd;
				fl.l_type   = F_RDLCK;
				fl.l_whence = SEEK_SET;
				fl.l_start  = 0;
				fl.l_len    = 0;
				fl.l_pid    = getpid();
				fd = open(lockstr.c_str(), O_RDONLY);
				if(fd == -1) {
					if(errno != ENOENT)
						cerr << "\t\tUnable to read lock file, error was " << strerror(errno) << "\n";
				} else {
					while(fcntl(fd, F_SETLK, &fl) == -1) {
						cerr << "\t\tWaiting for lock release on archive file... \n";
						sleep(10);
					}
					ifstream archin(archinstr.c_str());
					if(archin) {
						cerr << "\t\tRefreshing archive from " << archinstr << "...";
						ms->get_archive().clear();
						ms->get_archive().read(archin);
						archin.close();
						cerr << "done.\n";
					}
					fl.l_type = F_UNLCK;
					fcntl(fd, F_SETLK, &fl);
					close(fd);
					cerr << "\t\tArchive now has " << ms->get_archive().nmots() << " motifs\n";
				}
			}
			cerr << "\t\tSearch restart #" << j << "/" << nruns << "\n";
			ms->search_for_motif(worker, j, outfile);
		}
	}
	delete ms;
	return 0;
}
コード例 #20
0
ファイル: main.cpp プロジェクト: Yardape8000/wiiflow-plus
int main(int argc, char **argv)
{
	set_new_handler(no_memory);
	geckoinit = InitGecko();
	__exception_setreload(5);

	SYS_SetArena1Hi(APPLOADER_START);

	char *gameid = NULL;
	string dolLoc; //(argv[0] != NULL ? argv[0] : "");

	for (int i = 0; i < argc; i++)
	{
		if (argv[i] != NULL && strcasestr(argv[i], "ios=") != NULL && strlen(argv[i]) > 4)
		{
			while(argv[i][0] && !isdigit(argv[i][0])) argv[i]++;
			if (atoi(argv[i]) < 254 && atoi(argv[i]) > 0)
				mainIOS = atoi(argv[i]);
		}
		else if (strlen(argv[i]) == 6)
		{
			gameid = argv[i];
			for (int i=0; i < 5; i++)
				if (!isalnum(gameid[i]))
					gameid = NULL;
		}
	}
	gprintf("Loading cIOS: %d\n", mainIOS);

	ISFS_Initialize();

	// Load Custom IOS
	bool iosOK = loadIOS(mainIOS, false);
	MEM2_init(52);

	u8 mainIOSBase = 0;
	iosOK = iosOK && cIOSInfo::D2X(mainIOS, &mainIOSBase);
	gprintf("Loaded cIOS: %u has base %u\n", mainIOS, mainIOSBase);

	// Init video
	CVideo vid;
	vid.init();
	WIILIGHT_Init();
	vid.waitMessage(0.2f);

	// Init
	Sys_Init();
	Sys_ExitTo(EXIT_TO_HBC);

	int ret = 0;

	do
	{
		Open_Inputs();

		bool deviceAvailable = false;

		u8 timeout = 0;
		while(!deviceAvailable && timeout++ != 20)
		{
			DeviceHandler::Instance()->MountAll();
			sleep(1);

			for(u8 device = SD; device <= USB8; device++)
				if(DeviceHandler::Instance()->IsInserted(device))
					deviceAvailable = true;
		}

		bool dipOK = Disc_Init() >= 0;

		CMenu menu(vid);
		menu.init(dolLoc);
		mainMenu = &menu;
		if(!deviceAvailable)
		{
			menu.error(L"Could not find a device to save configuration files on!");
			break;
		}
		else if(!iosOK)
		{
			menu.error(sfmt("d2x cIOS %i rev6 or later is required", mainIOS));
			break;
		}
		else if(!dipOK)
		{
			menu.error(L"Could not initialize the DIP module!");
			break;
		}
		else
		{
			if (gameid != NULL && strlen(gameid) == 6)
				menu._directlaunch(gameid);
			else
				ret = menu.main();
		}
		vid.cleanup();
		if (bootHB)
		{
			IOS_ReloadIOS(58);
			BootHomebrew();
		}

	} while (ret == 1);

	WifiGecko_Close();

	Nand::Instance()->Disable_Emu();
	Nand::DestroyInstance();

	Sys_Exit();
	return 0;
};
コード例 #21
0
ファイル: billstat.cpp プロジェクト: xkmld419/crawl
int billstat:: run()
{
	int i=0;
	
	TStatClass * pStat;
		
	int iStatClassID=-1;
	int iRunMode=0;
	int iPageInOutMode=1;
	int cGet=0;
	int process_id,flow_id;
	
	while((cGet=getopt(g_argc,g_argv,"c:rp"))!=EOF)
	{
		switch(cGet)
		{
			case 'c':
                iStatClassID = atoi(optarg);
                break;
			case 'r':
								iRunMode=1;
								break;
			case 'p':
								iPageInOutMode=0;
								break;
			default:
                printf("billstat:参数错误\n");
                printf("Usg billstat -c ? [-r] [-p]\n");
				return -1;
		}
	}
	
	if (iStatClassID==-1){
		printf("billstat:参数错误\n");
        printf("Usg billstat -c ? [-r] [-p]\n");
		return -1;
	}
	
	gpDBLink.connect("stat","group_by","tibs_stat");
	gpDBLink_Temp.connect("stat","group_by","tibs_stat");
	
	set_new_handler(my_new_error);

	InitAll();

	switch ( iStatClassID){
        case OID_CALL_EVENT:
            pStat = new StatCallEvent();
            break;
        case OID_SERV:
        	pStat = new StatServ();
        	break;
        case OID_ACCT_ITEM:
        	pStat = new StatAcctItem();
        	break;
        case OID_ACCT_BALANCE:
        	pStat = new StatAcctBalance();
        	break;
        case OID_BALANCE_SOURCE:
        	pStat = new StatBalanceSource();
        	break;
        case OID_BALANCE_PAYOUT:
        	pStat = new StatBalancePayout();
        	break;
        case OID_PAYMENT:
        	pStat = new StatPayment();
        	break;
        case OID_BILL:
        	pStat = new StatBill();
        	break;
        case OID_OTHER_EVENT:
        	pStat = new StatOtherEvent();
        	break;
        case OID_DATA_EVENT:
        	pStat = new StatDataEvent();
        	break;
        case OID_CYCLE_FEE_EVENT:
        	pStat = new StatCycleFeeEvent();
        	break;
        case OID_VALUE_ADDED_EVENT:
        	pStat = new StatValueAddedEvent();
        	break;
        case OID_ACCT_ITEM_AGGR:
        	pStat = new StatAcctItemAggr();
        	break;
        case OID_ERROR:
        	pStat = new StatError();
        	break;
        case OID_REDO_EVENT:
        	pStat = new StatRedoEvent();
        	break;
        case OID_AREFUNDLOG:
        	pStat = new StatARefundLog();
        	break;
        default:
            printf("统计类:[%d]不存在!\n",iStatClassID);
            return -1;
  }
  
  if (iRunMode)
				pStat->SetRunMode(iRunMode);
	
	pStat->SetPageInOutMode(iPageInOutMode);
	
	try{
			for (;;){
					
					if (pStat->GetRecord()){
  		
						pStat->ProcessStat();
						i++;
						
						if (i%500==0)
							usleep(1000);
							
						if (i%10000==0){
							pStat->OutputResult();
							pStat->Commit();
						}
						if (i%50000==0){
							pStat->FreeResult();
							pStat->Commit();
						}
					}
					else 
						break;
			}
			pStat->FreeResult();
			pStat->Commit();
			delete pStat;
			printf("统计程序正常结束!\n");
			return 1;
	}
	catch (TOCIException &oe) {
		cout<<"Error occured ... in "<< __FILE__ <<endl;
		cout<<oe.GetErrMsg()<<endl;
		cout<<oe.getErrSrc()<<endl;
		throw oe;
	}
	catch (TException &e) {
		cout<<"Error occured ... in "<< __FILE__ <<endl;
		cout<<e.GetErrMsg()<<endl;
		throw e;
	}
	catch (...) {
		cout<<"Error occured ... in "<< __FILE__ <<endl;
		throw TException("Error occured ... ");
	}
}
コード例 #22
0
void	GUI_MemoryHog::RemoveNewHandler(void)
{
	set_new_handler(sOldHandler);
}
コード例 #23
0
void	GUI_MemoryHog::InstallNewHandler(void)
{
	sOldHandler = set_new_handler(GUI_MemoryHog::our_new_handler);
}
コード例 #24
0
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) {
コード例 #25
0
ファイル: cvmsh2.cpp プロジェクト: cpraveen/taxis
int main(int argc, char **argv)
{ 
  Real8 cutoffradian = 30.0*Pi/180.0;
  char * fin=0,*fout=0,*fgeom=0;
  verbosity = 2;
  int ok=0,i=0;
  if (argc >= 3)
    {
      fin=argv[1];
      fout=argv[2];
      ok= !access(fin,R_OK) && (access(fout,F_OK) || !access(fout,W_OK)) ;
    }
  
  for (i=3;i<argc && ok ;i+=2)
    if (!strcmp(argv[i],"-g")) 
      {
	fgeom=argv[i+1];
	ok= ok &&  (access(fgeom,F_OK) || !access(fgeom,W_OK) );
      }
    else if (!strcmp(argv[i],"-thetamax"))
      cutoffradian = atof(argv[i+1])*Pi/180.0;
    else if (!strcmp(argv[i],"-v"))
      verbosity = atoi(argv[i+1]);
    else
      ok=0;
      
  
  
  if (!ok)
    {
      cout << "2D mesh convertisor of type   .am_fmt .amdba .am .nopo .msh .ftq + bd mesh\n";
      cout << "                    in type   .am_fmt .amdba .am .nopo .msh .ftq + bd mesh\n";
      cout << endl;
      cout << " usage: cnmsh2 InMesh OutMesh \n";
      cout << " or   : cnmsh2 Inmeshfile  OutBdmeshfile  [-g OutGeomfile ] [ -thetamax theta ] [-v level]\n";
      cout << endl;
      cout << " where  theta is the angular limit for  smooth curve in  degre \n";
      cout << "        level is level of verbosity in [0..99] 0 => no message, 99 to much \n";
      cout << endl;
      cout << " remark: ";
      cout << "   the  type of OutMesh is defined with the suffix\n";
      cout << "   si the suffixe is not in .am_fmt .amdba .am .nopo .msh .ftq, then \n";
      cout << "   the mesh is a bd mesh (cf .mesh)" << endl;
      return 1;
    }
  MeshIstreamErrorHandler = MeshErrorIO;
  set_new_handler( &NewHandler);
#ifdef DRAWING 
  initgraphique(); 
  initgraph=1;
#endif
  //    cout << "open file in " << fin<< endl;
  Triangles Th(fin,cutoffradian);
  if (!fgeom)
    Th.Write(fout);
  else
    {
      //      cout << " geom " << fgeom << endl;
      Th.Gh.Write(fgeom);
      Th.Write(fout,Triangles::BDMesh);
    }

   return 0;
}
コード例 #26
0
ファイル: init.cpp プロジェクト: dylancarlson/citplus
void startUp(int argc, const char *argv[])
    {
#if __BORLANDC__ >= 1106
    set_new_handler(0);
#endif

    strcpy(fullExePath, argv[0]);

#ifndef WINCIT
    fseek(stdin, 0, SEEK_CUR);  // Borland says to fseek() before setbuf()
    setbuf(stdin, NULL);
#endif

#ifndef WINCIT
#ifdef MULTI
    if (!initTaskInfo(&ti))
#else
    cfg.maxrooms = 0 ;
    if (!initFakeTaskInfo())
#endif
        {
        printf("Could not create initial task information structure.\n");
        exit(200);
        }
#endif

    tzset();

    critical(TRUE);

#ifndef WINCIT
    if (checkDataVer() != NumericVer)
        {
        printf("CTDL.DAT is version %d; version %d needed.\n", checkDataVer(), NumericVer);
        critical(FALSE);
        exit(200);
        }

    if (!read_messages())
        {
        printf("Could not read messages from CTDL.DAT\n");
        critical(FALSE);
        exit(200);
        }

    InitializeTimer();
#else
    if (checkDataVer() != NumericVer)
        {
		char bbb[100];
		sprintf(bbb, "CTDL.DAT is version %d; version %d needed.", checkDataVer(), NumericVer);

        MessageBox(NULL, bbb, NULL, MB_ICONSTOP | MB_OK);
        exit(200);
        }

    if (!read_messages())
        {
        MessageBox(NULL, "Could not read messages from CTDL.DAT.", NULL, MB_ICONSTOP | MB_OK);
        exit(200);
        }

    WNDCLASS wndclass;

    // define and register the main window class
    wndclass.style = 0; // CS_HREDRAW | CS_VREDRAW
    wndclass.cbClsExtra = 0;
    wndclass.cbWndExtra = 0;
    wndclass.hInstance = hInstance;
    wndclass.hIcon = LoadIcon(hInstance, "CITADEL");
    wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
    wndclass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);

    // define and register the logo window class
    wndclass.lpszMenuName = NULL;
    wndclass.lpfnWndProc = logoWndProc;
    wndclass.lpszClassName = "Citadel Logo";
    if (!RegisterClass(&wndclass))
        {
        MessageBox(NULL, "Could not register logo window", NULL, MB_ICONSTOP | MB_OK);
        exit(200);
        }

#ifdef NAHERROR
    // define and register the error window class
    wndclass.style = CS_VREDRAW;
    wndclass.lpfnWndProc = errorWndProc;
    wndclass.lpszClassName = "Citadel Error";
    if (!RegisterClass(&wndclass))
        {
        MessageBox(NULL, "Could not register error window", NULL, MB_ICONSTOP | MB_OK);
        exit(200);
        }

    // define and register the msg window class
    wndclass.lpfnWndProc = msgWndProc;
    wndclass.lpszClassName = "Citadel Message";
    if (!RegisterClass(&wndclass))
        {
        MessageBox(NULL, "Could not register msg window", NULL, MB_ICONSTOP | MB_OK);
        exit(200);
        }
#endif
#endif

    // initialize all drivers to internal functions

#ifdef WINCIT
    // com
//  initrs          = (void (cdecl *)(int,int,int,int,int,int)) nullFunc;
//  deinitrs        = nullFunc;
//  ringstatrs      = (int (cdecl *)(void)) nullFunc;
//  carrstatrs      = (int (cdecl *)(void)) nullFunc;
//  statrs          = (int (cdecl *)(void)) nullFunc;
//  flushrs         = nullFunc;
//  getrs           = (int (cdecl *)(void)) nullFunc;
//  putrs           = (void (cdecl *)(char)) nullFunc;
//  dtrrs           = (void (cdecl *)(int)) nullFunc;
//  flushoutrs      = nullFunc;
#else
    // Start using BIOS
    charattr = bioschar;
    stringattr = biosstring;

    // com
    initrs          = InitRS;
    deinitrs        = DeInitRS;
    ringstatrs      = RingStatRS;
    carrstatrs      = CarrStatRS;
    statrs          = StatRS;
    flushrs         = FlushRS;
    getrs           = GetRS;
    putrs           = PutRS;
    dtrrs           = DtrRS;
    flushoutrs      = nullFunc;

    // ups
    initups         = nullFunc;
    deinitups       = nullFunc;
    statups         = NULL;

    // kbd
    initkbd         = nullFunc;
    deinitkbd       = nullFunc;
    statcon         = StatCON;
    getcon          = GetCON;
    sp_press        = special_pressed;

    // snd
    init_sound      = (int (cdecl *)(void)) nullFunc;
    close_sound     = (int (cdecl *)(void)) nullFunc;
    get_version     = (int (cdecl *)(void)) nullFunc;
    query_drivers   = (int (cdecl *)(void)) nullFunc;
    query_status    = (int (cdecl *)(void)) nullFunc;
    start_snd_src   = (int (cdecl *)(int, const void *)) nullFunc;
    play_sound      = (int (cdecl *)(int)) nullFunc;
    stop_sound      = (int (cdecl *)(int)) nullFunc;
    pause_sound     = (int (cdecl *)(int)) nullFunc;
    resume_sound    = (int (cdecl *)(int)) nullFunc;
    read_snd_stat   = (int (cdecl *)(int)) nullFunc;
    set_midi_map    = (int (cdecl *)(int)) nullFunc;
    get_src_vol     = (int (cdecl *)(int)) nullFunc;
    set_src_vol     = (int (cdecl *)(int, int)) nullFunc;
    set_fade_pan    = (int (cdecl *)(void *)) nullFunc;
    strt_fade_pan   = (int (cdecl *)(void)) nullFunc;
    stop_fade_pan   = (int (cdecl *)(int)) nullFunc;
    pse_fade_pan    = (int (cdecl *)(void)) nullFunc;
    res_fade_pan    = (int (cdecl *)(void)) nullFunc;
    read_fade_pan   = (int (cdecl *)(int)) nullFunc;
    get_pan_pos     = (int (cdecl *)(int)) nullFunc;
    set_pan_pos     = (int (cdecl *)(int, int)) nullFunc;
    say_ascii       = (int (cdecl *)(const char *, int)) nullFunc;
#endif

    parseArgs(argc, argv);

#ifndef WINCIT
    if (!cfg.bios)
        {
        charattr = directchar;
        stringattr = directstring;
        }
#endif

#ifndef WINCIT
    if (!cmdLine[1])
        {
        uchar *ptr = (uchar *) MK_FP(_psp, 128);

        if (ptr[0])
            {
            memcpy(cmdLine, ptr + 1, max(128, ptr[0]));

            cmdLine[ptr[0]] = 0;
            }
        }

    OC.whichIO = CONSOLE;
#endif


    if (!initCitadel())
        {
#ifndef WINCIT
        DeinitializeTimer();
#endif
        critical(FALSE);
        exit(200);
        }


#ifndef WINCIT
    ScreenSaver.Update();
#endif

    if (BoardNameHash && hash(cfg.nodeTitle) != BoardNameHash)
        {
        crashout(getmsg(681));
        }

#ifndef WINCIT
    // Set system to a known state
    OC.Echo = BOTH;
    OC.SetOutFlag(IMPERVIOUS);
    modStat = FALSE;
    OC.whichIO = CONSOLE;

    OC.setio();

    if (!(login_pw || login_user || (slv_door && cfg.forcelogin)))
        {
        CommPort->FlushInput();
        greeting();
        }

    Cron.ResetTimer();

    if (slv_net)
        {
        doccr();

        if(read_tr_messages())
            {
            cPrintf(gettrmsg(49), slv_node);
            dump_tr_messages();
            }

        if (net_callout(slv_node))
            {
            did_net(slv_node);
            }

        ExitToMsdos = TRUE;
        }

    if (slv_door) // set according to carrier
        {
        // set baud rate even if carrier not present
        if (slv_baud != PS_ERROR)
            {
            CommPort->SetSpeed(slv_baud);
            }
        else
            {
            CommPort->SetSpeed(cfg.initbaud);
            }

        for (ModemSpeedE i = MS_300; i < MS_NUM; i = (ModemSpeedE) (i +1))
            {
            if (connectbauds[i] == bauds[CommPort->GetSpeed()])
                {
                CommPort->SetModemSpeed(i);
                break;
                }
            }

        if (CommPort->HaveConnection())
            {
            CarrierJustFound();

            OC.whichIO = MODEM;
            OC.setio();
            }
        else
            {
            OC.whichIO = CONSOLE;
            OC.setio();
            }
        }

    setdefaultTerm(TT_ANSI);

    StatusLine.Toggle();        // Turns it on (starts life off).

    ScreenSaver.SetMayTurnOn(TRUE);

    time(&LastActiveTime);
    TimeoutChecking = TRUE;

    if (*cmd_script)
        {
#ifdef WINCIT
        runScript(cmd_script, NULL);
#else
        runScript(cmd_script);
#endif
        }

    doEvent(EVT_STARTUP);
#endif
    }
コード例 #27
0
#ifndef CIRCULAR__H_
#define CIRCULAR__H_
#include"circular.h"
class NoMem{
public:
	NoMem(){}
};
void my_new_handler()
{
	throw NoMem();
}
new_handler Old_Handler_ = set_new_handler(my_new_handler);
class OutOfBounds{
public:
	OutOfBounds(){}
};
template<class T>
circhain<T>::~circhain()
{
	circhainNode<T> *next;
	circhainNode<T> *fnode = first;
	first = first->link;
	while( first != fnode){
		next = first->link;
		delete first;
		first = next;
	}

	delete first;
}
template<class T>
コード例 #28
0
SkOSWindow::SkOSWindow(void* hWnd) : fHWND(hWnd), fAGLCtx(NULL)
{
	OSStatus    result;
    WindowRef   wr = (WindowRef)hWnd;

    HIViewRef imageView, parent;
    HIViewRef rootView = HIViewGetRoot(wr);
    HIViewFindByID(rootView, kHIViewWindowContentID, &parent);
    result = HIImageViewCreate(NULL, &imageView);
	SkASSERT(result == noErr);

    result = HIViewAddSubview(parent, imageView);
	SkASSERT(result == noErr);

    fHVIEW = imageView;

    HIViewSetVisible(imageView, true);
    HIViewPlaceInSuperviewAt(imageView, 0, 0);

    if (true) {
        HILayoutInfo layout;
        layout.version = kHILayoutInfoVersionZero;
        set_bindingside(&layout.binding.left, parent, kHILayoutBindLeft);
        set_bindingside(&layout.binding.top, parent, kHILayoutBindTop);
        set_bindingside(&layout.binding.right, parent, kHILayoutBindRight);
        set_bindingside(&layout.binding.bottom, parent, kHILayoutBindBottom);
        set_axisscale(&layout.scale.x, parent);
        set_axisscale(&layout.scale.y, parent);
        set_axisposition(&layout.position.x, parent, kHILayoutPositionLeft);
        set_axisposition(&layout.position.y, rootView, kHILayoutPositionTop);
        HIViewSetLayoutInfo(imageView, &layout);
    }

    HIImageViewSetOpaque(imageView, true);
    HIImageViewSetScaleToFit(imageView, false);

	static const EventTypeSpec  gTypes[] = {
		{ kEventClassKeyboard,  kEventRawKeyDown			},
        { kEventClassKeyboard,  kEventRawKeyUp              },
		{ kEventClassMouse,		kEventMouseDown				},
		{ kEventClassMouse,		kEventMouseDragged			},
		{ kEventClassMouse,		kEventMouseMoved			},
		{ kEventClassMouse,		kEventMouseUp				},
		{ kEventClassTextInput, kEventTextInputUnicodeForKeyEvent   },
		{ kEventClassWindow,	kEventWindowBoundsChanged	},
//		{ kEventClassWindow,	kEventWindowDrawContent		},
		{ SK_MacEventClass,		SK_MacEventKind				}
	};

	EventHandlerUPP handlerUPP = NewEventHandlerUPP(SkOSWindow::EventHandler);
	int				count = SK_ARRAY_COUNT(gTypes);

	result = InstallEventHandler(GetWindowEventTarget(wr), handlerUPP,
						count, gTypes, this, nil);
	SkASSERT(result == noErr);

	gCurrOSWin = this;
	gCurrEventQ = GetCurrentEventQueue();
	gEventTarget = GetWindowEventTarget(wr);

	static bool gOnce = true;
	if (gOnce) {
		gOnce = false;
		gPrevNewHandler = set_new_handler(sk_new_handler);
	}
}
コード例 #29
0
ファイル: NodeParser.C プロジェクト: juddy/edcde
//---------------------------------------------------------------------
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);
      }
コード例 #30
0
ファイル: GException.cpp プロジェクト: 371816210/ebookdroid-1
#ifndef NEED_DJVU_MEMORY
// This is not activated when C++ memory management
// is overidden.  The overriding functions handle
// memory exceptions by themselves.
# if defined(_MSC_VER)
// Microsoft is different!
static int throw_memory_error(size_t) { G_THROW(GException::outofmemory); return 0; }
static int (*old_handler)(size_t) = _set_new_handler(throw_memory_error);
# else // !_MSC_VER
// Standard C++
static void throw_memory_error() { G_THROW(GException::outofmemory); }
#  if !defined(WIN32) && !defined(__CYGWIN32__) && !defined(OS2)
#   ifdef HAVE_STDINCLUDES
//static void (*old_handler)() = std::set_new_handler(throw_memory_error);
#   else
static void (*old_handler)() = set_new_handler(throw_memory_error);
#   endif // HAVE_STDINCLUDES
#  endif // ! WIN32
# endif // !_MSC_VER
#endif // !NEED_DJVU_MEMORY


#ifdef HAVE_NAMESPACES
}
# ifndef NOT_USING_DJVU_NAMESPACE
using namespace DJVU;
# endif
#endif