Exemple #1
0
CString
XMLRestriction::CheckNames(CString p_value)
{
  CString result;

  if(p_value.Find("  ") >= 0)
  {
    return "ENTITIES/IDREFS contains seperators larger than a space: " + p_value;
  }

  p_value.Trim();
  int pos = p_value.Find(' ');

  while(pos > 0)
  {
    CString token = p_value.Left(pos);
    p_value = p_value.Mid(pos + 1);

    result = CheckName(token);
    if(!result.IsEmpty())
    {
      result = "ENTITIES/IDREFS: " + result;
      return result;
    }
    // Next token
    pos = p_value.Find(' ');
  }
  return CheckName(p_value);
}
Exemple #2
0
static boolean StoreAllocation(
    void* ptr, 
    int   size,
    MemCheck_MemStore  memStore,
    char* filename, 
    int   lineno
    )
{
   MemoryData mPtr, *prev;

   /* This debugassert will trip on the given allocation numbered
    * distAllocNdx as * reported in the memory leak report. This is much
    * faster than a conditional * breakpoint. <Gus 9/25/97> */
   if (distAllocNdxStopper != 0 && distAllocNdxStopper <= distAllocNdx) {
   		AllocationBreakStop(distAllocNdx);
		distAllocNdxStopper = 0;
   }
   DebugAssert(distAllocNdxStopper == 0 || distAllocNdxStopper != distAllocNdx);
   prev = &memoryData;
   for( mPtr=memoryData; mPtr; mPtr=mPtr->next ) {
      if( mPtr->numInUse < NUM_MEM_BLK ) {
         int i,j,k;
         void  **addr;
         pCard32 mask = mPtr->inUseMask;
         for( i=0; i<NUM_MEM_MASK; ++i,++mask )
            if( *mask != 0xFFFFFFFF ) break;
         addr = &mPtr->address[i<<5];
         for( j=0; j<32; ++j,++addr )
            if( *addr == NULL ) break;
         k = (i<<5) + j;
         *mask |= ((Card32)1 << j);
         mPtr->keepMask[i] |= ((Card32)1 << j);
         ++mPtr->numInUse;
         *addr = ptr;
         mPtr->allocNdx[k] = distAllocNdx;
         mPtr->fileName[k] = CheckName( filename );
         mPtr->lineNo[k] = lineno;
         mPtr->size[k] = size;
         mPtr->memStore[k] = memStore;
         return 1;
      }
      prev = &mPtr->next;
   }
   *prev = mPtr = (MemoryData)OSProvided_Calloc( sizeof(MemoryDataRec), 1 );
   if( !mPtr ) return 0;
   mPtr->address[0]   = ptr;
   mPtr->allocNdx[0]  = distAllocNdx;
   mPtr->inUseMask[0] = 1;
   mPtr->keepMask[0]  = 1;
   mPtr->fileName[0]  = CheckName( filename );
   mPtr->lineNo[0]    = lineno;
   mPtr->size[0]      = size;
   mPtr->memStore[0] = memStore;
   mPtr->numInUse = 1;
   mPtr->next = NULL;
   return 1;
}
bool CREvent::OnCreateRoleBtn(const CEGUI::EventArgs &e)
{
	if (GetInst(SelectRolePage).GetPlayerCount() >= 1)
	{
        GetInst(MsgEventManager).PushEvent(Msg_Ok,AppFrame::GetText("Base_34"));   //目前不能创建更多的角色了!
		return false;
	}
	CEGUI::Window *pPageWin = GetInst(CreateRolePage).GetPageWindow();
	CEGUI::Editbox* pNameEdit = static_cast<CEGUI::Editbox*>(pPageWin->getChild("EditName"));

	const char * strName = CEGUIStringToAnsiChar(pNameEdit->getText());
	if (strcmp(strName,"") == 0)
	{
		GetInst(MsgEventManager).PushEvent(Msg_Ok,AppFrame::GetText("Player_72"));  //"名字不能为空"
		return false;
	}
	if (!CheckName(strName))
	{
		GetInst(MsgEventManager).PushEvent(Msg_Ok,AppFrame::GetText("Player_73"));  //"名字中不能有空格"
		return false; 
	}
	int  iSex  = random(2);
	//RandomChoseDetails();
	//RandomChoseCountry();
	BYTE lConstellation = random(12) + 1;
	//const char *strName,char nOccupation, char nSex, BYTE lHead, BYTE lFace, BYTE lCountry,BYTE lConstellation,BYTE bRandCountry
	GetGame()->C2L_AddRole_Send(strName, 0, (char)GetSelectSex(), GetHair(), GetFace(), GetSelectCountry(), lConstellation, 0 );
	return true;
}
/*
// AssignCreate
//
// Create a new assignment record
//
// Returns STRUCT * on success, 0 on error
*/
static ASSIGN *AssignCreate( SOURCEFILE *ps, ASSIGN **pList, char *Name )
{
    ASSIGN *pas;

    /* Make sure this name is OK to use */
    if( !CheckName(ps,Name) )
        return(0);

    /* Make sure the name is not too long */
    if( strlen(Name)>=STRUCT_NAME_LEN )
        { Report(ps,REP_ERROR,"Structure name too long"); return(0); }

    /* Allocate a new record */
    pas = malloc(sizeof(ASSIGN));
    if( !pas )
        { Report(ps,REP_ERROR,"Memory allocation failed"); return(0); }

    strcpy( pas->Name, Name );

    /* Put this equate in the master list */
    pas->pPrev  = 0;
    pas->pNext  = *pList;
    *pList = pas;

    if( Pass==1 && (Options & OPTION_DEBUG) )
        printf("%s(%5d) : DOTCMD : Assignment '%s' declared\n",
                            ps->SourceName,ps->CurrentLine,pas->Name);

    return(pas);
}
/*
// StructCreate
//
// Create a new structure record
//
// Returns STRUCT * on success, 0 on error
*/
static STRUCT *StructCreate( SOURCEFILE *ps, char *Name )
{
    STRUCT *pst;

    /* Make sure this name is OK to use */
    if( !CheckName(ps,Name) )
        return(0);

    /* Make sure its not too long */
    if( strlen(Name)>=STRUCT_NAME_LEN )
        { Report(ps,REP_ERROR,"Structure name too long"); return(0); }

    /* Allocate a new record */
    pst = malloc(sizeof(STRUCT));
    if( !pst )
        { Report(ps,REP_ERROR,"Memory allocation failed"); return(0); }

    strcpy( pst->Name, Name );
    pst->Elements  = 0;
    pst->TotalSize = 0;

    /* Put this equate in the master list */
    pst->pPrev  = 0;
    pst->pNext  = pStructList;
    pStructList = pst;

    if( Pass==1 && (Options & OPTION_DEBUG) )
        printf("%s(%5d) : DOTCMD : Structure '%s' declared\n",
                            ps->SourceName,ps->CurrentLine,pst->Name);

    return(pst);
}
Exemple #6
0
 void DiEditorManager::OpenFx(const DiString& fxFileName)
 {
     DiString base = fxFileName.ExtractFileName();
     if(!DiAssetManager::GetInstance().HasArchive(base))
     {
         DiString message;
         message.Format("Cannot find the effect file(%s) in our media folders!", base.c_str());
         MyGUI::Message::createMessageBox("Message", "Error", message.c_str(),
                                          MyGUI::MessageBoxStyle::Ok|MyGUI::MessageBoxStyle::IconError);
         
         return;
     }
     
     DiFxTokensParser parser;
     
     auto stream = DiAssetManager::GetInstance().OpenArchive(base);
     shared_ptr<DiXMLFile> xmlfile(DI_NEW DiXMLFile());
     xmlfile->Load(stream->GetAsString());
     DiXMLElement root = xmlfile->GetRoot();
     
     if (!root.CheckName("Effects"))
     {
         DI_WARNING("Bad effect file: %s", base.c_str());
         return;
     }
     
     auto child = root.GetChild();
     while (child)
     {
         if (child.CheckName("ParticleSystem"))
         {
             auto ps = parser.ReadSystem(child);
             LoadParticleSystem(ps);
         }
         else if(child.CheckName("ReferenceModel"))
         {
             LoadRefModel(child);
         }
         
         child = child.GetNext();
     }
     
     SetCurrentFileName(fxFileName);
 }
