Exemplo n.º 1
0
// InitFunction: Will be called during the initialisation of each entity instance.
// It is normally used to initialise the entity (e.g. collision setup) and the private variables.
void VisMouseCamera_cl::InitFunction()
{
  BaseInit();

  m_SpeedMode = 0;
  m_walkMode = NONE;
}
Exemplo n.º 2
0
UILabel::UILabel(UIWidget *ptr , const std::string &t) {
	
	BaseInit();
	AddParent(ptr);
	Init();
	text = t;
}
Exemplo n.º 3
0
bool Tokenizer::Init(const wxString& filename, LoaderBase* loader)
{
    m_pLoader = loader;
    BaseInit();
    if (filename.IsEmpty())
    {
        if (m_Filename.IsEmpty())
        {
//            cbMessageBox(_T("Tokenizer::Init() called without filename..."));
            return false;
        }
    }
    else
        m_Filename = filename;

    if (!wxFileExists(m_Filename))
        return false;

    if (!ReadFile())
    {
//        cbMessageBox(_T("File ") + filename + _T(" does not exist..."));
        return false;
    }

    if (!m_BufferLen)
    {
        //cbMessageBox("File is empty!");
        return false;
    }

    m_IsOK = true;
    return true;
}
Exemplo n.º 4
0
fresult OpenSpaceStatusBar::Init(Size sz, Repositories* reps, Factories* facts)
{
	fresult fres;
	fres = BaseInit(sz, reps, facts);
	ENSURESUCCESS(fres);

	_batteryImagesCount =5;
	_batteryImages[0] = battery_0;
	_batteryImages[1] = battery_1;
	_batteryImages[2] = battery_2;
	_batteryImages[3] = battery_3;
	_batteryImages[4] = battery_4;

	_networkImagesCount =5;
	_NetworkImages[0] = signal_0;
	_NetworkImages[1] = signal_1;
	_NetworkImages[2] = signal_2;
	_NetworkImages[3] = signal_3;
	_NetworkImages[4] = signal_4;

	fres = CreateStatusBar();
	ENSURESUCCESS(fres);

	return SUCCESS;
}
Exemplo n.º 5
0
bool Tokenizer::InitFromBuffer(const wxString& buffer)
{
    BaseInit();
    m_Buffer = buffer;
    m_BufferLen = buffer.Length();
    m_IsOK = true;
    m_Filename.Clear();
    return true;
}
Exemplo n.º 6
0
void ClothEntity_cl::InitFunction()
{
  m_vCurrentPos = GetPosition();
  m_vCurrentOri = GetOrientation();
  BaseInit();
  if (!GetMesh())
    return;
  const char *szModel = GetMesh()->GetFilename();
  SetMeshModel(szModel,m_vCurrentScaling);
}
Exemplo n.º 7
0
bool Tokenizer::InitFromBuffer(const wxString& buffer, const wxString& fileOfBuffer, size_t initLineNumber)
{
    BaseInit();
    m_BufferLen = buffer.Length();
    m_Buffer = buffer + _T(" "); // + 1 => sentinel
    m_IsOK = true;
    m_Filename = fileOfBuffer;
    m_LineNumber = initLineNumber;
    return true;
}
Exemplo n.º 8
0
fresult MedStressForm::Init( Repositories* reps, Factories* facts, char* name, FormManager* frmmngr, OpenSpaceApp* app, OpenSpaceLogic* logic )
{
	fresult fres;
	_TitleText = "Медицина/";
	_SubtitleText = "Стрессы";

	fres = BaseInit(sbdmTitles, reps,facts, name, frmmngr, app, logic);
	ENSURESUCCESS(fres);

	return SUCCESS;
}
Exemplo n.º 9
0
void Location::DisposeLoc () {
    BaseInit();
    extref = false;
    pcrel = false;
    length = -1;
    address = -1;
    oldValue = INVALIDVAL;
    indirect = false;
    cnext = locFreeList;
    locFreeList = this;
}
Exemplo n.º 10
0
fresult YNDialogForm::Init( Repositories* reps, Factories* facts, char* name, FormManager* frmmngr, OpenSpaceApp* app, OpenSpaceLogic* logic )
{
	fresult fres;

	fres = BaseInit(sbdmTitles, reps,facts, name, frmmngr, app, logic);
	ENSURESUCCESS(fres);

	_dialogName = NULL;

	return SUCCESS;
}
Exemplo n.º 11
0
UITextbox::UITextbox(UIWidget *ptr) {
	AddParent(ptr);
	BaseInit();
	height = 19;
	char_height = 13;
	char_width = 8;
	padding = 4.0f;
	SetBounds(UIRect(10,10,100,0));
	SetBgColor(kNone, UIColor(180,180,180,255));

}
Exemplo n.º 12
0
// ---------------------------------------------------------------------------------
// Method: Serialize
// Author: Fabian Roeken, Patrick Harms
// ---------------------------------------------------------------------------------
void VisMouseCamera_cl::Serialize( VArchive& ar )
{
  VisBaseEntity_cl::Serialize( ar );

  if ( ar.IsLoading() )
  {
    ar >> m_SpeedMode;

    // all base initialization takes place now :-)
    BaseInit();
  }
Exemplo n.º 13
0
fresult MedChooseWoundForm::Init( Repositories* reps, Factories* facts, char* name, FormManager* frmmngr, OpenSpaceApp* app, OpenSpaceLogic* logic )
{
	fresult fres;
	_TitleText = "Медицина/";
	_SubtitleText = "Добавить\nпроблему";

	fres = BaseInit(sbdmTitles, reps,facts, name, frmmngr, app, logic);
	ENSURESUCCESS(fres);

	return SUCCESS;
}
Exemplo n.º 14
0
fresult NewWoundForm::Init( Repositories* reps, Factories* facts, char* name, FormManager* frmmngr, Honor2App* app, Honor2Logic* logic )
{
	fresult fres;
	fres = BaseInit(TRUE,reps,facts, name, frmmngr, app, logic);
	ENSURESUCCESS(fres);

	_woundSelected = FALSE;
	_target =  UnknownTarget;

		return SUCCESS;
}
Exemplo n.º 15
0
void BaseUnitTest() 
{
	bool baseOk = false;
	
    SetConsoleTitle("Unit-Test: base.c/ base.h");
	
	printf("\n\t\t\tTEST BEGINN");
	
	baseOk = BaseInit("G:\\Coding\\buildcfg\\unittest\\base");
	
	if(!baseOk){
		printf("\aDatei konnte nicht geoeffnnet werden\n\n");
		return;
	}
	
	printf("Test der Zeichen-Funktonen:\n\n");
	printf("\t Erstes Zeichen, mit Cur(): %c, Pos: %ld [ \'a\' erwartet, Pos: 0 (\'a\') ]\n", Cur(), ftell( base->datei ) );
	printf("\t Zweites Zeichen mit Next(): %c, Pos: %ld[ \'z\' erwartet, Pos: 0 (\'a\') ]\n", Next(), ftell( base->datei ) );
	printf("\t Zweites Zeichen mit Fwd(): %c, Pos: %ld [\'z\' erwartet, Pos: 0 (\'z\') ]\n", Fwd(), ftell( base->datei) );
	printf("\t Erstes Zeichen mit Last(): %c, Pos: %ld [\'a\' erwartet, Pos: 1 (\'z\') ]\n", Last(), ftell( base->datei) );
	printf("\t Erstes Zeichen mit Rwd(): %c, Pos: %ld [\'a\' erwartet, Pos: 1 (\'a\') ]\n", Rwd(), ftell( base->datei ) );
	printf("\t Erstes Zeichen mit Cur(): %c, Pos: %ld [\'a\' erwartet, Pos: 0 (\'a\') ]\n", Cur(), ftell( base->datei ) );

	printf(" Skip(): ");
	printf("\n\tIn Zeile 2 wechseln.\n\n");
	
	while( Cur() != '\n'){
		Fwd();
	}
	Fwd();
	printf("\n\tSchleife beendet!");
	Skip();
	printf("\n\n\t naechtes Zeichen: %c, Zeile  (F erwartet, in Zeile 13 oder so)\n\n", Cur());
	
	printf(" GetLineCount():\n\n");
	printf("\n\n\t\t200 Zeichen weiter...\n\n");
	
	for(int i = 0; i < 200; i++) Fwd();
	printf("\t\tDatei-Position vorher: %ld\n\n", ftell( base->datei ));
	printf("\t\tDas sollte Zeile: %d sein.\n\n", GetLineCount());
	printf("\t\tUnd das die Position nachher: %ld", ftell( base->datei ));
	printf("\nBaseClose():\n\n");
	BaseClose();
	
	if( base ){
		printf("\t\nBaseClose fehlgeschlagen!\n");
		return;
	}else{
		printf("\t\nBaseClose erfolgreich!\n");
	}
	
	printf("\n\n\t\t\tTEST ABGESCHLOSSEN\n\n");
}
Exemplo n.º 16
0
void VFreeCamera::Serialize(VArchive& ar)
{
  VisBaseEntity_cl::Serialize(ar);

  if (ar.IsLoading())
  {
    int iLocalVersion;
    ar >> iLocalVersion;
    VASSERT_MSG(iLocalVersion <= VFREECAMERA_VERSION_CURRENT && iLocalVersion >= VFREECAMERA_VERSION_0, "Invalid local version. Please re-export");

    BaseInit();

    if (iLocalVersion >= VFREECAMERA_VERSION_3)
    {
      ar >> m_fSensitivity;
      ar >> m_fMoveSpeed;
    }
Exemplo n.º 17
0
bool Tokenizer::Init(const wxString& filename, LoaderBase* loader)
{
    m_Loader = loader;
    BaseInit();
    if (filename.IsEmpty())
    {
        if (m_Filename.IsEmpty())
        {
            TRACE(_T("Init() : Called without filename."));
            return false;
        }
    }
    else
    {
        m_Filename = filename;
        TRACE(_T("Init() : m_Filename='%s'"), m_Filename.wx_str());
#ifdef CC_PARSER_TEST
        TRACE2_SET_FLAG(filename);
        TRACE2(filename);
#endif
    }

    if (!wxFileExists(m_Filename))
    {
        TRACE(_T("Init() : File '%s' does not exist."), m_Filename.wx_str());
        return false;
    }

    if (!ReadFile())
    {
        TRACE(_T("Init() : File '%s' could not be read."), m_Filename.wx_str());
        return false;
    }

    if (!m_BufferLen)
    {
        TRACE(_T("Init() : File '%s' is empty."), m_Filename.wx_str());
        return false;
    }

    m_IsOK = true;
    return true;
}
Exemplo n.º 18
0
void ClothEntity_cl::Serialize( VArchive &ar )
{
  if (ar.IsLoading())
  {
    VisBaseEntity_cl::Serialize(ar);
    char iVersion,iModelType;
    char szModelFile[FS_MAX_PATH+1];
    int iReserved;
    bool bTemp;
    hkvVec4 vPos,vOri;
    ar >> iVersion;VASSERT(iVersion==0 || iVersion==1);
    ar >> iModelType;VASSERT(iModelType==0); // currently from file only. Later maybe planar subdiv.
    ar.ReadStringBinary(szModelFile,FS_MAX_PATH);
    ar >> vPos;
    ar >> vOri;
    if (iVersion>=1)
      m_vCurrentScaling.SerializeAsVisVector (ar);

    ar >> m_fPhysicsTicks;
    ar >> bTemp;m_bSimulateWhenVisible=bTemp;
    ar >> m_fGravity;

    BaseInit();
    
    m_vCurrentPos = vPos.getAsVec3 (); // do not apply delta in SetClothPosition
    SetMeshModel(szModelFile, m_vCurrentScaling);

    ar >> bTemp; // has mesh?
    if (bTemp)
    {
      VASSERT(m_spMesh!=NULL);
      m_spMesh->SerializeX(ar);;
    }
    ar >> m_iInitialTickCount;
    ar >> iReserved; VASSERT(iReserved==0);

    //SetClothPosition(vPos); 
    SetClothOrientation(vOri.getAsVec3 ());
    ResetForces();
    //SetRelativeLightGridSamplePos(vLGRelPos);
    m_iRemainingInitialTicks = m_iInitialTickCount;
    RunInitialTicks();
  } else
Exemplo n.º 19
0
//Initialization;
fresult TextField::Init(Size size, Position position, char* buff, Size buffSize, IRender* renderer )
{
	fresult fres;
	fres = BaseInit(size, position, renderer);
	if (fres != SUCCESS)
	{
		return fres;
	}
	
	_ScrollPositionTx.Left = 0;
	_ScrollPositionTx.Top = 0;

	
	//Defaulting:
	_Format.BgColor = ThreeK_DEFAULT_TEXTFIELD_BACKGROUND;
	_Format.FgColor = ThreeK_DEFAULT_TEXTFIELD_FOREGROUND;
	//Get Default font
	fres = GetFontById(ThreeK_DEFAULT_TEXTFIELD_FONT, &(_Format.Font));
	if (fres != SUCCESS)
	{
		return fres;
	}
	
	SetSize(size);

	_Position = position;
	_render = renderer;

	_textBuff = buff;
	_textBuffSizeTx = buffSize;
	_buffLength = buffSize.Height*buffSize.Width;

	_WordWrap = false;

	_textBuffCarretPositionTx.data =0;

	return SUCCESS;
};
Exemplo n.º 20
0
UIListbox::UIListbox(UIWidget *ptr) {
	AddParent(ptr);
	BaseInit();
	char_width = 8;
	char_height = 13;
	SetViewCount(3);
	SetBounds(UIRect(10,10,100,100));
	item_height = 15;
	selected_text = UIColor(0,0,0);
	selected_bg = UIColor(100,142,208);
	SetBgColor(kNone, UIColor(39,39,39));
	SetFontColor(kNone, UIColor(253,253,253));
	button_color = UIColor(159,159,159);
	view_pos = 0;
	selected_index = 0;
	tri_offsetx = 4;
	tri_offsety = 3;
	tri_length = 8;
	chat_mode = false;
	max_lines = 100;
	
	//icon = new UIImage(NULL);
}
Exemplo n.º 21
0
UILabel::UILabel(UIWidget *ptr) {
	
	BaseInit();
	AddParent(ptr);
	Init();
}
Exemplo n.º 22
0
Base::Base (What id) {
    this->id = id;
    BaseInit();
}
Exemplo n.º 23
0
UILabel::UILabel() {
	BaseInit();
	Init();
}
Exemplo n.º 24
0
/**
 * This method is called after fork of the sweeper process. It sets up signal
 * handlers and does initialization that is required by a postgres backend.
 */
NON_EXEC_STATIC void
BackoffSweeperMain(int argc, char *argv[])
{
	sigjmp_buf	local_sigjmp_buf;

	IsUnderPostmaster = true;
	isSweeperProcess = true;

	/* Stay away from PMChildSlot */
	MyPMChildSlot = -1;

	/* reset MyProcPid */
	MyProcPid = getpid();

	/* Lose the postmaster's on-exit routines */
	on_exit_reset();

	/* Identify myself via ps */
	init_ps_display("sweeper process", "", "", "");

	SetProcessingMode(InitProcessing);

	/*
	 * Set up signal handlers.  We operate on databases much like a regular
	 * backend, so we use the same signal handling.  See equivalent code in
	 * tcop/postgres.c.
	 */
	pqsignal(SIGHUP, SIG_IGN);
	pqsignal(SIGINT, SIG_IGN);
	pqsignal(SIGALRM, SIG_IGN);
	pqsignal(SIGPIPE, SIG_IGN);
	pqsignal(SIGUSR1, SIG_IGN);

	pqsignal(SIGTERM, die);
	pqsignal(SIGQUIT, quickdie);
	pqsignal(SIGUSR2, BackoffRequestShutdown);

	pqsignal(SIGFPE, FloatExceptionHandler);
	pqsignal(SIGCHLD, SIG_DFL);

	/*
	 * Copied from bgwriter
	 */
	CurrentResourceOwner = ResourceOwnerCreate(NULL, "Sweeper process");

	/* Early initialization */
	BaseInit();

	/* See InitPostgres()... */
	InitProcess();

	SetProcessingMode(NormalProcessing);

	/*
	 * If an exception is encountered, processing resumes here.
	 *
	 * See notes in postgres.c about the design of this coding.
	 */
	if (sigsetjmp(local_sigjmp_buf, 1) != 0)
	{
		/* Prevents interrupts while cleaning up */
		HOLD_INTERRUPTS();

		/* Report the error to the server log */
		EmitErrorReport();

		/*
		 * We can now go away.  Note that because we'll call InitProcess, a
		 * callback will be registered to do ProcKill, which will clean up
		 * necessary state.
		 */
		proc_exit(0);
	}

	/* We can now handle ereport(ERROR) */
	PG_exception_stack = &local_sigjmp_buf;

	PG_SETMASK(&UnBlockSig);

	MyBackendId = InvalidBackendId;

	/* main loop */
	BackoffSweeperLoop();

	/* One iteration done, go away */
	proc_exit(0);
}
Exemplo n.º 25
0
/*
 * AutoVacMain
 */
NON_EXEC_STATIC void
AutoVacMain(int argc, char *argv[])
{
    ListCell   *cell;
    List	   *dblist;
    autovac_dbase *db;
    TransactionId xidForceLimit;
    bool		for_xid_wrap;
    sigjmp_buf	local_sigjmp_buf;

    /* we are a postmaster subprocess now */
    IsUnderPostmaster = true;
    am_autovacuum = true;

    /* MPP-4990: Autovacuum always runs as utility-mode */
    Gp_role = GP_ROLE_UTILITY;

    /* reset MyProcPid */
    MyProcPid = getpid();

    /* record Start Time for logging */
    MyStartTime = time(NULL);

    /* Identify myself via ps */
    init_ps_display("autovacuum process", "", "", "");

    SetProcessingMode(InitProcessing);

    /*
     * If possible, make this process a group leader, so that the postmaster
     * can signal any child processes too.  (autovacuum probably never has
     * any child processes, but for consistency we make all postmaster
     * child processes do this.)
     */
#ifdef HAVE_SETSID
    if (setsid() < 0)
        elog(FATAL, "setsid() failed: %m");
#endif

    /*
     * Set up signal handlers.	We operate on databases much like a regular
     * backend, so we use the same signal handling.  See equivalent code in
     * tcop/postgres.c.
     *
     * Currently, we don't pay attention to postgresql.conf changes that
     * happen during a single daemon iteration, so we can ignore SIGHUP.
     */
    pqsignal(SIGHUP, SIG_IGN);

    /*
     * SIGINT is used to signal cancelling the current table's vacuum; SIGTERM
     * means abort and exit cleanly, and SIGQUIT means abandon ship.
     */
    pqsignal(SIGINT, StatementCancelHandler);
    pqsignal(SIGTERM, die);
    pqsignal(SIGQUIT, quickdie);
    pqsignal(SIGALRM, handle_sig_alarm);

    pqsignal(SIGPIPE, SIG_IGN);
    pqsignal(SIGUSR1, procsignal_sigusr1_handler);
    /* We don't listen for async notifies */
    pqsignal(SIGUSR2, SIG_IGN);
    pqsignal(SIGFPE, FloatExceptionHandler);
    pqsignal(SIGCHLD, SIG_DFL);

    /* Early initialization */
    BaseInit();

    /*
     * Create a per-backend PGPROC struct in shared memory, except in the
     * EXEC_BACKEND case where this was done in SubPostmasterMain. We must do
     * this before we can use LWLocks (and in the EXEC_BACKEND case we already
     * had to do some stuff with LWLocks).
     */
#ifndef EXEC_BACKEND
    InitProcess();
#endif

    /*
     * If an exception is encountered, processing resumes here.
     *
     * See notes in postgres.c about the design of this coding.
     */
    if (sigsetjmp(local_sigjmp_buf, 1) != 0)
    {
        /* Prevents interrupts while cleaning up */
        HOLD_INTERRUPTS();

        /* Report the error to the server log */
        EmitErrorReport();

        /*
         * We can now go away.	Note that because we called InitProcess, a
         * callback was registered to do ProcKill, which will clean up
         * necessary state.
         */
        proc_exit(0);
    }

    /* We can now handle ereport(ERROR) */
    PG_exception_stack = &local_sigjmp_buf;

    PG_SETMASK(&UnBlockSig);

    /*
     * Force zero_damaged_pages OFF in the autovac process, even if it is set
     * in postgresql.conf.	We don't really want such a dangerous option being
     * applied non-interactively.
     */
    SetConfigOption("zero_damaged_pages", "false", PGC_SUSET, PGC_S_OVERRIDE);

    /* Get a list of databases */
    dblist = autovac_get_database_list();

    /*
     * Determine the oldest datfrozenxid/relfrozenxid that we will allow
     * to pass without forcing a vacuum.  (This limit can be tightened for
     * particular tables, but not loosened.)
     */
    recentXid = ReadNewTransactionId();
    xidForceLimit = recentXid - autovacuum_freeze_max_age;
    /* ensure it's a "normal" XID, else TransactionIdPrecedes misbehaves */
    if (xidForceLimit < FirstNormalTransactionId)
        xidForceLimit -= FirstNormalTransactionId;

    /*
     * Choose a database to connect to.  We pick the database that was least
     * recently auto-vacuumed, or one that needs vacuuming to prevent Xid
     * wraparound-related data loss.  If any db at risk of wraparound is
     * found, we pick the one with oldest datfrozenxid,
     * independently of autovacuum times.
     *
     * Note that a database with no stats entry is not considered, except for
     * Xid wraparound purposes.  The theory is that if no one has ever
     * connected to it since the stats were last initialized, it doesn't need
     * vacuuming.
     *
     * XXX This could be improved if we had more info about whether it needs
     * vacuuming before connecting to it.  Perhaps look through the pgstats
     * data for the database's tables?  One idea is to keep track of the
     * number of new and dead tuples per database in pgstats.  However it
     * isn't clear how to construct a metric that measures that and not cause
     * starvation for less busy databases.
     */
    db = NULL;
    for_xid_wrap = false;
    foreach(cell, dblist)
    {
        autovac_dbase *tmp = lfirst(cell);

        /* Find pgstat entry if any */
        tmp->entry = pgstat_fetch_stat_dbentry(tmp->oid);

        /* Check to see if this one is at risk of wraparound */
        if (TransactionIdPrecedes(tmp->frozenxid, xidForceLimit))
        {
            if (db == NULL ||
                    TransactionIdPrecedes(tmp->frozenxid, db->frozenxid))
                db = tmp;
            for_xid_wrap = true;
            continue;
        }
        else if (for_xid_wrap)
            continue;			/* ignore not-at-risk DBs */

        /*
         * Otherwise, skip a database with no pgstat entry; it means it
         * hasn't seen any activity.
         */
        if (!tmp->entry)
            continue;

        /*
         * Remember the db with oldest autovac time.  (If we are here,
         * both tmp->entry and db->entry must be non-null.)
         */
        if (db == NULL ||
                tmp->entry->last_autovac_time < db->entry->last_autovac_time)
            db = tmp;
    }
Exemplo n.º 26
0
void
ContQuerySchedulerMain(int argc, char *argv[])
{
	sigjmp_buf local_sigjmp_buf;
	List *dbs = NIL;

	/* we are a postmaster subprocess now */
	IsUnderPostmaster = true;
	am_cont_scheduler = true;

	/* reset MyProcPid */
	MyProcPid = getpid();
	MyPMChildSlot = AssignPostmasterChildSlot();

	/* record Start Time for logging */
	MyStartTime = time(NULL);

	/* Identify myself via ps */
	init_ps_display("continuous query scheduler process", "", "", "");

	ereport(LOG, (errmsg("continuous query scheduler started")));

	if (PostAuthDelay)
		pg_usleep(PostAuthDelay * 1000000L);

	SetProcessingMode(InitProcessing);

	/*
	 * If possible, make this process a group leader, so that the postmaster
	 * can signal any child processes too. This is only for consistency sake, we
	 * never fork the scheduler process. Instead dynamic bgworkers are used.
	 */
#ifdef HAVE_SETSID
	if (setsid() < 0)
		elog(FATAL, "setsid() failed: %m");
#endif

	/*
	 * Set up signal handlers.  We operate on databases much like a regular
	 * backend, so we use the same signal handling.  See equivalent code in
	 * tcop/postgres.c.
	 */
	pqsignal(SIGHUP, sighup_handler);
	pqsignal(SIGINT, sigint_handler);
	pqsignal(SIGTERM, sigterm_handler);

	pqsignal(SIGQUIT, quickdie);
	InitializeTimeouts(); /* establishes SIGALRM handler */

	pqsignal(SIGPIPE, SIG_IGN);
	pqsignal(SIGUSR1, procsignal_sigusr1_handler);
	pqsignal(SIGUSR2, sigusr2_handler);
	pqsignal(SIGFPE, FloatExceptionHandler);
	pqsignal(SIGCHLD, SIG_DFL);

#define BACKTRACE_SEGFAULTS
#ifdef BACKTRACE_SEGFAULTS
	pqsignal(SIGSEGV, debug_segfault);
#endif

	/* Early initialization */
	BaseInit();

	/*
	 * Create a per-backend PGPROC struct in shared memory, except in the
	 * EXEC_BACKEND case where this was done in SubPostmasterMain. We must do
	 * this before we can use LWLocks (and in the EXEC_BACKEND case we already
	 * had to do some stuff with LWLocks).
	 */
#ifndef EXEC_BACKEND
	InitProcess();
#endif

	InitPostgres(NULL, InvalidOid, NULL, NULL);

	SetProcessingMode(NormalProcessing);

	/*
	 * Create a memory context that we will do all our work in.  We do this so
	 * that we can reset the context during error recovery and thereby avoid
	 * possible memory leaks.
	 */
	ContQuerySchedulerMemCxt = AllocSetContextCreate(TopMemoryContext,
			"ContQuerySchedulerCtx",
			ALLOCSET_DEFAULT_MINSIZE,
			ALLOCSET_DEFAULT_INITSIZE,
			ALLOCSET_DEFAULT_MAXSIZE);
	MemoryContextSwitchTo(ContQuerySchedulerMemCxt);

	/*
	 * If an exception is encountered, processing resumes here.
	 *
	 * This code is a stripped down version of PostgresMain error recovery.
	 */
	if (sigsetjmp(local_sigjmp_buf, 1) != 0)
	{
		/* since not using PG_TRY, must reset error stack by hand */
		error_context_stack = NULL;

		/* Prevents interrupts while cleaning up */
		HOLD_INTERRUPTS();

		/* Forget any pending QueryCancel or timeout request */
		disable_all_timeouts(false);
		QueryCancelPending = false; /* second to avoid race condition */

		/* Report the error to the server log */
		EmitErrorReport();

		/* Abort the current transaction in order to recover */
		AbortCurrentTransaction();

		/*
		 * Now return to normal top-level context and clear ErrorContext for
		 * next time.
		 */
		MemoryContextSwitchTo(ContQuerySchedulerMemCxt);
		FlushErrorState();

		/* Flush any leaked data in the top-level context */
		MemoryContextResetAndDeleteChildren(ContQuerySchedulerMemCxt);

		/* Now we can allow interrupts again */
		RESUME_INTERRUPTS();

		/*
		 * Sleep at least 1 second after any error.  We don't want to be
		 * filling the error logs as fast as we can.
		 */
		pg_usleep(1000000L);
	}
	/* We can now handle ereport(ERROR) */
	PG_exception_stack = &local_sigjmp_buf;

	/* must unblock signals before calling rebuild_database_list */
	PG_SETMASK(&UnBlockSig);

	ContQuerySchedulerShmem->scheduler_pid = MyProcPid;

	dbs = get_database_list();

	/* Loop forever */
	for (;;)
	{
		ListCell *lc;
		int rc;

		foreach(lc, dbs)
		{
			DatabaseEntry *db_entry = lfirst(lc);
			bool found;
			ContQueryProcGroup *grp = hash_search(ContQuerySchedulerShmem->proc_table, &db_entry->oid, HASH_ENTER, &found);

			/* If we don't have an entry for this dboid, initialize a new one and fire off bg procs */
			if (!found)
			{
				grp->db_oid = db_entry->oid;
				namestrcpy(&grp->db_name, NameStr(db_entry->name));

				start_group(grp);
			}
		}

		/* Allow sinval catchup interrupts while sleeping */
		EnableCatchupInterrupt();

		/*
		 * Wait until naptime expires or we get some type of signal (all the
		 * signal handlers will wake us by calling SetLatch).
		 */
		rc = WaitLatch(&MyProc->procLatch, WL_LATCH_SET | WL_POSTMASTER_DEATH, 0);

		ResetLatch(&MyProc->procLatch);

		DisableCatchupInterrupt();

		/*
		 * Emergency bailout if postmaster has died.  This is to avoid the
		 * necessity for manual cleanup of all postmaster children.
		 */
		if (rc & WL_POSTMASTER_DEATH)
			proc_exit(1);

		/* the normal shutdown case */
		if (got_SIGTERM)
			break;

		/* update config? */
		if (got_SIGHUP)
		{
			got_SIGHUP = false;
			ProcessConfigFile(PGC_SIGHUP);

			/* update tuning parameters, so that they can be read downstream by background processes */
			update_tuning_params();
		}

		/* terminate a proc group? */
		if (got_SIGUSR2)
		{
			HASH_SEQ_STATUS status;
			ContQueryProcGroup *grp;

			got_SIGUSR2 = false;

			hash_seq_init(&status, ContQuerySchedulerShmem->proc_table);
			while ((grp = (ContQueryProcGroup *) hash_seq_search(&status)) != NULL)
			{
				ListCell *lc;

				if (!grp->terminate)
					continue;

				foreach(lc, dbs)
				{
					DatabaseEntry *entry = lfirst(lc);
					if (entry->oid == grp->db_oid)
					{
						dbs = list_delete(dbs, entry);
						break;
					}
				}

				terminate_group(grp);
			}
		}
Exemplo n.º 27
0
int main(int argc, char* argv[]) {
  struct bParamList * paramList = NULL;
  const char *strPtr;

  int ii;

  for (ii=0; ii<TCX_MAX_CLIENTS; ii++) {
    CLIENT[ii] = NULL;
  }

  /*
   * Set some parameters
   */

  /* add some defaults */
  paramList = bParametersAddEntry(paramList, "*", "base.bps", "9600");
  paramList = bParametersAddEntry(paramList, "*", "base.dev", "/dev/cur0");
  paramList = bParametersAddEntry(paramList, "", "TCXHOST", "localhost");
  paramList = bParametersAddEntry(paramList, "", "fork", "yes");

  /* add some parameter files */
  paramList = bParametersAddFile(paramList, "etc/beeSoft.ini");

  /* add some enviroment variables */
  paramList = bParametersAddEnv(paramList, "", "TCXHOST");

  /* add command line arguements */
  paramList = bParametersAddArray(paramList, "", argc, argv);

  /* here is where we should add non "parameter format" options */


  bParametersFillParams(paramList);

  strPtr = bParametersGetParam(paramList, "robot", "name");
  if (!strPtr) {
    fprintf(stderr,
	    "Robot name not set.  Check the value in beeSoft.ini.\n");
    exit(1);
  }
  else if (!strcmp("none", strPtr)) {
    fprintf(stderr,
	    "Robot name set to 'none'.  Check value in beeSoft.ini.\n");
    exit(1);
  }

  strPtr = bParametersGetParam(paramList, strPtr, "base.type");
  if (!strPtr) {
    fprintf(stderr,
	    "Base type not set.  Check the value in beeSoft.ini.\n");
    exit(1);
  }
  else if (
	   strcmp("B14", strPtr) &&
	   strcmp("B21", strPtr) &&
	   strcmp("Ramona", strPtr)
	   ) {
    fprintf(stderr,
	    "Arm type set to unrecognized type '%s'.  Check the\n"
	    "value in beeSoft.ini.\n", strPtr);
    exit(1);
  }
  
  /*
   *
   */

  argv0 = argv[0];

  if (makeLock(BASE_SERVER_LOCK)<0) {
    fprintf(stderr,"%s:  Already running base server\n",argv[0]);
    exit(-1);
  }

  if (findArg(argc,argv,"-v")) {
    VERBOSE = TRUE;
    fprintf(stderr,"baseServer started in verbose mode\n");
  }

  if (findArg(argc,argv,"-noIrs")) {
    IRS = FALSE;
    fprintf(stderr,"baseServer started without IRs\n");
  }

  if (findArg(argc,argv,"-noTactiles")) {
    TACTILES = FALSE;
    fprintf(stderr,"baseServer started without Tactiles\n");
  }

  if (findArg(argc,argv,"-noSonars")) {
    SONARS= FALSE;
    fprintf(stderr,"baseServer started without Sonars\n");
  }

  if (findArg(argc,argv,"-simulator")) {
    useSimulator=TRUE;
    fprintf(stderr,"baseServer connecting to simulator.\n");
  }

  
  RaiInit();
  BaseInit(bRobot.base_dev, bRobot.base_bps);
  catchInterrupts();

  initBaseServerTCX(bRobot.TCXHOST);

  if (useSimulator==TRUE) {
    simulatorHandle = tcxConnectModule(TCX_SIMULATOR_MODULE_NAME);
  }

  registerWatchdogCallback(watchdogToClient);

  /*
   * GRUMBLE - It is going to be a bit ugly to get the sensor
   * structures initialized without opening /dev/abus.  tds
   */

  if (SONARS && !useSimulator) {
    sonarInit();
    registerSonarCallback(sonarToClient);
    SIM_sonarStop();  /* turn off sonar until we have a client */
  }

  if (IRS && !useSimulator) {
    irInit();
    registerIrCallback(irToClient);
    SIM_irStop();  /* turn off ir until we have a client */
  }

  if (TACTILES && !useSimulator) {
    tactileInit();
    registerTactileCallback(tactileToClient);
    tactileStop();
  }

  registerStatusCallback(statusToClient);
  registerBaseCallback(baseToClient);
  initBaseServerModules();

  if (bRobot.fork) {
    bDaemonize("baseServer.log");
  }

  rotateLimp(); 
  translateLimp(); 

  RaiStart();

  exit(0);
}
Exemplo n.º 28
0
// Driver Entry routine
//		This routine is called when the driver is loaded.
//		Usually, this is where any devices associated with
//		the driver are created.
//
//		The driver often reads the registry at DriverEntry in
//		order to setup various configurable parameters.
//		
//		Driver::Works makes it easy to use the registry to also
//		control what devices are present and should be created.
//
NTSTATUS FSAVP::DriverEntry(PUNICODE_STRING RegistryPath)
{
	NTSTATUS status=STATUS_INSUFFICIENT_RESOURCES;
//return status;
	// Status of device creation
//	DbgPrint("FSAVP: DriverEntry\n");
	SetPoolTag(' wen');			// Set default pool tag for all 'new' allocations
								// Under checked build, use POOLMON to view tags

	// Automatically load following variables from registry values
	// The default value is preloaded.  If the appropriate registry
	// value is not found, the default will be left unchanged.

	// Open the driver "Parameters" key
	pFSAVPDriver=this;
	sRegistryPath.Assign(L"");
	sRegistryPath.Append(RegistryPath->Buffer);
	KRegistryKey Params(sRegistryPath, L"Parameters");
	if (!NT_SUCCESS(Params.LastError()))
	{
		// Error, could not open registry key
		return STATUS_INSUFFICIENT_RESOURCES;
	}


#ifdef _TRACER
	Params.QueryValue(L"TraceDevice", (PULONG) &defTraceDevice);
	Params.QueryValue(L"TraceOutputLevel", (PULONG) &defTraceOutputLevel);
	Params.QueryValue(L"TraceBreakLevel", (PULONG) &defTraceBreakLevel);

	Tracer.SetTarget(defTraceDevice);
	Tracer.SetOutputLevel(defTraceOutputLevel);
	Tracer.SetBreakLevel(defTraceBreakLevel);
#endif

//#endif


// Create FSAVPDevice

	FSAVPDevice* pFSAVPDevice;
	pFSAVPDevice = new (NonPagedPool) FSAVPDevice();
	if (pFSAVPDevice == NULL)
	{
		_DebugTrace(TraceError, "Error constructing device FSAVPDevice\n");
		return STATUS_INSUFFICIENT_RESOURCES;
	}
	status = pFSAVPDevice->ConstructorStatus();
	if (!NT_SUCCESS(status))
	{
		// Error returned from a constructor
		_DebugTrace(TraceError, "Error creating device FSAVPDevice, status %x\n", status);
		delete pFSAVPDevice;
		return status;
	}
	
	status=BaseInit();
	if(!NT_SUCCESS(status))
    {
		_DebugTrace(TraceError, "Failed to INIT");
		BaseDestroy();
		delete pFSAVPDevice;
    }

	return status;
}
Exemplo n.º 29
0
void VFreeCamera::InitFunction()
{
  BaseInit();

  VisBaseEntity_cl::InitFunction();
}
Exemplo n.º 30
0
void StringInit(String* str, guint length)
{
	BaseInit(str, stringType);
	str->length = length;
	str->hash = INVALID_HASH;
}