source: branches/branch-1-0/src/helpers/prfh2.c@ 297

Last change on this file since 297 was 264, checked in by pr, 21 years ago

Fix spelling errors.

  • Property svn:eol-style set to CRLF
  • Property svn:keywords set to Author Date Id Revision
File size: 24.4 KB
Line 
1
2/*
3 *@@sourcefile prfh2.c:
4 * contains more Presentation Manager helper functions
5 * which deal with Profile (Prf*) functions.
6 *
7 * This file is new with V0.9.4 (2000-07-26) [umoeller].
8 *
9 * As opposed to the functions in prfh.c, these require
10 * linking against other helpers. As a result, these have
11 * been separated from prfh.c to allow linking against
12 * prfh.obj only.
13 *
14 * Function prefixes:
15 * -- prfh* Prf (profile, INI) helper functions
16 *
17 * Note: Version numbering in this file relates to XWorkplace version
18 * numbering.
19 *
20 *@@header "helpers\prfh.h"
21 *@@added V0.9.4 (2000-07-27) [umoeller]
22 */
23
24/*
25 * Copyright (C) 1997-2000 Ulrich M”ller.
26 * This file is part of the "XWorkplace helpers" source package.
27 * This is free software; you can redistribute it and/or modify
28 * it under the terms of the GNU General Public License as published
29 * by the Free Software Foundation, in version 2 as it comes in the
30 * "COPYING" file of the XWorkplace main distribution.
31 * This program is distributed in the hope that it will be useful,
32 * but WITHOUT ANY WARRANTY; without even the implied warranty of
33 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
34 * GNU General Public License for more details.
35 */
36
37#define OS2EMX_PLAIN_CHAR
38 // this is needed for "os2emx.h"; if this is defined,
39 // emx will define PSZ as _signed_ char, otherwise
40 // as unsigned char
41
42#define INCL_DOSERRORS
43#define INCL_WINSHELLDATA
44#define INCL_WINERRORS
45#include <os2.h>
46
47#include <stdlib.h>
48#include <stdio.h>
49#include <string.h>
50
51#include "setup.h" // code generation and debugging options
52
53#include "helpers\dosh.h"
54#include "helpers\stringh.h"
55
56#include "helpers\prfh.h"
57#include "helpers\xprf.h"
58
59#pragma hdrstop
60
61/*
62 *@@category: Helpers\Profile (INI) helpers
63 */
64
65/*
66 * prfhINIError:
67 * this is called whenever an error occurs saving a
68 * profile. This will compose an error string and
69 * all the callback func fncbError.
70 *
71 *@@changed V0.9.0 [umoeller]: changed prototype's logfile to stdio FILE*
72 */
73
74ULONG prfhINIError(ULONG ulOptions,
75 FILE* fLog,
76 PFNWP fncbError,
77 PSZ pszErrorString)
78{
79 ULONG ulrc;
80 CHAR szError2[2000];
81
82 if (fncbError)
83 {
84 if (ulOptions == MB_ABORTRETRYIGNORE)
85 sprintf(szError2, "%s"
86 "\nPress 'Abort' to abort saving the INI files. This will restart the WPS to avoid loss of data."
87 "\nPress 'Retry' to attempt saving this INI file again. "
88 "\nPress 'Ignore' to ignore this error. This might help, but "
89 "also lead to more errors or loss of the currently processed data.",
90 pszErrorString);
91 else
92 sprintf(szError2, "%s\nPress 'Cancel' to abort shutdown. ", pszErrorString);
93 ulrc = ( (ULONG)(*fncbError)(0, 0, szError2, (MPARAM)ulOptions) );
94
95 }
96 else
97 ulrc = (MBID_ABORT);
98
99 if (fLog)
100 {
101 fprintf(fLog, " Error occurred: %s\n Return code: %s (%lu)\n",
102 pszErrorString,
103 (ulrc == MBID_ABORT) ? "MBID_ABORT"
104 : (ulrc == MBID_IGNORE) ? "MBID_IGNORE"
105 : (ulrc == MBID_RETRY) ? "MBID_RETRY"
106 : "unknown",
107 ulrc);
108 fflush(fLog);
109 }
110
111 return (ulrc);
112}
113
114/*
115 * prfhINIError2:
116 * like the previous func, but with additional info
117 * for the error string.
118 *
119 *@@changed V0.9.0 [umoeller]: changed prototype's logfile to stdio FILE*
120 */
121
122ULONG prfhINIError2(ULONG ulOptions,
123 const char *pcszINI,
124 FILE* fLog,
125 PFNWP fncbError,
126 PSZ pszErrorString)
127{
128 CHAR szError2[2000];
129 sprintf(szError2, "An error occurred copying the profile %s: \n%s",
130 pcszINI, pszErrorString);
131 return (prfhINIError(ulOptions, fLog, fncbError, szError2));
132}
133
134/*
135 *@@ prfhCopyProfile:
136 * this function copies a given profile entirely into a
137 * new file. hOld is the handle, pszOld the filename
138 * of the profile to be copied (e.g. HINI_USERPROFILE
139 * and "?:\OS2\OS2.INI"; pszNew must point to a
140 * buffer which will contain the new filename ending
141 * in ".XFL" after prfhCopyProfile returns
142 * (e.g. "?:\OS2\OS2.XFL").
143 *
144 * You may specify a callback procedure which gets
145 * called upon every copied application in the INI
146 * file; this way, you can provide a progress bar.
147 * The second callback, fncbError, gets called upon
148 * errors.
149 *
150 *@@changed V0.9.0 [umoeller]: this now calls prfhCopyApp.
151 *@@changed V0.9.0 [umoeller]: fixed crashes with lower-case INI file names.
152 *@@changed V0.9.0 [umoeller]: changed prototype's logfile to stdio FILE*
153 *@@changed V0.9.4 (2000-07-15) [umoeller]: this never reported any errors, causing 0-byte INI files without warning. Fixed.
154 */
155
156BOOL prfhCopyProfile(HAB hab, // in: anchor block
157 FILE* fLog, // in: stdio logfile or NULL for no log
158 HINI hOld, // in: HINI to copy
159 PSZ pszOld, // in: fully qualif. filename of hOld
160 PSZ pszNew, // out: new filename
161 PFNWP fncbUpdate, // in: progress callback
162 HWND hwnd, ULONG msg, ULONG ulCount, ULONG ulMax,
163 // in: passed to fncbUpdate
164 PFNWP fncbError) // in: error callback
165{
166 // BOOL rc = TRUE;
167 HINI hNew;
168 PSZ pApps, // pKeys,
169 pApp2; // , pKey2;
170 ULONG ulSizeOfAppsList; // , ulSizeOfKeysList; // , ulSizeOfData;
171 // CHAR szLog[1000]; // removed V0.9.0
172 #define MBID_NOERROR 999
173 ULONG ulErrorStatus = MBID_NOERROR;
174 PSZ p_;
175 CHAR szError2[2000];
176
177 if (fLog)
178 {
179 fprintf(fLog, " Entering prfhCopyProfile, params: "
180 "hiniOld 0x%lX, pszOld %s, pfnwpCallback 0x%lX, "
181 "hwnd 0x%lX, msg 0x%lX, ulCount 0x%lX, ulMax 0x%lX\n",
182 hOld,
183 pszOld,
184 (ULONG)fncbUpdate,
185 hwnd,
186 msg,
187 ulCount,
188 ulMax);
189 fflush(fLog);
190 }
191
192 if ( (!pszOld) || (!pszNew) )
193 ulErrorStatus = prfhINIError2(MB_CANCEL, pszOld, fLog, fncbError,
194 "Invalid name buffers given.");
195
196 if (ulErrorStatus == MBID_NOERROR)
197 {
198 strupr(pszOld);
199 strcpy(pszNew, pszOld);
200 p_ = strhistr(pszNew, ".INI");
201 if (!p_)
202 ulErrorStatus = prfhINIError2(MB_CANCEL, pszNew, fLog, fncbError,
203 "Error composing new filename.");
204 }
205
206 if (ulErrorStatus == MBID_NOERROR)
207 {
208 strcpy(p_, ".XFL");
209
210 // delete new profile, in case something's left
211 if (fLog)
212 fprintf(fLog, " DEL %s\n", pszNew);
213
214 DosDelete(pszNew);
215
216 // open new profile
217 if (fLog)
218 fprintf(fLog, " PrfOpenProfile %s\n", pszNew);
219
220 hNew = PrfOpenProfile(hab, pszNew);
221 if (!hNew)
222 ulErrorStatus = prfhINIError2(MB_CANCEL, pszNew, fLog, fncbError,
223 "Error creating temporary profile.");
224 }
225
226 // get size of applications list
227 if (ulErrorStatus == MBID_NOERROR)
228 {
229 if (!PrfQueryProfileSize(hOld, NULL, NULL, &ulSizeOfAppsList))
230 ulErrorStatus = prfhINIError2(MB_CANCEL, pszNew, fLog, fncbError,
231 "Error querying applications list size.");
232 else
233 if (ulSizeOfAppsList == 0)
234 ulErrorStatus = prfhINIError2(MB_CANCEL, pszNew, fLog, fncbError,
235 "Size of applications list cannot be 0.");
236 }
237
238 if (ulErrorStatus == MBID_NOERROR)
239 {
240 // do-while loop in case of MBID_RETRY
241 do
242 {
243 ulErrorStatus = MBID_NOERROR; // if we have a retry in the do-while loop
244
245 // get applications list
246 pApps = (PSZ)malloc(ulSizeOfAppsList);
247 pApp2 = pApps;
248 if (!PrfQueryProfileData(hOld,
249 NULL,
250 NULL,
251 pApps,
252 &ulSizeOfAppsList))
253 ulErrorStatus = prfhINIError2(MB_CANCEL, pszNew, fLog, fncbError,
254 "Could not query application list.");
255
256 // applications loop
257
258 while ( (*pApp2 != 0)
259 && (ulErrorStatus == MBID_NOERROR)
260 )
261 {
262 CHAR szErrorKey[1000];
263 // copy application (this will call prfhCopyKey in turn)
264 ULONG ulrc = prfhCopyApp(hOld,
265 pApp2,
266 hNew,
267 pApp2,
268 szErrorKey);
269
270 ulErrorStatus = MBID_ABORT;
271
272 switch (ulrc)
273 {
274 case 0: // no error
275 ulErrorStatus = MBID_NOERROR;
276 break;
277
278 case PRFERR_KEYSLIST:
279 // couldn't query keys list
280 sprintf(szError2,
281 "Error querying keys list for \"%s\".",
282 pApp2);
283 break;
284
285 case PRFERR_DATASIZE:
286 // couldn't query data size for key
287 sprintf(szError2,
288 "Error querying data size for \"%s\"/\"%s\".",
289 pApp2, szErrorKey);
290 break;
291
292 case ERROR_NOT_ENOUGH_MEMORY:
293 // couldn't allocate memory
294 sprintf(szError2,
295 "Error allocating memory for copying \"%s\"/\"%s\".",
296 pApp2, szErrorKey);
297 break;
298
299 case PRFERR_READ:
300 // couldn't read data from source (PrfQueryProfileData error)
301 sprintf(szError2,
302 "Error reading data from app \"%s\", key \"%s\".",
303 pApp2, szErrorKey);
304 break;
305
306 case PRFERR_WRITE:
307 // couldn't write data to target (PrfWriteProfileData error)
308 sprintf(szError2,
309 "Error writing data to app \"%s\", key \"%s\".",
310 pApp2, szErrorKey);
311 break;
312 }
313
314 if (ulErrorStatus != MBID_NOERROR) // V0.9.4 (2000-07-15) [umoeller]
315 {
316 ulErrorStatus = prfhINIError2(MB_ABORTRETRYIGNORE, pszNew, fLog, fncbError,
317 szError2);
318 }
319
320 if (fncbUpdate)
321 {
322 ULONG ulNow2, ulMax2;
323 ulNow2 = ((1000*(pApp2-pApps))/ulSizeOfAppsList) + (ulCount*1000);
324 ulMax2 = (ulMax+1)*1000; // ulAppsSize;
325 (*fncbUpdate)(hwnd, msg, (MPARAM)ulNow2, (MPARAM)ulMax2);
326 }
327
328 // go for next app
329 pApp2 += strlen(pApp2)+1;
330
331 if (ulErrorStatus == MBID_IGNORE)
332 // error occurred, but user pressed "Ignore":
333 // skip this app
334 ulErrorStatus = MBID_NOERROR;
335
336 } // end while (*pApp2 != 0) && MBID_NOERROR
337
338 if (pApps)
339 free(pApps);
340
341 if (fLog)
342 fprintf(fLog, " Done copying apps\n");
343
344 } while (ulErrorStatus == MBID_RETRY);
345 } // end if (ulErrorOccurred == MBID_NOERROR)
346
347 if (fLog)
348 fprintf(fLog, " PrfCloseProfile %s\n", pszNew);
349
350 PrfCloseProfile(hNew);
351 if (fncbUpdate)
352 (*fncbUpdate)(hwnd, msg, (MPARAM)(ulCount+1), (MPARAM)(ulMax+1));
353
354 if (fLog)
355 {
356 fprintf(fLog, " Leaving prfhCopyProfile.\n");
357 fflush(fLog);
358 }
359
360 return (ulErrorStatus == MBID_NOERROR); // FALSE if error occurred
361}
362
363/*
364 *@@ prfhSaveINIs:
365 * this will enforce saving of OS2.INI and OS2SYS.INI
366 * by calling prfhCopyProfile (above) on them; the therefrom
367 * resulting ".XFL" files will replace the original
368 * ".INI" files.
369 * Specify fncbUpdate and fncbError like in prfhCopyProfile.
370 *
371 *@@changed V0.9.0 [umoeller]: fixed crashes with lower-case INI file names.
372 *@@changed V0.9.0 [umoeller]: changed prototype's logfile to stdio FILE*
373 */
374
375APIRET prfhSaveINIs(HAB hab, // in: anchor block
376 FILE* fLog, // in: stdio logfile or NULL for no log
377 PFNWP fncbUpdate, // in: progress callback
378 HWND hwnd, ULONG msg, // in: params passed to fncbUpdate
379 PFNWP fncbError) // in: error callback
380{
381 PRFPROFILE Profiles;
382 APIRET arc = NO_ERROR, arc2;
383 BOOL brc = TRUE;
384
385 // FILESTATUS3 fs3;
386 CHAR szSysNew[CCHMAXPATH],
387 szUserNew[CCHMAXPATH],
388 szSysBackup[CCHMAXPATH],
389 szUserBackup[CCHMAXPATH];
390
391 // the following flag may be one of the following:
392 // MBID_NOERROR--- everything's fine, continue
393 // MBID_IGNORE --- error occurred, but ignore
394 // MBID_RETRY --- error occurred, but retry
395 // MBID_ABORT --- error occurred, abort saving
396 ULONG ulErrorOccurred = MBID_IGNORE;
397
398 if (fLog)
399 fprintf(fLog, " Entering prfhSaveINIs...\n");
400
401 /*
402 * get system profiles:
403 *
404 */
405
406 Profiles.cchUserName = Profiles.cchSysName = 0;
407 brc = PrfQueryProfile(hab, &Profiles);
408
409 if (!brc)
410 ulErrorOccurred = prfhINIError(MB_CANCEL, fLog, fncbError,
411 "Error querying system profiles size.");
412
413 if (ulErrorOccurred == MBID_IGNORE)
414 {
415 Profiles.pszUserName = (PSZ)malloc(Profiles.cchUserName);
416 Profiles.pszSysName = (PSZ)malloc(Profiles.cchSysName);
417 if ( (Profiles.pszSysName == NULL)
418 || (Profiles.pszUserName == NULL)
419 )
420 ulErrorOccurred = prfhINIError(MB_CANCEL, fLog, fncbError,
421 "Error allocating memory (1).");
422 }
423
424 if (ulErrorOccurred == MBID_IGNORE)
425 {
426 if (!PrfQueryProfile(hab, &Profiles))
427 ulErrorOccurred = prfhINIError(MB_CANCEL, fLog, fncbError,
428 "Error querying profiles (2).");
429 }
430
431 if (ulErrorOccurred == MBID_IGNORE)
432 {
433 if (fLog)
434 fprintf(fLog, " System profiles are %s, %s\n",
435 Profiles.pszUserName, Profiles.pszSysName);
436
437 /*
438 * create new profile names:
439 *
440 */
441
442 strcpy(szSysBackup, Profiles.pszSysName);
443 strcpy(strhistr(szSysBackup, ".INI"), ".BAK");
444 strcpy(szUserBackup, Profiles.pszUserName);
445 strcpy(strhistr(szUserBackup, ".INI"), ".BAK");
446
447 /*
448 * create OS2SYS.XFL:
449 *
450 */
451
452 if (fLog)
453 fprintf(fLog, " Storing %s in *.XFL\n",
454 Profiles.pszSysName);
455
456 if (!prfhCopyProfile(hab,
457 fLog,
458 HINI_SYSTEMPROFILE,
459 Profiles.pszSysName, // old filename
460 szSysNew, // new filename
461 fncbUpdate, hwnd, msg, 0, 1,
462 fncbError))
463 {
464 // abort, since prfhCopyProfile already has error handling
465 ulErrorOccurred = MBID_ABORT;
466 }
467 }
468
469 if (ulErrorOccurred == MBID_IGNORE)
470 {
471 // create OS2.XFL
472
473 if (fLog)
474 fprintf(fLog, " Storing %s in *.XFL\n",
475 Profiles.pszUserName);
476
477 if (!prfhCopyProfile(hab,
478 fLog,
479 HINI_USERPROFILE,
480 Profiles.pszUserName, szUserNew,
481 fncbUpdate, hwnd, msg, 1, 1,
482 fncbError))
483 {
484 // abort, since prfhCopyProfile already has error handling
485 ulErrorOccurred = MBID_ABORT;
486 }
487 }
488
489 /*
490 * renaming stuff for OS2SYS.INI
491 *
492 */
493
494 if (ulErrorOccurred == MBID_IGNORE)
495 {
496 do
497 {
498 ulErrorOccurred = MBID_IGNORE; // if we have a retry in the do-while loop
499
500 if (ulErrorOccurred == MBID_IGNORE)
501 {
502 // attrib -r -s -h -a OS2SYS.BAK
503 if (fLog)
504 fprintf(fLog, " ATTRIB -R -S -H -A %s\n",
505 szSysBackup);
506
507 arc2 = doshSetPathAttr(szSysBackup, FILE_NORMAL);
508 if (fLog)
509 fprintf(fLog, " rc2: %lu\n", arc2);
510
511 // delete OS2SYS.BAK
512 if (fLog)
513 fprintf(fLog, " DEL %s\n",
514 szSysBackup);
515
516 arc2 = DosDelete(szSysBackup);
517 if (fLog)
518 fprintf(fLog, " rc2: %lu\n", arc2);
519
520 // attrib -r -s -h -a OS2SYS.INI
521 if (fLog)
522 fprintf(fLog, " ATTRIB -R -S -H -A %s\n",
523 Profiles.pszSysName);
524
525 arc2 = doshSetPathAttr(Profiles.pszSysName, FILE_NORMAL);
526 if (fLog)
527 fprintf(fLog, " rc2: %lu\n", arc2);
528
529 // move OS2SYS.INI OS2SYS.BAK
530 if (fLog)
531 fprintf(fLog, " MOVE %s %s\n",
532 Profiles.pszSysName, szSysBackup);
533 arc = DosMove(Profiles.pszSysName, szSysBackup);
534 if (fLog)
535 fprintf(fLog, " rc: %lu\n", arc);
536
537 if (arc)
538 ulErrorOccurred = prfhINIError(MB_ABORTRETRYIGNORE, fLog, fncbError, "Error moving original system profile to backup.");
539 }
540
541 if (ulErrorOccurred == MBID_IGNORE)
542 {
543 if (fLog)
544 fprintf(fLog, " MOVE %s %s\n",
545 szSysNew, Profiles.pszSysName);
546 arc = DosMove(szSysNew, Profiles.pszSysName);
547 if (fLog)
548 fprintf(fLog, " rc: %lu\n", arc);
549 if (arc)
550 ulErrorOccurred = prfhINIError(MB_ABORTRETRYIGNORE, fLog, fncbError, "Error moving newly created profile to system profile.");
551 }
552 } while (ulErrorOccurred == MBID_RETRY);
553 }
554
555 /*
556 * renaming stuff for OS2.INI
557 *
558 */
559
560 if (ulErrorOccurred == MBID_IGNORE)
561 {
562 do
563 {
564 ulErrorOccurred = MBID_IGNORE; // if we have a retry in the do-while loop
565
566 if (ulErrorOccurred == MBID_IGNORE)
567 {
568 // attrib -r -s -h -a OS2.BAK
569 if (fLog)
570 fprintf(fLog, " ATTRIB -R -S -H -A %s\n",
571 szUserBackup);
572
573 arc2 = doshSetPathAttr(szUserBackup, FILE_NORMAL);
574 if (fLog)
575 fprintf(fLog, " rc2: %lu\n", arc2);
576
577 // delete OS2.BAK
578 if (fLog)
579 fprintf(fLog," DEL %s\n",
580 szUserBackup);
581
582 arc2 = DosDelete(szUserBackup);
583 if (fLog)
584 fprintf(fLog, " rc2: %lu\n", arc2);
585
586 // attrib -r -s -h -a OS2.INI
587 if (fLog)
588 fprintf(fLog, " ATTRIB -R -S -H -A %s\n",
589 Profiles.pszUserName);
590 arc2 = doshSetPathAttr(Profiles.pszUserName, FILE_NORMAL);
591 if (fLog)
592 fprintf(fLog, " rc2: %lu\n", arc2);
593
594 // move OS2.INI OS2.BAK
595 if (fLog)
596 fprintf(fLog, " MOVE %s %s\n",
597 Profiles.pszUserName, szUserBackup);
598 arc = DosMove(Profiles.pszUserName, szUserBackup);
599 if (fLog)
600 fprintf(fLog, " rc: %lu\n", arc);
601
602 if (arc)
603 ulErrorOccurred = prfhINIError(MB_ABORTRETRYIGNORE, fLog, fncbError, "Error moving original user profile to backup.");
604 }
605
606 if (ulErrorOccurred == MBID_IGNORE)
607 {
608 // move OS2.XFL OS2.INI
609 if (fLog)
610 fprintf(fLog, " MOVE %s %s\n",
611 szUserNew, Profiles.pszUserName);
612
613 arc = DosMove(szUserNew, Profiles.pszUserName);
614 if (fLog)
615 fprintf(fLog, " rc: %lu\n", arc);
616
617 if (arc)
618 ulErrorOccurred = prfhINIError(MB_ABORTRETRYIGNORE, fLog, fncbError, "Error moving newly created profile to user profile.");
619 }
620 } while (ulErrorOccurred == MBID_RETRY);
621 }
622
623 // DosExitCritSec();
624
625 if (ulErrorOccurred != MBID_IGNORE)
626 {
627 DosMove(szSysBackup, Profiles.pszSysName);
628 DosMove(szUserBackup, Profiles.pszUserName);
629 }
630
631 if (Profiles.pszSysName)
632 free(Profiles.pszSysName);
633 if (Profiles.pszUserName)
634 free(Profiles.pszUserName);
635
636 if (fLog)
637 fprintf(fLog, " Done with prfhSaveINIs\n");
638
639 if (ulErrorOccurred != MBID_IGNORE)
640 return (999);
641 else
642 return NO_ERROR;
643}
644
645#ifdef __PRFH2_MAIN__
646
647int main(int argc, char* argv[])
648{
649 APIRET arc = NO_ERROR;
650 PCSZ pcszSource,
651 pcszTarget,
652 pcszApp;
653 PXINI piniSource;
654 HINI hiniTarget;
655 BOOL fCloseSource = FALSE,
656 fCloseTarget = FALSE;
657 HAB hab = WinInitialize(0);
658 CHAR szFailing[1000];
659
660 if (argc < 4)
661 {
662 printf("%d\nprfh2 <sourcefile> <targetfile> <appname>\n", argc);
663 exit(2);
664 }
665
666 pcszSource = argv[1];
667 pcszTarget = argv[2];
668 pcszApp = argv[3];
669
670 if (arc = xprfOpenProfile(pcszSource,
671 &piniSource))
672 {
673 printf("xprfOpenProfile returned %d opening source INI \"%s\"\n",
674 arc,
675 pcszSource);
676 }
677 else
678 fCloseSource = TRUE;
679
680 if (!strcmp(pcszTarget, "USER"))
681 hiniTarget = HINI_USER;
682 else if (!strcmp(pcszTarget, "SYSTEM"))
683 hiniTarget = HINI_SYSTEM;
684 else
685 {
686 if (!(hiniTarget = PrfOpenProfile(hab, (PSZ)pcszTarget)))
687 {
688 printf("Cannot open source INI \"%s\"\n", pcszTarget);
689 arc = -1;
690 }
691 else
692 fCloseTarget = TRUE;
693 }
694
695 if (!arc)
696 {
697 if (arc = xprfCopyApp2(piniSource,
698 pcszApp,
699 hiniTarget,
700 pcszApp,
701 szFailing))
702 {
703 printf("Error %d copying application \"%s\" from %s to %s\n",
704 arc,
705 pcszApp,
706 pcszSource,
707 pcszTarget);
708 printf("Failing key: \"%s\"\n",
709 szFailing);
710 }
711 else
712 printf("Application \"%s\" successfully copied from %s to %s\n",
713 pcszApp,
714 pcszSource,
715 pcszTarget);
716 }
717
718 if (arc)
719 {
720 ERRORID eid;
721 eid = WinGetLastError(hab);
722
723 printf("WinGetLastError returned 0x%lX\n",
724 eid);
725 }
726
727
728 if (fCloseSource)
729 xprfCloseProfile(piniSource);
730 if (fCloseTarget)
731 PrfCloseProfile(hiniTarget);
732
733 WinTerminate(hab);
734
735 exit(arc);
736}
737
738#endif
Note: See TracBrowser for help on using the repository browser.