]> git.ipfire.org Git - thirdparty/cups.git/blob - cgi-bin/testhi.c
6f09caeb8304d0c5d4e200d5df7b5eaea6a9f41b
[thirdparty/cups.git] / cgi-bin / testhi.c
1 /*
2 * "$Id: testhi.c 177 2006-06-21 00:20:03Z jlovell $"
3 *
4 * Help index test program for the Common UNIX Printing System (CUPS).
5 *
6 * Copyright 1997-2005 by Easy Software Products.
7 *
8 * These coded instructions, statements, and computer programs are the
9 * property of Easy Software Products and are protected by Federal
10 * copyright law. Distribution and use rights are outlined in the file
11 * "LICENSE.txt" which should have been included with this file. If this
12 * file is missing or damaged please contact Easy Software Products
13 * at:
14 *
15 * Attn: CUPS Licensing Information
16 * Easy Software Products
17 * 44141 Airport View Drive, Suite 204
18 * Hollywood, Maryland 20636 USA
19 *
20 * Voice: (301) 373-9600
21 * EMail: cups-info@cups.org
22 * WWW: http://www.cups.org
23 *
24 * Contents:
25 *
26 * main() - Test the help index code.
27 * list_nodes() - List nodes in an array...
28 */
29
30 /*
31 * Include necessary headers...
32 */
33
34 #include "cgi.h"
35
36
37 /*
38 * Local functions...
39 */
40
41 static void list_nodes(const char *title, cups_array_t *nodes);
42
43
44 /*
45 * 'main()' - Test the help index code.
46 */
47
48 int /* O - Exit status */
49 main(int argc, /* I - Number of command-line arguments */
50 char *argv[]) /* I - Command-line arguments */
51 {
52 help_index_t *hi, /* Help index */
53 *search; /* Search index */
54
55
56 /*
57 * Load the help index...
58 */
59
60 hi = helpLoadIndex("testhi.index", ".");
61
62 list_nodes("nodes", hi->nodes);
63 list_nodes("sorted", hi->sorted);
64
65 /*
66 * Do any searches...
67 */
68
69 if (argc > 1)
70 {
71 search = helpSearchIndex(hi, argv[1], NULL, argv[2]);
72
73 if (search)
74 {
75 list_nodes(argv[1], search->sorted);
76 helpDeleteIndex(search);
77 }
78 else
79 printf("%s (0 nodes)\n", argv[1]);
80 }
81
82 helpDeleteIndex(hi);
83
84 /*
85 * Return with no errors...
86 */
87
88 return (0);
89 }
90
91
92 /*
93 * 'list_nodes()' - List nodes in an array...
94 */
95
96 static void
97 list_nodes(const char *title, /* I - Title string */
98 cups_array_t *nodes) /* I - Nodes */
99 {
100 int i; /* Looping var */
101 help_node_t *node; /* Current node */
102
103
104 printf("%s (%d nodes):\n", title, cupsArrayCount(nodes));
105 for (i = 1, node = (help_node_t *)cupsArrayFirst(nodes);
106 node;
107 i ++, node = (help_node_t *)cupsArrayNext(nodes))
108 if (node->anchor)
109 printf(" %d: %s#%s \"%s\"\n", i, node->filename, node->anchor,
110 node->text);
111 else
112 printf(" %d: %s \"%s\"\n", i, node->filename, node->text);
113 }
114
115
116 /*
117 * End of "$Id: testhi.c 177 2006-06-21 00:20:03Z jlovell $".
118 */