Lines Matching defs:key
38 * is kept in memory, and a multi-key, hierarchical access mode is provided.
43 * - "key" is ASCII (a C string, in fact)
55 * Symbol table nodes contain a pointer to a key, a pointer to this
56 * key's data, and a pointer to the next node in the chain.
100 static struct sym *mknode(struct sym *next, char *key, void *data)
110 n->key = strdup(key);
113 if (n->key == NULL) {
114 sym_error = "sym node strdup(key) failed!";
122 * Search for a key in a single-level symbol table hierarchy.
124 static struct sym *find_key1(struct sym *sym, char *key)
127 if (strcmp(sym->key, key) == 0)
135 * Create a new key node, add it to the *end* of this list
137 static int add_key(SYM sym, char *key, void *data)
142 sym->sym = mknode(NULL, key, data);
149 sn->next = mknode(NULL, key, data);
166 * Add (key, data) to an existing symbol table
168 * If the key does not exist, a new key is added to the end of the list.
169 * If the key exists and the PUT_REPLACE flag is not supplied, return EEXIST.
170 * If a symbol table entry in a multi-part key is not a symbol table (i.e.
171 * element two of a three or more element key), return ENOTDIR.
177 * "key" is duplicated as needed, and is not modified.
180 * chop up key on commas
182 * search until a key element isn't found in the key tree, the key list is
183 * exhausted, or a key's data element is not a sub-tree
185 * if the key list is exhausted, return a "duplicate entry" error
187 * if the last found key's data element is not a sub-tree, return
190 * add new keys for sub-trees until key list is exhausted;
194 int sym_put(SYM sym, char *key, void *data, int flags)
196 const char **keys; /* key split into a 2d string array */
198 char *nkey; /* copy of 'key' -- before split */
205 nkey = strdup(key);
206 keys = splitstr(key, ",", NULL);
250 add_key(csym, *kk, data); /* last key */
262 * "key" is not modified.
263 * If the key cannot be found, NULL is returned
265 void *sym_get(SYM sym, char *key)
268 const char **keys; /* key split into a 2d string array */
276 nkey = strdup(key);
317 int sym_seq(SYM sym, DBT * key, DBT * data, int flags)
324 * specificly: sym_seq( .., "key,key") sets to Nth element of the 2nd
326 * sym_seq(.., "key,key,") sets to the first element of the 3rd
329 * sym_seq(.., "key,key") where both must be complete keys, sets
334 csym = (SYM) sym_get(sym, (char *)key->data);
341 key->data = sym->cursor->key;
350 key->data = sym->cursor->key;
363 key->data = sym->cursor->key;
394 printf("%s\n", se->key);
426 printf("%s", se->key);
431 printf("(%p) = %s (%p)\n", se->key, (char *)se->data,
458 free(se->key);