Exemple #1
0
static bool loadObjectTree(LoaderState& State, const XMLObject& xmlObject, XMLObjectVector &ret)
{
	XMLActor actor;

	auto found = TryForEachPath(State.Paths, xmlObject.SceneXMLFile, [&](auto& Path) {
		return XMLParser::parseScene(Path.c_str(), actor, ret);
	});
	if (!found)
	{
		MLog("loadObjectTree -- Failed to load xmlObject %s\n", xmlObject.Name.c_str());
		return false;
	}

	if (!actor.isValid)
		return false;

	if (!load(State, actor.eluName.c_str()))
	{
		MLog("loadObjectTree(%s) -- Failed to load object\n", xmlObject.Name.c_str());
		return false;
	}

	auto& Obj = State.Objects.back();
	Obj.World = MakeSaneWorldMatrix(xmlObject.Position, xmlObject.Dir, xmlObject.Up);

	return true;
}
bool LightmapGenerator::Generate()
{	
	Init();

	for (size_t i = 0; i < bsp.ConvexPolygons.size(); i++)
	{
		// The progress function returning false
		// indicates that the generation needs to stop.
		if (pProgressFn && !pProgressFn((float)i / (float)bsp.ConvexPolygons.size()))
			return false;

		int lightmapsize{};
		if (!ProcessConvexPolygon(&bsp.ConvexPolygons[i], i, lightmapsize))
		{
			MLog("LightmapGenerator::Generate -- ProcessConvexPolygon failed for polygon index %d\n", i);
			return false;
		}
		InsertLightmap(lightmapsize, i);
	}

	if (!SaveToFile())
	{
		MLog("LightmapGenerator::Generate -- SaveToFile failed\n");
		return false;
	}

	return true;
}
Exemple #3
0
int MUGIDFromName(

  char *GName)

  {
  struct group *buf;
  int tmpGID = 0;

  const char *FName = "MUGIDFromName";

  MDB(7,fSTRUCT) MLog("%s(%s)\n",
    FName,
    (GName != NULL) ? GName : "NULL");

  if ((GName == NULL) || !strcmp(GName,NONE))
    {
    return(-1);
    }

  errno = 0;

  buf = getgrnam(GName);

  if (buf == NULL)
    {
    MDB(3,fSTRUCT) MLog("ALERT:    error looking up group '%s' - %s (errno:%d)\n",
      GName,
      strerror(errno),
      errno);
    
    /* look for GID??? format */

    if (!strncmp(GName,"GID",strlen("GID")))
      {
      return(atoi(GName + strlen("GID")));
      }

    /* check to see if GName is the GID number itself (group names cannot start
     * with a number) */

    tmpGID = (int)strtol(GName,NULL,10);

    if (tmpGID != 0)
      {
      return(tmpGID);
      }

    return(-1);
    }

  return(buf->gr_gid);
  }    /* END MUGIDFromName() */
