예제 #1
0
파일: prntutil.c 프로젝트: noxdafox/clips
globle void PrintAtom(
  void *theEnv,
  const char *logicalName,
  int type,
  void *value)
  {
   struct externalAddressHashNode *theAddress;
   char buffer[20];

   switch (type)
     {
      case FLOAT:
        PrintFloat(theEnv,logicalName,ValueToDouble(value));
        break;
      case INTEGER:
        PrintLongInteger(theEnv,logicalName,ValueToLong(value));
        break;
      case SYMBOL:
        EnvPrintRouter(theEnv,logicalName,ValueToString(value));
        break;
      case STRING:
        if (PrintUtilityData(theEnv)->PreserveEscapedCharacters)
          { EnvPrintRouter(theEnv,logicalName,StringPrintForm(theEnv,ValueToString(value))); }
        else
          {
           EnvPrintRouter(theEnv,logicalName,"\"");
           EnvPrintRouter(theEnv,logicalName,ValueToString(value));
           EnvPrintRouter(theEnv,logicalName,"\"");
          }
        break;

      case DATA_OBJECT_ARRAY:
        if (PrintUtilityData(theEnv)->AddressesToStrings) EnvPrintRouter(theEnv,logicalName,"\"");
        
        EnvPrintRouter(theEnv,logicalName,"<Pointer-");
        gensprintf(buffer,"%p",value);
        EnvPrintRouter(theEnv,logicalName,buffer);
        EnvPrintRouter(theEnv,logicalName,">");
          
        if (PrintUtilityData(theEnv)->AddressesToStrings) EnvPrintRouter(theEnv,logicalName,"\"");
        break;

      case EXTERNAL_ADDRESS:
        theAddress = (struct externalAddressHashNode *) value;
        
        if (PrintUtilityData(theEnv)->AddressesToStrings) EnvPrintRouter(theEnv,logicalName,"\"");
        
        if ((EvaluationData(theEnv)->ExternalAddressTypes[theAddress->type] != NULL) &&
            (EvaluationData(theEnv)->ExternalAddressTypes[theAddress->type]->longPrintFunction != NULL))
          { (*EvaluationData(theEnv)->ExternalAddressTypes[theAddress->type]->longPrintFunction)(theEnv,logicalName,value); }
        else
          {
           EnvPrintRouter(theEnv,logicalName,"<Pointer-");
        
           gensprintf(buffer,"%d-",theAddress->type);
           EnvPrintRouter(theEnv,logicalName,buffer);
        
           gensprintf(buffer,"%p",ValueToExternalAddress(value));
           EnvPrintRouter(theEnv,logicalName,buffer);
           EnvPrintRouter(theEnv,logicalName,">");
          }
          
        if (PrintUtilityData(theEnv)->AddressesToStrings) EnvPrintRouter(theEnv,logicalName,"\"");
        break;

#if OBJECT_SYSTEM
      case INSTANCE_NAME:
        EnvPrintRouter(theEnv,logicalName,"[");
        EnvPrintRouter(theEnv,logicalName,ValueToString(value));
        EnvPrintRouter(theEnv,logicalName,"]");
        break;
#endif

      case RVOID:
        break;

      default:
        if (EvaluationData(theEnv)->PrimitivesArray[type] == NULL) break;
        if (EvaluationData(theEnv)->PrimitivesArray[type]->longPrintFunction == NULL)
          {
           EnvPrintRouter(theEnv,logicalName,"<unknown atom type>");
           break;
          }
        (*EvaluationData(theEnv)->PrimitivesArray[type]->longPrintFunction)(theEnv,logicalName,value);
        break;
     }
  }
