]> git.ipfire.org Git - thirdparty/cups.git/blame - cgi-bin/testhi.c
Update svn:keyword properties.
[thirdparty/cups.git] / cgi-bin / testhi.c
CommitLineData
ef416fc2 1/*
f2d18633 2 * "$Id$"
ef416fc2 3 *
321d8d57 4 * Help index test program for CUPS.
ef416fc2 5 *
321d8d57 6 * Copyright 2007-2011 by Apple Inc.
f7deaa1a 7 * Copyright 1997-2007 by Easy Software Products.
ef416fc2 8 *
9 * These coded instructions, statements, and computer programs are the
bc44d920 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/".
ef416fc2 14 *
15 * Contents:
16 *
17 * main() - Test the help index code.
18 * list_nodes() - List nodes in an array...
19 */
20
21/*
22 * Include necessary headers...
23 */
24
25#include "cgi.h"
26
27
28/*
29 * Local functions...
30 */
31
ecdc0628 32static void list_nodes(const char *title, cups_array_t *nodes);
ef416fc2 33
34
35/*
36 * 'main()' - Test the help index code.
37 */
38
39int /* O - Exit status */
40main(int argc, /* I - Number of command-line arguments */
41 char *argv[]) /* I - Command-line arguments */
42{
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
ecdc0628 53 list_nodes("nodes", hi->nodes);
54 list_nodes("sorted", hi->sorted);
ef416fc2 55
56 /*
57 * Do any searches...
58 */
59
60 if (argc > 1)
61 {
62 search = helpSearchIndex(hi, argv[1], NULL, argv[2]);
63
64 if (search)
65 {
ecdc0628 66 list_nodes(argv[1], search->sorted);
ef416fc2 67 helpDeleteIndex(search);
68 }
69 else
70 printf("%s (0 nodes)\n", argv[1]);
71 }
72
73 helpDeleteIndex(hi);
74
75 /*
76 * Return with no errors...
77 */
78
79 return (0);
80}
81
82
83/*
84 * 'list_nodes()' - List nodes in an array...
85 */
86
87static void
ecdc0628 88list_nodes(const char *title, /* I - Title string */
89 cups_array_t *nodes) /* I - Nodes */
ef416fc2 90{
ecdc0628 91 int i; /* Looping var */
92 help_node_t *node; /* Current node */
ef416fc2 93
94
ecdc0628 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))
f7deaa1a 99 {
ecdc0628 100 if (node->anchor)
f7deaa1a 101 printf(" %d: %s#%s \"%s\"", i, node->filename, node->anchor,
ecdc0628 102 node->text);
ef416fc2 103 else
f7deaa1a 104 printf(" %d: %s \"%s\"", i, node->filename, node->text);
105
106 printf(" (%d words)\n", cupsArrayCount(node->words));
107 }
ef416fc2 108}
109
110
111/*
f2d18633 112 * End of "$Id$".
ef416fc2 113 */