Exemple #4
0
NFAPI SCCString gh_getZipPackURL(SCCString url)
{
    // https://github.com/qokelate/CCGame
    // https://github.com/qokelate/CCGame.git
    // https://codeload.github.com/liftoff/GateOne/zip/master

    if (false == stringHasSubString(url, ".github.com/")
            && false == stringHasSubString(url, "://github.com/")) return nullptr;

    if (stringHasSuffix(url, "/zip/master"))
    {
        auto ptr = copyAsSCString(url);

        MLog("url: ", ptr);

        return ptr;
    }

    auto len = SCStringLen(url);

    auto ptr = (SCString)SCAlloc(len + 100);
    strcpy(ptr, "https://codeload.github.com");

    regexMatchFirst((void *)url, len, "://[^/]+/", nullptr, [&](SCRegexErrorInfo *errorInfo, size_t index, byte *buffer, size_t dataSize, void *param) {
        if (errorInfo)
        {
            MLog("error: ", errorInfo->errorMessage);
            return false;
        }

        auto pp = (SCCString)buffer + dataSize - 1;
        strcat(ptr, pp);

        return true;
    });

    len = SCStringLen(ptr);
    {
        auto pp = ptr + len - 4;
        if (stringCompare(pp, ".git")) *pp = 0;
    }

    strcat(ptr, "/zip/master");

    MLog("url: ", ptr);

    return ptr;
}
Exemple #5
0
int MCacheReadRsvs(

  marray_t *RArray,
  marray_t *ConstraintList)

  {
  mhashiter_t HTIter;
  char *Name;
  mtransrsv_t *R;

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

  MUHTIterInit(&HTIter);

  pthread_rwlock_rdlock(&MCache->RsvLock);

  while (MUHTIterate(&MCache->Rsvs,&Name,(void **)&R,NULL,&HTIter) == SUCCESS)
    {
    if (MRsvTransitionMatchesConstraints(R,ConstraintList))
      {
      MUArrayListAppendPtr(RArray,R);
      }
    else
      {
      MDB(8,fSCHED) MLog("INFO:     Reservation %s does not meet constraints.\n",R->Name);
      }
    } /* END while (MUHTIterate) */

  pthread_rwlock_unlock(&MCache->RsvLock);

  return(SUCCESS);
  }  /* END MCacheReadRsvs() */
Exemple #6
0
int MCacheReadJobs(

  marray_t *JArray,
  marray_t *ConstraintList)

  {
  mhashiter_t HTIter;
  char *Name;
  mtransjob_t *J;

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

  MUHTIterInit(&HTIter);

  pthread_rwlock_rdlock(&MCache->JobLock);

  while (MUHTIterate(&MCache->Jobs,&Name,(void **)&J,NULL,&HTIter) == SUCCESS)
    {
    if (MJobTransitionMatchesConstraints(J,ConstraintList))
      {
      MUArrayListAppendPtr(JArray,J);
      }
    else
      {
      MDB(8,fSCHED) MLog("INFO:     Job %s does not meet constraints.\n",J->Name);
      }
    } /* END while (MUHTIterate) */

  pthread_rwlock_unlock(&MCache->JobLock);

  return(SUCCESS);
  }  /* END MCacheReadJobs() */
Exemple #7
0
int MCacheRemoveVM(

    char *Name)

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

  if (MUStrIsEmpty(Name))
    {
    MDB(3,fSCHED) MLog("INFO:     Blank name given. Cannot remove from cache.\n");

    return(FAILURE);
    }

  pthread_rwlock_wrlock(&MCache->VMLock);

  MUHTRemove(&MCache->VMs,Name,&MVMTransitionFree);

  if (DBWRITE)
    {
    MMongoInterface::MMongoDeleteO(Name,mxoxVM);
    }


  pthread_rwlock_unlock(&MCache->VMLock);

  return(SUCCESS);
  }
Exemple #8
0
int MCacheWriteVM(

  mtransvm_t *VM) /* I */

  {
  int rc;

  const char *FName = "MCacheWriteVM";

  MDB(8,fSCHED) MLog("%s(%s)\n",
    FName,
    (VM != NULL) ? VM->VMID : NULL);

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

  pthread_rwlock_wrlock(&MCache->VMLock);

  rc = MUHTAdd(&MCache->VMs,VM->VMID,(void *)VM,NULL,&MVMTransitionFree);

  if (DBWRITE)
    {
    MMongoInterface::MTransOToMongo(VM,mxoxVM);
    }

  pthread_rwlock_unlock(&MCache->VMLock);

  return(rc);
  }  /* END MCacheWriteVM() */
