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

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

Add: added cvs variable $Id$ to source files.

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