1 | /* |
---|
2 | * A utility to test functionality of Gerald Carter''s regio interface. |
---|
3 | * |
---|
4 | * Copyright (C) 2005 Timothy D. Morgan |
---|
5 | * |
---|
6 | * This program is free software; you can redistribute it and/or modify |
---|
7 | * it under the terms of the GNU General Public License as published by |
---|
8 | * the Free Software Foundation; version 2 of the License. |
---|
9 | * |
---|
10 | * This program is distributed in the hope that it will be useful, |
---|
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
13 | * GNU General Public License for more details. |
---|
14 | * |
---|
15 | * You should have received a copy of the GNU General Public License |
---|
16 | * along with this program; if not, write to the Free Software |
---|
17 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
---|
18 | * |
---|
19 | * $Id: lib-regfio.c 30 2005-07-16 14:31:27Z tim $ |
---|
20 | */ |
---|
21 | |
---|
22 | |
---|
23 | #include <stdlib.h> |
---|
24 | #include <stdio.h> |
---|
25 | #include <string.h> |
---|
26 | #include "../include/regfio.h" |
---|
27 | |
---|
28 | void printKeyTree(REGF_FILE* f, REGF_NK_REC* cur, char* prefix) |
---|
29 | { |
---|
30 | REGF_NK_REC* sub; |
---|
31 | char* sub_prefix; |
---|
32 | |
---|
33 | if(prefix != NULL) |
---|
34 | { |
---|
35 | sub_prefix = (char*)zalloc(strlen(prefix)+strlen(cur->keyname)+2); |
---|
36 | strcpy(sub_prefix, prefix); |
---|
37 | strcat(sub_prefix, "/"); |
---|
38 | } |
---|
39 | else |
---|
40 | sub_prefix = (char*)zalloc(strlen(cur->keyname)+2); |
---|
41 | |
---|
42 | strcat(sub_prefix, cur->keyname); |
---|
43 | |
---|
44 | printf("%s:KEY\n", sub_prefix); |
---|
45 | while ((sub = regfio_fetch_subkey(f, cur)) != NULL) |
---|
46 | printKeyTree(f, sub, sub_prefix); |
---|
47 | |
---|
48 | free(sub_prefix); |
---|
49 | } |
---|
50 | |
---|
51 | |
---|
52 | int main(int argc, char** argv) |
---|
53 | { |
---|
54 | if(argc < 2) |
---|
55 | { |
---|
56 | printf("ERROR: Requires 1 argument.\n"); |
---|
57 | return 1; |
---|
58 | } |
---|
59 | |
---|
60 | REGF_FILE* f = regfio_open( argv[1] ); |
---|
61 | REGF_NK_REC* root = regfio_rootkey(f); |
---|
62 | |
---|
63 | printKeyTree(f, root, NULL); |
---|
64 | regfio_close(f); |
---|
65 | /* |
---|
66 | REGF_NK_REC* regfio_rootkey( REGF_FILE *file ); |
---|
67 | REGF_NK_REC* regfio_fetch_subkey( REGF_FILE *file, REGF_NK_REC *nk ); |
---|
68 | */ |
---|
69 | |
---|
70 | return 0; |
---|
71 | } |
---|