Exemple #9
0
int MCacheRemoveJob(

    char *JName)

  {
  if (MUStrIsEmpty(JName))
    {
    MDB(3,fSCHED) MLog("INFO:     Blank name given. Cannot remove from cache.\n");

    return(FAILURE);
    }

  pthread_rwlock_wrlock(&MCache->JobLock);

  MUHTRemove(&MCache->Jobs,JName,&MJobTransitionFree);

  if (DBWRITE)
    {
    MMongoInterface::MMongoDeleteO(JName,mxoJob);
    }

  pthread_rwlock_unlock(&MCache->JobLock);

  return(SUCCESS);
  }
Exemple #10
0
int MCacheWriteNode(

  mtransnode_t    *N)

  {
  int rc;

  const char *FName = "MCacheWriteNode";

  MDB(7,fTRANS) MLog("%s(%s)\n",
    FName,
    (MUStrIsEmpty(N->Name)) ? "NULL" : N->Name);

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

  /* Obtain the write lock and write the object */

  pthread_rwlock_wrlock(&MCache->NodeLock);
  rc = MUHTAdd(&MCache->Nodes,N->Name,(void*)N,NULL,&MNodeTransitionFree);

  if (DBWRITE)
    {
    MMongoInterface::MTransOToMongo(N,mxoNode);
    }

  pthread_rwlock_unlock(&MCache->NodeLock);

  return(rc);
  }  /* END MCacheWriteNode() */
Exemple #11
0
int MCacheReadVMs(

  marray_t *VMArray,        /* O */
  marray_t *ConstraintList) /* I */

  {
  mhashiter_t HTIter;
  char *VMID;
  mtransvm_t *VM;

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

  MUHTIterInit(&HTIter);

  pthread_rwlock_rdlock(&MCache->VMLock);

  while (MUHTIterate(&MCache->VMs,&VMID,(void **)&VM,NULL,&HTIter) == SUCCESS)
    {
    if (MVMTransitionMatchesConstraints(VM,ConstraintList))
      {
      MUArrayListAppendPtr(VMArray,VM);
      }
    else
      {
      MDB(8,fSCHED) MLog("INFO:     VM %s does not meet constraints.\n",VM->VMID);
      }
    } /* END while (MUHTIterate) */

  pthread_rwlock_unlock(&MCache->VMLock);

  return(SUCCESS);
  }  /* END MCacheReadVMs() */
Exemple #12
0
int MSysDequeueSocket(
  
  msocket_t **S)  /* O */

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

  if (MUDLListSize(MSocketQueue) == 0)
    {
    /* queue is empty */
    
    return(FAILURE);
    }

  MUMutexLock(&MSocketQueueMutex);

  *S = (msocket_t *)MUDLListRemoveFirst(MSocketQueue);

  MSched.TransactionCount--;

  MUMutexUnlock(&MSocketQueueMutex);

  MUGetMS(NULL,(long *)&(*S)->ProcessTime);

  MDB(7,fSOCK) MLog("INFO:     socket %d being serviced after %lu milli-sec wait\n",
    (*S)->sd,
    (*S)->ProcessTime - (*S)->CreateTime);
   
  return(SUCCESS);    
  }  /* END MSysDequeueSocket() */
Exemple #13
0
int MDAGDestroy(

  marray_t *DList)  /* I (modified) */

  {
  int index;
  mdepend_t **DArray;
  mdepend_t  *tmpD;

  const char *FName = "MDAGDestroy";

  MDB(9,fALL) MLog("%s(DList)\n",
    FName);

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

  DArray = (mdepend_t **)DList->Array;

  for (index = 0;index < DList->NumItems;index++)
    {
    tmpD = DArray[index];

    MUFree(&tmpD->Value);
    MUFree(&tmpD->SValue);

    MUFree((char **)&DArray[index]);
    }

  MUArrayListFree(DList);

  return(SUCCESS);
  } /* END MDAGDestroy() */
