Main Page | Modules | File List

KeySet Class Methods

Methods to manipulate KeySets. A KeySet is a linked list to group a number of Keys. Key Sets have an internal cursor to help in the Key navigation. More...

Functions

int ksInit (KeySet *ks)
int ksClose (KeySet *ks)
Key * ksNext (KeySet *ks)
int ksRewind (KeySet *ks)
Key * ksCurrent (const KeySet *ks)
size_t ksInsert (KeySet *ks, Key *toInsert)
size_t ksInsertKeys (KeySet *ks, KeySet *toInsert)
size_t ksAppend (KeySet *ks, Key *toAppend)
size_t ksAppendKeys (KeySet *ks, KeySet *toAppend)
int ksCompare (KeySet *ks1, KeySet *ks2, KeySet *removed)
size_t ksToStream (const KeySet *ks, FILE *stream, unsigned long options)

Detailed Description

Methods to manipulate KeySets. A KeySet is a linked list to group a number of Keys. Key Sets have an internal cursor to help in the Key navigation.

These are the methods to make various manipulations in the objects of class KeySet. Methods for sorting, merging, comparing, and internal cursor manipulation are provided. To use it:

#include <kdb.h>

Function Documentation

size_t ksAppend KeySet *  ks,
Key *  toAppend
 

Append a new Key to the end of the KeySet. The KeySet internal cursor is not moved.

Returns:
the size of the KeySet after insertion
Parameters:
ks KeySet that will receive the key
toAppend Key that will be appended to ks
See also:
ksInsert()

ksInsertKeys()

ksAppendKeys()

Definition at line 2336 of file key.c.

Referenced by commandEdit(), commandList(), kdbGetChildKeys(), kdbGetRootKeys(), and ksCompare().

size_t ksAppendKeys KeySet *  ks,
KeySet *  toAppend
 

Transfers an entire KeySet to the end of the KeySet.

After this call, the toAppend KeySet will be empty.

Returns:
the size of the KeySet after transfer
Parameters:
ks the KeySet that will receive the keys
toAppend the KeySet that provides the keys that will be transfered
See also:
ksAppend()

ksInsert()

ksInsertKeys()

Definition at line 2359 of file key.c.

Referenced by commandList(), kdbGetChildKeys(), and ksCompare().

int ksClose KeySet *  ks  ) 
 

KeySet destructor.

The keyClose() destructor will be called for all contained keys, and then freed. Then all internal KeySet pointers etc cleaned too. Sets the object ready to be freed by you.

See also:
ksInit()

keyClose()

Definition at line 2202 of file key.c.

References keyClose().

Referenced by commandList().

int ksCompare KeySet *  ks1,
KeySet *  ks2,
KeySet *  removed
 

Compare 2 KeySets with the following behavior:

  • A key (by full name) that is present on ks1 and ks2, and has something different, will be transfered from ks2 to ks1, and ks1's (old) version deleted.
  • Keys that are in ks1, but aren't in ks2 will be trasnsfered from ks1 to removed.
  • Keys that are keyCompare() equal in ks1 and ks2 will be deleted from ks2.
  • Keys that are available in ks2 but don't exist in ks1 will be transfered to ks1.

In the end, ks1 will have all the keys that matter, and ks2 will be empty.

After ksCompare(), you should:

See also:
keyCompare()

commandEdit() at the kdb command

Parameters:
ks1 first KeySet
ks2 second KeySet
removed empty KeySet that will be filled with keys removed from ks1

Definition at line 2411 of file key.c.

References KEY_FLAG_HASDOMAIN, KEY_FLAG_HASKEY, keyClose(), keyCompare(), ksAppend(), and ksAppendKeys().

Referenced by commandEdit().

Key* ksCurrent const KeySet *  ks  ) 
 

Return the current Key

See also:
ksNext()

ksRewind()

kdbMonitorKeys() for an example

Returns:
pointer to the Key pointed by ks's cursor

Definition at line 2266 of file key.c.

Referenced by kdbMonitorKeys().

int ksInit KeySet *  ks  ) 
 

KeySet object constructor.

Every KeySet object that will be used must be initialized first, to setup pointers, counters, etc.

See also:
ksClose()

keyInit()

Definition at line 2184 of file key.c.

Referenced by commandEdit(), commandImport(), commandList(), and kdbGetChildKeys().

size_t ksInsert KeySet *  ks,
Key *  toInsert
 

Insert a new Key in the begining of the KeySet. The KeySet internal cursor is not moved.

Returns:
the size of the KeySet after insertion
Parameters:
ks KeySet that will receive the key
toInsert Key that will be inserted into ks
See also:
ksAppend()

ksInsertKeys()

ksAppendKeys()

Definition at line 2285 of file key.c.

Referenced by kdbGetRootKeys().

size_t ksInsertKeys KeySet *  ks,
KeySet *  toInsert
 

Transfers an entire KeySet to the begining of the KeySet.

After this call, the toInsert KeySet will be empty.

Returns:
the size of the KeySet after insertion
Parameters:
ks the KeySet that will receive the keys
toInsert the KeySet that provides the keys that will be transfered
See also:
ksAppend()

ksInsert()

ksAppendKeys()

Definition at line 2308 of file key.c.

Key* ksNext KeySet *  ks  ) 
 

Returns the next Key in a KeySet. KeySets have an internal cursor that can be reset with ksRewind(). Every time ksNext() is called the cursor is incremented and the new current Key is returned. You'll get a NULL pointer if the end of KeySet was reached. After that, if ksNext() is called again, it will set the cursor to the begining of the KeySet and the first key is returned.

See also:
ksRewind()

ksCurrent()

Returns:
the new current Key

Definition at line 2232 of file key.c.

Referenced by commandEdit(), commandList(), and kdbMonitorKeys().

int ksRewind KeySet *  ks  ) 
 

Resets a KeySet internal cursor. Use it to set the cursor to the begining of the KeySet

See also:
ksNext()

ksCurrent()

kdbMonitorKeys() for an example

Returns:
allways 0

Definition at line 2251 of file key.c.

Referenced by commandEdit(), and commandList().

size_t ksToStream const KeySet *  ks,
FILE *  stream,
unsigned long  options
 

Prints an XML version of a KeySet object.

Accepted options:

  • KDB_O_NUMBERS: Do not convert UID and GID into user and group names
  • KDB_O_CONDENSED: Less human readable, more condensed output
  • KDB_O_XMLHEADERS: Include the correct XML headers in the output. Use it.

Parameters:
stream where to write output: a file or stdout
options ORed of KDB_O_* options
See also:
keyToStream()

KDBOptions

Returns:
number of bytes written to output

Definition at line 2509 of file key.c.

References KDB_O_XMLHEADERS, and keyToStream().

Referenced by commandEdit(), and commandList().


Generated on Tue Aug 31 08:40:42 2004 for Elektra Project by doxygen 1.3.6