예제 #2
0
void DdmRAIDMstrTest
::rmstrEventHandler(
			STATUS			eventCode,
			void			*pStatusData)
{
	U32					i=0;
	rowID				dedicatedSpareId;
	rowID				addMemberId;

	TRACEF_NF(TRACE_RMSTR_1,("\nEnter: DdmRAIDMstrTest::rmstrEventHandler\n"));
	RMSTR_EVT_ARRAY_ADDED_STATUS		*pEvtArrayAdded = NULL;
	RMSTR_EVT_ARRAY_DELETED_STATUS		*pEvtArrayDeleted = NULL;
	RMSTR_EVT_SPARE_ADDED_STATUS		*pEvtSpareAdded = NULL;
	RMSTR_EVT_SPARE_DELETED_STATUS		*pEvtSpareDeleted = NULL;
	RMSTR_EVT_UTIL_STARTED_STATUS		*pEvtUtilStarted = NULL;
	RMSTR_EVT_UTIL_STOPPED_STATUS		*pEvtUtilStopped = NULL;
	RMSTR_PRIORITY_CHANGED_STATUS		*pEvtPriorityChanged = NULL;
	RMSTR_PERCENT_COMPLETE_STATUS		*pEvtPercentComplete = NULL;
	RMSTR_EVT_MEMBER_DOWN_STATUS		*pEvtMemberDown = NULL;
	RMSTR_EVT_MEMBER_ADDED_STATUS		*pEvtMemberAdded = NULL;
	RMSTR_EVT_SPARE_ACTIVATED_STATUS	*pEvtSpareActivated = NULL;
	RMSTR_EVT_ARRAY_CRITICAL_STATUS		*pEvtArrayCriticalStatus = NULL;
	RMSTR_EVT_ARRAY_OFFLINE_STATUS		*pEvtArrayOfflineStatus = NULL;
	RMSTR_EVT_PREFERRED_MEMBER_CHANGED_STATUS		*pEvtPreferredMemberChanged = NULL;
	RMSTR_EVT_SOURCE_MEMBER_CHANGED_STATUS			*pEvtSourceMemberChanged = NULL;
	RMSTR_EVT_ARRAY_FAULT_TOLERANT_STATUS			*pEvtArrayFaultTolerant = NULL;

	RAID_UTIL_POLICIES					utilPolicy;
	rowID								tempRowId = {9,0,1};

	UnicodeString				ucNewArrayName;
	StringClass					scNewArrayName;


	TRACE_STRING(TRACE_RMSTR_1, "\t<<<Event Received>>>:\n");
	TRACEF_NF(TRACE_RMSTR_1,("\t\tEvent=%s\n", 
				dispEventName[eventCode]));
	switch(eventCode){
	case RMSTR_EVT_ARRAY_ADDED:
		pEvtArrayAdded = (RMSTR_EVT_ARRAY_ADDED_STATUS *)pStatusData;
		PrintArrayData(&pEvtArrayAdded->arrayData);
		// Display the array name
		ucNewArrayName = UnicodeString(pEvtArrayAdded->arrayName);
		ucNewArrayName.GetAsciiString(scNewArrayName);
		TRACEF_NF(TRACE_RMSTR_1, ("\t\tArrayName=%s\n", scNewArrayName.CString()));
#if 0
		addMemberId.Table = pEvtArrayAdded->arrayData.SRCTRID.Table;
		addMemberId.HiPart = 0;
		addMemberId.LoPart = 4;		// 5 is still free

		// Add a member
		TestAddMember(
			&pEvtArrayAdded->arrayData.thisRID,
			&addMemberId);
#endif

#if 0
		TestChangePreferredMember(
				&pEvtArrayAdded->arrayData.thisRID,
				&pEvtArrayAdded->arrayData.members[1]);
#endif
#if 0
		TestChangeSourceMember(
				&pEvtArrayAdded->arrayData.thisRID,
				&pEvtArrayAdded->arrayData.members[1]);
#endif

#if 1
		// Add a Dedicated Spare
		dedicatedSpareId.Table = pEvtArrayAdded->SRCData.rid.Table;
		dedicatedSpareId.HiPart = 0;
		dedicatedSpareId.LoPart = 5;		// 5 is still free
		TestAddSpare(
			//RAID_HOST_POOL_SPARE,
			//RAID_GENERAL_POOL_SPARE,
			RAID_DEDICATED_SPARE,
			&dedicatedSpareId,
			//NULL,
			&pEvtArrayAdded->arrayData.thisRID,	// target rid
			NULL);
#endif
#if 0
		memset(&utilPolicy,0,sizeof(RAID_UTIL_POLICIES));
		// Start a verify on the Array
		utilPolicy.SilentMode = 1;
		utilPolicy.RunThruErrors = 1;
		utilPolicy.SpecifyMembersToRunOn = 0;
		TestStartUtility(
			&pEvtArrayAdded->arrayData.thisRID,	// target rid
			RAID_UTIL_VERIFY,
			PRIORITY_HIGH,
			utilPolicy,
			5);							// %complete update rate
#endif

#if 0
		// Down a member
		rowID		memberRowId = pEvtArrayAdded->arrayData.members[1];
		TestDownAMember(&pEvtArrayAdded->arrayData.thisRID,&memberRowId);
#endif
		break;

	case RMSTR_EVT_ARRAY_DELETED:
		pEvtArrayDeleted = (RMSTR_EVT_ARRAY_DELETED_STATUS *)pStatusData;
		PrintArrayData(&pEvtArrayDeleted->arrayData);
#if 0
		TestDeleteArray(&pEvtArrayDeleted->arrayData.thisRID);
#endif

		break;


	case RMSTR_EVT_PREFERRED_MEMBER_CHANGED:
		pEvtPreferredMemberChanged = (RMSTR_EVT_PREFERRED_MEMBER_CHANGED_STATUS *)pStatusData;
		PrintArrayData(&pEvtPreferredMemberChanged->arrayData);
		break;

	case RMSTR_EVT_SOURCE_MEMBER_CHANGED:
		pEvtSourceMemberChanged = (RMSTR_EVT_SOURCE_MEMBER_CHANGED_STATUS *)pStatusData;
		PrintArrayData(&pEvtSourceMemberChanged->arrayData);
		break;


	case RMSTR_EVT_UTIL_STARTED:
		pEvtUtilStarted = (RMSTR_EVT_UTIL_STARTED_STATUS *)pStatusData;
		TRACEF_NF(TRACE_RMSTR_1,("\t\tUtil=%s\n", 
				dispUtilityName[pEvtUtilStarted->utilityData.utilityCode]));
		PrintUtilityData(&pEvtUtilStarted->utilityData);

#if 0
		TestDeleteArray(&pEvtUtilStarted->utilityData.targetRID);
#endif

#if 1
		//TestChangePriority(&pEvtUtilStarted->utilityData.thisRID, PRIORITY_LOW);
		TestAbortUtility(&pEvtUtilStarted->utilityData.thisRID);
#endif
		break;

	case RMSTR_EVT_UTIL_STOPPED:
		pEvtUtilStopped = (RMSTR_EVT_UTIL_STOPPED_STATUS *)pStatusData;
		TRACEF_NF(TRACE_RMSTR_1,("\t\tUtil=%s\n", 
				dispUtilityName[pEvtUtilStopped->utilityData.utilityCode]));
		switch(pEvtUtilStopped->reason){
		case RAID_UTIL_ABORTED:
			TRACEF_NF(TRACE_RMSTR_1, ("\t\tUTIL ABORTED BY USER\n"));
			break;
		case RAID_UTIL_ABORTED_IOERROR:
			TRACEF_NF(TRACE_RMSTR_1, ("\t\tUTIL ABORTED IOERROR\n"));
			break;
		case RAID_UTIL_COMPLETE:
			TRACEF_NF(TRACE_RMSTR_1, ("\t\tUTIL COMPLETED\n"));
			break;
		}
		PrintUtilityData(&pEvtUtilStopped->utilityData);
		switch(pEvtUtilStopped->utilityData.utilityCode){
		case RAID_UTIL_VERIFY:
			TRACEF_NF(TRACE_RMSTR_1, ("\t\tUtil Miscompare cnt=%x\n", 
				pEvtUtilStopped->miscompareCount));

			break;
		}
		break;
	

	case RMSTR_EVT_UTIL_PRIORITY_CHANGED:
		pEvtPriorityChanged = (RMSTR_PRIORITY_CHANGED_STATUS *)pStatusData;
		PrintUtilityData(&pEvtPriorityChanged->utilityData);
		TRACEF_NF(TRACE_RMSTR_1, ("\t\tUtil Old priority=%x\n", 
			pEvtPriorityChanged->oldPriority));
		TRACEF_NF(TRACE_RMSTR_1, ("\t\tUtil New priority=%x\n", 
			pEvtPriorityChanged->utilityData.priority));
		break;

	case RMSTR_EVT_UTIL_PERCENT_COMPLETE:
		pEvtPercentComplete = (RMSTR_PERCENT_COMPLETE_STATUS *)pStatusData;
		PrintUtilityData(&pEvtPercentComplete->utilityData);
		TRACEF_NF(TRACE_RMSTR_1, ("\t\tUtil Percent Complete=%x\n", 
			pEvtPercentComplete->percentComplete));
		break;

	case RMSTR_EVT_ARRAY_FAULT_TOLERANT:
		pEvtArrayFaultTolerant = (RMSTR_EVT_ARRAY_FAULT_TOLERANT_STATUS *)pStatusData;
		PrintArrayData(&pEvtArrayFaultTolerant->arrayData);
		break;

	case RMSTR_EVT_SPARE_ADDED:
		pEvtSpareAdded = (RMSTR_EVT_SPARE_ADDED_STATUS *)pStatusData;
		PrintSpareData(&pEvtSpareAdded->spareData);
#if 1
		// Down a member
		rowID		memberRowId;
		memberRowId.Table = 0xe;
		memberRowId.HiPart = 0;
		memberRowId.LoPart = 1;
		TestDownAMember(&pEvtSpareAdded->spareData.arrayRID,&memberRowId);
#endif
#if 0
		addMemberId.Table = pEvtSpareAdded->spareData.SRCTRID.Table;
		addMemberId.HiPart = 0;
		addMemberId.LoPart = 4;		// 5 is still free

		// Add a member
		TestAddMember(
			&pEvtSpareAdded->spareData.arrayRID,
			&addMemberId);
#endif

#if 0
		TestDeleteSpare(&pEvtSpareAdded->spareData.thisRID);
#endif
		break;
	
	case RMSTR_EVT_MEMBER_DOWN:
		pEvtMemberDown = (RMSTR_EVT_MEMBER_DOWN_STATUS *)pStatusData;
		PrintMemberData(&pEvtMemberDown->memberData);
#if 0
		// Add a Dedicated Spare
		dedicatedSpareId.Table = pEvtMemberDown->memberData.memberRID.Table;
		dedicatedSpareId.HiPart = 0;
		dedicatedSpareId.LoPart = 5;		// 5 is still free
		TestAddSpare(
			//RAID_HOST_POOL_SPARE,
			RAID_GENERAL_POOL_SPARE,
			//RAID_DEDICATED_SPARE,
			&dedicatedSpareId,
			NULL,
			//&pEvtMemberDown->memberData.arrayRID,	// target rid
			NULL);
#endif

		break;

	case RMSTR_EVT_MEMBER_ADDED:
		pEvtMemberAdded = (RMSTR_EVT_MEMBER_ADDED_STATUS *)pStatusData;
		PrintMemberData(&pEvtMemberAdded->memberData);
		break;

	case RMSTR_EVT_SPARE_ACTIVATED:
		pEvtSpareActivated = (RMSTR_EVT_SPARE_ACTIVATED_STATUS *)pStatusData;
		PrintSpareData(&pEvtSpareActivated->spareData);
#if 0
		memset(&utilPolicy,0,sizeof(RAID_UTIL_POLICIES));
		// Start a regenerate on the Array
		utilPolicy.SilentMode = 1;
		utilPolicy.RunThruErrors = 1;
		utilPolicy.SpecifyMembersToRunOn = 0;
		TestStartUtility(
			&pEvtSpareActivated->spareData.arrayRID,	// target rid
			RAID_UTIL_REGENERATE,
			PRIORITY_HIGH,
			utilPolicy,
			15);				// %complete update rate
#endif
#if 0
		// Add a Dedicated Spare
		dedicatedSpareId.Table = pEvtSpareActivated->spareData.SRCTRID.Table;
		dedicatedSpareId.HiPart = 0;
		dedicatedSpareId.LoPart = 5;		// 5 is still free
		TestAddSpare(
			//RAID_HOST_POOL_SPARE,
			//RAID_GENERAL_POOL_SPARE,
			RAID_DEDICATED_SPARE,
			&dedicatedSpareId,
			//NULL,
			&pEvtSpareActivated->spareData.arrayRID,	// target rid
			NULL);
#endif
		break;

	case RMSTR_EVT_SPARE_DELETED:	
		pEvtSpareDeleted = (RMSTR_EVT_SPARE_DELETED_STATUS *)pStatusData;
		PrintSpareData(&pEvtSpareDeleted->spareData);
#if 0
		TestDeleteArray(&pEvtSpareDeleted->spareData.arrayRID);
#endif
#if 0
		TestDeleteSpare(&pEvtSpareDeleted->spareData.thisRID);
#endif
		break;

	case RMSTR_EVT_ARRAY_CRITICAL:
		pEvtArrayCriticalStatus = (RMSTR_EVT_ARRAY_CRITICAL_STATUS *)pStatusData;
		PrintArrayData(&pEvtArrayCriticalStatus->arrayData);
		break;

	case RMSTR_EVT_ARRAY_OFFLINE:
		pEvtArrayOfflineStatus = (RMSTR_EVT_ARRAY_OFFLINE_STATUS *)pStatusData;
		PrintArrayData(&pEvtArrayOfflineStatus->arrayData);
		break;
	}
}
예제 #3
0
globle intBool EnvSaveFacts(
  void *theEnv,
  char *fileName,
  int saveCode,
  struct expr *theList)
  {
   int tempValue1, tempValue2, tempValue3;
   struct fact *theFact;
   FILE *filePtr;
   struct defmodule *theModule;
   DATA_OBJECT_PTR theDOArray;
   int count, i, printFact, error;

   /*======================================================*/
   /* Open the file. Use either "fast save" or I/O Router. */
   /*======================================================*/

   if ((filePtr = GenOpen(theEnv,fileName,(char*)"w")) == NULL)
     {
      OpenErrorMessage(theEnv,(char*)"save-facts",fileName);
      return(FALSE);
     }

   SetFastSave(theEnv,filePtr);

   /*===========================================*/
   /* Set the print flags so that addresses and */
   /* strings are printed properly to the file. */
   /*===========================================*/

   tempValue1 = PrintUtilityData(theEnv)->PreserveEscapedCharacters;
   PrintUtilityData(theEnv)->PreserveEscapedCharacters = TRUE;
   tempValue2 = PrintUtilityData(theEnv)->AddressesToStrings;
   PrintUtilityData(theEnv)->AddressesToStrings = TRUE;
   tempValue3 = PrintUtilityData(theEnv)->InstanceAddressesToNames;
   PrintUtilityData(theEnv)->InstanceAddressesToNames = TRUE;

   /*===================================================*/
   /* Determine the list of specific facts to be saved. */
   /*===================================================*/

   theDOArray = GetSaveFactsDeftemplateNames(theEnv,theList,saveCode,&count,&error);

   if (error)
     {
      PrintUtilityData(theEnv)->PreserveEscapedCharacters = tempValue1;
      PrintUtilityData(theEnv)->AddressesToStrings = tempValue2;
      PrintUtilityData(theEnv)->InstanceAddressesToNames = tempValue3;
      GenClose(theEnv,filePtr);
      SetFastSave(theEnv,NULL);
      return(FALSE);
     }

   /*=================*/
   /* Save the facts. */
   /*=================*/

   theModule = ((struct defmodule *) EnvGetCurrentModule(theEnv));

   for (theFact = (struct fact *) GetNextFactInScope(theEnv,NULL);
        theFact != NULL;
        theFact = (struct fact *) GetNextFactInScope(theEnv,theFact))
     {
      /*===========================================================*/
      /* If we're doing a local save and the facts's corresponding */
      /* deftemplate isn't in the current module, then don't save  */
      /* the fact.                                                 */
      /*===========================================================*/

      if ((saveCode == LOCAL_SAVE) &&
          (theFact->whichDeftemplate->header.whichModule->theModule != theModule))
        { printFact = FALSE; }

      /*=====================================================*/
      /* Otherwise, if the list of facts to be printed isn't */
      /* restricted, then set the print flag to TRUE.        */
      /*=====================================================*/

      else if (theList == NULL)
        { printFact = TRUE; }

      /*=======================================================*/
      /* Otherwise see if the fact's corresponding deftemplate */
      /* is in the list of deftemplates whose facts are to be  */
      /* saved. If it's in the list, then set the print flag   */
      /* to TRUE, otherwise set it to FALSE.                   */
      /*=======================================================*/

      else
        {
         printFact = FALSE;
         for (i = 0; i < count; i++)
           {
            if (theDOArray[i].value == (void *) theFact->whichDeftemplate)
              {
               printFact = TRUE;
               break;
              }
           }
        }

      /*===================================*/
      /* If the print flag is set to TRUE, */
      /* then save the fact to the file.   */
      /*===================================*/

      if (printFact)
        {
         PrintFact(theEnv,(char *) filePtr,theFact,FALSE,FALSE);
         EnvPrintRouter(theEnv,(char *) filePtr,(char*)"\n");
        }
     }

   /*==========================*/
   /* Restore the print flags. */
   /*==========================*/

   PrintUtilityData(theEnv)->PreserveEscapedCharacters = tempValue1;
   PrintUtilityData(theEnv)->AddressesToStrings = tempValue2;
   PrintUtilityData(theEnv)->InstanceAddressesToNames = tempValue3;

   /*=================*/
   /* Close the file. */
   /*=================*/

   GenClose(theEnv,filePtr);
   SetFastSave(theEnv,NULL);

   /*==================================*/
   /* Free the deftemplate name array. */
   /*==================================*/

   if (theList != NULL) rm3(theEnv,theDOArray,(long) sizeof(DATA_OBJECT) * count);

   /*===================================*/
   /* Return TRUE to indicate no errors */
   /* occurred while saving the facts.  */
   /*===================================*/

   return(TRUE);
  }