Exemple #14
0
int MCacheReadTriggers(

  marray_t *TArray,         /* O */
  marray_t *ConstraintList) /* I */

  {
  mhashiter_t HTIter;
  char *TrigID;
  mtranstrig_t *T;

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

  MUHTIterInit(&HTIter);

  pthread_rwlock_rdlock(&MCache->TriggerLock);

  while (MUHTIterate(&MCache->Triggers,&TrigID,(void **)&T,NULL,&HTIter) == SUCCESS)
    {
    if (MTrigTransitionMatchesConstraints(T,ConstraintList))
      {
      MUArrayListAppendPtr(TArray,T);
      }
    else
      {
      MDB(8,fSCHED) MLog("INFO:     Trigger %s does not meet constraints.\n",T->TrigID);
      }
    } /* END while (MUHTIterate) */

  pthread_rwlock_unlock(&MCache->TriggerLock);

  return(SUCCESS);
  }  /* END MCacheReadTriggers() */
Exemple #15
0
int MLocalCheckFairnessPolicy(

  mjob_t *J,
  long    StartTime,
  char   *Message)

  {
  const char *FName = "MLocalCheckFairnessPolicy";

  MDB(6,fSCHED) MLog("%s(%s,%ld,Message)\n",
    FName,
    (J != NULL) ? J->Name : "NULL",
    (unsigned long)StartTime);

/*
  if (ContribJobLengthFairnessPolicy(J,StartTime,Message) == FAILURE)
    {
    return(FAILURE);
    }
*/

/*
  if (ContribASCBackgroundJobPolicy(J,StartTime,Message) == FAILURE)
    {
    return(FAILURE);
    }
*/

  /* all local policies passed */

  return(SUCCESS);
  }  /* END MLocalFairnessPolicy() */
Exemple #16
0
int MWikiSDUpdate(

  char        *AString,  /* I */
  msdata_t    *SD,       /* I (modified) */
  mrm_t       *R)        /* I */

  {
  char *ptr;
  char *tail;

  char  SDAttr[MMAX_BUFFER];

  char  EMsg[MMAX_LINE];
  char  tmpLine[MMAX_LINE];

  const char *FName = "MWikiSDUpdate";

  MDB(2,fWIKI) MLog("%s(AString,SD,%s)\n",
    FName,
    (R != NULL) ? R->Name : "NULL");

  if ((SD == NULL) || (AString == NULL))
    {
    return(FAILURE);
    }

  ptr = AString;

  /* FORMAT:  <FIELD>=<VALUE> [<FIELD>=<VALUE>]... */

  while (ptr[0] != '\0')
    {
    if ((tail = MUStrChr(ptr,' ')) != NULL)
      {
      strncpy(SDAttr,ptr,MIN(MMAX_BUFFER - 1,tail - ptr));
      SDAttr[tail - ptr] = '\0';
      }
    else
      {
      MUStrCpy(SDAttr,ptr,MMAX_BUFFER);
      }

    if (MWikiSDUpdateAttr(SDAttr,SD,R,EMsg) == FAILURE)
      {
      snprintf(tmpLine,sizeof(tmpLine),"info corrupt for staging-data '%s -> %s' - %s",
        SD->SrcLocation,
        SD->DstLocation,
        EMsg);

      MMBAdd(&R->MB,tmpLine,NULL,mmbtNONE,0,0,NULL);
      }

    if (tail == NULL)
      break;

    ptr = tail + 1;
    }  /* END while ((tail = MUStrChr(ptr,';')) != NULL) */

  return(SUCCESS);
  }  /* END MWikiSDUpdate() */
