Example #1
0
int String::_concat (char const * s, short len)
{
    if (len < 0) len = (short) strlen(s);
    if (len > 0)
    {
        // Special case - are we concatenating ourselves??
        if (Stringdata->_refs == 1 &&  // No danger if we'll be reallocated anyway
            s >= c_ptr() &&         // Refers to us, or subStringing of us
            s <= (c_ptr() + length()))
        {   // This is handled separately, since we do not wish
            // to pass this heinous overhead onto all cases,
            // especially when this particular case is so rare...
            String tmpString(s, len);                 // Copy this Stringing first
            _chksize(short(len + length() + 1));
            memcpy(c_ptr() + length(), tmpString.c_ptr(), len);
        }
        else
        {
            _chksize (short(len + length() + 1));
            memcpy (c_ptr() + length(), s, len);
        }
        Stringdata->_length += len;
    }
    return length();
}
Example #2
0
//---------------------------------------------------------------------------
//  IFXString::Concatenate
//
//  This method appends the source characters to the destination buffer
//---------------------------------------------------------------------------
IFXRESULT IFXString::Concatenate(const IFXCHAR* pSource)
{
	IFXRESULT result = IFX_OK;

	if(pSource==NULL)
		result = IFX_E_INVALID_POINTER;

	if (IFXSUCCESS(result))
	{
		if (m_Buffer) 
		{
			IFXString tmpString(this);
			NewBuffer(m_BufferLength+(U32)wcslen(pSource));
			if (m_Buffer)
			{
				wcscpy(m_Buffer, tmpString.m_Buffer);
				wcscat(m_Buffer, pSource);
			}
			else
				result = IFX_E_INVALID_POINTER;
		} 
		else
			result = Assign(pSource);
	}

	return result;
}
Example #3
0
void SkyBox::unpackUpdate( NetConnection *conn, BitStream *stream )
{
   Parent::unpackUpdate( conn, stream );

   String tmpString( "" );
   stream->read( &tmpString );
   if ( !tmpString.equal( mMatName, String::NoCase ) )
   {
      mMatName = tmpString;
      _updateMaterial();
   }

   bool drawBottom = stream->readFlag();
   F32 bandHeight = 0;
   stream->read( &bandHeight );

   // If this flag has changed
   // we need to update the vertex buffer.
   if (  drawBottom != mDrawBottom || 
         bandHeight != mFogBandHeight )
   {
      mDrawBottom = drawBottom;
      mFogBandHeight = bandHeight;
      mIsVBDirty = true;
      _initRender();
   }
}
Example #4
0
inline void
reset_func(XalanDOMString& obj, MemoryManager&    theManager, Type string)
{
    assert( string != 0 );

    XalanDOMString tmpString(string, theManager);

    obj.swap(tmpString);
}
Example #5
0
// ============================================================================================
bool TestLauncher::saveResults()
{
	String tmpString( stimuliDirectory ) ;
	Time	now =  Time::getCurrentTime();
	
	tmpString += now.formatted(L"%Y-%m-%d_%H%M%S_") + subjectID + ".txt";

	return saveResults(tmpString);
}
Example #6
0
/////////////////////////////////////////////////////////////////////////////
// IVMESurface implementation
/////////////////////////////////////////////////////////////////////////////
STDMETHODIMP CVMESurface::put_Symbol(BSTR NewVal)								
{																	
	ObjectLock lock(this);											

	_bstr_t tmpString(NewVal);
	std::string asciiStr = tmpString;
	memset( m_HeaderData.__Symbol, 0, sizeof(m_HeaderData.__Symbol));
	memcpy(m_HeaderData.__Symbol, asciiStr.c_str(), asciiStr.length() );

	return S_OK;													
}																	
Example #7
0
/*! Adds the name of a shared object to the list of objects that are dynamically
    loaded by \c osgInit.

    \param[in] szName Name of shared object.

    \ingroup GrpBaseBaseInitExit
 */