Exemple #7
0
//--------------------------------------------------------------------------------------------------
void Process::Name
(
    std::string&& name
)
//--------------------------------------------------------------------------------------------------
{
    CheckName(name);

    m_Name = std::move(name);
}
Exemple #8
0
void
AllLinuxInputDevices::Remove(const char *name)
{
  if (!CheckName(name))
    return;

  auto i = FindByName(name);
  if (i != devices.end())
    devices.erase(i);
}
Exemple #9
0
//--------------------------------------------------------------------------------------------------
void Process::Name
(
    const std::string& name
)
//--------------------------------------------------------------------------------------------------
{
    CheckName(name);

    m_Name = name;
}
/*---------------------------------------------------------------------------*/
wxString wxGridColumnsTable::GetUniqueName()
{
   wxString name;
   size_t i = m_Columns.GetCount();

   do
   {
      name = wxString::Format(("COLUMN%l"), i++);
   }
   while (!CheckName(name));
   return name;
}
Exemple #11
0
CString   
XMLRestriction::CheckNCName(CString p_value)
{
  CString result = CheckName(p_value);
  if(result.IsEmpty())
  {
    if(p_value.Find(':') >= 0)
    {
      result = "NCName cannot contain a colon: " + p_value;
    }
  }
  return result;
}
Exemple #12
0
//--------------------------------------------------------------------------------------------------
void Process_t::SetName
(
    const std::string& name
)
//--------------------------------------------------------------------------------------------------
{
    // Note: The process name will become a config tree node name, so it can't contain
    // slashes or quotes or it will mess with the config tree.
    auto procName = path::GetLastNode(path::Unquote(name));

    CheckName(procName, parseTreePtr);

    this->name = procName;
}
Exemple #13
0
void NewUser(void)
{
	FILE *file;
	char name[100];
	char code[100];

	
	
	if(users != NULL)
		free(users);
	FillUsers();
	
	do
	{
		printf("USERNAME: "******"%s", name);
	}while(CheckName(name));
	
	do
	{
		ReadCode(code);
		printf("CODE: %s\n", code);

		if(CheckCode(code))
			printf("Code is already in use!\n");
		else
		{
			printf("Done.\n");
			break;
		}
	
		
	}while(1);
	
	
	
	if((file = fopen("USERS", "a+")) == NULL)
	{
		perror("Failed to open file!\n");
		exit(1);
	}
	else
	{		
		fprintf(file, "%s\t\t%s\r\n", name, code);
		fclose(file);
		
	}
}
Exemple #14
0
int GetIpv6VifGateway(int skt, const char *ifname)
{
    char pathBuf[MAX_NICINFO_LENGTH] = {0};
    char pszGateway[VIF_NAME_LENGTH] = {0};
    char pszGatewayBuf[VIF_NAME_LENGTH] = {0};
    FILE *iRet;

    if(NULL == ifname)
    {
        return ERROR;
    }

    if(SUCC != CheckName(ifname))
    {
        return ERROR;
    }

    (void)memset_s(pathBuf, MAX_NICINFO_LENGTH, 0, MAX_NICINFO_LENGTH);
     /*exec shell command to get ipv6 route gataway info*/
    (void)snprintf_s(pathBuf, MAX_NICINFO_LENGTH, MAX_NICINFO_LENGTH,
                "route -A inet6 -n | grep -w \"%s\" | grep UG | awk '{print $2}'", ifname);
    iRet = openPipe(pathBuf, "r");
    if (NULL == iRet)
    {
       INFO_LOG("Failed to execute route shell command, pathBuf=%s.", pathBuf);
       gtNicIpv6Info.info[gtNicIpv6Info.count].gateway[0] = '\0';
       return ERROR;
    }

    /*save default gw*/
    if(NULL != fgets(pszGatewayBuf,sizeof(pszGatewayBuf),iRet))
    {
       (void)sscanf_s(pszGatewayBuf,"%s",pszGateway,sizeof(pszGateway));
    }
    trim(pszGateway);

    /*if strlen(pszGateway) < 1, then 0*/
    if(strlen(pszGateway) < 1)
    {
       pszGateway[0]='0';
       pszGateway[1]='\0';
    }
    (void)pclose(iRet);
    (void)strncpy_s(gtNicIpv6Info.info[gtNicIpv6Info.count].gateway, IPV6_ADDR_LEN, pszGateway, strlen(pszGateway));
    return SUCC;
}
Exemple #15
0
static void ReplaceAllocation (void* ptr1, 
							   void* ptr2,
							   int size, 
							   char* filename, 
							   int lineno)
{
   MemoryData mPtr, *prev;

   prev = &memoryData;
   for( mPtr=memoryData; mPtr; mPtr=mPtr->next ) {
      int i,j,k;
      void **addr;
      pCard32 mask = mPtr->inUseMask;
      pCard32 keep = mPtr->keepMask;
      DebugAssert( mPtr->numInUse > 0 );
      for( i=0; i<NUM_MEM_MASK; ++i,++mask,++keep ) {
         if( *mask == 0 ) continue;
         addr = &mPtr->address[i<<5];
         for( k=i<<5,j=0; j<32; ++j,++k,++addr ) {
            if( *addr == ptr1 ) {
               if( (*addr = ptr2) != NULL ) {
                  mPtr->fileName[k] = CheckName( filename );
                  mPtr->allocNdx[k] = distAllocNdx;
                  mPtr->lineNo[k]   = lineno;
                  mPtr->size[k]     = size;
                  return;
               }
               *mask &= ~((Card32)1 << j);
               *keep &= ~((Card32)1 << j);
               if( --mPtr->numInUse == 0 ) {
                  MemoryData next = mPtr->next;
                  OSProvided_Free( mPtr );
                  *prev = next;
               }
               return;
            }
         }
      }
      prev = &mPtr->next;
   }
   DebugAssert( 0 );
}
Exemple #16
0
/*
 * Function will allow a user to change his handle
 */
