Implement ReadFileEx and WriteFileEx (lpOverlappedCompletion routine
[wine] / libtest / expand.c
1 #include <stdlib.h>
2 #include <stdio.h>
3 #include <string.h>
4 #include <windows.h>
5 #include <lzexpand.h>
6
7 int PASCAL WinMain(HINSTANCE hinstCurrent,
8                                 HINSTANCE hinstPrevious,
9                                 LPSTR lpCmdLine,
10                                 int nCmdShow)
11 {
12   OFSTRUCT SourceOpenStruct1, SourceOpenStruct2;
13   char OriginalName[256];
14   char FAR *lpzDestFile;
15   DWORD dwreturn;
16   HFILE hSourceFile, hDestFile;
17   /* Most Windows compilers have something like this: */
18   extern int _ARGC;
19   extern char **_ARGV;
20
21   hSourceFile = LZOpenFile(_ARGV[1], (LPOFSTRUCT) &SourceOpenStruct1, OF_READ);
22   if ((_ARGC == 3) && (_ARGV[2] != NULL))
23         lpzDestFile = _ARGV[2];
24   else {
25         lpzDestFile = OriginalName;
26         GetExpandedName(_ARGV[1], lpzDestFile);
27   };
28   hDestFile = LZOpenFile(lpzDestFile, (LPOFSTRUCT) &SourceOpenStruct2,
29                         OF_CREATE | OF_WRITE);
30   dwreturn = LZCopy(hSourceFile, hDestFile);
31   if (dwreturn != 0)
32           fprintf(stderr,"LZCopy failed: return is %ld\n",dwreturn);
33   LZClose(hSourceFile);
34   LZClose(hDestFile);
35   return dwreturn;
36 }