Esempio n. 1
0
static mad_status       CPUGetPiece( unsigned piece,
                                const char **descript_p,
                                size_t *max_descript_p,
                                const mad_reg_info **reg,
                                mad_type_handle *disp_type,
                                size_t *max_value )
{
    unsigned    idx;

    if( !FindEntry( CPUNumeric, piece, &idx, disp_type ) )
        return( MS_FAIL );
    *reg = &RegList[idx].info;
    if( !(MADState->reg_state[CPU_REG_SET] & CT_EXTENDED) ) {
        if( *disp_type == PPCT_H_DWORD ) {
            *disp_type = PPCT_H_WORD;
            *reg = &RegListHalf[idx - IDX_r0].info;
        }
    }
    //NYI: if extended & ~ 64 bit mode, downshift to 32-bit display.
    //     Also, if 64 <=> 32 bit switch, tell client to redraw window
    if( !(MADState->reg_state[CPU_REG_SET] & CT_HEX) ) {
        switch( *disp_type ) {
        case PPCT_H_DWORD:
            *disp_type = PPCT_H_UINT64;
            break;
        case PPCT_H_WORD:
            *disp_type = PPCT_H_ULONG;
            break;
        }
    }
    *descript_p = (*reg)->name;
    *max_descript_p = 0;
    *max_value = 0;
    return( MS_OK );
}
Esempio n. 2
0
bool PGenrepList::AddGenrep(u16 nWorldID, u16 nStationID)
{
    char query[256];

    if ((FindEntry(nWorldID, nStationID) >= mListSize) && (mListSize < 255))
    {
        if (mListSize == mListMaxSize)
        {
            IncreaseMaxSize();
        }
        mGenrepList[mListSize].mWorldID = nWorldID;
        mGenrepList[mListSize++].mStationID = nStationID;

        snprintf(query, 256, "INSERT INTO genrep (g_id,g_worldid,g_stationid,g_charid) VALUES (NULL,'%u','%u','%u');", nWorldID, nStationID, mOwnerCharID);
        if ( MySQL->GameQuery(query) )
        {
            Console->Print(RED, BLACK, "PGenrepList::AddGenrep could not add some genrep entry in the database");
            Console->Print("Query was:");
            Console->Print("%s", query);
            MySQL->ShowGameSQLError();
            return false;
        }

        return true;
    }
    else
        return false;
}
Esempio n. 3
0
RAMDISK_DIR_ENTRY * RAMDISK_PARTITION::FindPath(const char* path, const char **basename)
{
	int pathLen = strlen(path);
	char dirfilename[pathLen+1]; 					// to hold a full path 
	const char *cptr = path+pathLen;				// find the end...
	const char *filename = NULL;					// to hold filename
	while(cptr-->path)								//search till start
	{
		if((*cptr=='/') || (*cptr==':'))				// split at either / or : (whichever comes first form the end!)
		{
			cptr++;
			strlcpy(dirfilename, path, 1+cptr-path);	//copy string up till and including / or :
			filename = cptr;									//filename = now remainder of string
			break;
		}
	} 
	
	if(!filename)
	{
		filename		= path;				//filename = complete path
		dirfilename[0]	= 0;				//make directory path ""
	}
	RAMDISK_BASE_ENTRY *entry = FindEntry(dirfilename);
	if(entry)
	{
		if(basename) *basename = filename;
		return entry->IsDir();
	}
	return NULL;
}
void DSession::AttachL(DThread& aClient)
{
  if(FindEntry(aClient)) return;
  if(!iServer) User::Leave(KErrServerTerminated);
  DSessionShare** shares=iShares;
  TInt top=iClients;
  if(top==iAlloc)
  {
    if(top>(EMaxShares-EShareGranularity)) User::Leave(KErrNotSupported);
    TInt newClients=top+EShareGranularity;
    shares=(DSessionShare**)User::ReAllocL(shares,newClients*sizeof(DSessionShare*));
    iShares=shares;
    iAlloc=newClients;
  }
  TInt i=0;
  while(i<top)
  {
    TUint index=(i+top)>>1;
    DThread* item=shares[index]->iClient;
    if(&aClient<item)
    {
      top=index;
      continue;
    }
    i=index+1;
  }
  DSessionShare* share=DSessionShare::NewL(*this,aClient,*iServer);
  Mem::Move(shares+i+1,shares+i,(iClients++-i)*sizeof(DSessionShare*));
  shares[i]=share;
}
Esempio n. 5
0
TEST_F(DlExtTest, ExtInfoUseFdWithOffset) {
  const std::string lib_path = std::string(getenv("ANDROID_DATA")) + LIBZIPPATH;

  android_dlextinfo extinfo;
  extinfo.flags = ANDROID_DLEXT_USE_LIBRARY_FD | ANDROID_DLEXT_USE_LIBRARY_FD_OFFSET;
  extinfo.library_fd = TEMP_FAILURE_RETRY(open(lib_path.c_str(), O_RDONLY | O_CLOEXEC));

  // Find the offset of the shared library in the zip.
  ZipArchiveHandle handle;
  ASSERT_EQ(0, OpenArchive(lib_path.c_str(), &handle));
  ZipEntry zip_entry;
  ZipString zip_name;
  zip_name.name = reinterpret_cast<const uint8_t*>(LIBZIP_SIMPLE_ZIP);
  zip_name.name_length = sizeof(LIBZIP_SIMPLE_ZIP) - 1;
  ASSERT_EQ(0, FindEntry(handle, zip_name, &zip_entry));
  extinfo.library_fd_offset = zip_entry.offset;
  CloseArchive(handle);

  handle_ = android_dlopen_ext(lib_path.c_str(), RTLD_NOW, &extinfo);
  ASSERT_DL_NOTNULL(handle_);

  uint32_t* taxicab_number = reinterpret_cast<uint32_t*>(dlsym(handle_, "dlopen_testlib_taxicab_number"));
  ASSERT_DL_NOTNULL(taxicab_number);
  EXPECT_EQ(1729U, *taxicab_number);
}
Esempio n. 6
0
void wxsToolSpace::OnMouseClick(wxMouseEvent& event)
{
    SetFocus();

    if ( m_Unstable ) return;

    // Finding out which tool has been clicked
    int PosX = event.GetX();
    int PosY = event.GetY();

    Entry* Tool = FindEntry(PosX,PosY);

    if ( Tool )
    {
        if ( !Tool->m_Tool->GetIsSelected() )
        {
            m_Data->SelectItem(Tool->m_Tool,!event.ControlDown());
        }
        else
        {
            m_Data->SelectItem(Tool->m_Tool,false);
        }

        Tool->m_Tool->MouseClick(0,PosX,PosY);
    }
}
Esempio n. 7
0
otError Filter::Apply(const ExtAddress &aExtAddress, int8_t &aRss)
{
    otError error = OT_ERROR_NONE;

    otMacFilterEntry *entry = FindEntry(aExtAddress);

    // assign the default RssIn setting for all receiving messages first.
    aRss = mRssIn;

    // check AddressFilter.
    if (mAddressMode == OT_MAC_FILTER_ADDRESS_MODE_WHITELIST)
    {
        VerifyOrExit(entry != NULL && entry->mFiltered, error = OT_ERROR_ADDRESS_FILTERED);
    }
    else if (mAddressMode == OT_MAC_FILTER_ADDRESS_MODE_BLACKLIST)
    {
        VerifyOrExit(entry == NULL || !entry->mFiltered, error = OT_ERROR_ADDRESS_FILTERED);
    }

    // not override the default RssIn setting if no specific RssIn on the Extended Address.
    if (entry != NULL && entry->mRssIn != OT_MAC_FILTER_FIXED_RSS_DISABLED)
    {
        aRss = entry->mRssIn;
    }

exit:
    return error;
}
Esempio n. 8
0
otError Filter::AddRssIn(const ExtAddress *aExtAddress, int8_t aRss)
{
    otError error = OT_ERROR_NONE;

    // set the default RssIn for all received messages.
    if (aExtAddress == NULL)
    {
        mRssIn = aRss;
        ExitNow();
    }
    else
    {
        Entry *entry = FindEntry(*aExtAddress);

        if (entry == NULL)
        {
            VerifyOrExit((entry = FindAvailEntry()) != NULL, error = OT_ERROR_NO_BUFS);
            entry->mExtAddress = static_cast<const otExtAddress &>(*aExtAddress);
        }

        entry->mRssIn = aRss;
    }

exit:
    return error;
}
static void* unzip_file(ZipArchiveHandle zip, const char* entry_name, unsigned* sz)
{
    ZipEntryName zip_entry_name(entry_name);
    ZipEntry zip_entry;
    if (FindEntry(zip, zip_entry_name, &zip_entry) != 0) {
        fprintf(stderr, "archive does not contain '%s'\n", entry_name);
        return 0;
    }

    *sz = zip_entry.uncompressed_length;

    uint8_t* data = reinterpret_cast<uint8_t*>(malloc(zip_entry.uncompressed_length));
    if (data == NULL) {
        fprintf(stderr, "failed to allocate %u bytes for '%s'\n", *sz, entry_name);
        return 0;
    }

    int error = ExtractToMemory(zip, &zip_entry, data, zip_entry.uncompressed_length);
    if (error != 0) {
        fprintf(stderr, "failed to extract '%s': %s\n", entry_name, ErrorCodeString(error));
        free(data);
        return 0;
    }

    return data;
}
Esempio n. 10
0
static mad_status       FPUGetPiece( unsigned piece,
                                const char **descript_p,
                                size_t *max_descript_p,
                                const mad_reg_info **reg,
                                mad_type_handle *disp_type,
                                size_t *max_value )
{
    unsigned    idx;

    if( !FindEntry( FPUList, piece, &idx, disp_type ) ) return( MS_FAIL );
    if( MADState->reg_state[FPU_REG_SET] & FT_HEX ) {
        switch( *disp_type ) {
        case AXPT_DOUBLE:
            *disp_type = AXPT_HDOUBLE;
            break;
        }
    }
    if( MADState->reg_state[FPU_REG_SET] & FT_G_FLOAT ) {
        switch( *disp_type ) {
        case AXPT_DOUBLE:
            *disp_type = AXPT_RG_FLOAT;
            break;
        }
    }
    *reg = &RegList[idx].info;
    *descript_p = (*reg)->name;
    *max_descript_p = 0;
    *max_value = 0;
    return( MS_OK );
}
Esempio n. 11
0
static int unzip_to_file(ZipArchiveHandle zip, char* entry_name) {
    FILE* fp = tmpfile();
    if (fp == NULL) {
        fprintf(stderr, "failed to create temporary file for '%s': %s\n",
                entry_name, strerror(errno));
        return -1;
    }

    ZipEntryName zip_entry_name(entry_name);
    ZipEntry zip_entry;
    if (FindEntry(zip, zip_entry_name, &zip_entry) != 0) {
        fprintf(stderr, "archive does not contain '%s'\n", entry_name);
        return -1;
    }

    int fd = fileno(fp);
    int error = ExtractEntryToFile(zip, &zip_entry, fd);
    if (error != 0) {
        fprintf(stderr, "failed to extract '%s': %s\n", entry_name, ErrorCodeString(error));
        return -1;
    }

    lseek(fd, 0, SEEK_SET);
    return fd;
}
Esempio n. 12
0
bool wxExVCS::GetDir(wxWindow* parent)
{
  if (!Use())
  {
    return false;
  }
  
  const wxString message = _("Select VCS Folder");
  
  std::vector<wxExConfigItem> v;

  // See also vcsentry, same item is used there.
  v.push_back(wxExConfigItem(
    _("Base folder"), 
    CONFIG_COMBOBOXDIR, 
    wxEmptyString, 
    true,
    1005));
      
  if (wxExConfigFirstOf(_("Base folder")).empty()) 
  {
    if (
      parent != NULL && 
      wxExConfigDialog(parent, v, message).ShowModal() == wxID_CANCEL)
    {
      return false;
    }
  }
  else
  {
    m_Entry = FindEntry(wxExConfigFirstOf(_("Base folder")));
  
    if (m_Entry.GetName().empty())
    {
      if (
        parent != NULL &&
        wxExConfigDialog(parent, v, message).ShowModal() == wxID_CANCEL)
      {
        return false;
      }
    }
  }
  
  m_Entry = FindEntry(wxExConfigFirstOf(_("Base folder")));
  
  return !m_Entry.GetName().empty();
}
Esempio n. 13
0
// Печать заголовков файла, заданного именем
void aout_info(char *Name)
{
   char name83[11];
   Exec exec;

   Make83Name(Name, name83);
   DirEntry Entry;
   if (FindEntry(0, name83, &Entry) == (uint)-1)
   {
      printf("Cannot open file '%s'!\n", Name);
      return;
   }
   LoadPart(&Entry, &exec, 0, sizeof(Exec));


   printf("midmag\t= 0x%x\n",   exec.a_midmag);
   printf("text\t= %d\n",     exec.a_text);
   printf("data\t= %d\n",     exec.a_data);
   printf("bss\t= %d\n",      exec.a_bss);
   printf("syms\t= %d\n",     exec.a_syms);
   printf("entry\t= 0x%x\n",    exec.a_entry);
   printf("trsize\t= %d\n",   exec.a_trsize);
   printf("drsize\t= %d\n",   exec.a_drsize);

   printf("\nflags\t= 0x%x\n", N_FLAG(exec));
   printf("machine\t= ");
   switch (N_MID(exec))
   {
      case M_OLDSUN2:   printf("OldSun2"); break;
      case M_68010:     printf("m68010"); break;
      case M_68020:     printf("m68020"); break;
      case M_SPARC:     printf("sparc"); break;
      case M_386:       printf("386"); break;
      case M_MIPS1:     printf("mips1"); break;
      case M_MIPS2:     printf("mips2"); break;
      default:          printf("unknown?"); return;
   }
   printf("\n");
   if (N_MID(exec) != M_386)
   {
      printf("Only 386's binaries are supported\n");
      return;
   }

   printf("magic\t= ");
   switch (N_MAGIC(exec))
   {
      case OMAGIC:   printf("omagic"); break;
      case NMAGIC:   printf("nmagic"); break;
      case ZMAGIC:   printf("zmagic"); break;
      case QMAGIC:   printf("qmagic"); break;
      case CMAGIC:   printf("cmagic"); break;
      default:       printf("bad magic"); return;
   }


//   Relocation_Info rels[100];
// FIXME: добавить вывод relocation records
}
Esempio n. 14
0
int DeviceDir::MakeDir(const char name[], size_t length)
{
	if (FindEntry(name, length))
		return E_ENTRY_EXISTS;

	fEntryList.AddToTail(new DeviceDir(GetFileSystem(), name, length, this));
	return E_NO_ERROR;
}
Esempio n. 15
0
int IniFile::GetEntryCompatibleValueI(LPCTSTR lpcszKey, LPCTSTR lpcszEntry1, LPCTSTR lpcszEntry2, int nDefault)
{
	size_t nEntry = FindEntry(lpcszKey, lpcszEntry1);
	if (nEntry != InvalidIndex)
		return GetValueI(lpcszKey, lpcszEntry1, nDefault);

	return GetValueI(lpcszKey, lpcszEntry2, nDefault);
}
Esempio n. 16
0
BOOL IniFile::GetEntryCompatibleValueB(LPCTSTR lpcszKey, LPCTSTR lpcszEntry1, LPCTSTR lpcszEntry2, BOOL bDefault)
{
	size_t nEntry = FindEntry(lpcszKey, lpcszEntry1);
	if (nEntry != InvalidIndex)
		return GetValueB(lpcszKey, lpcszEntry1, bDefault);

	return GetValueB(lpcszKey, lpcszEntry2, bDefault);
}
Esempio n. 17
0
bool C4GroupSet::LoadEntryString(const char *szEntryName, StdStrBuf * rBuf)
{
	// Load the entry from the first group that has it
	C4Group *pGroup;
	if ((pGroup = FindEntry(szEntryName)))
		return pGroup->LoadEntryString(szEntryName, rBuf);
	// Didn't find it
	return false;
}
// ----------------------------------------------------------------------------
// CSIPCRRoutingEntry::AddL
// ----------------------------------------------------------------------------
//
void CSIPCRRoutingEntry::AddL( const CSIPCRRoutingEntry* aEntry )
    {        
	if (FindEntry(aEntry->UID())) 
	    {	    
	    User::Leave (KErrAlreadyExists);    
	    }
	    	        	   
    User::LeaveIfError(iServedClients.Append(aEntry));
    }
