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.

4537 lines
119 KiB

  1. /*++
  2. Copyright (c) 1991-1999, Microsoft Corporation All rights reserved.
  3. Module Name:
  4. locale.c
  5. Abstract:
  6. This file contains functions necessary to parse and write the locale
  7. specific tables to a data file.
  8. External Routines in this file:
  9. ParseWriteLocale
  10. Revision History:
  11. 12-10-91 JulieB Created.
  12. 03-10-00 lguindon Add explicit typecast to remove build errors
  13. --*/
  14. //
  15. // Include Files.
  16. //
  17. #include "nlstrans.h"
  18. //
  19. // Constant Declarations.
  20. //
  21. #define OPT_CAL_FLAG 1
  22. #define ERA_RANGE_FLAG 2
  23. //
  24. // Forward Declarations.
  25. //
  26. int
  27. ParseLocaleInfo(
  28. PLOCALE_HEADER pLocHdr,
  29. PLOCALE_STATIC pLocStat,
  30. PLOCALE_VARIABLE pLocVar,
  31. PLOCALE_HEADER pLocCnt,
  32. PSZ pszKeyWord);
  33. int
  34. ParseLine(
  35. PSZ pszLine,
  36. WORD *pInfo,
  37. int BufSize,
  38. BOOL fConvert);
  39. int
  40. ParseMultiLine(
  41. PSZ pszLine,
  42. WORD *pInfo,
  43. int BufSize);
  44. int ParseMultiLineSize(
  45. PSZ pszLine,
  46. WORD *pInfo,
  47. int BufSize,
  48. WORD *pNum,
  49. int Flag);
  50. int
  51. GetLocaleInfoSize(
  52. int *pSize);
  53. int
  54. ScanBuffer(
  55. PSZ pszLine,
  56. WORD *pInfo,
  57. int BufSize,
  58. BYTE *pszKey,
  59. BOOL fConvert);
  60. int
  61. WriteLocaleInit(
  62. FILE **ppOutputFile,
  63. int NumLoc,
  64. int OffLoc);
  65. int
  66. WriteLocaleInfo(
  67. DWORD Locale,
  68. int *pOffHdr,
  69. int *pOffLoc,
  70. PLOCALE_HEADER pLocHdr,
  71. PLOCALE_STATIC pLocStat,
  72. PLOCALE_VARIABLE pLocVar,
  73. PLOCALE_HEADER pLocCnt,
  74. FILE *pOutputFile);
  75. int
  76. WriteVariableLength(
  77. PLOCALE_HEADER pLocCnt,
  78. PLOCALE_VARIABLE pLocVar,
  79. int *pTotalSize,
  80. FILE *pOutputFile);
  81. int
  82. ParseWriteCalendar(
  83. PCALENDAR_HEADER pCalHdr,
  84. PCALENDAR_VARIABLE pCalVar,
  85. PSZ pszKeyWord,
  86. FILE *pOutputFile,
  87. int OffHdr);
  88. int
  89. ParseCalendarInfo(
  90. PCALENDAR_HEADER pCalHdr,
  91. PCALENDAR_VARIABLE pCalVar,
  92. PCALENDAR_HEADER pCalCnt,
  93. PSZ pszKeyWord);
  94. int
  95. WriteCalendarInit(
  96. FILE *pOutputFile,
  97. int NumCal,
  98. int OffCalHdr);
  99. int
  100. WriteCalendarInfo(
  101. DWORD Calendar,
  102. int *pOffHdr,
  103. int *pOffCal,
  104. int OffCalBegin,
  105. PCALENDAR_HEADER pCalHdr,
  106. PCALENDAR_VARIABLE pCalVar,
  107. PCALENDAR_HEADER pCalCnt,
  108. FILE *pOutputFile);
  109. int
  110. WriteCalendarVariableLength(
  111. PCALENDAR_HEADER pCalCnt,
  112. PCALENDAR_VARIABLE pCalVar,
  113. int *pTotalSize,
  114. FILE *pOutputFile);
  115. int
  116. ConvertUnicodeToWord(
  117. WORD *pString,
  118. WORD *pValue);
  119. //-------------------------------------------------------------------------//
  120. // EXTERNAL ROUTINES //
  121. //-------------------------------------------------------------------------//
  122. ////////////////////////////////////////////////////////////////////////////
  123. //
  124. // ParseWriteLocale
  125. //
  126. // This routine parses the input file for the locale specific tables, and
  127. // then writes the data to the output file. This routine is only entered
  128. // when the LOCALE keyword is found. The parsing continues until the
  129. // ENDLOCALE keyword is found.
  130. //
  131. // 12-10-91 JulieB Created.
  132. ////////////////////////////////////////////////////////////////////////////
  133. int ParseWriteLocale(
  134. PLOCALE_HEADER pLocHdr,
  135. PLOCALE_STATIC pLocStat,
  136. PLOCALE_VARIABLE pLocVar,
  137. PSZ pszKeyWord)
  138. {
  139. int Num; // number of locales
  140. int OffHdr; // file offset to header info
  141. int OffLoc; // file offset to locale info
  142. DWORD LocId; // locale id
  143. FILE *pOutputFile; // ptr to output file
  144. LOCALE_HEADER LocCnt; // locale character counts
  145. CALENDAR_HEADER CalHdr; // calendar header structure
  146. CALENDAR_VARIABLE CalVar; // calendar variable structure
  147. //
  148. // Get size parameter.
  149. //
  150. if (GetSize(&Num))
  151. return (1);
  152. //
  153. // Set up initial file pointer offsets.
  154. //
  155. // OffHdr = header size
  156. // OffLoc = header size + (Number of locales * header entry size)
  157. //
  158. OffHdr = LOC_CAL_HDR_WORDS;
  159. OffLoc = LOC_CAL_HDR_WORDS + (Num * LOCALE_HDR_WORDS);
  160. //
  161. // Initialize the output file and write the number of locales to
  162. // the file. Also, in order to allow for the seek, write zeros
  163. // in the file up to the first locale field.
  164. //
  165. if (WriteLocaleInit( &pOutputFile,
  166. Num,
  167. OffLoc ))
  168. {
  169. return (1);
  170. }
  171. //
  172. // Parse all of the locales one by one. Write each one to the file
  173. // separately to conserve memory.
  174. //
  175. for (; Num > 0; Num--)
  176. {
  177. //
  178. // Initialize all Locale structures each time.
  179. //
  180. memset(pLocHdr, 0, sizeof(LOCALE_HEADER));
  181. memset(pLocStat, 0, sizeof(LOCALE_STATIC));
  182. memset(pLocVar, 0, sizeof(LOCALE_VARIABLE));
  183. memset(&LocCnt, 0, sizeof(LOCALE_HEADER));
  184. //
  185. // Get the BEGINLOCALE keyword and locale id.
  186. //
  187. if (fscanf( pInputFile,
  188. "%s %lx ;%*[^\n]",
  189. pszKeyWord,
  190. &LocId ) == 2)
  191. {
  192. if (_stricmp(pszKeyWord, "BEGINLOCALE") == 0)
  193. {
  194. if (Verbose)
  195. printf("\n\nFound BEGINLOCALE keyword, LocaleID = %x\n\n",
  196. LocId);
  197. }
  198. else
  199. {
  200. printf("Parse Error: Error reading BEGINLOCALE and Locale ID.\n");
  201. fclose(pOutputFile);
  202. return (1);
  203. }
  204. }
  205. else
  206. {
  207. printf("Parse Error: Invalid Instruction '%s'.\n", pszKeyWord);
  208. printf(" Expecting BEGINLOCALE keyword and Locale ID.\n");
  209. fclose(pOutputFile);
  210. return (1);
  211. }
  212. //
  213. // Parse the locale information.
  214. //
  215. if (ParseLocaleInfo( pLocHdr,
  216. pLocStat,
  217. pLocVar,
  218. &LocCnt,
  219. pszKeyWord ))
  220. {
  221. printf("Parse Error: Language == %ws.\n", pLocStat->szILanguage);
  222. fclose(pOutputFile);
  223. return (1);
  224. }
  225. //
  226. // Write the locale id, offset, and locale information to
  227. // the output file.
  228. //
  229. if (WriteLocaleInfo( LocId,
  230. &OffHdr,
  231. &OffLoc,
  232. pLocHdr,
  233. pLocStat,
  234. pLocVar,
  235. &LocCnt,
  236. pOutputFile ))
  237. {
  238. printf("Write Error: Language == %ws.\n", pLocStat->szILanguage);
  239. fclose(pOutputFile);
  240. return (1);
  241. }
  242. }
  243. //
  244. // Look for ENDLOCALE keyword.
  245. //
  246. if (fscanf(pInputFile, "%s", pszKeyWord) == 1)
  247. {
  248. if (_stricmp(pszKeyWord, "ENDLOCALE") == 0)
  249. {
  250. if (Verbose)
  251. printf("\n\nFound ENDLOCALE keyword.\n");
  252. }
  253. else
  254. {
  255. //
  256. // The ENDLOCALE keyword was not found. Return failure.
  257. //
  258. printf("Parse Error: Expecting ENDLOCALE keyword.\n");
  259. fclose(pOutputFile);
  260. return (1);
  261. }
  262. }
  263. else
  264. {
  265. //
  266. // The ENDLOCALE keyword was not found. Return failure.
  267. //
  268. printf("Parse Error: Expecting ENDLOCALE keyword.\n");
  269. fclose(pOutputFile);
  270. return (1);
  271. }
  272. //
  273. // Look for CALENDAR keyword.
  274. //
  275. if (fscanf(pInputFile, "%s", pszKeyWord) == 1)
  276. {
  277. if (_stricmp(pszKeyWord, "CALENDAR") == 0)
  278. {
  279. if (Verbose)
  280. printf("\n\nFound CALENDAR keyword.\n");
  281. }
  282. else
  283. {
  284. //
  285. // The CALENDAR keyword was not found. Return failure.
  286. //
  287. printf("Parse Error: Expecting CALENDAR keyword.\n");
  288. fclose(pOutputFile);
  289. return (1);
  290. }
  291. }
  292. else
  293. {
  294. //
  295. // The CALENDAR keyword was not found. Return failure.
  296. //
  297. printf("Parse Error: Expecting CALENDAR keyword.\n");
  298. fclose(pOutputFile);
  299. return (1);
  300. }
  301. //
  302. // Get the valid keywords for CALENDAR.
  303. // Write the CALENDAR information to an output file.
  304. //
  305. if (ParseWriteCalendar( &CalHdr,
  306. &CalVar,
  307. pszKeyWord,
  308. pOutputFile,
  309. OffLoc ))
  310. {
  311. fclose(pOutputFile);
  312. return (1);
  313. }
  314. //
  315. // Close the output file.
  316. //
  317. fclose(pOutputFile);
  318. //
  319. // Return success.
  320. //
  321. printf("\nSuccessfully wrote output file %s\n", LOCALE_FILE);
  322. return (0);
  323. }
  324. //-------------------------------------------------------------------------//
  325. // INTERNAL ROUTINES //
  326. //-------------------------------------------------------------------------//
  327. ////////////////////////////////////////////////////////////////////////////
  328. //
  329. // ParseLocaleInfo
  330. //
  331. // This routine parses the locale information from the input file. If an
  332. // error is encountered, a 1 is returned.
  333. //
  334. // 12-10-91 JulieB Created.
  335. ////////////////////////////////////////////////////////////////////////////
  336. int ParseLocaleInfo(
  337. PLOCALE_HEADER pLocHdr,
  338. PLOCALE_STATIC pLocStat,
  339. PLOCALE_VARIABLE pLocVar,
  340. PLOCALE_HEADER pLocCnt,
  341. PSZ pszKeyWord)
  342. {
  343. int Count; // number of characters written
  344. WORD Tmp; // tmp place holder
  345. //
  346. // Read in the information associated with the language of a locale
  347. // and store it in the locale structure.
  348. //
  349. if (!ParseLine( pszKeyWord,
  350. pLocStat->szILanguage,
  351. 5,
  352. TRUE ))
  353. {
  354. return (1);
  355. }
  356. pLocHdr->SLanguage = (sizeof(LOCALE_HEADER) + sizeof(LOCALE_STATIC)) /
  357. sizeof(WORD);
  358. if (!(Count = ParseLine( pszKeyWord,
  359. pLocVar->szSLanguage,
  360. MAX,
  361. TRUE )))
  362. {
  363. return (1);
  364. }
  365. pLocCnt->SLanguage = (WORD)Count;
  366. pLocHdr->SAbbrevLang = pLocHdr->SLanguage + Count;
  367. if (!(Count = ParseLine( pszKeyWord,
  368. pLocVar->szSAbbrevLang,
  369. MAX,
  370. TRUE )))
  371. {
  372. return (1);
  373. }
  374. pLocCnt->SAbbrevLang = (WORD)Count;
  375. pLocHdr->SAbbrevLangISO = pLocHdr->SAbbrevLang + Count;
  376. if (!(Count = ParseLine( pszKeyWord,
  377. pLocVar->szSAbbrevLangISO,
  378. MAX,
  379. TRUE )))
  380. {
  381. return (1);
  382. }
  383. pLocCnt->SAbbrevLangISO = (WORD)Count;
  384. pLocHdr->SNativeLang = pLocHdr->SAbbrevLangISO + Count;
  385. if (!(Count = ParseLine( pszKeyWord,
  386. pLocVar->szSNativeLang,
  387. MAX,
  388. TRUE )))
  389. {
  390. return (1);
  391. }
  392. pLocCnt->SNativeLang = (WORD)Count;
  393. //
  394. // Read in the information associated with the country of a locale
  395. // and store it in the locale structure.
  396. //
  397. if (!ParseLine( pszKeyWord,
  398. pLocStat->szICountry,
  399. 6,
  400. TRUE ))
  401. {
  402. return (1);
  403. }
  404. pLocHdr->SCountry = pLocHdr->SNativeLang + Count;
  405. if (!(Count = ParseLine( pszKeyWord,
  406. pLocVar->szSCountry,
  407. MAX,
  408. TRUE )))
  409. {
  410. return (1);
  411. }
  412. pLocCnt->SCountry = (WORD)Count;
  413. pLocHdr->SAbbrevCtry = pLocHdr->SCountry + Count;
  414. if (!(Count = ParseLine( pszKeyWord,
  415. pLocVar->szSAbbrevCtry,
  416. MAX,
  417. TRUE )))
  418. {
  419. return (1);
  420. }
  421. pLocCnt->SAbbrevCtry = (WORD)Count;
  422. pLocHdr->SAbbrevCtryISO = pLocHdr->SAbbrevCtry + Count;
  423. if (!(Count = ParseLine( pszKeyWord,
  424. pLocVar->szSAbbrevCtryISO,
  425. MAX,
  426. TRUE )))
  427. {
  428. return (1);
  429. }
  430. pLocCnt->SAbbrevCtryISO = (WORD)Count;
  431. pLocHdr->SNativeCtry = pLocHdr->SAbbrevCtryISO + Count;
  432. if (!(Count = ParseLine( pszKeyWord,
  433. pLocVar->szSNativeCtry,
  434. MAX,
  435. TRUE )))
  436. {
  437. return (1);
  438. }
  439. pLocCnt->SNativeCtry = (WORD)Count;
  440. if (!ParseLine( pszKeyWord,
  441. pLocStat->szIGeoId,
  442. 8,
  443. TRUE ))
  444. {
  445. return (1);
  446. }
  447. //
  448. // Read in the default language, country, and code pages of a locale
  449. // and store it in the locale structure.
  450. //
  451. if (!ParseLine( pszKeyWord,
  452. pLocStat->szIDefaultLang,
  453. 5,
  454. TRUE ))
  455. {
  456. return (1);
  457. }
  458. if (!ParseLine( pszKeyWord,
  459. pLocStat->szIDefaultCtry,
  460. 6,
  461. TRUE ))
  462. {
  463. return (1);
  464. }
  465. if (!ParseLine( pszKeyWord,
  466. pLocStat->szIDefaultACP,
  467. 6,
  468. TRUE ))
  469. {
  470. return (1);
  471. }
  472. if (!ConvertUnicodeToWord( pLocStat->szIDefaultACP,
  473. &(pLocStat->DefaultACP) ))
  474. {
  475. printf("Parse Error: Invalid IDEFAULTACP value %s\n",
  476. pLocStat->szIDefaultACP);
  477. return (1);
  478. }
  479. if (!ParseLine( pszKeyWord,
  480. pLocStat->szIDefaultOCP,
  481. 6,
  482. TRUE ))
  483. {
  484. return (1);
  485. }
  486. if (!ParseLine( pszKeyWord,
  487. pLocStat->szIDefaultMACCP,
  488. 6,
  489. TRUE ))
  490. {
  491. return (1);
  492. }
  493. if (!ParseLine( pszKeyWord,
  494. pLocStat->szIDefaultEBCDICCP,
  495. 6,
  496. TRUE ))
  497. {
  498. return (1);
  499. }
  500. //
  501. // Read in the list separator, measurement info, and default paper size
  502. // of a locale and store it in the locale structure.
  503. //
  504. pLocHdr->SList = pLocHdr->SNativeCtry + Count;
  505. if (!(Count = ParseLine( pszKeyWord,
  506. pLocVar->szSList,
  507. MAX,
  508. TRUE )))
  509. {
  510. return (1);
  511. }
  512. pLocCnt->SList = (WORD)Count;
  513. if (!ParseLine( pszKeyWord,
  514. pLocStat->szIMeasure,
  515. 2,
  516. TRUE ))
  517. {
  518. return (1);
  519. }
  520. if (!ParseLine( pszKeyWord,
  521. pLocStat->szIPaperSize,
  522. 2,
  523. TRUE ))
  524. {
  525. return (1);
  526. }
  527. //
  528. // Read in the digits information of a locale and store it in the
  529. // locale structure.
  530. //
  531. pLocHdr->SDecimal = pLocHdr->SList + Count;
  532. if (!(Count = ParseLine( pszKeyWord,
  533. pLocVar->szSDecimal,
  534. MAX,
  535. TRUE )))
  536. {
  537. return (1);
  538. }
  539. pLocCnt->SDecimal = (WORD)Count;
  540. pLocHdr->SThousand = pLocHdr->SDecimal + Count;
  541. if (!(Count = ParseLine( pszKeyWord,
  542. pLocVar->szSThousand,
  543. MAX,
  544. TRUE )))
  545. {
  546. return (1);
  547. }
  548. pLocCnt->SThousand = (WORD)Count;
  549. pLocHdr->SGrouping = pLocHdr->SThousand + Count;
  550. if (!(Count = ParseLine( pszKeyWord,
  551. pLocVar->szSGrouping,
  552. MAX,
  553. TRUE )))
  554. {
  555. return (1);
  556. }
  557. pLocCnt->SGrouping = (WORD)Count;
  558. if (!ParseLine( pszKeyWord,
  559. pLocStat->szIDigits,
  560. 3,
  561. TRUE ))
  562. {
  563. return (1);
  564. }
  565. if (!ParseLine( pszKeyWord,
  566. pLocStat->szILZero,
  567. 2,
  568. TRUE ))
  569. {
  570. return (1);
  571. }
  572. if (!ParseLine( pszKeyWord,
  573. pLocStat->szINegNumber,
  574. 2,
  575. TRUE ))
  576. {
  577. return (1);
  578. }
  579. pLocHdr->SNativeDigits = pLocHdr->SGrouping + Count;
  580. if (!(Count = ParseLine( pszKeyWord,
  581. pLocVar->szSNativeDigits,
  582. MAX,
  583. TRUE )))
  584. {
  585. return (1);
  586. }
  587. pLocCnt->SNativeDigits = (WORD)Count;
  588. if (!ParseLine( pszKeyWord,
  589. pLocStat->szIDigitSubstitution,
  590. 2,
  591. TRUE ))
  592. {
  593. return (1);
  594. }
  595. //
  596. // Read in the monetary information of a locale and store it in the
  597. // locale structure.
  598. //
  599. pLocHdr->SCurrency = pLocHdr->SNativeDigits + Count;
  600. if (!(Count = ParseLine( pszKeyWord,
  601. pLocVar->szSCurrency,
  602. MAX,
  603. TRUE )))
  604. {
  605. return (1);
  606. }
  607. pLocCnt->SCurrency = (WORD)Count;
  608. pLocHdr->SIntlSymbol = pLocHdr->SCurrency + Count;
  609. if (!(Count = ParseLine( pszKeyWord,
  610. pLocVar->szSIntlSymbol,
  611. MAX,
  612. TRUE )))
  613. {
  614. return (1);
  615. }
  616. pLocCnt->SIntlSymbol = (WORD)Count;
  617. pLocHdr->SEngCurrName = pLocHdr->SIntlSymbol + Count;
  618. if (!(Count = ParseLine( pszKeyWord,
  619. pLocVar->szSEngCurrName,
  620. MAX,
  621. TRUE )))
  622. {
  623. return (1);
  624. }
  625. pLocCnt->SEngCurrName = (WORD)Count;
  626. pLocHdr->SNativeCurrName = pLocHdr->SEngCurrName + Count;
  627. if (!(Count = ParseLine( pszKeyWord,
  628. pLocVar->szSNativeCurrName,
  629. MAX,
  630. TRUE )))
  631. {
  632. return (1);
  633. }
  634. pLocCnt->SNativeCurrName = (WORD)Count;
  635. pLocHdr->SMonDecSep = pLocHdr->SNativeCurrName + Count;
  636. if (!(Count = ParseLine( pszKeyWord,
  637. pLocVar->szSMonDecSep,
  638. MAX,
  639. TRUE )))
  640. {
  641. return (1);
  642. }
  643. pLocCnt->SMonDecSep = (WORD)Count;
  644. pLocHdr->SMonThousSep = pLocHdr->SMonDecSep + Count;
  645. if (!(Count = ParseLine( pszKeyWord,
  646. pLocVar->szSMonThousSep,
  647. MAX,
  648. TRUE )))
  649. {
  650. return (1);
  651. }
  652. pLocCnt->SMonThousSep = (WORD)Count;
  653. pLocHdr->SMonGrouping = pLocHdr->SMonThousSep + Count;
  654. if (!(Count = ParseLine( pszKeyWord,
  655. pLocVar->szSMonGrouping,
  656. MAX,
  657. TRUE )))
  658. {
  659. return (1);
  660. }
  661. pLocCnt->SMonGrouping = (WORD)Count;
  662. if (!ParseLine( pszKeyWord,
  663. pLocStat->szICurrDigits,
  664. 3,
  665. TRUE ))
  666. {
  667. return (1);
  668. }
  669. if (!ParseLine( pszKeyWord,
  670. pLocStat->szIIntlCurrDigits,
  671. 3,
  672. TRUE ))
  673. {
  674. return (1);
  675. }
  676. if (!ParseLine( pszKeyWord,
  677. pLocStat->szICurrency,
  678. 2,
  679. TRUE ))
  680. {
  681. return (1);
  682. }
  683. if (!ParseLine( pszKeyWord,
  684. pLocStat->szINegCurr,
  685. 3,
  686. TRUE ))
  687. {
  688. return (1);
  689. }
  690. //
  691. // Read in the positive and negative sign information of a locale
  692. // and store it in the locale structure.
  693. //
  694. pLocHdr->SPositiveSign = pLocHdr->SMonGrouping + Count;
  695. if (!(Count = ParseLine( pszKeyWord,
  696. pLocVar->szSPositiveSign,
  697. MAX,
  698. TRUE )))
  699. {
  700. return (1);
  701. }
  702. pLocCnt->SPositiveSign = (WORD)Count;
  703. pLocHdr->SNegativeSign = pLocHdr->SPositiveSign + Count;
  704. if (!(Count = ParseLine( pszKeyWord,
  705. pLocVar->szSNegativeSign,
  706. MAX,
  707. TRUE )))
  708. {
  709. return (1);
  710. }
  711. pLocCnt->SNegativeSign = (WORD)Count;
  712. //
  713. // Read in the time information of a locale and store it
  714. // in the locale structure.
  715. //
  716. pLocHdr->STimeFormat = pLocHdr->SNegativeSign + Count;
  717. if (!(Count = ParseMultiLine( pszKeyWord,
  718. pLocVar->szSTimeFormat,
  719. MAX )))
  720. {
  721. return (1);
  722. }
  723. pLocCnt->STimeFormat = (WORD)Count;
  724. pLocHdr->STime = pLocHdr->STimeFormat + Count;
  725. if (!(Count = ParseLine( pszKeyWord,
  726. pLocVar->szSTime,
  727. MAX,
  728. TRUE )))
  729. {
  730. return (1);
  731. }
  732. pLocCnt->STime = (WORD)Count;
  733. if (!ParseLine( pszKeyWord,
  734. pLocStat->szITime,
  735. 2,
  736. TRUE ))
  737. {
  738. return (1);
  739. }
  740. if (!ParseLine( pszKeyWord,
  741. pLocStat->szITLZero,
  742. 2,
  743. TRUE ))
  744. {
  745. return (1);
  746. }
  747. if (!ParseLine( pszKeyWord,
  748. pLocStat->szITimeMarkPosn,
  749. 2,
  750. TRUE ))
  751. {
  752. return (1);
  753. }
  754. pLocHdr->S1159 = pLocHdr->STime + Count;
  755. if (!(Count = ParseLine( pszKeyWord,
  756. pLocVar->szS1159,
  757. MAX,
  758. TRUE )))
  759. {
  760. return (1);
  761. }
  762. pLocCnt->S1159 = (WORD)Count;
  763. pLocHdr->S2359 = pLocHdr->S1159 + Count;
  764. if (!(Count = ParseLine( pszKeyWord,
  765. pLocVar->szS2359,
  766. MAX,
  767. TRUE )))
  768. {
  769. return (1);
  770. }
  771. pLocCnt->S2359 = (WORD)Count;
  772. //
  773. // Read in the short date information of a locale and store it
  774. // in the locale structure.
  775. //
  776. pLocHdr->SShortDate = pLocHdr->S2359 + Count;
  777. if (!(Count = ParseMultiLine( pszKeyWord,
  778. pLocVar->szSShortDate,
  779. MAX )))
  780. {
  781. return (1);
  782. }
  783. pLocCnt->SShortDate = (WORD)Count;
  784. pLocHdr->SDate = pLocHdr->SShortDate + Count;
  785. if (!(Count = ParseLine( pszKeyWord,
  786. pLocVar->szSDate,
  787. MAX,
  788. TRUE )))
  789. {
  790. return (1);
  791. }
  792. pLocCnt->SDate = (WORD)Count;
  793. if (!ParseLine( pszKeyWord,
  794. pLocStat->szIDate,
  795. 2,
  796. TRUE ))
  797. {
  798. return (1);
  799. }
  800. if (!ParseLine( pszKeyWord,
  801. pLocStat->szICentury,
  802. 2,
  803. TRUE ))
  804. {
  805. return (1);
  806. }
  807. if (!ParseLine( pszKeyWord,
  808. pLocStat->szIDayLZero,
  809. 2,
  810. TRUE ))
  811. {
  812. return (1);
  813. }
  814. if (!ParseLine( pszKeyWord,
  815. pLocStat->szIMonLZero,
  816. 2,
  817. TRUE ))
  818. {
  819. return (1);
  820. }
  821. //
  822. // Read in the long date information of a locale and store it
  823. // in the locale structure.
  824. //
  825. pLocHdr->SYearMonth = pLocHdr->SDate + Count;
  826. if (!(Count = ParseMultiLine( pszKeyWord,
  827. pLocVar->szSYearMonth,
  828. MAX )))
  829. {
  830. return (1);
  831. }
  832. pLocCnt->SYearMonth = (WORD)Count;
  833. pLocHdr->SLongDate = pLocHdr->SYearMonth + Count;
  834. if (!(Count = ParseMultiLine( pszKeyWord,
  835. pLocVar->szSLongDate,
  836. MAX )))
  837. {
  838. return (1);
  839. }
  840. pLocCnt->SLongDate = (WORD)Count;
  841. if (!ParseLine( pszKeyWord,
  842. pLocStat->szILDate,
  843. 2,
  844. TRUE ))
  845. {
  846. return (1);
  847. }
  848. if (!ParseLine( pszKeyWord,
  849. pLocStat->szICalendarType,
  850. 3,
  851. TRUE ))
  852. {
  853. return (1);
  854. }
  855. pLocHdr->IOptionalCalendar = pLocHdr->SLongDate + Count;
  856. if (!(Count = ParseMultiLineSize( pszKeyWord,
  857. pLocVar->szIOptionalCalendar,
  858. MAX,
  859. &Tmp,
  860. OPT_CAL_FLAG )))
  861. {
  862. return (1);
  863. }
  864. pLocCnt->IOptionalCalendar = (WORD)Count;
  865. if (!ParseLine(pszKeyWord,
  866. pLocStat->szIFirstDayOfWeek,
  867. 2,
  868. TRUE ))
  869. {
  870. return (1);
  871. }
  872. if (!ParseLine( pszKeyWord,
  873. pLocStat->szIFirstWeekOfYear,
  874. 2,
  875. TRUE ))
  876. {
  877. return (1);
  878. }
  879. //
  880. // Read in the day information of a locale and store it in the
  881. // locale structure.
  882. //
  883. pLocHdr->SDayName1 = pLocHdr->IOptionalCalendar + Count;
  884. if (!(Count = ParseLine( pszKeyWord,
  885. pLocVar->szSDayName1,
  886. MAX,
  887. TRUE )))
  888. {
  889. return (1);
  890. }
  891. pLocCnt->SDayName1 = (WORD)Count;
  892. pLocHdr->SDayName2 = pLocHdr->SDayName1 + Count;
  893. if (!(Count = ParseLine( pszKeyWord,
  894. pLocVar->szSDayName2,
  895. MAX,
  896. TRUE )))
  897. {
  898. return (1);
  899. }
  900. pLocCnt->SDayName2 = (WORD)Count;
  901. pLocHdr->SDayName3 = pLocHdr->SDayName2 + Count;
  902. if (!(Count = ParseLine( pszKeyWord,
  903. pLocVar->szSDayName3,
  904. MAX,
  905. TRUE )))
  906. {
  907. return (1);
  908. }
  909. pLocCnt->SDayName3 = (WORD)Count;
  910. pLocHdr->SDayName4 = pLocHdr->SDayName3 + Count;
  911. if (!(Count = ParseLine( pszKeyWord,
  912. pLocVar->szSDayName4,
  913. MAX,
  914. TRUE )))
  915. {
  916. return (1);
  917. }
  918. pLocCnt->SDayName4 = (WORD)Count;
  919. pLocHdr->SDayName5 = pLocHdr->SDayName4 + Count;
  920. if (!(Count = ParseLine( pszKeyWord,
  921. pLocVar->szSDayName5,
  922. MAX,
  923. TRUE )))
  924. {
  925. return (1);
  926. }
  927. pLocCnt->SDayName5 = (WORD)Count;
  928. pLocHdr->SDayName6 = pLocHdr->SDayName5 + Count;
  929. if (!(Count = ParseLine( pszKeyWord,
  930. pLocVar->szSDayName6,
  931. MAX,
  932. TRUE )))
  933. {
  934. return (1);
  935. }
  936. pLocCnt->SDayName6 = (WORD)Count;
  937. pLocHdr->SDayName7 = pLocHdr->SDayName6 + Count;
  938. if (!(Count = ParseLine( pszKeyWord,
  939. pLocVar->szSDayName7,
  940. MAX,
  941. TRUE )))
  942. {
  943. return (1);
  944. }
  945. pLocCnt->SDayName7 = (WORD)Count;
  946. pLocHdr->SAbbrevDayName1 = pLocHdr->SDayName7 + Count;
  947. if (!(Count = ParseLine( pszKeyWord,
  948. pLocVar->szSAbbrevDayName1,
  949. MAX,
  950. TRUE )))
  951. {
  952. return (1);
  953. }
  954. pLocCnt->SAbbrevDayName1 = (WORD)Count;
  955. pLocHdr->SAbbrevDayName2 = pLocHdr->SAbbrevDayName1 + Count;
  956. if (!(Count = ParseLine( pszKeyWord,
  957. pLocVar->szSAbbrevDayName2,
  958. MAX,
  959. TRUE )))
  960. {
  961. return (1);
  962. }
  963. pLocCnt->SAbbrevDayName2 = (WORD)Count;
  964. pLocHdr->SAbbrevDayName3 = pLocHdr->SAbbrevDayName2 + Count;
  965. if (!(Count = ParseLine( pszKeyWord,
  966. pLocVar->szSAbbrevDayName3,
  967. MAX,
  968. TRUE )))
  969. {
  970. return (1);
  971. }
  972. pLocCnt->SAbbrevDayName3 = (WORD)Count;
  973. pLocHdr->SAbbrevDayName4 = pLocHdr->SAbbrevDayName3 + Count;
  974. if (!(Count = ParseLine( pszKeyWord,
  975. pLocVar->szSAbbrevDayName4,
  976. MAX,
  977. TRUE )))
  978. {
  979. return (1);
  980. }
  981. pLocCnt->SAbbrevDayName4 = (WORD)Count;
  982. pLocHdr->SAbbrevDayName5 = pLocHdr->SAbbrevDayName4 + Count;
  983. if (!(Count = ParseLine( pszKeyWord,
  984. pLocVar->szSAbbrevDayName5,
  985. MAX,
  986. TRUE )))
  987. {
  988. return (1);
  989. }
  990. pLocCnt->SAbbrevDayName5 = (WORD)Count;
  991. pLocHdr->SAbbrevDayName6 = pLocHdr->SAbbrevDayName5 + Count;
  992. if (!(Count = ParseLine( pszKeyWord,
  993. pLocVar->szSAbbrevDayName6,
  994. MAX,
  995. TRUE )))
  996. {
  997. return (1);
  998. }
  999. pLocCnt->SAbbrevDayName6 = (WORD)Count;
  1000. pLocHdr->SAbbrevDayName7 = pLocHdr->SAbbrevDayName6 + Count;
  1001. if (!(Count = ParseLine( pszKeyWord,
  1002. pLocVar->szSAbbrevDayName7,
  1003. MAX,
  1004. TRUE )))
  1005. {
  1006. return (1);
  1007. }
  1008. pLocCnt->SAbbrevDayName7 = (WORD)Count;
  1009. //
  1010. // Read in the month information of a locale and store it in the
  1011. // locale structure.
  1012. //
  1013. pLocHdr->SMonthName1 = pLocHdr->SAbbrevDayName7 + Count;
  1014. if (!(Count = ParseLine( pszKeyWord,
  1015. pLocVar->szSMonthName1,
  1016. MAX,
  1017. TRUE )))
  1018. {
  1019. return (1);
  1020. }
  1021. pLocCnt->SMonthName1 = (WORD)Count;
  1022. pLocHdr->SMonthName2 = pLocHdr->SMonthName1 + Count;
  1023. if (!(Count = ParseLine( pszKeyWord,
  1024. pLocVar->szSMonthName2,
  1025. MAX,
  1026. TRUE )))
  1027. {
  1028. return (1);
  1029. }
  1030. pLocCnt->SMonthName2 = (WORD)Count;
  1031. pLocHdr->SMonthName3 = pLocHdr->SMonthName2 + Count;
  1032. if (!(Count = ParseLine( pszKeyWord,
  1033. pLocVar->szSMonthName3,
  1034. MAX,
  1035. TRUE )))
  1036. {
  1037. return (1);
  1038. }
  1039. pLocCnt->SMonthName3 = (WORD)Count;
  1040. pLocHdr->SMonthName4 = pLocHdr->SMonthName3 + Count;
  1041. if (!(Count = ParseLine( pszKeyWord,
  1042. pLocVar->szSMonthName4,
  1043. MAX,
  1044. TRUE )))
  1045. {
  1046. return (1);
  1047. }
  1048. pLocCnt->SMonthName4 = (WORD)Count;
  1049. pLocHdr->SMonthName5 = pLocHdr->SMonthName4 + Count;
  1050. if (!(Count = ParseLine( pszKeyWord,
  1051. pLocVar->szSMonthName5,
  1052. MAX,
  1053. TRUE )))
  1054. {
  1055. return (1);
  1056. }
  1057. pLocCnt->SMonthName5 = (WORD)Count;
  1058. pLocHdr->SMonthName6 = pLocHdr->SMonthName5 + Count;
  1059. if (!(Count = ParseLine( pszKeyWord,
  1060. pLocVar->szSMonthName6,
  1061. MAX,
  1062. TRUE )))
  1063. {
  1064. return (1);
  1065. }
  1066. pLocCnt->SMonthName6 = (WORD)Count;
  1067. pLocHdr->SMonthName7 = pLocHdr->SMonthName6 + Count;
  1068. if (!(Count = ParseLine( pszKeyWord,
  1069. pLocVar->szSMonthName7,
  1070. MAX,
  1071. TRUE )))
  1072. {
  1073. return (1);
  1074. }
  1075. pLocCnt->SMonthName7 = (WORD)Count;
  1076. pLocHdr->SMonthName8 = pLocHdr->SMonthName7 + Count;
  1077. if (!(Count = ParseLine( pszKeyWord,
  1078. pLocVar->szSMonthName8,
  1079. MAX,
  1080. TRUE )))
  1081. {
  1082. return (1);
  1083. }
  1084. pLocCnt->SMonthName8 = (WORD)Count;
  1085. pLocHdr->SMonthName9 = pLocHdr->SMonthName8 + Count;
  1086. if (!(Count = ParseLine( pszKeyWord,
  1087. pLocVar->szSMonthName9,
  1088. MAX,
  1089. TRUE )))
  1090. {
  1091. return (1);
  1092. }
  1093. pLocCnt->SMonthName9 = (WORD)Count;
  1094. pLocHdr->SMonthName10 = pLocHdr->SMonthName9 + Count;
  1095. if (!(Count = ParseLine( pszKeyWord,
  1096. pLocVar->szSMonthName10,
  1097. MAX,
  1098. TRUE )))
  1099. {
  1100. return (1);
  1101. }
  1102. pLocCnt->SMonthName10 = (WORD)Count;
  1103. pLocHdr->SMonthName11 = pLocHdr->SMonthName10 + Count;
  1104. if (!(Count = ParseLine( pszKeyWord,
  1105. pLocVar->szSMonthName11,
  1106. MAX,
  1107. TRUE )))
  1108. {
  1109. return (1);
  1110. }
  1111. pLocCnt->SMonthName11 = (WORD)Count;
  1112. pLocHdr->SMonthName12 = pLocHdr->SMonthName11 + Count;
  1113. if (!(Count = ParseLine( pszKeyWord,
  1114. pLocVar->szSMonthName12,
  1115. MAX,
  1116. TRUE )))
  1117. {
  1118. return (1);
  1119. }
  1120. pLocCnt->SMonthName12 = (WORD)Count;
  1121. pLocHdr->SMonthName13 = pLocHdr->SMonthName12 + Count;
  1122. if (!(Count = ParseLine( pszKeyWord,
  1123. pLocVar->szSMonthName13,
  1124. MAX,
  1125. TRUE )))
  1126. {
  1127. return (1);
  1128. }
  1129. pLocCnt->SMonthName13 = (WORD)Count;
  1130. pLocHdr->SAbbrevMonthName1 = pLocHdr->SMonthName13 + Count;
  1131. if (!(Count = ParseLine( pszKeyWord,
  1132. pLocVar->szSAbbrevMonthName1,
  1133. MAX,
  1134. TRUE )))
  1135. {
  1136. return (1);
  1137. }
  1138. pLocCnt->SAbbrevMonthName1 = (WORD)Count;
  1139. pLocHdr->SAbbrevMonthName2 = pLocHdr->SAbbrevMonthName1 + Count;
  1140. if (!(Count = ParseLine( pszKeyWord,
  1141. pLocVar->szSAbbrevMonthName2,
  1142. MAX,
  1143. TRUE )))
  1144. {
  1145. return (1);
  1146. }
  1147. pLocCnt->SAbbrevMonthName2 = (WORD)Count;
  1148. pLocHdr->SAbbrevMonthName3 = pLocHdr->SAbbrevMonthName2 + Count;
  1149. if (!(Count = ParseLine( pszKeyWord,
  1150. pLocVar->szSAbbrevMonthName3,
  1151. MAX,
  1152. TRUE )))
  1153. {
  1154. return (1);
  1155. }
  1156. pLocCnt->SAbbrevMonthName3 = (WORD)Count;
  1157. pLocHdr->SAbbrevMonthName4 = pLocHdr->SAbbrevMonthName3 + Count;
  1158. if (!(Count = ParseLine( pszKeyWord,
  1159. pLocVar->szSAbbrevMonthName4,
  1160. MAX,
  1161. TRUE )))
  1162. {
  1163. return (1);
  1164. }
  1165. pLocCnt->SAbbrevMonthName4 = (WORD)Count;
  1166. pLocHdr->SAbbrevMonthName5 = pLocHdr->SAbbrevMonthName4 + Count;
  1167. if (!(Count = ParseLine( pszKeyWord,
  1168. pLocVar->szSAbbrevMonthName5,
  1169. MAX,
  1170. TRUE )))
  1171. {
  1172. return (1);
  1173. }
  1174. pLocCnt->SAbbrevMonthName5 = (WORD)Count;
  1175. pLocHdr->SAbbrevMonthName6 = pLocHdr->SAbbrevMonthName5 + Count;
  1176. if (!(Count = ParseLine( pszKeyWord,
  1177. pLocVar->szSAbbrevMonthName6,
  1178. MAX,
  1179. TRUE )))
  1180. {
  1181. return (1);
  1182. }
  1183. pLocCnt->SAbbrevMonthName6 = (WORD)Count;
  1184. pLocHdr->SAbbrevMonthName7 = pLocHdr->SAbbrevMonthName6 + Count;
  1185. if (!(Count = ParseLine( pszKeyWord,
  1186. pLocVar->szSAbbrevMonthName7,
  1187. MAX,
  1188. TRUE )))
  1189. {
  1190. return (1);
  1191. }
  1192. pLocCnt->SAbbrevMonthName7 = (WORD)Count;
  1193. pLocHdr->SAbbrevMonthName8 = pLocHdr->SAbbrevMonthName7 + Count;
  1194. if (!(Count = ParseLine( pszKeyWord,
  1195. pLocVar->szSAbbrevMonthName8,
  1196. MAX,
  1197. TRUE )))
  1198. {
  1199. return (1);
  1200. }
  1201. pLocCnt->SAbbrevMonthName8 = (WORD)Count;
  1202. pLocHdr->SAbbrevMonthName9 = pLocHdr->SAbbrevMonthName8 + Count;
  1203. if (!(Count = ParseLine( pszKeyWord,
  1204. pLocVar->szSAbbrevMonthName9,
  1205. MAX,
  1206. TRUE )))
  1207. {
  1208. return (1);
  1209. }
  1210. pLocCnt->SAbbrevMonthName9 = (WORD)Count;
  1211. pLocHdr->SAbbrevMonthName10 = pLocHdr->SAbbrevMonthName9 + Count;
  1212. if (!(Count = ParseLine( pszKeyWord,
  1213. pLocVar->szSAbbrevMonthName10,
  1214. MAX,
  1215. TRUE )))
  1216. {
  1217. return (1);
  1218. }
  1219. pLocCnt->SAbbrevMonthName10 = (WORD)Count;
  1220. pLocHdr->SAbbrevMonthName11 = pLocHdr->SAbbrevMonthName10 + Count;
  1221. if (!(Count = ParseLine( pszKeyWord,
  1222. pLocVar->szSAbbrevMonthName11,
  1223. MAX,
  1224. TRUE )))
  1225. {
  1226. return (1);
  1227. }
  1228. pLocCnt->SAbbrevMonthName11 = (WORD)Count;
  1229. pLocHdr->SAbbrevMonthName12 = pLocHdr->SAbbrevMonthName11 + Count;
  1230. if (!(Count = ParseLine( pszKeyWord,
  1231. pLocVar->szSAbbrevMonthName12,
  1232. MAX,
  1233. TRUE )))
  1234. {
  1235. return (1);
  1236. }
  1237. pLocCnt->SAbbrevMonthName12 = (WORD)Count;
  1238. pLocHdr->SAbbrevMonthName13 = pLocHdr->SAbbrevMonthName12 + Count;
  1239. if (!(Count = ParseLine( pszKeyWord,
  1240. pLocVar->szSAbbrevMonthName13,
  1241. MAX,
  1242. TRUE )))
  1243. {
  1244. return (1);
  1245. }
  1246. pLocCnt->SAbbrevMonthName13 = (WORD)Count;
  1247. pLocHdr->SEndOfLocale = pLocHdr->SAbbrevMonthName13 + Count;
  1248. //
  1249. // Read in the font signature information of a locale and store it in
  1250. // the locale structure.
  1251. //
  1252. // NOTE: Don't want the null terminator on this string, so tell
  1253. // the parse routine that there is one more space in the buffer.
  1254. // This works because the buffer is filled with 0 initially, so
  1255. // no null terminator is added onto the end of the string.
  1256. // Instead, it will simply fill in the buffer with the
  1257. // MAX_FONTSIGNATURE amount of values.
  1258. //
  1259. if (!ParseLine( pszKeyWord,
  1260. pLocStat->szFontSignature,
  1261. MAX_FONTSIGNATURE + 1, // don't want null term
  1262. FALSE ))
  1263. {
  1264. return (1);
  1265. }
  1266. //
  1267. // Get szIPosSymPrecedes and szIPosSepBySpace from the szICurrency
  1268. // value.
  1269. //
  1270. // NOTE: All buffers initialized to 0, so no need to zero terminate.
  1271. //
  1272. switch (*(pLocStat->szICurrency))
  1273. {
  1274. case ( '0' ) :
  1275. {
  1276. *(pLocStat->szIPosSymPrecedes) = L'1';
  1277. *(pLocStat->szIPosSepBySpace) = L'0';
  1278. break;
  1279. }
  1280. case ( '1' ) :
  1281. {
  1282. *(pLocStat->szIPosSymPrecedes) = L'0';
  1283. *(pLocStat->szIPosSepBySpace) = L'0';
  1284. break;
  1285. }
  1286. case ( '2' ) :
  1287. {
  1288. *(pLocStat->szIPosSymPrecedes) = L'1';
  1289. *(pLocStat->szIPosSepBySpace) = L'1';
  1290. break;
  1291. }
  1292. case ( '3' ) :
  1293. {
  1294. *(pLocStat->szIPosSymPrecedes) = L'0';
  1295. *(pLocStat->szIPosSepBySpace) = L'1';
  1296. break;
  1297. }
  1298. default :
  1299. {
  1300. printf("Parse Error: Invalid ICURRENCY value.\n");
  1301. return (1);
  1302. }
  1303. }
  1304. //
  1305. // Get szIPosSignPosn, szINegSignPosn, szINegSymPrecedes, and
  1306. // szINegSepBySpace from the szINegCurr value.
  1307. //
  1308. // NOTE: All buffers initialized to 0, so no need to zero terminate.
  1309. //
  1310. switch (*(pLocStat->szINegCurr))
  1311. {
  1312. case ( '0' ) :
  1313. {
  1314. *(pLocStat->szIPosSignPosn) = L'3';
  1315. *(pLocStat->szINegSignPosn) = L'0';
  1316. *(pLocStat->szINegSymPrecedes) = L'1';
  1317. *(pLocStat->szINegSepBySpace) = L'0';
  1318. break;
  1319. }
  1320. case ( '1' ) :
  1321. {
  1322. switch (*((pLocStat->szINegCurr) + 1))
  1323. {
  1324. case ( 0 ) :
  1325. {
  1326. *(pLocStat->szIPosSignPosn) = L'3';
  1327. *(pLocStat->szINegSignPosn) = L'3';
  1328. *(pLocStat->szINegSymPrecedes) = L'1';
  1329. *(pLocStat->szINegSepBySpace) = L'0';
  1330. break;
  1331. }
  1332. case ( '0' ) :
  1333. {
  1334. *(pLocStat->szIPosSignPosn) = L'4';
  1335. *(pLocStat->szINegSignPosn) = L'4';
  1336. *(pLocStat->szINegSymPrecedes) = L'0';
  1337. *(pLocStat->szINegSepBySpace) = L'1';
  1338. break;
  1339. }
  1340. case ( '1' ) :
  1341. {
  1342. *(pLocStat->szIPosSignPosn) = L'2';
  1343. *(pLocStat->szINegSignPosn) = L'2';
  1344. *(pLocStat->szINegSymPrecedes) = L'1';
  1345. *(pLocStat->szINegSepBySpace) = L'1';
  1346. break;
  1347. }
  1348. case ( '2' ) :
  1349. {
  1350. *(pLocStat->szIPosSignPosn) = L'4';
  1351. *(pLocStat->szINegSignPosn) = L'4';
  1352. *(pLocStat->szINegSymPrecedes) = L'1';
  1353. *(pLocStat->szINegSepBySpace) = L'1';
  1354. break;
  1355. }
  1356. case ( '3' ) :
  1357. {
  1358. *(pLocStat->szIPosSignPosn) = L'3';
  1359. *(pLocStat->szINegSignPosn) = L'3';
  1360. *(pLocStat->szINegSymPrecedes) = L'0';
  1361. *(pLocStat->szINegSepBySpace) = L'1';
  1362. break;
  1363. }
  1364. case ( '4' ) :
  1365. {
  1366. *(pLocStat->szIPosSignPosn) = L'3';
  1367. *(pLocStat->szINegSignPosn) = L'0';
  1368. *(pLocStat->szINegSymPrecedes) = L'1';
  1369. *(pLocStat->szINegSepBySpace) = L'1';
  1370. break;
  1371. }
  1372. case ( '5' ) :
  1373. {
  1374. *(pLocStat->szIPosSignPosn) = L'1';
  1375. *(pLocStat->szINegSignPosn) = L'0';
  1376. *(pLocStat->szINegSymPrecedes) = L'0';
  1377. *(pLocStat->szINegSepBySpace) = L'1';
  1378. break;
  1379. }
  1380. default :
  1381. {
  1382. printf("Parse Error: Invalid INEGCURR value.\n");
  1383. return (1);
  1384. }
  1385. }
  1386. break;
  1387. }
  1388. case ( '2' ) :
  1389. {
  1390. *(pLocStat->szIPosSignPosn) = L'4';
  1391. *(pLocStat->szINegSignPosn) = L'4';
  1392. *(pLocStat->szINegSymPrecedes) = L'1';
  1393. *(pLocStat->szINegSepBySpace) = L'0';
  1394. break;
  1395. }
  1396. case ( '3' ) :
  1397. {
  1398. *(pLocStat->szIPosSignPosn) = L'2';
  1399. *(pLocStat->szINegSignPosn) = L'2';
  1400. *(pLocStat->szINegSymPrecedes) = L'1';
  1401. *(pLocStat->szINegSepBySpace) = L'0';
  1402. break;
  1403. }
  1404. case ( '4' ) :
  1405. {
  1406. *(pLocStat->szIPosSignPosn) = L'1';
  1407. *(pLocStat->szINegSignPosn) = L'0';
  1408. *(pLocStat->szINegSymPrecedes) = L'0';
  1409. *(pLocStat->szINegSepBySpace) = L'0';
  1410. break;
  1411. }
  1412. case ( '5' ) :
  1413. {
  1414. *(pLocStat->szIPosSignPosn) = L'1';
  1415. *(pLocStat->szINegSignPosn) = L'1';
  1416. *(pLocStat->szINegSymPrecedes) = L'0';
  1417. *(pLocStat->szINegSepBySpace) = L'0';
  1418. break;
  1419. }
  1420. case ( '6' ) :
  1421. {
  1422. *(pLocStat->szIPosSignPosn) = L'3';
  1423. *(pLocStat->szINegSignPosn) = L'3';
  1424. *(pLocStat->szINegSymPrecedes) = L'0';
  1425. *(pLocStat->szINegSepBySpace) = L'0';
  1426. break;
  1427. }
  1428. case ( '7' ) :
  1429. {
  1430. *(pLocStat->szIPosSignPosn) = L'4';
  1431. *(pLocStat->szINegSignPosn) = L'4';
  1432. *(pLocStat->szINegSymPrecedes) = L'0';
  1433. *(pLocStat->szINegSepBySpace) = L'0';
  1434. break;
  1435. }
  1436. case ( '8' ) :
  1437. {
  1438. *(pLocStat->szIPosSignPosn) = L'1';
  1439. *(pLocStat->szINegSignPosn) = L'1';
  1440. *(pLocStat->szINegSymPrecedes) = L'0';
  1441. *(pLocStat->szINegSepBySpace) = L'1';
  1442. break;
  1443. }
  1444. case ( '9' ) :
  1445. {
  1446. *(pLocStat->szIPosSignPosn) = L'3';
  1447. *(pLocStat->szINegSignPosn) = L'3';
  1448. *(pLocStat->szINegSymPrecedes) = L'1';
  1449. *(pLocStat->szINegSepBySpace) = L'1';
  1450. break;
  1451. }
  1452. default :
  1453. {
  1454. printf("Parse Error: Invalid INEGCURR value.\n");
  1455. return (1);
  1456. }
  1457. }
  1458. //
  1459. // Return success.
  1460. //
  1461. return (0);
  1462. }
  1463. ////////////////////////////////////////////////////////////////////////////
  1464. //
  1465. // ParseLine
  1466. //
  1467. // This routine parses one line of the input file. This routine is only
  1468. // called to parse a line within the LOCALE keyword section.
  1469. // Returns the number of characters written to the buffer (0 means error).
  1470. //
  1471. // 12-10-91 JulieB Created.
  1472. ////////////////////////////////////////////////////////////////////////////
  1473. int ParseLine(
  1474. PSZ pszLine,
  1475. WORD *pInfo,
  1476. int BufSize,
  1477. BOOL fConvert)
  1478. {
  1479. int Num = 0; // number of strings read in
  1480. BYTE pszKey[MAX]; // keyword - ignored
  1481. //
  1482. // Get to next line of information.
  1483. // If no more strings could be read in, return an error.
  1484. //
  1485. if (fscanf(pInputFile, "%s", pszKey) == 0)
  1486. {
  1487. printf("Parse Error: Incomplete LOCALE information.\n");
  1488. return (0);
  1489. }
  1490. //
  1491. // Read in the rest of the line.
  1492. //
  1493. if (fgets(pszLine, MAX, pInputFile) == NULL)
  1494. {
  1495. *pInfo = 0;
  1496. return (1);
  1497. }
  1498. //
  1499. // Return the count of characters put in the buffer.
  1500. //
  1501. return (ScanBuffer( pszLine,
  1502. pInfo,
  1503. BufSize,
  1504. pszKey,
  1505. fConvert ));
  1506. }
  1507. ////////////////////////////////////////////////////////////////////////////
  1508. //
  1509. // ParseMultiLine
  1510. //
  1511. // This routine parses multiple lines of the input file. This routine is only
  1512. // called to parse a set of lines within the LOCALE keyword section.
  1513. // Returns the number of characters written to the buffer (0 means error).
  1514. // This should only be called to parse multiple lines for ONE locale item.
  1515. //
  1516. // 12-10-91 JulieB Created.
  1517. ////////////////////////////////////////////////////////////////////////////
  1518. int ParseMultiLine(
  1519. PSZ pszLine,
  1520. WORD *pInfo,
  1521. int BufSize)
  1522. {
  1523. int Num = 0; // number of strings read in
  1524. BYTE pszKey[MAX]; // keyword - ignored
  1525. int Count = 0; // count of characters
  1526. int TmpCt; // ScanBuffer return count
  1527. WORD *pInfoPtr; // tmp ptr to pInfo buffer
  1528. //
  1529. // Get to next line of information.
  1530. // If no more strings could be read in, return an error.
  1531. //
  1532. if (fscanf(pInputFile, "%s", pszKey) == 0)
  1533. {
  1534. printf("Parse Error: Incomplete LOCALE information.\n");
  1535. return (0);
  1536. }
  1537. //
  1538. // Get size parameter.
  1539. //
  1540. if (GetLocaleInfoSize(&Num))
  1541. {
  1542. return (0);
  1543. }
  1544. //
  1545. // Check for num == 0.
  1546. //
  1547. if (Num == 0)
  1548. {
  1549. *pInfo = 0;
  1550. return (1);
  1551. }
  1552. //
  1553. // Read in the appropriate number of lines.
  1554. //
  1555. pInfoPtr = pInfo;
  1556. while (Num > 0)
  1557. {
  1558. //
  1559. // Read in the rest of the line. If nothing on the current line,
  1560. // go to the next line and try again.
  1561. //
  1562. if (fgets(pszLine, MAX, pInputFile) != NULL)
  1563. {
  1564. TmpCt = ScanBuffer( pszLine,
  1565. pInfoPtr,
  1566. BufSize - Count,
  1567. pszKey,
  1568. TRUE );
  1569. Num--;
  1570. pInfoPtr += TmpCt;
  1571. Count += TmpCt;
  1572. }
  1573. }
  1574. //
  1575. // Return the count of characters put in the buffer.
  1576. //
  1577. return (Count);
  1578. }
  1579. ////////////////////////////////////////////////////////////////////////////
  1580. //
  1581. // ParseMultiLineSize
  1582. //
  1583. // This routine parses the IOPTIONALCALENDAR line and the SERARANGES line
  1584. // of the calendar input file. It stores the value as both a WORD and a
  1585. // string. It also stores the size of the information read in, including
  1586. // the 2 words for the value and the size.
  1587. //
  1588. // Returns the number of characters written to the buffer (0 means error).
  1589. //
  1590. // 12-10-91 JulieB Created.
  1591. ////////////////////////////////////////////////////////////////////////////
  1592. int ParseMultiLineSize(
  1593. PSZ pszLine,
  1594. WORD *pInfo,
  1595. int BufSize,
  1596. WORD *pNum,
  1597. int Flag)
  1598. {
  1599. int Num = 0; // number of strings read in
  1600. BYTE pszKey[MAX]; // keyword - ignored
  1601. int Count = 0; // count of characters
  1602. int TmpCt; // ScanBuffer return count
  1603. int Value; // value for sscanf
  1604. WORD *pInfoPtr; // tmp ptr to pInfo buffer
  1605. int Incr; // increment amount for buffer
  1606. //
  1607. // Get to next line of information.
  1608. // If no more strings could be read in, return an error.
  1609. //
  1610. if (fscanf(pInputFile, "%s", pszKey) == 0)
  1611. {
  1612. printf("Parse Error: Incomplete LOCALE information.\n");
  1613. return (0);
  1614. }
  1615. //
  1616. // Get size parameter.
  1617. //
  1618. if (GetLocaleInfoSize(&Num))
  1619. {
  1620. return (0);
  1621. }
  1622. //
  1623. // Save the number of ranges.
  1624. //
  1625. *pNum = (WORD)Num;
  1626. //
  1627. // Check for num == 0.
  1628. //
  1629. if (Num == 0)
  1630. {
  1631. *pInfo = 0;
  1632. return (1);
  1633. }
  1634. //
  1635. // Set the increment amount based on the Flag parameter.
  1636. //
  1637. Incr = (Flag == ERA_RANGE_FLAG) ? 4 : 2;
  1638. //
  1639. // Read in the appropriate number of lines.
  1640. //
  1641. pInfoPtr = pInfo;
  1642. while (Num > 0)
  1643. {
  1644. //
  1645. // If we're getting the era ranges, then we need to read in the
  1646. // month and day of the era before we read in the year.
  1647. //
  1648. // Ordering in Buffer:
  1649. // Month, Day, Year, Offset, Year String, Era Name String
  1650. //
  1651. if (Flag == ERA_RANGE_FLAG)
  1652. {
  1653. //
  1654. // Get the Month.
  1655. //
  1656. if (GetLocaleInfoSize(&Value))
  1657. {
  1658. return (0);
  1659. }
  1660. pInfoPtr[0] = (WORD)Value;
  1661. //
  1662. // Get the Day.
  1663. //
  1664. if (GetLocaleInfoSize(&Value))
  1665. {
  1666. return (0);
  1667. }
  1668. pInfoPtr[1] = (WORD)Value;
  1669. }
  1670. //
  1671. // Read in the rest of the line. If nothing on the current line,
  1672. // go to the next line and try again.
  1673. //
  1674. if (fgets(pszLine, MAX, pInputFile) != NULL)
  1675. {
  1676. TmpCt = ScanBuffer( pszLine,
  1677. pInfoPtr + Incr,
  1678. BufSize - Count - Incr,
  1679. pszKey,
  1680. TRUE );
  1681. TmpCt += Incr;
  1682. swscanf(pInfoPtr + Incr, L"%d", &Value);
  1683. pInfoPtr[Incr - 2] = (WORD)Value;
  1684. pInfoPtr[Incr - 1] = (WORD)TmpCt;
  1685. Num--;
  1686. pInfoPtr += TmpCt;
  1687. Count += TmpCt;
  1688. }
  1689. }
  1690. //
  1691. // Return the count of characters put in the buffer.
  1692. //
  1693. return (Count);
  1694. }
  1695. ////////////////////////////////////////////////////////////////////////////
  1696. //
  1697. // GetLocaleInfoSize
  1698. //
  1699. // This routine gets the size of the table from the input file. If the
  1700. // size is not there, then an error is returned.
  1701. //
  1702. // 07-30-91 JulieB Created.
  1703. ////////////////////////////////////////////////////////////////////////////
  1704. int GetLocaleInfoSize(
  1705. int *pSize)
  1706. {
  1707. int NumItems; // number of items returned from fscanf
  1708. //
  1709. // Read the size from the input file.
  1710. //
  1711. NumItems = fscanf(pInputFile, "%d", pSize);
  1712. if (NumItems != 1)
  1713. {
  1714. printf("Parse Error: Error reading size value.\n");
  1715. return (1);
  1716. }
  1717. if (*pSize < 0)
  1718. {
  1719. printf("Parse Error: Invalid size value %d\n", *pSize);
  1720. return (1);
  1721. }
  1722. if (Verbose)
  1723. printf(" SIZE = %d\n", *pSize);
  1724. //
  1725. // Return success.
  1726. //
  1727. return (0);
  1728. }
  1729. ////////////////////////////////////////////////////////////////////////////
  1730. //
  1731. // ScanBuffer
  1732. //
  1733. // This routine converts the given ansi buffer to a wide character buffer,
  1734. // removes leading and trailing white space, and then scans it for escape
  1735. // characters. The final buffer and the number of characters written to
  1736. // the buffer (0 means error) are returned.
  1737. //
  1738. // 12-10-91 JulieB Created.
  1739. ////////////////////////////////////////////////////////////////////////////
  1740. int ScanBuffer(
  1741. PSZ pszLine,
  1742. WORD *pInfo,
  1743. int BufSize,
  1744. BYTE *pszKey,
  1745. BOOL fConvert)
  1746. {
  1747. int Num = 0; // number of strings read in
  1748. WORD pwszTemp[MAX]; // first string of information
  1749. WORD *pwszInfoPtr; // ptr to string of information to store
  1750. int Count = 0; // count of characters
  1751. //
  1752. // Convert the ansi buffer to a wide char buffer and skip over any
  1753. // leading white space.
  1754. //
  1755. if (sscanf(pszLine, "%*[\t ]%255w[^\n]", pwszTemp) == 0)
  1756. {
  1757. //
  1758. // This should only happen if there is only white space on the line.
  1759. //
  1760. *pInfo = 0;
  1761. return (1);
  1762. }
  1763. //
  1764. // Remove trailing spaces.
  1765. //
  1766. // NOTE: Subtract 1 from the end of the string to skip over the
  1767. // null terminator. The line feed was already filtered out above.
  1768. //
  1769. pwszInfoPtr = pwszTemp + wcslen(pwszTemp) - 1;
  1770. while ((pwszInfoPtr != pwszTemp) &&
  1771. ((*pwszInfoPtr == L' ') || (*pwszInfoPtr == L'\t')))
  1772. {
  1773. pwszInfoPtr--;
  1774. }
  1775. *(pwszInfoPtr + 1) = 0;
  1776. if (Verbose)
  1777. printf(" %s\t%ws\n", pszKey, pwszTemp);
  1778. //
  1779. // Buffer should be initialized to zero, so no need to
  1780. // zero terminate the string.
  1781. //
  1782. pwszInfoPtr = pwszTemp;
  1783. while ((*pwszInfoPtr != L'\n') && (*pwszInfoPtr != 0))
  1784. {
  1785. //
  1786. // Check output buffer size.
  1787. //
  1788. if (Count >= (BufSize - 1))
  1789. {
  1790. printf("WARNING: String is too long - truncating %s\n",
  1791. pszKey);
  1792. break;
  1793. }
  1794. //
  1795. // Check for escape sequence.
  1796. //
  1797. if (*pwszInfoPtr == L'\\')
  1798. {
  1799. pwszInfoPtr++;
  1800. if ((*pwszInfoPtr == L'x') || (*pwszInfoPtr == L'X'))
  1801. {
  1802. //
  1803. // Read in hex value.
  1804. //
  1805. // NOTE: All hex values MUST be 4 digits long -
  1806. // character may be ignored or hex values may be
  1807. // incorrect.
  1808. //
  1809. if (swscanf(pwszInfoPtr + 1, L"%4x", &Num) != 1)
  1810. {
  1811. printf("Parse Error: No number following \\x for %s.\n", pszKey);
  1812. return (0);
  1813. }
  1814. //
  1815. // Check for special character - 0xffff. Change it to a
  1816. // null terminator.
  1817. // This means that there is more than one string for one
  1818. // LCTYPE information.
  1819. //
  1820. if ((fConvert) && (Num == 0xffff))
  1821. {
  1822. *pInfo = (WORD)0;
  1823. }
  1824. else
  1825. {
  1826. *pInfo = (WORD)Num;
  1827. }
  1828. pInfo++;
  1829. pwszInfoPtr += 5;
  1830. Count++;
  1831. }
  1832. else if (*pwszInfoPtr == L'\\')
  1833. {
  1834. //
  1835. // Want to print out backslash, so do it.
  1836. //
  1837. *pInfo = *pwszInfoPtr;
  1838. pInfo++;
  1839. pwszInfoPtr++;
  1840. Count++;
  1841. }
  1842. else
  1843. {
  1844. //
  1845. // Escape character not followed by valid character.
  1846. //
  1847. printf("Parse Error: Invalid escape sequence for %s.\n",
  1848. pszKey);
  1849. return (0);
  1850. }
  1851. }
  1852. else
  1853. {
  1854. //
  1855. // Simply copy character. No special casing required.
  1856. //
  1857. *pInfo = *pwszInfoPtr;
  1858. pInfo++;
  1859. pwszInfoPtr++;
  1860. Count++;
  1861. }
  1862. }
  1863. //
  1864. // Return the count of characters put in the buffer.
  1865. //
  1866. return (Count + 1);
  1867. }
  1868. ////////////////////////////////////////////////////////////////////////////
  1869. //
  1870. // WriteLocaleInit
  1871. //
  1872. // This routine opens the output file for writing and writes the number
  1873. // of locales as the first piece of data to the file.
  1874. //
  1875. // 12-10-91 JulieB Created.
  1876. ////////////////////////////////////////////////////////////////////////////
  1877. int WriteLocaleInit(
  1878. FILE **ppOutputFile,
  1879. int NumLoc,
  1880. int OffLoc)
  1881. {
  1882. WORD pDummy[MAX]; // dummy storage
  1883. DWORD dwValue; // temp storage value
  1884. //
  1885. // Make sure output file can be opened for writing.
  1886. //
  1887. if ((*ppOutputFile = fopen(LOCALE_FILE, "w+b")) == 0)
  1888. {
  1889. printf("Error opening output file %s.\n", LOCALE_FILE);
  1890. return (1);
  1891. }
  1892. if (Verbose)
  1893. printf("\n\nWriting output file %s...\n", LOCALE_FILE);
  1894. //
  1895. // Write the number of locales to the file.
  1896. //
  1897. dwValue = (DWORD)NumLoc;
  1898. if (FileWrite( *ppOutputFile,
  1899. &dwValue,
  1900. sizeof(DWORD),
  1901. 1,
  1902. "Number of Locales" ))
  1903. {
  1904. fclose(*ppOutputFile);
  1905. return (1);
  1906. }
  1907. //
  1908. // Write zeros in the file to allow the seek to work.
  1909. //
  1910. memset(pDummy, 0, MAX * sizeof(WORD));
  1911. if (FileWrite( *ppOutputFile,
  1912. pDummy,
  1913. sizeof(WORD),
  1914. OffLoc,
  1915. "Locale File Header" ))
  1916. {
  1917. fclose(*ppOutputFile);
  1918. return (1);
  1919. }
  1920. //
  1921. // Seek back to the beginning of the locale header.
  1922. //
  1923. if (fseek( *ppOutputFile,
  1924. LOC_CAL_HDR_WORDS * sizeof(WORD),
  1925. 0 ))
  1926. {
  1927. printf("Seek Error: Can't seek in file %s.\n", LOCALE_FILE);
  1928. return (1);
  1929. }
  1930. //
  1931. // Return success.
  1932. //
  1933. return (0);
  1934. }
  1935. ////////////////////////////////////////////////////////////////////////////
  1936. //
  1937. // WriteLocaleInfo
  1938. //
  1939. // This routine writes the locale id, offset, and locale information to
  1940. // the output file. It needs to seek ahead to the correct position for the
  1941. // locale information, and then seeks back to the header position. The
  1942. // file positions are updated to reflect the next offsets.
  1943. //
  1944. // 12-10-91 JulieB Created.
  1945. ////////////////////////////////////////////////////////////////////////////
  1946. int WriteLocaleInfo(
  1947. DWORD Locale,
  1948. int *pOffHdr,
  1949. int *pOffLoc,
  1950. PLOCALE_HEADER pLocHdr,
  1951. PLOCALE_STATIC pLocStat,
  1952. PLOCALE_VARIABLE pLocVar,
  1953. PLOCALE_HEADER pLocCnt,
  1954. FILE *pOutputFile)
  1955. {
  1956. int Size; // size of locale information
  1957. int TotalSize = 0; // total size of the locale information
  1958. DWORD dwValue; // temp storage value
  1959. if (Verbose)
  1960. printf("\nWriting Locale Information for %x...\n", Locale);
  1961. //
  1962. // Write the locale id and offset to the locale information in
  1963. // the header area of the output file.
  1964. //
  1965. dwValue = (DWORD)(*pOffLoc);
  1966. if (FileWrite( pOutputFile,
  1967. &Locale,
  1968. sizeof(DWORD),
  1969. 1,
  1970. "Locale ID" ) ||
  1971. FileWrite( pOutputFile,
  1972. &dwValue,
  1973. sizeof(DWORD),
  1974. 1,
  1975. "Locale Info Offset" ))
  1976. {
  1977. return (1);
  1978. }
  1979. //
  1980. // Seek forward to locale info offset.
  1981. //
  1982. if (fseek( pOutputFile,
  1983. (*pOffLoc) * sizeof(WORD),
  1984. 0 ))
  1985. {
  1986. printf("Seek Error: Can't seek in file %s.\n", LOCALE_FILE);
  1987. return (1);
  1988. }
  1989. //
  1990. // Write the locale information to the output file.
  1991. // Header Info
  1992. // Static Length Info
  1993. // Variable Length Info
  1994. //
  1995. TotalSize = Size = sizeof(LOCALE_HEADER) / sizeof(WORD);
  1996. if (FileWrite( pOutputFile,
  1997. pLocHdr,
  1998. sizeof(WORD),
  1999. Size,
  2000. "Locale Header" ))
  2001. {
  2002. return (1);
  2003. }
  2004. TotalSize += (Size = sizeof(LOCALE_STATIC) / sizeof(WORD));
  2005. if (FileWrite( pOutputFile,
  2006. pLocStat,
  2007. sizeof(WORD),
  2008. Size,
  2009. "Locale Static Info" ))
  2010. {
  2011. return (1);
  2012. }
  2013. if (WriteVariableLength( pLocCnt,
  2014. pLocVar,
  2015. &TotalSize,
  2016. pOutputFile ))
  2017. {
  2018. return (1);
  2019. }
  2020. //
  2021. // Set the offsets to their new values.
  2022. //
  2023. Size = *pOffLoc;
  2024. (*pOffHdr) += LOCALE_HDR_WORDS;
  2025. (*pOffLoc) += TotalSize;
  2026. //
  2027. // Make sure the size is not wrapping - can't be greater than
  2028. // a DWORD.
  2029. //
  2030. if (Size > *pOffLoc)
  2031. {
  2032. printf("Size Error: Offset is greater than a DWORD for locale %x.\n", Locale);
  2033. return (1);
  2034. }
  2035. //
  2036. // Seek back to the header offset.
  2037. //
  2038. if (fseek( pOutputFile,
  2039. (*pOffHdr) * sizeof(WORD),
  2040. 0 ))
  2041. {
  2042. printf("Seek Error: Can't seek in file %s.\n", LOCALE_FILE);
  2043. return (1);
  2044. }
  2045. //
  2046. // Return success.
  2047. //
  2048. return (0);
  2049. }
  2050. ////////////////////////////////////////////////////////////////////////////
  2051. //
  2052. // WriteVariableLength
  2053. //
  2054. // This routine writes the variable length locale information to the output
  2055. // file. It adds on to the total size of the locale information as it adds
  2056. // the variable length information.
  2057. //
  2058. // 12-10-91 JulieB Created.
  2059. ////////////////////////////////////////////////////////////////////////////
  2060. int WriteVariableLength(
  2061. PLOCALE_HEADER pLocCnt,
  2062. PLOCALE_VARIABLE pLocVar,
  2063. int *pTotalSize,
  2064. FILE *pOutputFile)
  2065. {
  2066. int Size; // size of string
  2067. *pTotalSize += (Size = pLocCnt->SLanguage);
  2068. if (FileWrite( pOutputFile,
  2069. pLocVar->szSLanguage,
  2070. sizeof(WORD),
  2071. Size,
  2072. "Locale Variable Info" ))
  2073. {
  2074. return (1);
  2075. }
  2076. *pTotalSize += (Size = pLocCnt->SAbbrevLang);
  2077. if (FileWrite( pOutputFile,
  2078. pLocVar->szSAbbrevLang,
  2079. sizeof(WORD),
  2080. Size,
  2081. "Locale Variable Info" ))
  2082. {
  2083. return (1);
  2084. }
  2085. *pTotalSize += (Size = pLocCnt->SAbbrevLangISO);
  2086. if (FileWrite( pOutputFile,
  2087. pLocVar->szSAbbrevLangISO,
  2088. sizeof(WORD),
  2089. Size,
  2090. "Locale Variable Info" ))
  2091. {
  2092. return (1);
  2093. }
  2094. *pTotalSize += (Size = pLocCnt->SNativeLang);
  2095. if (FileWrite( pOutputFile,
  2096. pLocVar->szSNativeLang,
  2097. sizeof(WORD),
  2098. Size,
  2099. "Locale Variable Info" ))
  2100. {
  2101. return (1);
  2102. }
  2103. *pTotalSize += (Size = pLocCnt->SCountry);
  2104. if (FileWrite( pOutputFile,
  2105. pLocVar->szSCountry,
  2106. sizeof(WORD),
  2107. Size,
  2108. "Locale Variable Info" ))
  2109. {
  2110. return (1);
  2111. }
  2112. *pTotalSize += (Size = pLocCnt->SAbbrevCtry);
  2113. if (FileWrite( pOutputFile,
  2114. pLocVar->szSAbbrevCtry,
  2115. sizeof(WORD),
  2116. Size,
  2117. "Locale Variable Info" ))
  2118. {
  2119. return (1);
  2120. }
  2121. *pTotalSize += (Size = pLocCnt->SAbbrevCtryISO);
  2122. if (FileWrite( pOutputFile,
  2123. pLocVar->szSAbbrevCtryISO,
  2124. sizeof(WORD),
  2125. Size,
  2126. "Locale Variable Info" ))
  2127. {
  2128. return (1);
  2129. }
  2130. *pTotalSize += (Size = pLocCnt->SNativeCtry);
  2131. if (FileWrite( pOutputFile,
  2132. pLocVar->szSNativeCtry,
  2133. sizeof(WORD),
  2134. Size,
  2135. "Locale Variable Info" ))
  2136. {
  2137. return (1);
  2138. }
  2139. *pTotalSize += (Size = pLocCnt->SList);
  2140. if (FileWrite( pOutputFile,
  2141. pLocVar->szSList,
  2142. sizeof(WORD),
  2143. Size,
  2144. "Locale Variable Info" ))
  2145. {
  2146. return (1);
  2147. }
  2148. *pTotalSize += (Size = pLocCnt->SDecimal);
  2149. if (FileWrite( pOutputFile,
  2150. pLocVar->szSDecimal,
  2151. sizeof(WORD),
  2152. Size,
  2153. "Locale Variable Info" ))
  2154. {
  2155. return (1);
  2156. }
  2157. *pTotalSize += (Size = pLocCnt->SThousand);
  2158. if (FileWrite( pOutputFile,
  2159. pLocVar->szSThousand,
  2160. sizeof(WORD),
  2161. Size,
  2162. "Locale Variable Info" ))
  2163. {
  2164. return (1);
  2165. }
  2166. *pTotalSize += (Size = pLocCnt->SGrouping);
  2167. if (FileWrite( pOutputFile,
  2168. pLocVar->szSGrouping,
  2169. sizeof(WORD),
  2170. Size,
  2171. "Locale Variable Info" ))
  2172. {
  2173. return (1);
  2174. }
  2175. *pTotalSize += (Size = pLocCnt->SNativeDigits);
  2176. if (FileWrite( pOutputFile,
  2177. pLocVar->szSNativeDigits,
  2178. sizeof(WORD),
  2179. Size,
  2180. "Locale Variable Info" ))
  2181. {
  2182. return (1);
  2183. }
  2184. *pTotalSize += (Size = pLocCnt->SCurrency);
  2185. if (FileWrite( pOutputFile,
  2186. pLocVar->szSCurrency,
  2187. sizeof(WORD),
  2188. Size,
  2189. "Locale Variable Info" ))
  2190. {
  2191. return (1);
  2192. }
  2193. *pTotalSize += (Size = pLocCnt->SIntlSymbol);
  2194. if (FileWrite( pOutputFile,
  2195. pLocVar->szSIntlSymbol,
  2196. sizeof(WORD),
  2197. Size,
  2198. "Locale Variable Info" ))
  2199. {
  2200. return (1);
  2201. }
  2202. *pTotalSize += (Size = pLocCnt->SEngCurrName);
  2203. if (FileWrite( pOutputFile,
  2204. pLocVar->szSEngCurrName,
  2205. sizeof(WORD),
  2206. Size,
  2207. "Locale Variable Info" ))
  2208. {
  2209. return (1);
  2210. }
  2211. *pTotalSize += (Size = pLocCnt->SNativeCurrName);
  2212. if (FileWrite( pOutputFile,
  2213. pLocVar->szSNativeCurrName,
  2214. sizeof(WORD),
  2215. Size,
  2216. "Locale Variable Info" ))
  2217. {
  2218. return (1);
  2219. }
  2220. *pTotalSize += (Size = pLocCnt->SMonDecSep);
  2221. if (FileWrite( pOutputFile,
  2222. pLocVar->szSMonDecSep,
  2223. sizeof(WORD),
  2224. Size,
  2225. "Locale Variable Info" ))
  2226. {
  2227. return (1);
  2228. }
  2229. *pTotalSize += (Size = pLocCnt->SMonThousSep);
  2230. if (FileWrite( pOutputFile,
  2231. pLocVar->szSMonThousSep,
  2232. sizeof(WORD),
  2233. Size,
  2234. "Locale Variable Info" ))
  2235. {
  2236. return (1);
  2237. }
  2238. *pTotalSize += (Size = pLocCnt->SMonGrouping);
  2239. if (FileWrite( pOutputFile,
  2240. pLocVar->szSMonGrouping,
  2241. sizeof(WORD),
  2242. Size,
  2243. "Locale Variable Info" ))
  2244. {
  2245. return (1);
  2246. }
  2247. *pTotalSize += (Size = pLocCnt->SPositiveSign);
  2248. if (FileWrite( pOutputFile,
  2249. pLocVar->szSPositiveSign,
  2250. sizeof(WORD),
  2251. Size,
  2252. "Locale Variable Info" ))
  2253. {
  2254. return (1);
  2255. }
  2256. *pTotalSize += (Size = pLocCnt->SNegativeSign);
  2257. if (FileWrite( pOutputFile,
  2258. pLocVar->szSNegativeSign,
  2259. sizeof(WORD),
  2260. Size,
  2261. "Locale Variable Info" ))
  2262. {
  2263. return (1);
  2264. }
  2265. *pTotalSize += (Size = pLocCnt->STimeFormat);
  2266. if (FileWrite( pOutputFile,
  2267. pLocVar->szSTimeFormat,
  2268. sizeof(WORD),
  2269. Size,
  2270. "Locale Variable Info" ))
  2271. {
  2272. return (1);
  2273. }
  2274. *pTotalSize += (Size = pLocCnt->STime);
  2275. if (FileWrite( pOutputFile,
  2276. pLocVar->szSTime,
  2277. sizeof(WORD),
  2278. Size,
  2279. "Locale Variable Info" ))
  2280. {
  2281. return (1);
  2282. }
  2283. *pTotalSize += (Size = pLocCnt->S1159);
  2284. if (FileWrite( pOutputFile,
  2285. pLocVar->szS1159,
  2286. sizeof(WORD),
  2287. Size,
  2288. "Locale Variable Info" ))
  2289. {
  2290. return (1);
  2291. }
  2292. *pTotalSize += (Size = pLocCnt->S2359);
  2293. if (FileWrite( pOutputFile,
  2294. pLocVar->szS2359,
  2295. sizeof(WORD),
  2296. Size,
  2297. "Locale Variable Info" ))
  2298. {
  2299. return (1);
  2300. }
  2301. *pTotalSize += (Size = pLocCnt->SShortDate);
  2302. if (FileWrite( pOutputFile,
  2303. pLocVar->szSShortDate,
  2304. sizeof(WORD),
  2305. Size,
  2306. "Locale Variable Info" ))
  2307. {
  2308. return (1);
  2309. }
  2310. *pTotalSize += (Size = pLocCnt->SDate);
  2311. if (FileWrite( pOutputFile,
  2312. pLocVar->szSDate,
  2313. sizeof(WORD),
  2314. Size,
  2315. "Locale Variable Info" ))
  2316. {
  2317. return (1);
  2318. }
  2319. *pTotalSize += (Size = pLocCnt->SYearMonth);
  2320. if (FileWrite( pOutputFile,
  2321. pLocVar->szSYearMonth,
  2322. sizeof(WORD),
  2323. Size,
  2324. "Locale Variable Info" ))
  2325. {
  2326. return (1);
  2327. }
  2328. *pTotalSize += (Size = pLocCnt->SLongDate);
  2329. if (FileWrite( pOutputFile,
  2330. pLocVar->szSLongDate,
  2331. sizeof(WORD),
  2332. Size,
  2333. "Locale Variable Info" ))
  2334. {
  2335. return (1);
  2336. }
  2337. *pTotalSize += (Size = pLocCnt->IOptionalCalendar);
  2338. if (FileWrite( pOutputFile,
  2339. pLocVar->szIOptionalCalendar,
  2340. sizeof(WORD),
  2341. Size,
  2342. "Locale Variable Info" ))
  2343. {
  2344. return (1);
  2345. }
  2346. *pTotalSize += (Size = pLocCnt->SDayName1);
  2347. if (FileWrite( pOutputFile,
  2348. pLocVar->szSDayName1,
  2349. sizeof(WORD),
  2350. Size,
  2351. "Locale Variable Info" ))
  2352. {
  2353. return (1);
  2354. }
  2355. *pTotalSize += (Size = pLocCnt->SDayName2);
  2356. if (FileWrite( pOutputFile,
  2357. pLocVar->szSDayName2,
  2358. sizeof(WORD),
  2359. Size,
  2360. "Locale Variable Info" ))
  2361. {
  2362. return (1);
  2363. }
  2364. *pTotalSize += (Size = pLocCnt->SDayName3);
  2365. if (FileWrite( pOutputFile,
  2366. pLocVar->szSDayName3,
  2367. sizeof(WORD),
  2368. Size,
  2369. "Locale Variable Info" ))
  2370. {
  2371. return (1);
  2372. }
  2373. *pTotalSize += (Size = pLocCnt->SDayName4);
  2374. if (FileWrite( pOutputFile,
  2375. pLocVar->szSDayName4,
  2376. sizeof(WORD),
  2377. Size,
  2378. "Locale Variable Info" ))
  2379. {
  2380. return (1);
  2381. }
  2382. *pTotalSize += (Size = pLocCnt->SDayName5);
  2383. if (FileWrite( pOutputFile,
  2384. pLocVar->szSDayName5,
  2385. sizeof(WORD),
  2386. Size,
  2387. "Locale Variable Info" ))
  2388. {
  2389. return (1);
  2390. }
  2391. *pTotalSize += (Size = pLocCnt->SDayName6);
  2392. if (FileWrite( pOutputFile,
  2393. pLocVar->szSDayName6,
  2394. sizeof(WORD),
  2395. Size,
  2396. "Locale Variable Info" ))
  2397. {
  2398. return (1);
  2399. }
  2400. *pTotalSize += (Size = pLocCnt->SDayName7);
  2401. if (FileWrite( pOutputFile,
  2402. pLocVar->szSDayName7,
  2403. sizeof(WORD),
  2404. Size,
  2405. "Locale Variable Info" ))
  2406. {
  2407. return (1);
  2408. }
  2409. *pTotalSize += (Size = pLocCnt->SAbbrevDayName1);
  2410. if (FileWrite( pOutputFile,
  2411. pLocVar->szSAbbrevDayName1,
  2412. sizeof(WORD),
  2413. Size,
  2414. "Locale Variable Info" ))
  2415. {
  2416. return (1);
  2417. }
  2418. *pTotalSize += (Size = pLocCnt->SAbbrevDayName2);
  2419. if (FileWrite( pOutputFile,
  2420. pLocVar->szSAbbrevDayName2,
  2421. sizeof(WORD),
  2422. Size,
  2423. "Locale Variable Info" ))
  2424. {
  2425. return (1);
  2426. }
  2427. *pTotalSize += (Size = pLocCnt->SAbbrevDayName3);
  2428. if (FileWrite( pOutputFile,
  2429. pLocVar->szSAbbrevDayName3,
  2430. sizeof(WORD),
  2431. Size,
  2432. "Locale Variable Info" ))
  2433. {
  2434. return (1);
  2435. }
  2436. *pTotalSize += (Size = pLocCnt->SAbbrevDayName4);
  2437. if (FileWrite( pOutputFile,
  2438. pLocVar->szSAbbrevDayName4,
  2439. sizeof(WORD),
  2440. Size,
  2441. "Locale Variable Info" ))
  2442. {
  2443. return (1);
  2444. }
  2445. *pTotalSize += (Size = pLocCnt->SAbbrevDayName5);
  2446. if (FileWrite( pOutputFile,
  2447. pLocVar->szSAbbrevDayName5,
  2448. sizeof(WORD),
  2449. Size,
  2450. "Locale Variable Info" ))
  2451. {
  2452. return (1);
  2453. }
  2454. *pTotalSize += (Size = pLocCnt->SAbbrevDayName6);
  2455. if (FileWrite( pOutputFile,
  2456. pLocVar->szSAbbrevDayName6,
  2457. sizeof(WORD),
  2458. Size,
  2459. "Locale Variable Info" ))
  2460. {
  2461. return (1);
  2462. }
  2463. *pTotalSize += (Size = pLocCnt->SAbbrevDayName7);
  2464. if (FileWrite( pOutputFile,
  2465. pLocVar->szSAbbrevDayName7,
  2466. sizeof(WORD),
  2467. Size,
  2468. "Locale Variable Info" ))
  2469. {
  2470. return (1);
  2471. }
  2472. *pTotalSize += (Size = pLocCnt->SMonthName1);
  2473. if (FileWrite( pOutputFile,
  2474. pLocVar->szSMonthName1,
  2475. sizeof(WORD),
  2476. Size,
  2477. "Locale Variable Info" ))
  2478. {
  2479. return (1);
  2480. }
  2481. *pTotalSize += (Size = pLocCnt->SMonthName2);
  2482. if (FileWrite( pOutputFile,
  2483. pLocVar->szSMonthName2,
  2484. sizeof(WORD),
  2485. Size,
  2486. "Locale Variable Info" ))
  2487. {
  2488. return (1);
  2489. }
  2490. *pTotalSize += (Size = pLocCnt->SMonthName3);
  2491. if (FileWrite( pOutputFile,
  2492. pLocVar->szSMonthName3,
  2493. sizeof(WORD),
  2494. Size,
  2495. "Locale Variable Info" ))
  2496. {
  2497. return (1);
  2498. }
  2499. *pTotalSize += (Size = pLocCnt->SMonthName4);
  2500. if (FileWrite( pOutputFile,
  2501. pLocVar->szSMonthName4,
  2502. sizeof(WORD),
  2503. Size,
  2504. "Locale Variable Info" ))
  2505. {
  2506. return (1);
  2507. }
  2508. *pTotalSize += (Size = pLocCnt->SMonthName5);
  2509. if (FileWrite( pOutputFile,
  2510. pLocVar->szSMonthName5,
  2511. sizeof(WORD),
  2512. Size,
  2513. "Locale Variable Info" ))
  2514. {
  2515. return (1);
  2516. }
  2517. *pTotalSize += (Size = pLocCnt->SMonthName6);
  2518. if (FileWrite( pOutputFile,
  2519. pLocVar->szSMonthName6,
  2520. sizeof(WORD),
  2521. Size,
  2522. "Locale Variable Info" ))
  2523. {
  2524. return (1);
  2525. }
  2526. *pTotalSize += (Size = pLocCnt->SMonthName7);
  2527. if (FileWrite( pOutputFile,
  2528. pLocVar->szSMonthName7,
  2529. sizeof(WORD),
  2530. Size,
  2531. "Locale Variable Info" ))
  2532. {
  2533. return (1);
  2534. }
  2535. *pTotalSize += (Size = pLocCnt->SMonthName8);
  2536. if (FileWrite( pOutputFile,
  2537. pLocVar->szSMonthName8,
  2538. sizeof(WORD),
  2539. Size,
  2540. "Locale Variable Info" ))
  2541. {
  2542. return (1);
  2543. }
  2544. *pTotalSize += (Size = pLocCnt->SMonthName9);
  2545. if (FileWrite( pOutputFile,
  2546. pLocVar->szSMonthName9,
  2547. sizeof(WORD),
  2548. Size,
  2549. "Locale Variable Info" ))
  2550. {
  2551. return (1);
  2552. }
  2553. *pTotalSize += (Size = pLocCnt->SMonthName10);
  2554. if (FileWrite( pOutputFile,
  2555. pLocVar->szSMonthName10,
  2556. sizeof(WORD),
  2557. Size,
  2558. "Locale Variable Info" ))
  2559. {
  2560. return (1);
  2561. }
  2562. *pTotalSize += (Size = pLocCnt->SMonthName11);
  2563. if (FileWrite( pOutputFile,
  2564. pLocVar->szSMonthName11,
  2565. sizeof(WORD),
  2566. Size,
  2567. "Locale Variable Info" ))
  2568. {
  2569. return (1);
  2570. }
  2571. *pTotalSize += (Size = pLocCnt->SMonthName12);
  2572. if (FileWrite( pOutputFile,
  2573. pLocVar->szSMonthName12,
  2574. sizeof(WORD),
  2575. Size,
  2576. "Locale Variable Info" ))
  2577. {
  2578. return (1);
  2579. }
  2580. *pTotalSize += (Size = pLocCnt->SMonthName13);
  2581. if (FileWrite( pOutputFile,
  2582. pLocVar->szSMonthName13,
  2583. sizeof(WORD),
  2584. Size,
  2585. "Locale Variable Info" ))
  2586. {
  2587. return (1);
  2588. }
  2589. *pTotalSize += (Size = pLocCnt->SAbbrevMonthName1);
  2590. if (FileWrite( pOutputFile,
  2591. pLocVar->szSAbbrevMonthName1,
  2592. sizeof(WORD),
  2593. Size,
  2594. "Locale Variable Info" ))
  2595. {
  2596. return (1);
  2597. }
  2598. *pTotalSize += (Size = pLocCnt->SAbbrevMonthName2);
  2599. if (FileWrite( pOutputFile,
  2600. pLocVar->szSAbbrevMonthName2,
  2601. sizeof(WORD),
  2602. Size,
  2603. "Locale Variable Info" ))
  2604. {
  2605. return (1);
  2606. }
  2607. *pTotalSize += (Size = pLocCnt->SAbbrevMonthName3);
  2608. if (FileWrite( pOutputFile,
  2609. pLocVar->szSAbbrevMonthName3,
  2610. sizeof(WORD),
  2611. Size,
  2612. "Locale Variable Info" ))
  2613. {
  2614. return (1);
  2615. }
  2616. *pTotalSize += (Size = pLocCnt->SAbbrevMonthName4);
  2617. if (FileWrite( pOutputFile,
  2618. pLocVar->szSAbbrevMonthName4,
  2619. sizeof(WORD),
  2620. Size,
  2621. "Locale Variable Info" ))
  2622. {
  2623. return (1);
  2624. }
  2625. *pTotalSize += (Size = pLocCnt->SAbbrevMonthName5);
  2626. if (FileWrite( pOutputFile,
  2627. pLocVar->szSAbbrevMonthName5,
  2628. sizeof(WORD),
  2629. Size,
  2630. "Locale Variable Info" ))
  2631. {
  2632. return (1);
  2633. }
  2634. *pTotalSize += (Size = pLocCnt->SAbbrevMonthName6);
  2635. if (FileWrite( pOutputFile,
  2636. pLocVar->szSAbbrevMonthName6,
  2637. sizeof(WORD),
  2638. Size,
  2639. "Locale Variable Info" ))
  2640. {
  2641. return (1);
  2642. }
  2643. *pTotalSize += (Size = pLocCnt->SAbbrevMonthName7);
  2644. if (FileWrite( pOutputFile,
  2645. pLocVar->szSAbbrevMonthName7,
  2646. sizeof(WORD),
  2647. Size,
  2648. "Locale Variable Info" ))
  2649. {
  2650. return (1);
  2651. }
  2652. *pTotalSize += (Size = pLocCnt->SAbbrevMonthName8);
  2653. if (FileWrite( pOutputFile,
  2654. pLocVar->szSAbbrevMonthName8,
  2655. sizeof(WORD),
  2656. Size,
  2657. "Locale Variable Info" ))
  2658. {
  2659. return (1);
  2660. }
  2661. *pTotalSize += (Size = pLocCnt->SAbbrevMonthName9);
  2662. if (FileWrite( pOutputFile,
  2663. pLocVar->szSAbbrevMonthName9,
  2664. sizeof(WORD),
  2665. Size,
  2666. "Locale Variable Info" ))
  2667. {
  2668. return (1);
  2669. }
  2670. *pTotalSize += (Size = pLocCnt->SAbbrevMonthName10);
  2671. if (FileWrite( pOutputFile,
  2672. pLocVar->szSAbbrevMonthName10,
  2673. sizeof(WORD),
  2674. Size,
  2675. "Locale Variable Info" ))
  2676. {
  2677. return (1);
  2678. }
  2679. *pTotalSize += (Size = pLocCnt->SAbbrevMonthName11);
  2680. if (FileWrite( pOutputFile,
  2681. pLocVar->szSAbbrevMonthName11,
  2682. sizeof(WORD),
  2683. Size,
  2684. "Locale Variable Info" ))
  2685. {
  2686. return (1);
  2687. }
  2688. *pTotalSize += (Size = pLocCnt->SAbbrevMonthName12);
  2689. if (FileWrite( pOutputFile,
  2690. pLocVar->szSAbbrevMonthName12,
  2691. sizeof(WORD),
  2692. Size,
  2693. "Locale Variable Info" ))
  2694. {
  2695. return (1);
  2696. }
  2697. *pTotalSize += (Size = pLocCnt->SAbbrevMonthName13);
  2698. if (FileWrite( pOutputFile,
  2699. pLocVar->szSAbbrevMonthName13,
  2700. sizeof(WORD),
  2701. Size,
  2702. "Locale Variable Info" ))
  2703. {
  2704. return (1);
  2705. }
  2706. //
  2707. // Return success.
  2708. //
  2709. return (0);
  2710. }
  2711. ////////////////////////////////////////////////////////////////////////////
  2712. //
  2713. // ParseWriteCalendar
  2714. //
  2715. // This routine parses the input file for the calendar specific tables, and
  2716. // then writes the data to the output file. This routine is only entered
  2717. // when the CALENDAR keyword is found. The parsing continues until the
  2718. // ENDCALENDAR keyword is found.
  2719. //
  2720. // 12-10-91 JulieB Created.
  2721. ////////////////////////////////////////////////////////////////////////////
  2722. int ParseWriteCalendar(
  2723. PCALENDAR_HEADER pCalHdr,
  2724. PCALENDAR_VARIABLE pCalVar,
  2725. PSZ pszKeyWord,
  2726. FILE *pOutputFile,
  2727. int OffHdr)
  2728. {
  2729. int Num; // number of calendars
  2730. int OffCal; // file offset to calendar info
  2731. int OffCalBegin; // file offset to beginning of calendar info
  2732. DWORD CalId; // calendar id
  2733. CALENDAR_HEADER CalCnt; // calendar character counts
  2734. //
  2735. // Get size parameter.
  2736. //
  2737. if (GetSize(&Num))
  2738. return (1);
  2739. //
  2740. // Set up initial file pointer offsets.
  2741. //
  2742. // OffCal = (Number of calendars * header entry size)
  2743. //
  2744. OffCalBegin = OffHdr;
  2745. OffCal = Num * CALENDAR_HDR_WORDS;
  2746. //
  2747. // Initialize the output file and write the number of calendars to
  2748. // the file. Also, in order to allow for the seek, write zeros
  2749. // in the file up to the first calendar field.
  2750. //
  2751. if (WriteCalendarInit( pOutputFile,
  2752. Num,
  2753. OffHdr ))
  2754. {
  2755. return (1);
  2756. }
  2757. //
  2758. // Parse all of the calendars one by one. Write each one to the file
  2759. // separately to conserve memory.
  2760. //
  2761. for (; Num > 0; Num--)
  2762. {
  2763. //
  2764. // Initialize all Calendar structures each time.
  2765. //
  2766. memset(pCalHdr, 0, sizeof(CALENDAR_HEADER));
  2767. memset(pCalVar, 0, sizeof(CALENDAR_VARIABLE));
  2768. memset(&CalCnt, 0, sizeof(CALENDAR_HEADER));
  2769. //
  2770. // Get the BEGINCALENDAR keyword and calendar id.
  2771. //
  2772. if (fscanf( pInputFile,
  2773. "%s %ld ;%*[^\n]",
  2774. pszKeyWord,
  2775. &CalId ) == 2)
  2776. {
  2777. if (_stricmp(pszKeyWord, "BEGINCALENDAR") == 0)
  2778. {
  2779. if (Verbose)
  2780. printf("\n\nFound BEGINCALENDAR keyword, CalendarID = %d\n\n",
  2781. CalId);
  2782. }
  2783. else
  2784. {
  2785. printf("Parse Error: Error reading BEGINCALENDAR and Calendar ID.\n");
  2786. return (1);
  2787. }
  2788. }
  2789. else
  2790. {
  2791. printf("Parse Error: Invalid Instruction '%s'.\n", pszKeyWord);
  2792. printf(" Expecting BEGINCALENDAR keyword and Calendar ID.\n");
  2793. return (1);
  2794. }
  2795. //
  2796. // Parse the calendar information.
  2797. //
  2798. if (ParseCalendarInfo( pCalHdr,
  2799. pCalVar,
  2800. &CalCnt,
  2801. pszKeyWord ))
  2802. {
  2803. printf("Parse Error: Calendar == %d.\n", CalId);
  2804. return (1);
  2805. }
  2806. //
  2807. // Write the calendar id, offset, and calendar information to
  2808. // the output file.
  2809. //
  2810. if (WriteCalendarInfo( CalId,
  2811. &OffHdr,
  2812. &OffCal,
  2813. OffCalBegin,
  2814. pCalHdr,
  2815. pCalVar,
  2816. &CalCnt,
  2817. pOutputFile ))
  2818. {
  2819. printf("Write Error: Calendar == %d.\n", CalId);
  2820. return (1);
  2821. }
  2822. }
  2823. //
  2824. // Look for ENDCALENDAR keyword.
  2825. //
  2826. if (fscanf(pInputFile, "%s", pszKeyWord) == 1)
  2827. {
  2828. if (_stricmp(pszKeyWord, "ENDCALENDAR") == 0)
  2829. {
  2830. if (Verbose)
  2831. printf("\n\nFound ENDCALENDAR keyword.\n");
  2832. //
  2833. // Return success.
  2834. //
  2835. return (0);
  2836. }
  2837. }
  2838. //
  2839. // If this point is reached, then the ENDCALENDAR keyword was not
  2840. // found. Return failure.
  2841. //
  2842. printf("Parse Error: Expecting ENDCALENDAR keyword.\n");
  2843. return (1);
  2844. }
  2845. ////////////////////////////////////////////////////////////////////////////
  2846. //
  2847. // ParseCalendarInfo
  2848. //
  2849. // This routine parses the calendar information from the input file. If an
  2850. // error is encountered, a 1 is returned.
  2851. //
  2852. // 12-10-91 JulieB Created.
  2853. ////////////////////////////////////////////////////////////////////////////
  2854. int ParseCalendarInfo(
  2855. PCALENDAR_HEADER pCalHdr,
  2856. PCALENDAR_VARIABLE pCalVar,
  2857. PCALENDAR_HEADER pCalCnt,
  2858. PSZ pszKeyWord)
  2859. {
  2860. int Count; // number of characters written
  2861. int Value; // hex value returned
  2862. //
  2863. // Read in the calendar id and store it in the calendar structure.
  2864. //
  2865. pCalHdr->SCalendar = sizeof(CALENDAR_HEADER) / sizeof(WORD);
  2866. if (!(Count = ParseLine( pszKeyWord,
  2867. pCalVar->szSCalendar,
  2868. MAX,
  2869. TRUE )))
  2870. {
  2871. return (1);
  2872. }
  2873. pCalCnt->SCalendar = (WORD)Count;
  2874. //
  2875. // Read in the two digit year max and store it in the calendar
  2876. // structure.
  2877. //
  2878. pCalHdr->STwoDigitYearMax = pCalHdr->SCalendar + Count;
  2879. if (!(Count = ParseLine( pszKeyWord,
  2880. pCalVar->szSTwoDigitYearMax,
  2881. MAX,
  2882. TRUE )))
  2883. {
  2884. return (1);
  2885. }
  2886. pCalCnt->STwoDigitYearMax = (WORD)Count;
  2887. //
  2888. // Read in the range offsets and store them in the calendar structure.
  2889. //
  2890. pCalHdr->SEraRanges = pCalHdr->STwoDigitYearMax + Count;
  2891. if (!(Count = ParseMultiLineSize( pszKeyWord,
  2892. pCalVar->szSEraRanges,
  2893. MAX,
  2894. &(pCalHdr->NumRanges),
  2895. ERA_RANGE_FLAG )))
  2896. {
  2897. return (1);
  2898. }
  2899. pCalCnt->SEraRanges = (WORD)Count;
  2900. pCalCnt->NumRanges = pCalHdr->NumRanges;
  2901. //
  2902. // Read in the short date information and store it in the
  2903. // calendar structure.
  2904. //
  2905. pCalHdr->SShortDate = pCalHdr->SEraRanges + Count;
  2906. if (!(Count = ParseMultiLine( pszKeyWord,
  2907. pCalVar->szSShortDate,
  2908. MAX )))
  2909. {
  2910. return (1);
  2911. }
  2912. pCalCnt->SShortDate = (WORD)Count;
  2913. //
  2914. // Read in the year month information and store it in the
  2915. // calendar structure.
  2916. //
  2917. pCalHdr->SYearMonth = pCalHdr->SShortDate + Count;
  2918. if (!(Count = ParseMultiLine( pszKeyWord,
  2919. pCalVar->szSYearMonth,
  2920. MAX )))
  2921. {
  2922. return (1);
  2923. }
  2924. pCalCnt->SYearMonth = (WORD)Count;
  2925. //
  2926. // Read in the long date information and store it in the
  2927. // calendar structure.
  2928. //
  2929. pCalHdr->SLongDate = pCalHdr->SYearMonth + Count;
  2930. if (!(Count = ParseMultiLine( pszKeyWord,
  2931. pCalVar->szSLongDate,
  2932. MAX )))
  2933. {
  2934. return (1);
  2935. }
  2936. pCalCnt->SLongDate = (WORD)Count;
  2937. pCalHdr->SDayName1 = pCalHdr->SLongDate + Count;
  2938. //
  2939. // See if any day or month names exist.
  2940. //
  2941. if (fscanf(pInputFile, "%s", pszKeyWord) != 1)
  2942. {
  2943. printf("Parse Error: Error reading ERA keyword.\n");
  2944. return (1);
  2945. }
  2946. if (GetLocaleInfoSize(&Value))
  2947. return (1);
  2948. pCalHdr->IfNames = (WORD)Value;
  2949. pCalCnt->IfNames = (WORD)Value;
  2950. if (!Value)
  2951. {
  2952. pCalHdr->SCalendar -= CAL_NAME_HDR_SIZE;
  2953. pCalHdr->STwoDigitYearMax -= CAL_NAME_HDR_SIZE;
  2954. pCalHdr->SEraRanges -= CAL_NAME_HDR_SIZE;
  2955. pCalHdr->SShortDate -= CAL_NAME_HDR_SIZE;
  2956. pCalHdr->SYearMonth -= CAL_NAME_HDR_SIZE;
  2957. pCalHdr->SLongDate -= CAL_NAME_HDR_SIZE;
  2958. pCalHdr->SDayName1 -= CAL_NAME_HDR_SIZE;
  2959. //
  2960. // Return success. Don't read any more values for this
  2961. // calendar.
  2962. //
  2963. return (0);
  2964. }
  2965. //
  2966. // Read in the day information and store it in the
  2967. // calendar structure.
  2968. //
  2969. pCalHdr->SDayName1 = pCalHdr->SLongDate + Count;
  2970. if (!(Count = ParseLine( pszKeyWord,
  2971. pCalVar->szSDayName1,
  2972. MAX,
  2973. TRUE )))
  2974. {
  2975. return (1);
  2976. }
  2977. pCalCnt->SDayName1 = (WORD)Count;
  2978. pCalHdr->SDayName2 = pCalHdr->SDayName1 + Count;
  2979. if (!(Count = ParseLine( pszKeyWord,
  2980. pCalVar->szSDayName2,
  2981. MAX,
  2982. TRUE )))
  2983. {
  2984. return (1);
  2985. }
  2986. pCalCnt->SDayName2 = (WORD)Count;
  2987. pCalHdr->SDayName3 = pCalHdr->SDayName2 + Count;
  2988. if (!(Count = ParseLine( pszKeyWord,
  2989. pCalVar->szSDayName3,
  2990. MAX,
  2991. TRUE )))
  2992. {
  2993. return (1);
  2994. }
  2995. pCalCnt->SDayName3 = (WORD)Count;
  2996. pCalHdr->SDayName4 = pCalHdr->SDayName3 + Count;
  2997. if (!(Count = ParseLine( pszKeyWord,
  2998. pCalVar->szSDayName4,
  2999. MAX,
  3000. TRUE )))
  3001. {
  3002. return (1);
  3003. }
  3004. pCalCnt->SDayName4 = (WORD)Count;
  3005. pCalHdr->SDayName5 = pCalHdr->SDayName4 + Count;
  3006. if (!(Count = ParseLine( pszKeyWord,
  3007. pCalVar->szSDayName5,
  3008. MAX,
  3009. TRUE )))
  3010. {
  3011. return (1);
  3012. }
  3013. pCalCnt->SDayName5 = (WORD)Count;
  3014. pCalHdr->SDayName6 = pCalHdr->SDayName5 + Count;
  3015. if (!(Count = ParseLine( pszKeyWord,
  3016. pCalVar->szSDayName6,
  3017. MAX,
  3018. TRUE )))
  3019. {
  3020. return (1);
  3021. }
  3022. pCalCnt->SDayName6 = (WORD)Count;
  3023. pCalHdr->SDayName7 = pCalHdr->SDayName6 + Count;
  3024. if (!(Count = ParseLine( pszKeyWord,
  3025. pCalVar->szSDayName7,
  3026. MAX,
  3027. TRUE )))
  3028. {
  3029. return (1);
  3030. }
  3031. pCalCnt->SDayName7 = (WORD)Count;
  3032. pCalHdr->SAbbrevDayName1 = pCalHdr->SDayName7 + Count;
  3033. if (!(Count = ParseLine( pszKeyWord,
  3034. pCalVar->szSAbbrevDayName1,
  3035. MAX,
  3036. TRUE )))
  3037. {
  3038. return (1);
  3039. }
  3040. pCalCnt->SAbbrevDayName1 = (WORD)Count;
  3041. pCalHdr->SAbbrevDayName2 = pCalHdr->SAbbrevDayName1 + Count;
  3042. if (!(Count = ParseLine( pszKeyWord,
  3043. pCalVar->szSAbbrevDayName2,
  3044. MAX,
  3045. TRUE )))
  3046. {
  3047. return (1);
  3048. }
  3049. pCalCnt->SAbbrevDayName2 = (WORD)Count;
  3050. pCalHdr->SAbbrevDayName3 = pCalHdr->SAbbrevDayName2 + Count;
  3051. if (!(Count = ParseLine( pszKeyWord,
  3052. pCalVar->szSAbbrevDayName3,
  3053. MAX,
  3054. TRUE )))
  3055. {
  3056. return (1);
  3057. }
  3058. pCalCnt->SAbbrevDayName3 = (WORD)Count;
  3059. pCalHdr->SAbbrevDayName4 = pCalHdr->SAbbrevDayName3 + Count;
  3060. if (!(Count = ParseLine( pszKeyWord,
  3061. pCalVar->szSAbbrevDayName4,
  3062. MAX,
  3063. TRUE )))
  3064. {
  3065. return (1);
  3066. }
  3067. pCalCnt->SAbbrevDayName4 = (WORD)Count;
  3068. pCalHdr->SAbbrevDayName5 = pCalHdr->SAbbrevDayName4 + Count;
  3069. if (!(Count = ParseLine( pszKeyWord,
  3070. pCalVar->szSAbbrevDayName5,
  3071. MAX,
  3072. TRUE )))
  3073. {
  3074. return (1);
  3075. }
  3076. pCalCnt->SAbbrevDayName5 = (WORD)Count;
  3077. pCalHdr->SAbbrevDayName6 = pCalHdr->SAbbrevDayName5 + Count;
  3078. if (!(Count = ParseLine( pszKeyWord,
  3079. pCalVar->szSAbbrevDayName6,
  3080. MAX,
  3081. TRUE )))
  3082. {
  3083. return (1);
  3084. }
  3085. pCalCnt->SAbbrevDayName6 = (WORD)Count;
  3086. pCalHdr->SAbbrevDayName7 = pCalHdr->SAbbrevDayName6 + Count;
  3087. if (!(Count = ParseLine( pszKeyWord,
  3088. pCalVar->szSAbbrevDayName7,
  3089. MAX,
  3090. TRUE )))
  3091. {
  3092. return (1);
  3093. }
  3094. pCalCnt->SAbbrevDayName7 = (WORD)Count;
  3095. //
  3096. // Read in the month information of a locale and store it in the
  3097. // locale structure.
  3098. //
  3099. pCalHdr->SMonthName1 = pCalHdr->SAbbrevDayName7 + Count;
  3100. if (!(Count = ParseLine( pszKeyWord,
  3101. pCalVar->szSMonthName1,
  3102. MAX,
  3103. TRUE )))
  3104. {
  3105. return (1);
  3106. }
  3107. pCalCnt->SMonthName1 = (WORD)Count;
  3108. pCalHdr->SMonthName2 = pCalHdr->SMonthName1 + Count;
  3109. if (!(Count = ParseLine( pszKeyWord,
  3110. pCalVar->szSMonthName2,
  3111. MAX,
  3112. TRUE )))
  3113. {
  3114. return (1);
  3115. }
  3116. pCalCnt->SMonthName2 = (WORD)Count;
  3117. pCalHdr->SMonthName3 = pCalHdr->SMonthName2 + Count;
  3118. if (!(Count = ParseLine( pszKeyWord,
  3119. pCalVar->szSMonthName3,
  3120. MAX,
  3121. TRUE )))
  3122. {
  3123. return (1);
  3124. }
  3125. pCalCnt->SMonthName3 = (WORD)Count;
  3126. pCalHdr->SMonthName4 = pCalHdr->SMonthName3 + Count;
  3127. if (!(Count = ParseLine( pszKeyWord,
  3128. pCalVar->szSMonthName4,
  3129. MAX,
  3130. TRUE )))
  3131. {
  3132. return (1);
  3133. }
  3134. pCalCnt->SMonthName4 = (WORD)Count;
  3135. pCalHdr->SMonthName5 = pCalHdr->SMonthName4 + Count;
  3136. if (!(Count = ParseLine( pszKeyWord,
  3137. pCalVar->szSMonthName5,
  3138. MAX,
  3139. TRUE )))
  3140. {
  3141. return (1);
  3142. }
  3143. pCalCnt->SMonthName5 = (WORD)Count;
  3144. pCalHdr->SMonthName6 = pCalHdr->SMonthName5 + Count;
  3145. if (!(Count = ParseLine( pszKeyWord,
  3146. pCalVar->szSMonthName6,
  3147. MAX,
  3148. TRUE )))
  3149. {
  3150. return (1);
  3151. }
  3152. pCalCnt->SMonthName6 = (WORD)Count;
  3153. pCalHdr->SMonthName7 = pCalHdr->SMonthName6 + Count;
  3154. if (!(Count = ParseLine( pszKeyWord,
  3155. pCalVar->szSMonthName7,
  3156. MAX,
  3157. TRUE )))
  3158. {
  3159. return (1);
  3160. }
  3161. pCalCnt->SMonthName7 = (WORD)Count;
  3162. pCalHdr->SMonthName8 = pCalHdr->SMonthName7 + Count;
  3163. if (!(Count = ParseLine( pszKeyWord,
  3164. pCalVar->szSMonthName8,
  3165. MAX,
  3166. TRUE )))
  3167. {
  3168. return (1);
  3169. }
  3170. pCalCnt->SMonthName8 = (WORD)Count;
  3171. pCalHdr->SMonthName9 = pCalHdr->SMonthName8 + Count;
  3172. if (!(Count = ParseLine( pszKeyWord,
  3173. pCalVar->szSMonthName9,
  3174. MAX,
  3175. TRUE )))
  3176. {
  3177. return (1);
  3178. }
  3179. pCalCnt->SMonthName9 = (WORD)Count;
  3180. pCalHdr->SMonthName10 = pCalHdr->SMonthName9 + Count;
  3181. if (!(Count = ParseLine( pszKeyWord,
  3182. pCalVar->szSMonthName10,
  3183. MAX,
  3184. TRUE )))
  3185. {
  3186. return (1);
  3187. }
  3188. pCalCnt->SMonthName10 = (WORD)Count;
  3189. pCalHdr->SMonthName11 = pCalHdr->SMonthName10 + Count;
  3190. if (!(Count = ParseLine( pszKeyWord,
  3191. pCalVar->szSMonthName11,
  3192. MAX,
  3193. TRUE )))
  3194. {
  3195. return (1);
  3196. }
  3197. pCalCnt->SMonthName11 = (WORD)Count;
  3198. pCalHdr->SMonthName12 = pCalHdr->SMonthName11 + Count;
  3199. if (!(Count = ParseLine( pszKeyWord,
  3200. pCalVar->szSMonthName12,
  3201. MAX,
  3202. TRUE )))
  3203. {
  3204. return (1);
  3205. }
  3206. pCalCnt->SMonthName12 = (WORD)Count;
  3207. pCalHdr->SMonthName13 = pCalHdr->SMonthName12 + Count;
  3208. if (!(Count = ParseLine( pszKeyWord,
  3209. pCalVar->szSMonthName13,
  3210. MAX,
  3211. TRUE )))
  3212. {
  3213. return (1);
  3214. }
  3215. pCalCnt->SMonthName13 = (WORD)Count;
  3216. pCalHdr->SAbbrevMonthName1 = pCalHdr->SMonthName13 + Count;
  3217. if (!(Count = ParseLine( pszKeyWord,
  3218. pCalVar->szSAbbrevMonthName1,
  3219. MAX,
  3220. TRUE )))
  3221. {
  3222. return (1);
  3223. }
  3224. pCalCnt->SAbbrevMonthName1 = (WORD)Count;
  3225. pCalHdr->SAbbrevMonthName2 = pCalHdr->SAbbrevMonthName1 + Count;
  3226. if (!(Count = ParseLine( pszKeyWord,
  3227. pCalVar->szSAbbrevMonthName2,
  3228. MAX,
  3229. TRUE )))
  3230. {
  3231. return (1);
  3232. }
  3233. pCalCnt->SAbbrevMonthName2 = (WORD)Count;
  3234. pCalHdr->SAbbrevMonthName3 = pCalHdr->SAbbrevMonthName2 + Count;
  3235. if (!(Count = ParseLine( pszKeyWord,
  3236. pCalVar->szSAbbrevMonthName3,
  3237. MAX,
  3238. TRUE )))
  3239. {
  3240. return (1);
  3241. }
  3242. pCalCnt->SAbbrevMonthName3 = (WORD)Count;
  3243. pCalHdr->SAbbrevMonthName4 = pCalHdr->SAbbrevMonthName3 + Count;
  3244. if (!(Count = ParseLine( pszKeyWord,
  3245. pCalVar->szSAbbrevMonthName4,
  3246. MAX,
  3247. TRUE )))
  3248. {
  3249. return (1);
  3250. }
  3251. pCalCnt->SAbbrevMonthName4 = (WORD)Count;
  3252. pCalHdr->SAbbrevMonthName5 = pCalHdr->SAbbrevMonthName4 + Count;
  3253. if (!(Count = ParseLine( pszKeyWord,
  3254. pCalVar->szSAbbrevMonthName5,
  3255. MAX,
  3256. TRUE )))
  3257. {
  3258. return (1);
  3259. }
  3260. pCalCnt->SAbbrevMonthName5 = (WORD)Count;
  3261. pCalHdr->SAbbrevMonthName6 = pCalHdr->SAbbrevMonthName5 + Count;
  3262. if (!(Count = ParseLine( pszKeyWord,
  3263. pCalVar->szSAbbrevMonthName6,
  3264. MAX,
  3265. TRUE )))
  3266. {
  3267. return (1);
  3268. }
  3269. pCalCnt->SAbbrevMonthName6 = (WORD)Count;
  3270. pCalHdr->SAbbrevMonthName7 = pCalHdr->SAbbrevMonthName6 + Count;
  3271. if (!(Count = ParseLine( pszKeyWord,
  3272. pCalVar->szSAbbrevMonthName7,
  3273. MAX,
  3274. TRUE )))
  3275. {
  3276. return (1);
  3277. }
  3278. pCalCnt->SAbbrevMonthName7 = (WORD)Count;
  3279. pCalHdr->SAbbrevMonthName8 = pCalHdr->SAbbrevMonthName7 + Count;
  3280. if (!(Count = ParseLine( pszKeyWord,
  3281. pCalVar->szSAbbrevMonthName8,
  3282. MAX,
  3283. TRUE )))
  3284. {
  3285. return (1);
  3286. }
  3287. pCalCnt->SAbbrevMonthName8 = (WORD)Count;
  3288. pCalHdr->SAbbrevMonthName9 = pCalHdr->SAbbrevMonthName8 + Count;
  3289. if (!(Count = ParseLine( pszKeyWord,
  3290. pCalVar->szSAbbrevMonthName9,
  3291. MAX,
  3292. TRUE )))
  3293. {
  3294. return (1);
  3295. }
  3296. pCalCnt->SAbbrevMonthName9 = (WORD)Count;
  3297. pCalHdr->SAbbrevMonthName10 = pCalHdr->SAbbrevMonthName9 + Count;
  3298. if (!(Count = ParseLine( pszKeyWord,
  3299. pCalVar->szSAbbrevMonthName10,
  3300. MAX,
  3301. TRUE )))
  3302. {
  3303. return (1);
  3304. }
  3305. pCalCnt->SAbbrevMonthName10 = (WORD)Count;
  3306. pCalHdr->SAbbrevMonthName11 = pCalHdr->SAbbrevMonthName10 + Count;
  3307. if (!(Count = ParseLine( pszKeyWord,
  3308. pCalVar->szSAbbrevMonthName11,
  3309. MAX,
  3310. TRUE )))
  3311. {
  3312. return (1);
  3313. }
  3314. pCalCnt->SAbbrevMonthName11 = (WORD)Count;
  3315. pCalHdr->SAbbrevMonthName12 = pCalHdr->SAbbrevMonthName11 + Count;
  3316. if (!(Count = ParseLine( pszKeyWord,
  3317. pCalVar->szSAbbrevMonthName12,
  3318. MAX,
  3319. TRUE )))
  3320. {
  3321. return (1);
  3322. }
  3323. pCalCnt->SAbbrevMonthName12 = (WORD)Count;
  3324. pCalHdr->SAbbrevMonthName13 = pCalHdr->SAbbrevMonthName12 + Count;
  3325. if (!(Count = ParseLine( pszKeyWord,
  3326. pCalVar->szSAbbrevMonthName13,
  3327. MAX,
  3328. TRUE )))
  3329. {
  3330. return (1);
  3331. }
  3332. pCalCnt->SAbbrevMonthName13 = (WORD)Count;
  3333. pCalHdr->SEndOfCalendar = pCalHdr->SAbbrevMonthName13 + Count;
  3334. //
  3335. // Return success.
  3336. //
  3337. return (0);
  3338. }
  3339. ////////////////////////////////////////////////////////////////////////////
  3340. //
  3341. // WriteCalendarInit
  3342. //
  3343. // This routine writes the number of calendars and the offset to the
  3344. // calendar information in the data file.
  3345. //
  3346. // 12-10-91 JulieB Created.
  3347. ////////////////////////////////////////////////////////////////////////////
  3348. int WriteCalendarInit(
  3349. FILE *pOutputFile,
  3350. int NumCal,
  3351. int OffCalHdr)
  3352. {
  3353. WORD pDummy[MAX]; // dummy storage
  3354. DWORD dwValue; // temp storage value
  3355. //
  3356. // Write the number of calendars to the file.
  3357. //
  3358. //
  3359. // Seek to NumCalendar offset.
  3360. //
  3361. if (fseek( pOutputFile,
  3362. LOC_NUM_CAL_WORDS * sizeof(WORD),
  3363. 0 ))
  3364. {
  3365. printf("Seek Error: Can't seek in file %s.\n", LOCALE_FILE);
  3366. return (1);
  3367. }
  3368. //
  3369. // Write the number of calendars to the file.
  3370. //
  3371. dwValue = (DWORD)NumCal;
  3372. if (FileWrite( pOutputFile,
  3373. &dwValue,
  3374. sizeof(DWORD),
  3375. 1,
  3376. "Number of Calendars" ))
  3377. {
  3378. return (1);
  3379. }
  3380. //
  3381. // Write the offset of calendar info to the file.
  3382. //
  3383. dwValue = (DWORD)OffCalHdr;
  3384. if (FileWrite( pOutputFile,
  3385. &dwValue,
  3386. sizeof(DWORD),
  3387. 1,
  3388. "Offset of Calendar Info" ))
  3389. {
  3390. return (1);
  3391. }
  3392. //
  3393. // Seek to calendar header.
  3394. //
  3395. if (fseek( pOutputFile,
  3396. OffCalHdr * sizeof(WORD),
  3397. 0 ))
  3398. {
  3399. printf("Seek Error: Can't seek in file %s.\n", LOCALE_FILE);
  3400. return (1);
  3401. }
  3402. //
  3403. // Write zeros in the file to allow the seek to work.
  3404. //
  3405. memset(pDummy, 0, MAX * sizeof(WORD));
  3406. if (FileWrite( pOutputFile,
  3407. pDummy,
  3408. sizeof(WORD),
  3409. NumCal * CALENDAR_HDR_WORDS,
  3410. "Calendar Header" ))
  3411. {
  3412. return (1);
  3413. }
  3414. //
  3415. // Seek back to the beginning of the calendar header.
  3416. //
  3417. if (fseek( pOutputFile,
  3418. OffCalHdr * sizeof(WORD),
  3419. 0 ))
  3420. {
  3421. printf("Seek Error: Can't seek in file %s.\n", LOCALE_FILE);
  3422. return (1);
  3423. }
  3424. //
  3425. // Return success.
  3426. //
  3427. return (0);
  3428. }
  3429. ////////////////////////////////////////////////////////////////////////////
  3430. //
  3431. // WriteCalendarInfo
  3432. //
  3433. // This routine writes the calendar id, offset, and calendar information to
  3434. // the output file. It needs to seek ahead to the correct position for the
  3435. // calendar information, and then seeks back to the header position. The
  3436. // file positions are updated to reflect the next offsets.
  3437. //
  3438. // 12-10-91 JulieB Created.
  3439. ////////////////////////////////////////////////////////////////////////////
  3440. int WriteCalendarInfo(
  3441. DWORD Calendar,
  3442. int *pOffHdr,
  3443. int *pOffCal,
  3444. int OffCalBegin,
  3445. PCALENDAR_HEADER pCalHdr,
  3446. PCALENDAR_VARIABLE pCalVar,
  3447. PCALENDAR_HEADER pCalCnt,
  3448. FILE *pOutputFile)
  3449. {
  3450. int Size; // size of locale information
  3451. int TotalSize = 0; // total size of the locale information
  3452. int NameSize; // size of name space to subtract
  3453. WORD wValue; // temp storage value
  3454. if (Verbose)
  3455. printf("\nWriting Calendar Information for %x...\n", Calendar);
  3456. //
  3457. // Write the calendar id and offset to the calendar information in
  3458. // the calendar header area of the output file.
  3459. //
  3460. wValue = (WORD)Calendar;
  3461. if (FileWrite( pOutputFile,
  3462. &wValue,
  3463. sizeof(WORD),
  3464. 1,
  3465. "Calendar ID" ))
  3466. {
  3467. return (1);
  3468. }
  3469. wValue = (WORD)(*pOffCal);
  3470. if (FileWrite( pOutputFile,
  3471. &wValue,
  3472. sizeof(WORD),
  3473. 1,
  3474. "Calendar Info Offset" ))
  3475. {
  3476. return (1);
  3477. }
  3478. //
  3479. // Seek forward to calendar info offset.
  3480. //
  3481. if (fseek( pOutputFile,
  3482. (OffCalBegin + (*pOffCal)) * sizeof(WORD),
  3483. 0 ))
  3484. {
  3485. printf("Seek Error: Can't seek in file %s.\n", LOCALE_FILE);
  3486. return (1);
  3487. }
  3488. //
  3489. // Write the calendar information to the output file.
  3490. // Header Info
  3491. // Variable Length Info
  3492. //
  3493. NameSize = (pCalHdr->IfNames) ? 0 : CAL_NAME_HDR_SIZE;
  3494. TotalSize = Size = (sizeof(CALENDAR_HEADER) / sizeof(WORD)) - NameSize;
  3495. if (FileWrite( pOutputFile,
  3496. pCalHdr,
  3497. sizeof(WORD),
  3498. Size,
  3499. "Calendar Header" ))
  3500. {
  3501. return (1);
  3502. }
  3503. if (WriteCalendarVariableLength( pCalCnt,
  3504. pCalVar,
  3505. &TotalSize,
  3506. pOutputFile ))
  3507. {
  3508. return (1);
  3509. }
  3510. //
  3511. // Set the offsets to their new values.
  3512. //
  3513. (*pOffHdr) += CALENDAR_HDR_WORDS;
  3514. (*pOffCal) += TotalSize;
  3515. //
  3516. // Make sure the size is not wrapping - can't be greater than
  3517. // a DWORD.
  3518. //
  3519. if (*pOffCal > 0xffff)
  3520. {
  3521. printf("Size Error: Offset is greater than a WORD for calendar %d.\n", Calendar);
  3522. return (1);
  3523. }
  3524. //
  3525. // Seek back to the calendar header offset.
  3526. //
  3527. if (fseek( pOutputFile,
  3528. (*pOffHdr) * sizeof(WORD),
  3529. 0 ))
  3530. {
  3531. printf("Seek Error: Can't seek in file %s.\n", LOCALE_FILE);
  3532. return (1);
  3533. }
  3534. //
  3535. // Return success.
  3536. //
  3537. return (0);
  3538. }
  3539. ////////////////////////////////////////////////////////////////////////////
  3540. //
  3541. // WriteCalendarVariableLength
  3542. //
  3543. // This routine writes the variable length calendar information to the output
  3544. // file. It adds on to the total size of the calendar information as it adds
  3545. // the variable length information.
  3546. //
  3547. // 12-10-91 JulieB Created.
  3548. ////////////////////////////////////////////////////////////////////////////
  3549. int WriteCalendarVariableLength(
  3550. PCALENDAR_HEADER pCalCnt,
  3551. PCALENDAR_VARIABLE pCalVar,
  3552. int *pTotalSize,
  3553. FILE *pOutputFile)
  3554. {
  3555. int Size; // size of string
  3556. *pTotalSize += (Size = pCalCnt->SCalendar);
  3557. if (FileWrite( pOutputFile,
  3558. pCalVar->szSCalendar,
  3559. sizeof(WORD),
  3560. Size,
  3561. "Calendar Variable Info" ))
  3562. {
  3563. return (1);
  3564. }
  3565. *pTotalSize += (Size = pCalCnt->STwoDigitYearMax);
  3566. if (FileWrite( pOutputFile,
  3567. pCalVar->szSTwoDigitYearMax,
  3568. sizeof(WORD),
  3569. Size,
  3570. "Calendar Variable Info" ))
  3571. {
  3572. return (1);
  3573. }
  3574. *pTotalSize += (Size = pCalCnt->SEraRanges);
  3575. if (FileWrite( pOutputFile,
  3576. pCalVar->szSEraRanges,
  3577. sizeof(WORD),
  3578. Size,
  3579. "Calendar Variable Info" ))
  3580. {
  3581. return (1);
  3582. }
  3583. *pTotalSize += (Size = pCalCnt->SShortDate);
  3584. if (FileWrite( pOutputFile,
  3585. pCalVar->szSShortDate,
  3586. sizeof(WORD),
  3587. Size,
  3588. "Calendar Variable Info" ))
  3589. {
  3590. return (1);
  3591. }
  3592. *pTotalSize += (Size = pCalCnt->SYearMonth);
  3593. if (FileWrite( pOutputFile,
  3594. pCalVar->szSYearMonth,
  3595. sizeof(WORD),
  3596. Size,
  3597. "Calendar Variable Info" ))
  3598. {
  3599. return (1);
  3600. }
  3601. *pTotalSize += (Size = pCalCnt->SLongDate);
  3602. if (FileWrite( pOutputFile,
  3603. pCalVar->szSLongDate,
  3604. sizeof(WORD),
  3605. Size,
  3606. "Calendar Variable Info" ))
  3607. {
  3608. return (1);
  3609. }
  3610. //
  3611. // See if any of the day or month names exist.
  3612. //
  3613. if (pCalCnt->IfNames == 0)
  3614. {
  3615. //
  3616. // Return success. Don't write any of the day or month names.
  3617. //
  3618. return (0);
  3619. }
  3620. *pTotalSize += (Size = pCalCnt->SDayName1);
  3621. if (FileWrite( pOutputFile,
  3622. pCalVar->szSDayName1,
  3623. sizeof(WORD),
  3624. Size,
  3625. "Calendar Variable Info" ))
  3626. {
  3627. return (1);
  3628. }
  3629. *pTotalSize += (Size = pCalCnt->SDayName2);
  3630. if (FileWrite( pOutputFile,
  3631. pCalVar->szSDayName2,
  3632. sizeof(WORD),
  3633. Size,
  3634. "Calendar Variable Info" ))
  3635. {
  3636. return (1);
  3637. }
  3638. *pTotalSize += (Size = pCalCnt->SDayName3);
  3639. if (FileWrite( pOutputFile,
  3640. pCalVar->szSDayName3,
  3641. sizeof(WORD),
  3642. Size,
  3643. "Calendar Variable Info" ))
  3644. {
  3645. return (1);
  3646. }
  3647. *pTotalSize += (Size = pCalCnt->SDayName4);
  3648. if (FileWrite( pOutputFile,
  3649. pCalVar->szSDayName4,
  3650. sizeof(WORD),
  3651. Size,
  3652. "Calendar Variable Info" ))
  3653. {
  3654. return (1);
  3655. }
  3656. *pTotalSize += (Size = pCalCnt->SDayName5);
  3657. if (FileWrite( pOutputFile,
  3658. pCalVar->szSDayName5,
  3659. sizeof(WORD),
  3660. Size,
  3661. "Calendar Variable Info" ))
  3662. {
  3663. return (1);
  3664. }
  3665. *pTotalSize += (Size = pCalCnt->SDayName6);
  3666. if (FileWrite( pOutputFile,
  3667. pCalVar->szSDayName6,
  3668. sizeof(WORD),
  3669. Size,
  3670. "Calendar Variable Info" ))
  3671. {
  3672. return (1);
  3673. }
  3674. *pTotalSize += (Size = pCalCnt->SDayName7);
  3675. if (FileWrite( pOutputFile,
  3676. pCalVar->szSDayName7,
  3677. sizeof(WORD),
  3678. Size,
  3679. "Calendar Variable Info" ))
  3680. {
  3681. return (1);
  3682. }
  3683. *pTotalSize += (Size = pCalCnt->SAbbrevDayName1);
  3684. if (FileWrite( pOutputFile,
  3685. pCalVar->szSAbbrevDayName1,
  3686. sizeof(WORD),
  3687. Size,
  3688. "Calendar Variable Info" ))
  3689. {
  3690. return (1);
  3691. }
  3692. *pTotalSize += (Size = pCalCnt->SAbbrevDayName2);
  3693. if (FileWrite( pOutputFile,
  3694. pCalVar->szSAbbrevDayName2,
  3695. sizeof(WORD),
  3696. Size,
  3697. "Calendar Variable Info" ))
  3698. {
  3699. return (1);
  3700. }
  3701. *pTotalSize += (Size = pCalCnt->SAbbrevDayName3);
  3702. if (FileWrite( pOutputFile,
  3703. pCalVar->szSAbbrevDayName3,
  3704. sizeof(WORD),
  3705. Size,
  3706. "Calendar Variable Info" ))
  3707. {
  3708. return (1);
  3709. }
  3710. *pTotalSize += (Size = pCalCnt->SAbbrevDayName4);
  3711. if (FileWrite( pOutputFile,
  3712. pCalVar->szSAbbrevDayName4,
  3713. sizeof(WORD),
  3714. Size,
  3715. "Calendar Variable Info" ))
  3716. {
  3717. return (1);
  3718. }
  3719. *pTotalSize += (Size = pCalCnt->SAbbrevDayName5);
  3720. if (FileWrite( pOutputFile,
  3721. pCalVar->szSAbbrevDayName5,
  3722. sizeof(WORD),
  3723. Size,
  3724. "Calendar Variable Info" ))
  3725. {
  3726. return (1);
  3727. }
  3728. *pTotalSize += (Size = pCalCnt->SAbbrevDayName6);
  3729. if (FileWrite( pOutputFile,
  3730. pCalVar->szSAbbrevDayName6,
  3731. sizeof(WORD),
  3732. Size,
  3733. "Calendar Variable Info" ))
  3734. {
  3735. return (1);
  3736. }
  3737. *pTotalSize += (Size = pCalCnt->SAbbrevDayName7);
  3738. if (FileWrite( pOutputFile,
  3739. pCalVar->szSAbbrevDayName7,
  3740. sizeof(WORD),
  3741. Size,
  3742. "Calendar Variable Info" ))
  3743. {
  3744. return (1);
  3745. }
  3746. *pTotalSize += (Size = pCalCnt->SMonthName1);
  3747. if (FileWrite( pOutputFile,
  3748. pCalVar->szSMonthName1,
  3749. sizeof(WORD),
  3750. Size,
  3751. "Calendar Variable Info" ))
  3752. {
  3753. return (1);
  3754. }
  3755. *pTotalSize += (Size = pCalCnt->SMonthName2);
  3756. if (FileWrite( pOutputFile,
  3757. pCalVar->szSMonthName2,
  3758. sizeof(WORD),
  3759. Size,
  3760. "Calendar Variable Info" ))
  3761. {
  3762. return (1);
  3763. }
  3764. *pTotalSize += (Size = pCalCnt->SMonthName3);
  3765. if (FileWrite( pOutputFile,
  3766. pCalVar->szSMonthName3,
  3767. sizeof(WORD),
  3768. Size,
  3769. "Calendar Variable Info" ))
  3770. {
  3771. return (1);
  3772. }
  3773. *pTotalSize += (Size = pCalCnt->SMonthName4);
  3774. if (FileWrite( pOutputFile,
  3775. pCalVar->szSMonthName4,
  3776. sizeof(WORD),
  3777. Size,
  3778. "Calendar Variable Info" ))
  3779. {
  3780. return (1);
  3781. }
  3782. *pTotalSize += (Size = pCalCnt->SMonthName5);
  3783. if (FileWrite( pOutputFile,
  3784. pCalVar->szSMonthName5,
  3785. sizeof(WORD),
  3786. Size,
  3787. "Calendar Variable Info" ))
  3788. {
  3789. return (1);
  3790. }
  3791. *pTotalSize += (Size = pCalCnt->SMonthName6);
  3792. if (FileWrite( pOutputFile,
  3793. pCalVar->szSMonthName6,
  3794. sizeof(WORD),
  3795. Size,
  3796. "Calendar Variable Info" ))
  3797. {
  3798. return (1);
  3799. }
  3800. *pTotalSize += (Size = pCalCnt->SMonthName7);
  3801. if (FileWrite( pOutputFile,
  3802. pCalVar->szSMonthName7,
  3803. sizeof(WORD),
  3804. Size,
  3805. "Calendar Variable Info" ))
  3806. {
  3807. return (1);
  3808. }
  3809. *pTotalSize += (Size = pCalCnt->SMonthName8);
  3810. if (FileWrite( pOutputFile,
  3811. pCalVar->szSMonthName8,
  3812. sizeof(WORD),
  3813. Size,
  3814. "Calendar Variable Info" ))
  3815. {
  3816. return (1);
  3817. }
  3818. *pTotalSize += (Size = pCalCnt->SMonthName9);
  3819. if (FileWrite( pOutputFile,
  3820. pCalVar->szSMonthName9,
  3821. sizeof(WORD),
  3822. Size,
  3823. "Calendar Variable Info" ))
  3824. {
  3825. return (1);
  3826. }
  3827. *pTotalSize += (Size = pCalCnt->SMonthName10);
  3828. if (FileWrite( pOutputFile,
  3829. pCalVar->szSMonthName10,
  3830. sizeof(WORD),
  3831. Size,
  3832. "Calendar Variable Info" ))
  3833. {
  3834. return (1);
  3835. }
  3836. *pTotalSize += (Size = pCalCnt->SMonthName11);
  3837. if (FileWrite( pOutputFile,
  3838. pCalVar->szSMonthName11,
  3839. sizeof(WORD),
  3840. Size,
  3841. "Calendar Variable Info" ))
  3842. {
  3843. return (1);
  3844. }
  3845. *pTotalSize += (Size = pCalCnt->SMonthName12);
  3846. if (FileWrite( pOutputFile,
  3847. pCalVar->szSMonthName12,
  3848. sizeof(WORD),
  3849. Size,
  3850. "Calendar Variable Info" ))
  3851. {
  3852. return (1);
  3853. }
  3854. *pTotalSize += (Size = pCalCnt->SMonthName13);
  3855. if (FileWrite( pOutputFile,
  3856. pCalVar->szSMonthName13,
  3857. sizeof(WORD),
  3858. Size,
  3859. "Calendar Variable Info" ))
  3860. {
  3861. return (1);
  3862. }
  3863. *pTotalSize += (Size = pCalCnt->SAbbrevMonthName1);
  3864. if (FileWrite( pOutputFile,
  3865. pCalVar->szSAbbrevMonthName1,
  3866. sizeof(WORD),
  3867. Size,
  3868. "Calendar Variable Info" ))
  3869. {
  3870. return (1);
  3871. }
  3872. *pTotalSize += (Size = pCalCnt->SAbbrevMonthName2);
  3873. if (FileWrite( pOutputFile,
  3874. pCalVar->szSAbbrevMonthName2,
  3875. sizeof(WORD),
  3876. Size,
  3877. "Calendar Variable Info" ))
  3878. {
  3879. return (1);
  3880. }
  3881. *pTotalSize += (Size = pCalCnt->SAbbrevMonthName3);
  3882. if (FileWrite( pOutputFile,
  3883. pCalVar->szSAbbrevMonthName3,
  3884. sizeof(WORD),
  3885. Size,
  3886. "Calendar Variable Info" ))
  3887. {
  3888. return (1);
  3889. }
  3890. *pTotalSize += (Size = pCalCnt->SAbbrevMonthName4);
  3891. if (FileWrite( pOutputFile,
  3892. pCalVar->szSAbbrevMonthName4,
  3893. sizeof(WORD),
  3894. Size,
  3895. "Calendar Variable Info" ))
  3896. {
  3897. return (1);
  3898. }
  3899. *pTotalSize += (Size = pCalCnt->SAbbrevMonthName5);
  3900. if (FileWrite( pOutputFile,
  3901. pCalVar->szSAbbrevMonthName5,
  3902. sizeof(WORD),
  3903. Size,
  3904. "Calendar Variable Info" ))
  3905. {
  3906. return (1);
  3907. }
  3908. *pTotalSize += (Size = pCalCnt->SAbbrevMonthName6);
  3909. if (FileWrite( pOutputFile,
  3910. pCalVar->szSAbbrevMonthName6,
  3911. sizeof(WORD),
  3912. Size,
  3913. "Calendar Variable Info" ))
  3914. {
  3915. return (1);
  3916. }
  3917. *pTotalSize += (Size = pCalCnt->SAbbrevMonthName7);
  3918. if (FileWrite( pOutputFile,
  3919. pCalVar->szSAbbrevMonthName7,
  3920. sizeof(WORD),
  3921. Size,
  3922. "Calendar Variable Info" ))
  3923. {
  3924. return (1);
  3925. }
  3926. *pTotalSize += (Size = pCalCnt->SAbbrevMonthName8);
  3927. if (FileWrite( pOutputFile,
  3928. pCalVar->szSAbbrevMonthName8,
  3929. sizeof(WORD),
  3930. Size,
  3931. "Calendar Variable Info" ))
  3932. {
  3933. return (1);
  3934. }
  3935. *pTotalSize += (Size = pCalCnt->SAbbrevMonthName9);
  3936. if (FileWrite( pOutputFile,
  3937. pCalVar->szSAbbrevMonthName9,
  3938. sizeof(WORD),
  3939. Size,
  3940. "Calendar Variable Info" ))
  3941. {
  3942. return (1);
  3943. }
  3944. *pTotalSize += (Size = pCalCnt->SAbbrevMonthName10);
  3945. if (FileWrite( pOutputFile,
  3946. pCalVar->szSAbbrevMonthName10,
  3947. sizeof(WORD),
  3948. Size,
  3949. "Calendar Variable Info" ))
  3950. {
  3951. return (1);
  3952. }
  3953. *pTotalSize += (Size = pCalCnt->SAbbrevMonthName11);
  3954. if (FileWrite( pOutputFile,
  3955. pCalVar->szSAbbrevMonthName11,
  3956. sizeof(WORD),
  3957. Size,
  3958. "Calendar Variable Info" ))
  3959. {
  3960. return (1);
  3961. }
  3962. *pTotalSize += (Size = pCalCnt->SAbbrevMonthName12);
  3963. if (FileWrite( pOutputFile,
  3964. pCalVar->szSAbbrevMonthName12,
  3965. sizeof(WORD),
  3966. Size,
  3967. "Calendar Variable Info" ))
  3968. {
  3969. return (1);
  3970. }
  3971. *pTotalSize += (Size = pCalCnt->SAbbrevMonthName13);
  3972. if (FileWrite( pOutputFile,
  3973. pCalVar->szSAbbrevMonthName13,
  3974. sizeof(WORD),
  3975. Size,
  3976. "Calendar Variable Info" ))
  3977. {
  3978. return (1);
  3979. }
  3980. //
  3981. // Return success.
  3982. //
  3983. return (0);
  3984. }
  3985. ////////////////////////////////////////////////////////////////////////////
  3986. //
  3987. // ConvertUnicodeToWord
  3988. //
  3989. // This routine converts a Unicode string to a WORD value.
  3990. //
  3991. // 08-21-95 JulieB Created.
  3992. ////////////////////////////////////////////////////////////////////////////
  3993. #define ISDIGIT(c) ((c) >= L'0' && (c) <= L'9')
  3994. int ConvertUnicodeToWord(
  3995. WORD *pString,
  3996. WORD *pValue)
  3997. {
  3998. UINT Val = 0;
  3999. while (*pString)
  4000. {
  4001. if (ISDIGIT(*pString))
  4002. {
  4003. Val *= 10;
  4004. Val += *pString - L'0';
  4005. pString++;
  4006. }
  4007. else
  4008. {
  4009. //
  4010. // Error.
  4011. //
  4012. return (0);
  4013. }
  4014. }
  4015. if (Val > 0xffff)
  4016. {
  4017. //
  4018. // Code page cannot be greater than a WORD value.
  4019. //
  4020. return (0);
  4021. }
  4022. *pValue = (WORD)Val;
  4023. return (1);
  4024. }