]>
git.ipfire.org Git - thirdparty/cups.git/blob - cgi-bin/websearch.c
351f92db08a6dae2d07b02817ca8bb8308d4e49b
4 * Web search program for www.cups.org.
6 * Copyright 2007-2009 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(help_index_t
*hi
, const char *title
,
41 * 'main()' - Test the help index code.
44 int /* O - Exit status */
45 main(int argc
, /* I - Number of command-line args */
46 char *argv
[]) /* I - Command-line arguments */
48 help_index_t
*hi
, /* Help index */
49 *search
; /* Search index */
50 char indexname
[1024]; /* Name of index file */
55 puts("Usage: websearch directory \"search terms\"");
60 * Load the help index...
63 snprintf(indexname
, sizeof(indexname
), "%s/.index", argv
[1]);
64 hi
= helpLoadIndex(indexname
, argv
[1]);
70 search
= helpSearchIndex(hi
, argv
[2], NULL
, NULL
);
73 list_nodes(hi
, argv
[1], search
->sorted
);
76 * Return with no errors...
84 * 'list_nodes()' - List nodes in an array...
88 list_nodes(help_index_t
*hi
, /* I - Help index */
89 const char *title
, /* I - Title string */
90 cups_array_t
*nodes
) /* I - Nodes */
92 help_node_t
*node
, /* Current node */
93 *file
; /* File node */
96 printf("%d\n", cupsArrayCount(nodes
));
97 for (node
= (help_node_t
*)cupsArrayFirst(nodes
);
99 node
= (help_node_t
*)cupsArrayNext(nodes
))
103 file
= helpFindNode(hi
, node
->filename
, NULL
);
104 printf("%d|%s#%s|%s|%s\n", node
->score
, node
->filename
, node
->anchor
,
105 node
->text
, file
? file
->text
: node
->filename
);
108 printf("%d|%s|%s|%s\n", node
->score
, node
->filename
, node
->text
,