예제 #1
0
void ReadContext(kstring file, XLContext &context)
// ----------------------------------------------------------------------------
//   Parse the syntax description table
// ----------------------------------------------------------------------------
{
    XLContext syntaxTable;

    // Enter infix priorities
    syntaxTable /
        // Separator have very low priority
        10 / "\n" /
        20 / "\t" /* Priority for blocks */
        ;

    // Enter comment descriptors
    syntaxTable.Comment("//", "\n");

    XLParser parser (file, &syntaxTable);
    XLTree *tree = parser.Parse();

    // At first, I thought it was elegant.
    // In reality, it is darn ugly. But hey, it's just throwaway code
    XLInitializeContext init(context);
    XLDo<XLInitializeContext> doInit(init);
    doInit(tree);

    // Cheat grossly, now that the C++ parser behaves differently from the
    // XL versions with respect to block priority...
    context.SetInfixPriority(INDENT_MARKER, 400);
}
예제 #2
0
int thread_mutex_unlock(struct thread_mutex_t * mutexUnlocked)
{
   critFlag = 1;
    if(!initDone)
  {
    doInit();
    initDone = 1;
  }
  if(mutexUnlocked -> threadOwner == 0)
  {
    //no thread holds the lock
    critFlag = 0;
    return 0;
  }
  else
  {
    //skip over it in mutex queue
    
    //add to ready queue
    struct TCB * myP = mutexUnlocked -> thread_head;
    struct TCB * topHead = head;
    while(topHead -> next != NULL)
    {
      topHead = topHead -> next;
    }
    topHead -> next = myP;
    mutexUnlocked -> threadOwner = (long)mutexUnlocked -> thread_head;
    mutexUnlocked -> thread_head = mutexUnlocked -> thread_head -> next;
    critFlag = 0;
    return 1;
  }
}
예제 #3
0
/*Do everything thread_yield does except call asm_special_yield() instead of asm_yield()*/
static void special_yield(void)
{
  critFlag = 1;
  if(!initDone)
  {
    doInit();
    initDone = 1;
  }
  // if ready queue is empty, return (how do I check if the ready queue is empty?) head -> next == NULL? end == head?
  if(head -> next == NULL)
  {
    //I want the thread to keep running and simply not yield
    return;
  }
  else
  {
    //rotate ready queue. first element needs to be at the end and last element needs to be at the beginning
    struct TCB * p = head;
    head = head -> next;
    free(p);
    struct TCB * next = head;
    //save current thread's state(register contents) in it's TCB and restore the next thread's state from it's TCB
    if(head -> next == NULL)
    {
      //printf("Process needs to be halted! No more active threads\n");
    } 
    critFlag = 0;
    asm_special_yield(next); 
  } 
}
예제 #4
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    doInit();
}
예제 #5
0
float DepthMap::toDepth(int d) {
	if (!init) {
		doInit();
		init = true;
	}
	return cache[d];
}
예제 #6
0
void Enumerator::init(Solver& s, uint64 m) { 
	numModels_ = m; 
	if (s.strategies().satPrePro.get() != 0) {
		s.strategies().satPrePro.get()->setEnumerate(numModels_ != 1);
	}
	doInit(s);
}
예제 #7
0
/* Constructor - this gets called when we create a new instance of
 * this class.  It should initialize all of the member variables and
 * do whatever memory allocation is necessary. */