Exemple #17
0
int MDAGCopy(

  marray_t *DList,
  marray_t *SList)

  {
  mdepend_t *tmpS;

  const char *FName = "MDAGCopy";

  MDB(5,fALL) MLog("%s(DList,SList)\n",
    FName);

  if ((SList == NULL) || (DList == NULL))
    {
    return(FAILURE);
    }

 if (DList->Array != NULL)
    {
    MUArrayListFree(DList);
    }

  if (SList->Array == NULL)
    {
    /* nothing to copy */

    return(SUCCESS);
    }

  MUArrayListCreate(DList,SList->ElementSize,SList->NumItems);

  tmpS = ((mdepend_t **)SList->Array)[0];

  if (tmpS == NULL)
    {
    /* nothing to copy */

    return(SUCCESS);
    }

  while (tmpS != NULL)
    {
    MDAGSetAnd(DList,tmpS->Type,tmpS->Value,tmpS->SValue,&tmpS->BM);

    tmpS = tmpS->NextAnd;
    }

  tmpS = ((mdepend_t **)SList->Array)[0]->NextOr;

  while (tmpS != NULL)
    {
    MDAGSetOr(DList,tmpS->Type,tmpS->Value,NULL);

    tmpS = tmpS->NextOr;
    }

  return(SUCCESS);
  }  /* END MDAGCopy */
Exemple #18
0
int MDAGCreate(

  marray_t   *DList,  /* I */
  mdepend_t **DP)     /* O (modified) */

  {
  mdepend_t *NewD = NULL;

  const char *FName = "MDAGCreate";

  MDB(5,fALL) MLog("%s(DList,DP)\n",
    FName);

  if (DP != NULL)
    {
    *DP = NULL;
    }

  if ((DList == NULL) || (DP == NULL))
    {
    return(FAILURE);
    }

  NewD = (mdepend_t *)MUCalloc(1,sizeof(mdepend_t));

  if (NewD == NULL)
    {
    MDB(1,fALL) MLog("ALERT:    could not allocate new dependency\n");

    return(FAILURE);
    }

  NewD->Satisfied = MBNOTSET;

  if (MUArrayListAppendPtr(DList,NewD) == FAILURE)
    {
    return(FAILURE);
    }

  *DP = NewD;

  NewD->Index = DList->NumItems-1;

  return(SUCCESS);
  }  /* END MDAGCreate() */
