mUnzip 1.0

mUnzip is a .zip decompressing DLL for mIRC, by Kamek, based on Info-ZIP's Unzip program source.

mUnzip works with signals (introducted in mIRC 6.0) to let the script interact with the DLL.

Unzip function syntax

The Unzip function syntax is: Unzip [-flags] [signal] [pattern] <zip file> <output path>

For example: //echo -a $dll(mUnzip.dll, Unzip, -dS mysignal C:\MyFile.zip "C:\Extract dir\"

Where the flags are:

Behavior flags
You can use only one of these flags at a time
-o Always overwrite files
-E Extract only newer files (skip replacing files that are older than your local files)
If you don't specify any of the flags above, a replacing signal will be sent.
Informational flags
-t Test zip file (test integrity without extracting)
-v List all the files that are available, but without extracting
-z Show zip file comment
-Z Shows extensive information about the specified archive (beware, you'll be FLOODED with information)
Other flags
-d Use the specified folder names (keep the same dir structure from the zip file, highly recommended)
-M Custom wildmask pattern: a pattern will specify which files should be extracted. Currently, only one pattern is allowed (you can't, for example, use *.txt;*.exe).
-Qn Makes the operation more quiet: -Q1 echoes few information, -Q2 hides any echo signals
-S Custom signal name: right after the flags, you'll need to specify a suffix for the signal.

You shouldn't use any behavior or informational flag at the same time, and shouldn't mix behavior and informational flags. -d and -Qn don't work with the information flags. Also, please note that, even when you're just using one of the informational flags, you still need to specify a target directory (valid or not).

Return values

The function will either return a success or an error code.

Success codes are in the format S_OK |+[status flags], where [status flags] can contain w if some minor wrong thing happened (for example, a file that couldn't be extracted because it needed a password) or c if the zip file has a comment.

If you use the -v flag, however, the returned value will have some more information:
S_OK |+[status flags]|<total compressed size> <total decompressed size> <avg compression ratio>|<total number of files>

The error codes are in the format E_[name] [description], where [name] is a small name for the error (that will remain constant) and [description] is a human-readable description. For example: E_INVPARM Invalid parameters.

Signals

mUnzip uses signals to communicate with mIRC and interact with the script. The format of a signal is: on *:SIGNAL:<signal>:<code>

If you don't specify any custom signal name (-S flag), it will be mUnzip. If you do, it will be mUnzip_suffix (like mUnzip_Sample).

When a signal is called, $1 corresponds to the "event" that can be handled and $2- corresponds to the parameters.

The following are the supported events:

echo
Called when the DLL wants to output something. As this DLL is based on a console program, much of its output may look like a DOS utility output.
You can use the -Qn flag to determine the amount of information you want echoed.
list
Occurs when you use the -v flag. A 'list' event is called for each file in the archive.
$2- corresponds to a string in the following format:
<filename>|<size> <comp. size> <ratio>|<date> <time>|<crc> <deflating method> +[status flags]
For now, the only status flag is e (encrypted file).
You should use $gettok() to parse this list.
comment
Occurs when you use the -z flag. Each line in the zip comments will call this event, where $2- is the line.
replace
Occurs when you don't use neither -E nor -o flags. $2- will correspond to the filename in your computer which is about to be overwritten.
You can use /dll mUnzip.dll Reply <reply> to answer what to do. The reply can be "yes", "no", "yes all" or "no all". "no" is the default action.
extracted
Occurs when the DLL has just finished extracting the specified filename. $2- will be <filename>|<file size>. If you want to stop extracting any files further, you can use /dll mUnzip.dll Reply stop.

Other features

The DLLInfo function returns some information about the DLL. You don't really need any parameters.

Example of use: //echo -a $dll(mUnzip.dll, DLLInfo, .)

The code I made for DLL is actually just an interface for the wonderful work the people from Info-ZIP made in their Unzip application. If you want to know more about Info-ZIP, you should visit http://www.info-zip.org/.