Unpacker plugins API

Unpacker plugins extract files from archives.

Search engine invokes the appropriate plugin every time it needs for all of single file from archive. Plugin enumerates the files in archive and extracts acquired file returning the name of temporary file. In some cases the search engine enumerates the archive files and extract them one by one. In other cases it just requires the single necessary file to be extracted.

Placement

DLLs are usually stored in c:\program files\integra\plugins\unpackers. Search engine initialization code looks up this folder for *.dll and tries to load each of them as a plugin.

API

1. Plugin instance construction and initialization

 void* Constructor(void)

This procedure is called once per search engine session. Its main purpose is to load all necessary DLL, read configuration files and so on.

It returns the pointer to plugin object which is used in all subsequent calls as This argument.

2.  Plugin instance destruction

void Destructor( void *This )

It frees resources allocated by plugin instance during Constructor call.

This procedure is call on search engine termination.

3. Plugin features and options retrieval

const wchar_t* GetSolarixPluginProperty( void *This, int iProp, int iSub )

Search engine determines the features and characteristics of the plugin using this procedure. iProp and iSub are required property id and sub-id. String value of property is returned if possible. If property is not supported just returns NULL.

There are some minimal set of required properties:

iProp iSub Meaning
0 Must be "unpacker_plugin" for unpacker plugins
1 Plugin human readable name, e.q. "7Zip unpacker"
2 Copyright string
3 List of file detected extensions. Extensions are separated by ; for example "7z;7zip"

Future vesions of search engine may acquire another prorerties. Return NULL if you don't know the meaning of the acquired property.

4. Start extraction

void* StartExtraction( void *This, const wchar_t *Filename, const PluginOptions *Options )

This procedure opens the archive and returns the extraction context pointer which is used in all subsequent API calls. Each StartExtraction must return unique extraction context.

Please note that search engine can simultaneously open several archive and operates them independently.

5. Get next filename in archive

const wchar_t* ExtractNextFilename( void *This, void *Ctx )

First call after  StartExtraction returns the very first name of file in archive. Subsequent calls with the same Ctx must enumerates the file names in archive.

Please note that search engine can mix ExtractNextFilename and UnpackFile calls.

Returns NULL when no more name is available.

6. Extract file

const wchar_t* UnpackFile( void *This, void *Ctx, const wchar_t *Filename )

Plugin must unpack the file Filename from archive, store it in a temporary file and return the name of that temporary file.

Return NULL if extraction is impossible.

7. Finish extraction

void ExtractionComplete( void *This, void *Ctx )

Search engine calls this procedure when it does not need the archive any more. You must free all memory resources and close files associated with extraction context. Also you'd better delete all temporary file.


© Mental Computing 2009  rss  email  icq free counters Πειςθνγ@Mail.ru