DanceTracker::DanceTracker(IplImage* ProtoFrame, unsigned int n_obj)
    : MT_TrackerBase(ProtoFrame),
      m_iBlobValThresh(DEFAULT_BG_THRESH),
	  m_iBlobAreaThreshLow(DEFAULT_MIN_BLOB_AREA),
	  m_iBlobAreaThreshHigh(DEFAULT_MAX_BLOB_AREA),
      m_dOverlapFactor(1.0),
	  m_iSearchAreaPadding(DEFAULT_SEARCH_AREA_PADDING),      
      m_iStartFrame(-1),
      m_iStopFrame(-1),
      m_pGYBlobber(NULL),
      m_vpUKF(n_obj, NULL),
      m_dSigmaPosition(DEFAULT_SIGMA_POSITION),
      m_dSigmaHeading(DEFAULT_SIGMA_HEADING),
      m_dSigmaSpeed(DEFAULT_SIGMA_SPEED),
      m_dSigmaPositionMeas(DEFAULT_SIGMA_POSITION_MEAS),
      m_dSigmaHeadingMeas(DEFAULT_SIGMA_HEADING_MEAS),
      m_dPrevSigmaPosition(0),
      m_dPrevSigmaHeading(0),
      m_dPrevSigmaSpeed(0),
      m_dPrevSigmaPositionMeas(0),
      m_dPrevSigmaHeadingMeas(0),
      m_bShowBlobs(true),
      m_bShowTracking(true),
      m_bShowInitialBlobs(true),
      m_bShowAssociations(true),
      m_dDt(0),
      m_iFrameCounter(0),
      m_iNObj(n_obj),
      m_iFrameHeight(0),
	  m_iFrameWidth(0),
      m_YABlobber()
{
    doInit(ProtoFrame);
}
예제 #8
0
BOOL
CAdvancedOptions::doDlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM)
{
	switch (message) {
	case WM_INITDIALOG:
		doInit(hwnd);
		return TRUE;

	case WM_COMMAND:
		switch (LOWORD(wParam)) {
		case IDOK:
			if (save(hwnd)) {
				EndDialog(hwnd, 0);
			}
			return TRUE;

		case IDCANCEL:
			EndDialog(hwnd, 0);
			return TRUE;

		case IDC_ADVANCED_DEFAULTS:
			setDefaults(hwnd);
			return TRUE;
		}
		break;

	default:
		break;
	}

	return FALSE;
}
예제 #9
0
/******************************************************************************************************
  SN_Checker using OpenGL
  *******************************************************************************((((******************/
SN_CheckerGL::SN_CheckerGL(GLenum pixfmt, const QSize &imagesize, qreal framerate, const quint64 appid, const QSettings *s, SN_ResourceMonitor *rm, QGraphicsItem *parent, Qt::WindowFlags wFlags)
    : SN_Checker(imagesize, framerate, appid, s, rm, parent, wFlags)
    , _image(0)
    , _textureid(0)
    , _pixelFormat(pixfmt)
{
	switch (_pixelFormat) {
	case GL_RGB: {
		qDebug() << "24bpp";
		_image = new QImage(imagesize, QImage::Format_RGB888);
		break;
	}
	case GL_RGBA: {
		qDebug() << "32bpp";
		_image = new QImage(imagesize, QImage::Format_RGB32); // 0xffRRGGBB
		break;
	}
	}
	_appInfo->setFrameSize(_image->width(), _image->height(), _image->depth());

	_workerThread->setNumpixel(_image->width() * _image->height());
	_workerThread->setByteperpixel(_image->depth() / 8);

	//
	//
	// OpenGL related stuff need to be called after the widget has added to the Scene that has OpenGL viewport
	// Because opengl functions needs valid OpenGL context
	//
	//
	QTimer::singleShot(10, this, SLOT(doInit()));
}
예제 #10
0
/* loop forever. doState() has a switch for the actions and events to be
   checked for 'port_state'. the actions and events may or may not change
   'port_state' by calling toState(), but once they are done we loop around
   again and perform the actions required for the new 'port_state'. */
void 
protocol(RunTimeOpts *rtOpts, PtpClock *ptpClock)
{
	DBG("event POWERUP\n");

	toState(PTP_INITIALIZING, rtOpts, ptpClock);

	DBG("Debug Initializing...\n");

	for (;;)
	{
		/* 20110701: this main loop was rewritten to be more clear */

		if (ptpClock->portState == PTP_INITIALIZING) {
			if (!doInit(rtOpts, ptpClock)) {
				return;
			}
		} else {
			doState(rtOpts, ptpClock);
		}

		
		if (ptpClock->message_activity)
			DBGV("activity\n");

		/* Perform the heavy signal processing synchronously */
		check_signals(rtOpts, ptpClock);
	}
}
예제 #11
0
/******************************************************************************************************
  SN_Checker using OpenGL PBO
  *******************************************************************************((((******************/