Esempio n. 19
0
void DSession::DiscardShare(DSessionShare& aShare)
{
  if(iAttributes&EShared)
  {
    DSessionShare** share=FindEntry(*aShare.iClient);
    Mem::Move(share,share+1,(TUint8*)(iShares+--iClients)-(TUint8*)share);
  }
  else iPrimary=NULL;
}
Esempio n. 20
0
void DatabaseListModel::update(const QString& s)
{
    if(DatabaseListEntry* e = FindEntry(s))
    {
        QModelIndex m = createIndex(m_databases.indexOf(*e), DBLV_NAME, (void*) 0);
        QModelIndex n = createIndex(m_databases.indexOf(*e), DBLV_UTF8, (void*) 0);
        emit QAbstractItemModel::dataChanged(m, n);
    }
}
Esempio n. 21
0
bool C4GroupSet::LoadEntry(const char *szEntryName, char **lpbpBuf, size_t *ipSize, int32_t iAppendZeros)
{
	// Load the entry from the first group that has it
	C4Group *pGroup;
	if ((pGroup = FindEntry(szEntryName)))
		return pGroup->LoadEntry(szEntryName, lpbpBuf, ipSize, iAppendZeros);
	// Didn't find it
	return false;
}
Esempio n. 22
0
//Does the platform-specific equivalent of this in nsswitch.conf:
// hosts: files dns
DWORD
DJConfigureHostsEntry(const char *testPrefix)
{
    DWORD ceError = ERROR_SUCCESS;
    NsswitchConf conf;
    DistroInfo distro;
    int line;
    const char *hostsByFile;
    const char *hostsByDns;
    int moduleIndex;

    if(testPrefix == NULL)
        testPrefix = "";

    memset(&distro, 0, sizeof(distro));
    memset(&conf, 0, sizeof(conf));

    GCE(ceError = DJGetDistroInfo(testPrefix, &distro));

    ceError = ReadNsswitchConf(&conf, testPrefix, TRUE);
    GCE(ceError);

    hostsByFile = GetNameOfHostsByFile(&conf, &distro);
    hostsByDns = GetNameOfHostsByDns(&conf, &distro);

    line = FindEntry(&conf, 0, "hosts");
    if(line == -1)
    {
        DJ_LOG_INFO("Adding hosts line");
        GCE(ceError = AddEntry(&conf, &distro, &line, "hosts"));
        GCE(ceError = InsertModule(&conf, &distro, line, 0, hostsByDns));
        GCE(ceError = InsertModule(&conf, &distro, line, 0, hostsByFile));
    }
    moduleIndex = FindModuleOnLine(&conf, line, hostsByFile);
    if(moduleIndex > 0)
    {
        /* The local module exists on the line, but it is not the first
         * entry. */
        GCE(ceError = RemoveModule(&conf, line, moduleIndex));
    }
    if(moduleIndex != 0)
    {
        GCE(ceError = InsertModule(&conf, &distro, line, 0, hostsByFile));
    }

    if(conf.modified)
        WriteNsswitchConfiguration(testPrefix, &conf);
    else
        DJ_LOG_INFO("nsswitch not modified");

cleanup:
    FreeNsswitchConfContents(&conf);
    DJFreeDistroInfo(&distro);

    return ceError;
}
Esempio n. 23
0
LIB_COMPONENT* CMP_LIBRARY::FindComponent( const wxChar* aName )
{
    LIB_COMPONENT* component = NULL;
    LIB_ALIAS* entry = FindEntry( aName );

    if( entry != NULL )
        component = entry->GetComponent();

    return component;
}
Esempio n. 24
0
const char *FConfigFile::GetValueForKey (const char *key) const
{
	FConfigEntry *entry = FindEntry (CurrentSection, key);

	if (entry != NULL)
	{
		return entry->Value;
	}
	return NULL;
}
Esempio n. 25
0
bool wxExVCS::SetEntryFromBase(wxWindow* parent)
{
  if (!Use())
  {
    return false;
  }
  
  const wxString message = _("Select VCS Folder");
  
  // See also vcsentry, same item is used there.
  const std::vector<wxExItem> v{{
    _("Base folder"), ITEM_COMBOBOX_DIR, wxAny(), true, wxWindow::NewControlId()}};
      
  if (wxExConfigFirstOf(_("Base folder")).empty()) 
  {
    if (
      parent != nullptr && 
      wxExItemDialog(parent, v, message).ShowModal() == wxID_CANCEL)
    {
      return false;
    }
    
    m_Entry = FindEntry(wxExConfigFirstOf(_("Base folder")));
  }
  else
  {
    m_Entry = FindEntry(wxExConfigFirstOf(_("Base folder")));
  
    if (m_Entry.GetName().empty())
    {
      if (
        parent != nullptr &&
        wxExItemDialog(parent, v, message).ShowModal() == wxID_CANCEL)
      {
        return false;
      }
      
      m_Entry = FindEntry(wxExConfigFirstOf(_("Base folder")));
    }
  }
  
  return !m_Entry.GetName().empty();
}
Esempio n. 26
0
// create a new entry and add it to the current group
ConfigEntry *
ConfigGroup::AddEntry(const wxString& strName, int nLine)
{
  wxASSERT( FindEntry(strName) == NULL );

  ConfigEntry *pEntry = new ConfigEntry(this, strName, nLine);
  m_aEntries.Add(pEntry);

  return pEntry;
}
Esempio n. 27
0
	bool Del(bool bNegated, const CString& sChan, const CString& sHost) {
		VAttachIter it = FindEntry(sChan, sHost);
		if (it == m_vMatches.end() || it->IsNegated() != bNegated)
			return false;

		DelNV(it->ToString());
		m_vMatches.erase(it);

		return true;
	}
