home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
napalm.napnet.hu
/
2015-02-12.napalm.napnet.hu.tar
/
napalm.napnet.hu
/
programok
/
kommunikacio
/
mpp700.exe
/
nGZIPn.cpp
< prev
next >
Wrap
C/C++ Source or Header
|
2001-01-30
|
2KB
|
84 lines
//----------------------------------------------------------------------------
// nGZIPn.dll - compression engine for mIRC
// 01.02.2001 (c) Necroman - necroman@europe.com, irc://irc.undernet.org/mIRC
//----------------------------------------------------------------------------
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <stdio.h>
#include "zlib\\zlib.h"
#define BUFSIZE 0x80000
extern "C"
{
//----------------------------------------------------------------------------
int __stdcall zip(HWND mWnd, HWND aWnd, char *data, char *parms, BOOL show, BOOL nopause)
{
const char *result = "$false";
//open source (decompressed) file
FILE *src_file;
if (src_file = fopen(data,"rb"))
{
//open destionation (compressed) file
gzFile dest_file;
if (dest_file = gzopen(strcat(data,".gz"),"wb9"))
{
//compress data
char buf[BUFSIZE];
do
{
int bytes = fread(buf,1,BUFSIZE,src_file);
if (!gzwrite(dest_file,buf,bytes)) break;
if (feof(src_file)) result = "$true";
if (bytes != BUFSIZE) break;
} while (true);
gzclose(dest_file);
}
fclose(src_file);
}
strcpy(data,result);
return 3;
}
//----------------------------------------------------------------------------
int __stdcall unzip(HWND mWnd, HWND aWnd, char *data, char *parms, BOOL show, BOOL nopause)
{
const char *result = "$false";
//open source (compressed) file
gzFile src_file;
if (src_file = gzopen(strcat(strcpy(parms,data),".gz"),"rb"))
{
//open destination (uncompressed) file
FILE *dest_file;
if (dest_file = fopen(data,"wb"))
{
//decompress data
char buf[BUFSIZE];
do
{
int bytes = gzread(src_file,buf,BUFSIZE);
if (!bytes) result = "$true";
if (bytes < 1) break;
if ((DWORD)bytes != fwrite(buf,1,bytes,dest_file)) break;
} while (true);
fclose(dest_file);
}
gzclose(src_file);
}
strcpy(data,result);
return 3;
}
//----------------------------------------------------------------------------
int __stdcall version(HWND mWnd, HWND aWnd, char *data, char *parms, BOOL show, BOOL nopause)
{
strcpy(data,"nGZIPn 1.0 - (c) 2001 Necroman - necroman@europe.com, #mIRC @ Undernet");
return 3;
}
//----------------------------------------------------------------------------
void __stdcall LoadDll(PVOID) {}
}