]>
Commit | Line | Data |
---|---|---|
226caca2 | 1 | /* |
2 | * "$Id$" | |
3 | * | |
5b9bc2e0 | 4 | * Help index test program for CUPS. |
226caca2 | 5 | * |
5b9bc2e0 | 6 | * Copyright 2007-2011 by Apple Inc. |
2d7b6d77 | 7 | * Copyright 1997-2007 by Easy Software Products. |
226caca2 | 8 | * |
9 | * These coded instructions, statements, and computer programs are the | |
4e8d321f | 10 | * property of Apple Inc. and are protected by Federal copyright |
11 | * law. Distribution and use rights are outlined in the file "LICENSE.txt" | |
12 | * which should have been included with this file. If this file is | |
13 | * file is missing or damaged, see the license at "http://www.cups.org/". | |
226caca2 | 14 | * |
15 | * Contents: | |
16 | * | |
921a23f4 | 17 | * main() - Test the help index code. |
18 | * list_nodes() - List nodes in an array... | |
226caca2 | 19 | */ |
20 | ||
21 | /* | |
22 | * Include necessary headers... | |
23 | */ | |
24 | ||
787da309 | 25 | #include "cgi.h" |
226caca2 | 26 | |
27 | ||
4dd6cea8 | 28 | /* |
29 | * Local functions... | |
30 | */ | |
31 | ||
aeffa1fb | 32 | static void list_nodes(const char *title, cups_array_t *nodes); |
4dd6cea8 | 33 | |
34 | ||
226caca2 | 35 | /* |
36 | * 'main()' - Test the help index code. | |
37 | */ | |
38 | ||
39 | int /* O - Exit status */ | |
40 | main(int argc, /* I - Number of command-line arguments */ | |
41 | char *argv[]) /* I - Command-line arguments */ | |
42 | { | |
4dd6cea8 | 43 | help_index_t *hi, /* Help index */ |
44 | *search; /* Search index */ | |
45 | ||
46 | ||
47 | /* | |
48 | * Load the help index... | |
49 | */ | |
50 | ||
51 | hi = helpLoadIndex("testhi.index", "."); | |
52 | ||
aeffa1fb | 53 | list_nodes("nodes", hi->nodes); |
54 | list_nodes("sorted", hi->sorted); | |
4dd6cea8 | 55 | |
2ee932a6 | 56 | /* |
57 | * Do any searches... | |
58 | */ | |
59 | ||
60 | if (argc > 1) | |
61 | { | |
2cd61226 | 62 | search = helpSearchIndex(hi, argv[1], NULL, argv[2]); |
2ee932a6 | 63 | |
64 | if (search) | |
65 | { | |
aeffa1fb | 66 | list_nodes(argv[1], search->sorted); |
2ee932a6 | 67 | helpDeleteIndex(search); |
68 | } | |
69 | else | |
70 | printf("%s (0 nodes)\n", argv[1]); | |
71 | } | |
72 | ||
4dd6cea8 | 73 | helpDeleteIndex(hi); |
74 | ||
226caca2 | 75 | /* |
76 | * Return with no errors... | |
77 | */ | |
78 | ||
79 | return (0); | |
80 | } | |
81 | ||
82 | ||
4dd6cea8 | 83 | /* |
84 | * 'list_nodes()' - List nodes in an array... | |
85 | */ | |
86 | ||
87 | static void | |
aeffa1fb | 88 | list_nodes(const char *title, /* I - Title string */ |
89 | cups_array_t *nodes) /* I - Nodes */ | |
4dd6cea8 | 90 | { |
aeffa1fb | 91 | int i; /* Looping var */ |
92 | help_node_t *node; /* Current node */ | |
4dd6cea8 | 93 | |
94 | ||
aeffa1fb | 95 | printf("%s (%d nodes):\n", title, cupsArrayCount(nodes)); |
96 | for (i = 1, node = (help_node_t *)cupsArrayFirst(nodes); | |
97 | node; | |
98 | i ++, node = (help_node_t *)cupsArrayNext(nodes)) | |
2d7b6d77 | 99 | { |
aeffa1fb | 100 | if (node->anchor) |
2d7b6d77 | 101 | printf(" %d: %s#%s \"%s\"", i, node->filename, node->anchor, |
aeffa1fb | 102 | node->text); |
4dd6cea8 | 103 | else |
2d7b6d77 | 104 | printf(" %d: %s \"%s\"", i, node->filename, node->text); |
105 | ||
106 | printf(" (%d words)\n", cupsArrayCount(node->words)); | |
107 | } | |
4dd6cea8 | 108 | } |
109 | ||
110 | ||
226caca2 | 111 | /* |
112 | * End of "$Id$". | |
113 | */ |