SN_CheckerGLPBO::SN_CheckerGLPBO(GLenum pixfmt, const QSize &imagesize, qreal framerate, const quint64 appid, const QSettings *s, SN_ResourceMonitor *rm, QGraphicsItem *parent, Qt::WindowFlags wFlags)
    : SN_Checker(imagesize, framerate, appid, s, rm, parent, wFlags)
    , _textureid(0)
    , _pixelFormat(pixfmt)
    , __firstFrame(true)
    , _pboBufIdx(0)
    , __bufferMapped(false)
    , _pbomutex(0)
    , _pbobufferready(0)
{
	_workerThread->setNumpixel(_imgsize.width() * _imgsize.height());
	if (_pixelFormat == GL_RGB) {
		_appInfo->setFrameSize(_imgsize.width(), _imgsize.height(), 24);
		_workerThread->setByteperpixel(3);
	}
	else if (_pixelFormat == GL_RGBA) {
		_appInfo->setFrameSize(_imgsize.width(), _imgsize.height(), 32);
		_workerThread->setByteperpixel(4);
	}

	//
	//
	// OpenGL related stuff need to be called after the widget has added to the Scene that has OpenGL viewport
	// Because opengl functions needs valid OpenGL context
	//
	//
	QTimer::singleShot(10, this, SLOT(doInit()));
}
예제 #12
0
//*******************************************************************************
void CWaterEnvMap::renderTestMesh(IDriver &driver)
{
	doInit();
	CMaterial testMat;
	testMat.setLighting(false);
	testMat.texEnvOpRGB(0, CMaterial::Modulate);
	testMat.texEnvArg0RGB(0, CMaterial::Texture, CMaterial::SrcColor);
	testMat.texEnvArg0RGB(1, CMaterial::Diffuse, CMaterial::SrcColor);
	testMat.texEnvOpAlpha(0, CMaterial::Replace);
	testMat.texEnvArg0Alpha(0, CMaterial::Constant, CMaterial::SrcAlpha);
	testMat.texConstantColor(0, CRGBA(255, 255, 255, 255));
	testMat.setDoubleSided(true);
	testMat.setZWrite(false);
	testMat.setZFunc(CMaterial::always);
	// tmp : test cubemap
	driver.activeVertexProgram(&testMeshVP);
	driver.activeVertexBuffer(_TestVB);
	driver.activeIndexBuffer(_TestIB);
	driver.setConstantMatrix(0, IDriver::ModelViewProjection, IDriver::Identity); // tmp
	_MaterialPassThruZTest.setTexture(0, _EnvCubic);
	driver.setConstantMatrix(0, IDriver::ModelViewProjection, IDriver::Identity);
	driver.setConstant(4, 2.f, 1.f, 0.f, 0.f);
	//driver.renderTriangles(testMat, 0, TEST_VB_NUM_TRIS);
	driver.renderTriangles(_MaterialPassThruZTest, 0, TEST_VB_NUM_TRIS);
	driver.activeVertexProgram(NULL);
}
예제 #13
0
int onCheatConsole()
{
    char init_title[80];
    sprintf(init_title, "Current Data");
    init_dlg[0].dp=init_title;
    zinitdata *zinit2 = copyIntoZinit(game);
    //modify some entries
    init_dlg[1655].dp = (void *)"";
    init_dlg[1658].dp = (void *)"Current HP (hearts):";
    init_dlg[1658].flags |= D_DISABLED;
    init_dlg[1659].flags |= D_DISABLED;
    init_dlg[1663].flags |= D_DISABLED;
    init_dlg[1664].flags |= D_DISABLED;
    init_dlg[1664].dp = (void *)"";
    init_dlg[1670].flags |= D_DISABLED;
    init_dlg[1671].flags |= D_DISABLED;
    init_dlg[1667].flags |= D_DISABLED;
    init_dlg[1698].flags |= D_DISABLED;
    init_dlg[1699].flags |= D_DISABLED;
    init_dlg[1703].flags |= D_DISABLED;
    init_dlg[1704].flags |= D_DISABLED;
    init_dlg[1705].flags |= D_DISABLED;
//  the following statement has no effect, as the D_DISABLED flag is ignored by the jwin_tab_proc
//  init_tabs[4].flags |= D_DISABLED;
    int rval = doInit(zinit2);
    resetItems(game, zinit2, false);
    delete zinit2;
    ringcolor(false);
    return rval;
}
예제 #14
0
파일: enumerator.cpp 프로젝트: klusark/sat
Enumerator::EnumeratorConstraint* Enumerator::endInit(SharedContext& ctx, uint32 t) { 
	enumerated              = 0;
	updates_                = 0;
	EnumeratorConstraint* c = doInit(ctx, t, false);
	if (c == 0 && mini_)  c = new NullEnumerator::NullConstraint();
	if (mini_) { c->attach(*ctx.master()); }
	return c;
}
예제 #15
0
/**
 * Initialize the kinodynamic trees (the SingleSupportModels).
 **/