void preloadSharedObject(const OSG::TChar *szName)
{
    if(osgPreloadSharedObject == NULL)
    {
        osgPreloadSharedObject = new std::vector<tstring>;
    }

    tstring tmpString(szName);

    osgPreloadSharedObject->push_back(tmpString);
}
void
DOMStringPrintWriter::print(long	l)
{
    assert ( m_outputString != 0 );

    XalanDOMString tmpString( m_outputString->getMemoryManager() );

    LongToDOMString(l, tmpString);

	(*m_outputString) += tmpString;
}
void
DOMStringPrintWriter::print(double	d)
{
    assert ( m_outputString != 0 );

    XalanDOMString tmpString( m_outputString->getMemoryManager() );

    DoubleToDOMString(d, tmpString);

	(*m_outputString) += tmpString;
}
Example #10
0
std::string SelectBox::GetSelectedItem()
{
	int ItemIndex = SendMessage(this->controlHandler, static_cast<UINT>(CB_GETCURSEL),
	                            static_cast<WPARAM>(0), static_cast<LPARAM>(0));

	TCHAR ListItem[256];
	static_cast<TCHAR>(SendMessage(this->controlHandler, static_cast<UINT>(CB_GETLBTEXT),
	                               static_cast<WPARAM>(ItemIndex), reinterpret_cast<LPARAM>(ListItem)));
	std::wstring tmpString(ListItem);
	return std::string(tmpString.begin(), tmpString.end());
}
Example #11
0
bool
GenericAttributeText::CheckAttributeChanged()
{
	GenericValueStruct tmpValue = fValue;
	BString tmpString(fFullValueText);
	ReadValue(&fFullValueText);

	// fDirty could already be true, in that case we mustn't set it to
	// false, even if the attribute text hasn't changed
	bool changed = (fValue.int64t != tmpValue.int64t) || (tmpString != fFullValueText);
	if (changed)
		fDirty = true;

	return fDirty;
}
void
DOMStringPrintWriter::write(
			const char*		s,
			size_t			theOffset,
			size_t			theLength)
{
    assert(XalanDOMString::size_type(theOffset) == theOffset);
    assert(XalanDOMString::size_type(theLength) == theLength);

    assert ( m_outputString != 0 );

    XalanDOMString tmpString( m_outputString->getMemoryManager() );

    tmpString = TranscodeFromLocalCodePage(s, tmpString);
	write(
        tmpString,
        XalanDOMString::size_type(theOffset),
        XalanDOMString::size_type(theLength));
}
Example #13
0
void Histograms::InitFP(){
    for (int idx = 0; idx != 16; ++idx){
        std::stringstream tmpString("");
        tmpString << "g" << idx;
        fractionProfilesGluon.push_back(new TProfile(tmpString.str().c_str(),"",ptBins,ptRange));
        tmpString.str("");
        tmpString << "q" << idx;
        fractionProfilesQuark.push_back(new TProfile(tmpString.str().c_str(),"",ptBins,ptRange));
        tmpString.str("");
        tmpString << "lq" << idx;
        fractionProfilesLQuark.push_back(new TProfile(tmpString.str().c_str(),"",ptBins,ptRange));
        tmpString.str("");
        tmpString << "hq" << idx;
        fractionProfilesHQuark.push_back(new TProfile(tmpString.str().c_str(),"",ptBins,ptRange));
        tmpString.str("");
        tmpString << "a" << idx;
        fractionProfilesAll.push_back(new TProfile(tmpString.str().c_str(),"",ptBins,ptRange));
    }
}
Example #14
0
int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);

    if(argc < 3)
    {
        qDebug() << "To few arguments!";
        qDebug() << "Usage: cmdtimeout [00h][00m]00[s] command [argumentlist]";
    }

    int msec = parseTime(QString(argv[1]));

    QStringList lst;
    for(int idx=0; idx < argc-3; idx++)
    {
        QString tmpString(argv[idx+3]);
        lst += tmpString;
    }

    QString cmd(argv[2]);
    Application app(cmd,lst,msec);

    return a.exec();
}
Example #15
0
int MRMJobValidate(

  mjob_t              *J,              /* I */
  mrm_t               *R,              /* I */
  char                *EMsg,           /* O (optional,minsize=MMAX_LINE) */
  enum MJobCtlCmdEnum *FailureAction,  /* I (optional) */
  int                 *SC)             /* O (optional) */

  {
  enum MWJobAttrEnum aindex;
  enum MRMSubTypeEnum SType;

  int     index;

  char    SPath[MMAX_BUFFER];

  char   *BPtr;
  int     BSpace;

  char   *ptr;
  char   *TokPtr;

  char   *ptr2;
  char   *TokPtr2;

  char    tEMsg[MMAX_LINE];

  enum MStatusCodeEnum tmpSC;

  mbool_t GRes = FALSE;

  const char *FName = "MRMJobValidate";

  MDB(2,fRM) MLog("%s(%s,%s,EMsg,FailureAction,SC)\n",
    FName,
    (J != NULL) ? J->Name : "NULL",
    (R != NULL) ? R->Name : "NULL");

  if (EMsg != NULL)
    EMsg[0] = '\0';

  if (SC != NULL)
    *SC = 0;

  if (J == NULL)
    {
    return(FAILURE);
    }

  if (R->ND.URL[mrmXJobValidate] == NULL)
    {
    /* no job validate script specified */

    return(SUCCESS);
    }

  MUSNInit(&BPtr,&BSpace,SPath,sizeof(SPath));

  MUSNPrintF(&BPtr,&BSpace,"%s=%s ",
    MWikiJobAttr[mwjaUName],
    J->Credential.U->Name);

  if (J->EUser != NULL)
    {
    /* report execution user */

    MUSNPrintF(&BPtr,&BSpace,"%s=%s ",
      "EUSER",
      J->EUser);
    }

  if (J->Credential.G != NULL)
    {
    MUSNPrintF(&BPtr,&BSpace,"%s=%s ",
      MWikiJobAttr[mwjaGName],
      J->Credential.G->Name);
    }

  if (J->SpecWCLimit[0] > 0)
    {
    MUSNPrintF(&BPtr,&BSpace,"%s=%ld ",
      MWikiJobAttr[mwjaWCLimit],
      J->SpecWCLimit[0]);
    }

/* 
  if (J->Request.TC > 0)
    {
    MUSNPrintF(&BPtr,&BSpace,"%s=%d ",
      MWikiJobAttr[mwjaTasks],
      J->Request.TC);
    }
*/

  if (J->Credential.C != NULL)
    {
    MUSNPrintF(&BPtr,&BSpace,"%s=%s ",
      MWikiJobAttr[mwjaRClass],
      J->Credential.C->Name);
    }

  if (J->QOSRequested != NULL)
    {
    MUSNPrintF(&BPtr,&BSpace,"%s=%s ",
      MWikiJobAttr[mwjaQOS],
      J->QOSRequested->Name);
    }

  if (J->Env.Cmd != NULL)
    {
    char *ptr;
    char *TokPtr;

    char tmpLine[MMAX_LINE];

    MUStrCpy(tmpLine,J->Env.Cmd,sizeof(tmpLine));

    ptr = MUStrTok(tmpLine," ",&TokPtr);

    MUStringChop(ptr);

    MUSNPrintF(&BPtr,&BSpace,"%s=%s ",
      MWikiJobAttr[mwjaExec],
      ptr);
    }    /* END if (J->E.Cmd != NULL) */

  if (!bmisclear(&J->Req[0]->ReqFBM))
    {
    char tmpLine[MMAX_LINE];

    MUSNPrintF(&BPtr,&BSpace,"%s=%s ",
      MWikiJobAttr[mwjaRFeatures],
      MUNodeFeaturesToString(',',&J->Req[0]->ReqFBM,tmpLine));
    }

  if (J->Variables.Table != NULL)
    {
    mstring_t tmp(MMAX_LINE);

    MJobAToMString(J,mjaVariables,&tmp);

    MUSNPrintF(&BPtr,&BSpace,"%s=%s ",
      MWikiJobAttr[mwjaVariables],
      tmp.c_str());
    }

  /* display generic resources */

  for (index = 1;index < MSched.M[mxoxGRes];index++)
    { 
    if (MGRes.Name[index][0] == '\0')
      break;
 
    if (MSNLGetIndexCount(&J->Req[0]->DRes.GenericRes,index) == 0)
      continue;

    if (GRes == FALSE)
      {
      MUSNPrintF(&BPtr,&BSpace,"GRES=%s:%d",
        MGRes.Name[index],
        MSNLGetIndexCount(&J->Req[0]->DRes.GenericRes,index));

      GRes = TRUE;
      }
    else
      {
      MUSNPrintF(&BPtr,&BSpace,",%s:%d",
        MGRes.Name[index],
        MSNLGetIndexCount(&J->Req[0]->DRes.GenericRes,index));
      }
    }  /* END for (index) */

  /* send this off to JOBVALIDATEURL */
  
  SType = R->ND.NatType;

  R->ND.NatType = mrmstX1E;

  mstring_t Response(MMAX_LINE);

  /* NOTE: should we pass-in Job Validate specific timeout, ie 2 seconds? (NYI) */

  if (MNatDoCommand(
        &R->ND,
        SPath,
        mrmXJobValidate,
        R->ND.Protocol[mrmXJobValidate],
        FALSE,
        NULL,
        NULL,
        &Response,
        tEMsg,               /* O */
        &tmpSC) == FAILURE)
    {
    R->ND.NatType = SType;

    /* make failure action configurable */

    if ((ptr = strstr(tEMsg,"ACTION=")) != NULL)
      {
      ptr += strlen("ACTION=");

      ptr2 = MUStrTok(ptr," \n\t",&TokPtr);

      if (FailureAction != NULL)
        *FailureAction = (enum MJobCtlCmdEnum)MUGetIndexCI(ptr2,MJobCtlCmds,FALSE,mjcmNONE);
      }

    if (EMsg != NULL)
      MUStrCpy(EMsg,tEMsg,MMAX_LINE);

    if (SC != NULL)
      *SC = (int)tmpSC;

    return(FAILURE);
    }

  if (SC != NULL)
    *SC = (int)tmpSC;

  R->ND.NatType = SType;

  for (index = 0;Response[index] != '\0';index++)
    {
    if (Response[index] == '\n')
      Response[index] = ' ';
    }

  mstring_t tmpString(MMAX_LINE);

  MWikiFromAVP(NULL,Response.c_str(),&tmpString);

  /* Need a char array that can be modified, not the immutable tmpString  */
  char *mutableResponse = NULL;
  MUStrDup(&mutableResponse,tmpString.c_str());

  ptr = MUStrTok(mutableResponse,";",&TokPtr);

  int rc = SUCCESS;

  /* NYI:  change other job attributes such as NodeCount RMXString User/Group */

  while (ptr != NULL)
    {
    ptr2 = MUStrTok(ptr,"=",&TokPtr2);

    aindex = (enum MWJobAttrEnum)MUGetIndexCI(ptr2,MWikiJobAttr,FALSE,mwjaNONE);

    switch (aindex)
      {
      case mwjaAccount:

        if ((J->Credential.A == NULL) || (strcmp(TokPtr2,J->Credential.A->Name)))
          {
          if (MRMJobModify(
                J,
                "Account_Name",
                NULL,
                TokPtr2,
                mSet,
                "account modified by jobvalidate interface",
                tEMsg,              /* O */
                NULL) != SUCCESS)
            {
            MDB(2,fSCHED) MLog("INFO:     cannot set account on job %s to '%s' - invalid account - %s\n",
              J->Name,
              TokPtr2,
              tEMsg);

            if (EMsg != NULL)
              strcpy(EMsg,"cannot set account");

            rc = FAILURE;
            goto cleanupExit;
            }

          MAcctAdd(TokPtr2,&J->Credential.A);

          bmset(&J->IFlags,mjifAccountLocked);
          }

        break;

      case mwjaRClass:

        if ((J->Credential.C == NULL) || (strcmp(TokPtr2,J->Credential.C->Name)))
          {
          mclass_t *C;

          if (MClassFind(TokPtr2,&C) == FAILURE)
            {
            MDB(2,fSCHED) MLog("INFO:     cannot set class on job %s to '%s' - invalid class\n",
              J->Name,
              TokPtr2);

            if (EMsg != NULL)
              strcpy(EMsg,"cannot locate class");

            rc = FAILURE;
            goto cleanupExit;
            }
          
          if (MJobSetClass(J,C,TRUE,tEMsg) == FAILURE)
            {
            MDB(2,fSCHED) MLog("INFO:     cannot set class on job %s to '%s' - %s\n",
              J->Name,
              C->Name,
              tEMsg);

            if (EMsg != NULL)
              strcpy(EMsg,"cannot set class");

            rc = FAILURE;
            goto cleanupExit;
            }

          bmset(&J->IFlags,mjifClassLocked);
          }  /* END if ((J->Cred.C == NULL) || ...) */

        break;

      case mwjaQOS:

        /* bypass qos checks and put qos directly onto job */

        J->QOSRequested = NULL;

        if (MQOSFind(TokPtr2,&J->Credential.Q) != SUCCESS)
          {
          MDB(2,fSCHED) MLog("INFO:     cannot set qos on job %s to '%s' - invalid QoS\n",
            J->Name,
            TokPtr2);

          if (EMsg != NULL)
            strcpy(EMsg,"cannot locate qos");

          rc = FAILURE;
          goto cleanupExit;
          }

        bmset(&J->IFlags,mjifQOSLocked);

        break;

      case mwjaRFeatures:

        MReqSetAttr(J,J->Req[0],mrqaReqNodeFeature,(void **)TokPtr2,mdfString,mSet);

        break;

      case mwjaWCLimit:

        if (MRMJobModify(
             J,
             "Resource_List",
             "walltime",
             TokPtr2,
             mSet,
             "walltime modified by jobvalidate interface",
             tEMsg,
             NULL) == FAILURE)
          {
          MDB(2,fSCHED) MLog("INFO:     cannot modify walltime for rm job %s - '%s'\n",
            J->Name,
            tEMsg);

          if (EMsg != NULL)
            strcpy(EMsg,"cannot modify walltime");

          rc = FAILURE;
          goto cleanupExit;
          }

        break;

      case mwjaVariables:

        MJobSetAttr(J,mjaVariables,(void **)TokPtr2,mdfString,mAdd);

        break;

      default:

        /* NO-OP */
 
        break;
      }  /* END switch (aindex) */

    ptr = MUStrTok(NULL,";",&TokPtr);
    }    /* END while (ptr != NULL) */

cleanupExit:
  MUFree(&mutableResponse);

  return(rc);
  }  /* END MRMJobValidate() */
