]> git.ipfire.org Git - thirdparty/cups.git/blame - cgi-bin/testhi.c
Remove svn:keywords since they cause svn_load_dirs.pl to complain about every file.
[thirdparty/cups.git] / cgi-bin / testhi.c
CommitLineData
ef416fc2 1/*
c07d5b2d 2 * "$Id: testhi.c 177 2006-06-21 00:20:03Z jlovell $"
ef416fc2 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
ecdc0628 41static void list_nodes(const char *title, cups_array_t *nodes);
ef416fc2 42
43
44/*
45 * 'main()' - Test the help index code.
46 */
47
48int /* O - Exit status */
49main(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
ecdc0628 62 list_nodes("nodes", hi->nodes);
63 list_nodes("sorted", hi->sorted);
ef416fc2 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 {
ecdc0628 75 list_nodes(argv[1], search->sorted);
ef416fc2 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
96static void
ecdc0628 97list_nodes(const char *title, /* I - Title string */
98 cups_array_t *nodes) /* I - Nodes */
ef416fc2 99{
ecdc0628 100 int i; /* Looping var */
101 help_node_t *node; /* Current node */
ef416fc2 102
103
ecdc0628 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);
ef416fc2 111 else
ecdc0628 112 printf(" %d: %s \"%s\"\n", i, node->filename, node->text);
ef416fc2 113}
114
115
116/*
c07d5b2d 117 * End of "$Id: testhi.c 177 2006-06-21 00:20:03Z jlovell $".
ef416fc2 118 */