void Chg_Handle()
{
    char    *Handle, *temp;

    Handle = calloc(81, sizeof(char));
    temp   = calloc(81, sizeof(char));

    ReadExitinfo();
    Syslog('+', "Old handle \"%s\"", exitinfo.sHandle);

    while (TRUE) {
	Enter(1);
	/* Enter a handle (Enter to Quit): */
	pout(LIGHTBLUE, BLACK, (char *) Language(412));
	colour(CFG.InputColourF, CFG.InputColourB);
	GetstrC(temp, 34);

	if ((strcmp(temp, "")) == 0) {
	    free(Handle);
	    free(temp);
	    return;
	}
	strcpy(Handle, tlcap(temp));

	if (CheckHandle(Handle) || CheckUnixNames(Handle)) {
	    pout(LIGHTRED, BLACK, (char *)"\r\nThat handle is already been used\r\n");
	} else if (CheckName(Handle)) {
	    pout(LIGHTRED, BLACK, (char *)"\r\nThat name is already been used\r\n");
	} else if((strcasecmp(Handle, "sysop")) == 0) {
	    pout(LIGHTRED, BLACK, (char *)"\r\nYou cannot use Sysop as a handle\r\n");
	} else if(strcmp(temp, "") != 0) {
	    Setup(exitinfo.sHandle, temp);
	    pout(LIGHTGREEN, BLACK, (char *)"\r\nHandle Changed!\r\n\r\n");
	    Syslog('+', "New handle \"%s\"", exitinfo.sHandle);
	    break;
	}
    }

    WriteExitinfo();
    free(temp);
    free(Handle);
}
Exemple #17
0
void
AllLinuxInputDevices::Add(const char *name)
{
  if (!CheckName(name))
    return;

#ifdef HAVE_INOTIFY
  auto i = FindByName(name);
  if (i != devices.end())
    /* already have that one */
    return;
#endif

  StaticString<64> path;
  path.Format("/dev/input/%s", name);

  devices.emplace_back(name, io_loop, queue, merge);
  if (!devices.back().device.Open(path))
    devices.pop_back();
}
Exemple #18
0
void ShmSystemV::Open(const std::string &name, const Mode openMode)
{
    m_Name = name;
    CheckName();
    m_OpenMode = openMode;

    // not using const
    key_t key = ftok(m_Name.c_str(), static_cast<int>(m_ProjectID));

    switch (m_OpenMode)
    {
    case (Mode::Write):
        ProfilerStart("open");
        m_ShmID = shmget(key, m_Size, IPC_CREAT | 0666);
        ProfilerStop("open");
        break;

    case (Mode::Append):
        ProfilerStart("open");
        m_ShmID = shmget(key, m_Size, 0);
        ProfilerStop("open");
        break;

    case (Mode::Read):
        ProfilerStart("open");
        m_ShmID = shmget(key, m_Size, 0);
        ProfilerStop("open");
        break;

    default:
        throw std::invalid_argument(
            "ERROR: unknown open mode for shared memory segment " + m_Name +
            ", in call to SystemV Open");
    }

    CheckShmID("in call to ShmSystemV shmget at Open");

    m_Buffer = static_cast<char *>(shmat(m_ShmID, nullptr, 0));
    CheckBuffer("in call to SystemV shmat at Open");
    m_IsOpen = false;
}
Exemple #19
0
/*
// MacroCreate
//
// Create a new macro record
//
// Returns MACRO * on success, 0 on error
*/
static MACRO *MacroCreate(SOURCEFILE *ps, char *Name) {
  MACRO *pm;

  /* Make sure this name is OK to use */
  if (!CheckName(ps, Name))
    return (0);

  /* Make sure its not too long */
  if (strlen(Name) >= MACRO_NAME_LEN) {
    Report(ps, REP_ERROR, "Macro name too long");
    return (0);
  }

  /* Allocate a new record */
  pm = malloc(sizeof(MACRO));
  if (!pm) {
    Report(ps, REP_ERROR, "Memory allocation failed");
    return (0);
  }

  strcpy(pm->Name, Name);
  pm->InUse = 1;
  pm->Id = MacroId++;
  pm->Arguments = 0;
  pm->Required = 0;
  pm->CodeLines = 0;
  pm->Labels = 0;
  pm->Expands = 0;

  /* Put this equate in the master list */
  pm->pPrev = 0;
  pm->pNext = pMacroList;
  pMacroList = pm;

  if (Pass == 1 && (Options & OPTION_DEBUG))
    printf("%s(%5d) : DOTCMD : Macro '%s' declared\n", ps->SourceName,
           ps->CurrentLine, pm->Name);

  return (pm);
}
Exemple #20
0
/* When running this function, chair is the chair to IGNORE 
   That's because this function is running while GetStatsForChair is running,
   And we wouldn't like to interrupt its order and ability to detect name changes
   In the seat it's getting stats for*/ 
