search script

This script manages the HTTP requests for free-text search.

filename_matches ($filetext, $advanced, $casesensitive, $file)

Function filename_matches tells if search results for $file should be kept for display.

  1. $filetext

    a string containing the desired name fragment or pattern

  2. $advanced

    an integer equal to 1 if $filetext is a pattern, 0 otherwise

  3. $casesensitive

    an integer equal to 1 if comparison is case-sensitive, 0 otherwise

  4. $file

    a string containing the filename to check

Result is 1 if fragment $filetext is present (either as a substring or a matching pattern) inside filename $file.

glimpsesearch ($searchtext, $filetext, $advanced, $casesensitive)

Function glimpsesearch searches the tree with glimpse.

  1. $searchtext

    a string containing the text to look for

  2. $filetext

    a string containing the desired name fragment or pattern

  3. $advanced

    an integer equal to 1 if $filetext is a pattern, 0 otherwise

  4. $casesensitive

    an integer equal to 1 if comparison is case-sensitive, 0 otherwise

Glimpse is launched to search the source-tree for the string given. Results are then filtered on the optional filename. The remaining hits are returned in an array.

swishsearch ($searchtext, $filetext, $advanced, $casesensitive)

Function swishsearch searches the tree with Swish-e.

  1. $searchtext

    a string containing the text to look for

  2. $filetext

    a string containing the desired name fragment or pattern

  3. $advanced

    an integer equal to 1 if $filetext is a pattern, 0 otherwise

  4. $casesensitive

    an integer equal to 1 if comparison is case-sensitive, 0 otherwise

Swish-e is launched to search the source-tree for the string given. Results are then filtered on the optional filename. The remaining hits are returned in an array.

checkvalidref ($file)

Function checkvalidref is a "$variable" substitution function. It returns CSS class name searchinvalid if the file timestamp is incorrect, meaning the file has been modified after genxref indexing. Otherwise, it returns an empty string.

  1. $file

    a string containing the filename to check

Since the search engines return OS-relative path, the filename must be prefixed with a / to observe LXR file designation rule.

printresults ($templ, $searchtext, @results)

Function printresults is a "$function" substitution function. It returns an HTML string which is the concatenation of its expanded argument applied to every search result.

  1. $templ

    a string containing the template (i.e. argument)

  2. $searchtext

    a string containing the looked-for text

  3. @results

    an array containing the search results

Because of the different nature of the results, processing is split depending on the search engines. With Glimpse, line for the hit was grabbed, while with Swish-e, only a relevance score is available.

Note:

search ()

Sub search is the main driver for free-text search.

It dispatches search to the correct search engine, then calls the result editor.

Note:

Script entry point

Builds the header and footer and launches search for the real job.