Exemple #19
0
bool loadMaterial(LoaderState& State, const char* name)
{
	XMLMaterialVector xMats;

	auto found = TryForEachPath(State.Paths, name, [&](auto& path) {
		return XMLParser::parseXMLMaterial(path.c_str(), xMats);	
	});
	if (!found)
	{
		DMLog("loadMaterial on %s failed\n", name);
		return false;
	}

	XMLMaterialVector::iterator itor;
	State.Materials.reserve(xMats.size());

	for (auto& mat : xMats)
	{
		EluMaterial mtl;
		mtl.cAmbient = { EXPAND_VECTOR(mat.ambient), 1 };
		mtl.cDiffuse = { EXPAND_VECTOR(mat.diffuse), 1 };
		mtl.cSpecular = { EXPAND_VECTOR(mat.specular), 1 };
		mtl.cEmissive = { 0, 0, 0, 0 };
		mtl.shininess = mat.SpecularLevel;
		mtl.roughness = 0.f;
		mtl.AlphaTestValue = mat.AlphaTestValue;
		mtl.TwoSided = mat.TwoSided;

		auto LoadTexture = [&](auto Flag, auto& Texture, auto& Filename) {
			if (Filename.empty())
				return false;

			auto fn = [&](auto& Path) {
				if (!FileExists(Path.c_str()))
					return false;
				Texture = Path;
				return true;
			};
			if (!TryForEachPath(State.Paths, Filename, fn))
				if (!TryForEachPath(State.Paths, Filename + ".dds", fn))
				{
					MLog("loadMaterial -- Failed to load texture %s!\n", Filename.c_str());
					return false;
				}
			return true;
		};

		LoadTexture(FLAG_DIFFUSE, mtl.tDiffuse, mat.DiffuseMap);
		LoadTexture(FLAG_NORMAL, mtl.tNormal, mat.NormalMap);
		LoadTexture(FLAG_SPECULAR, mtl.tSpecular, mat.SpecularMap);
		LoadTexture(FLAG_OPACITY, mtl.tOpacity, mat.OpacityMap);
		LoadTexture(FLAG_SELFILLUM, mtl.tEmissive, mat.SelfIlluminationMap);

		State.Materials.push_back(mtl);
	}
	return true;
}
Exemple #20
0
bool loadTree(LoaderState& State, const char * sceneName, std::vector<RLIGHT>& Lights)
{
	DMLog("loadTree %s\n", sceneName);

	XMLActor actor;
	XMLObjectVector ret;
	XMLLightVector lights;

	auto found = TryForEachPath(State.Paths, sceneName, [&](auto& Path) {
		return XMLParser::parseScene(Path.c_str(), actor, ret, &lights);
	});
	if (!found)
	{
		MLog("loadTree -- Failed to load %s\n", sceneName);
		return false;
	}
	else
		DMLog("loadTree -- loaded %s\n", sceneName);

	for (auto& srcLight : lights)
	{
		Lights.emplace_back();
		auto& dstLight = Lights.back();
		dstLight.Position = srcLight.Position;
		dstLight.Color = srcLight.Diffuse;
		dstLight.fAttnStart = srcLight.AttStart;
		dstLight.fAttnEnd = srcLight.AttEnd;
		dstLight.fIntensity = srcLight.Intensity;
		dstLight.Name = srcLight.Name;
	}

	DMLog("loadTree -- actor.isValid = %d\n", actor.isValid);
	if (actor.isValid)
	{
		if (!load(State, actor.eluName.c_str()))
		{
			MLog("loadTree(%s) -- Failed to load actor thing\n", sceneName);
		}
	}

	ReadTree(State, ret);

	return true;
}
Exemple #21
0
int MMBCopyAll(

  mmb_t **DstHead,  /* O (modified/alloc) */
  mmb_t  *SrcHead)  /* I */

  {
  mmb_t *mptr;

  mmb_t *MB;

  const char *FName = "MMBCopyAll";

  MDB(7,fSTRUCT) MLog("%s(DstHead,SrcHead)\n",
    FName);

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

  if (SrcHead == NULL)
    {
    return(SUCCESS);
    }

  for (mptr = SrcHead;mptr != NULL;mptr = mptr->Next)
    {
    if (MMBAdd(
          DstHead,
          mptr->Data,
          mptr->Owner,
          mptr->Type,
          mptr->ExpireTime,
          mptr->Priority,
          &MB) == FAILURE)
      {
      continue;
      }

    MB->Count     = mptr->Count;
    MB->IsPrivate = mptr->IsPrivate;
    MB->CTime     = mptr->CTime;

    if (mptr->Label != NULL)
      MUStrDup(&MB->Label,mptr->Label);

    if (mptr->Source != NULL)
      MUStrDup(&MB->Source,mptr->Source); 
    }  /* END for (mptr) */

  return(SUCCESS);
  }  /* END MMBCopyAll() */
