Playing a non-existent CD should fail instead of crash.
[wine/multimedia.git] / libtest / expand.c
blobcb2e31a04d281b182b5c36e9c40dcc07c5120052
1 #include <stdlib.h>
2 #include <stdio.h>
3 #include <string.h>
4 #include <windows.h>
5 #include <lzexpand.h>
7 int PASCAL WinMain(HINSTANCE hinstCurrent,
8 HINSTANCE hinstPrevious,
9 LPSTR lpCmdLine,
10 int nCmdShow)
12 OFSTRUCT SourceOpenStruct1, SourceOpenStruct2;
13 char OriginalName[256], WriteBuf[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;
22 MessageBox((HWND)NULL, (LPCSTR)_ARGV[1], (LPCSTR)"_ARGV[1]:", MB_OK);
23 MessageBox((HWND)NULL, (LPCSTR)_ARGV[2], (LPCSTR)"_ARGV[2]:", MB_OK);
25 hSourceFile = LZOpenFile(_ARGV[1], (LPOFSTRUCT) &SourceOpenStruct1,
26 OF_READ);
28 wsprintf(WriteBuf, "Source File Handle: %d\nNo. of args: %d",
29 hSourceFile, _ARGC);
30 MessageBox((HWND)NULL, (LPCSTR)WriteBuf, (LPCSTR)NULL, MB_OK);
32 if ((_ARGC == 3) && (_ARGV[2] != NULL)) lpzDestFile = _ARGV[2];
33 else
35 lpzDestFile = OriginalName;
36 GetExpandedName(_ARGV[1], lpzDestFile);
39 MessageBox((HWND)NULL, (LPCSTR)lpzDestFile, (LPCSTR)"Destination File",
40 MB_OK);
42 hDestFile = LZOpenFile(lpzDestFile, (LPOFSTRUCT) &SourceOpenStruct2,
43 OF_CREATE | OF_WRITE);
44 wsprintf(WriteBuf, "Destination File Handle: %d\nNo. of args: %d",
45 hDestFile, _ARGC-1);
46 MessageBox((HWND)NULL, (LPCSTR)WriteBuf, (LPCSTR)NULL, MB_OK);
48 dwreturn = LZCopy(hSourceFile, hDestFile);
50 if (dwreturn == LZERROR_BADINHANDLE)
51 MessageBox((HWND)NULL, (LPCSTR)"LZERROR_BADINHANDLE\n", (LPCSTR)NULL, MB_OK);
52 if (dwreturn == LZERROR_BADOUTHANDLE)
53 MessageBox((HWND)NULL, (LPCSTR)"LZERROR_BADOUTHANDLE\n", (LPCSTR)NULL, MB_OK);
54 if (dwreturn == LZERROR_BADVALUE)
55 MessageBox((HWND)NULL, (LPCSTR)"LZERROR_BADVALUE\n", (LPCSTR)NULL, MB_OK);
56 if (dwreturn == LZERROR_GLOBALLOC)
57 MessageBox((HWND)NULL, (LPCSTR)"LZERROR_GLOBALLOC\n", (LPCSTR)NULL, MB_OK);
58 if (dwreturn == LZERROR_GLOBLOCK)
59 MessageBox((HWND)NULL, (LPCSTR)"LZERROR_GLOBLOCK\n", (LPCSTR)NULL, MB_OK);
60 if (dwreturn == LZERROR_READ)
61 MessageBox((HWND)NULL, (LPCSTR)"LZERROR_READ\n", (LPCSTR)NULL, MB_OK);
62 if (dwreturn == LZERROR_WRITE)
63 MessageBox((HWND)NULL, (LPCSTR)"LZERROR_WRITE\n", (LPCSTR)NULL, MB_OK);
64 if ((long)dwreturn > 0L)
65 {wsprintf((LPSTR)WriteBuf, (LPCSTR)"Successful decompression from %s to %s\n",
66 _ARGV[1], lpzDestFile);
67 MessageBox((HWND)NULL, (LPSTR)WriteBuf, (LPCSTR)NULL, MB_OK);
69 LZClose(hSourceFile); LZClose(hDestFile);
70 return dwreturn;