Example #1
0
QPair<QList<QNetworkRequest>, QStringList> Cache::createRequests(const QList<QUrl> &in,
																 bool refreshAll)
{
	QList<QUrl> urlsIn = in;
	QList<QNetworkRequest> requests;
	{
		QList<QUrl> urls = refreshAll ? in : getStaleUrls(in);
		requests.reserve(urls.size());
		for (const auto url : urls) {
			urlsIn.removeAll(url);
			QNetworkRequest request(url);
			const auto entryIt = findEntry(url);
			if (entryIt != m_entries.end()) {
				const auto entry = *entryIt;
				// TODO add the md5 as a header
			}
			requests.append(request);
		}
	}
	QStringList localfiles;
	{
		// loop through all urls that didn't get made into network requests
		for (const auto url : urlsIn) {
			localfiles.append(absoluteFilename(*findEntry(url)));
		}
	}
	return qMakePair(requests, localfiles);
}
Example #2
0
static RList* sections(RBinFile *arch) {
	RList *ret = NULL;
	RBinSection *ptr = NULL;
	ut64 textsize, datasize, symssize, spszsize, pcszsize;
	ut64 entry0 = findEntry (arch->buf, 0);
	ut64 entry1 = findEntry (arch->buf, 1);
	ut64 entry2 = findEntry (arch->buf, 2);

	if (!(ret = r_list_newf (free))) {
		return NULL;
	}
	// add text segment
	textsize = r_mem_get_num (arch->buf->buf + 4, 4);
	if (!(ptr = R_NEW0 (RBinSection))) {
		return ret;
	}
	if (!entry1) {
		entry1 = arch->buf->length;
	}
	strncpy (ptr->name, "init", R_BIN_SIZEOF_STRINGS);
	ptr->size = entry1-entry0;
	ptr->vsize = entry1-entry0;
	ptr->paddr = entry0 + 4;
	ptr->vaddr = entry0;
	ptr->srwx = R_BIN_SCN_READABLE | R_BIN_SCN_EXECUTABLE | R_BIN_SCN_MAP; // r-x
	r_list_append (ret, ptr);

	if (entry1) {
		if (entry2) {
			if (!(ptr = R_NEW0 (RBinSection)))
				return ret;
			strncpy (ptr->name, "fini", R_BIN_SIZEOF_STRINGS);
			ptr->size = entry2-entry1;
			ptr->vsize = entry2-entry1;
			ptr->paddr = entry1 + 4;
			ptr->vaddr = entry1;
			ptr->srwx = R_BIN_SCN_READABLE | R_BIN_SCN_EXECUTABLE | R_BIN_SCN_MAP; // r-x
			r_list_append (ret, ptr);
		} else {
			entry2 = entry1;
		}
	}
	if (entry2) {
		if (!(ptr = R_NEW0 (RBinSection)))
			return ret;
		strncpy (ptr->name, "text", R_BIN_SIZEOF_STRINGS);
		ptr->size = arch->buf->length - entry2;
		ptr->vsize = arch->buf->length - entry2;
		ptr->paddr = entry2 + 4;
		ptr->vaddr = entry2;
		ptr->srwx = R_BIN_SCN_READABLE | R_BIN_SCN_EXECUTABLE | R_BIN_SCN_MAP; // r-x
		r_list_append (ret, ptr);
	}
	return ret;
}
Example #3
0
CRFileHistRecord * CRFileHist::savePosition( lString16 fpathname, size_t sz,
                            const lString16 & title,
                            const lString16 & author,
                            const lString16 & series,
                            ldomXPointer ptr )
{
    //CRLog::trace("CRFileHist::savePosition");
    lString16 name;
	lString16 path;
    splitFName( fpathname, path, name );
    CRBookmark bmk( ptr );
    //CRLog::trace("Bookmark created");
    int index = findEntry( name, path, (lvsize_t)sz );
    //CRLog::trace("findEntry exited");
    if ( index>=0 ) {
        makeTop( index );
        _records[0]->setLastPos( &bmk );
        _records[0]->setLastTime( (time_t)time(0) );
        return _records[0];
    }
    CRFileHistRecord * rec = new CRFileHistRecord();
    rec->setTitle( title );
    rec->setAuthor( author );
    rec->setSeries( series );
    rec->setFileName( name );
    rec->setFilePath( path );
    rec->setFileSize( (lvsize_t)sz );
    rec->setLastPos( &bmk );
    rec->setLastTime( (time_t)time(0) );

    _records.insert( 0, rec );
    //CRLog::trace("CRFileHist::savePosition - exit");
    return rec;
}
Example #4
0
bool KEntryMap::revertEntry(const QByteArray& group, const QByteArray& key, KEntryMap::SearchFlags flags)
{
    Q_ASSERT((flags & KEntryMap::SearchDefaults) == 0);
    Iterator entry = findEntry(group, key, flags);
    if (entry != end()) {
        //qDebug() << "reverting" << entry.key() << " = " << entry->mValue;
        if (entry->bReverted) { // already done before
            return false;
        }

        KEntryKey defaultKey(entry.key());
        defaultKey.bDefault = true;
        //qDebug() << "looking up default entry with key=" << defaultKey;
        const ConstIterator defaultEntry = constFind(defaultKey);
        if (defaultEntry != constEnd()) {
            Q_ASSERT(defaultEntry.key().bDefault);
            //qDebug() << "found, update entry";
            *entry = *defaultEntry; // copy default value, for subsequent lookups
        } else {
            entry->mValue = QByteArray();
        }
        entry->bDirty = true;
        entry->bReverted = true; // skip it when writing out to disk

        //qDebug() << "Here's what we have now:" << *this;
        return true;
    }
    return false;
}
Example #5
0
int ConfGetInt(const char *name)
	{
	int entry = findEntry(name);
	if (entry >= 0)
		return ConfSetting[entry].value._int;
	return 0;																		// To satisfy compiler and default
	}