Esempio n. 28
0
bool wxExVCS::Execute()
{
  const wxExFileName filename(GetFile());

  if (!filename.IsOk())
  {
    return m_Entry.Execute(
      m_Entry.GetCommand().IsAdd() ? wxExConfigFirstOf(_("Path")): std::string(), 
      wxExLexer(), 
      true,
      wxExConfigFirstOf(_("Base folder")));
  }
  else
  {
    std::string args;
    std::string wd;
    
    if (m_Files.size() > 1)
    {
      for (const auto& it : m_Files)
      {
        args += "\"" + it + "\" ";
      }
    }
    else if (m_Entry.GetName() == "git")
    {
      const std::string admin_dir(FindEntry(filename).GetAdminDir());
      wd = GetTopLevelDir(admin_dir, filename);
      
      if (!filename.GetFullName().empty())
      {
        args = GetRelativeFile(
          admin_dir, 
          filename);
      }
    }
    else if (m_Entry.GetName() == "sccs")
    {
      args = "\"" + 
      // sccs for windows does not handle windows paths,
      // so convert them to UNIX, and add volume as well.
#ifdef __WXMSW__      
        filename.GetVolume() + wxFileName::GetVolumeSeparator() +
#endif        
        filename.GetFullPath(wxPATH_UNIX) + "\"";
    }
    else
    {
      args = "\"" + filename.GetFullPath() + "\"";
    }
    
    return m_Entry.Execute(args, filename.GetLexer(), true, wd);
  }
}
Esempio n. 29
0
int DeviceDir::Lookup(const char name[], size_t nameLen, VNode **outNode)
{
	DeviceEntry *entry = FindEntry(name, nameLen);
	if (entry) {
		entry->AcquireRef();
		*outNode = entry;
		return E_NO_ERROR;
	}

	return E_NO_SUCH_FILE;
}
Esempio n. 30
0
BOOL CamCache::FindPath( UINT32 Handle, INT32* &Points, BYTE* &Types, UINT32 &Length )
{
	INT32 *Object = (INT32*) FindEntry( Handle ) ;
	if ( Object )
	{
		Length = *Object ;
		Points = ++Object ;
		Types = (BYTE*) (Object+2*Length) ;
	}
	return Object!=NULL ;
}