1Key :: Miscelaneous(3) Library Functions Manual Key :: Miscelaneous(3)
2
3
4
6 Key :: Miscelaneous - Methods to do various things.
7
8
9 Functions
10 Key * keyNext (Key *key)
11 Return a pointer to the next key, if key is member of a KeySet.
12 ssize_t keyToStream (const Key *key, FILE *stream, unsigned long
13 options)
14 Prints an XML representation of the key.
15 ssize_t keyToStreamBasename (const Key *key, FILE *stream, const char
16 *parent, const size_t parentSize, unsigned long options)
17 Same as keyToStream() but tries to strip parentSize bytes from key
18 name if it matches parent .
19 void * keySerialize (Key *key)
20 Return a block of memory with the entire key serialized, including
21 metainfo, value, comment and full name.
22 Key * keyUnserialize (const void *serialized)
23 Given a membory block created by keySerialize(), unserialize it
24 into a Key structure and return it.
25
27 Methods to do various things.
28
29 To use them:
30
31 #include <kdb.h>
32
33
35 Key* keyNext (Key * key)
36 Return a pointer to the next key, if key is member of a KeySet.
37
38 Different from ksNext(), this call does not affect the KeySet internal
39 cursor .
40
41 Definition at line 2544 of file key.c.
42
43 References _Key::next.
44
45 ssize_t keyToStream (const Key * key, FILE * stream, unsigned long options)
46 Prints an XML representation of the key.
47
48 String generated is of the form:
49
50 <key name="system/sw/xorg/Monitor/Monitor0/Name"
51 type="string" uid="root" gid="root" mode="0660">
52
53 <value>Samsung TFT panel</value>
54 <comment>My monitor</comment>
55 </key>
56
57 <key parent="system/sw/xorg/Monitor/Monitor0" basename="Name"
58 type="string" uid="root" gid="root" mode="0660">
59
60 <value>Samsung TFT panel</value>
61 <comment>My monitor</comment>
62 </key>.fi
63
64 Parameters:
65 stream where to write output: a file or stdout
66 options Some KDBOptions ORed:
67
68 · KDBOptions::KDB_O_NUMBERS
69 Do not convert UID and GID into user and group names
70
71 · KDBOptions::KDB_O_CONDENSED
72 Less human readable, more condensed output
73
74 · KDBOptions::KDB_O_FULLNAME
75 The user keys are exported with their full names (including user domains)
76
77 See also:
78 ksToStream()
79
80 Returns:
81 number of bytes written to output
82
83 Definition at line 2786 of file key.c.
84
85 References keyToStreamBasename().
86
87 Referenced by ksToStream().
88
89 ssize_t keyToStreamBasename (const Key * key, FILE * stream, const char *
90 parent, const size_t parentSize, unsigned long options)
91 Same as keyToStream() but tries to strip parentSize bytes from key name
92 if it matches parent .
93
94 Taking the example from keyToStream(), if parent is 'system/sw/xorg',
95 the generated string is of the form:
96
97 <key basename="Monitor/Monitor0/Name"
98 type="string" uid="root" gid="root" mode="0660">
99
100 <value>Samsung TFT panel</value>
101 <comment>My monitor</comment>
102 </key>
103
104 It usefull to produce more human readable XML output of a key when it
105 is being represented in a context that defines the parent key name. For
106 example:
107
108 <keyset parent="user/sw">
109 <key basename="kdbedit"..../>
110 <key basename="phototools"..../>
111 <key basename="myapp"..../>
112 </keyset>.fi
113
114 In the bove example, each <key> entry was generated by a call to keyToStreamBasename() having 'user/sw' as parent .
115
116 This method is used when ksToStream() is called with KDBOption::KDB_O_HIER option.
117
118 Parameters:
119 parentSize the maximum size of parent that will be used. If 0, the entire parent will be used.
120 parent the string (or part of it, defined by parentSize ) that will be used to strip from the key name.
121
122 Returns:
123 number of bytes written to output
124
125 Definition at line 2832 of file key.c.
126
127 References _Key::access, _Key::comment, _Key::data, _Key::dataSize, encode(), _Key::gid, KDB_O_CONDENSED, KDB_O_FULLNAME, KDB_O_FULLUGID, KDB_O_NUMBERS, _Key::key, KEY_TYPE_BINARY, KEY_TYPE_LINK, KEY_TYPE_STRING, KEY_TYPE_UNDEFINED, keyGetFullName(), keyIsDir(), keyIsUser(), strblen(), _Key::type, _Key::uid, and _Key::userDomain.
128
129 Referenced by keyToStream(), and ksToStream().
130
131 void* keySerialize (Key * key)
132 Return a block of memory with the entire key serialized, including
133 metainfo, value, comment and full name.
134
135 Deallocate it with a simple free().
136
137 See also:
138 keyUnserialize()
139
140 Definition at line 3236 of file key.c.
141
142 References _Key::comment, _Key::commentSize, _Key::data,
143 _Key::dataSize, KEY_METAINFO_SIZE, keyGetFullName(),
144 keyGetFullNameSize(), and _Key::recordSize.
145
146 Key* keyUnserialize (const void * serialized)
147 Given a membory block created by keySerialize(), unserialize it into a
148 Key structure and return it.
149
150 The serialized can be freed after this call, because memory will be
151 allocated for all elements of the new key;
152
153 See also:
154 keySerialize()
155
156 Definition at line 3279 of file key.c.
157
158 References _Key::comment, _Key::commentSize, _Key::data,
159 _Key::dataSize, KEY_METAINFO_SIZE, KEY_SWITCH_END, keyNew(), and
160 keySetName().
161
162
163
164Elektra Project 25 Mar 2007 Key :: Miscelaneous(3)