Example #6
0
bool ConfGetBool(const char *name)
	{
	int entry = findEntry(name);
	if (entry >= 0)
		return ConfSetting[entry].value._bool;
	return false;																	// To satisfy compiler and default
	}
Example #7
0
bool checkCrossingAtPoint(const Coords* a, const Coords* b) {
    if (a->getPred() == 0) {
        return false;
    }

    const Coords* exitN1 = std::get<0>(a->linearNeighbours[1]);
    const Coords* exitN0 = std::get<0>(a->linearNeighbours[0]);

    int orientExit = exitN1->isRight(exitN0, a);
    int inSectorExit;
    int inSectorEntry;

    const Coords* entry = findEntry(a);

    const Coords* entryN1 = std::get<0>(entry->linearNeighbours[1]);
    const Coords* entryN0 = std::get<0>(entry->linearNeighbours[0]);
    int orientEntry = entryN1->isRight(entryN0, entry);

    if (orientExit == -1) {
        inSectorExit = inSector(a, b, exitN1, exitN0);
    } else if (orientExit == 0) {
        inSectorExit = b->isRight(exitN0, exitN1);
    } else {
        inSectorExit = inSector(a, b, exitN0, exitN1);
    }

    if (orientEntry == -1) {
        inSectorEntry = inSector(entry, entry->getPred(), entryN1, entryN0);
    } else if (orientEntry == 0) {
        inSectorEntry = entry->getPred()->isRight(entryN0, entryN1);
    } else {
        inSectorEntry = inSector(entry, entry->getPred(), entryN0, entryN1);
    }

    if (orientExit != 0) {
        inSectorExit *= orientExit;
    }
    if (orientEntry != 0) {
        inSectorEntry *= orientEntry;
    }

    if (false) {
        std::cout << std::endl;
        std::cout << "entry: " << entry->toString();
        std::cout << "exit: " << a->toString();
        std::cout << "B: " << b->toString();
        std::cout << "Pred: " << entry->getPred()->toString();
        std::cout << "exitN0" << exitN0->toString();
        std::cout << "exitN1" << exitN1->toString();
        std::cout << "entryN0" << entryN0->toString();
        std::cout << "entryN1" << entryN1->toString();
        std::cout << "orientExit: " << orientExit << std::endl;
        std::cout << "orientEntry: " << orientEntry << std::endl;
        std::cout << "inSectorExit: " << inSectorExit << std::endl;
        std::cout << "inSectorEntry: " << inSectorEntry << std::endl;

    }

    return inSectorExit != inSectorEntry;
}
void HistoryContentsWidget::removeDomainEntries()
{
	QStandardItem *domainItem = findEntry(getEntry(m_ui->historyView->currentIndex()));

	if (!domainItem)
	{
		return;
	}

	const QString host = QUrl(domainItem->text()).host();
	QList<qint64> entries;

	for (int i = 0; i < m_model->rowCount(); ++i)
	{
		QStandardItem *groupItem = m_model->item(i, 0);

		if (!groupItem)
		{
			continue;
		}

		for (int j = (groupItem->rowCount() - 1); j >= 0; --j)
		{
			QStandardItem *entryItem = groupItem->child(j, 0);

			if (entryItem && host == QUrl(entryItem->text()).host())
			{
				entries.append(entryItem->data(Qt::UserRole).toLongLong());
			}
		}
	}

	HistoryManager::removeEntries(entries);
}
JNIEXPORT jobjectArray JNICALL Java_com_congnt_ndkguide_Store_getColorArray(
		JNIEnv* pEnv, jobject pThis, jstring pKey) {
	StoreEntry* lEntry = findEntry(pEnv, &gStore, pKey, NULL);
	if (isEntryValid(pEnv, lEntry, StoreType_ArrayColor)) {
		jclass lColorClass = (*pEnv)->FindClass(pEnv,
				"com/congnt/ndkguide/Color");
		if (lColorClass == NULL)
			return NULL;
		jobjectArray lColorJavaArray = (*pEnv)->NewObjectArray(pEnv,
				lEntry->mLength, lColorClass, NULL);
		(*pEnv)->DeleteLocalRef(pEnv, lColorClass);
		if (lColorJavaArray == NULL)
			return NULL;
		int32_t i;
		for (i = 0; i < lEntry->mLength; ++i) {
			(*pEnv)->SetObjectArrayElement(pEnv, lColorJavaArray, i,
					lEntry->mValue.mColorArray[i]);
			if ((*pEnv)->ExceptionCheck(pEnv)) {
				return NULL;
			}
		}
		return lColorJavaArray;
	} else {
		return NULL;
	}

}
Example #10
0
void *
hash_Remove (
  pwr_tStatus		*sts,
  hash_sTable		*htp,
  void			*ip		/* Address of item to be removed.  */
)
{
  hash_sGtable		*ghtp;
  pool_sQlink		*il;
  pool_sQlink		*bl;


  ghtp = htp->ghtp;
  ghtp->removes++;

  il = findEntry(sts, &bl, htp, (char *)ip + ghtp->key_offset);
  if (il == NULL) return NULL;

  il = pool_Qremove(sts, htp->php, il);
  if (il == NULL)
    return NULL;

  ghtp->entries--;
  if (bl->flink == bl->self)
    ghtp->used_buckets--;

  pwr_Return(ip, sts, HASH__SUCCESS);
}
Example #11
0
void *
hash_Insert (
  pwr_tStatus		*sts,
  hash_sTable		*htp,
  void			*ip		/* Address of item to be inserted.  */
)
{
  hash_sGtable		*ghtp;
  pool_sQlink		*il;
  pool_sQlink		*bl;		/* Address of bucket link.  */

  ghtp = htp->ghtp;
  ghtp->inserts++;

  il = findEntry(sts, &bl, htp, (char* )ip + ghtp->key_offset);

  if (il != NULL) {
    pwr_Return(NULL, sts, HASH__DUPLICATE);
  } else {
    if (bl->self == bl->flink) {	/* This is an empty bucket.  */
      ghtp->used_buckets++;
      if (ghtp->used_buckets > ghtp->max_used_buckets)
	ghtp->max_used_buckets = ghtp->used_buckets;
    }

    il = (pool_sQlink *)((char *)ip + ghtp->link_offset);
    il = pool_QinsertSucc(sts, htp->php, il, bl);
    if (il == NULL) return NULL;
    ghtp->entries++;
    if (ghtp->entries > ghtp->max_entries)
      ghtp->max_entries = ghtp->entries;
  }

  pwr_Return(ip, sts, HASH__SUCCESS);
}
Example #12
0
StoreEntry * allocateEntry(JNIEnv* pEnv, Store* pStore, jstring jstrKey) {
	// If entry already exists in the store, releases its content
	// and keep its key.
	int32_t lError = 0;
	StoreEntry* lEntry = findEntry(pEnv, pStore, jstrKey, &lError);
	if (NULL != lEntry) {
		releaseEntryValue(pEnv, lEntry);
	}
	// If entry does not exist, create a new entry right after
	// already allocated entries.
	else if (!lError) {
		// Checks store can accept a new entry.
		if (pStore->mLength >= STORE_MAX_CAPACITY) {
			throwStoreFullException(pEnv);
			return NULL;
		}

		lEntry = pStore->mEntries + pStore->mLength;

		// Copies the new key into its final C string buffer.
		const char* lKeyTmp = (*pEnv)->GetStringUTFChars(pEnv, jstrKey, NULL);

		if (NULL == lKeyTmp) {
			return NULL;
		}

		lEntry->mKey = (char*) malloc(strlen(lKeyTmp));
		strcpy(lEntry->mKey, lKeyTmp);
		(*pEnv)->ReleaseStringUTFChars(pEnv, jstrKey, lKeyTmp);

		++pStore->mLength;
	}

	return lEntry;
}
Example #13
0
StoreEntry* allocateEntry(JNIEnv* env, Store* rStore, jstring rKey)
{
	LOGV("allocateEntry is called");
	int32_t error = 0;
	StoreEntry* rEntry = findEntry(env, rStore, rKey, &error);

	if(rEntry != NULL) freeEntry(env, rEntry);

	else if(!error)
	{
		LOGV("No error while allocation");
		if(rStore->numentries >= STORE_MAX_CAPACITY)
		{
			LOGV("Store is full");
			throwStoreFullException(env);
			return NULL;
		}
		rEntry = rStore->allentries + rStore->numentries;

		const char* tmpKeyString = (*env)->GetStringUTFChars(env, rKey, NULL);
		if(tmpKeyString == NULL) return NULL;

		rEntry->nKey = (char*) malloc(strlen(tmpKeyString));
		strcpy(rEntry->nKey, tmpKeyString);

		(*env)->ReleaseStringUTFChars(env, rKey, tmpKeyString);

		rStore->numentries++;
	}

	return rEntry;
}
Example #14
0
char * ConfGetString(const char *name)
	{
	int entry = findEntry(name);
	if (entry >= 0)
		return ConfSetting[entry].value._string;
	return "";																		// To satisfy compiler and default
	}