예제 #4
0
파일: prntutil.c 프로젝트: DrItanium/maya
void PrintAtom(
  Environment *theEnv,
  const char *logicalName,
  unsigned short type,
  void *value)
  {
   CLIPSExternalAddress *theAddress;
   char buffer[20];

   switch (type)
     {
      case FLOAT_TYPE:
        WriteFloat(theEnv,logicalName,((CLIPSFloat *) value)->contents);
        break;
      case INTEGER_TYPE:
        WriteInteger(theEnv,logicalName,((CLIPSInteger *) value)->contents);
        break;
      case SYMBOL_TYPE:
        WriteString(theEnv,logicalName,((CLIPSLexeme *) value)->contents);
        break;
      case STRING_TYPE:
        if (PrintUtilityData(theEnv)->PreserveEscapedCharacters)
          { WriteString(theEnv,logicalName,StringPrintForm(theEnv,((CLIPSLexeme *) value)->contents)); }
        else
          {
           WriteString(theEnv,logicalName,"\"");
           WriteString(theEnv,logicalName,((CLIPSLexeme *) value)->contents);
           WriteString(theEnv,logicalName,"\"");
          }
        break;

      case EXTERNAL_ADDRESS_TYPE:
        theAddress = (CLIPSExternalAddress *) value;

        if (PrintUtilityData(theEnv)->AddressesToStrings) WriteString(theEnv,logicalName,"\"");

        if ((EvaluationData(theEnv)->ExternalAddressTypes[theAddress->type] != NULL) &&
            (EvaluationData(theEnv)->ExternalAddressTypes[theAddress->type]->longPrintFunction != NULL))
          { (*EvaluationData(theEnv)->ExternalAddressTypes[theAddress->type]->longPrintFunction)(theEnv,logicalName,value); }
        else
          {
           WriteString(theEnv,logicalName,"<Pointer-");

           gensprintf(buffer,"%d-",theAddress->type);
           WriteString(theEnv,logicalName,buffer);

           gensprintf(buffer,"%p",((CLIPSExternalAddress *) value)->contents);
           WriteString(theEnv,logicalName,buffer);
           WriteString(theEnv,logicalName,">");
          }

        if (PrintUtilityData(theEnv)->AddressesToStrings) WriteString(theEnv,logicalName,"\"");
        break;

#if OBJECT_SYSTEM
      case INSTANCE_NAME_TYPE:
        WriteString(theEnv,logicalName,"[");
        WriteString(theEnv,logicalName,((CLIPSLexeme *) value)->contents);
        WriteString(theEnv,logicalName,"]");
        break;
#endif

      case VOID_TYPE:
        break;

      default:
        if (EvaluationData(theEnv)->PrimitivesArray[type] == NULL) break;
        if (EvaluationData(theEnv)->PrimitivesArray[type]->longPrintFunction == NULL)
          {
           WriteString(theEnv,logicalName,"<unknown atom type>");
           break;
          }
        (*EvaluationData(theEnv)->PrimitivesArray[type]->longPrintFunction)(theEnv,logicalName,value);
        break;
     }
  }