Exemple #22
0
int main(int argc, char** argv)
try
{
	char LogFileName[MFile::MaxPath];
	GetLogFilename(LogFileName, "MatchLog", "txt");
	InitLog(MLOGSTYLE_DEBUGSTRING | MLOGSTYLE_FILE, LogFileName);
	void MatchServerCustomLog(const char*);
	CustomLog = MatchServerCustomLog;

	MCrashDump::SetCallback([](uintptr_t ExceptionInfo) {
		char Filename[MFile::MaxPath];
		GetLogFilename(Filename, "MatchServer", "dmp");
		MCrashDump::WriteDump(ExceptionInfo, Filename);
	});

	MBMatchServer MatchServer;

	if (!MatchServer.Create(6000))
	{
		MLog("MMatchServer::Create failed\n");
		return -1;
	}

	MatchServer.InitLocator();

	std::thread{ [&] { InputThreadProc(); } }.detach();

	while (true)
	{
		MatchServer.Run();
		HandleInput(MatchServer);
		std::this_thread::sleep_for(std::chrono::milliseconds(1));
	}
}
catch (std::runtime_error& e)
{
	MLog("Uncaught std::runtime_error: %s\n", e.what());
	throw;
}
Exemple #23
0
int MDAGSetAnd(

  marray_t          *DP,       /* I */
  enum MDependEnum   DType,    /* I */
  char              *Value,    /* I (optional) */
  char              *SValue,   /* I (optional) */
  mbitmap_t         *FlagBM)   /* I */

  {
  mdepend_t *tmpD;
  mdepend_t *NewD;

  const char *FName = "MDAGSetAnd";

  MDB(5,fALL) MLog("%s(DP,%s,%s,%s)\n",
    FName,
    MDependType[DType],
    (Value != NULL) ? Value : "NULL",
    (SValue != NULL) ? SValue : "NULL");

  if ((DP == NULL) ||
      (DP->Array == NULL))
    return(FAILURE);

  tmpD = ((mdepend_t **)DP->Array)[0];

  if (MDAGCreate(DP,&NewD) == FAILURE)
    {
    return(FAILURE);
    }

  if (tmpD != NULL)
    {
    while (tmpD->NextAnd != NULL)
      {
      tmpD = tmpD->NextAnd;
      }

    tmpD->NextAnd = NewD;
    }

  NewD->Type = DType;

  MUStrDup(&NewD->SValue,SValue);
  MUStrDup(&NewD->Value,Value);

  bmcopy(&NewD->BM,FlagBM);

  return(SUCCESS);
  }  /* END MDAGSetAnd() */
Exemple #24
0
int MCacheWriteRsv(

  mtransrsv_t   *R)

  {
  int rc;

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

  pthread_rwlock_wrlock(&MCache->RsvLock);

  if (bmisset(&R->TFlags,mtransfDeleteExisting))
    {
    MLog("INFO:      removing rsv %s from cache\n",R->Name);

    rc = MUHTRemove(&MCache->Rsvs,R->Name,MRsvTransitionFree);

    if (DBWRITE)
      {
      MMongoInterface::MMongoDeleteO(R->Name,mxoRsv);
      }

    MRsvTransitionFree((void **)&R);

    R = NULL;
    }
  else
    {
    rc = MUHTAdd(&MCache->Rsvs,R->Name,(void*)R,NULL,&MRsvTransitionFree);

    if (DBWRITE)
      {
      MMongoInterface::MTransOToMongo((mtransrsv_t *)R,mxoRsv);
      }
    }

  if (DBWRITE)
    {
    MMongoInterface::MTransOToMongo((mtransrsv_t *)R,mxoRsv);
    }

  pthread_rwlock_unlock(&MCache->RsvLock);

  return (rc);
  }  /* END MCacheWriteRsv() */
Exemple #25
0
int MUMutexUnlock(

  mmutex_t *Mutex)  /* I */

  {
#ifdef MTHREADSAFE
  if (pthread_mutex_unlock(Mutex) != 0)
    {
    MDB(0,fCORE) MLog("ALERT:  cannot unlock mutex!\n");

    return(FAILURE);
    }
#endif /* MTHREADSAFE */

  return(SUCCESS);
  }  /* END MUMutexUnlock() */
Exemple #26
0
int MDAGSetOr(

  marray_t          *DList,
  enum MDependEnum   DType,
  char              *Value,
  char              *SValue)

  {
  mdepend_t *tmpD;
  mdepend_t *NewD;

  const char *FName = "MDAGSetOr";

  MDB(5,fALL) MLog("%s(DList,%s,%s,%s)\n",
    FName,
    MDependType[DType],
    (Value != NULL) ? Value : "NULL",
    (SValue != NULL) ? SValue : "NULL");

  if ((DList == NULL) ||
      (DList->Array == NULL))
    return(FAILURE);

  tmpD = (mdepend_t *)MUArrayListGetPtr(DList,0);

  if (MDAGCreate(DList,&NewD) == FAILURE)
    {
    return(FAILURE);
    }

  if (tmpD != NULL)
    {
    while (tmpD->NextOr != NULL)
      {
      tmpD = tmpD->NextOr;
      }

    tmpD->NextOr = NewD;
    }

  NewD->Type = DType;

  MUStrDup(&NewD->SValue,SValue);
  MUStrDup(&NewD->Value,Value);

  return(SUCCESS);
  }  /* END MDAGSetOr() */
