]>
git.ipfire.org Git - thirdparty/cups.git/blob - cgi-bin/websearch.c
4 * Web search program for www.cups.org.
6 * Copyright 2007-2008 by Apple Inc.
7 * Copyright 1997-2007 by Easy Software Products.
9 * These coded instructions, statements, and computer programs are the
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/".
17 * websearch directory "search string"
21 * main() - Search a directory of help files.
22 * list_nodes() - List matching nodes.
26 * Include necessary headers...
36 static void list_nodes(const char *title
, cups_array_t
*nodes
);
40 * 'main()' - Test the help index code.
43 int /* O - Exit status */
44 main(int argc
, /* I - Number of command-line args */
45 char *argv
[]) /* I - Command-line arguments */
47 help_index_t
*hi
, /* Help index */
48 *search
; /* Search index */
49 char indexname
[1024]; /* Name of index file */
54 puts("Usage: websearch directory \"search terms\"");
59 * Load the help index...
62 snprintf(indexname
, sizeof(indexname
), "%s/.index", argv
[1]);
63 hi
= helpLoadIndex(indexname
, argv
[1]);
69 search
= helpSearchIndex(hi
, argv
[2], NULL
, NULL
);
72 list_nodes(argv
[1], search
->sorted
);
75 * Return with no errors...
83 * 'list_nodes()' - List nodes in an array...
87 list_nodes(const char *title
, /* I - Title string */
88 cups_array_t
*nodes
) /* I - Nodes */
90 help_node_t
*node
; /* Current node */
93 printf("%d\n", cupsArrayCount(nodes
));
94 for (node
= (help_node_t
*)cupsArrayFirst(nodes
);
96 node
= (help_node_t
*)cupsArrayNext(nodes
))
99 printf("%d|%s#%s|%s\n", node
->score
, node
->filename
, node
->anchor
,
102 printf("%d|%s|%s\n", node
->score
, node
->filename
, node
->text
);