src/libs/elektra/keyset.c
/*
 * Lookup for a Key contained in @p ks KeySet that matches the binary @p value,
 * starting from ks' ksNext() position.
 *
 * If found, @p ks internal cursor will be positioned in the matched key.
 * That means it is also accessible by ksCurrent(). A pointer to the Key
 * is returned. If not found, @p ks internal cursor won't move, and a
 * NULL pointer is returned.
 *
 * This method skips string keys.
 *
 * @param ks where to look for
 * @param value the value which owner key you want to find
 * @param size the size of @p value
 * @param options some @p KDB_O_* option bits:
 * 	- @p KDB_O_NOALL @n
 * 		Only search from ksCurrent() to end of keyset, see above text.
 * @return the Key found, NULL otherwise
 * @retval 0 on NULL pointer
 * @see ksLookupByString()
 * @see keyCompare() for very powerful Key lookups in KeySets
 * @see ksCurrent(), ksRewind(), ksNext()
 */
Lookup for a Key contained in @p ks KeySet that matches the binary @p value,
starting from ks' ksNext() position.

If found, @p ks internal cursor will be positioned in the matched key.
That means it is also accessible by ksCurrent(). A pointer to the Key
is returned. If not found, @p ks internal cursor won't move, and a
NULL pointer is returned.

This method skips string keys.


Lookup for a Key contained in @p ks KeySet that matches the binary @p value starting from ks ' ksNext () position . If found @p ks internal cursor will be positioned in the matched key . That means it is also accessible by ksCurrent () . A pointer to the Key is returned . If not found @p ks internal cursor won ' t move and a NULL pointer is returned . This method skips string keys .
Key * ksLookupByBinary (KeySet * ks, const void * value, size_t size, option_t options)
{
	cursor_t init = 0;
	Key * current = 0;
	if (!ks) return 0;
	if (!(options & KDB_O_NOALL))
	{
		ksRewind (ks);
		init = ksGetCursor (ks);
	}
	while ((current = ksNext (ks)))
	{
		if (!keyIsBinary (current)) continue;
		if (size != current->dataSize) continue;
		if (!value)
		{
			if (!current->data.v)
				break;
			else
				continue;
		}
		if (current->data.v && !memcmp (current->data.v, value, size)) break;
	}
	if (!(options & KDB_O_NOALL))
	{
		ksSetCursor (ks, init);
	}
	return 0;
}
Key * ksLookupByBinary ( KeySet * ks , const void * value , size_t size , option_t options ) { cursor_t init = 0 ; Key * current = 0 ; if ( ! ks ) return 0 ; if ( ! ( options & KDB_O_NOALL ) ) { ksRewind ( ks ) ; init = ksGetCursor ( ks ) ; } while ( ( current = ksNext ( ks ) ) ) { if ( ! keyIsBinary ( current ) ) continue ; if ( size != current -> dataSize ) continue ; if ( ! value ) { if ( ! current -> data . v ) break ; else continue ; } if ( current -> data . v && ! memcmp ( current -> data . v , value , size ) ) break ; } if ( ! ( options & KDB_O_NOALL ) ) { ksSetCursor ( ks , init ) ; } return 0 ; }
Lookup for a Key contained in @p ks KeySet that matches the binary @p value,
 starting from ks' ksNext() position.
Lookup for a Key contained in @p ks KeySet that matches the binary @p value starting from ks ' ksNext () position .
/* reached end of KeySet */