Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2415 lines
68 KiB

  1. #include "precomp.h"
  2. #pragma hdrstop
  3. /* File: iinterp.c */
  4. /**************************************************************************/
  5. /* Install: INF Install section interpreter
  6. /**************************************************************************/
  7. INT APIENTRY EncryptCDData(UCHAR *, UCHAR *, UCHAR *, INT, INT, INT, UCHAR *);
  8. BOOL APIENTRY FGetCmo(INT Line, UINT *pcFields, CMO * pcmo);
  9. /**/
  10. #define cmoNil ((CMO)0)
  11. /**/
  12. #define spcNil ((SPC)0)
  13. #define spcUndoActionsAndExit ((SPC)13)
  14. #define spcAddSectionFilesToCopyList ((SPC)14)
  15. #define spcAddSectionKeyFileToCopyList ((SPC)15)
  16. #define spcAddNthSectionFileToCopyList ((SPC)16)
  17. #define spcBackupSectionFiles ((SPC)17)
  18. #define spcBackupSectionKeyFile ((SPC)18)
  19. #define spcBackupNthSectionFile ((SPC)19)
  20. #define spcRemoveSectionFiles ((SPC)20)
  21. #define spcRemoveSectionKeyFile ((SPC)21)
  22. #define spcRemoveNthSectionFile ((SPC)22)
  23. #define spcCreateDir ((SPC)23)
  24. #define spcRemoveDir ((SPC)24)
  25. #define spcCreateIniSection ((SPC)26)
  26. #define spcReplaceIniSection ((SPC)30)
  27. #define spcRemoveIniSection ((SPC)31)
  28. #define spcCreateIniKeyNoValue ((SPC)32)
  29. #define spcCreateIniKeyValue ((SPC)33)
  30. #define spcReplaceIniKeyValue ((SPC)34)
  31. #define spcRemoveIniKeyValue ((SPC)35)
  32. #define spcRemoveIniKey ((SPC)36)
  33. #define spcSetEnvVariableValue ((SPC)37)
  34. #define spcCreateProgManGroup ((SPC)38)
  35. #define spcRemoveProgManGroup ((SPC)39)
  36. #define spcCreateProgManItem ((SPC)40)
  37. #define spcRemoveProgManItem ((SPC)41)
  38. #define spcStampResource ((SPC)44)
  39. #define spcExt ((SPC)47)
  40. #define spcCopyFilesInCopyList ((SPC)48)
  41. #define spcCloseSys ((SPC)49)
  42. #define spcShowProgManGroup ((SPC)50)
  43. #define spcDumpCopyList ((SPC)51)
  44. #define spcCreateSysIniKeyValue ((SPC)52)
  45. #define spcClearCopyList ((SPC)53)
  46. #define spcGetCopyListCost ((SPC)54)
  47. #define spcSetupGetCopyListCost ((SPC)55)
  48. #define spcParseSharedAppList ((SPC)56)
  49. #define spcInstallSharedAppList ((SPC)57)
  50. #define spcSearchDirList ((SPC)58)
  51. #define spcSetupDOSApps ((SPC)59)
  52. #define spcChangeBootIniTimeout ((SPC)60)
  53. #define spcCreateCommonProgManGroup ((SPC)63)
  54. #define spcRemoveCommonProgManGroup ((SPC)64)
  55. #define spcShowCommonProgManGroup ((SPC)65)
  56. #define spcCreateCommonProgManItem ((SPC)66)
  57. #define spcRemoveCommonProgManItem ((SPC)67)
  58. #define spcAppend 1
  59. #define spcOverwrite 5
  60. #define spcPrepend 6
  61. #define spcVital 7
  62. static SCP rgscpCommands[] =
  63. {
  64. { "CREATEDIR", spcCreateDir },
  65. { "REMOVEDIR", spcRemoveDir },
  66. { "ADDSECTIONFILESTOCOPYLIST", spcAddSectionFilesToCopyList },
  67. { "ADDSECTIONKEYFILETOCOPYLIST", spcAddSectionKeyFileToCopyList },
  68. { "ADDNTHSECTIONFILETOCOPYLIST", spcAddNthSectionFileToCopyList },
  69. { "COPYFILESINCOPYLIST", spcCopyFilesInCopyList },
  70. { "CREATEINISECTION", spcCreateIniSection },
  71. { "REPLACEINISECTION", spcReplaceIniSection },
  72. { "REMOVEINISECTION", spcRemoveIniSection },
  73. { "CREATEINIKEYNOVALUE", spcCreateIniKeyNoValue },
  74. { "CREATEINIKEYVALUE", spcCreateIniKeyValue },
  75. { "REPLACEINIKEYVALUE", spcReplaceIniKeyValue },
  76. { "REMOVEINIKEYVALUE", spcRemoveIniKeyValue },
  77. { "REMOVEINIKEY", spcRemoveIniKey },
  78. { "CREATESYSINIKEYVALUE", spcCreateSysIniKeyValue },
  79. { "CREATEPROGMANGROUP", spcCreateProgManGroup },
  80. { "CREATEPROGMANITEM", spcCreateProgManItem },
  81. { "REMOVEPROGMANITEM", spcRemoveProgManItem },
  82. { "SHOWPROGMANGROUP", spcShowProgManGroup},
  83. { "STAMPRESOURCE", spcStampResource },
  84. { "CLOSE-SYSTEM", spcCloseSys },
  85. { "EXIT", spcExt },
  86. { "DUMPCOPYLIST", spcDumpCopyList },
  87. { "CLEARCOPYLIST", spcClearCopyList },
  88. { "GETCOPYLISTCOST", spcGetCopyListCost },
  89. { "SETUPGETCOPYLISTCOST", spcSetupGetCopyListCost },
  90. { "SEARCHDIRLIST", spcSearchDirList },
  91. { "SETUPDOSAPPS", spcSetupDOSApps },
  92. { "CHANGEBOOTINITIMEOUT", spcChangeBootIniTimeout },
  93. { "REMOVEPROGMANGROUP", spcRemoveProgManGroup },
  94. { "CREATECOMMONPROGMANGROUP", spcCreateCommonProgManGroup },
  95. { "REMOVECOMMONPROGMANGROUP", spcRemoveCommonProgManGroup },
  96. { "SHOWCOMMONPROGMANGROUP", spcShowCommonProgManGroup },
  97. { "CREATECOMMONPROGMANITEM", spcCreateCommonProgManItem },
  98. { "REMOVECOMMONPROGMANITEM", spcRemoveCommonProgManItem },
  99. #ifdef UNUSED
  100. { "BACKUPSECTIONFILES", spcBackupSectionFiles },
  101. { "BACKUPSECTIONKEYFILE", spcBackupSectionKeyFile },
  102. { "BACKUPNTHSECTIONFILE", spcBackupNthSectionFile },
  103. { "REMOVESECTIONFILES", spcRemoveSectionFiles },
  104. { "REMOVESECTIONKEYFILE", spcRemoveSectionKeyFile },
  105. { "REMOVENTHSECTIONFILE", spcRemoveNthSectionFile },
  106. { "SETENVVARIABLEVALUE", spcSetEnvVariableValue },
  107. { "UNDOACTIONSANDEXIT", spcUndoActionsAndExit },
  108. { "PARSESHAREDAPPLIST", spcParseSharedAppList },
  109. { "INSTALLSHAREDAPPLIST", spcInstallSharedAppList },
  110. #endif /* UNUSED */
  111. { NULL, spcNil }
  112. };
  113. static SCP rgscpOptions[] =
  114. {
  115. { "A", spcAppend },
  116. { "APPEND", spcAppend },
  117. { "O", spcOverwrite },
  118. { "OVERWRITE", spcOverwrite },
  119. { "P", spcPrepend },
  120. { "PREPEND", spcPrepend },
  121. { "V", spcVital },
  122. { "VITAL", spcVital },
  123. { NULL, spcNil }
  124. };
  125. /**/
  126. static PSPT psptCommands = NULL, psptOptions = NULL;
  127. /**/
  128. UINT iFieldCur = 0;
  129. static BOOL fParseError = fFalse;
  130. CHP rgchInstBufTmpShort[cchpBufTmpShortBuf] = "short";
  131. CHP rgchInstBufTmpLong[cchpBufTmpLongBuf] = "long";
  132. // REVIEW: global window handle for shell
  133. HWND hwndFrame = NULL;
  134. HANDLE hinstShell = NULL;
  135. BOOL fMono = fFalse;
  136. /*
  137. ** Purpose:
  138. ** Arguments:
  139. ** Returns:
  140. **
  141. *************************************************************************/
  142. BOOL APIENTRY FGetArgSz(INT Line,UINT *pcFields, SZ *psz)
  143. {
  144. if (iFieldCur <= *pcFields)
  145. return((*psz = SzGetNthFieldFromInfLine(Line,iFieldCur++)) != (SZ)NULL);
  146. return(fFalse);
  147. }
  148. /*
  149. ** Purpose:
  150. ** Arguments:
  151. ** Returns:
  152. **
  153. *************************************************************************/
  154. BOOL APIENTRY FGetArgUINT(INT Line, UINT *pcFields, UINT *pu)
  155. {
  156. SZ sz;
  157. if (FGetArgSz(Line,pcFields,&sz))
  158. {
  159. *pu = atoi(sz);
  160. SFree(sz);
  161. return(fTrue);
  162. }
  163. return(fFalse);
  164. }
  165. /*
  166. ** Purpose:
  167. ** Arguments:
  168. ** Returns:
  169. **
  170. *************************************************************************/
  171. BOOL APIENTRY FParseSectionFiles(INT Line, UINT *pcFields, PFNSF pfnsf)
  172. {
  173. BOOL fOkay = fFalse;
  174. SZ szSection, szSrc;
  175. fParseError = fTrue;
  176. if (FGetArgSz(Line,pcFields, &szSection))
  177. {
  178. if (FGetArgSz(Line,pcFields, &szSrc))
  179. {
  180. Assert(szSection != NULL && szSrc != NULL);
  181. if (*szSection != '\0' && FValidDir(szSrc))
  182. {
  183. fParseError = fFalse;
  184. fOkay = (*pfnsf)(szSection, szSrc);
  185. }
  186. SFree(szSrc);
  187. }
  188. SFree(szSection);
  189. }
  190. return(fOkay);
  191. }
  192. /*
  193. ** Purpose:
  194. ** Arguments:
  195. ** Returns:
  196. **
  197. *************************************************************************/
  198. BOOL APIENTRY FParseCopySection(INT Line, UINT *pcFields)
  199. {
  200. BOOL fOkay = fFalse;
  201. SZ szSection, szSrc, szDest;
  202. fParseError = fTrue;
  203. if (FGetArgSz(Line,pcFields, &szSection))
  204. {
  205. if (FGetArgSz(Line,pcFields, &szSrc))
  206. {
  207. if (FGetArgSz(Line,pcFields, &szDest))
  208. {
  209. Assert(szSection != NULL && szSrc != NULL && szDest != NULL);
  210. if (*szSection != '\0' && FValidDir(szSrc) && FValidDir(szDest))
  211. {
  212. GRC grc;
  213. fParseError = fFalse;
  214. while ((grc = GrcAddSectionFilesToCopyList(szSection, szSrc,
  215. szDest)) != grcOkay) {
  216. SZ szParam1 = NULL, szParam2 = NULL;
  217. switch ( grc ) {
  218. case grcINFBadFDLine:
  219. case grcINFMissingLine:
  220. case grcINFMissingSection:
  221. szParam1 = pLocalInfPermInfo()->szName;
  222. szParam2 = szSection;
  223. break;
  224. default:
  225. break;
  226. }
  227. if (EercErrorHandler(hwndFrame, grc, fTrue, szParam1, szParam2, 0) ==
  228. eercAbort)
  229. break;
  230. }
  231. fOkay = ((grc == grcOkay) ? fTrue : fFalse);
  232. }
  233. SFree(szDest);
  234. }
  235. SFree(szSrc);
  236. }
  237. SFree(szSection);
  238. }
  239. return(fOkay);
  240. }
  241. /*
  242. ** Purpose:
  243. ** Arguments:
  244. ** Returns:
  245. **
  246. *************************************************************************/
  247. BOOL APIENTRY FParseCopySectionKey(INT Line, UINT *pcFields)
  248. {
  249. BOOL fOkay = fFalse;
  250. SZ szSection, szKey, szSrc, szDest;
  251. fParseError = fTrue;
  252. if (FGetArgSz(Line,pcFields, &szSection))
  253. {
  254. if (FGetArgSz(Line,pcFields, &szKey))
  255. {
  256. if (FGetArgSz(Line,pcFields, &szSrc))
  257. {
  258. if (FGetArgSz(Line,pcFields, &szDest))
  259. {
  260. Assert(szSection != NULL && szKey != NULL && szSrc != NULL
  261. && szDest != NULL);
  262. if (*szSection != '\0' && *szKey != '\0' && FValidDir(szSrc)
  263. && FValidDir(szDest))
  264. {
  265. GRC grc;
  266. fParseError = fFalse;
  267. while ((grc = GrcAddSectionKeyFileToCopyList(szSection,
  268. szKey, szSrc, szDest)) != grcOkay) {
  269. SZ szParam1 = NULL, szParam2 = NULL;
  270. switch ( grc ) {
  271. case grcINFBadFDLine:
  272. case grcINFMissingLine:
  273. case grcINFMissingSection:
  274. szParam1 = pLocalInfPermInfo()->szName;
  275. szParam2 = szSection;
  276. break;
  277. default:
  278. break;
  279. }
  280. if (EercErrorHandler(hwndFrame, grc, fTrue, szParam1, szParam2, 0)
  281. == eercAbort)
  282. break;
  283. }
  284. fOkay = ((grc == grcOkay) ? fTrue : fFalse);
  285. }
  286. SFree(szDest);
  287. }
  288. SFree(szSrc);
  289. }
  290. SFree(szKey);
  291. }
  292. SFree(szSection);
  293. }
  294. return(fOkay);
  295. }
  296. /*
  297. ** Purpose:
  298. ** Arguments:
  299. ** Returns:
  300. **
  301. *************************************************************************/
  302. BOOL APIENTRY FParseCopyNthSection(INT Line, UINT *pcFields)
  303. {
  304. BOOL fOkay = fFalse;
  305. SZ szSection, szSrc, szDest;
  306. UINT n;
  307. fParseError = fTrue;
  308. if (FGetArgSz(Line,pcFields, &szSection))
  309. {
  310. if (FGetArgUINT(Line,pcFields, &n))
  311. {
  312. if (FGetArgSz(Line,pcFields, &szSrc))
  313. {
  314. if (FGetArgSz(Line,pcFields, &szDest))
  315. {
  316. Assert(szSection != NULL && szSrc != NULL && szDest !=NULL);
  317. if (*szSection != '\0' && n > 0 && FValidDir(szSrc)
  318. && FValidDir(szDest))
  319. {
  320. GRC grc;
  321. fParseError = fFalse;
  322. while ((grc = GrcAddNthSectionFileToCopyList(szSection,
  323. n, szSrc, szDest)) != grcOkay) {
  324. SZ szParam1 = NULL, szParam2 = NULL;
  325. switch ( grc ) {
  326. case grcINFBadFDLine:
  327. case grcINFMissingLine:
  328. case grcINFMissingSection:
  329. szParam1 = pLocalInfPermInfo()->szName;
  330. szParam2 = szSection;
  331. break;
  332. default:
  333. break;
  334. }
  335. if (EercErrorHandler(hwndFrame, grc, fTrue, szParam1, szParam2, 0)
  336. == eercAbort)
  337. break;
  338. }
  339. fOkay = ((grc == grcOkay) ? fTrue : fFalse);
  340. }
  341. SFree(szDest);
  342. }
  343. SFree(szSrc);
  344. }
  345. }
  346. SFree(szSection);
  347. }
  348. return(fOkay);
  349. }
  350. /*
  351. ** Purpose:
  352. ** Arguments:
  353. ** Returns:
  354. **
  355. *************************************************************************/
  356. BOOL APIENTRY FParseDirectory(INT Line, UINT *pcFields, PFND pfnd)
  357. {
  358. BOOL fOkay = fFalse;
  359. SZ szDirectory;
  360. fParseError = fTrue;
  361. if (FGetArgSz(Line,pcFields, &szDirectory))
  362. {
  363. CMO cmo = cmoNil;
  364. SZ szOption;
  365. fOkay = fTrue;
  366. while (fOkay && FGetArgSz(Line,pcFields, &szOption))
  367. {
  368. switch (SpcParseString(psptOptions, szOption))
  369. {
  370. default:
  371. fOkay = fFalse;
  372. break;
  373. case spcVital:
  374. cmo |= cmoVital;
  375. break;
  376. }
  377. SFree(szOption);
  378. }
  379. Assert(szDirectory != NULL);
  380. if (fOkay && FValidDir(szDirectory))
  381. {
  382. fParseError = fFalse;
  383. fOkay = (*pfnd)(szDirectory, cmo);
  384. }
  385. SFree(szDirectory);
  386. }
  387. return(fOkay);
  388. }
  389. /*
  390. ** Purpose:
  391. ** Arguments:
  392. ** Returns:
  393. **
  394. *************************************************************************/
  395. BOOL APIENTRY FParseCreateIniSection(INT Line, UINT *pcFields, SZ szIniFile,
  396. SZ szSection)
  397. {
  398. CMO cmo = cmoNil;
  399. SZ szOption;
  400. BOOL fOkay = fTrue;
  401. fParseError = fTrue;
  402. while (fOkay && FGetArgSz(Line,pcFields, &szOption))
  403. {
  404. switch (SpcParseString(psptOptions, szOption))
  405. {
  406. default:
  407. fOkay = fFalse;
  408. break;
  409. case spcOverwrite:
  410. cmo |= cmoOverwrite;
  411. break;
  412. case spcVital:
  413. cmo |= cmoVital;
  414. break;
  415. }
  416. SFree(szOption);
  417. }
  418. Assert(szIniFile != NULL && szSection != NULL);
  419. if (fOkay)
  420. {
  421. fParseError = fFalse;
  422. fOkay = FCreateIniSection(szIniFile, szSection, cmo);
  423. }
  424. return(fOkay);
  425. }
  426. /*
  427. ** Purpose:
  428. ** Arguments:
  429. ** Returns:
  430. **
  431. *************************************************************************/
  432. BOOL APIENTRY FParseReplaceIniSection(INT Line, UINT *pcFields, SZ szIniFile,
  433. SZ szSection)
  434. {
  435. CMO cmo = cmoNil;
  436. BOOL fOkay = fFalse;
  437. SZ szNewSection;
  438. fParseError = fTrue;
  439. if (FGetArgSz(Line,pcFields, &szNewSection))
  440. {
  441. SZ szOption;
  442. fOkay = fTrue;
  443. while (fOkay && FGetArgSz(Line,pcFields, &szOption))
  444. {
  445. switch (SpcParseString(psptOptions, szOption))
  446. {
  447. default:
  448. fOkay = fFalse;
  449. break;
  450. case spcVital:
  451. cmo |= cmoVital;
  452. break;
  453. }
  454. SFree(szOption);
  455. }
  456. Assert(szIniFile != NULL && szSection != NULL && szNewSection != NULL);
  457. if (fOkay && *szNewSection != '\0')
  458. {
  459. fParseError = fFalse;
  460. fOkay = FReplaceIniSection(szIniFile, szSection, szNewSection, cmo);
  461. }
  462. SFree(szNewSection);
  463. }
  464. return(fOkay);
  465. }
  466. /*
  467. ** Purpose:
  468. ** Arguments:
  469. ** Returns:
  470. **
  471. *************************************************************************/
  472. BOOL APIENTRY FParseRemoveIniSection(INT Line, UINT *pcFields, SZ szIniFile,
  473. SZ szSection)
  474. {
  475. CMO cmo = cmoNil;
  476. SZ szOption;
  477. BOOL fOkay = fTrue;
  478. fParseError = fTrue;
  479. while (fOkay && FGetArgSz(Line,pcFields, &szOption))
  480. {
  481. switch (SpcParseString(psptOptions, szOption))
  482. {
  483. default:
  484. fOkay = fFalse;
  485. break;
  486. case spcVital:
  487. cmo |= cmoVital;
  488. break;
  489. }
  490. SFree(szOption);
  491. }
  492. Assert(szIniFile != NULL && szSection != NULL);
  493. if (fOkay)
  494. {
  495. fParseError = fFalse;
  496. fOkay = FRemoveIniSection(szIniFile, szSection, cmo);
  497. }
  498. return(fOkay);
  499. }
  500. /*
  501. ** Purpose:
  502. ** Arguments:
  503. ** Returns:
  504. **
  505. *************************************************************************/
  506. BOOL APIENTRY FParseCreateIniKeyValue(INT Line, UINT *pcFields, SZ szIniFile,
  507. SZ szSection)
  508. {
  509. CMO cmo = cmoNil;
  510. BOOL fOkay = fFalse;
  511. SZ szKey, szValue;
  512. fParseError = fTrue;
  513. if (FGetArgSz(Line,pcFields, &szKey))
  514. {
  515. if (FGetArgSz(Line,pcFields, &szValue))
  516. {
  517. SZ szOption;
  518. fOkay = fTrue;
  519. while (fOkay && FGetArgSz(Line,pcFields, &szOption))
  520. {
  521. switch (SpcParseString(psptOptions, szOption))
  522. {
  523. default:
  524. fOkay = fFalse;
  525. break;
  526. case spcOverwrite:
  527. cmo |= cmoOverwrite;
  528. break;
  529. case spcVital:
  530. cmo |= cmoVital;
  531. break;
  532. }
  533. SFree(szOption);
  534. }
  535. Assert(szIniFile != NULL && szSection != NULL && szKey != NULL
  536. && szValue != NULL);
  537. if (fOkay && *szKey != '\0')
  538. {
  539. fParseError = fFalse;
  540. fOkay = FCreateIniKeyValue(szIniFile, szSection, szKey, szValue,
  541. cmo);
  542. }
  543. SFree(szValue);
  544. }
  545. SFree(szKey);
  546. }
  547. return(fOkay);
  548. }
  549. /*
  550. ** Purpose:
  551. ** Arguments:
  552. ** Returns:
  553. **
  554. *************************************************************************/
  555. BOOL APIENTRY FParseCreateSysIniKeyValue(INT Line, UINT *pcFields, SZ szIniFile,
  556. SZ szSection)
  557. {
  558. CMO cmo = cmoNil;
  559. BOOL fOkay = fFalse;
  560. SZ szKey, szValue;
  561. fParseError = fTrue;
  562. if (FGetArgSz(Line,pcFields, &szKey))
  563. {
  564. if (FGetArgSz(Line,pcFields, &szValue))
  565. {
  566. SZ szOption;
  567. fOkay = fTrue;
  568. while (fOkay && FGetArgSz(Line,pcFields, &szOption))
  569. {
  570. switch (SpcParseString(psptOptions, szOption))
  571. {
  572. default:
  573. fOkay = fFalse;
  574. break;
  575. case spcOverwrite:
  576. cmo |= cmoOverwrite;
  577. break;
  578. case spcVital:
  579. cmo |= cmoVital;
  580. break;
  581. }
  582. SFree(szOption);
  583. }
  584. Assert(szIniFile != NULL && szSection != NULL && szKey != NULL
  585. && szValue != NULL);
  586. if (fOkay && *szKey != '\0')
  587. {
  588. fParseError = fFalse;
  589. fOkay = FCreateSysIniKeyValue(szIniFile, szSection, szKey,
  590. szValue, cmo);
  591. }
  592. SFree(szValue);
  593. }
  594. SFree(szKey);
  595. }
  596. return(fOkay);
  597. }
  598. /*
  599. ** Purpose:
  600. ** Arguments:
  601. ** Returns:
  602. **
  603. *************************************************************************/
  604. BOOL APIENTRY FParseCreateIniKeyNoValue(INT Line, UINT *pcFields, SZ szIniFile,
  605. SZ szSection)
  606. {
  607. CMO cmo = cmoNil;
  608. BOOL fOkay = fFalse;
  609. SZ szKey;
  610. fParseError = fTrue;
  611. if (FGetArgSz(Line,pcFields, &szKey))
  612. {
  613. SZ szOption;
  614. fOkay = fTrue;
  615. while (fOkay && FGetArgSz(Line,pcFields, &szOption))
  616. {
  617. switch (SpcParseString(psptOptions, szOption))
  618. {
  619. default:
  620. fOkay = fFalse;
  621. break;
  622. case spcOverwrite:
  623. cmo |= cmoOverwrite;
  624. break;
  625. case spcVital:
  626. cmo |= cmoVital;
  627. break;
  628. }
  629. SFree(szOption);
  630. }
  631. Assert(szIniFile != NULL && szSection != NULL && szKey != NULL);
  632. if (fOkay && *szKey != '\0')
  633. {
  634. fParseError = fFalse;
  635. fOkay = FCreateIniKeyNoValue(szIniFile, szSection, szKey, cmo);
  636. }
  637. SFree(szKey);
  638. }
  639. return(fOkay);
  640. }
  641. /*
  642. ** Purpose:
  643. ** Arguments:
  644. ** Returns:
  645. **
  646. *************************************************************************/
  647. BOOL APIENTRY FParseReplaceIniKeyValue(INT Line, UINT *pcFields, SZ szIniFile,
  648. SZ szSection)
  649. {
  650. CMO cmo = cmoNil;
  651. BOOL fOkay = fFalse;
  652. SZ szKey, szValue;
  653. fParseError = fTrue;
  654. if (FGetArgSz(Line,pcFields, &szKey))
  655. {
  656. if (FGetArgSz(Line,pcFields, &szValue))
  657. {
  658. SZ szOption;
  659. fOkay = fTrue;
  660. while (fOkay && FGetArgSz(Line,pcFields, &szOption))
  661. {
  662. switch (SpcParseString(psptOptions, szOption))
  663. {
  664. default:
  665. fOkay = fFalse;
  666. break;
  667. case spcVital:
  668. cmo |= cmoVital;
  669. break;
  670. }
  671. SFree(szOption);
  672. }
  673. Assert(szIniFile != NULL && szSection != NULL && szKey != NULL
  674. && szValue != NULL);
  675. if (fOkay && *szKey != '\0')
  676. {
  677. fParseError = fFalse;
  678. fOkay = FReplaceIniKeyValue(szIniFile, szSection, szKey,
  679. szValue, cmo);
  680. }
  681. SFree(szValue);
  682. }
  683. SFree(szKey);
  684. }
  685. return(fOkay);
  686. }
  687. /*
  688. ** Purpose:
  689. ** Arguments:
  690. ** Returns:
  691. **
  692. *************************************************************************/
  693. BOOL APIENTRY FParseAppendIniKeyValue(INT Line, UINT *pcFields, SZ szIniFile,
  694. SZ szSection)
  695. {
  696. CMO cmo = cmoNil;
  697. BOOL fOkay = fFalse;
  698. SZ szKey, szValue;
  699. fParseError = fTrue;
  700. if (FGetArgSz(Line,pcFields, &szKey))
  701. {
  702. if (FGetArgSz(Line,pcFields, &szValue))
  703. {
  704. SZ szOption;
  705. fOkay = fTrue;
  706. while (fOkay && FGetArgSz(Line,pcFields, &szOption))
  707. {
  708. switch (SpcParseString(psptOptions, szOption))
  709. {
  710. default:
  711. fOkay = fFalse;
  712. break;
  713. case spcVital:
  714. cmo |= cmoVital;
  715. break;
  716. }
  717. SFree(szOption);
  718. }
  719. Assert(szIniFile != NULL && szSection != NULL && szKey != NULL
  720. && szValue != NULL);
  721. if (fOkay && *szKey != '\0')
  722. {
  723. fParseError = fFalse;
  724. fOkay = FAppendIniKeyValue(szIniFile, szSection, szKey,
  725. szValue, cmo);
  726. }
  727. SFree(szValue);
  728. }
  729. SFree(szKey);
  730. }
  731. return(fOkay);
  732. }
  733. /*
  734. ** Purpose:
  735. ** Arguments:
  736. ** Returns:
  737. **
  738. *************************************************************************/
  739. BOOL APIENTRY FParseRemoveIniKey(INT Line, UINT *pcFields, SZ szIniFile, SZ szSection)
  740. {
  741. CMO cmo = cmoNil;
  742. BOOL fOkay = fFalse;
  743. SZ szKey;
  744. fParseError = fTrue;
  745. if (FGetArgSz(Line,pcFields, &szKey))
  746. {
  747. SZ szOption;
  748. fOkay = fTrue;
  749. while (fOkay && FGetArgSz(Line,pcFields, &szOption))
  750. {
  751. switch (SpcParseString(psptOptions, szOption))
  752. {
  753. default:
  754. fOkay = fFalse;
  755. break;
  756. case spcVital:
  757. cmo |= cmoVital;
  758. break;
  759. }
  760. SFree(szOption);
  761. }
  762. Assert(szIniFile != NULL && szSection != NULL && szKey != NULL);
  763. if (fOkay && *szKey != '\0')
  764. {
  765. fParseError = fFalse;
  766. fOkay = FRemoveIniKey(szIniFile, szSection, szKey, cmo);
  767. }
  768. SFree(szKey);
  769. }
  770. return(fOkay);
  771. }
  772. /*
  773. ** Purpose:
  774. ** Arguments:
  775. ** Returns:
  776. **
  777. *************************************************************************/
  778. BOOL APIENTRY FParseIniSection(INT Line, UINT *pcFields, SPC spc)
  779. {
  780. BOOL fOkay = fFalse;
  781. SZ szIniFile, szIniSection;
  782. fParseError = fTrue;
  783. if (FGetArgSz(Line,pcFields, &szIniFile))
  784. {
  785. if (FGetArgSz(Line,pcFields, &szIniSection))
  786. {
  787. Assert(szIniFile != NULL && szIniSection != NULL);
  788. if (*szIniFile != '\0'
  789. && (FValidPath(szIniFile)
  790. || CrcStringCompareI(szIniFile, "WIN.INI") == crcEqual)
  791. && *szIniSection != '\0')
  792. {
  793. fParseError = fFalse;
  794. switch (spc)
  795. {
  796. default:
  797. fParseError = fTrue;
  798. Assert(fFalse);
  799. break;
  800. case spcCreateIniSection:
  801. fOkay = FParseCreateIniSection(Line, pcFields, szIniFile,
  802. szIniSection);
  803. break;
  804. case spcRemoveIniSection:
  805. fOkay = FParseRemoveIniSection(Line, pcFields, szIniFile,
  806. szIniSection);
  807. break;
  808. case spcReplaceIniSection:
  809. fOkay = FParseReplaceIniSection(Line, pcFields, szIniFile,
  810. szIniSection);
  811. break;
  812. case spcCreateIniKeyNoValue:
  813. fOkay = FParseCreateIniKeyNoValue(Line, pcFields, szIniFile,
  814. szIniSection);
  815. break;
  816. case spcCreateIniKeyValue:
  817. fOkay = FParseCreateIniKeyValue(Line, pcFields, szIniFile,
  818. szIniSection);
  819. break;
  820. case spcReplaceIniKeyValue:
  821. fOkay = FParseReplaceIniKeyValue(Line, pcFields, szIniFile,
  822. szIniSection);
  823. break;
  824. case spcRemoveIniKey:
  825. fOkay = FParseRemoveIniKey(Line, pcFields, szIniFile, szIniSection);
  826. break;
  827. case spcCreateSysIniKeyValue:
  828. fOkay = FParseCreateSysIniKeyValue(Line, pcFields, szIniFile,
  829. szIniSection);
  830. break;
  831. }
  832. }
  833. SFree(szIniSection);
  834. }
  835. SFree(szIniFile);
  836. }
  837. return(fOkay);
  838. }
  839. /*
  840. ** Purpose:
  841. ** Arguments:
  842. ** Returns:
  843. **
  844. *************************************************************************/
  845. BOOL APIENTRY FParseSetEnv(INT Line, UINT *pcFields)
  846. {
  847. BOOL fOkay = fFalse;
  848. SZ szFile, szVar, szVal;
  849. CMO cmo = cmoNil;
  850. fParseError = fTrue;
  851. if (FGetArgSz(Line,pcFields, &szFile))
  852. {
  853. if (FGetArgSz(Line,pcFields, &szVar))
  854. {
  855. if (FGetArgSz(Line,pcFields, &szVal))
  856. {
  857. SZ szOption;
  858. fOkay = fTrue;
  859. while (fOkay && FGetArgSz(Line,pcFields, &szOption))
  860. {
  861. switch (SpcParseString(psptOptions, szOption))
  862. {
  863. default:
  864. fOkay = fFalse;
  865. break;
  866. case spcAppend:
  867. cmo |= cmoAppend;
  868. break;
  869. case spcPrepend:
  870. cmo |= cmoPrepend;
  871. break;
  872. }
  873. SFree(szOption);
  874. }
  875. Assert(szFile != NULL && szVar != NULL && szVal != NULL);
  876. if (fOkay)
  877. {
  878. fParseError = fFalse;
  879. fOkay = FSetEnvVariableValue(szFile, szVar, szVal, cmo);
  880. }
  881. SFree(szVal);
  882. }
  883. SFree(szVar);
  884. }
  885. SFree(szFile);
  886. }
  887. return(fOkay);
  888. }
  889. /*
  890. ** Purpose:
  891. ** Arguments:
  892. ** Returns:
  893. **
  894. *************************************************************************/
  895. BOOL APIENTRY FParseCreateProgManGroup(INT Line, UINT *pcFields, BOOL CommonGroup)
  896. {
  897. BOOL fOkay = fFalse;
  898. SZ szDescription;
  899. fParseError = fTrue;
  900. if (FGetArgSz(Line,pcFields, &szDescription))
  901. {
  902. SZ szFile;
  903. if (FGetArgSz(Line,pcFields, &szFile))
  904. {
  905. CMO cmo = cmoNil;
  906. SZ szOption;
  907. fOkay = fTrue;
  908. while (fOkay && FGetArgSz(Line,pcFields, &szOption))
  909. {
  910. switch (SpcParseString(psptOptions, szOption))
  911. {
  912. default:
  913. fOkay = fFalse;
  914. break;
  915. case spcVital:
  916. cmo |= cmoVital;
  917. break;
  918. }
  919. SFree(szOption);
  920. }
  921. Assert(szDescription != NULL && szFile != NULL);
  922. if (fOkay && *szDescription != '\0')
  923. {
  924. fParseError = fFalse;
  925. fOkay = FCreateProgManGroup(szDescription, szFile, cmo, CommonGroup);
  926. }
  927. SFree(szFile);
  928. }
  929. SFree(szDescription);
  930. }
  931. return(fOkay);
  932. }
  933. /*
  934. ** Purpose:
  935. ** Arguments:
  936. ** Returns:
  937. **
  938. *************************************************************************/
  939. BOOL APIENTRY FParseRemoveProgManGroup(INT Line, UINT *pcFields, BOOL CommonGroup)
  940. {
  941. BOOL fOkay = fFalse;
  942. SZ szDescription;
  943. fParseError = fTrue;
  944. if (FGetArgSz(Line,pcFields, &szDescription))
  945. {
  946. CMO cmo = cmoNil;
  947. SZ szOption;
  948. fOkay = fTrue;
  949. while (fOkay && FGetArgSz(Line,pcFields, &szOption))
  950. {
  951. switch (SpcParseString(psptOptions, szOption))
  952. {
  953. default:
  954. fOkay = fFalse;
  955. break;
  956. case spcVital:
  957. cmo |= cmoVital;
  958. break;
  959. }
  960. SFree(szOption);
  961. }
  962. Assert(szDescription != NULL);
  963. if (fOkay && *szDescription != '\0')
  964. {
  965. fParseError = fFalse;
  966. fOkay = FRemoveProgManGroup(szDescription, cmo, CommonGroup);
  967. }
  968. SFree(szDescription);
  969. }
  970. return(fOkay);
  971. }
  972. /*
  973. ** Purpose:
  974. ** Arguments:
  975. ** Returns:
  976. **
  977. *************************************************************************/
  978. BOOL APIENTRY FParseShowProgManGroup(INT Line, UINT *pcFields, BOOL CommonGroup)
  979. {
  980. BOOL fOkay = fFalse;
  981. SZ szGroup;
  982. fParseError = fTrue;
  983. if (FGetArgSz(Line,pcFields, &szGroup))
  984. {
  985. SZ szCommand;
  986. if (FGetArgSz(Line,pcFields, &szCommand))
  987. {
  988. SZ szOption;
  989. CMO cmo = cmoNil;
  990. fOkay = fTrue;
  991. while (fOkay && FGetArgSz(Line,pcFields, &szOption))
  992. {
  993. switch (SpcParseString(psptOptions, szOption))
  994. {
  995. default:
  996. fOkay = fFalse;
  997. break;
  998. case spcVital:
  999. cmo |= cmoVital;
  1000. break;
  1001. }
  1002. SFree(szOption);
  1003. }
  1004. Assert(szGroup != NULL && szCommand != NULL);
  1005. if (fOkay && *szGroup != '\0' && *szCommand != '\0')
  1006. {
  1007. fParseError = fFalse;
  1008. fOkay = FShowProgManGroup(szGroup, szCommand, cmo, CommonGroup);
  1009. }
  1010. SFree(szCommand);
  1011. }
  1012. SFree(szGroup);
  1013. }
  1014. return(fOkay);
  1015. }
  1016. /*
  1017. ** Purpose:
  1018. ** Arguments:
  1019. ** Returns:
  1020. **
  1021. *************************************************************************/
  1022. BOOL APIENTRY FParseCreateProgManItem(INT Line, UINT *pcFields, BOOL CommonGroup)
  1023. {
  1024. BOOL fOkay = fFalse;
  1025. SZ szGroup;
  1026. fParseError = fTrue;
  1027. if (FGetArgSz(Line,pcFields, &szGroup))
  1028. {
  1029. SZ szDescription;
  1030. if (FGetArgSz(Line,pcFields, &szDescription))
  1031. {
  1032. SZ szCmdLine;
  1033. if (FGetArgSz(Line,pcFields, &szCmdLine))
  1034. {
  1035. SZ szIconFile;
  1036. if (FGetArgSz(Line, pcFields, &szIconFile))
  1037. {
  1038. SZ szIconNum;
  1039. if (FGetArgSz(Line, pcFields, &szIconNum))
  1040. {
  1041. SZ szOption;
  1042. CMO cmo = cmoNil;
  1043. fOkay = fTrue;
  1044. while (fOkay && FGetArgSz(Line,pcFields, &szOption))
  1045. {
  1046. switch (SpcParseString(psptOptions, szOption))
  1047. {
  1048. default:
  1049. fOkay = fFalse;
  1050. break;
  1051. case spcOverwrite:
  1052. cmo |= cmoOverwrite;
  1053. break;
  1054. case spcVital:
  1055. cmo |= cmoVital;
  1056. break;
  1057. }
  1058. SFree(szOption);
  1059. }
  1060. Assert(
  1061. szGroup != NULL &&
  1062. szDescription != NULL &&
  1063. szCmdLine != NULL &&
  1064. szIconFile != NULL &&
  1065. szIconNum != NULL
  1066. );
  1067. if ( fOkay
  1068. && *szGroup != '\0'
  1069. && *szDescription != '\0'
  1070. && *szCmdLine != '\0'
  1071. ) {
  1072. fParseError = fFalse;
  1073. while( !FCreateProgManItem(
  1074. szGroup,
  1075. szDescription,
  1076. szCmdLine,
  1077. szIconFile,
  1078. atoi(szIconNum),
  1079. cmo,
  1080. CommonGroup
  1081. )
  1082. ) {
  1083. EERC eerc;
  1084. if ((eerc = EercErrorHandler(hwndFrame, grcDDEAddItem, cmo & cmoVital, szDescription, szGroup,
  1085. 0)) != eercRetry) {
  1086. fOkay = (eerc == eercIgnore);
  1087. break;
  1088. }
  1089. }
  1090. }
  1091. SFree(szIconNum);
  1092. }
  1093. SFree(szIconFile);
  1094. }
  1095. SFree(szCmdLine);
  1096. }
  1097. SFree(szDescription);
  1098. }
  1099. SFree(szGroup);
  1100. }
  1101. return(fOkay);
  1102. }
  1103. /*
  1104. ** Purpose:
  1105. ** Arguments:
  1106. ** Returns:
  1107. **
  1108. *************************************************************************/
  1109. BOOL APIENTRY FParseRemoveProgManItem(INT Line, UINT *pcFields, BOOL CommonGroup)
  1110. {
  1111. BOOL fOkay = fFalse;
  1112. SZ szGroup;
  1113. fParseError = fTrue;
  1114. if (FGetArgSz(Line,pcFields, &szGroup)) {
  1115. SZ szDescription;
  1116. if (FGetArgSz(Line,pcFields, &szDescription)) {
  1117. SZ szOption;
  1118. CMO cmo = cmoNil;
  1119. fOkay = fTrue;
  1120. while (fOkay && FGetArgSz(Line,pcFields, &szOption))
  1121. {
  1122. switch (SpcParseString(psptOptions, szOption))
  1123. {
  1124. default:
  1125. fOkay = fFalse;
  1126. break;
  1127. case spcVital:
  1128. cmo |= cmoVital;
  1129. break;
  1130. }
  1131. SFree(szOption);
  1132. }
  1133. Assert(szGroup != NULL && szDescription != NULL);
  1134. if (fOkay) {
  1135. fParseError = fFalse;
  1136. FRemoveProgManItem( szGroup, szDescription, cmo, CommonGroup );
  1137. }
  1138. SFree(szDescription);
  1139. }
  1140. SFree(szGroup);
  1141. }
  1142. return(fOkay);
  1143. }
  1144. /*
  1145. ** Purpose:
  1146. ** Arguments:
  1147. ** Returns:
  1148. **
  1149. *************************************************************************/
  1150. BOOL APIENTRY FParseSearchDirList(INT Line, UINT *pcFields)
  1151. {
  1152. BOOL fOkay = fFalse;
  1153. SZ szInfVar = NULL;
  1154. SZ szDirList = NULL;
  1155. SZ szRecurse = NULL;
  1156. SZ szSilent = NULL;
  1157. SZ szSearchList = NULL;
  1158. SZ szWin16Restr = NULL;
  1159. SZ szWin32Restr = NULL;
  1160. SZ szDosRestr = NULL;
  1161. BOOL fRecurse;
  1162. BOOL fSilent;
  1163. if ( *pcFields >= 9 ) {
  1164. FGetArgSz( Line, pcFields, &szInfVar );
  1165. if ( szInfVar ) {
  1166. FGetArgSz( Line, pcFields, &szDirList );
  1167. if ( szDirList ) {
  1168. FGetArgSz( Line, pcFields, &szRecurse );
  1169. if ( szRecurse ) {
  1170. FGetArgSz( Line, pcFields, &szSilent );
  1171. if ( szSilent ) {
  1172. FGetArgSz( Line, pcFields, &szSearchList );
  1173. if ( szSearchList ) {
  1174. FGetArgSz( Line, pcFields, &szWin16Restr );
  1175. if ( szWin16Restr ) {
  1176. FGetArgSz( Line, pcFields, &szWin32Restr );
  1177. if ( szWin32Restr ) {
  1178. FGetArgSz( Line, pcFields, &szDosRestr );
  1179. if ( szDosRestr ) {
  1180. fRecurse = (CrcStringCompare(szRecurse, "YES") == crcEqual);
  1181. fSilent = (CrcStringCompare(szSilent, "YES") == crcEqual);
  1182. fOkay = FSearchDirList( szInfVar,
  1183. szDirList,
  1184. fRecurse,
  1185. fSilent,
  1186. szSearchList,
  1187. szWin16Restr,
  1188. szWin32Restr,
  1189. szDosRestr );
  1190. SFree( szDosRestr );
  1191. }
  1192. SFree( szWin32Restr );
  1193. }
  1194. SFree( szWin16Restr );
  1195. }
  1196. SFree( szSearchList );
  1197. }
  1198. SFree( szSilent );
  1199. }
  1200. SFree( szRecurse );
  1201. }
  1202. SFree( szDirList );
  1203. }
  1204. SFree( szInfVar );
  1205. }
  1206. }
  1207. return fOkay;
  1208. }
  1209. /*
  1210. ** Purpose:
  1211. ** Arguments:
  1212. ** Returns:
  1213. **
  1214. *************************************************************************/
  1215. BOOL APIENTRY FParseSetupDOSAppsList(INT Line, UINT *pcFields)
  1216. {
  1217. BOOL fOkay = fFalse;
  1218. SZ szAppList = NULL;
  1219. SZ szWinMode = NULL;
  1220. SZ szDefltStdValues = NULL;
  1221. SZ szDefltEnhValues = NULL;
  1222. SZ szPifDir = NULL;
  1223. SZ szGroup = NULL;
  1224. if(*pcFields >= 7) {
  1225. FGetArgSz( Line, pcFields, &szAppList );
  1226. if ( szAppList ) {
  1227. FGetArgSz( Line, pcFields, &szWinMode );
  1228. if ( szWinMode ) {
  1229. FGetArgSz( Line, pcFields, &szDefltStdValues );
  1230. if ( szDefltStdValues ) {
  1231. FGetArgSz( Line, pcFields, &szDefltEnhValues );
  1232. if ( szDefltEnhValues ) {
  1233. FGetArgSz( Line, pcFields, &szPifDir );
  1234. if ( szPifDir ) {
  1235. FGetArgSz( Line, pcFields, &szGroup );
  1236. if ( szGroup ) {
  1237. fOkay = FInstallDOSPifs(
  1238. szAppList,
  1239. szWinMode,
  1240. szDefltStdValues,
  1241. szDefltEnhValues,
  1242. szPifDir,
  1243. szGroup
  1244. );
  1245. SFree( szGroup );
  1246. }
  1247. SFree( szPifDir );
  1248. }
  1249. SFree( szDefltEnhValues );
  1250. }
  1251. SFree( szDefltStdValues );
  1252. }
  1253. SFree( szWinMode );
  1254. }
  1255. SFree( szAppList );
  1256. }
  1257. }
  1258. return(fOkay);
  1259. }
  1260. BOOL
  1261. FParseChangeBootIniTimeout(INT Line, UINT *pcFields)
  1262. {
  1263. BOOL fOkay = fFalse;
  1264. SZ szTimeout = NULL;
  1265. if(*pcFields == 2) {
  1266. FGetArgSz(Line,pcFields,&szTimeout);
  1267. if(szTimeout) {
  1268. fOkay = FChangeBootIniTimeout(atoi(szTimeout));
  1269. SFree(szTimeout);
  1270. }
  1271. }
  1272. return(fOkay);
  1273. }
  1274. /*
  1275. ** Purpose:
  1276. ** Arguments:
  1277. ** Returns:
  1278. **
  1279. *************************************************************************/
  1280. BOOL APIENTRY FGetCmo(INT Line, UINT *pcFields, CMO * pcmo)
  1281. {
  1282. BOOL fOkay = fFalse;
  1283. CMO cmo = cmoNil;
  1284. SZ szOption;
  1285. fOkay = fTrue;
  1286. while (fOkay && FGetArgSz(Line,pcFields, &szOption)) {
  1287. switch (SpcParseString(psptOptions, szOption))
  1288. {
  1289. default:
  1290. fOkay = fFalse;
  1291. break;
  1292. case spcOverwrite:
  1293. cmo |= cmoOverwrite;
  1294. break;
  1295. case spcVital:
  1296. cmo |= cmoVital;
  1297. break;
  1298. }
  1299. SFree(szOption);
  1300. }
  1301. *pcmo = cmo;
  1302. return fOkay;
  1303. }
  1304. /*
  1305. ** Purpose:
  1306. ** Arguments:
  1307. ** Returns:
  1308. **
  1309. *************************************************************************/
  1310. BOOL APIENTRY FParseStampResource(INT Line, UINT *pcFields)
  1311. {
  1312. BOOL fOkay = fFalse;
  1313. SZ szSect, szKey, szDst, szData;
  1314. UINT wResType, wResId, cbData;
  1315. fParseError = fTrue;
  1316. if (FGetArgSz(Line,pcFields, &szSect))
  1317. {
  1318. if (FGetArgSz(Line,pcFields, &szKey))
  1319. {
  1320. if (FGetArgSz(Line,pcFields, &szDst))
  1321. {
  1322. if (FGetArgUINT(Line,pcFields, &wResType))
  1323. if (FGetArgUINT(Line,pcFields, &wResId))
  1324. if (FGetArgSz(Line,pcFields, &szData))
  1325. {
  1326. if (FGetArgUINT(Line,pcFields, &cbData))
  1327. {
  1328. Assert(szSect != NULL && szKey != NULL
  1329. && szDst != NULL && szData != NULL);
  1330. if (*szSect != '\0' && *szKey != '\0'
  1331. && FValidDir(szDst))
  1332. {
  1333. fParseError = fFalse;
  1334. fOkay = FStampResource(szSect, szKey, szDst,
  1335. (WORD)wResType, (WORD)wResId, szData, cbData);
  1336. }
  1337. }
  1338. SFree(szData);
  1339. }
  1340. SFree(szDst);
  1341. }
  1342. SFree(szKey);
  1343. }
  1344. SFree(szSect);
  1345. }
  1346. return(fOkay);
  1347. }
  1348. /*
  1349. ** Purpose:
  1350. ** Arguments:
  1351. ** Returns:
  1352. **
  1353. *************************************************************************/
  1354. BOOL APIENTRY FStrToDate(SZ szDate, PUSHORT pwYear, PUSHORT pwMonth,
  1355. PUSHORT pwDay)
  1356. {
  1357. if (!isdigit(*(szDate + 0)) ||
  1358. !isdigit(*(szDate + 1)) ||
  1359. !isdigit(*(szDate + 2)) ||
  1360. !isdigit(*(szDate + 3)) ||
  1361. *(szDate + 4) != '-' ||
  1362. !isdigit(*(szDate + 5)) ||
  1363. !isdigit(*(szDate + 6)) ||
  1364. *(szDate + 7) != '-' ||
  1365. !isdigit(*(szDate + 8)) ||
  1366. !isdigit(*(szDate + 9)) ||
  1367. *(szDate + 10) != '\0')
  1368. return(fFalse);
  1369. *pwYear = (USHORT)(((*(szDate + 0) - '0') * 1000) + ((*(szDate + 1) - '0') * 100) +
  1370. ((*(szDate + 2) - '0') * 10) + (*(szDate + 3) - '0'));
  1371. *pwMonth = (USHORT)(((*(szDate + 5) - '0') * 10) + (*(szDate + 6) - '0'));
  1372. *pwDay = (USHORT)(((*(szDate + 8) - '0') * 10) + (*(szDate + 9) - '0'));
  1373. if (*pwMonth < 1 || *pwMonth > 12 || *pwDay < 1 || *pwDay > 31)
  1374. return(fFalse);
  1375. return(fTrue);
  1376. }
  1377. /*
  1378. ** Purpose:
  1379. ** Arguments:
  1380. ** Returns:
  1381. **
  1382. *************************************************************************/
  1383. BOOL APIENTRY FParseCloseSystem(INT Line, UINT *pcFields)
  1384. {
  1385. BOOL fOkay = fFalse;
  1386. SZ szSect, szKey, szDst;
  1387. UINT wResType, wResId;
  1388. SZ szName, szOrg, szDate, szSer;
  1389. USHORT wYear, wMonth, wDay;
  1390. CHP szData[149];
  1391. if ((szSect = SzFindSymbolValueInSymTab("STF_SYS_INIT")) == (SZ)NULL ||
  1392. (CrcStringCompare(szSect, "YES") != crcEqual &&
  1393. CrcStringCompare(szSect, "NET") != crcEqual) ||
  1394. (szName = SzFindSymbolValueInSymTab("STF_CD_NAME")) == (SZ)NULL ||
  1395. (szOrg = SzFindSymbolValueInSymTab("STF_CD_ORG")) == (SZ)NULL ||
  1396. (szDate = SzFindSymbolValueInSymTab("STF_CD_DATE")) == (SZ)NULL ||
  1397. (szSer = SzFindSymbolValueInSymTab("STF_CD_SER")) == (SZ)NULL ||
  1398. !FStrToDate(szDate, &wYear, &wMonth, &wDay) ||
  1399. EncryptCDData(szData, szName, szOrg, wYear, wMonth, wDay, szSer))
  1400. return(fFalse);
  1401. fParseError = fTrue;
  1402. if (FGetArgSz(Line,pcFields, &szSect))
  1403. {
  1404. if (FGetArgSz(Line,pcFields, &szKey))
  1405. {
  1406. if (FGetArgSz(Line,pcFields, &szDst))
  1407. {
  1408. if (FGetArgUINT(Line, pcFields, &wResType))
  1409. if (FGetArgUINT(Line, pcFields, &wResId))
  1410. {
  1411. Assert(szSect != NULL && szKey != NULL && szDst !=NULL);
  1412. if (*szSect != '\0' && *szKey != '\0'
  1413. && FValidDir(szDst))
  1414. {
  1415. fParseError = fFalse;
  1416. fOkay = FStampResource(szSect, szKey, szDst,
  1417. (WORD)wResType, (WORD)wResId, szData, 149);
  1418. }
  1419. }
  1420. SFree(szDst);
  1421. }
  1422. SFree(szKey);
  1423. }
  1424. SFree(szSect);
  1425. }
  1426. return(fOkay);
  1427. }
  1428. /*
  1429. ** Purpose:
  1430. ** Arguments:
  1431. ** Returns:
  1432. **
  1433. *************************************************************************/
  1434. BOOL APIENTRY FUndoActions(VOID)
  1435. {
  1436. /* REVIEW STUB */
  1437. Assert(fFalse);
  1438. return(fFalse);
  1439. }
  1440. /*
  1441. ** Purpose:
  1442. ** Arguments:
  1443. ** Returns:
  1444. **
  1445. *************************************************************************/
  1446. BOOL APIENTRY FParseGetCopyListCost(INT Line,UINT cFields)
  1447. {
  1448. BOOL fOkay;
  1449. SZ szAdditionalNeeded = (SZ)NULL;
  1450. SZ szTotalFree = (SZ)NULL;
  1451. SZ szTotalNeeded = (SZ)NULL;
  1452. SZ szFreePerDisk = (SZ)NULL;
  1453. SZ szClusterPerDisk = (SZ)NULL;
  1454. SZ szTroublePairs = (SZ)NULL;
  1455. SZ szNeededPerDisk = (SZ)NULL;
  1456. SZ szExtraCosts = (SZ)NULL;
  1457. ChkArg(cFields >= 3, 1, fFalse);
  1458. Assert(FValidCopyList( pLocalInfPermInfo() ));
  1459. fParseError = fTrue;
  1460. if (!FGetArgSz(Line, &cFields, &szAdditionalNeeded) || *szAdditionalNeeded == '\0'
  1461. || !FGetArgSz(Line, &cFields, &szTotalFree) || *szTotalFree == '\0'
  1462. || !FGetArgSz(Line, &cFields, &szTotalNeeded) || *szTotalNeeded == '\0'
  1463. || (cFields >= 5 && !FGetArgSz(Line, &cFields, &szFreePerDisk))
  1464. || (cFields >= 6 && !FGetArgSz(Line, &cFields, &szClusterPerDisk))
  1465. || (cFields >= 7 && !FGetArgSz(Line, &cFields, &szTroublePairs))
  1466. || (cFields >= 8 && !FGetArgSz(Line, &cFields, &szNeededPerDisk))
  1467. || (cFields == 9 && !FGetArgSz(Line, &cFields, &szExtraCosts)))
  1468. fOkay = fFalse;
  1469. else
  1470. {
  1471. fParseError = fFalse;
  1472. fOkay = FGetCopyListCost(szAdditionalNeeded, szTotalFree, szTotalNeeded,
  1473. szFreePerDisk, szClusterPerDisk, szTroublePairs,
  1474. szNeededPerDisk, szExtraCosts);
  1475. }
  1476. if(szAdditionalNeeded) {
  1477. SFree(szAdditionalNeeded);
  1478. }
  1479. if(szTotalFree) {
  1480. SFree(szTotalFree);
  1481. }
  1482. if(szTotalNeeded) {
  1483. SFree(szTotalNeeded);
  1484. }
  1485. if(szFreePerDisk) {
  1486. SFree(szFreePerDisk);
  1487. }
  1488. if(szClusterPerDisk) {
  1489. SFree(szClusterPerDisk);
  1490. }
  1491. if(szTroublePairs) {
  1492. SFree(szTroublePairs);
  1493. }
  1494. if(szNeededPerDisk) {
  1495. SFree(szNeededPerDisk);
  1496. }
  1497. if(szExtraCosts) {
  1498. SFree(szExtraCosts);
  1499. }
  1500. return(fOkay);
  1501. }
  1502. BOOL APIENTRY FInitParsingTables( void )
  1503. {
  1504. psptCommands = PsptInitParsingTable(rgscpCommands);
  1505. if (!psptCommands) {
  1506. return(fFalse);
  1507. }
  1508. psptOptions = PsptInitParsingTable(rgscpOptions);
  1509. if (!psptOptions) {
  1510. FDestroyParsingTable(psptCommands);
  1511. psptCommands = NULL;
  1512. return(fFalse);
  1513. }
  1514. return(fTrue);
  1515. }
  1516. /*
  1517. ** Purpose:
  1518. ** Arguments:
  1519. ** Returns:
  1520. **
  1521. *************************************************************************/
  1522. BOOL APIENTRY FParseInstallSection(HANDLE hInstance, SZ szSection)
  1523. {
  1524. BOOL fDone = fFalse;
  1525. BOOL fOkay = fTrue;
  1526. INT Line;
  1527. if((Line = FindInfSectionLine(szSection)) == -1)
  1528. return(fFalse);
  1529. psptCommands = PsptInitParsingTable(rgscpCommands);
  1530. if (!psptCommands) {
  1531. return(fFalse);
  1532. }
  1533. psptOptions = PsptInitParsingTable(rgscpOptions);
  1534. if (!psptOptions) {
  1535. FDestroyParsingTable(psptCommands);
  1536. psptCommands = NULL;
  1537. return(fFalse);
  1538. }
  1539. while (fOkay && (!fDone) && ((Line = FindNextLineFromInf(Line)) != -1) &&
  1540. FHandleFlowStatements(&Line,hwndFrame, szSection, NULL, NULL))
  1541. {
  1542. UINT cFields = CFieldsInInfLine(Line);
  1543. if (cFields)
  1544. {
  1545. SZ szCommand;
  1546. iFieldCur = 1;
  1547. fParseError = fFalse;
  1548. if ((fOkay = FGetArgSz(Line,&cFields, &szCommand)) != fFalse)
  1549. {
  1550. SPC spc = SpcParseString(psptCommands, szCommand);
  1551. switch (spc)
  1552. {
  1553. default:
  1554. fParseError = fTrue;
  1555. fOkay = fFalse;
  1556. break;
  1557. #ifdef UNUSED
  1558. case spcUndoActionsAndExit:
  1559. fOkay = FUndoActions();
  1560. fDone = fTrue;
  1561. break;
  1562. #endif /* UNUSED */
  1563. case spcAddSectionFilesToCopyList:
  1564. fOkay = FParseCopySection(Line, &cFields);
  1565. break;
  1566. case spcAddSectionKeyFileToCopyList:
  1567. fOkay = FParseCopySectionKey(Line, &cFields);
  1568. break;
  1569. case spcAddNthSectionFileToCopyList:
  1570. fOkay = FParseCopyNthSection(Line, &cFields);
  1571. break;
  1572. case spcCopyFilesInCopyList:
  1573. fOkay = FCopyFilesInCopyList(hInstance);
  1574. if (!fOkay && fUserQuit)
  1575. fOkay = fDone = fTrue;
  1576. Assert(*(PpclnHeadList(pLocalInfPermInfo())) == (PCLN)NULL);
  1577. break;
  1578. #ifdef UNUSED
  1579. case spcBackupSectionFiles:
  1580. fOkay = FParseSectionFiles(Line, &cFields, FBackupSectionFiles);
  1581. break;
  1582. case spcBackupSectionKeyFile:
  1583. fOkay = FParseSectionKeyFile(Line, &cFields,
  1584. FBackupSectionKeyFile);
  1585. break;
  1586. case spcBackupNthSectionFile:
  1587. fOkay = FParseSectionNFile(Line, &cFields, FBackupNthSectionFile);
  1588. break;
  1589. case spcRemoveSectionFiles:
  1590. fOkay = FParseSectionFiles(Line, &cFields, FRemoveSectionFiles);
  1591. break;
  1592. case spcRemoveSectionKeyFile:
  1593. fOkay = FParseSectionKeyFile(Line, &cFields,
  1594. FRemoveSectionKeyFile);
  1595. break;
  1596. case spcRemoveNthSectionFile:
  1597. fOkay = FParseSectionNFile(Line, &cFields, FRemoveNthSectionFile);
  1598. break;
  1599. #endif /* UNUSED */
  1600. case spcCreateDir:
  1601. fOkay = FParseDirectory(Line, &cFields, FCreateDir);
  1602. break;
  1603. case spcRemoveDir:
  1604. fOkay = FParseDirectory(Line, &cFields, FRemoveDir);
  1605. break;
  1606. case spcCreateIniSection:
  1607. case spcReplaceIniSection:
  1608. case spcRemoveIniSection:
  1609. case spcCreateIniKeyNoValue:
  1610. case spcCreateIniKeyValue:
  1611. case spcReplaceIniKeyValue:
  1612. case spcRemoveIniKey:
  1613. case spcCreateSysIniKeyValue:
  1614. fOkay = FParseIniSection(Line, &cFields, spc);
  1615. break;
  1616. #ifdef UNUSED
  1617. case spcSetEnvVariableValue:
  1618. fOkay = FParseSetEnv(Line, &cFields);
  1619. break;
  1620. #endif /* UNUSED */
  1621. case spcCreateProgManGroup:
  1622. fOkay = FParseCreateProgManGroup(Line, &cFields, FALSE);
  1623. break;
  1624. case spcCreateCommonProgManGroup:
  1625. fOkay = FParseCreateProgManGroup(Line, &cFields, TRUE);
  1626. break;
  1627. case spcRemoveProgManGroup:
  1628. fOkay = FParseRemoveProgManGroup(Line, &cFields, FALSE);
  1629. break;
  1630. case spcRemoveCommonProgManGroup:
  1631. fOkay = FParseRemoveProgManGroup(Line, &cFields, TRUE);
  1632. break;
  1633. case spcRemoveProgManItem:
  1634. fOkay = FParseRemoveProgManItem(Line, &cFields,FALSE);
  1635. break;
  1636. case spcRemoveCommonProgManItem:
  1637. fOkay = FParseRemoveProgManItem(Line, &cFields,TRUE);
  1638. break;
  1639. case spcCreateProgManItem:
  1640. fOkay = FParseCreateProgManItem(Line, &cFields,FALSE);
  1641. break;
  1642. case spcCreateCommonProgManItem:
  1643. fOkay = FParseCreateProgManItem(Line, &cFields,TRUE);
  1644. break;
  1645. case spcShowProgManGroup:
  1646. fOkay = FParseShowProgManGroup(Line, &cFields, FALSE);
  1647. break;
  1648. case spcShowCommonProgManGroup:
  1649. fOkay = FParseShowProgManGroup(Line, &cFields, TRUE);
  1650. break;
  1651. case spcStampResource:
  1652. fOkay = FParseStampResource(Line, &cFields);
  1653. break;
  1654. case spcCloseSys:
  1655. fOkay = FParseCloseSystem(Line, &cFields);
  1656. break;
  1657. case spcClearCopyList:
  1658. if (cFields != 1)
  1659. fParseError = fTrue;
  1660. else
  1661. {
  1662. if (*(PpclnHeadList( pLocalInfPermInfo() )) != (PCLN)NULL)
  1663. EvalAssert(FFreeCopyList( pLocalInfPermInfo() ));
  1664. fOkay = fTrue;
  1665. }
  1666. break;
  1667. case spcSetupGetCopyListCost:
  1668. if (cFields != 4)
  1669. fParseError = fTrue;
  1670. else
  1671. {
  1672. SZ szFree = (SZ)NULL;
  1673. SZ szCluster = (SZ)NULL;
  1674. SZ szTotal = (SZ)NULL;
  1675. fParseError = fTrue;
  1676. if (!FGetArgSz(Line, &cFields, &szFree) || *szFree == '\0'
  1677. || !FGetArgSz(Line, &cFields, &szCluster)
  1678. || !FGetArgSz(Line, &cFields, &szTotal)
  1679. || *szCluster == '\0' || *szTotal == '\0')
  1680. fOkay = fFalse;
  1681. else
  1682. {
  1683. fParseError = fFalse;
  1684. fOkay = FSetupGetCopyListCost(szFree, szCluster,
  1685. szTotal);
  1686. }
  1687. if(szFree) {
  1688. SFree(szFree);
  1689. }
  1690. if(szCluster) {
  1691. SFree(szCluster);
  1692. }
  1693. if(szTotal) {
  1694. SFree(szTotal);
  1695. }
  1696. }
  1697. break;
  1698. case spcGetCopyListCost:
  1699. if (cFields < 3)
  1700. fParseError = fTrue;
  1701. else
  1702. {
  1703. Assert(FValidCopyList( pLocalInfPermInfo() ));
  1704. fOkay = FParseGetCopyListCost(Line, cFields);
  1705. }
  1706. break;
  1707. #ifdef UNUSED
  1708. case spcParseSharedAppList:
  1709. Assert(cFields == 2);
  1710. /* BLOCK */
  1711. {
  1712. SZ szList = (SZ)NULL;
  1713. if (!FGetArgSz(Line, &cFields, &szList))
  1714. fOkay = fFalse;
  1715. else
  1716. fOkay = FParseSharedAppList(szList);
  1717. if(szList) {
  1718. SFree(szList);
  1719. }
  1720. }
  1721. break;
  1722. case spcInstallSharedAppList:
  1723. Assert(cFields == 2);
  1724. /* BLOCK */
  1725. {
  1726. SZ szList = (SZ)NULL;
  1727. if (!FGetArgSz(Line, &cFields, &szList))
  1728. fOkay = fFalse;
  1729. else
  1730. fOkay = FInstallSharedAppList(szList);
  1731. if(szList) {
  1732. SFree(szList);
  1733. }
  1734. }
  1735. break;
  1736. #endif /* UNUSED */
  1737. case spcDumpCopyList:
  1738. #if DBG
  1739. /* BLOCK */
  1740. {
  1741. PCLN pclnCur;
  1742. PFH pfh;
  1743. /* REVIEW BUG - take a filename as an arg */
  1744. EvalAssert((pfh = PfhOpenFile("c:copylist.txt",
  1745. ofmCreate)) != (PFH)NULL);
  1746. FWriteSzToFile(pfh, "*** COPY LIST ***\r\n");
  1747. Assert(FValidCopyList( pLocalInfPermInfo() ));
  1748. pclnCur = *(PpclnHeadList( pLocalInfPermInfo() ));
  1749. while (pclnCur != (PCLN)NULL)
  1750. {
  1751. PCLN pcln = pclnCur;
  1752. FPrintPcln(pfh, pclnCur);
  1753. pclnCur = pclnCur->pclnNext;
  1754. }
  1755. FWriteSzToFile(pfh, "\r\n*** END OF COPY LIST ***\r\n");
  1756. EvalAssert(FCloseFile(pfh)); /*** REVIEW: TEST ***/
  1757. }
  1758. #endif /* DBG */
  1759. break;
  1760. case spcExt:
  1761. fDone = fTrue;
  1762. break;
  1763. case spcSearchDirList:
  1764. fOkay = FParseSearchDirList(Line, &cFields);
  1765. break;
  1766. case spcSetupDOSApps:
  1767. fOkay = FParseSetupDOSAppsList(Line, &cFields);
  1768. break;
  1769. case spcChangeBootIniTimeout:
  1770. fOkay = FParseChangeBootIniTimeout(Line, &cFields);
  1771. break;
  1772. }
  1773. SFree(szCommand);
  1774. }
  1775. }
  1776. if (fParseError)
  1777. fOkay = fFalse;
  1778. }
  1779. EvalAssert(FDestroyParsingTable(psptCommands));
  1780. EvalAssert(FDestroyParsingTable(psptOptions));
  1781. if (!fParseError)
  1782. return(fOkay);
  1783. LoadString(hinstShell, IDS_ERROR, rgchInstBufTmpShort, cchpBufTmpShortMax);
  1784. LoadString(hinstShell, IDS_SHL_CMD_ERROR, rgchInstBufTmpLong,
  1785. cchpBufTmpLongMax);
  1786. /* BLOCK */
  1787. {
  1788. UINT cFields;
  1789. RGSZ rgsz;
  1790. UINT iszCur = 0;
  1791. SZ szCur;
  1792. EvalAssert((cFields = CFieldsInInfLine(Line)) != 0);
  1793. while ((rgsz = RgszFromInfScriptLine(Line,cFields)) == (RGSZ)NULL)
  1794. if (!FHandleOOM(hwndFrame))
  1795. return(fFalse);
  1796. EvalAssert((szCur = *rgsz) != (SZ)NULL);
  1797. while (szCur != (SZ)NULL)
  1798. {
  1799. if (iszCur == 0)
  1800. EvalAssert(SzStrCat(rgchInstBufTmpLong, "\n'")
  1801. == rgchInstBufTmpLong);
  1802. else
  1803. EvalAssert(SzStrCat(rgchInstBufTmpLong, " ")
  1804. == rgchInstBufTmpLong);
  1805. if (strlen(rgchInstBufTmpLong) + strlen(szCur) >
  1806. (cchpBufTmpLongMax - 7))
  1807. {
  1808. Assert(strlen(rgchInstBufTmpLong) <= (cchpBufTmpLongMax - 5));
  1809. EvalAssert(SzStrCat(rgchInstBufTmpLong, "...")
  1810. == rgchInstBufTmpLong);
  1811. break;
  1812. }
  1813. else
  1814. EvalAssert(SzStrCat(rgchInstBufTmpLong, szCur)
  1815. == rgchInstBufTmpLong);
  1816. szCur = rgsz[++iszCur];
  1817. }
  1818. EvalAssert(FFreeRgsz(rgsz));
  1819. EvalAssert(SzStrCat(rgchInstBufTmpLong, "'") == rgchInstBufTmpLong);
  1820. }
  1821. MessageBox(hwndFrame, rgchInstBufTmpLong, rgchInstBufTmpShort,
  1822. MB_OK | MB_ICONHAND);
  1823. return(fFalse);
  1824. }
  1825. /*
  1826. ** Purpose:
  1827. ** The Install entry point. Interprets the commands
  1828. ** in the specified Install Commands INF section.
  1829. ** Arguments:
  1830. ** hinst, hwnd : Windows stuff
  1831. ** rgsz : array of arguments (NULL terminated)
  1832. ** csz : count of arguments (must be 1)
  1833. ** Returns:
  1834. ** fTrue if successful
  1835. ** fFalse if not
  1836. *************************************************************************/
  1837. BOOL APIENTRY FInstallEntryPoint(HANDLE hinst, HWND hwnd, RGSZ rgsz,
  1838. UINT csz)
  1839. {
  1840. BOOL fOkay;
  1841. HDC hdc;
  1842. ChkArg(hinst != (HANDLE)NULL, 1, fFalse);
  1843. ChkArg(hwnd != (HWND)NULL, 2, fFalse);
  1844. ChkArg(rgsz != (RGSZ)NULL
  1845. && *rgsz != (SZ)NULL
  1846. && *(rgsz + 1) == (SZ)NULL, 3, fFalse);
  1847. ChkArg(csz == 1, 4, fFalse);
  1848. FInitFreeTable(pLocalInfPermInfo()); /* do not check return value! */
  1849. //REVIEW: these are globals that are being used for progress gizmo.
  1850. hwndFrame = hwnd;
  1851. hinstShell = hinst;
  1852. hdc = GetDC(NULL);
  1853. if (hdc) {
  1854. fMono = (GetDeviceCaps(hdc, NUMCOLORS) == 2);
  1855. ReleaseDC(NULL, hdc);
  1856. }
  1857. fUserQuit = fFalse;
  1858. fOkay = FParseInstallSection(hinst, rgsz[0]);
  1859. // EndProgmanDde();
  1860. if (fUserQuit)
  1861. return(FAddSymbolValueToSymTab(INSTALL_OUTCOME, USERQUIT));
  1862. else if (fOkay == fFalse)
  1863. return(FAddSymbolValueToSymTab(INSTALL_OUTCOME, FAILURE));
  1864. else
  1865. return(FAddSymbolValueToSymTab(INSTALL_OUTCOME, SUCCESS));
  1866. }
  1867. /* REVIEW should be in a separate DLL */
  1868. /*
  1869. ** Purpose:
  1870. ** ??
  1871. ** Arguments:
  1872. ** none
  1873. ** Returns:
  1874. ** none
  1875. **
  1876. ***************************************************************************/
  1877. INT APIENTRY EncryptCDData(pchBuf, pchName, pchOrg, wYear, wMonth,
  1878. wDay, pchSer)
  1879. UCHAR * pchBuf;
  1880. UCHAR * pchName;
  1881. UCHAR * pchOrg;
  1882. INT wYear;
  1883. INT wMonth;
  1884. INT wDay;
  1885. UCHAR * pchSer;
  1886. {
  1887. UCHAR ch, pchTmp[149];
  1888. UCHAR * pchCur;
  1889. UCHAR * szGarbageCur;
  1890. UCHAR * szGarbage = "LtRrBceHabCT AhlenN";
  1891. INT cchName, cchOrg, i, j, chksumName, chksumOrg;
  1892. time_t timet;
  1893. if (pchBuf == (UCHAR *)NULL)
  1894. return(1);
  1895. if (pchName == (UCHAR *)NULL || (cchName = lstrlen(pchName)) == 0 ||
  1896. cchName > 52)
  1897. return(2);
  1898. for (i = cchName, chksumName = 0; i > 0; )
  1899. if ((ch = *(pchName + --i)) < ' ')
  1900. return(2);
  1901. else
  1902. chksumName += ch;
  1903. if (pchOrg == (UCHAR *)NULL || (cchOrg = lstrlen(pchOrg)) == 0 ||
  1904. cchOrg > 52)
  1905. return(3);
  1906. for (i = cchOrg, chksumOrg = 0; i > 0; )
  1907. if ((ch = *(pchOrg + --i)) < ' ')
  1908. return(3);
  1909. else
  1910. chksumOrg += ch;
  1911. if (wYear < 1900 || wYear > 4096)
  1912. return(4);
  1913. if (wMonth < 1 || wMonth > 12)
  1914. return(5);
  1915. if (wDay < 1 || wDay > 31)
  1916. return(6);
  1917. if (pchSer == (UCHAR *)NULL || lstrlen(pchSer) != 20)
  1918. return(7);
  1919. time(&timet);
  1920. *(pchTmp + 0) = (UCHAR)(' ' + (timet & 0x0FF));
  1921. *(pchTmp + 1) = (UCHAR)('e' + (cchName & 0x0F));
  1922. *(pchTmp + 2) = (UCHAR)('e' + ((cchName >> 4) & 0x0F));
  1923. *(pchTmp + 3) = (UCHAR)('e' + (cchOrg & 0x0F));
  1924. *(pchTmp + 4) = (UCHAR)('e' + ((cchOrg >> 4) & 0x0F));
  1925. *(pchTmp + 5) = (UCHAR)('e' + (chksumName & 0x0F));
  1926. *(pchTmp + 6) = (UCHAR)('e' + ((chksumName >> 4) & 0x0F));
  1927. *(pchTmp + 7) = (UCHAR)('e' + (chksumOrg & 0x0F));
  1928. *(pchTmp + 8) = (UCHAR)('e' + ((chksumOrg >> 4) & 0x0F));
  1929. *(pchTmp + 9) = (UCHAR)('e' + (wDay & 0x0F));
  1930. *(pchTmp + 10) = (UCHAR)('e' + ((wDay >> 4) & 0x0F));
  1931. *(pchTmp + 11) = (UCHAR)('e' + (wMonth & 0x0F));
  1932. *(pchTmp + 12) = (UCHAR)('e' + (wYear & 0x0F));
  1933. *(pchTmp + 13) = (UCHAR)('e' + ((wYear >> 4) & 0x0F));
  1934. *(pchTmp + 14) = (UCHAR)('e' + ((wYear >> 8) & 0x0F));
  1935. pchCur = pchTmp + 15;
  1936. while ((*pchCur++ = *pchName++) != '\0')
  1937. ;
  1938. pchCur--;
  1939. while ((*pchCur++ = *pchOrg++) != '\0')
  1940. ;
  1941. pchCur--;
  1942. szGarbageCur = szGarbage;
  1943. for (i = 112 - cchName - cchOrg; i-- > 0; )
  1944. {
  1945. if (*szGarbageCur == '\0')
  1946. szGarbageCur = szGarbage;
  1947. *pchCur++ = *szGarbageCur++;
  1948. }
  1949. pchTmp[127] = 'k';
  1950. for (i = 0; i < 126; i++)
  1951. pchTmp[i + 1] = pchTmp[i] ^ pchTmp[i + 1];
  1952. for (i = 0, j = 110; i < 127; )
  1953. {
  1954. pchBuf[j] = pchTmp[i++];
  1955. j = (j + 111) & 0x7F;
  1956. }
  1957. pchBuf[127] = '\0';
  1958. lstrcpy(pchBuf + 128, pchSer);
  1959. return(0);
  1960. }
  1961. #ifdef UNUSED
  1962. /*
  1963. ** Purpose:
  1964. ** Arguments:
  1965. ** Returns:
  1966. **
  1967. *************************************************************************/
  1968. BOOL APIENTRY FParseSectionKeyFile(INT Line, UINT *pcFields, PFNSKF pfnskf)
  1969. {
  1970. BOOL fOkay = fFalse;
  1971. SZ szSection, szKey, szSrc;
  1972. fParseError = fTrue;
  1973. if (FGetArgSz(Line,pcFields, &szSection))
  1974. {
  1975. if (FGetArgSz(Line,pcFields, &szKey))
  1976. {
  1977. if (FGetArgSz(Line,pcFields, &szSrc))
  1978. {
  1979. Assert(szSection != NULL && szKey != NULL && szSrc != NULL);
  1980. if (*szSection != '\0' && *szKey != '\0' && FValidDir(szSrc))
  1981. {
  1982. fParseError = fFalse;
  1983. fOkay = (*pfnskf)(szSection, szKey, szSrc);
  1984. }
  1985. SFree(szSrc);
  1986. }
  1987. SFree(szKey);
  1988. }
  1989. SFree(szSection);
  1990. }
  1991. return(fOkay);
  1992. }
  1993. /*
  1994. ** Purpose:
  1995. ** Arguments:
  1996. ** Returns:
  1997. **
  1998. *************************************************************************/
  1999. BOOL APIENTRY FParseSectionNFile(INT Line, UINT *pcFields, PFNSNF pfnsnf)
  2000. {
  2001. BOOL fOkay = fFalse;
  2002. SZ szSection, szSrc;
  2003. UINT n;
  2004. fParseError = fTrue;
  2005. if (FGetArgSz(Line,pcFields, &szSection))
  2006. {
  2007. if (FGetArgUINT(Line,pcFields, &n))
  2008. if (FGetArgSz(Line,pcFields, &szSrc))
  2009. {
  2010. Assert(szSection != NULL && szSrc != NULL);
  2011. if (*szSection != '\0' && FValidDir(szSrc) && n > 0)
  2012. {
  2013. fParseError = fFalse;
  2014. fOkay = (*pfnsnf)(szSection, n, szSrc);
  2015. }
  2016. SFree(szSrc);
  2017. }
  2018. SFree(szSection);
  2019. }
  2020. return(fOkay);
  2021. }
  2022. #endif /* UNUSED */