void CPokerTrackerThread::ReportSeatChanges(int chair)
{
	int i;
	bool nameChanged;
	char currentScrapeName[k_max_length_of_playername];
	write_log_pokertracker(3, "ReportSeatChanges: started\n");
	for (i = k_min_chair_number; i < k_max_chair_number; ++i)
	{
		if (i != chair)
		{
			memcpy(currentScrapeName, _player_stats[i].scraped_name, k_max_length_of_playername);
			CheckName(i, nameChanged);
			if (nameChanged)
			{
				/* Scrapped name got changed. Clear stats for that chair */
				write_log_pokertracker(2, "ReportSeatChanges: chair [%d]: new player sat down in chair! oldscrape[%s] newscrape[%s].\n", i, currentScrapeName, _player_stats[i].scraped_name);
				/* Clear stats but leave the new name intact */
				ClearSeatStats(i, false);
			}
		}
	}
}
Exemple #21
0
void RemoveUser(void)
{
	FILE *file;
	char name[100];
	int i;
	
	if(users != NULL)
		free(users);
	FillUsers();
	
	printf("USERNAME: "******"%s", name);
	
	if(!CheckName(name))
		printf("No such user!\n");
	else
	{
		if((file = fopen("USERS", "w")) == NULL)
		{
			perror("Failed to open file!\n");
			exit(1);
		}
		else
		{		
			for(i = 0; i < LINES; i++)
			{
				if(!strcmp(name, users[i].name))
					continue;
				fprintf(file, "%s\t\t%s\r\n", users[i].name, users[i].code);
			}
			
			fclose(file);
			
		}
		
	}
	
	
}
Exemple #22
0
/*
// ScopeCreate
//
// Create a new scope record
//
// Returns STRUCT * on success, 0 on error
*/
static SCOPE *ScopeCreate(SOURCEFILE *ps, char *Name) {
  SCOPE *psc;

  /* Make sure this name is OK to use */
  if (!CheckName(ps, Name))
    return (0);

  /* Make sure its not too long */
  if (strlen(Name) >= SCOPE_NAME_LEN) {
    Report(ps, REP_ERROR, "Scope name too long");
    return (0);
  }

  /* Allocate a new record */
  psc = malloc(sizeof(SCOPE));
  if (!psc) {
    Report(ps, REP_ERROR, "Memory allocation failed");
    return (0);
  }

  strcpy(psc->Name, Name);
  psc->Flags = SCOPE_FLG_OPEN;
  psc->pParent = pScopeCurrent;
  psc->pAssignList = 0;

  /* Put this equate in the master list */
  psc->pPrev = 0;
  psc->pNext = pScopeList;
  pScopeList = psc;
  pScopeCurrent = psc;

  if (Pass == 1 && (Options & OPTION_DEBUG)) {
    if (ps)
      printf("%s(%5d) : ", ps->SourceName, ps->CurrentLine);
    printf("DOTCMD : Scope '%s' declared\n", psc->Name);
  }

  return (psc);
}
Exemple #23
0
/*
// EquateCreate
//
// Creates an equate record
//
// Returns 0 on success, -1 on error
*/
int EquateCreate( SOURCEFILE *ps, char *Name, char *Value )
{
    EQUATE *pd;

    /* Make sure this name is OK to use */
    if( !CheckName(ps,Name) )
        return(-1);

    /* Make sure its not a too long */
    if( strlen(Name)>=EQUATE_NAME_LEN )
        { Report(ps,REP_ERROR,"Equate name '%s' too long",Name); return(-1); }
    if( strlen(Value)>=EQUATE_DATA_LEN )
        { Report(ps,REP_ERROR,"Equate data '%s' too long",Value); return(-1); }

    /* Allocate a new record */
    pd = malloc(sizeof(EQUATE));
    if( !pd )
        { Report(ps,REP_ERROR,"Memory allocation failed"); return(-1); }

    /* Load in the name and data */
    strcpy( pd->name, Name );
    strcpy( pd->data, Value );

    /* Put this equate in the master list */
    pd->Busy  = 0;
    pd->pPrev = 0;
    pd->pNext = pEqList;
    if( pEqList )
        pEqList->pPrev = pd;
    pEqList   = pd;

    if( Pass==1 && (Options & OPTION_DEBUG) )
        printf("%s(%5d) : DEFINE : '%s' = '%s'\n",
                            ps->SourceName,ps->CurrentLine,pd->name,pd->data);

    return(0);
}
/* -----------------------------------------------------------------------------*/
strPtr SetUpDriver (StatePtr params)
{
	strPtr msg;
	MidiName name = InetDriverName (strLANName, params->net.port, kDefaultLANPort);
	msg = CheckName (name);
	if (msg) return msg;

	short mode = params->driverMode ? TInetControler::kDriverMode : TInetControler::kApplMode;
	if (gControl) delete gControl;
	gControl = new TInetControler(&params->net, name, mode);
	if (!gControl) {
		CloseInetDriver ();
		return strMemFail;
	}
	else {
		gIdleThread = ThreadCreate (gControl);
		if (!gIdleThread) {
			CloseInetDriver ();
			return "CreateThread failed";
		}
	}
	gAutoQuit = &params->autoQuit;
	return 0;
}
/* -----------------------------------------------------------------------------*/
strPtr SetUpDriver (StatePtr params)
{
	strPtr msg;
	MidiName name = InetDriverName (strWANName, params->net.port, kDefaultWANPort);
	msg = CheckName (name);
	if (msg) return msg;

	short mode = params->driverMode ? TInetControler::kDriverMode : TInetControler::kApplMode;
	gAutoQuit = &params->autoQuit;
	if (gControl) delete gControl;	gControl = 0;
	if (gServer) delete gServer;	gServer = 0;
	gServer = new TMidiServer (params->net.port, 0);
	gFeedback = new OSXFeedback ();
	if (gServer && gFeedback) {
		gControl = new TWANControler (gServer, &params->net, name, params->maxClients, mode);
		if (gControl) {
			gControl->SetFeedback (gFeedback);
			if (!gControl->Start ()) {
				CloseInetDriver ();
				return "cannot start Internet server";
			}
			else {
				gIdleThread = ThreadCreate (gControl);
				if (!gIdleThread) {
					CloseInetDriver ();
					return "CreateThread failed";
		}
			}
		}
	}
	if (!gControl || !gServer || !gFeedback) {
		CloseInetDriver ();
		return strMemFail;
	}
	return 0;
}
/*---------------------------------------------------------------------------*/
void wxGridColumnsTable::SetValue(int row, int col, const wxString& value)
{
   if (col == 0)
   {
      if (CheckName(value, row))
         m_Columns[row]->SetName(value.Upper());
   }
   else if (col == 1)
   {
      if (value == ("INTEGER"))
      {
         long l_Long;
         wxString val;

         m_Columns[row]->SetType(cttInteger);
         val = m_Columns[row]->GetDefault();
         if ((val != wxEmptyString) && !val.ToLong(&l_Long))
            SetValue(row, 4, wxEmptyString);
      }
      else if (value == ("INTEGER AUTOINCREMENT"))
      {
         if (CheckAutoInc())
            return;
         m_Columns[row]->SetType(cttIntegerAutoinc);
         SetValueAsBool(row, 3, true);
         SetValue(row, 4, wxEmptyString);
         // Oblige la grille à prendre en compte le changement
         GetView()->SetCellValue(row, 3, ("1"));
      }
      else if (value == ("REAL"))
      {
         double l_Double;
         wxString val;

         m_Columns[row]->SetType(cttReal);
         val = m_Columns[row]->GetDefault();
         if ((val != wxEmptyString) && !val.ToDouble(&l_Double))
            SetValue(row, 4, wxEmptyString);
      }
      else if (value == ("TEXT"))
         m_Columns[row]->SetType(cttText);
      else if (value == ("BLOB"))
         m_Columns[row]->SetType(cttBlob);
   }
   else if (col == 4)
   {
      if (value != wxEmptyString)
      {
         long l_Long;
         double l_Double;

         switch (m_Columns[row]->GetType())
         {
            case cttInteger :
               if (value.ToLong(&l_Long))
                  m_Columns[row]->SetDefault(wxString::Format(("%li"), l_Long));
               break;
            case cttIntegerAutoinc : return;
            case cttReal :
               if (value.ToDouble(&l_Double))
                  m_Columns[row]->SetDefault(wxString::Format(("%f"), l_Double));
               break;
            case cttText :
            case cttBlob :
               if ((value.Upper() == ("CURRENT_TIME"))||
                  (value.Upper() == ("CURRENT_DATE"))||
                  (value.Upper() == ("CURRENT_TIMESTAMP")))
                  m_Columns[row]->SetDefault(value.Upper());
               else
                  m_Columns[row]->SetDefault(value);
         }
      }
      else
         m_Columns[row]->SetDefault(wxEmptyString);
   }
}
Exemple #27
0
/*
// EquateProcess
//
// Processes a #define command
//
// Returns 1 on success, 0 on error
*/
static int EquateProcess( SOURCEFILE *ps, char *Src )
{
    EQUATE *pd,*pdTmp;
    char c;
    int  idx,srcIdx;

    /* Allocate a new record */
    pd = malloc(sizeof(EQUATE));
    if( !pd )
        { Report(ps,REP_ERROR,"Memory allocation failed"); return(0); }

    srcIdx=0;

    /* Remove leading white space */
    do
    {
        c = Src[srcIdx++];
    } while( c==' ' || c==0x9 );

    /* Character must be a legal label */
    if( !LabelChar(c,1) )
        { Report(ps,REP_ERROR,"Illegal label"); free(pd); return(0); }

    /* The name can only be delimited by a white space */
    /* Note: We now allow a NULL for a #define with no value */
    idx=0;
    for(;;)
    {
        pd->name[idx++]=c;
        c = Src[srcIdx++];
        if( !c || c==' ' || c==0x9 )
            break;
        if( !LabelChar(c,0) )
            { Report(ps,REP_ERROR,"Illegal #define"); free(pd); return(0); }
        if( idx >= (EQUATE_NAME_LEN-1) )
            { Report(ps,REP_ERROR,"Label too long"); free(pd); return(0); }
    }
    pd->name[idx]=0;

    /* Make sure this name is OK to use */
    if( !CheckName(ps,pd->name) )
    {
        free(pd);
        return(0);
    }

    /* Remove leading white space (unless we already hit EOL) */
    if( c )
        do
        {
            c = Src[srcIdx++];
        } while( c==' ' || c==0x9 );

    /* Load in the text part of the equate (defaul to "1" if no value) */
    if( !c )
        strcpy( pd->data, "1" );
    else
        strcpy( pd->data, Src+srcIdx-1 );

    /* Check for dedefinition, but ignore exact duplicates */
    if( (pdTmp = EquateFind(pd->name)) != 0 )
    {
        idx = strcmp( pd->data, pdTmp->data );
        if( !idx )
        {
            free(pd);
            return(1);
        }
        EquateDestroy(pdTmp);
        Report(ps,REP_WARN1,"Redefinition of equate '%s'",pd->name);
    }

    /* Put this equate in the master list */
    pd->Busy  = 0;
    pd->pPrev = 0;
    pd->pNext = pEqList;
    if( pEqList )
        pEqList->pPrev = pd;
    pEqList   = pd;

    if( Pass==1 && (Options & OPTION_DEBUG) )
        printf("%s(%5d) : DEFINE : '%s' = '%s'\n",
                            ps->SourceName,ps->CurrentLine,pd->name,pd->data);

    return(1);
}
Exemple #28
0
 void ICEVisitor::VisitBinaryOperator(BinaryOperator *BO) {
   const NamedDecl *ACD = dyn_cast_or_null<NamedDecl>(AC->getDecl());
   VisitChildren(BO);
   std::string ename = "EventNumber_t";
   clang::Expr *LHS = BO->getLHS();
   clang::Expr *RHS = BO->getRHS();
   if (!LHS || !RHS)
     return;
   std::string lname = LHS->getType().getAsString();
   std::string rname = RHS->getType().getAsString();
   if (IntegerLiteral::classof(LHS->IgnoreCasts()) || IntegerLiteral::classof(RHS->IgnoreCasts()))
     return;
   if (!(lname == ename || rname == ename))
     return;
   if (lname == ename && rname == ename)
     return;
   clang::QualType OTy;
   clang::QualType TTy;
   if (lname == ename && ImplicitCastExpr::classof(RHS)) {
     ImplicitCastExpr *ICE = dyn_cast_or_null<ImplicitCastExpr>(RHS);
     TTy = BR.getContext().getCanonicalType(LHS->getType());
     OTy = BR.getContext().getCanonicalType(ICE->getSubExprAsWritten()->getType());
   }
   if (rname == ename && ImplicitCastExpr::classof(LHS)) {
     ImplicitCastExpr *ICE = dyn_cast_or_null<ImplicitCastExpr>(LHS);
     TTy = BR.getContext().getCanonicalType(RHS->getType());
     OTy = BR.getContext().getCanonicalType(ICE->getSubExprAsWritten()->getType());
   }
   if (TTy.isNull() || OTy.isNull())
     return;
   QualType ToTy = TTy.getUnqualifiedType();
   QualType OrigTy = OTy.getUnqualifiedType();
   if (!(ToTy->isIntegerType() || ToTy->isFloatingType()))
     return;
   if (ToTy->isBooleanType())
     return;
   CharUnits size_otype = BR.getContext().getTypeSizeInChars(OrigTy);
   CharUnits size_ttype = BR.getContext().getTypeSizeInChars(ToTy);
   std::string oname = OrigTy.getAsString();
   std::string tname = ToTy.getAsString();
   if (ToTy->isFloatingType()) {
     llvm::SmallString<100> buf;
     llvm::raw_svector_ostream os(buf);
     os << "Cast-to type, " << tname << ". Cast-from type, " << oname << " . " << support::getQualifiedName(*(ACD));
     clang::ento::PathDiagnosticLocation CELoc =
         clang::ento::PathDiagnosticLocation::createBegin(BO, BR.getSourceManager(), AC);
     BR.EmitBasicReport(ACD,
                        CheckName(),
                        "implicit cast of int type to float type",
                        "CMS code rules",
                        os.str(),
                        CELoc,
                        BO->getSourceRange());
   }
   if ((size_otype > size_ttype)) {
     llvm::SmallString<100> buf;
     llvm::raw_svector_ostream os(buf);
     os << "Cast-to type, " << tname << ". Cast-from type, " << oname << ". Cast may result in truncation. "
        << support::getQualifiedName(*(ACD));
     clang::ento::PathDiagnosticLocation CELoc =
         clang::ento::PathDiagnosticLocation::createBegin(BO, BR.getSourceManager(), AC);
     BR.EmitBasicReport(ACD,
                        CheckName(),
                        "implicit cast of int type to smaller int type could truncate",
                        "CMS code rules",
                        os.str(),
                        CELoc,
                        BO->getSourceRange());
   }
   if ((size_otype == size_ttype) &&
       (ToTy->hasSignedIntegerRepresentation() && OrigTy->hasUnsignedIntegerRepresentation() ||
        ToTy->hasUnsignedIntegerRepresentation() && OrigTy->hasSignedIntegerRepresentation())) {
     llvm::SmallString<100> buf;
     llvm::raw_svector_ostream os(buf);
     os << "Cast-to type, " << tname << ". Cast-from type, " << oname << ". Changes int sign type. "
        << support::getQualifiedName(*(ACD));
     clang::ento::PathDiagnosticLocation CELoc =
         clang::ento::PathDiagnosticLocation::createBegin(BO, BR.getSourceManager(), AC);
     BR.EmitBasicReport(
         ACD, CheckName(), "implicit cast ins sign type", "CMS code rules", os.str(), CELoc, BO->getSourceRange());
   }
   return;
   return;
 }
