source: trunk/src/version/version.cpp@ 78

Last change on this file since 78 was 78, checked in by phaller, 26 years ago

Add: ported VERSION from WINE, enables a few installers to run

File size: 24.5 KB
Line 
1/*
2 * Win32 Version resource APIs for OS/2
3 *
4 * Implementation of VERSION.DLL - File Installer routines
5 * Copyright 1996,1997 Marcus Meissner
6 * Copyright 1997 David Cuthbert
7 * Copyright 1998 Sander van Leeuwen (sandervl@xs4all.nl)
8 *
9 * Project Odin Software License can be found in LICENSE.TXT
10 */
11
12
13#include <os2win.h>
14#include <stdio.h>
15#include <stdlib.h>
16#include <string.h>
17#include <misc.h>
18#include <unicode.h>
19#include "version.h"
20
21#include "lzexpand.h"
22
23
24/*
25#include "winver.h"
26#include "windef.h"
27*/
28
29
30/******************************************************************************/
31/******************************************************************************/
32BOOL WIN32API VERSION_GetFileVersionInfoA(LPTSTR lpszFile,
33 DWORD dwHandle,
34 DWORD cbBuf,
35 LPVOID lpvData)
36{
37 dprintf(("VERSION: GetFileVersionInfoA %s\n",
38 lpszFile));
39
40 return GetVersionStruct(lpszFile,
41 (char *)lpvData,
42 cbBuf);
43}
44/******************************************************************************/
45/******************************************************************************/
46BOOL WIN32API VERSION_GetFileVersionInfoW(LPWSTR lpszFile,
47 DWORD dwHandle,
48 DWORD cbBuf,
49 LPVOID lpvData)
50{
51 BOOL rc;
52 char *astring = UnicodeToAsciiString(lpszFile);
53
54 dprintf(("VERSION: GetFileVersionInfoW (%s,%08xh,%08xh,%08xh)\n",
55 lpszFile,
56 dwHandle,
57 cbBuf,
58 lpvData));
59
60 rc = GetVersionStruct(astring, (char *)lpvData, cbBuf);
61 FreeAsciiString(astring);
62 return(rc);
63}
64/******************************************************************************/
65/******************************************************************************/
66DWORD WIN32API VERSION_GetFileVersionInfoSizeA(LPTSTR lpszFile,
67 LPDWORD lpdwHandle)
68{
69 dprintf(("VERSION: GetFileVersionInfoSizeA(%s,%08xh)\n",
70 lpszFile,
71 lpdwHandle));
72
73 if(lpdwHandle)
74 lpdwHandle = 0;
75
76 return GetVersionSize(lpszFile);
77}
78/******************************************************************************/
79/******************************************************************************/
80DWORD WIN32API VERSION_GetFileVersionInfoSizeW(LPWSTR lpszFile,
81 LPDWORD lpdwHandle)
82{
83 char *astring = UnicodeToAsciiString(lpszFile);
84 DWORD rc;
85
86 dprintf(("VERSION: GetFileVersionInfoSizeW(%08xh,%08xh)\n",
87 lpszFile,
88 lpdwHandle));
89
90 if(lpdwHandle)
91 lpdwHandle = 0;
92
93 rc = GetVersionSize(astring);
94 FreeAsciiString(astring);
95 return(rc);
96}
97/******************************************************************************/
98/******************************************************************************/
99BOOL WIN32API VERSION_VerQueryValueA(const LPVOID pBlock,
100 LPTSTR lpSubBlock,
101 LPVOID lplpBuffer,
102 PUINT puLen)
103{
104 dprintf(("VERSION: VerQueryValueA(%08xh,%08xh,%08xh,%08xh) not implemented\n",
105 pBlock,
106 lpSubBlock,
107 lplpBuffer,
108 puLen));
109
110 return TRUE;
111}
112/******************************************************************************/
113/******************************************************************************/
114/*KSO Sun 24.05.1998*/
115BOOL WIN32API VERSION_VerQueryValueW(const LPVOID pBlock,
116 LPWSTR lpSubBlock,
117 LPVOID lplpBuffer,
118 PUINT puLen)
119{
120 dprintf(("VERSION: VerQueryValueW(%08xh,%08xh,%08xh,%08xh) not implemented\n",
121 pBlock,
122 lpSubBlock,
123 lplpBuffer,
124 puLen));
125
126 return TRUE;
127}
128/******************************************************************************/
129/******************************************************************************/
130
131
132
133/******************************************************************************
134 *
135 * void ver_dstring(
136 * char const * prologue,
137 * char const * teststring,
138 * char const * epilogue )
139 *
140 * This function will print via dprintf[_]ver to stddeb the prologue string,
141 * followed by the address of teststring and the string it contains if
142 * teststring is non-null or "(null)" otherwise, and then the epilogue
143 * string followed by a new line.
144 *
145 * Revision history
146 * 30-May-1997 Dave Cuthbert (dacut@ece.cmu.edu)
147 * Original implementation as dprintf[_]ver_string
148 * 05-Jul-1997 Dave Cuthbert (dacut@ece.cmu.edu)
149 * Fixed problem that caused bug with tools/make_debug -- renaming
150 * this function should fix the problem.
151 * 15-Feb-1998 Dimitrie Paun (dimi@cs.toronto.edu)
152 * Modified it to make it print the message using only one
153 * dprintf[_]ver call.
154 *
155 *****************************************************************************/
156
157static void ver_dstring(char const * prologue,
158 char const * teststring,
159 char const * epilogue )
160{
161 dprintf(("VERSION: ver_dstring(%s, %s, %s)\n",
162 prologue,
163 teststring,
164 epilogue));
165}
166
167
168/******************************************************************************
169 *
170 * int testFileExistence(
171 * char const * path,
172 * char const * file )
173 *
174 * Tests whether a given path/file combination exists. If the file does
175 * not exist, the return value is zero. If it does exist, the return
176 * value is non-zero.
177 *
178 * Revision history
179 * 30-May-1997 Dave Cuthbert (dacut@ece.cmu.edu)
180 * Original implementation
181 *
182 *****************************************************************************/
183
184static int testFileExistence(char const * path,
185 char const * file )
186{
187 char filename[1024];
188 int filenamelen;
189 OFSTRUCT fileinfo;
190 int retval;
191
192 fileinfo.cBytes = sizeof(OFSTRUCT);
193
194 strcpy(filename, path);
195 filenamelen = strlen(filename);
196
197 /* Add a trailing \ if necessary */
198 if(filenamelen)
199 {
200 if(filename[filenamelen - 1] != '\\')
201 strcat(filename, "\\");
202 }
203 else /* specify the current directory */
204 strcpy(filename, ".\\");
205
206 /* Create the full pathname */
207 strcat(filename, file);
208
209 if(OpenFile(filename, &fileinfo, OF_EXIST) == HFILE_ERROR)
210 retval = 0;
211 else
212 retval = 1;
213
214 return retval;
215}
216
217
218/******************************************************************************
219 *
220 * int testFileExclusiveExistence(
221 * char const * path,
222 * char const * file )
223 *
224 * Tests whether a given path/file combination exists and ensures that no
225 * other programs have handles to the given file. If the file does not
226 * exist or is open, the return value is zero. If it does exist, the
227 * return value is non-zero.
228 *
229 * Revision history
230 * 30-May-1997 Dave Cuthbert (dacut@ece.cmu.edu)
231 * Original implementation
232 *
233 *****************************************************************************/
234
235static int testFileExclusiveExistence(char const * path,
236 char const * file )
237{
238 char filename[1024];
239 int filenamelen;
240 OFSTRUCT fileinfo;
241 int retval;
242
243 fileinfo.cBytes = sizeof(OFSTRUCT);
244
245 strcpy(filename, path);
246 filenamelen = strlen(filename);
247
248 /* Add a trailing \ if necessary */
249 if(filenamelen)
250 {
251 if(filename[filenamelen - 1] != '\\')
252 strcat(filename, "\\");
253 }
254 else /* specify the current directory */
255 strcpy(filename, ".\\");
256
257 /* Create the full pathname */
258 strcat(filename, file);
259
260 if(OpenFile(filename,
261 &fileinfo,
262 OF_EXIST | OF_SHARE_EXCLUSIVE) == HFILE_ERROR)
263 retval = 0;
264 else
265 retval = 1;
266
267 return retval;
268}
269
270
271/*****************************************************************************
272 *
273 * VerFindFile() [VER.8]
274 * Determines where to install a file based on whether it locates another
275 * version of the file in the system. The values VerFindFile returns are
276 * used in a subsequent call to the VerInstallFile function.
277 *
278 * Revision history:
279 * 30-May-1997 Dave Cuthbert (dacut@ece.cmu.edu)
280 * Reimplementation of VerFindFile from original stub.
281 *
282 ****************************************************************************/
283
284/* VerFindFile32A [VERSION.5] */
285DWORD WIN32API VERSION_VerFindFileA(UINT flags,
286 LPCSTR lpszFilename,
287 LPCSTR lpszWinDir,
288 LPCSTR lpszAppDir,
289 LPSTR lpszCurDir,
290 UINT *lpuCurDirLen,
291 LPSTR lpszDestDir,
292 UINT *lpuDestDirLen )
293{
294 DWORD retval;
295 char curDir[256];
296 char destDir[256];
297 unsigned int curDirSizeReq;
298 unsigned int destDirSizeReq;
299
300 retval = 0;
301
302 /* Print out debugging information */
303 dprintf(("VERSION: VerFindFileA(%08xh,%s,%s,%s,%08xh,%08xh,%08xh,%08xh)\n",
304 flags,
305 lpszFilename,
306 lpszWinDir,
307 lpszAppDir,
308 lpszCurDir,
309 lpuCurDirLen,
310 lpszDestDir,
311 lpuDestDirLen));
312
313 ver_dstring("\tlpszFilename = ", lpszFilename, "");
314 ver_dstring("\tlpszWinDir = ", lpszWinDir, "");
315 ver_dstring("\tlpszAppDir = ", lpszAppDir, "");
316
317 /* Figure out where the file should go; shared files default to the
318 system directory */
319
320 strcpy(curDir, "");
321 strcpy(destDir, "");
322
323 if(flags & VFFF_ISSHAREDFILE)
324 {
325 GetSystemDirectoryA(destDir, 256);
326
327 /* Were we given a filename? If so, try to find the file. */
328 if(lpszFilename)
329 {
330 if(testFileExistence(destDir, lpszFilename))
331 {
332 strcpy(curDir, destDir);
333
334 if(!testFileExclusiveExistence(destDir, lpszFilename))
335 retval |= VFF_FILEINUSE;
336 }
337 else
338 if(lpszAppDir && testFileExistence(lpszAppDir,
339 lpszFilename))
340 {
341 strcpy(curDir, lpszAppDir);
342 retval |= VFF_CURNEDEST;
343
344 if(!testFileExclusiveExistence(lpszAppDir, lpszFilename))
345 retval |= VFF_FILEINUSE;
346 }
347 }
348 }
349 else
350 if(!(flags & VFFF_ISSHAREDFILE))
351 { /* not a shared file */
352 if(lpszAppDir)
353 {
354 char systemDir[256];
355 GetSystemDirectoryA(systemDir, 256);
356
357 strcpy(destDir, lpszAppDir);
358
359 if(lpszFilename)
360 {
361 if(testFileExistence(lpszAppDir, lpszFilename))
362 {
363 strcpy(curDir, lpszAppDir);
364
365 if(!testFileExclusiveExistence(lpszAppDir, lpszFilename))
366 retval |= VFF_FILEINUSE;
367 }
368 else
369 if(testFileExistence(systemDir, lpszFilename))
370 {
371 strcpy(curDir, systemDir);
372 retval |= VFF_CURNEDEST;
373
374 if(!testFileExclusiveExistence(systemDir, lpszFilename))
375 retval |= VFF_FILEINUSE;
376 }
377 }
378 }
379 }
380
381 curDirSizeReq = strlen(curDir) + 1;
382 destDirSizeReq = strlen(destDir) + 1;
383
384
385
386 /* Make sure that the pointers to the size of the buffers are
387 valid; if not, do NOTHING with that buffer. If that pointer
388 is valid, then make sure that the buffer pointer is valid, too! */
389
390 if(lpuDestDirLen && lpszDestDir)
391 {
392 if(*lpuDestDirLen < destDirSizeReq)
393 {
394 retval |= VFF_BUFFTOOSMALL;
395 if (*lpuDestDirLen)
396 {
397 strncpy(lpszDestDir, destDir, *lpuDestDirLen - 1);
398 lpszDestDir[*lpuDestDirLen - 1] = '\0';
399 }
400 }
401 else
402 strcpy(lpszDestDir, destDir);
403
404 *lpuDestDirLen = destDirSizeReq;
405 }
406
407 if(lpuCurDirLen && lpszCurDir)
408 {
409 if(*lpuCurDirLen < curDirSizeReq)
410 {
411 retval |= VFF_BUFFTOOSMALL;
412 if (*lpuCurDirLen)
413 {
414 strncpy(lpszCurDir, curDir, *lpuCurDirLen - 1);
415 lpszCurDir[*lpuCurDirLen - 1] = '\0';
416 }
417 }
418 else
419 strcpy(lpszCurDir, curDir);
420
421 *lpuCurDirLen = curDirSizeReq;
422 }
423
424 dprintf(("VERSION: VerFindFileA ret = %lu (%s%s%s)\n", retval,
425 (retval & VFF_CURNEDEST) ? "VFF_CURNEDEST " : "",
426 (retval & VFF_FILEINUSE) ? "VFF_FILEINUSE " : "",
427 (retval & VFF_BUFFTOOSMALL) ? "VFF_BUFFTOOSMALL " : ""));
428
429 ver_dstring("\t(Exit) lpszCurDir = ", lpszCurDir, "");
430
431 return retval;
432}
433
434/* VerFindFile32W [VERSION.6] */
435DWORD WIN32API VERSION_VerFindFileW(UINT flags,
436 LPWSTR filename,
437 LPWSTR windir,
438 LPWSTR appdir,
439 LPWSTR curdir,
440 UINT *pcurdirlen,
441 LPWSTR destdir,
442 UINT *pdestdirlen)
443{
444 UINT curdirlen,
445 destdirlen;
446 LPSTR wfn,
447 wwd,
448 wad,
449 wdd,
450 wcd;
451 DWORD ret;
452
453 wfn = UnicodeToAsciiString(filename );
454 wwd = UnicodeToAsciiString(windir );
455 wad = UnicodeToAsciiString(appdir );
456 wcd = (LPSTR)HeapAlloc( GetProcessHeap(), 0, *pcurdirlen );
457 wdd = (LPSTR)HeapAlloc( GetProcessHeap(), 0, *pdestdirlen );
458
459 ret = VERSION_VerFindFileA(flags,
460 wfn,
461 wwd,
462 wad,
463 wcd,
464 &curdirlen,
465 wdd,
466 &destdirlen);
467
468 AsciiToUnicodeN(wcd,curdir,*pcurdirlen);
469 AsciiToUnicodeN(wdd,destdir,*pdestdirlen);
470 *pcurdirlen = strlen(wcd);
471 *pdestdirlen = strlen(wdd);
472
473 FreeAsciiString(wfn );
474 FreeAsciiString(wwd );
475 FreeAsciiString(wad );
476 FreeAsciiString(wcd );
477 FreeAsciiString(wdd );
478 return ret;
479}
480
481static LPBYTE _fetch_versioninfo(LPSTR fn,VS_FIXEDFILEINFO **vffi)
482{
483 DWORD alloclen;
484 LPBYTE buf;
485 DWORD ret;
486
487 alloclen = 1000;
488 buf = (LPBYTE)malloc(alloclen);
489
490 while (1)
491 {
492 ret = VERSION_GetFileVersionInfoA(fn,
493 0,
494 alloclen,
495 buf);
496 if (!ret)
497 {
498 free(buf);
499 return 0;
500 }
501
502 if (alloclen<*(WORD*)buf)
503 {
504 free(buf);
505 alloclen = *(WORD*)buf;
506 buf = (LPBYTE)malloc(alloclen);
507 }
508 else
509 {
510 *vffi = (VS_FIXEDFILEINFO*)(buf+0x14);
511
512 if ((*vffi)->dwSignature == 0x004f0049) /* hack to detect unicode */
513 *vffi = (VS_FIXEDFILEINFO*)(buf+0x28);
514
515 if ((*vffi)->dwSignature != VS_FFI_SIGNATURE)
516 dprintf(("VERSION: _fetch_versioninfo: Bad VS_FIXEDFILEINFO signature 0x%08lx\n",
517 (*vffi)->dwSignature));
518
519 return buf;
520 }
521 }
522}
523
524static DWORD _error2vif(DWORD error)
525{
526 switch (error)
527 {
528 case ERROR_ACCESS_DENIED:
529 return VIF_ACCESSVIOLATION;
530
531 case ERROR_SHARING_VIOLATION:
532 return VIF_SHARINGVIOLATION;
533
534 default:
535 return 0;
536 }
537}
538
539
540/******************************************************************************
541 * VerInstallFile32A [VERSION.7]
542 */
543DWORD WIN32API VERSION_VerInstallFileA(UINT flags,
544 LPCSTR srcfilename,
545 LPCSTR destfilename,
546 LPCSTR srcdir,
547 LPCSTR destdir,
548 LPCSTR curdir,
549 LPSTR tmpfile,
550 UINT *tmpfilelen )
551{
552 LPCSTR pdest;
553 char destfn[260],
554 tmpfn[260],
555 srcfn[260];
556 HFILE hfsrc,
557 hfdst;
558 DWORD attr,
559 ret,
560 xret,
561 tmplast;
562 LPBYTE buf1,buf2;
563 OFSTRUCT ofs;
564
565 dprintf(("VERSION: VerInstallFileA(%x,%s,%s,%s,%s,%s,%p,%d)\n",
566 flags,
567 srcfilename,
568 destfilename,
569 srcdir,
570 destdir,
571 curdir,
572 tmpfile,
573 *tmpfilelen));
574
575#if 1
576 dprintf(("VERSION: VersInstallFileA not implemented\n"));
577
578 return 0;
579#else
580 xret = 0;
581
582 sprintf(srcfn,
583 "%s\\%s",
584 srcdir,
585 srcfilename);
586
587 if (!destdir || !*destdir)
588 pdest = srcdir;
589 else
590 pdest = destdir;
591
592 sprintf(destfn,
593 "%s\\%s",
594 pdest,
595 destfilename);
596
597 hfsrc=LZOpenFileA(srcfn,
598 &ofs,
599 OF_READ);
600
601 if (hfsrc==HFILE_ERROR)
602 return VIF_CANNOTREADSRC;
603
604 sprintf(tmpfn,"%s\\%s",pdest,destfilename);
605 tmplast=strlen(pdest)+1;
606 attr = GetFileAttributesA(tmpfn);
607 if (attr!=-1) {
608 if (attr & FILE_ATTRIBUTE_READONLY) {
609 LZClose(hfsrc);
610 return VIF_WRITEPROT;
611 }
612 /* FIXME: check if file currently in use and return VIF_FILEINUSE */
613 }
614 attr = -1;
615 if (flags & VIFF_FORCEINSTALL) {
616 if (tmpfile[0]) {
617 sprintf(tmpfn,"%s\\%s",pdest,tmpfile);
618 tmplast = strlen(pdest)+1;
619 attr = GetFileAttributesA(tmpfn);
620 /* if it exists, it has been copied by the call before.
621 * we jump over the copy part...
622 */
623 }
624 }
625 if (attr == -1) {
626 char *s;
627
628 GetTempFileNameA(pdest,"ver",0,tmpfn); /* should not fail ... */
629 s=strrchr(tmpfn,'\\');
630 if (s)
631 tmplast = s-tmpfn;
632 else
633 tmplast = 0;
634 hfdst = OpenFile(tmpfn,&ofs,OF_CREATE);
635 if (hfdst == HFILE_ERROR) {
636 LZClose(hfsrc);
637 return VIF_CANNOTCREATE; /* | translated dos error */
638 }
639 ret = LZCopy(hfsrc,hfdst);
640 _lclose(hfdst);
641 if (((long) ret) < 0) {
642 /* translate LZ errors into VIF_xxx */
643 switch (ret) {
644 case LZERROR_BADINHANDLE:
645 case LZERROR_READ:
646 case LZERROR_BADVALUE:
647 case LZERROR_UNKNOWNALG:
648 ret = VIF_CANNOTREADSRC;
649 break;
650 case LZERROR_BADOUTHANDLE:
651 case LZERROR_WRITE:
652 ret = VIF_OUTOFMEMORY; /* FIXME: correct? */
653 break;
654 case LZERROR_GLOBALLOC:
655 case LZERROR_GLOBLOCK:
656 ret = VIF_OUTOFSPACE;
657 break;
658 default: /* unknown error, should not happen */
659 ret = 0;
660 break;
661 }
662 if (ret) {
663 LZClose(hfsrc);
664 return ret;
665 }
666 }
667 }
668 xret = 0;
669 if (!(flags & VIFF_FORCEINSTALL)) {
670 VS_FIXEDFILEINFO *destvffi,*tmpvffi;
671 buf1 = _fetch_versioninfo(destfn,&destvffi);
672 if (buf1) {
673 buf2 = _fetch_versioninfo(tmpfn,&tmpvffi);
674 if (buf2) {
675 char *tbuf1,*tbuf2;
676 UINT len1,len2;
677
678 len1=len2=40;
679
680 /* compare file versions */
681 if ((destvffi->dwFileVersionMS > tmpvffi->dwFileVersionMS)||
682 ((destvffi->dwFileVersionMS==tmpvffi->dwFileVersionMS)&&
683 (destvffi->dwFileVersionLS > tmpvffi->dwFileVersionLS)
684 )
685 )
686 xret |= VIF_MISMATCH|VIF_SRCOLD;
687 /* compare filetypes and filesubtypes */
688 if ((destvffi->dwFileType!=tmpvffi->dwFileType) ||
689 (destvffi->dwFileSubtype!=tmpvffi->dwFileSubtype)
690 )
691 xret |= VIF_MISMATCH|VIF_DIFFTYPE;
692 if (VerQueryValueA(buf1,"\\VarFileInfo\\Translation",(LPVOID*)&tbuf1,&len1) &&
693 VerQueryValueA(buf2,"\\VarFileInfo\\Translation",(LPVOID*)&tbuf2,&len2)
694 ) {
695 /* irgendwas mit tbuf1 und tbuf2 machen
696 * generiert DIFFLANG|MISMATCH
697 */
698 }
699 free(buf2);
700 } else
701 xret=VIF_MISMATCH|VIF_SRCOLD;
702 free(buf1);
703 }
704 }
705 if (xret) {
706 if (*tmpfilelen<strlen(tmpfn+tmplast)) {
707 xret|=VIF_BUFFTOOSMALL;
708 DeleteFileA(tmpfn);
709 } else {
710 strcpy(tmpfile,tmpfn+tmplast);
711 *tmpfilelen = strlen(tmpfn+tmplast)+1;
712 xret|=VIF_TEMPFILE;
713 }
714 } else {
715 if (-1!=GetFileAttributesA(destfn))
716 if (!DeleteFileA(destfn)) {
717 xret|=_error2vif(GetLastError())|VIF_CANNOTDELETE;
718 DeleteFileA(tmpfn);
719 LZClose(hfsrc);
720 return xret;
721 }
722 if ((!(flags & VIFF_DONTDELETEOLD)) &&
723 curdir &&
724 *curdir &&
725 lstrcmpiA(curdir,pdest)
726 ) {
727 char curfn[260];
728
729 sprintf(curfn,"%s\\%s",curdir,destfilename);
730 if (-1!=GetFileAttributesA(curfn)) {
731 /* FIXME: check if in use ... if it is, VIF_CANNOTDELETECUR */
732 if (!DeleteFileA(curfn))
733 xret|=_error2vif(GetLastError())|VIF_CANNOTDELETECUR;
734 }
735 }
736 if (!MoveFileA(tmpfn,destfn)) {
737 xret|=_error2vif(GetLastError())|VIF_CANNOTRENAME;
738 DeleteFileA(tmpfn);
739 }
740 }
741 LZClose(hfsrc);
742 return xret;
743#endif
744}
745
746
747/* VerInstallFile32W [VERSION.8] */
748DWORD WIN32API VERSION_VerInstallFileW(UINT flags,
749 LPWSTR srcfilename,
750 LPWSTR destfilename,
751 LPWSTR srcdir,
752 LPWSTR destdir,
753 LPWSTR curdir,
754 LPWSTR tmpfile,
755 UINT *tmpfilelen )
756{
757 LPSTR wsrcf,
758 wsrcd,
759 wdestf,
760 wdestd,
761 wtmpf,
762 wcurd;
763 DWORD ret;
764
765 wsrcf = UnicodeToAsciiString(srcfilename );
766 wsrcd = UnicodeToAsciiString(srcdir );
767 wdestf = UnicodeToAsciiString(destfilename );
768 wdestd = UnicodeToAsciiString(destdir );
769 wtmpf = UnicodeToAsciiString(tmpfile );
770 wcurd = UnicodeToAsciiString(curdir );
771
772 ret = VERSION_VerInstallFileA(flags,
773 wsrcf,
774 wdestf,
775 wsrcd,
776 wdestd,
777 wcurd,
778 wtmpf,
779 tmpfilelen);
780 if (!ret)
781 AsciiToUnicodeN(wtmpf,
782 tmpfile,
783 *tmpfilelen);
784
785 FreeAsciiString(wsrcf);
786 FreeAsciiString(wsrcd);
787 FreeAsciiString(wdestf);
788 FreeAsciiString(wdestd);
789 FreeAsciiString(wtmpf);
790
791 if (wcurd)
792 FreeAsciiString(wcurd);
793
794 return ret;
795}
796
797
798/***********************************************************************
799 * VerLanguageName32A [VERSION.9]
800 */
801DWORD WIN32API VERSION_VerLanguageNameA(UINT wLang,
802 LPSTR szLang,
803 UINT nSize)
804{
805 char buffer[80];
806 LPCSTR name;
807 DWORD result;
808
809 dprintf(("VERSION: VerLanguageNameA(%08xh,%08xh,%08xh) not implemented.\n",
810 wLang,
811 szLang,
812 nSize));
813
814#if 0
815 /*
816 * First, check \System\CurrentControlSet\control\Nls\Locale\<langid>
817 * from the registry.
818 */
819
820 sprintf( buffer,
821 "\\System\\CurrentControlSet\\control\\Nls\\Locale\\%08x",
822 wLang );
823
824 result = RegQueryValueA(HKEY_LOCAL_MACHINE,
825 buffer,
826 szLang,
827 (LPDWORD)&nSize );
828 if (result == ERROR_SUCCESS ||
829 result == ERROR_MORE_DATA)
830 return nSize;
831
832 /*
833 * If that fails, use the internal table
834 * (actually, Windows stores the names in a string table resource ...)
835 */
836
837 name = WINE_GetLanguageName( wLang );
838 lstrcpynA( szLang, name, nSize );
839 return lstrlenA( name );
840#endif
841
842 return 0;
843}
844
845/***********************************************************************
846 * VerLanguageName32W [VERSION.10]
847 */
848DWORD WIN32API VERSION_VerLanguageNameW(UINT wLang,
849 LPWSTR szLang,
850 UINT nSize )
851{
852 char buffer[80];
853 LPWSTR keyname;
854 LPCSTR name;
855 DWORD result;
856
857 dprintf(("VERSION: VerLanguageNameW(%08xh,%08xh,%08xh) not implemented.\n",
858 wLang,
859 szLang,
860 nSize));
861
862#if 0
863 /*
864 * First, check \System\CurrentControlSet\control\Nls\Locale\<langid>
865 * from the registry.
866 */
867
868 sprintf( buffer,
869 "\\System\\CurrentControlSet\\control\\Nls\\Locale\\%08x",
870 wLang );
871
872 keyname = HEAP_strdupAtoW( GetProcessHeap(), 0, buffer );
873 result = RegQueryValueW( HKEY_LOCAL_MACHINE, keyname, szLang, (LPDWORD)&nSize );
874 HeapFree( GetProcessHeap(), 0, keyname );
875
876 if (result == ERROR_SUCCESS ||
877 result == ERROR_MORE_DATA)
878 return nSize;
879
880 /*
881 * If that fails, use the internal table
882 * (actually, Windows stores the names in a string table resource ...)
883 */
884
885 name = WINE_GetLanguageName( wLang );
886 lstrcpynAtoW( szLang, name, nSize );
887 return lstrlenA( name );
888#else
889 return 0;
890#endif
891}
892
893
Note: See TracBrowser for help on using the repository browser.