Exemple #27
0
int MRsvAdjustTime(

  long Delta)  /* I (time change in seconds) */

  {
  rsv_iter RTI;

  int nindex;

  mnode_t *N;
  mrsv_t  *R;
  mre_t   *RE;

  const char *FName = "MRsvAdjustTime";

  MDB(4,fSTRUCT) MLog("%s(%ld)\n",
    FName,
    Delta);

  MRsvIterInit(&RTI);

  while (MRsvTableIterate(&RTI,&R) == SUCCESS)
    {
    R->StartTime = MIN(R->StartTime + Delta,MMAX_TIME);
    R->EndTime   = MIN(R->EndTime + Delta,MMAX_TIME);
    }

  for (nindex = 0;nindex < MSched.M[mxoNode];nindex++)
    {
    N = MNode[nindex];

    if ((N == NULL) || (N->Name[0] == '\0'))
      break;

    if (N->Name[0] == '\1')
      continue;

    for (RE = N->RE;RE != NULL;MREGetNext(RE,&RE))
      {
      RE->Time = MIN(RE->Time + Delta,MMAX_TIME);
      }  /* END for (MREGetNext) */
    }    /* END for (nindex) */

  return(SUCCESS);
  }  /* END MRsvAdjustTime() */
Exemple #28
0
int MUMutexLock(

  mmutex_t *Mutex)  /* I */

  {
#ifdef MTHREADSAFE
  if (pthread_mutex_lock(Mutex) != 0)
    {
    /* NOTE:  this can result in infinite recursion as MLog() calls MUMutexLock() */

    MDB(0,fCORE) MLog("ALERT:  cannot lock mutex!\n");

    return(FAILURE);
    }
#endif /* MTHREADSAFE */

  return(SUCCESS);
  }  /* END MULockMutex() */
Exemple #29
0
bool loadPropTree(LoaderState& State, const char * propName)
{
	DMLog("loadPropTree %s\n", propName);

	XMLObjectVector ret;

	auto found = TryForEachPath(State.Paths, propName, [&](auto& Path) {
		return XMLParser::parseProp(Path.c_str(), ret);
	});
	if (!found)
	{
		MLog("loadPropTree -- Failed to load %s\n", propName);
		return false;
	}

	ReadTree(State, ret);

	return true;
}
Exemple #30
0
int MMBRemoveMessage(

  mmb_t            **Head,
  const char        *Msg,
  enum MMBTypeEnum   MType)

  {
  int Index;

  const char *FName = "MMBRemoveMessage";

  MDB(7,fSTRUCT) MLog("%s(Head,%.32s...,%s)\n",
    FName,
    (Msg != NULL) ? Msg : "",
    (MType <= mmbtLAST) ? MMBType[MType] : "???");

  if ((Head == NULL) || ((Msg == NULL) && (MType == mmbtNONE)))
    {
    return(SUCCESS);
    }

  if (Msg != NULL)
    {
    /* locate messages which match string */

    if (MMBGetIndex(*Head,NULL,Msg,mmbtNONE,&Index,NULL) == SUCCESS)
      {
      /* remove specified message */

      MMBRemove(Index,Head);
      }
    }
  else
    {
    /* locate messages which match type */

    while (MMBGetIndex(*Head,NULL,NULL,MType,&Index,NULL) == SUCCESS)
      MMBRemove(Index,Head);
    }

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