Example #16
0
int runPFSortedJets(std::string fileName) {

    // Create file on which histogram(s) can be saved.
    TFile *inFile = new TFile(fileName.c_str(), "READ");
    THStack* partFracs = new THStack("particlestacks", "");

    // Read histograms.
    vector<TProfile*> fractionProfiles;
    for (int idx = 0; idx != 16; ++idx){
        std::stringstream tmpString("");
        tmpString << "a" << idx; 
        // a = all, g = gluonjets, q = quarkjets, lq = low pt quarks, hq = high pt quarks
        fractionProfiles.push_back( (TProfile*) inFile->Get( tmpString.str().c_str()) );
    }
    cout << fractionProfiles.size();

    vector<TH1D*> fractionHists;
    for (int idx = 0; idx != 16; ++idx){
        fractionHists.push_back( fractionProfiles[idx]->ProjectionX("","") );
    }
    vector<TH1D*> PFfracs;
    PFfracs.push_back( (TH1D*) fractionHists[0]->Clone("chf") );
    PFfracs[0]->Add( fractionHists[1] );
    PFfracs[0]->Add( fractionHists[3] );
    PFfracs[0]->Add( fractionHists[4] );
    PFfracs[0]->Add( fractionHists[7] );
    PFfracs[0]->Add( fractionHists[8] );
    PFfracs[0]->Add( fractionHists[13] );
    PFfracs.push_back( (TH1D*) fractionHists[2]->Clone("phf") );
    PFfracs[1]->Add( fractionHists[11] );
    PFfracs.push_back( (TH1D*) fractionHists[5]->Clone("nhf") );
    PFfracs[2]->Add( fractionHists[6] );
    PFfracs[2]->Add( fractionHists[9] );
    PFfracs[2]->Add( fractionHists[10] );
    PFfracs[2]->Add( fractionHists[12] );
    PFfracs.push_back( (TH1D*) fractionHists[14]->Clone("elf+muf") );
    PFfracs.push_back( (TH1D*) fractionHists[15]->Clone("others") );

    PFfracs[0]->SetFillColor(kRed);
    PFfracs[1]->SetFillColor(kBlue);
    PFfracs[2]->SetFillColor(kGreen);
    PFfracs[3]->SetFillColor(kYellow);
    PFfracs[4]->SetFillColor(kCyan);

    for (unsigned i = 0; i != PFfracs.size(); ++i){
        partFracs->Add( PFfracs[i] );
    }

    TCanvas *canv = tdrCanvas("c1",fractionHists[0],12,0,1);//new TCanvas("c1","c1",600,600);

    stackModify(fractionHists[0]);
    partFracs->SetHistogram( fractionHists[0] );
    partFracs->GetHistogram()->SetMaximum(1.01);
    partFracs->GetHistogram()->SetMinimum(-0.01);
    //partFracs->SetFillStyle(4000);

    TLegend *leg = tdrLeg(0.83,0.1,0.98,0.93);
    leg->AddEntry( PFfracs[4], "rest", "f" );
    leg->AddEntry( PFfracs[3], "elf+muf", "f" );
    leg->AddEntry( PFfracs[2], "nhf", "f" );
    leg->AddEntry( PFfracs[1], "phf", "f" );
    leg->AddEntry( PFfracs[0], "chf", "f" );
    leg->SetTextSize(0.045);

    TLatex latex;
    latex.SetNDC();
    latex.SetTextAngle(0);
    latex.SetTextColor(kBlack);

    latex.SetTextFont(42);
    latex.SetTextAlign(31);
    latex.SetTextSize(0.6*0.07);

    partFracs->Draw("same");
    latex.DrawLatex(0.77,0.85,"Pythia 6 Z2*");

    //fixOverlay();
    //canv->Print("efracs.pdf"); 
    // Done.
    return 0;
}
Example #17
0
void appl::TextViewer::onRegenerateDisplay() {
	if (needRedraw() == false) {
		return;
	}
	//tic();
	// For the scrooling windows
	m_displayDrawing.clear();
	m_displayText.clear();
	
	// reset the background :
	m_displayDrawing.setPos(vec3(0, 0, 0));
	m_displayDrawing.setColor((*m_paintingProperties)[m_colorBackground].getForeground());
	m_displayDrawing.rectangleWidth(m_size);
	
	if (m_buffer == nullptr) {
		m_maxSize.setX(256);
		m_maxSize.setY(256);
		float textEndAlignament = std::max(11.0f, m_size.x()-20.0f);
		m_displayText.setTextAlignement(10, textEndAlignament, ewol::compositing::alignLeft);
		m_displayText.setRelPos(vec3(10, 0, 0));
		std::string tmpString("<br/>\n"
		                       "<font color=\"red\">\n"
		                       "	<b>\n"
		                       "		edn - Editeur De N'ours\n"
		                       "	</b>\n"
		                       "</font>\n"
		                       "<br/>\n"
		                       "<br/>\n"
		                       "<font color=\"indigo\">\n"
		                       "	<i>\n"
		                       "		No Buffer Availlable to display\n"
		                       "	</i>\n"
		                       "</font>\n");
		m_displayText.setPos(vec3(0.0f, m_size.y(), 0.0f) );
		m_displayText.forceLineReturn();
		m_displayText.printDecorated(tmpString);
		// call the herited class...
		WidgetScrolled::onRegenerateDisplay();
		return;
	}
	// normal displa of the buffer :
	vec3 tmpCursorPosition(0, 0, -1);
	float tmpCursorLenght = -1.0;
	// real display ...
	m_displayText.setColor(etk::Color<>(0, 0, 0, 255));
	float countNbLine = 1;
	int32_t countColomn = 0;
	// the siplay string :
	std::u32string stringToDisplay;
	appl::Buffer::Iterator selectPosStart = m_buffer->begin();
	appl::Buffer::Iterator selectPosStop = m_buffer->begin();
	if (m_buffer->hasTextSelected() == true) {
		selectPosStart = m_buffer->selectStart();
		selectPosStop = m_buffer->selectStop();
	}
	m_displayText.setPos(vec3(-m_originScrooled.x(), m_size.y()+m_originScrooled.y(), 0));
	m_displayText.forceLineReturn();
	appl::Buffer::Iterator startingIt = m_buffer->begin();
	int64_t startLineId = 0;
	if (m_size.y() < m_displayText.getPos().y()) {
		for (startingIt = m_buffer->begin();
		     (bool)startingIt == true;
		     ++startingIt) {
			if (*startingIt == u32char::Return) {
				++startLineId;
				m_displayText.forceLineReturn();
				if (m_size.y() >= m_displayText.getPos().y()) {
					++startingIt;
					break;
				}
			}
		}
	}
	// Display line number :
	m_lastOffsetDisplay = 0;
	vec3 tmpLetterSize = m_displayText.calculateSize((char32_t)'A');
	{
		int32_t nbLine = m_buffer->getNumberOfLines();
		float nbLineCalc = nbLine;
		int32_t nbChar = 0;
		while (nbLineCalc >= 1.0f) {
			++nbChar;
			nbLineCalc /= 10.0f;
		}
		m_lastOffsetDisplay = tmpLetterSize.x() * (float)nbChar + 1.0f;
		m_displayText.setFontItalic((*m_paintingProperties)[m_colorLineNumber].getItalic());
		m_displayText.setFontBold((*m_paintingProperties)[m_colorLineNumber].getBold());
		m_displayText.setColorBg((*m_paintingProperties)[m_colorLineNumber].getBackground());
		m_displayText.setColor((*m_paintingProperties)[m_colorLineNumber].getForeground());
		m_displayText.setClippingMode(false);
		
		vec3 startWriteRealPosition = m_displayText.getPos();
		m_displayText.setPos(vec3(0.0f, startWriteRealPosition.y(), 0.0f));
		for (int32_t iii=startLineId;
		     iii<nbLine;
		     ++iii) {
			char tmpLineNumber[50];
			sprintf(tmpLineNumber, "%*d", nbChar, iii+1);
			m_displayText.print(tmpLineNumber);
			m_displayText.forceLineReturn();
			if (m_displayText.getPos().y() < -20.0f ) {
				break;
			}
		}
		m_displayText.setPos(vec3(-m_originScrooled.x()+m_lastOffsetDisplay, startWriteRealPosition.y(), 0.0f));
		m_displayText.setClipping(vec2(m_lastOffsetDisplay, 0), m_size);
	}
	appl::DisplayHLData displayLocalSyntax;
	m_buffer->hightlightGenerateLines(displayLocalSyntax, startingIt, (m_size.y()/tmpLetterSize.y()) + 5);
	float maxSizeX = 0;
	appl::HighlightInfo * HLColor = nullptr;
	bool DisplayCursorAndSelection = isSelectedLast();
	appl::Buffer::Iterator it;
	for (it = startingIt;
	     (bool)it == true;
	     ++it) {
		if (it == m_buffer->cursor()) {
			// need to display the cursor :
			tmpCursorPosition = m_displayText.getPos();
			tmpCursorLenght = 0.0f;
		}
		//APPL_DEBUG("display element '" << currentValue << "'at pos : " << m_displayText.getPos() );
		//APPL_DEBUG(" element size : " << iii << " : " << bufferElementSize);
		if (*it == u32char::Return) {
			countNbLine += 1;
			countColomn = 0;
			maxSizeX = std::max(m_displayText.getPos().x(), maxSizeX);
			// Display the end line position only if we have the focus ...
			if (DisplayCursorAndSelection == true) {
				if (it >= selectPosStart && it < selectPosStop) {
					ewol::compositing::Drawing& draw = m_displayText.getDrawing();
					draw.setColor(etk::Color<>(0xFF, 0x00, 0x00, 0xFF));
					draw.setPos(m_displayText.getPos() + tmpLetterSize/4.0f);
					draw.rectangle(m_displayText.getPos() + tmpLetterSize*3.0f/4.0f);
				}
			}
			if (tmpCursorLenght == 0.0f) {
				tmpCursorLenght = tmpLetterSize.x();
			}
			m_displayText.forceLineReturn();
			m_displayText.setPos(vec3(-m_originScrooled.x()+m_lastOffsetDisplay, m_displayText.getPos().y(), 0.0f));
			if (m_displayText.getPos().y() < -20.0f ) {
				break;
			}
			continue;
		}
		HLColor = m_buffer->getElementColorAtPosition(displayLocalSyntax, (int64_t)it);
		bool haveBackground = false;
		if (    HLColor != nullptr
		     && HLColor->patern != nullptr) {
			m_displayText.setColor(HLColor->patern->getColorGlyph().getForeground());
			m_displayText.setColorBg(HLColor->patern->getColorGlyph().getBackground());
			haveBackground = HLColor->patern->getColorGlyph().haveBackground();
			m_displayText.setFontItalic(HLColor->patern->getColorGlyph().getItalic());
			m_displayText.setFontBold(HLColor->patern->getColorGlyph().getBold());
		} else {
			m_displayText.setFontItalic((*m_paintingProperties)[m_colorNormal].getItalic());
			m_displayText.setFontBold((*m_paintingProperties)[m_colorNormal].getBold());
			m_displayText.setColorBg((*m_paintingProperties)[m_colorNormal].getBackground());
			m_displayText.setColor((*m_paintingProperties)[m_colorNormal].getForeground());
		}
		if (haveBackground == false) {
			if (*it == u32char::Space) {
				m_displayText.setColorBg((*m_paintingProperties)[m_colorSpace].getForeground());
			} else if (*it == u32char::Tabulation) {
				m_displayText.setColorBg((*m_paintingProperties)[m_colorTabulation].getForeground());
			}
		}
		m_buffer->expand(countColomn, *it, stringToDisplay);
		// Display selection only if we have the focus ...
		if (DisplayCursorAndSelection == true) {
			if (it >= selectPosStart && it < selectPosStop) {
				m_displayText.setColor((*m_paintingProperties)[m_colorSelection].getForeground());
				m_displayText.setColorBg((*m_paintingProperties)[m_colorSelection].getBackground());
			}
		}
		//APPL_DEBUG("display : '" << currentValue << "'  == > '" << stringToDisplay << "'");
		m_displayText.print(stringToDisplay);
		if (tmpCursorLenght == 0.0f) {
			tmpCursorLenght = m_displayText.getPos().x()-tmpCursorPosition.x();
		}
		countColomn += stringToDisplay.size();
	}
	if (it == m_buffer->cursor()) {
		tmpCursorPosition = m_displayText.getPos();
		tmpCursorLenght = 5;
	}
	maxSizeX = std::max(m_displayText.getPos().x(), maxSizeX);
	// Display cursor only if we have the focus ...
	if (    tmpCursorPosition.z() != -1
	     && getFocus() == true) {
		// display the cursor:
		//APPL_DEBUG("display cursor at position : " << tmpCursorPosition);
		m_displayText.setPos(tmpCursorPosition);
		if (m_buffer->hasTextSelected() == true) {
			m_displayText.setColorBg((*m_paintingProperties)[m_colorCursor].getForeground());
			m_displayText.printCursor(false);
		} else {
			if (m_insertMode == true) {
				m_displayText.setColorBg((*m_paintingProperties)[m_colorSelection].getBackground());
			} else {
				m_displayText.setColorBg((*m_paintingProperties)[m_colorCursor].getForeground());
			}
			m_displayText.printCursor(m_insertMode, tmpCursorLenght);
		}
	}
	// set maximum size (X&Y) :
	{
		vec3 tmpLetterSize = m_displayText.calculateSize((char32_t)'A');
		int64_t nbLines = m_buffer->getNumberOfLines();
		m_maxSize.setX(maxSizeX+m_originScrooled.x());
		m_maxSize.setY((float)nbLines*tmpLetterSize.y());
	}
	//toc("Display time : ");
	// call the herited class...
	WidgetScrolled::onRegenerateDisplay();
}
Example #18
0
bool osgDoInit(OSG::Int32, 
               OSG::Char8 **,
               OSG::UInt16   major,
               OSG::UInt16   minor,
               OSG::UInt16   release,
               bool          debug,
               bool          dll,
               bool          mt)
{
    CompileConfig prog(major, 
                       minor, 
                       release, 
                       debug, 
                       dll, 
                       mt);

    CompileConfig lib (OSG_MAJOR_VERSION, 
                       OSG_MINOR_VERSION, 
                       OSG_RELEASE_VERSION,
                       OSG_INIT_DEBUG,
                       OSG_INIT_DLL,
                       OSG_INIT_MT);
    
    if(lib.compare(prog))
    {
        exit(1);
    }

#ifdef WIN32 
    // Very crude way to safeguard on low level cast, have to find a better
    // way later.
    OSG_ASSERT(sizeof(UInt32) == sizeof(long));
#endif

    bool returnValue = true;
    
    if(GlobalSystemState != Startup)
    {
        FFATAL(("osgInit: System was already initialized; repeated calls are "
                "NOT allowed.\n"));
                
        returnValue = false;
    }

    if(returnValue == false)
        return returnValue;

    returnValue = SharedObjectHandler::the()->initialize();

    if(osgPreloadSharedObject != NULL)
    {
        for(UInt32 i = 0; i < osgPreloadSharedObject->size(); ++i)
        {
            SharedObjectHandler::the()->getOSGSharedObject(
                (*osgPreloadSharedObject)[i].c_str());
        }
    }

#ifdef WIN32
    std::string pathSep(";");
#else
    std::string pathSep(":");
#endif

    char *szEnvLibs = getenv("OSG_LOAD_LIBS");

    if(szEnvLibs != NULL)
    {
        std::string tmpString(szEnvLibs);
        string_token_iterator libIt(tmpString, pathSep.c_str());

        string_token_iterator libEnd;

        while(libIt != libEnd)
        {
            SharedObjectHandler::the()->getOSGSharedObject(
                (*libIt).c_str());

            ++libIt;
        }
    }

    const char *szEnvPlugins       = getenv("OSG_PLUGIN_PATH");
    const char *szEnvPluginPattern = getenv("OSG_PLUGIN_PATTERN");

    //SharedObjectHandler::the()->dump();

    if(szEnvPlugins != NULL)
    {
        if(szEnvPluginPattern == NULL)
        {
            szEnvPluginPattern = PluginPattern;
        }

        fprintf(stderr, "Get Plugins %s from %s\n", 
                szEnvPluginPattern,
                szEnvPlugins);

        std::vector<Char8 *> *pPlugins = 
            Directory::getEntries(szEnvPlugins, szEnvPluginPattern);

        if(pPlugins != NULL)
        {
            std::string szPluginName;

            for(UInt32 i = 0; i < pPlugins->size(); ++i)
            {
                if((*pPlugins)[i][0] == '.')
                {
                    if((*pPlugins)[i][1] == '\0')
                    {
                        continue;
                    }
                    else if((*pPlugins)[i][1] == '.' &&
                            (*pPlugins)[i][2] == '\0')
                    {
                        continue;
                    }
                }

                szPluginName.assign(szEnvPlugins);
                szPluginName += '/';
                szPluginName += (*pPlugins)[i];

                fprintf(stderr, "plugin : %s\n", szPluginName.c_str());

                SharedObjectHandler::the()->getSharedObject(
                    szPluginName.c_str());
            }
        }

        delete pPlugins;
    }

    if(osgLibraryVersions != NULL)
    {
        FNOTICE(("osgInit:  Main Version                  : %s\n", OSG_VERSION_STRING));
        for(LibVersionMap::const_iterator LibMapItor(osgLibraryVersions->begin());
            LibMapItor != osgLibraryVersions->end();
            ++LibMapItor)
        {
            FNOTICE(("osgInit:  %-30s: %-10s  Rev: %s\n",
                     LibMapItor->first.c_str(),
                     LibMapItor->second.first.c_str(),
                     LibMapItor->second.second.c_str()));
        }
    }
    
    //SharedObjectHandler::the()->dump();

    if(returnValue == false)
        return returnValue;

    // without it floats could be written as "1,456" ...
    setlocale(LC_NUMERIC, "English");

    if(osgPreMPInitFunctions != NULL)
    {
        for(UInt32 i = 0; i < osgPreMPInitFunctions->size(); i++)
        {
            returnValue &= (*osgPreMPInitFunctions)[i]();

            if(returnValue == false)
                break;
        }

        osgPreMPInitFunctions->clear();
    }

    if(returnValue == false)
        return returnValue;

    returnValue &= ThreadManager::initialize();

    if(returnValue == false)
        return returnValue;

    if(osgPreFactoryInitFunctions != NULL)
    {
        for(UInt32 i = 0; i < osgPreFactoryInitFunctions->size(); i++)
        {
            returnValue &= (*osgPreFactoryInitFunctions)[i]();

            if(returnValue == false)
                break;
        }

        osgPreFactoryInitFunctions->clear();
    }

    if(returnValue == false)
        return returnValue;

    returnValue &= FactoryController::the()->initialize();

    if(returnValue == false)
        return returnValue;

    if(osgPostFactoryInitFunctions != NULL)
    {
        for(UInt32 i = 0; i < osgPostFactoryInitFunctions->size(); i++)
        {
            returnValue &= (*osgPostFactoryInitFunctions)[i]();

            if(returnValue == false)
                break;
        }

        osgPostFactoryInitFunctions->clear();
    }

    GlobalSystemState = Running;

    osgLog().setLogLevel(OSG_DEFAULT_LOG_LEVEL);

    return returnValue;
}
Example #19
0
int MJobProcessTVariables(

  mjob_t *J)  /* I */

  {
  mjob_t *MasterJ = NULL;

  mhashiter_t HTI;
  char *VarName;
  char *VarVal;
  mbitmap_t VarBM;

  char NamesToAdd[MMAX_TEMP_VARS][MMAX_LINE];
  char ValuesToAdd[MMAX_TEMP_VARS][MMAX_LINE];

  char NamesToAddMaster[MMAX_TEMP_VARS][MMAX_LINE];
  char ValuesToAddMaster[MMAX_TEMP_VARS][MMAX_LINE];
  mbitmap_t *BMToAddMaster[MMAX_TEMP_VARS];

  int AddIndex;
  int AddIndexMaster;

  int  tmpI;
  char tmpLine[MMAX_LINE];
  char *SetVal = NULL;

  mbool_t DoVarExport = FALSE;
  mbool_t NoGroupExport = FALSE;  /* don't set the variable to export at the group level */

  const char *FName = "MJobProcessTVariables";

  MDB(3,fSCHED) MLog("%s(%s)\n",
    FName,
    J->Name);

  if (MUHTIsEmpty(&J->Variables))
    {
    return(SUCCESS);
    }

  memset(NamesToAdd,0,sizeof(NamesToAdd));
  memset(ValuesToAdd,0,sizeof(ValuesToAdd));

  AddIndex = 0;

  memset(NamesToAddMaster,0,sizeof(NamesToAddMaster));
  memset(ValuesToAddMaster,0,sizeof(ValuesToAddMaster));
  memset(BMToAddMaster,0,sizeof(BMToAddMaster));

  AddIndexMaster = 0;

  MUHTIterInit(&HTI);

  while (MUHTIterate(&J->Variables,&VarName,(void **)&VarVal,&VarBM,&HTI) == SUCCESS)
    {
    DoVarExport = FALSE;
    NoGroupExport = FALSE;

    MDB(7,fSCHED) MLog("INFO:     processing variable '%s'\n",
      VarName);

    SetVal = VarVal;

    if (bmisset(&VarBM,mtvaExport))
      DoVarExport = TRUE;

    if (bmisset(&VarBM,mtvaIncr))
      {
      if (VarVal != NULL)
        {
        tmpI = (int)strtol((char *)VarVal,NULL,10);

        tmpI++;
        }
      else
        {
        tmpI = 1;
        }

      snprintf(tmpLine,sizeof(tmpLine),"%d",tmpI);

      SetVal = tmpLine;

      if (AddIndex < MMAX_TEMP_VARS)
        {
        MUStrCpy(NamesToAdd[AddIndex],VarName,MMAX_LINE);
        MUStrCpy(ValuesToAdd[AddIndex],SetVal,MMAX_LINE);

        AddIndex++;
        }

      MJobWriteVarStats(J,mSet,VarName,SetVal,NULL);
      }
    else if ((!strcasecmp(VarName,"ccode")) && 
             (MJOBISCOMPLETE(J) == TRUE))
      {
      DoVarExport = TRUE;
      NoGroupExport = TRUE;

      snprintf(tmpLine,sizeof(tmpLine),"%d",
        J->CompletionCode);

      SetVal = tmpLine;

      if (AddIndex < MMAX_TEMP_VARS)
        {
        MUStrCpy(NamesToAdd[AddIndex],VarName,MMAX_LINE);
        MUStrCpy(ValuesToAdd[AddIndex],SetVal,MMAX_LINE);

        AddIndex++;
        }

      MJobWriteVarStats(J,mSet,VarName,SetVal,NULL);

#ifdef MYAHOO
#define MPBS_STDFILE_ERROR_CODE -9
      /* check to see if we have a special completion code
       * that should result in an error message */

      if (J->CompletionCode == MPBS_STDFILE_ERROR_CODE)
        {
        mjob_t *JGroup;
        char tmpLine[MMAX_LINE];
        mstring_t tmpString(MMAX_LINE);

        MJobAToMString(
          J,
          mjaAllocNodeList,
          &tmpString,
          mfmNONE);

        snprintf(tmpLine,sizeof(tmpLine),"job '%s' failed to create stdout/stderr files on '%s'",
          J->Name,
          tmpString.c_str());

        /* there has been an error setting the stdout/stderr file */

        MMBAdd(
          &J->MessageBuffer,
          tmpLine,
          NULL,
          mmbtOther,
          MSched.Time + MCONST_DAYLEN,
          0,
          NULL);

        if (MJobGetGroupJob(J,&JGroup) == SUCCESS)
          {
          MMBAdd(
            &JGroup->MessageBuffer,
            tmpLine,
            NULL,
            mmbtOther,
            MSched.Time + MCONST_DAYLEN,
            0,
            NULL);
          }
        }
#endif /* MYAHOO */
      }
    else if (!strcmp(VarName,"HOSTLIST") &&
             (MJOBISCOMPLETE(J) == TRUE))
      {
      mstring_t tmp(MMAX_LINE);

      if (MJobAToMString(
            J,
            mjaAllocNodeList,
            &tmp) == SUCCESS)
        {
        /* can succeed, but not populate outgoing buffer */

        if (!tmp.empty())
          {
          DoVarExport = TRUE;
          NoGroupExport = TRUE;

          if (AddIndex < MMAX_TEMP_VARS)
            {
            MUStrCpy(NamesToAdd[AddIndex],VarName,MMAX_LINE);
            MUStrCpy(ValuesToAdd[AddIndex],tmp.c_str(),MMAX_LINE);

            AddIndex++;
            }

          MJobWriteVarStats(J,mSet,VarName,tmp.c_str(),NULL);
          }
        }
      }

    if (bmisset(&VarBM,mtvaNoExport))
      {
      /* override our desire to export this variable if it
       * is explicitly stated that this variable should NOT
       * be exported */

      DoVarExport = FALSE;
      }

    /* export variable to group job */

    if ((DoVarExport == TRUE) &&
        (J->JGroup != NULL)) 
      {
      if (MJobFind(J->JGroup->Name,&MasterJ,mjsmExtended) == SUCCESS)
        {
        mbitmap_t GroupBM;
        char *GroupVal;

        if ((bmisset(&VarBM,mtvaExport) && bmisset(&VarBM,mtvaIncr)) &&
            (MUHTGet(&MasterJ->Variables,VarName,(void **)&GroupVal,&GroupBM) == SUCCESS))
          {
          if (GroupVal != NULL)
            {
            tmpI = (int)strtol(GroupVal,NULL,10);

            tmpI++;
            }
          else
            {
            tmpI = 1;
            }

          snprintf(tmpLine,sizeof(tmpLine),"%d",tmpI);

          SetVal = tmpLine;

          bmset(&GroupBM,mtvaExport);
          }
        else if (NoGroupExport == TRUE)
          {
          /* prevent this variable from exporting up, further
           * out of the group object */

          bmset(&GroupBM,mtvaNoExport);
          }
        else if (DoVarExport == TRUE)
          {
          bmset(&GroupBM,mtvaExport);
          }

        if (AddIndexMaster < MMAX_TEMP_VARS)
          {
          MUStrCpy(NamesToAddMaster[AddIndexMaster],VarName,MMAX_LINE);
          MUStrCpy(ValuesToAddMaster[AddIndexMaster],SetVal,MMAX_LINE);
          BMToAddMaster[AddIndexMaster] = &GroupBM;

          AddIndexMaster++;
          }

        MJobWriteVarStats(MasterJ,mSet,VarName,SetVal,NULL);
        }    /* END if ((MJobFind(J->JGroup) || ... */
      }      /* END if ((J->JGroup != NULL)... */
    }  /* END while (MUHTIterate()) */

  if (!MUStrIsEmpty(NamesToAdd[0]))
    {
    for (AddIndex = 0;AddIndex < MMAX_TEMP_VARS;AddIndex++)
      {
      if (MUStrIsEmpty(NamesToAdd[AddIndex]))
        break;

      MUHTAdd(&J->Variables,NamesToAdd[AddIndex],strdup(ValuesToAdd[AddIndex]),NULL,MUFREE);
      }
    }  /* END if (!MUStrIsEmpty(NamesToAdd[0])) */

  if ((MasterJ != NULL) && !MUStrIsEmpty(NamesToAddMaster[0]))
    {
    for (AddIndexMaster = 0;AddIndexMaster < MMAX_TEMP_VARS;AddIndexMaster++)
      {
      if (MUStrIsEmpty(NamesToAddMaster[AddIndexMaster]))
        break;

      MUHTAdd(&J->Variables,NamesToAddMaster[AddIndexMaster],strdup(ValuesToAddMaster[AddIndexMaster]),BMToAddMaster[AddIndexMaster],MUFREE);
      }
    }

  /* checkpoint jobs to ensure we don't lose newly updated variables in a crash */

  MOCheckpoint(mxoJob,(void *)J,FALSE,NULL);
  MOCheckpoint(mxoJob,(void *)MasterJ,FALSE,NULL);

  return(SUCCESS);
  }  /* END MJobProcessTVariables() */