Example #15
0
/**
 * Retrieve tag data from header.
 * @param h		header
 * @retval td		tag data container
 * @param flags		flags to control retrieval
 * @return		1 on success, 0 on not found
 */
static int intGetTdEntry(Header h, rpmtd td, headerGetFlags flags)
{
    indexEntry entry;
    int rc;

    /* First find the tag */
    /* FIX: h modified by sort. */
    entry = findEntry(h, td->tag, RPM_NULL_TYPE);
    if (entry == NULL) {
	/* Td is zeroed above, just return... */
	return 0;
    }

    if (flags & HEADERGET_RAW) {
	rc = copyTdEntry(entry, td, flags);
    } else {
	switch (entry->info.type) {
	case RPM_I18NSTRING_TYPE:
	    rc = copyI18NEntry(h, entry, td, flags);
	    break;
	default:
	    rc = copyTdEntry(entry, td, flags);
	    break;
	}
    }

    if (rc == 0)
	td->flags |= RPMTD_INVALID;

    /* XXX 1 on success */
    return ((rc == 1) ? 1 : 0);
}
Example #16
0
int UNPK_stat(PHYSFS_Dir *opaque, const char *filename,
              int *exists, PHYSFS_Stat *stat)
{
    int isDir = 0;
    const UNPKinfo *info = (const UNPKinfo *) opaque;
    const UNPKentry *entry = findEntry(info, filename, &isDir);

    if (isDir)
    {
        *exists = 1;
        stat->filetype = PHYSFS_FILETYPE_DIRECTORY;
        stat->filesize = 0;
    } /* if */
    else if (entry != NULL)
    {
        *exists = 1;
        stat->filetype = PHYSFS_FILETYPE_REGULAR;
        stat->filesize = entry->size;
    } /* else if */
    else
    {
        *exists = 0;
        return 0;
    } /* else */

    stat->modtime = -1;
    stat->createtime = -1;
    stat->accesstime = -1;
    stat->readonly = 1;

    return 1;
} /* UNPK_stat */
void GCUserView::qlv_contextMenuRequested(Q3ListViewItem *i, const QPoint &pos, int)
{
	if(!i || !i->parent() || !gcDlg_)
		return;

	QPointer<GCUserViewItem> lvi = (GCUserViewItem *)i;
	bool self = gcDlg_->nick() == i->text(0);
	GCUserViewItem* c = (GCUserViewItem*) findEntry(gcDlg_->nick());
	if (!c) {
		qWarning(QString("groupchatdlg.cpp: Self ('%1') not found in contactlist").arg(gcDlg_->nick()));
		return;
	}
	Q3PopupMenu *pm = new Q3PopupMenu;
	pm->insertItem(IconsetFactory::icon("psi/sendMessage").icon(), tr("Send &message"), 0);
	pm->insertItem(IconsetFactory::icon("psi/start-chat").icon(), tr("Open &chat window"), 1);
	pm->insertSeparator();
	pm->insertItem(tr("&Kick"),10);
	pm->setItemEnabled(10, MUCManager::canKick(c->s.mucItem(),lvi->s.mucItem()));
	pm->insertItem(tr("&Ban"),11);
	pm->setItemEnabled(11, MUCManager::canBan(c->s.mucItem(),lvi->s.mucItem()));

	Q3PopupMenu* rm = new Q3PopupMenu(pm);
	rm->insertItem(tr("Visitor"),12);
	rm->setItemChecked(12, lvi->s.mucItem().role() == MUCItem::Visitor);
	rm->setItemEnabled(12, (!self || lvi->s.mucItem().role() == MUCItem::Visitor) && MUCManager::canSetRole(c->s.mucItem(),lvi->s.mucItem(),MUCItem::Visitor));
	rm->insertItem(tr("Participant"),13);
	rm->setItemChecked(13, lvi->s.mucItem().role() == MUCItem::Participant);
	rm->setItemEnabled(13, (!self || lvi->s.mucItem().role() == MUCItem::Participant) && MUCManager::canSetRole(c->s.mucItem(),lvi->s.mucItem(),MUCItem::Participant));
	rm->insertItem(tr("Moderator"),14);
	rm->setItemChecked(14, lvi->s.mucItem().role() == MUCItem::Moderator);
	rm->setItemEnabled(14, (!self || lvi->s.mucItem().role() == MUCItem::Moderator) && MUCManager::canSetRole(c->s.mucItem(),lvi->s.mucItem(),MUCItem::Moderator));
	pm->insertItem(tr("Change role"),rm);

	/*Q3PopupMenu* am = new Q3PopupMenu(pm);
	am->insertItem(tr("Unaffiliated"),15);
	am->setItemChecked(15, lvi->s.mucItem().affiliation() == MUCItem::NoAffiliation);
	am->setItemEnabled(15, (!self || lvi->s.mucItem().affiliation() == MUCItem::NoAffiliation) && MUCManager::canSetAffiliation(c->s.mucItem(),lvi->s.mucItem(),MUCItem::NoAffiliation));
	am->insertItem(tr("Member"),16);
	am->setItemChecked(16, lvi->s.mucItem().affiliation() == MUCItem::Member);
	am->setItemEnabled(16,  (!self || lvi->s.mucItem().affiliation() == MUCItem::Member) && MUCManager::canSetAffiliation(c->s.mucItem(),lvi->s.mucItem(),MUCItem::Member));
	am->insertItem(tr("Administrator"),17);
	am->setItemChecked(17, lvi->s.mucItem().affiliation() == MUCItem::Admin);
	am->setItemEnabled(17,  (!self || lvi->s.mucItem().affiliation() == MUCItem::Admin) && MUCManager::canSetAffiliation(c->s.mucItem(),lvi->s.mucItem(),MUCItem::Admin));
	am->insertItem(tr("Owner"),18);
	am->setItemChecked(18, lvi->s.mucItem().affiliation() == MUCItem::Owner);
	am->setItemEnabled(18,  (!self || lvi->s.mucItem().affiliation() == MUCItem::Owner) && MUCManager::canSetAffiliation(c->s.mucItem(),lvi->s.mucItem(),MUCItem::Owner));
	pm->insertItem(tr("Change affiliation"),am);*/
	pm->insertSeparator();
	//pm->insertItem(tr("Send &file"), 4);
	//pm->insertSeparator();
	pm->insertItem(tr("Check &Status"), 2);
	pm->insertItem(IconsetFactory::icon("psi/vCard").icon(), tr("User &Info"), 3);
	int x = pm->exec(pos);
	bool enabled = pm->isItemEnabled(x) || rm->isItemEnabled(x);
	delete pm;

	if(x == -1 || !enabled || lvi.isNull())
		return;
	action(lvi->text(0), lvi->s, x);
}
Example #18
0
/**
 * Return i18n string from header that matches locale.
 * @param h		header
 * @param entry		i18n string data
 * @retval td		tag data container
 * @param flags		flags to control allocation
 * @return		1 always
 */
