void initializeAmf(void)
{
    SaAmfCallbacksT     callbacks;
    SaVersionT          version;
    ClIocPortT          iocPort;
    SaAisErrorT         rc = SA_AIS_OK;

    /* Get the pid for the process and store it in global variable. */
    mypid = getpid();

    /* SAFplus is fully API compatible with SA-Forum (SAF) definitions.

       This optional call customizes OpenClovis SAFplus Platform extensions
       to the basic SAF services (to use, you would define the parameters as globals).  
       
       If this call is removed, standard SAF services will work just fine. */

    /* clAppConfigure(&clEoConfig,clEoBasicLibs,clEoClientLibs); */

    
    /*
     * Initialize and register with SAFplus AMF. 'version' specifies the
     * version of AMF with which this application would like to
     * interface. 'callbacks' is used to register the callbacks this
     * component expects to receive.
     */
    version.releaseCode  = 'B';
    version.majorVersion = 01;
    version.minorVersion = 01;
    
    callbacks.saAmfHealthcheckCallback          = NULL; /* rarely necessary because SAFplus monitors the process */
    callbacks.saAmfComponentTerminateCallback   = safTerminate;
    callbacks.saAmfCSISetCallback               = safAssignWork;
    callbacks.saAmfCSIRemoveCallback            = safRemoveWork;
    callbacks.saAmfProtectionGroupTrackCallback = NULL;
        
    /* Initialize AMF client library. */
    if ( (rc = saAmfInitialize(&amfHandle, &callbacks, &version)) != SA_AIS_OK)
        errorExit(rc);

    /*
     * Now register the component with AMF. At this point it is
     * ready to provide service, i.e. take work assignments.
     */

    if ( (rc = saAmfComponentNameGet(amfHandle, &appName)) != SA_AIS_OK) 
        errorExit(rc);
    if ( (rc = saAmfComponentRegister(amfHandle, &appName, NULL)) != SA_AIS_OK) 
        errorExit(rc);

    /*
     * Print out standard information for this component.
     */

    clEoMyEoIocPortGet(&iocPort);
    
    clprintf (CL_LOG_SEV_INFO, "Component [%.*s] : PID [%d]. Initializing\n", appName.length, appName.value, mypid);
    clprintf (CL_LOG_SEV_INFO, "   IOC Address             : 0x%x\n", clIocLocalAddressGet());
    clprintf (CL_LOG_SEV_INFO, "   IOC Port                : 0x%x\n", iocPort);
}
コード例 #2
0
ファイル: WP7Injector.cpp プロジェクト: AliSayed/MoSync
void WP7Injector::inject(const Icon* icon, const std::map<std::string, std::string>& params) {
	string size = verifyParameter(params, "size");
	/**if (size != "default" && size != "72x72" && size != "57x57" && size != "114x114") {
		errorExit("iOS only supports these icon sizes: 57x57, 114x114 and 72x72");
	}**/
	if(size != "default" && size != "62x62" && size != "173x173") {
		errorExit(
			"Windows Phone requires an image size of 62x62 for"
			"the application icon, and 173x173 for the background image (for tiles)."
		);
	}
	string dst = verifyParameter(params, "dst");
	const IconInstance* iconInst = icon->findBestInstance(size);
	if(!iconInst)
	{
		map<string, string>::const_iterator i = params.find("lenient");
		if (i == params.end())
		{
			errorExit("Couldn't find any icon instance.");
		} else
		{
			printf("Warning: found no icon with size %s.\n", size.c_str());
		}
	} else {
		if(!convertInstanceToImageFormat(iconInst, dst.c_str(), size, "png"))
		{
			errorExit("Windows Phone 7 icon conversion failed.");
		}
	}
}
コード例 #3
0
static void createWindow(HINSTANCE hInstance)
{
	WNDCLASS wc;

	wc.style = 0;
	wc.lpfnWndProc = windowProc;
	wc.cbClsExtra = 0;
	wc.cbWndExtra = 0;
	wc.hInstance = hInstance;
	wc.hIcon = NULL;
	wc.hCursor = LoadCursor(0, IDC_ARROW);
	wc.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);
	wc.lpszMenuName = NULL;
	wc.lpszClassName = "tesstest";
	if (!RegisterClass(&wc))
		errorExit("RegisterClass failed!\n");

	RECT rc = { 0, 0, 1024, 768 };
	AdjustWindowRect(&rc, WS_OVERLAPPEDWINDOW, FALSE);

	hWnd = CreateWindow("tesstest", "Tess test", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT,
		rc.right - rc.left, rc.bottom - rc.top, NULL, NULL, hInstance, NULL);
	if (!hWnd)
		errorExit("CreateWindow failed!\n");
}
コード例 #4
0
ファイル: astprt.cpp プロジェクト: michaelemch/om
// this is an in-order traversal of the tree.  this is meant for
// debugging purposes only
void AST::astPrint(Node *node) {
    if(node == NULL) {
        return;
    }

    // print the left subtree
    this->astPrint(node->left);

    print "Node: ";
    printf("%p: ", node);

    // print node type
    switch(node->type) {
	case node_STMT: print "stmt_list :" << endl; break;
	case node_FC:   print "stmt_if   :" << endl; break;
	case node_LOOP: print "stmt_for  :" << endl; break;
	case node_ARG:  print "node_arg  :" << endl; break;
	case node_BRK:  print "stmt_brk  :" << endl; break;
	case node_CON:  print "stmt_con  :" << endl; break;
	case node_PRT:  print "stmt_prt  :" << endl; break;
	case node_RET:  print "stmt_ret  :" << endl; break;
	case node_EXPR:
	    print "expression: ";
            // if we're an expression, we have an operation
	    switch (node->op) {
		case op_ADD:  print "   op: +" << endl; break;
		case op_SUB:  print "   op: -" << endl; break;
		case op_MUL:  print "   op: *" << endl; break;
		case op_DIV:  print "   op: /" << endl; break;
		case op_MOD:  print "   op: %" << endl; break;
		case op_AND:  print "   op: &&" << endl; break;
		case op_LOR:  print "   op: ||" << endl; break;
		case op_EQ:   print "   op: ==" << endl; break;
		case op_NE:   print "   op: !=" << endl; break;
		case op_GE:   print "   op: >=" << endl; break;
		case op_GT:   print "   op: >" << endl; break;
		case op_LE:   print "   op: <=" << endl; break;
		case op_LT:   print "   op: <" << endl; break;
		case op_NOT:  print "   op: !" << endl; break;
		case op_CAT:  print "   op: |" << endl; break;
		case op_SET:  printf("  set: %s = \n", node->id); break;
		case op_CONST:printf("const: %s\n", node->id); break;
		case op_GET:  printf("  get: %s\n", node->id); break;
		case op_CALL: printf(" call: %s\n", node->id); break;
		case op_NULL: print endl; break;
		default:
		    errorExit("Operation not implemented: %d", node->op);
		    break;
	    }
	    break;
	default:
	    errorExit("Node type not implemented: %d", node->type);
	    break;
    }

    // print the right subtree
    this->astPrint(node->right);
}
コード例 #5
0
ファイル: AndroidInjector.cpp プロジェクト: Felard/MoSync
void AndroidInjector::inject(const Icon* icon, const std::map<std::string, std::string>& params) {
	string size = verifyParameter(params, "size");
	string dst = verifyParameter(params, "dst");
	const IconInstance* iconInst = icon->findBestInstance(size);
	if(!iconInst) errorExit("Couldn't find any icon instance.");

	if(!convertInstanceToImageFormat(iconInst, dst.c_str(), size, "png")) 
		errorExit("Android icon conversion failed.");
}
コード例 #6
0
void CommandChannel::run()
{

//	//模拟温度报警
//	unsigned long tempCode = 0x21;
//	unsigned long length = 4;
//	unsigned long degree = 80;
//	QByteArray dataArray;
//	dataArray.append( FBtoNetworkCharP(tempCode), 4);
//	dataArray.append( FBtoNetworkCharP(length), 4);
//	dataArray.append( FBtoNetworkCharP(degree), 4);
//	m_SendDataThread->sendData(dataArray);

	g_SendDataThread = m_SendDataThread;
	InitialAlarm(Alarm);

	CommandMapper* commandMapper = CommandMapper::instance();

	while(true)
	{
		unsigned long commandCode;
		unsigned long commandLength;
		if(!getFourByte(m_Socket, commandCode))
		{
			qDebug()<<"Get command code error";
			errorExit();
		}

		//将时间间隔的起始设置为现在的时间
		QTime receiveCommandTime = QTime::currentTime();
		m_CheckOnlineThread->setNewCommandTime(receiveCommandTime);

		if(commandCode != 0x03) //如果不是keep-alive指令,则尽快将此响应返回,使得服务器不会认为掉线
		{
			responseCommand(commandCode);
		}

		if(!getFourByte(m_Socket, commandLength))
		{
			qDebug()<<"Get command length error";
			errorExit();
		}

		if(500 * 1024 <= commandLength) // 指令长度应该是小于500K的
		{
			qDebug()<<"Command length is too large error";
			errorExit();
		}

		if(!commandMapper->handleCommand(commandCode,
										 m_Socket,
										 commandLength))
		{
			errorExit();
		}
	}
}
コード例 #7
0
/* 
   testGetInstance of the OS provider. 
*/
void OSTestClient::testGetInstance (CIMClient &client,
                                    Boolean verboseTest)
{
  CIMObjectPath  getTestRef;    //  will need an instance for Get
  
  try
    {
      Boolean deepInheritance = true;
      Boolean localOnly = true;
   
      testLog("OS Provider Test GetInstance");
     
      // first do an EnumerateInstanceNames - select one to play with 
      // doesn't hurt to keep testing enumerate :-)
 
      Array<CIMObjectPath> cimReferences = 
	    client.enumerateInstanceNames(NAMESPACE, CLASSNAME);
 
      Uint32 numberInstances = cimReferences.size();
      if (verboseTest)
	cout << numberInstances << " instances of PG_OperatingSystem" <<endl;

      for (Uint32 i = 0; i < cimReferences.size(); i++)
      {
         CIMName className = cimReferences[i].getClassName();
         if (!className.equal (CLASSNAME))
         {
	    errorExit("EnumInstanceNames failed - wrong class");
	 }
         // add in some content checks on the keys returned

         _validateKeys(cimReferences[i], verboseTest);

         // let's just take the first instance found
         getTestRef = cimReferences[i];

    }   // end for looping through instances
    
    if (verboseTest)
       cout<<"EnumerateInstanceNames for Get Instance completed"<<endl; 
   
    // now call GetInstance with the appropriate references
    CIMInstance getTestInstance = client.getInstance(NAMESPACE,
                                                     getTestRef);

    // now validate the properties returned
    _validateProperties(getTestInstance, verboseTest);

    testLog("OS Provider Test Get Instance passed ");
    }  // end try 
   
    catch(Exception& e)
    {
      errorExit(e.getMessage());
    }
}
コード例 #8
0
static char *getNextLine( int in, int newfile, const char *filename, unsigned lineno )
{
    static wio_ssize_t  rd;
    static char         *offset;
    static char         *start;
    static char         *endbuf;
    static int          finalread;
    static int          done = 0;

    if( done ) {
        done = 0;
        return( NULL );
    }
    if( newfile ) {
        rd = read( in, IObuffer, IObsize );
        if( -1 == rd )
            errorExit( "I/O error" );
        start = offset = IObuffer;
        endbuf = IObuffer + rd;
        finalread = ( rd != IObsize );
    }
    for( ; ; ) {
        wio_size_t const    len = ( ( endbuf - start ) - ( offset - start ) );
        char * const        lf = memchr( offset, '\n', len );
        char * const        line = start;

        if( lf != NULL ) {
            if( lf > IObuffer && lf[-1] == '\r' ) lf[-1] = '\0';
            *lf = '\0';
            offset = start = lf + 1;
            return( line );
        }
        if( finalread ) {
            endbuf[1] = '\0';
            done = 1;
            return( start );
        }
        if( len >= IObsize ) {
            free( IObuffer );
            IObsize += IObsize >> 1;
            IObuffer = malloc( IObsize );
            if( IObuffer == NULL || -1 == lseek( in, -rd, SEEK_CUR ) )
                errorExit( "line too long: len (%lu) >= IObsize (%lu) at \"%s\":%u",
                    (unsigned long)len, (unsigned long)IObsize, filename, lineno );
            return getNextLine( in, newfile, filename, lineno );
        }
        memmove( IObuffer, offset, len );
        start = IObuffer;
        offset = IObuffer + len;
        rd = read( in, offset, IObsize - len );
        if( -1 == rd )
            errorExit( "I/O error" );
        finalread = ( rd != IObsize - len );
        endbuf = offset + rd;
    }
コード例 #9
0
ファイル: utils.c プロジェクト: schmijos/dancepads
void copyData(int iDest, int iSrc) {
	char acBuff[BUFFLEN];
	int iCount;
	while ((iCount = read(iSrc, acBuff, sizeof(acBuff))) > 0) {
		if (write(iDest, acBuff, iCount) != iCount)
			errorExit("write");
	}
	if (iCount < 0)
		errorExit("read");
	return;
}
コード例 #10
0
int getJavaStartCommand(char *scriptFile) { 
	HANDLE hChildStdoutRd, hChildStdoutWr, hChildStdoutRdDup;
    SECURITY_ATTRIBUTES saAttr; 
    BOOL fSuccess; 
	
	//DebugBreak();
    // Set the bInheritHandle flag so pipe handles are inherited. 
    saAttr.nLength = sizeof(SECURITY_ATTRIBUTES); 
    saAttr.bInheritHandle = TRUE; 
    saAttr.lpSecurityDescriptor = NULL; 
 
    // The steps for redirecting child process's STDOUT: 
    //     1. Create anonymous pipe to be STDOUT for child process. 
    //     2. Create a noninheritable duplicate of the read handle and
    //        close the inheritable read handle. 
    //     3. Set STDOUT for child process
 
    // Create a pipe to be used for the child process's STDOUT. 
     if (! CreatePipe(&hChildStdoutRd, &hChildStdoutWr, &saAttr, 0)) 
        errorExit("Stdout pipe creation failed"); 
 
    // Create noninheritable read handle and close the inheritable read 
    // handle. 
    fSuccess = DuplicateHandle(GetCurrentProcess(), hChildStdoutRd,
        GetCurrentProcess(), &hChildStdoutRdDup , 0, FALSE,
        DUPLICATE_SAME_ACCESS);
	if(!fSuccess) {
		PrintEvent(_T("DuplicateHandle failed"));
		errorExit("DuplicateHandle failed");
	}
    CloseHandle(hChildStdoutRd);

	//
	// Now create the child process. 
    fSuccess = createChildProcess(scriptFile, hChildStdoutWr);

	if (!fSuccess) {
		PrintEvent(_T("Could not create process!!"));
		errorExit("Create process failed"); 
	}

	//PrintEvent(_T("Created Child Process Successfully"));

	// Close the write end of the pipe before reading from the 
    // read end of the pipe. 
    if (!CloseHandle(hChildStdoutWr)) 
        errorExit("Closing handle failed"); 

    // Read from pipe that is the standard output for child process. 
    readFromPipe(hChildStdoutRdDup); 

    return 0;
} 
コード例 #11
0
ファイル: pixmaps.cpp プロジェクト: pshendry/RSWR
// checkBitmapError(): Examines the presumed return code from a call to
//   XReadBitmapFile() and, if it represents an error, exit
void checkBitmapError( int rc ) {
    switch (rc) {
        case BitmapOpenFailed:
            errorExit("Could not open X Bitmap file.");
            break;
        case BitmapFileInvalid:
            errorExit("File opened which does not contain a valid X Bitmap.");
            break;
        case BitmapNoMemory:
            errorExit("Not enough memory to open X Bitmap.");
            break;
    }
}
コード例 #12
0
ファイル: Injector.cpp プロジェクト: N00bKefka/MoSync
	bool Injector::convertInstanceToImageFormat(const IconInstance *iconInstance,
		const char *dstFilename, const string& size, const string& format) {
		const char *mosyncdir_c = getenv("MOSYNCDIR");
		if(!mosyncdir_c) errorExit("MOSYNCDIR missing");
		string mosyncdir = mosyncdir_c;

		string src = iconInstance->filename;
		string dst = string(dstFilename);

		string extension = getExtension(src);

		if (!fForce && compareTime(src.c_str(), dst.c_str()) < 0) {
			printf("No need to generate icon, use -force switch to override.\n");
			return true;
		}

		if(extension == "svg") {
			ostringstream batik;
			batik << "java -jar \""<<mosyncdir<<"/bin/Batik/batik-rasterizer.jar\""
				" \""<<src<<"\" -d \""<<dst<<"\"";
			if(size != "default") {
				unsigned int n;
				unsigned w, h;
				int res = sscanf(size.c_str(), "%ux%u%n", &w, &h, &n);
				if(res != 2 || n != size.size())
					errorExit("Broken parameter: size.");
				batik << " -w "<<w<<" -h "<<h;
			}
			int res = run(batik.str().c_str());
			if(res != 0)
				errorExit("Batik failed.");
			return true;
		}

		string resizeFlag;
		if(size != "default")
			resizeFlag = " -resize " + size;
	#if defined(WIN32)
		string magick =
			"\""+mosyncdir+"\\bin\\ImageMagick\\convert.exe\" \"" + src + "\"" +
			resizeFlag + " \"" + dst + "\"";
	#else
		string magick =
		"\""+mosyncdir+"/bin/ImageMagick/convert\" \"" + src + "\"" +
		resizeFlag + " \"" + dst + "\"";
	#endif

		if(run(magick.c_str()) != 0) errorExit("Image Magick failed.");

		return true;
	}
コード例 #13
0
ファイル: OSInfo.cpp プロジェクト: ncultra/Pegasus-2.5
void OSInfoCommand::getOSInfo(ostream& outPrintWriter,
                              ostream& errPrintWriter)
{

    CIMClient client;
    client.setTimeout( _timeout );

    try
    {
        _connectToServer( client, outPrintWriter);

        Boolean deepInheritance = true;
        Boolean localOnly = false;
        Boolean includeQualifiers = false;
        Boolean includeClassOrigin = false;
        Uint32 numberInstances;
        Array<CIMInstance> cimNInstances =
               client.enumerateInstances(NAMESPACE, CLASSNAME,
                                         deepInheritance,
                                         localOnly,  includeQualifiers,
                                         includeClassOrigin );

        numberInstances = cimNInstances.size();

        // while we only have one instance (the running OS), we can take the
        // first instance.  When the OSProvider supports installed OSs as well,
        // will need to select the runningOS instance

        for (Uint32 i = 0; i < cimNInstances.size(); i++)
        {
           CIMObjectPath instanceRef = cimNInstances[i].getPath ();
           if ( !(instanceRef.getClassName().equal (CIMName (CLASSNAME))))
           {
              errorExit(errPrintWriter, "EnumerateInstances failed");
           }

           // first gather the interesting properties
           gatherProperties(cimNInstances[i], _useRawDateTimeFormat);
           // then display them
           displayProperties(outPrintWriter);

      }   // end for looping through instances

    }  // end try

    catch(const Exception& e)
    {
      errorExit(errPrintWriter, e.getMessage());
    }

}
コード例 #14
0
ファイル: main.c プロジェクト: FlyingCampDesign/BSL_Files
void setMode()
{
  token = strtok( line, " ");  // get command
  token = strtok( NULL, " ");  // get family
  printf("Initializing, Mode: ");
  if( memcmp( token, "543x_family", 11) == 0 )
  {
    BSL_setFamily(FAMILY_5438);
	printf("5438  ");
  }
  else if( memcmp( token, "ROM", 3) == 0 )
  {
    BSL_setFamily(FAMILY_ROM);
	printf("ROM   ");
  }
  else if( memcmp( token, "5xx", 3) == 0 )
  {
    BSL_setFamily(FAMILY_FLASH);
	printf("5xx ");
  } 
  else if( memcmp( token, "6xx", 3) == 0 )
  {
    BSL_setFamily(FAMILY_FLASH);
	printf("6xx ");
  } 
  else
  {
    errorExit("Error parsing MODE");
  }
  token = strtok( NULL, " ");  // get COM
  if( memcmp( token, "COM", 3) == 0 )
  {
    BSL_setCom( COM_UART );
    printf("COM: %s", token);
	BSL_initialize_BSL( token );
	printf("\tDONE");
  }
  else if( memcmp( token, "USB", 3) == 0 )
  {
    BSL_setCom( COM_USB );
    printf("USB: %s", token);
	BSL_initialize_BSL("");
  }
  else
  {
    errorExit("Error parsing COMM");
  }
  printf("\n");

}
コード例 #15
0
ファイル: NISTestClient.cpp プロジェクト: deleisha/neopegasus
/*
   testEnumerateInstances of the NIS provider.
*/
void NISTestClient::testEnumerateInstances(
    CIMClient &client,
    Boolean verboseTest)
{
    try
    {
        Boolean deepInheritance = true;
        Boolean localOnly = true;
        Boolean includeQualifiers = false;
        Boolean includeClassOrigin = false;
        Uint32 numberInstances;

        testLog("NIS Provider Test EnumerateInstances");

        Array<CIMInstance> cimNInstances = client.enumerateInstances(
            NAMESPACE,
            CLASS_NAME,
            deepInheritance,
            localOnly,
            includeQualifiers,
            includeClassOrigin);

        numberInstances = cimNInstances.size();
        if (verboseTest)
            cout << numberInstances << " instances of PG_NISServerService" <<
                endl;

        for (Uint32 i = 0; i < cimNInstances.size(); i++)
        {
            CIMObjectPath instanceRef = cimNInstances[i].getPath ();
            if (verboseTest)
                cout << "Instance ClassName is " <<
                    instanceRef.getClassName().getString() << endl;
            if(!instanceRef.getClassName().equal(CLASS_NAME))
            {
                errorExit("EnumInstances failed");
            }

            // now validate the properties
            _validateProperties(cimNInstances[i], verboseTest);
        }       // end for looping through instances

        testLog("NIS Provider Test EnumInstances Passed");
    }
    catch(Exception& e)
    {
        errorExit(e.getMessage());
    }
}
コード例 #16
0
ファイル: SDLOpenGL.cpp プロジェクト: i7693209/SDLOpenGL
void SDLOpenGL::init()
{
  if (SDL_Init(SDL_INIT_EVERYTHING) <0)
  {
    errorExit("error init");

  }
  m_window=SDL_CreateWindow(m_name.c_str(),m_x,m_y,m_width,
                            m_height,SDL_WINDOW_OPENGL);
  if(!m_window)
  {
    errorExit("window error");
  }
  createGLcontext();
}
コード例 #17
0
int main()
{
  cout << "+++++ Testing ProcessProviders" << endl;
  
  // Connect
  try
  {
    c.connectLocal ();
  }
  catch (Exception& e)
  {
    errorExit(e);
  }

  //
  //  Set a timeout longer than the default to avoid operations such as 
  //  enumerateInstances timing out on slower systems
  //
  c.setTimeout (TIMEOUT);

  int rc;
  if ((rc = testClass(CLASS_CIM_PROCESS)) != 0) return rc;
  if ((rc = testClass(CLASS_UNIX_PROCESS)) != 0) return rc;
  if ((rc = testClass(CLASS_UNIX_PROCESS_STAT)) != 0) return rc;
  cout << "+++++ passed all tests" << endl;
  return 0;
}
コード例 #18
0
void 
OpenSteer::OpenSteerDemo::initialize (void)
{
//    clock.setVariableFrameRateMode(false);
//    clock.setAnimationMode(false);
//    clock.setFixedFrameRate(2);
    // select the default PlugIn
    selectDefaultPlugIn ();

    {
        // XXX this block is for debugging purposes,
        // XXX should it be replaced with something permanent?

        std::cout << std::endl << "Known plugins:" << std::endl;   // xxx?
        PlugIn::applyToAll (printPlugIn);                          // xxx?
        std::cout << std::endl;                                    // xxx?

        // identify default PlugIn
        if (!selectedPlugIn) errorExit ("no default PlugIn");
        std::cout << std::endl << "Default plugin:" << std::endl;  // xxx?
        std::cout << " " << *selectedPlugIn << std::endl;          // xxx?
        std::cout << std::endl;                                    // xxx?
    }

    // initialize the default PlugIn
    openSelectedPlugIn ();
}
コード例 #19
0
void dispatchLoop(void)
{        
    SaAisErrorT         rc = SA_AIS_OK;
    SaSelectionObjectT amf_dispatch_fd;
    int maxFd;
    fd_set read_fds;

    /*
      * Get the AMF dispatch FD for the callbacks
    */
    if ( (rc = saAmfSelectionObjectGet(amfHandle, &amf_dispatch_fd)) != SA_AIS_OK)
         errorExit(rc);

    maxFd = amf_dispatch_fd;  /* maxFd = max(amf_dispatch_fd,ckpt_dispatch_fd); */
    do
    {
       FD_ZERO(&read_fds);
       FD_SET(amf_dispatch_fd, &read_fds);
         
       if( select(maxFd + 1, &read_fds, NULL, NULL, NULL) < 0)
       {
          char errorStr[80];
          int err = errno;
          if (EINTR == err) continue;

          errorStr[0] = 0; /* just in case strerror does not fill it in */
          strerror_r(err, errorStr, 79);
          //clprintf (CL_LOG_SEV_ERROR, "Error [%d] during dispatch loop select() call: [%s]",err,errorStr);
          break;
       }
       if (FD_ISSET(amf_dispatch_fd,&read_fds)) saAmfDispatch(amfHandle, SA_DISPATCH_ALL);
      
    }while(!unblockNow);      
}
int main(int argc, char *argv[])
{
    SaAisErrorT rc = SA_AIS_OK;
    SaSelectionObjectT dispatch_fd;
    fd_set read_fds;
    ClRcT ret = CL_OK;

    /* Connect to the SAF cluster */
    initializeAmf();

    /* Do the application specific initialization here. */
    FD_ZERO(&read_fds);

    if ( (rc = saAmfSelectionObjectGet(amfHandle, &dispatch_fd)) != SA_AIS_OK)
        errorExit(rc);
    
    FD_SET(dispatch_fd, &read_fds);
    
    /* Handle the AMF dispatch loop by spawning a thread that does it */
    ret = clOsalTaskCreateDetached("DISPATCH-THREAD", CL_OSAL_SCHED_OTHER, 0, 0, saAmfDispatchThread, NULL);
    if(ret != CL_OK)
    {
        clprintf(CL_LOG_SEV_ERROR, "Dispatch task create failed with rc 0x%x",rc);
        return ret;
    } 
    while (!unblockNow)
    {
        /* csa112: If I am active then I'll publish an event.
           Note, any application can publish and event regardless of
           HA state.  This tutorial simply uses HA state so only
           one of the two processes are publishing.
        */
        
        if (running && ha_state == SA_AMF_HA_ACTIVE)
        {
            csa113Comp_PublishEvent();
        }
    
        sleep(1);  /* Keep the event publish rate reasonable for this tutorial*/
    }
    
    /* Do the application specific finalization here. */
    if ((rc = saEvtChannelClose(evtChannelHandle)) != SA_AIS_OK)
    {
        clprintf(CL_LOG_SEV_ERROR, "Failed [0x%x] to close event channel", rc);
    }

    if ((rc = saEvtFinalize(evtLibHandle)) != SA_AIS_OK)
    {
        clprintf(CL_LOG_SEV_ERROR, "Failed [0x%x] to finalize event library", rc);
    }

    /* Now finalize my connection with the SAF cluster */
    if((rc = saAmfFinalize(amfHandle)) != SA_AIS_OK)
      clprintf (CL_LOG_SEV_ERROR, "AMF finalization error[0x%X]", rc);
    else
      clprintf (CL_LOG_SEV_INFO, "AMF Finalized");   

    return 0;
}
コード例 #21
0
ファイル: GA.c プロジェクト: HelenRouty/LEAM-plone
/* return the fitness to the GA engine */
void GAsendFit(double fit)
{
  char url_cmd[MAX_URL_LEN];
  HTTP_Response hResponse;

  if (debug)
     fprintf(stderr, "GAsendFit: fitness = %f\n", fit);

  /* construct the mature baby cmd url */
  sprintf(url_cmd, "%s/%s?%s&%s%s&%s%f",
	  GA_URL, ROOT_CMD, MATURE_BABY,
	  ID_STUB, GA_ID, FIT_STUB, fit);
  
  /* actually send the fitness for kid GA_ID to the server */
  hResponse = http_request(url_cmd, NULL, kHMethodGet, HFLAG_NONE);
  /* check to see if we got OK as a response */
  if (hResponse.lSize <= 0 || strcasecmp(hResponse.pData, MATURE_BABY_OK))
    {
      /* there was an error */
      sprintf(estring,"Error GAsendFit: Error sending fit\n");
      errorExit(estring);
    }
  /* free up the pData from the response */
  if (hResponse.pData) free(hResponse.pData);
}
コード例 #22
0
TEST(TestCase2, DeathTest_Fails)
{
	// test fails with wrong return code
	EXPECT_EXIT(errorExit("Expected message."),
	            ExitedWithCode(EXIT_SUCCESS),
	            "Expected message.") << "EXPECT_EXIT with wrong exit status.";;
}
コード例 #23
0
int main(int argc, char *argv[])
{
  cout << "+++++ Testing Processor Provider" << endl;

  processorTestVerbose = getenv("PEGASUS_TEST_VERBOSE");

  if ((argc == 2) && String::equalNoCase(argv[1], "verbose"))
  {
    processorTestVerbose = true;
  }

  // Connect
  try
  {
    c.connectLocal();
  }
  catch (Exception& e)
  {
    errorExit(e);
  }

  int rc;
  if ((rc = testClass(CLASS_CIM_PROCESSOR)) != 0) return rc;
  if ((rc = testClass(CLASS_PROCESSOR)) != 0) return rc;
  cout << "+++++ passed all tests" << endl;
  return 0;
}
コード例 #24
0
void dispatchLoop(void)
{        
  SaAisErrorT         rc = SA_AIS_OK;
  SaSelectionObjectT amf_dispatch_fd;
  int maxFd;
  fd_set read_fds;

  
  if ( (rc = saAmfSelectionObjectGet(amfHandle, &amf_dispatch_fd)) != SA_AIS_OK)
    errorExit(rc);
    
  maxFd = amf_dispatch_fd;  /* maxFd = max(amf_dispatch_fd,ckpt_dispatch_fd); */
  do
    {
      FD_ZERO(&read_fds);
      FD_SET(amf_dispatch_fd, &read_fds);
      /* FD_SET(ckpt_dispatch_fd, &read_fds); */
        
      if( select(maxFd + 1, &read_fds, NULL, NULL, NULL) < 0)
        {
          char errorStr[80];
          int err = errno;
          if (EINTR == err) continue;

          errorStr[0] = 0; /* just in case strerror does not fill it in */
          strerror_r(err, errorStr, 79);
          break;
        }
      if (FD_ISSET(amf_dispatch_fd,&read_fds)) saAmfDispatch(amfHandle, SA_DISPATCH_ALL);
      /* if (FD_ISSET(ckpt_dispatch_fd,&read_fds)) saCkptDispatch(ckptLibraryHandle, SA_DISPATCH_ALL); */
    }while(!unblockNow);      
}
コード例 #25
0
TEST(TestCase2, DeathTest_WrongMessage)
{
	// test ok but wrong message
	EXPECT_EXIT(errorExit("Actual message."),
	            ExitedWithCode(EXIT_FAILURE),
	            "Expected message.") << "EXPECT_EXIT with wrong message.";
}
コード例 #26
0
// Test a Class by enumerating the instances.
int testClass(const CIMName& className)
{
    Array<CIMObjectPath> refs;

    // =======================================================================
    // enumerateInstanceNames
    // =======================================================================

    cout << "+++++ enumerateInstanceNames(" << NAMESPACE << " " <<
        className << ") ";
    try
    {
        refs = c.enumerateInstanceNames(NAMESPACE,className);
    }
    catch (Exception& e)
    {
        cout << endl;
        errorExit(e);
    }

    cout << refs.size() << " instances" << endl;
    // if zero instances, not an error, but can't proceed
    if (refs.size() == 0)
    {
        cout << "+++++ test completed early" << endl;
        return 0;
    }
    return 0;
}
コード例 #27
0
ファイル: process.c プロジェクト: annielcook/hw5
//Function that executes the pipline command by reseting file descriptors
//so that output of left is passed as input to right
//parameters are the command tree and the boolean for if the left process should
//be backgrounded
//Some of this function comes from pipe.c given in class
int doPipeline(CMD* c, bool bkgd){


    int fd[2],                  // Read and write file descriptors for pipe
	pid, status,            // Process ID and status of child
	pidTwo, statusTwo;

	//execute pipe and fork and if either fails, exit
	if (pipe(fd) || (pid = fork()) < 0) errorExit (EXIT_FAILURE);

	else if (pid == 0) {                    // Child process
	    close (fd[0]);                      //  No reading from new pipe
		if (fd[1] != 1) {                   //  stdout = write[new pipe]
			dup2 (fd[1], 1);
			close (fd[1]);
		}
	    exit(pipelineA(c->left, bkgd));    //  Overlay by i-th filter

	} else {   
		close(fd[1]);                             // Parent process
    }

    //execute a child process for the child
    if ((pidTwo = fork()) < 0) errorExit (EXIT_FAILURE);

    else if (pidTwo == 0) {                        // Child process
    	if(fd[0] != 0){
    		dup2(fd[0], 0);
    		close(fd[0]);
    	}
		exit(stageA(c->right, bkgd)); //  Overlay by last filter
    } else {
    	close(fd[0]);
    	//wait to get the status
    	waitpid(pid, &status, WUNTRACED);
    	waitpid(pidTwo, &statusTwo, WUNTRACED);
    	//set status
    	return (status > 0 && statusTwo == 0) ? 
    		setStatus(status) : setStatus(statusTwo);
    }
    //reap zombies
   	pid_t zombie;
    while((zombie = waitpid(-1, &status, WNOHANG)) > 0); //reap zombies

    return 1;

}
コード例 #28
0
ファイル: Injector.cpp プロジェクト: N00bKefka/MoSync
	string Injector::verifyParameter(
		const map<string, string>& params, 
		const string& name)
	{
		map<string, string>::const_iterator i = params.find(name);
		if(i == params.end()) errorExit("Parameter " + name + " missing.");
		return (*i).second;
	}
コード例 #29
0
static void outOfMemory(void)
{
  printf("RAxML was not able to allocate enough memory.\n");
  printf("Please check the approximate memory consumption of your dataset using\n");
  printf("the memory calculator at http://www.exelixis-lab.org/web/software/raxml/index.html.\n");
  printf("RAxML will exit now\n");

  errorExit(-1);
}
コード例 #30
0
/**
   _validateKeys method of the OS provider Test Client
  */
void OSTestClient::_validateKeys(CIMObjectPath &cimRef, 
                                 Boolean verboseTest)
{
   // don't have a try here - want it to be caught by caller

   Array<CIMKeyBinding> keyBindings = cimRef.getKeyBindings();

   if (verboseTest)
      cout << "Retrieved " << keyBindings.size() << " keys" <<endl;

   for (Uint32 j = 0; j < keyBindings.size(); j++)
   {
      CIMName keyName = keyBindings[j].getName();
      if (verboseTest)
         cout << "checking key " << keyName << endl;
      if (((keyName.equal ("CSCreationClassName")) &&
          (goodCSCreationClassName(
               keyBindings[j].getValue(),
               verboseTest) == false))) 
      {
         errorExit ("CSCreationClassName not CIM_UnitaryComputerSystem");
      }
      else if ((keyName.equal ("CSName")) &&
               (goodCSName(keyBindings[j].getValue(),
                       verboseTest) == false))
      { 
         errorExit ("CSName not correct");
      }
      else if ((keyName.equal ("CreationClassName")) &&
          (goodCreationClassName( 
            keyBindings[j].getValue(),
            verboseTest) == false))
      { 
         errorExit ("CreationClassName not correct");
      }
      else if ((keyName.equal ("Name")) &&
                (goodName( 
                  keyBindings[j].getValue(),
                  verboseTest) == false))
      { 
         errorExit ("Name not correct");
      }
    }  // end for j looping through properties
}