void RobotModel::initTrees()
{
	boost::shared_ptr<const urdf::Link> root = m_model->getRoot();
	boost::shared_ptr<SingleSupportModel> model = boost::make_shared<SingleSupportModel>(this, root);
	model->initFrom(*m_model, root->name);
	model->setCoefficient(0.0);

#if DUMP_TREES
	TreeStream stream(&std::cout);
	stream << *model;
#endif

	m_models.push_back(model);

	doInit(root);

	// Calculate the total mass
	m_mass = 0.0;
	std::vector<boost::shared_ptr<urdf::Link> > links;
	m_model->getLinks(links);
	for(size_t i = 0; i < links.size(); ++i)
	{
		if(links[i]->inertial)
			m_mass += links[i]->inertial->mass;
	}

	// Setup tf transform for /ego_rot
	tf::StampedTransform t_imu;
	t_imu.frame_id_ = "/ego_rot";
	t_imu.child_frame_id_ = "/trunk_link";
	t_imu.setIdentity();
	m_tf_buf.push_back(t_imu);

	// Setup tf transforms for each link
	for(size_t i = 1; i < model->mBodies.size(); ++i)
	{
		tf::StampedTransform t;
		t.frame_id_ = model->GetBodyName(model->lambda[i]);
		t.child_frame_id_ = model->GetBodyName(i);
		t.setIdentity();
		m_tf_buf.push_back(t);
	}

	// Setup fixed transforms
	for(size_t i = 1; i < model->mFixedBodies.size(); ++i)
	{
		tf::StampedTransform t;
		const RigidBodyDynamics::FixedBody& body = model->mFixedBodies[i];
		t.frame_id_ = model->GetBodyName(body.mMovableParent);
		t.child_frame_id_ = model->GetBodyName(model->fixed_body_discriminator + i);

		rbdlToTF(body.mParentTransform, &t);

		m_tf_fixed_buf.push_back(t);
	}
}
예제 #16
0
파일: IModule.cpp 프로젝트: Jeky-v/Snake
void IModule::Init()
{
  if (m_isinit)
    Close();

  m_isinit = true;
  m_isexit = false;

  doInit();
}
예제 #17
0
void
CAdvancedOptions::setDefaults(HWND hwnd)
{
	// restore defaults
	m_screenName = ARCH->getHostName();
	m_port       = kDefaultPort;

	// update GUI
	doInit(hwnd);
}
예제 #18
0
void MythScreenStack::ScheduleInitIfNeeded(void)
{
    // make sure Init() is called outside the paintEvent
    if (m_DoInit && m_topScreen && !m_InitTimerStarted &&
        !m_topScreen->IsLoading())
    {
        m_InitTimerStarted = true;
        QTimer::singleShot(100, this, SLOT(doInit()));
    }
}
예제 #19
0
파일: FaceSinkGraph.cpp 프로젝트: ogdf/ogdf
// construction of face sink graph with cross references
FaceSinkGraph::FaceSinkGraph(
	const ConstCombinatorialEmbedding &E, // given embedding
	node s) :                             // single source
	m_pE            (&E),
	m_source        (s),
	m_T             (nullptr)
{
	m_originalNode  .init(*this, nullptr);
	m_originalFace  .init(*this, nullptr);
	m_containsSource.init(*this, false);
	doInit();
}
예제 #20
0
int APIENTRY _tWinMain(HINSTANCE hInstance,
					   HINSTANCE hPrevInstance,
					   LPTSTR    lpCmdLine,
					   int       nCmdShow)
{
	UNREFERENCED_PARAMETER(hPrevInstance);
	UNREFERENCED_PARAMETER(lpCmdLine);

	MSG msg;


	// Initialize global strings
	LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
	LoadString(hInstance, IDC_CCHELPER, szWindowClass, MAX_LOADSTRING);

	HANDLE	hMutex;

	hMutex = CreateMutex(NULL, TRUE, szWindowClass);
	if(GetLastError() == ERROR_ALREADY_EXISTS){
		AlreadyRun();
		return 0;
	}

	OleInitialize(NULL);

	if( !doInit(hInstance, nCmdShow) )
		return -1;

    for (;;)
    {
        if(PeekMessage(&msg,NULL,0,0,PM_NOREMOVE))
        {
            if(!GetMessage(&msg,NULL,0,0))
            {
                return msg.wParam;
            }
            TranslateMessage(&msg);
            DispatchMessage(&msg);
        }else
		{
			//if( !AppLoop() )
			//	DestroyWindow(g_hWndMain);
			//else
			WaitMessage();
		}

    }

	OleUninitialize();

	return (int) msg.wParam;
}
예제 #21
0
    nitf_PluginRegistry_loadPlugin(const char* fullName, nitf_Error * error)
{
    
    /*  For now, the key is the dll name minus the extension  */
    char keyName[NITF_MAX_PATH] = "";
    char* p;
    int ok;
    int i, begin, end;
    nitf_DLL *dll;
    char **ident;
    nitf_PluginRegistry* reg = nitf_PluginRegistry_getInstance(error);

    /*  Construct the DLL object  */
    dll = nitf_DLL_construct(error);
    if (!dll)
    {
        return NITF_FAILURE;
    }
    /*  Otherwise we can load the DLL  */
    if (!nitf_DLL_load(dll, fullName, error))
    {
        /*  
         * If the load failed, we have a set error
         *  So all we have to do is close shop, go home
         */
        return NITF_FAILURE;
    }
    nitf_Utils_baseName(keyName, fullName, NITF_DLL_EXTENSION);
    
    /* Now init the plugin!!!  */
    ident = doInit(dll, keyName, error);
    
    /*  If no ident, we have a set error and an invalid plugin  */
    if (ident)
    {
        /*  I expect to have problems with this now and then  */
        ok = insertPlugin(reg, ident, dll, error);
        
        /*  If insertion failed, take our toys and leave  */
        if (!ok)
        {
            return NITF_FAILURE;
        }
#if NITF_DEBUG_PLUGIN_REG
        printf("Successfully loaded plugin: [%s] at [%p]\n",
               keyName, dll);
#endif
        return NITF_SUCCESS;
    }
    return NITF_FAILURE;
    
}
예제 #22
0
파일: FaceSinkGraph.cpp 프로젝트: ogdf/ogdf
void FaceSinkGraph::init(
	const ConstCombinatorialEmbedding &E, // given embedding
	node s)                               // single source
{
	m_pE     = &E;
	m_source = s;
	m_T      = nullptr;
	m_originalNode  .init(*this,nullptr);
	m_originalFace  .init(*this,nullptr);
	m_containsSource.init(*this,false);

	doInit();
}
예제 #23
0
int thread_mutex_lock(struct thread_mutex_t * mutexLocked)
{
  critFlag = 1;
    if(!initDone)
  {
    doInit();
    initDone = 1;
  }
  //when lock is called, currently running thread is trying to lock. Use head.
  if(mutexLocked -> threadOwner == 0)
  {
    //I am free to place myself in the wait queue, the lock is open
    mutexLocked -> threadOwner = (long)head;
    critFlag = 0;
    return 1;
  }
  else if(mutexLocked -> threadOwner == (long)head)
  {
    //I'm trying to suspend myself. error
    critFlag = 0;
    return 0;
  }
  else
  {
    //have to block thread, check if user was stupid and thread is already in queue
    struct TCB * p = mutexLocked -> thread_head;
    if(p == NULL)
    {
      p = head;
      head = head -> next;
      return 1;
    }
    while(p -> next != NULL)
    {
      if((long)p == (long)head)
      {
        //tried to lock a thread that was already waiting 
        critFlag = 0;
        return 0;
      }
      else
      {
        p = p -> next;
      }
    }
    p -> next = head;
    head = head -> next;
    critFlag = 0;
    return 1;
  }
}
예제 #24
0
/* forever after, call this function in a non-rtos system */
void protocol_loop(RunTimeOpts *rtOpts, PtpClock *ptpClock)
{
  if(ptpClock->port_state != PTP_INITIALIZING)
    doState(rtOpts, ptpClock);
  else if(!doInit(rtOpts, ptpClock))
    return;

  if(ptpClock->message_activity)
    DBGV("activity\n");
#if 0
  else
    DBGV("no activity\n");
#endif
}
예제 #25
0
//*******************************************************************************
void CWaterEnvMap::update(TGlobalAnimationTime time, IDriver &driver)
{
	if (_LastRenderTime == time) return;
	_LastRenderTime = time;
	// First five updates are used to render the cubemap faces (bottom face is not rendered)
	// Sixth update project the cubemap into a 2D texture
	uint numTexToRender;
	if (_UpdateTime > 0)
	{
		uint64 currRenderTick = (uint64) (time / (_UpdateTime / (NUM_FACES_TO_RENDER + 1)));
		numTexToRender = (uint) (currRenderTick - _LastRenderTick);
		_LastRenderTick = currRenderTick;
	}
	else
	{
		numTexToRender = NUM_FACES_TO_RENDER + 1;
	}
	if (!numTexToRender) return;
	if (_NumRenderedFaces == 0)
	{
		_StartRenderTime = time;
	}
	uint lastCubeFacesToRender = std::min((uint) NUM_FACES_TO_RENDER, _NumRenderedFaces + numTexToRender); // we don't render negative Z (only top hemisphere is used)
	for(uint k = _NumRenderedFaces; k < lastCubeFacesToRender; ++k)
	{
		driver.setRenderTarget(_EnvCubic, 0, 0, _EnvCubicSize, _EnvCubicSize, 0, (uint32) k);
		render((CTextureCube::TFace) k, _StartRenderTime);
	}
	_NumRenderedFaces = lastCubeFacesToRender;
	if (_NumRenderedFaces == NUM_FACES_TO_RENDER && (_NumRenderedFaces + numTexToRender) > NUM_FACES_TO_RENDER)
	{
		// render to 2D map
		driver.setRenderTarget(_Env2D, 0, 0, _Env2DSize, _Env2DSize);
		doInit();
		//
		driver.activeVertexProgram(NULL);
		driver.activeVertexBuffer(_FlattenVB);
		driver.activeIndexBuffer(_FlattenIB);
		driver.setFrustum(-1.f, 1.f, -1.f, 1.f, 0.f, 1.f, false);
		driver.setupViewMatrix(CMatrix::Identity);
		CMatrix mat;
		//mat.scale(0.8f);
		driver.setupModelMatrix(mat);
		_MaterialPassThru.setTexture(0, _EnvCubic);
		_MaterialPassThru.texConstantColor(0, CRGBA(255, 255, 255, _Alpha));
		driver.renderTriangles(_MaterialPassThru, 0, FVB_NUM_TRIS);
		_NumRenderedFaces = 0; // start to render again
	}
	driver.setRenderTarget(NULL);
}
예제 #26
0
 /**
  * Constructor for a known rowID
  * 
  * @param _db the associated database instance
  * @param _tabName the associated table name
  * @param _rowId 
  */
 TabRow::TabRow(GenericDatabase* _db, const QString& _tabName, int _rowId, bool skipCheck)
 : db(_db), tabName(_tabName), rowId(_rowId)
 {
   // Dangerous short-cut for lib-internal purposes:
   // if we're told that _db, _tabName and _rowId are GUARANTEED to be correct
   // (e. g. they result from a previous SELECT), we don't need further database
   // queries to check them again
   if (skipCheck)
   {
     return; // all done
   }
   
   QVariantList emptyList;
   doInit("id = " + QString::number(rowId), emptyList);
 }
