expand.c 994 Bytes
Newer Older
Alexandre Julliard's avatar
Alexandre Julliard committed
1 2 3 4 5 6 7 8 9 10 11 12
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <windows.h>
#include <lzexpand.h>

int PASCAL WinMain(HINSTANCE hinstCurrent,
				HINSTANCE hinstPrevious,
				LPSTR lpCmdLine,
				int nCmdShow)
{
  OFSTRUCT SourceOpenStruct1, SourceOpenStruct2;
13
  char OriginalName[256];
Alexandre Julliard's avatar
Alexandre Julliard committed
14
  char FAR *lpzDestFile;
Alexandre Julliard's avatar
Alexandre Julliard committed
15 16
  DWORD dwreturn;
  HFILE hSourceFile, hDestFile;
Alexandre Julliard's avatar
Alexandre Julliard committed
17 18 19
  /* Most Windows compilers have something like this: */
  extern int _ARGC;
  extern char **_ARGV;
Alexandre Julliard's avatar
Alexandre Julliard committed
20

21 22 23 24 25 26
  hSourceFile = LZOpenFile(_ARGV[1], (LPOFSTRUCT) &SourceOpenStruct1, OF_READ);
  if ((_ARGC == 3) && (_ARGV[2] != NULL))
	lpzDestFile = _ARGV[2];
  else {
  	lpzDestFile = OriginalName;
  	GetExpandedName(_ARGV[1], lpzDestFile);
Alexandre Julliard's avatar
Alexandre Julliard committed
27 28 29 30
  };
  hDestFile = LZOpenFile(lpzDestFile, (LPOFSTRUCT) &SourceOpenStruct2,
			OF_CREATE | OF_WRITE);
  dwreturn = LZCopy(hSourceFile, hDestFile);
31 32 33 34
  if (dwreturn != 0)
	  fprintf(stderr,"LZCopy failed: return is %ld\n",dwreturn);
  LZClose(hSourceFile);
  LZClose(hDestFile);
Alexandre Julliard's avatar
Alexandre Julliard committed
35 36
  return dwreturn;
}