CNSearch 1.5.1
Creating Plugin
To create a plugin, you should unpack 'plugin.zip', located in '/manual' folder of the distribution kit. This file contains the source code of the plugin processing test files.
For correct functioning, plugin must have a correct extension and possess the following set of functions:
Name of a function |
Description of a function |
char *get_info(void) |
The function returns a string - information about plugin (its name) |
char *get_mime(void) |
The function returns a string - list of MIME TYPEs, separated by vertical line "|" and processed by this plugin; |
char* get_shortdesc(void) |
The function returns a string - short name of a file type |
char* get_range(void) |
The function returns a string - field "Range" of HTTP header (see RFC2068); if field "Range" is not used, the function returns NULL. |
char* get_title(void) |
The function returns a string - document title. If value is NULL, URL of the document is displayed. TPluginWord* get_word(unsigned char *d, unsigned long filesize) The main function returns a pointer to 'TpluginWord' structure, containing a word which should be added to the search index. This function must return words contained in a document in series.
|
TpluginWord structure looks as follows:
typedef struct {
char word[32];
int rel;
bool end;
} TPluginWord;
where:
- word - a word with appended nulls \0x00 to the right. Thus, maximum length of a word is 32 symbols.
- rel - word relevancy; it can range from 1 to 256. Recommended values are 1 to 4. In the example, each word has relevancy of 1, with exception of word written in CAPITAL LETTERS. Its relevancy is 2.
- end - has 'true' value if there are no more words in a document. In this case 'word' and 'rel' are ignored.
Methods, used by the system for generation of plugin functions:
- get_info(), get_mime(), and get_shortdesc() functions are called once during the plugin loading;
- get_title() function is called once for each document; afterwards get_word() function is called for corresponding documents until 'end' field of TwordPlugin structure acquires 'true' value.