bool HAbstractCdsDataSource::init()
{
    if (isInitialized())
    {
        return false;
    }

    if (doInit())
    {
        h_ptr->m_initialized = true;
        return true;
    }

    return false;
}
예제 #28
0
파일: GameSvr.cpp 프로젝트: AmbBAI/AIJudge
int _tmain(int argc, _TCHAR* argv[])
{
#ifdef _MAKE_SERVICE

	if (argc >= 2)
	{
		bool b_ret;
		ServiceCtrl svr_ctrl;
		svr_ctrl.OpenManager();
		if (strcmp(argv[1], "install") == 0)
		{
			char module_file[MAX_PATH];
			BaseFunc::getModuleFilePath(module_file);
			b_ret = svr_ctrl.installService(
				JUDGE_CONFIG::_SERVICE_NAME,
				JUDGE_CONFIG::_SERVICE_DISPLAY_NAME,
				module_file);
		}
		else if (strcmp(argv[1], "remove") == 0)
		{
			b_ret = svr_ctrl.removeService(JUDGE_CONFIG::_SERVICE_NAME);
		}
		else if (strcmp(argv[1], "start") == 0)
		{
			b_ret = svr_ctrl.startService(JUDGE_CONFIG::_SERVICE_NAME);
		}
		else if (strcmp(argv[1], "stop") == 0)
		{
			b_ret = svr_ctrl.stopService(JUDGE_CONFIG::_SERVICE_NAME);
		}
		printf("RESULT: %s:%d\n", b_ret?"OK":"FAULT", BaseFunc::getSysError());
		return 0;
	}

	ServiceBase* p_service = ServiceBase::getInstance();
	p_service->setServerInitFunc(doInit);
	p_service->setServerStopFunc(doDestory);
	p_service->initService(JUDGE_CONFIG::_SERVICE_NAME);
#else
	if( !doInit() )
		return false;

	getchar();

	doDestory();
#endif
	return 0;
}
예제 #29
0
long
GUISUMOAbstractView::onConfigure(FXObject*, FXSelector, void*) {
    if (makeCurrent()) {
        glViewport(0, 0, getWidth() - 1, getHeight() - 1);
        glClearColor(
            myVisualizationSettings->backgroundColor.red() / 255.,
            myVisualizationSettings->backgroundColor.green() / 255.,
            myVisualizationSettings->backgroundColor.blue() / 255.,
            myVisualizationSettings->backgroundColor.alpha() / 255.);
        doInit();
        myAmInitialised = true;
        makeNonCurrent();
        checkSnapshots();
    }
    return 1;
}
void signal_handler(int signum)
{
  //  printf("signum=%d\n",signum);
	if(signum == SIGCHLD)
	{
		while(waitpid(-1,NULL,WNOHANG) > 0); /* clean up child processes */
	}
	// don't comment out this line, other wise program will exit
	else if(signum == SIGHUP)
		doInit();
	else
	{
		while(waitpid(-1,NULL,WNOHANG) > 0);
		exit(0);
	}
}