ServerSaveActivity::ServerSaveActivity(SaveInfo save, ServerSaveActivity::SaveUploadedCallback * callback) :
	WindowActivity(ui::Point(-1, -1), ui::Point(440, 200)),
	thumbnail(NULL),
	save(save),
	callback(callback),
	saveUploadTask(NULL)
{
	titleLabel = new ui::Label(ui::Point(4, 5), ui::Point((Size.X/2)-8, 16), "");
	titleLabel->SetTextColour(style::Colour::InformationTitle);
	titleLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
	titleLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
	AddComponent(titleLabel);
	CheckName(save.GetName()); //set titleLabel text

	ui::Label * previewLabel = new ui::Label(ui::Point((Size.X/2)+4, 5), ui::Point((Size.X/2)-8, 16), "Preview:");
	previewLabel->SetTextColour(style::Colour::InformationTitle);
	previewLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
	previewLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
	AddComponent(previewLabel);

	nameField = new ui::Textbox(ui::Point(8, 25), ui::Point((Size.X/2)-16, 16), save.GetName(), "[save name]");
	nameField->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
	nameField->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
	nameField->SetActionCallback(new NameChangedAction(this));
	AddComponent(nameField);
	FocusComponent(nameField);

	descriptionField = new ui::Textbox(ui::Point(8, 65), ui::Point((Size.X/2)-16, Size.Y-(65+16+4)), save.GetDescription(), "[save description]");
	descriptionField->SetMultiline(true);
	descriptionField->SetLimit(254);
	descriptionField->Appearance.VerticalAlign = ui::Appearance::AlignTop;
	descriptionField->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
	AddComponent(descriptionField);

	publishedCheckbox = new ui::Checkbox(ui::Point(8, 45), ui::Point((Size.X/2)-80, 16), "Publish", "");
	if(Client::Ref().GetAuthUser().Username != save.GetUserName())
	{
		//Save is not owned by the user, disable by default
		publishedCheckbox->SetChecked(false);	
	}
	else
	{
		//Save belongs to the current user, use published state already set
		publishedCheckbox->SetChecked(save.GetPublished());
	}
	AddComponent(publishedCheckbox);

	pausedCheckbox = new ui::Checkbox(ui::Point(160, 45), ui::Point(55, 16), "Paused", "");
	pausedCheckbox->SetChecked(save.GetGameSave()->paused);
	AddComponent(pausedCheckbox);

	ui::Button * cancelButton = new ui::Button(ui::Point(0, Size.Y-16), ui::Point((Size.X/2)-75, 16), "Cancel");
	cancelButton->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
	cancelButton->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
	cancelButton->Appearance.BorderInactive = ui::Colour(200, 200, 200);
	cancelButton->SetActionCallback(new CancelAction(this));
	AddComponent(cancelButton);
	SetCancelButton(cancelButton);

	ui::Button * okayButton = new ui::Button(ui::Point((Size.X/2)-76, Size.Y-16), ui::Point(76, 16), "Save");
	okayButton->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
	okayButton->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
	okayButton->Appearance.TextInactive = style::Colour::InformationTitle;
	okayButton->SetActionCallback(new SaveAction(this));
	AddComponent(okayButton);
	SetOkayButton(okayButton);

	ui::Button * PublishingInfoButton = new ui::Button(ui::Point((Size.X*3/4)-75, Size.Y-42), ui::Point(150, 16), "Publishing Info");
	PublishingInfoButton->Appearance.HorizontalAlign = ui::Appearance::AlignCentre;
	PublishingInfoButton->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
	PublishingInfoButton->Appearance.TextInactive = style::Colour::InformationTitle;
	PublishingInfoButton->SetActionCallback(new PublishingAction(this));
	AddComponent(PublishingInfoButton);

	ui::Button * RulesButton = new ui::Button(ui::Point((Size.X*3/4)-75, Size.Y-22), ui::Point(150, 16), "Save Uploading Rules");
	RulesButton->Appearance.HorizontalAlign = ui::Appearance::AlignCentre;
	RulesButton->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
	RulesButton->Appearance.TextInactive = style::Colour::InformationTitle;
	RulesButton->SetActionCallback(new RulesAction(this));
	AddComponent(RulesButton);

	if(save.GetGameSave())
		RequestBroker::Ref().RenderThumbnail(save.GetGameSave(), false, true, (Size.X/2)-16, -1, this);
}
Exemple #30
0
 void ICEVisitor::VisitImplicitCastExpr(ImplicitCastExpr *CE) {
   const NamedDecl *ACD = dyn_cast<NamedDecl>(AC->getDecl());
   VisitChildren(CE);
   const Expr *SE = CE->getSubExprAsWritten();
   std::string sename = SE->getType().getAsString();
   const clang::Expr *E = CE->getSubExpr();
   if (!(sename == "EventNumber_t"))
     return;
   QualType OTy = BR.getContext().getCanonicalType(E->getType());
   QualType TTy = BR.getContext().getCanonicalType(CE->getType());
   QualType ToTy = TTy.getUnqualifiedType();
   QualType OrigTy = OTy.getUnqualifiedType();
   if (!(ToTy->isIntegerType() || ToTy->isFloatingType()))
     return;
   if (ToTy->isBooleanType())
     return;
   CharUnits size_otype = BR.getContext().getTypeSizeInChars(OrigTy);
   CharUnits size_ttype = BR.getContext().getTypeSizeInChars(ToTy);
   std::string oname = OrigTy.getAsString();
   std::string tname = ToTy.getAsString();
   if (ToTy->isFloatingType()) {
     llvm::SmallString<100> buf;
     llvm::raw_svector_ostream os(buf);
     os << "Cast-to type, " << tname << ". Cast-from type, " << oname << " . " << support::getQualifiedName(*(ACD));
     clang::ento::PathDiagnosticLocation CELoc =
         clang::ento::PathDiagnosticLocation::createBegin(CE, BR.getSourceManager(), AC);
     BR.EmitBasicReport(ACD,
                        CheckName(),
                        "implicit cast of int type to float type",
                        "CMS code rules",
                        os.str(),
                        CELoc,
                        CE->getSourceRange());
   }
   if ((size_otype > size_ttype)) {
     llvm::SmallString<100> buf;
     llvm::raw_svector_ostream os(buf);
     os << "Cast-to type, " << tname << ". Cast-from type, " << oname << ". Cast may result in truncation. "
        << support::getQualifiedName(*(ACD));
     clang::ento::PathDiagnosticLocation CELoc =
         clang::ento::PathDiagnosticLocation::createBegin(CE, BR.getSourceManager(), AC);
     BR.EmitBasicReport(ACD,
                        CheckName(),
                        "implicit cast of int type to smaller int type could truncate",
                        "CMS code rules",
                        os.str(),
                        CELoc,
                        CE->getSourceRange());
   }
   if (ToTy->hasSignedIntegerRepresentation() && OrigTy->hasUnsignedIntegerRepresentation() ||
       ToTy->hasUnsignedIntegerRepresentation() && OrigTy->hasSignedIntegerRepresentation()) {
     llvm::SmallString<100> buf;
     llvm::raw_svector_ostream os(buf);
     os << "Cast-to type, " << tname << ". Cast-from type, " << oname << ". Changes int sign type. "
        << support::getQualifiedName(*(ACD));
     clang::ento::PathDiagnosticLocation CELoc =
         clang::ento::PathDiagnosticLocation::createBegin(CE, BR.getSourceManager(), AC);
     BR.EmitBasicReport(ACD,
                        CheckName(),
                        "implicit cast changes int sign type",
                        "CMS code rules",
                        os.str(),
                        CELoc,
                        CE->getSourceRange());
   }
   return;
 }