Example #20
0
int MRMNodeSetPowerState(

  mnode_t              *N,
  mnl_t                *NL,
  mvm_t                *V,
  enum MPowerStateEnum  PowerState,
  char                 *EMsg)

  {
  char    *ptr;

  int      nindex;
  int      rc;

  mnode_t *tmpN = NULL;

  mnat_t *ND = NULL;

  mpsi_t *P = NULL;  

  char CmdString[MMAX_LINE];

  long RMTime;

  const char *FName = "MRMNodeSetPowerState";

  MDB(2,fRM) MLog("%s(%s,%s,%s,EMsg)\n",
    FName,
    (N != NULL) ? N->Name : "NULL",
    (V != NULL) ? V->VMID : "",
    MPowerState[PowerState]);

  if (EMsg != NULL)
    EMsg[0] = '\0';

  tmpN = (NL != NULL) ? MNLReturnNodeAtIndex(NL,0) : N;

  if ((tmpN == NULL) || (PowerState == mpowNONE))
    {
    return(FAILURE);
    }

  if ((MSched.ProvRM != NULL) && (MSched.ProvRM->ND.Path[mrmXNodePower] != NULL))
    {
    ND = &MSched.ProvRM->ND;
    P = MSched.ProvRM->P;
    }
  else if ((tmpN->RM != NULL) && (tmpN->RM->ND.Path[mrmXNodePower] != NULL))
    {
    ND = &tmpN->RM->ND;
    P = tmpN->RM->P;
    }

  /* perform variable-substitution in URL */

  if (ND != NULL)
    {
    MUInsertVarList(
      ND->Path[mrmXNodePower],
      NULL,
      NULL,
      NULL,
      CmdString,         /* O */
      sizeof(CmdString),
      FALSE);
    }

  if ((V != NULL) && (V->PowerState == PowerState))
    {
    /* requested state already active */

    MDB(3,fSTRUCT) MLog("INFO:     powerselectstate (%s) matches requested powerstate on vm %s\n",
      MPowerState[PowerState],
      V->VMID);

    /* need a better way to handle this */
    /* return(SUCCESS); */
    }

  if (tmpN->PowerSelectState == PowerState)
    {
    /* requested state already active */

    MDB(3,fSTRUCT) MLog("INFO:     powerselectstate (%s) matches requested powerstate on node %s\n",
      MPowerState[PowerState],
      tmpN->Name);

    /* need a better way to handle this */
    /* return(SUCCESS); */
    }

  switch (PowerState)
    {
    case mpowOn:
    case mpowOff:

      if (V != NULL)
        {
        V->PowerSelectState = PowerState;
        V->PowerState       = PowerState;
        V->PowerMTime       = MSched.Time;
        }
      else
        {
        for (nindex = 0;nindex < MSched.M[mxoNode];nindex++)
          {
          if (NL != NULL)
            {
            tmpN = MNLReturnNodeAtIndex(NL,nindex);
            }
          else if (nindex > 0)
            {
            tmpN = NULL;
            }
          else
            {
            tmpN = N;
            }
 
          if (tmpN == NULL)
            break;

          /* power node on */
     
          if ((ND == NULL) || (ND->Path[mrmXNodePower] == NULL))
            {
            if (MSched.Mode != msmTest)
              {
              MDB(3,fSTRUCT) MLog("WARNING:  no external power interface - cannot power %s node %s%s%s\n",
                MPowerState[PowerState],
                tmpN->Name,
                (V != NULL) ? ":" : "",
                (V != NULL) ? V->VMID : "");
     
              if (PowerState == mpowOn)
                {
                MMBAdd(&tmpN->MB,"no external power interface - cannot power on node",NULL,mmbtNONE,0,0,NULL);
          
                if (tmpN->RM != NULL)
                  MMBAdd(&tmpN->RM->MB,"no external power interface - cannot power on node",NULL,mmbtNONE,0,0,NULL);
                }
              else
                {
                MMBAdd(&tmpN->MB,"no external power interface - cannot power off node",NULL,mmbtNONE,0,0,NULL);
          
                if (tmpN->RM != NULL)
                  MMBAdd(&tmpN->RM->MB,"no external power interface - cannot power off node",NULL,mmbtNONE,0,0,NULL);
                }
    
              if (EMsg != NULL)
                snprintf(EMsg,MMAX_LINE,"no external power interface - cannot modify power state");
     
              return(FAILURE);
              }
     
            /* no external action specified, make local changes only */
     
            MDB(3,fSTRUCT) MLog("INFO:     no external power interface - internally powering %s node %s\n",
              MPowerState[PowerState],
              tmpN->Name);
     
            tmpN->PowerSelectState = PowerState;
            tmpN->PowerIsEnabled = TRUE;
     
            return(SUCCESS);
            } /* END if ((ND == NULL) || (ND->Path[mrmXNodePower] == NULL)) */
          }   /* END for (nindex) */
        }     /* END else */

      {
      mstring_t NodeList(MMAX_LINE);

      if (NL != NULL)
        {
        MNLToMString(NL,FALSE,",",'\0',1,&NodeList);
  
        ptr = NodeList.c_str();

        tmpN = MNLReturnNodeAtIndex(NL,0);
        }
      else if (V != NULL)
        {
        ptr = V->VMID;

        tmpN = N;
        }
      else
        {
        ptr =  N->Name;

        tmpN = N;
        }

      mstring_t tmpString(MMAX_LINE);

      /* execute script */

      MStringAppendF(&tmpString,"%s %s %s",
        CmdString,
        ptr,
        (PowerState == mpowOn) ? "ON" : "OFF");

      MRMStartFunc(tmpN->RM,NULL,mrmNodeModify);

      /* switched to MUReadPipe2 4/3/09 DRW */

      mstring_t Response(MMAX_LINE);
      mstring_t StdErr(MMAX_LINE);

      if (MUReadPipe2(
            tmpString.c_str(),          /* COMMAND */
            NULL,                       /* stdin */
            &Response,                  /* stdout */
            &StdErr,                    /* stderr */
            P,                          /* PSI */
            &rc,                        /* return code */
            EMsg,                       /* duh */
            NULL) == FAILURE)           /* SC */
        {
        MDB(1,fSTRUCT) MLog("ALERT:    cannot read output of command '%s'\n",
          CmdString);

        return(FAILURE);
        }

      MRMEndFunc(tmpN->RM,NULL,mrmNodeModify,&RMTime);

      /* remove time from sched load and add to rm action load */

      MSched.LoadEndTime[mschpRMAction] += RMTime;
      MSched.LoadStartTime[mschpSched]  += RMTime;

      if (strstr(Response.c_str(),"ERROR") != NULL)
        {
        MDB(1,fSTRUCT) MLog("ALERT:    unable to set power to %s for node %s with command '%s'\n",
          MPowerState[PowerState],
          tmpN->Name,
          CmdString);

        if (EMsg != NULL)
          snprintf(EMsg,MMAX_LINE,"error reported from power command - %s",
            Response.c_str());

        return(FAILURE);
        }

      if (V != NULL)
        {
        V->PowerSelectState = PowerState;
        V->PowerState       = PowerState;
        }
      else
        {
        char tmpLine[MMAX_LINE];

        snprintf(tmpLine,sizeof(tmpLine),"node powered %s",
          MPowerState[PowerState]);

        for (nindex = 0;nindex < MSched.M[mxoNode];nindex++)
          {
          if (NL != NULL)
            {
            tmpN = MNLReturnNodeAtIndex(NL,nindex);
            }
          else if (nindex > 0)
            {
            tmpN = NULL;
            }
          else
            {
            tmpN = N;
            }
 
          if (tmpN == NULL)
            break;

          tmpN->PowerSelectState = PowerState;
          tmpN->PowerIsEnabled   = TRUE;

          MOWriteEvent((void *)tmpN,mxoNode,mrelNodeModify,tmpLine,MStat.eventfp,NULL);
     
          if ((PowerState == mpowOn) &&
              (V == NULL) &&
              (MPOWPISGREEN(tmpN->PowerPolicy) || (MPOWPISGREEN(MSched.DefaultN.PowerPolicy))))
            {
            double IdleWatts;
     
            /* NOTE:  node is transitioning from standby to idle */
     
            IdleWatts = MPar[tmpN->PtIndex].DefNodeIdleWatts;
     
            if ((MSched.WattsGMetricIndex > 0) &&
               ((tmpN->XLoad == NULL) || !bmisset(&tmpN->XLoad->RMSetBM,MSched.WattsGMetricIndex)))
              {
              MNodeSetGMetric(
                tmpN,
                MSched.WattsGMetricIndex,
                MPar[tmpN->PtIndex].DefNodeIdleWatts);
     
              tmpN->XLoad->GMetric[MSched.WattsGMetricIndex]->IntervalLoad = MPar[tmpN->PtIndex].DefNodeIdleWatts;
              tmpN->XLoad->GMetric[MSched.WattsGMetricIndex]->SampleCount++;
              }
     
            if (MSched.PWattsGMetricIndex > 0)
              {
              MNodeSetGMetric(
                tmpN,
                MSched.PWattsGMetricIndex,
                IdleWatts);
              }
            }
          else if ((PowerState == mpowOff) &&
                   (V == NULL) &&
                   (MPOWPISGREEN(tmpN->PowerPolicy) || (MPOWPISGREEN(MSched.DefaultN.PowerPolicy))))
            {
            /* node is transitioning from idle to standby */
     
            if ((MSched.WattsGMetricIndex > 0) &&
               ((tmpN->XLoad == NULL) || !bmisset(&tmpN->XLoad->RMSetBM,MSched.WattsGMetricIndex)))
              {
              /* RM is not reporting wattage, usage defaults */
     
              MNodeSetGMetric(tmpN,MSched.WattsGMetricIndex,MPar[tmpN->PtIndex].DefNodeStandbyWatts);
     
              /* NOTE:  pwatts should maintain 'idle' wattage. */
     
              tmpN->XLoad->GMetric[MSched.WattsGMetricIndex]->IntervalLoad = MPar[tmpN->PtIndex].DefNodeStandbyWatts;
              tmpN->XLoad->GMetric[MSched.WattsGMetricIndex]->SampleCount++;
              }
            }
          }    /* END for (nindex) */
        }      /* END else */
      }

      break;

    default:

      /* NYI */

      return(FAILURE);

      /*NOTREACHED*/

      break;
    }  /* END switch (PowerState) */

  return(SUCCESS);
  }  /* END MRMNodeSetPowerState() */