static int copyI18NEntry(Header h, indexEntry entry, rpmtd td, 
						headerGetFlags flags)
{
    const char *lang, *l, *le;
    indexEntry table;

    td->type = RPM_STRING_TYPE;
    td->count = 1;
    /* if no match, just return the first string */
    td->data = entry->data;

    /* XXX Drepper sez' this is the order. */
    if ((lang = getenv("LANGUAGE")) == NULL &&
	(lang = getenv("LC_ALL")) == NULL &&
	(lang = getenv("LC_MESSAGES")) == NULL &&
	(lang = getenv("LANG")) == NULL)
	    goto exit;
    
    if ((table = findEntry(h, RPMTAG_HEADERI18NTABLE, RPM_STRING_ARRAY_TYPE)) == NULL)
	goto exit;

    for (l = lang; *l != '\0'; l = le) {
	const char *t;
	char *ed, *ed_weak = NULL;
	int langNum;

	while (*l && *l == ':')			/* skip leading colons */
	    l++;
	if (*l == '\0')
	    break;
	for (le = l; *le && *le != ':'; le++)	/* find end of this locale */
	    {};

	/* For each entry in the header ... */
	for (langNum = 0, t = table->data, ed = entry->data;
	     langNum < entry->info.count;
	     langNum++, t += strlen(t) + 1, ed += strlen(ed) + 1) {

	    int match = headerMatchLocale(t, l, le);
	    if (match == 1) {
		td->data = ed;
		goto exit;
	    } else if (match == 2) { 
		ed_weak = ed;
	    }
	}
	if (ed_weak) {
	    td->data = ed_weak;
	    goto exit;
	}
    }

exit:
    if (flags & HEADERGET_ALLOC) {
	td->data = xstrdup(td->data);
	td->flags |= RPMTD_ALLOCED;
    }

    return 1;
}
Example #19
0
bool
ConfigScope::is_in_table(const char *name) const
{
	int	index;

	return (findEntry(name, index) != 0);
}
int main(void)
{
	struct entry * findEntry(struct entry *listPtr, int match);
	struct entry n1, n2, n3;
	struct entry *listPtr, *listStart = &n1;

	int search;

	n1.value = 100;
	n1.next = &n2;
	
	n2.value = 200;
	n2.next = &n3;

	n3.value = 300;
	n3.next = 0;

	printf("Enter value to locate: ");
	scanf("%i", &search);

	listPtr = findEntry(listStart, search);

	if (listPtr != (struct entry *) 0)
		printf("Found %i.\n", listPtr->value);
	else
		printf("Not found.\n");

	return 0;
}
void HtmlRenderer::printColumn(size_t column, Replacement& rep)
{
    char title[64];
    snprintf(title, sizeof(title), "/*$%lu", column+1);

    rep.m_found = findEntry(title, rep.m_open, rep.m_close);
    if (!rep.m_found) return;

    double not_a_value;
    memset(&not_a_value, 255, sizeof(double));

    ostringstream os;
    double value = 0;
    for (size_t row=0; row < m_iter->count(); row++) {
        double val;
        m_iter->value(row, column, val);
        if (0 != memcmp(&not_a_value, &val, sizeof(val))) {
            value = val;
        }

        char buffer[128];
        m_response->convertValue(value, buffer, sizeof(buffer));
        if (row > 0) os << ",";
        os << buffer;
    }

    rep.m_content = os.str();
}
Example #22
0
File: macro.c Project: xrg/RPM
void
addMacro(rpmMacroContext mc,
	const char * n, const char * o, const char * b, int level)
{
    rpmMacroEntry * mep;

    if (mc == NULL) mc = rpmGlobalMacroContext;

    /* If new name, expand macro table */
    if ((mep = findEntry(mc, n, 0)) == NULL) {
	if (mc->firstFree == mc->macrosAllocated)
	    expandMacroTable(mc);
	if (mc->macroTable != NULL)
	    mep = mc->macroTable + mc->firstFree++;
    }

    if (mep != NULL) {
	/* Push macro over previous definition */
	pushMacro(mep, n, o, b, level);

	/* If new name, sort macro table */
	if ((*mep)->prev == NULL)
	    sortMacroTable(mc);
    }
}
Example #23
0
StoreEntry *allocateEntry(JNIEnv *pEnv, Store *pStore, jstring pKey) {

    int32_t lError = 0;
    StoreEntry *lEntry = findEntry(pEnv, pStore, pKey, &lError);

    if (lEntry != NULL) {
        releaseEntryValue(pEnv, lEntry);
    } else if (!lError) {
        if (pStore->mLength >= STORE_MAX_CAPACITY) {
            return NULL;
        }
        lEntry = pStore->mEntries + pStore->mLength;

        const char *lKeyTmp = (*pEnv)->GetStringUTFChars(pEnv, pKey, NULL);

        if (lKeyTmp == NULL) {
            return NULL;
        }
        lEntry->mKey = (char *) malloc(strlen(lKeyTmp));
        strcpy(lEntry->mKey, lKeyTmp);
        (*pEnv)->ReleaseStringUTFChars(pEnv, pKey, lKeyTmp);

        ++pStore->mLength;
    }
    return lEntry;
}
Example #24
0
dnscacheLookup(struct sockaddr_storage *const addr,
	prop_t **const fqdn, prop_t **const fqdnLowerCase,
	prop_t **const localName, prop_t **const ip)
{
	DEFiRet;

	iRet = findEntry(addr, fqdn, fqdnLowerCase, localName, ip);

	if(iRet != RS_RET_OK) {
		DBGPRINTF("dnscacheLookup failed with iRet %d\n", iRet);
		prop.AddRef(staticErrValue);
		*ip = staticErrValue;
		if(fqdn != NULL) {
			prop.AddRef(staticErrValue);
			*fqdn = staticErrValue;
		}
		if(fqdnLowerCase != NULL) {
			prop.AddRef(staticErrValue);
			*fqdnLowerCase = staticErrValue;
		}
		if(localName != NULL) {
			prop.AddRef(staticErrValue);
			*localName = staticErrValue;
		}
	}
	RETiRet;
}
Example #25
0
int Lookup::find(const struct HashTable *table,
		 const QChar *c, unsigned int len)
{
  const HashEntry *entry = findEntry( table, c, len );
  if (entry)
    return entry->value;
  return -1;
}
Example #26
0
unsigned Dictionary<Entry>::getTagID(KyteaString str, KyteaString tag, int lev) {
    const Entry * ent = findEntry(str);
    if(ent == 0) return 0;
    for(unsigned i = 0; i < ent->tags[lev].size(); i++)
        if(ent->tags[lev][i] == tag)
            return i+1;
    return 0;
}
void HistoryContentsWidget::copyEntryLink()
{
	QStandardItem *entryItem = findEntry(getEntry(m_ui->historyView->currentIndex()));

	if (entryItem)
	{
		QApplication::clipboard()->setText(entryItem->text());
	}
}
JNIEXPORT jstring JNICALL Java_com_congnt_ndkguide_Store_getString(JNIEnv* pEnv,
		jobject pThis, jstring pKey) {
	StoreEntry* lEntry = findEntry(pEnv, &gStore, pKey, NULL);
	if (isEntryValid(pEnv, lEntry, StoreType_String)) {
		return (*pEnv)->NewStringUTF(pEnv, lEntry->mValue.mString);
	} else {
		return NULL;
	}
}
void HistoryContentsWidget::bookmarkEntry()
{
	QStandardItem *entryItem = findEntry(getEntry(m_ui->historyView->currentIndex()));

	if (entryItem)
	{
		emit requestedAddBookmark(QUrl(entryItem->text()), m_ui->historyView->currentIndex().sibling(m_ui->historyView->currentIndex().row(), 1).data(Qt::DisplayRole).toString());
	}
}
JNIEXPORT jobject JNICALL Java_com_congnt_ndkguide_Store_getColor(JNIEnv* pEnv,
		jobject pThis, jstring pKey) {
	StoreEntry* lEntry = findEntry(pEnv, &gStore, pKey, NULL);
	if (isEntryValid(pEnv, lEntry, StoreType_Color)) {
		return lEntry->mValue.mColor;
	} else {
		return NULL;
	}
}