Leaked source code of windows server 2003
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.

1525 lines
40 KiB

  1. ;/*
  2. ; * Microsoft Confidential
  3. ; * Copyright (C) Microsoft Corporation 1991
  4. ; * All Rights Reserved.
  5. ; */
  6. /* -------------------------------------------------------------------------- */
  7. #include "dos.h"
  8. #include "string.h"
  9. #include "stdio.h"
  10. #include "stdlib.h"
  11. #include "ctype.h"
  12. #include "process.h"
  13. #include "malloc.h"
  14. #include "bldmsg.h"
  15. /* -------------------------------------------------------------------------- */
  16. #define FALSE (char) (1==0)
  17. #define TRUE (char) !FALSE
  18. #define NUL (char) '\0'
  19. #define READONLY 0
  20. #define NAME_COMMAND "COMMAND\0" /* Mar 88, SWN */
  21. #define MAXLINE 200 /* Supposed to be used for getting the message text. */
  22. #define MAXUTILERROR 300
  23. #define MAXEXTENDEDERROR 100
  24. #define MAXPARSERERROR 20
  25. #define MAXCOMMONERROR 100
  26. #define MAXLENGTH 500
  27. #define TOTALUTIL 45
  28. /* -------------------------------------------------------------------------- */
  29. #define ParseOrExtend ((!strnicmp(USEstring,"PARSE\n",5) ) || (!strnicmp(USEstring,"EXTEND\0",5) ) )
  30. #define IsReserved(c) ( (c == '1') || (c == '2') )
  31. /* -------------------------------------------------------------------------- */
  32. char *MessageSkeletonFilePtr;
  33. char *CommentLinePtr = "\x0d\x0a; ----------------------------------------------------------\x0d\x0a\x0d\x0a";
  34. char EofFlags[256];
  35. char ClassFlag1;
  36. char ClassFlag2;
  37. int ClassCount;
  38. int ClassCounts[256];
  39. int CurrentClass;
  40. int CurrentClassIndex;
  41. int CurrentMessageNumber;
  42. int LineNumber;
  43. int add_crlf ;
  44. int Pass;
  45. char Done;
  46. char MessagePending;
  47. char ClassPending;
  48. char UtilityName[16];
  49. char USEstring[16] ;
  50. char Is_Utility_Command[16]; /* Mar 88, SWN */
  51. char Is_Command_set[] = "12cdeCDE";
  52. char CurrentClassFileName[128];
  53. unsigned SkeletonHandle = 0xffff;
  54. unsigned ClassHandle = 0xffff;
  55. unsigned CommonMessageLines;
  56. unsigned ParserMessageLines;
  57. unsigned ExtendedMessageLines;
  58. unsigned UtilMessageLines;
  59. unsigned ContinueLine;
  60. char CountryIdx[128];
  61. char CountryMsg[128];
  62. char CountryName[128];
  63. char ReadCommonFlag = FALSE;
  64. char ReadExtendFlag = FALSE;
  65. char ReadParserFlag = FALSE;
  66. char ReadUtilFlag = FALSE;
  67. char *UtilErrorTexts[MAXUTILERROR+1];
  68. char *ExtendedErrorTexts[MAXEXTENDEDERROR+1];
  69. char *ParserErrorTexts[MAXPARSERERROR+1];
  70. char *CommonErrorTexts[MAXCOMMONERROR+1];
  71. char Debugging = FALSE;
  72. /* -------------------------------------------------------------------------- */
  73. void error(union REGS *, union REGS *, struct SREGS *);
  74. void LineInput( unsigned, char far * );
  75. unsigned DosRead( unsigned, char far *, int );
  76. unsigned DosWrite( unsigned, char far *, int );
  77. long DosLSeek( unsigned, long, int );
  78. void DosClose( unsigned );
  79. unsigned DosOpen( char far *, unsigned );
  80. unsigned DosCreate( char far *, unsigned );
  81. unsigned LowOf(long);
  82. unsigned HighOf(long);
  83. long LongOf(unsigned, unsigned);
  84. void main(int, char * []);
  85. void ProcessSkeletonFile(char *);
  86. void UtilRecord(char *);
  87. void ClassRecord(char *);
  88. void DefRecord(char *);
  89. void UseRecord(char *);
  90. void EndRecord(char *);
  91. void DefContinue(char *);
  92. void UseContinue(char *);
  93. void MessageTerminate(void);
  94. void ClassTerminate(void);
  95. void CommentLine(void);
  96. void BlankLine(void);
  97. void PublicLine(void);
  98. void ReadCommon(void);
  99. char *MyMalloc(int);
  100. /* -------------------------------------------------------------------------- */
  101. void main(argc,argv)
  102. int argc;
  103. char *argv[];
  104. {
  105. int i;
  106. char *s;
  107. unsigned len;
  108. char far *PspCharPtr;
  109. unsigned far *PspWordPtr;
  110. unsigned long ProgramSize;
  111. unsigned long MemoryAllocatable;
  112. union REGS InRegs;
  113. union REGS OutRegs;
  114. struct SREGS SegRegs;
  115. /* check for assistance needed */
  116. if ( (argc < 3) && (*argv[1] == (char) '?') )
  117. {
  118. printf("BUILDMSG country skeleton-file-spec\n");
  119. exit(1);
  120. }
  121. /* get the 1st parm is the Country name */
  122. /* get the skeleton file name (2nd Parm) to be processed */
  123. strcpy(CountryName, argv[1]);
  124. strupr(CountryName);
  125. strcpy(CountryIdx,CountryName);
  126. strcat(CountryIdx, ".IDX");
  127. strcpy(CountryMsg,CountryName);
  128. strcat(CountryMsg, ".MSG");
  129. for (i = 0; i <= MAXUTILERROR ; i++) UtilErrorTexts[i] = "";
  130. for (i = 0; i <= MAXEXTENDEDERROR; i++) ExtendedErrorTexts[i] = "";
  131. for (i = 0; i <= MAXPARSERERROR ; i++) ParserErrorTexts[i] = "";
  132. for (i = 0; i <= MAXCOMMONERROR ; i++) CommonErrorTexts[i] = "";
  133. for (i = 0; i < 256; i++)
  134. {
  135. ClassCounts[i] = 0;
  136. EofFlags[i] = TRUE;
  137. }
  138. if ( (argc > 3) && (strnicmp(argv[3],"/D",2) == 0) ) Debugging = TRUE;
  139. InRegs.x.ax = 0x6200;
  140. intdos(&InRegs, &OutRegs);
  141. printf("BuildMsg - PSP at %04x\n",OutRegs.x.bx);
  142. FP_SEG(PspWordPtr) = OutRegs.x.bx;
  143. FP_OFF(PspWordPtr) = 0;
  144. FP_SEG(PspCharPtr) = OutRegs.x.bx;
  145. FP_OFF(PspCharPtr) = 0;
  146. ProgramSize = (unsigned long) *(PspWordPtr+1);
  147. printf("Program memory size is %ld\n",ProgramSize);
  148. InRegs.x.ax = 0x4800;
  149. InRegs.x.bx = 0xffff;
  150. intdos(&InRegs, &OutRegs);
  151. if (OutRegs.x.cflag)
  152. {
  153. InRegs.x.bx = OutRegs.x.bx;
  154. }
  155. else {
  156. SegRegs.es = OutRegs.x.ax;
  157. InRegs.x.ax = 0x4900;
  158. intdosx(&InRegs, &OutRegs, &SegRegs);
  159. }
  160. MemoryAllocatable = (unsigned long) InRegs.x.bx;
  161. MemoryAllocatable *= 16;
  162. printf("Allocatable memory size is %ld\n",MemoryAllocatable);
  163. ProcessSkeletonFile(argv[2]);
  164. exit(0);
  165. }
  166. /* -------------------------------------------------------------------------- */
  167. void ProcessSkeletonFile(FileName)
  168. char *FileName;
  169. {
  170. union REGS InRegs;
  171. union REGS OutRegs;
  172. struct SREGS SegRegs;
  173. unsigned SkeletonHandle;
  174. char *s;
  175. int i;
  176. char out[128];
  177. char CurrentRecord[256];
  178. char RecordTypeText[32];
  179. int LastRecord;
  180. char Processed;
  181. MessageSkeletonFilePtr = FileName;
  182. printf("Processing [%s]\n",MessageSkeletonFilePtr);
  183. /* Process the MESSAGE.SKL file */
  184. SkeletonHandle = DosOpen( (char far *) MessageSkeletonFilePtr, READONLY);
  185. ClassCount = 0;
  186. for (Pass = 1; Pass < 3; Pass++)
  187. {
  188. if (Debugging) printf("--> Starting Pass %d <--\n",Pass);
  189. ClassFlag1 = FALSE;
  190. ClassFlag2 = FALSE;
  191. CurrentClassIndex = 0;
  192. LineNumber = 0;
  193. CurrentClass = 0;
  194. Done = FALSE;
  195. LastRecord = 0;
  196. MessagePending = FALSE;
  197. ClassPending = FALSE;
  198. InRegs.x.ax = 0x4200;
  199. InRegs.x.bx = SkeletonHandle;
  200. InRegs.x.cx = 0;
  201. InRegs.x.dx = 0;
  202. intdosx(&InRegs,&OutRegs,&SegRegs);
  203. if (OutRegs.x.cflag)
  204. error(&InRegs,&OutRegs,&SegRegs);
  205. while ( (!EofFlags[SkeletonHandle]) && (!Done) )
  206. { CurrentRecord[0] = NUL;
  207. LineInput(SkeletonHandle, (char far *) &CurrentRecord[0] );
  208. LineNumber++;
  209. RecordTypeText[0] = NUL;
  210. sscanf(&CurrentRecord[0]," %s ",&RecordTypeText[0]);
  211. i = strlen(RecordTypeText);
  212. strupr(RecordTypeText);
  213. if (RecordTypeText[0] == (char) ':') Processed = FALSE;
  214. else Processed = TRUE;
  215. if (strcmp(RecordTypeText,":UTIL") == 0)
  216. { UtilRecord(&CurrentRecord[i]);
  217. Processed = TRUE;
  218. LastRecord = 1;
  219. }
  220. if (strcmp(RecordTypeText,":CLASS") == 0)
  221. { ClassRecord(&CurrentRecord[i]);
  222. Processed = TRUE;
  223. LastRecord = 2;
  224. }
  225. if (strcmp(RecordTypeText,":DEF") == 0)
  226. { DefRecord(&CurrentRecord[i]);
  227. Processed = TRUE;
  228. LastRecord = 3;
  229. }
  230. if (strcmp(RecordTypeText,":USE") == 0)
  231. { UseRecord(&CurrentRecord[i]);
  232. Processed = TRUE;
  233. LastRecord = 4;
  234. }
  235. if (strcmp(RecordTypeText,":END") == 0)
  236. { EndRecord(&CurrentRecord[i]);
  237. Processed = TRUE;
  238. LastRecord = 5;
  239. }
  240. if (!Processed)
  241. { printf("Error: unrecognized record in skeleton file, line %d\n",LineNumber);
  242. exit(1);
  243. }
  244. }
  245. if (!ClassFlag1) ClassRecord(" 1 ");
  246. if (!ClassFlag2) ClassRecord(" 2 ");
  247. if (MessagePending) MessageTerminate();
  248. if (ClassPending) ClassTerminate();
  249. if (Debugging) printf("--> Ending Pass %d <--\n",Pass);
  250. }
  251. DosClose(SkeletonHandle);
  252. sprintf(CurrentClassFileName,"%s.CTL",UtilityName);
  253. ClassHandle = DosCreate((char far *) &CurrentClassFileName[0], 0);
  254. i = sprintf(out,"$M_NUM_CLS EQU %d\x0d\x0a",ClassCount-2);
  255. DosWrite(ClassHandle,(char far *) &out[0], i);
  256. DosClose(ClassHandle);
  257. SkeletonHandle = 0xfffe; /* 0xfffe == -2 */
  258. return;
  259. }
  260. /* -------------------------------------------------------------------------- */
  261. void UtilRecord(Record)
  262. char *Record;
  263. {
  264. sscanf(Record," %s ",UtilityName);
  265. strupr(UtilityName);
  266. if (Pass == 1)
  267. {
  268. printf(" Utility Name = [%s]\n",UtilityName);
  269. ReadCommon();
  270. }
  271. return;
  272. }
  273. /* -------------------------------------------------------------------------- */
  274. void PublicLine()
  275. {
  276. int i;
  277. char out[128];
  278. if ( !IsReserved(CurrentClass) ) i = sprintf(out," PUBLIC $M_CLS_%d\x0d\x0a",CurrentClassIndex);
  279. else i = sprintf(out," PUBLIC $M_MSGSERV_%c\x0d\x0a",CurrentClass);
  280. DosWrite(ClassHandle,(char far *) &out[0], i);
  281. return;
  282. }
  283. /* -------------------------------------------------------------------------- */
  284. void ClassRecord(Record)
  285. char *Record;
  286. {
  287. union REGS InRegs;
  288. union REGS OutRegs;
  289. struct SREGS SegRegs;
  290. int i;
  291. char out[128];
  292. MessageTerminate();
  293. ClassTerminate();
  294. while ( isspace(*Record) ) Record++;
  295. *Record = (char) toupper(*Record);
  296. CurrentClass = (int) *Record;
  297. if ( !IsReserved(CurrentClass) ) CurrentClassIndex++;
  298. if (CurrentClass == '1') ClassFlag1 = TRUE;
  299. if (CurrentClass == '2') ClassFlag2 = TRUE;
  300. sprintf(CurrentClassFileName,"%s.%s%c",UtilityName,"CL",CurrentClass);
  301. if (Pass == 1)
  302. {
  303. ClassHandle = DosCreate((char far *) &CurrentClassFileName[0], 0);
  304. printf(" Created include file [%s]\n",CurrentClassFileName);
  305. CommentLine();
  306. PublicLine();
  307. i = sprintf(out," IF1\x0d\x0a");
  308. DosWrite(ClassHandle,(char far *) &out[0], i);
  309. i = sprintf(out," %%out ... Including message Class %c\x0d\x0a",CurrentClass);
  310. DosWrite(ClassHandle,(char far *) &out[0], i);
  311. i = sprintf(out," ENDIF\x0d\x0a");
  312. DosWrite(ClassHandle,(char far *) &out[0], i);
  313. CommentLine();
  314. i = sprintf(out,"$M_CLASS_%c_STRUC LABEL BYTE\x0d\x0a",CurrentClass);
  315. DosWrite(ClassHandle,(char far *) &out[0], i);
  316. i = sprintf(out," $M_CLASS_ID <%03XH,EXPECTED_VERSION,Class_%c_MessageCount>\x0d\x0a",
  317. ((!IsReserved(CurrentClass)) ? 255 : (CurrentClass-'0')),CurrentClass);
  318. DosWrite(ClassHandle,(char far *) &out[0], i);
  319. CommentLine();
  320. ClassCount++;
  321. }
  322. if (Pass == 2)
  323. {
  324. ClassHandle = DosOpen((char far *) &CurrentClassFileName[0], 2);
  325. InRegs.x.ax = 0x4202;
  326. InRegs.x.bx = ClassHandle;
  327. InRegs.x.cx = 0;
  328. InRegs.x.dx = 0;
  329. intdosx(&InRegs,&OutRegs,&SegRegs);
  330. if (OutRegs.x.cflag)
  331. error(&InRegs,&OutRegs,&SegRegs);
  332. }
  333. ClassPending = TRUE;
  334. return;
  335. }
  336. /* -------------------------------------------------------------------------- */
  337. void CommentLine()
  338. {
  339. DosWrite(ClassHandle,(char far *) CommentLinePtr, strlen(CommentLinePtr) );
  340. return;
  341. }
  342. /* -------------------------------------------------------------------------- */
  343. void BlankLine()
  344. {
  345. DosWrite(ClassHandle,(char far *) "\x0d\x0a", 2 );
  346. return;
  347. }
  348. /* -------------------------------------------------------------------------- */
  349. void DefRecord(Record)
  350. char *Record;
  351. {
  352. union REGS InRegs;
  353. union REGS OutRegs;
  354. struct SREGS SegRegs;
  355. int i,m;
  356. char *TextPtr;
  357. char *NumberPtr;
  358. char out[128];
  359. char ActualMsg[256];
  360. int MsgNumber;
  361. char MsgStatus;
  362. char MsgLevel[5];
  363. char *LfPtr;
  364. if ( IsReserved(CurrentClass) )
  365. { printf("Error: :DEF not allowed in Class 1 or Class2, line %d\n",LineNumber);
  366. exit(1);
  367. }
  368. MessageTerminate();
  369. TextPtr = Record;
  370. while ( (isspace(*TextPtr)) && (*TextPtr != NUL) ) TextPtr++;
  371. NumberPtr = TextPtr;
  372. while ( (!isspace(*TextPtr)) && (*TextPtr != NUL) ) TextPtr++;
  373. sscanf(NumberPtr," %d ",&CurrentMessageNumber);
  374. if (Pass == 1)
  375. {
  376. BlankLine();
  377. i = sprintf(out,"$M_%c_%05XH_STRUC LABEL BYTE\x0d\x0a",CurrentClass,CurrentMessageNumber);
  378. DosWrite(ClassHandle,(char far *) &out[0], i);
  379. /* i = sprintf(out," $M_ID <%05XH,0,$M_%c_%05XH_MSG-$M_%c_%05XH_STRUC>\x0d\x0a", */
  380. i = sprintf(out," $M_ID <%05XH,$M_%c_%05XH_MSG-$M_%c_%05XH_STRUC>\x0d\x0a", /* Mar 88, SWN */
  381. CurrentMessageNumber,CurrentClass,CurrentMessageNumber,CurrentClass,CurrentMessageNumber);
  382. DosWrite(ClassHandle,(char far *) &out[0], i);
  383. }
  384. if (Pass == 2)
  385. {
  386. BlankLine();
  387. while ( (*TextPtr != NUL) && (isspace(*TextPtr)) ) TextPtr++;
  388. i = sprintf(out,"$M_%c_%05XH_MSG LABEL BYTE\x0d\x0a",CurrentClass,CurrentMessageNumber);
  389. DosWrite(ClassHandle,(char far *) &out[0], i);
  390. /* i = sprintf(out," DW $M_%c_%05XH_END-$M_%c_%05XH_MSG-2\x0d\x0a", */
  391. i = sprintf(out," DB $M_%c_%05XH_END-$M_%c_%05XH_MSG-1\x0d\x0a", /* Mar 88, SWN */
  392. CurrentClass,CurrentMessageNumber,CurrentClass,CurrentMessageNumber);
  393. DosWrite(ClassHandle,(char far *) &out[0], i);
  394. for ( m=1; m <= UtilMessageLines; m++)
  395. {
  396. sscanf(UtilErrorTexts[m], " %d %s %s ",&MsgNumber,&MsgStatus,&MsgLevel[0]);
  397. LfPtr = strchr(UtilErrorTexts[m], ' ');
  398. LfPtr = strchr(LfPtr+1, ' ');
  399. LfPtr = strchr(LfPtr+1, ' ');
  400. strcpy(ActualMsg, LfPtr+1 );
  401. if ( MsgNumber == CurrentMessageNumber)
  402. {
  403. if (Debugging) printf("DefRecord() :: MsgNumber = %d, CurrentMessageNumber = %d\n",
  404. MsgNumber,CurrentMessageNumber);
  405. i = sprintf(out," DB %s\x0d\x0a",ActualMsg);
  406. DosWrite(ClassHandle,(char far *) &out[0], i);
  407. ContinueLine = m + 1;
  408. }
  409. }
  410. MessagePending = TRUE;
  411. }
  412. return;
  413. }
  414. /* -------------------------------------------------------------------------- */
  415. void UseRecord(Record)
  416. char *Record;
  417. {
  418. union REGS InRegs;
  419. union REGS OutRegs;
  420. struct SREGS SegRegs;
  421. int i,j;
  422. char *TextPtr;
  423. char *NumberPtr;
  424. int TempNumber;
  425. char out[128];
  426. MessageTerminate();
  427. NumberPtr = Record;
  428. while ( (isspace(*NumberPtr)) && (*NumberPtr != NUL) ) NumberPtr++;
  429. if ( (isdigit(*NumberPtr)) || ( (*NumberPtr == (char) '-') && (isdigit(*(NumberPtr+1))) ) )
  430. { if ( IsReserved(CurrentClass) )
  431. { printf("Error: :USE in CLASS 1, cannot specify a msg-number on line %d\n",LineNumber);
  432. exit(1);
  433. }
  434. sscanf(NumberPtr," %d ",&CurrentMessageNumber);
  435. TextPtr = NumberPtr;
  436. while ( (!isspace(*TextPtr)) && (*TextPtr != NUL) ) TextPtr++;
  437. while ( ( isspace(*TextPtr)) && (*TextPtr != NUL) ) TextPtr++;
  438. strcpy(USEstring, "empty\0");
  439. if (strnicmp(TextPtr,"PARSE",5) == 0) { strcpy(USEstring, "PARSE\0"); i = 5; j = 1; }
  440. if (strnicmp(TextPtr,"COMMON",6) == 0) { i = 6; j = 2; }
  441. if (strnicmp(TextPtr,"EXTEND",6) == 0) { strcpy(USEstring, "EXTEND\0"); i = 6; j = 3; }
  442. NumberPtr = TextPtr + i;
  443. sscanf(NumberPtr," %d ",&TempNumber);
  444. switch(j)
  445. {
  446. case 1: if (TempNumber <= MAXPARSERERROR)
  447. TextPtr = ParserErrorTexts[TempNumber];
  448. else if (TempNumber == 999)
  449. { TextPtr = ParserErrorText999;
  450. }
  451. else TextPtr = "";
  452. break;
  453. case 2: if (TempNumber <= MAXCOMMONERROR)
  454. TextPtr = CommonErrorTexts[TempNumber];
  455. else TextPtr = "";
  456. break;
  457. case 3: if (TempNumber <= MAXEXTENDEDERROR)
  458. TextPtr = ExtendedErrorTexts[TempNumber];
  459. else if (TempNumber == 999)
  460. { TextPtr = ExtendedErrorText999;
  461. }
  462. else TextPtr = "";
  463. break;
  464. default:TextPtr = "";
  465. break;
  466. }
  467. if (*TextPtr == NUL)
  468. { printf("Error: :USE of PARSE, COMMON or EXTENDED with invalid msg-number, line %d\n",LineNumber);
  469. if (Debugging) printf("then ->CurrentMessageNumber = %d, TempNumber = %d, j = %d\n",
  470. CurrentMessageNumber,TempNumber,j);
  471. exit(1);
  472. }
  473. }
  474. else {
  475. strcpy(USEstring, "empty\0");
  476. TextPtr = NumberPtr;
  477. if (strnicmp(TextPtr,"PARSE",5) == 0) { strcpy(USEstring, "PARSE\0"); i = 5; j = 1; }
  478. if (strnicmp(TextPtr,"COMMON",6) == 0) { i = 6; j = 2; }
  479. if (strnicmp(TextPtr,"EXTEND",6) == 0) { strcpy(USEstring, "PARSE\0"); i = 6; j = 3; }
  480. NumberPtr += i;
  481. sscanf(NumberPtr," %d ",&CurrentMessageNumber);
  482. TempNumber = CurrentMessageNumber;
  483. if ( (CurrentClass == '1') && (j != 3) )
  484. { printf("Error: :USE in CLASS 1 must be EXTENDED ERROR on line %d\n",LineNumber);
  485. exit(1);
  486. }
  487. if ( (CurrentClass == '2') && (j != 1) )
  488. { printf("Error: :USE in CLASS 1 must be PARSE ERROR on line %d\n",LineNumber);
  489. exit(1);
  490. }
  491. switch(j)
  492. {
  493. case 1: if (TempNumber <= MAXPARSERERROR)
  494. TextPtr = ParserErrorTexts[TempNumber];
  495. else if (TempNumber == 999)
  496. TextPtr = ParserErrorText999;
  497. else TextPtr = "";
  498. break;
  499. case 2: if (TempNumber <= MAXCOMMONERROR)
  500. TextPtr = CommonErrorTexts[TempNumber];
  501. else TextPtr = "";
  502. break;
  503. case 3: if (TempNumber <= MAXEXTENDEDERROR)
  504. TextPtr = ExtendedErrorTexts[TempNumber];
  505. else if (TempNumber == 999)
  506. TextPtr = ExtendedErrorText999;
  507. else TextPtr = "";
  508. break;
  509. default:TextPtr = "";
  510. break;
  511. }
  512. if (*TextPtr == NUL)
  513. { printf("Error: :USE of PARSE, COMMON or EXTENDED with invalid msg-number, line %d\n",LineNumber);
  514. if (Debugging) printf("else ->CurrentMessageNumber = %d, TempNumber = %d, j = %d\n",
  515. CurrentMessageNumber,TempNumber,j);
  516. exit(1);
  517. }
  518. }
  519. if (Pass == 1)
  520. {
  521. BlankLine();
  522. i = sprintf(out,"$M_%c_%05XH_STRUC LABEL BYTE\x0d\x0a",CurrentClass,CurrentMessageNumber);
  523. DosWrite(ClassHandle,(char far *) &out[0], i);
  524. /* i = sprintf(out," $M_ID <%05XH,0,$M_%c_%05XH_MSG-$M_%c_%05XH_STRUC>\x0d\x0a", */
  525. i = sprintf(out," $M_ID <%05XH,$M_%c_%05XH_MSG-$M_%c_%05XH_STRUC>\x0d\x0a", /* Mar 88, SWN */
  526. CurrentMessageNumber,CurrentClass,CurrentMessageNumber,CurrentClass,CurrentMessageNumber);
  527. DosWrite(ClassHandle,(char far *) &out[0], i);
  528. }
  529. if (Pass == 2)
  530. {
  531. strcpy( Is_Utility_Command, NAME_COMMAND ) ;
  532. if ( !ParseOrExtend )
  533. {
  534. add_crlf = 0 ;
  535. }
  536. else
  537. {
  538. if ( !strnicmp( Is_Utility_Command, UtilityName, 5) )
  539. {
  540. if ( ( CurrentClass != 67 ) && ( CurrentClass != 68 ) &&
  541. ( CurrentClass != 69 ) && ( CurrentClass != '1') &&
  542. ( CurrentClass != '2') )
  543. {
  544. add_crlf = 1 ;
  545. }
  546. else
  547. {
  548. add_crlf = 0 ;
  549. }
  550. }
  551. else
  552. {
  553. if ( ( CurrentClass != '1') && ( CurrentClass != '2') )
  554. {
  555. add_crlf = 1 ;
  556. }
  557. else
  558. {
  559. add_crlf = 0 ;
  560. }
  561. }
  562. }
  563. BlankLine();
  564. i = sprintf(out,"$M_%c_%05XH_MSG LABEL BYTE\x0d\x0a",CurrentClass,CurrentMessageNumber);
  565. DosWrite(ClassHandle,(char far *) &out[0], i);
  566. /* i = sprintf(out," DW $M_%c_%05XH_END-$M_%c_%05XH_MSG-2\x0d\x0a", */
  567. i = sprintf(out," DB $M_%c_%05XH_END-$M_%c_%05XH_MSG-1\x0d\x0a", /* Mar 88, SWN */
  568. CurrentClass,CurrentMessageNumber,CurrentClass,CurrentMessageNumber);
  569. DosWrite(ClassHandle,(char far *) &out[0], i);
  570. if ( add_crlf )
  571. {
  572. i = sprintf(out," DB %s,CR,LF\x0d\x0a",TextPtr);
  573. }
  574. else
  575. {
  576. i = sprintf(out," DB %s\x0d\x0a",TextPtr);
  577. }
  578. DosWrite(ClassHandle,(char far *) &out[0], i);
  579. MessagePending = TRUE;
  580. }
  581. return;
  582. }
  583. /* -------------------------------------------------------------------------- */
  584. void DefContinue(Record)
  585. char *Record;
  586. {
  587. printf("Error: :DEF continue should not occur",LineNumber);
  588. exit(1);
  589. return;
  590. }
  591. /* -------------------------------------------------------------------------- */
  592. void UseContinue(Record)
  593. char *Record;
  594. {
  595. printf("Error: :USE continue should not occur",LineNumber);
  596. exit(1);
  597. }
  598. /* -------------------------------------------------------------------------- */
  599. void EndRecord(Record)
  600. char *Record;
  601. {
  602. if (!ClassFlag1) ClassRecord(" 1 ");
  603. if (!ClassFlag2) ClassRecord(" 2 ");
  604. MessageTerminate();
  605. ClassTerminate();
  606. Done = TRUE;
  607. return;
  608. }
  609. /* -------------------------------------------------------------------------- */
  610. void MessageTerminate()
  611. {
  612. char out[128];
  613. if (MessagePending)
  614. {
  615. sprintf(out,"$M_%c_%05XH_END LABEL BYTE\x0d\x0a",CurrentClass,CurrentMessageNumber);
  616. DosWrite(ClassHandle,(char far *) &out[0],strlen(out) );
  617. /* sprintf(out," DB \"$\"\x0d\x0a"); */
  618. sprintf(out," \0",CurrentClass,CurrentMessageNumber); /* Mar 88, SWN */
  619. DosWrite(ClassHandle,(char far *) &out[0],strlen(out) );
  620. ClassCounts[CurrentClass]++;
  621. }
  622. MessagePending = FALSE;
  623. return;
  624. }
  625. /* -------------------------------------------------------------------------- */
  626. void ClassTerminate()
  627. {
  628. int i;
  629. char out[128];
  630. if ( (ClassPending) && (Pass == 1) )
  631. { CommentLine();
  632. if (CurrentClass == '1')
  633. { i = sprintf(out,"$M_1_FF_STRUC LABEL BYTE\x0d\x0a");
  634. DosWrite(ClassHandle,(char far *) &out[0], i);
  635. /* i = sprintf(out," $M_ID <0FFFFH,0,$M_1_FF_MSG-$M_1_FF_STRUC>\x0d\x0a"); */
  636. i = sprintf(out," $M_ID <0FFFFH,$M_1_FF_MSG-$M_1_FF_STRUC>\x0d\x0a");
  637. DosWrite(ClassHandle,(char far *) &out[0], i);
  638. ClassCounts[CurrentClass] ++;
  639. CommentLine();
  640. }
  641. if (CurrentClass == '2')
  642. { i = sprintf(out,"$M_2_FF_STRUC LABEL BYTE\x0d\x0a");
  643. DosWrite(ClassHandle,(char far *) &out[0], i);
  644. /* i = sprintf(out," $M_ID <0FFFFH,0,$M_2_FF_MSG-$M_2_FF_STRUC>\x0d\x0a"); */
  645. i = sprintf(out," $M_ID <0FFFFH,$M_2_FF_MSG-$M_2_FF_STRUC>\x0d\x0a");
  646. DosWrite(ClassHandle,(char far *) &out[0], i);
  647. ClassCounts[CurrentClass] ++;
  648. CommentLine();
  649. }
  650. DosClose(ClassHandle);
  651. ClassHandle = 0xfffe; /* 0xfffe == -2 */
  652. }
  653. if ( (ClassPending) && (Pass == 2) )
  654. { CommentLine();
  655. if (CurrentClass == '1')
  656. { i = sprintf(out,"$M_1_FF_MSG LABEL BYTE\x0d\x0a");
  657. DosWrite(ClassHandle,(char far *) &out[0], i);
  658. /* i = sprintf(out," DW $M_1_FF_END-$M_1_FF_MSG-2\x0d\x0a"); */
  659. i = sprintf(out," DB $M_1_FF_END-$M_1_FF_MSG-1\x0d\x0a"); /* Mar 88, SWN */
  660. DosWrite(ClassHandle,(char far *) &out[0], i);
  661. i = sprintf(out, EXTENDED_STR); /* Mar 88, SWN */
  662. DosWrite(ClassHandle,(char far *) &out[0], i);
  663. i = sprintf(out,"$M_1_FF_END LABEL BYTE\x0d\x0a");
  664. DosWrite(ClassHandle,(char far *) &out[0], i);
  665. /* i = sprintf(out," DB \"$\"\x0d\x0a"); */
  666. i = sprintf(out," \0"); /* Mar 88, SWN */
  667. DosWrite(ClassHandle,(char far *) &out[0], i);
  668. CommentLine();
  669. }
  670. if (CurrentClass == '2')
  671. { i = sprintf(out,"$M_2_FF_MSG LABEL BYTE\x0d\x0a");
  672. DosWrite(ClassHandle,(char far *) &out[0], i);
  673. /* i = sprintf(out," DW $M_2_FF_END-$M_2_FF_MSG-2\x0d\x0a"); */
  674. i = sprintf(out," DB $M_2_FF_END-$M_2_FF_MSG-1\x0d\x0a"); /* Mar 88, SWN */
  675. DosWrite(ClassHandle,(char far *) &out[0], i);
  676. i = sprintf(out,PARSE_STR); /* Mar 88, SWN */
  677. DosWrite(ClassHandle,(char far *) &out[0], i);
  678. i = sprintf(out,"$M_2_FF_END LABEL BYTE\x0d\x0a");
  679. DosWrite(ClassHandle,(char far *) &out[0], i);
  680. /* i = sprintf(out," DB \"$\"\x0d\x0a"); */
  681. i = sprintf(out," \0"); /* Mar 88, SWN */
  682. DosWrite(ClassHandle,(char far *) &out[0], i);
  683. CommentLine();
  684. }
  685. i = sprintf(out,"Class_%c_MessageCount EQU %d\x0d\x0a",CurrentClass,ClassCounts[CurrentClass]);
  686. DosWrite(ClassHandle,(char far *) &out[0], i );
  687. CommentLine();
  688. i = sprintf(out," IF FARmsg\x0d\x0a");
  689. DosWrite(ClassHandle,(char far *) &out[0], i);
  690. if ( !IsReserved(CurrentClass) )
  691. { i = sprintf(out,"$M_CLS_%d PROC FAR\x0d\x0a",CurrentClassIndex);
  692. DosWrite(ClassHandle,(char far *) &out[0], i);
  693. }
  694. else { i = sprintf(out,"$M_MSGSERV_%c PROC FAR\x0d\x0a",CurrentClass);
  695. DosWrite(ClassHandle,(char far *) &out[0], i);
  696. }
  697. i = sprintf(out," ELSE\x0d\x0a");
  698. DosWrite(ClassHandle,(char far *) &out[0], i);
  699. if ( !IsReserved(CurrentClass) )
  700. { i = sprintf(out,"$M_CLS_%d PROC NEAR\x0d\x0a",CurrentClassIndex);
  701. DosWrite(ClassHandle,(char far *) &out[0], i);
  702. }
  703. else { i = sprintf(out,"$M_MSGSERV_%c PROC NEAR\x0d\x0a",CurrentClass);
  704. DosWrite(ClassHandle,(char far *) &out[0], i);
  705. }
  706. i = sprintf(out," ENDIF\x0d\x0a");
  707. DosWrite(ClassHandle,(char far *) &out[0], i);
  708. BlankLine();
  709. i = sprintf(out," PUSH CS\x0d\x0a");
  710. DosWrite(ClassHandle,(char far *) &out[0], i);
  711. i = sprintf(out," POP ES\x0d\x0a");
  712. DosWrite(ClassHandle,(char far *) &out[0], i);
  713. i = sprintf(out," LEA DI,$M_CLASS_%c_STRUC\x0d\x0a",CurrentClass);
  714. DosWrite(ClassHandle,(char far *) &out[0], i);
  715. i = sprintf(out," ADD CX,$-$M_CLASS_%c_STRUC\x0d\x0a",CurrentClass);
  716. DosWrite(ClassHandle,(char far *) &out[0], i);
  717. i = sprintf(out," RET\x0d\x0a");
  718. DosWrite(ClassHandle,(char far *) &out[0], i);
  719. BlankLine();
  720. if ( !IsReserved(CurrentClass) )
  721. { i = sprintf(out,"$M_CLS_%d ENDP\x0d\x0a",CurrentClassIndex);
  722. DosWrite(ClassHandle,(char far *) &out[0], i);
  723. }
  724. else { i = sprintf(out,"$M_MSGSERV_%c Endp\x0d\x0a",CurrentClass);
  725. DosWrite(ClassHandle,(char far *) &out[0], i);
  726. }
  727. CommentLine();
  728. DosClose(ClassHandle);
  729. ClassHandle = 0xfffe; /* 0xfffe == -2 */
  730. printf(" Completed [%s]\n",CurrentClassFileName);
  731. }
  732. ClassPending = FALSE;
  733. return;
  734. }
  735. /* -------------------------------------------------------------------------- */
  736. unsigned LowOf(LongValue)
  737. long LongValue;
  738. {
  739. return ( (unsigned) ( LongValue & 0x0000FFFFl ) );
  740. }
  741. /* -------------------------------------------------------------------------- */
  742. unsigned HighOf(LongValue)
  743. long LongValue;
  744. {
  745. return ( (unsigned) ( (LongValue & 0xFFFF0000l) >> 16 ) );
  746. }
  747. /* -------------------------------------------------------------------------- */
  748. long LongOf(HighValue,LowValue)
  749. unsigned HighValue;
  750. unsigned LowValue;
  751. {
  752. long hv;
  753. long lv;
  754. hv = (long) HighValue;
  755. lv = (long) LowValue;
  756. return ( ( hv << 16 ) + lv );
  757. }
  758. /* -------------------------------------------------------------------------- */
  759. unsigned DosOpen(FileNamePtr,OpenType)
  760. char far *FileNamePtr;
  761. unsigned OpenType;
  762. {
  763. union REGS InRegs;
  764. union REGS OutRegs;
  765. struct SREGS SegRegs;
  766. InRegs.x.ax = 0x3d00 + OpenType;
  767. InRegs.x.dx = FP_OFF(FileNamePtr);
  768. SegRegs.ds = FP_SEG(FileNamePtr);
  769. intdosx(&InRegs, &OutRegs, &SegRegs);
  770. if (OutRegs.x.cflag)
  771. error(&InRegs,&OutRegs,&SegRegs);
  772. EofFlags[OutRegs.x.ax] = FALSE;
  773. return(OutRegs.x.ax);
  774. }
  775. /* -------------------------------------------------------------------------- */
  776. long DosLSeek(Handle, ToPosition, Relative)
  777. unsigned Handle;
  778. long ToPosition;
  779. int Relative;
  780. {
  781. union REGS InRegs;
  782. union REGS OutRegs;
  783. struct SREGS SegRegs;
  784. InRegs.x.ax = 0x4200 + (Relative & 0x000f);
  785. InRegs.x.bx = Handle;
  786. InRegs.x.cx = HighOf(ToPosition);
  787. InRegs.x.dx = LowOf(ToPosition);
  788. intdosx(&InRegs, &OutRegs, &SegRegs);
  789. if (OutRegs.x.cflag)
  790. error(&InRegs,&OutRegs,&SegRegs);
  791. return( LongOf(OutRegs.x.dx,OutRegs.x.ax) );
  792. }
  793. /* -------------------------------------------------------------------------- */
  794. unsigned DosCreate(FileNamePtr,Attributes)
  795. char far *FileNamePtr;
  796. unsigned Attributes;
  797. {
  798. union REGS InRegs;
  799. union REGS OutRegs;
  800. struct SREGS SegRegs;
  801. InRegs.x.ax = 0x3c00;
  802. InRegs.x.cx = Attributes;
  803. InRegs.x.dx = FP_OFF(FileNamePtr);
  804. SegRegs.ds = FP_SEG(FileNamePtr);
  805. intdosx(&InRegs, &OutRegs, &SegRegs);
  806. if (OutRegs.x.cflag)
  807. error(&InRegs,&OutRegs,&SegRegs);
  808. EofFlags[OutRegs.x.ax] = FALSE;
  809. return(OutRegs.x.ax);
  810. }
  811. /* -------------------------------------------------------------------------- */
  812. void DosClose(Handle)
  813. unsigned Handle;
  814. {
  815. union REGS InRegs;
  816. union REGS OutRegs;
  817. struct SREGS SegRegs;
  818. InRegs.x.ax = 0x3e00;
  819. InRegs.x.bx = Handle;
  820. intdosx(&InRegs,&OutRegs,&SegRegs);
  821. if (OutRegs.x.cflag) error(&InRegs,&OutRegs,&SegRegs);
  822. return;
  823. }
  824. /* -------------------------------------------------------------------------- */
  825. unsigned DosRead(Handle,BufferPtr,ReadLength)
  826. unsigned Handle;
  827. char far *BufferPtr;
  828. int ReadLength;
  829. {
  830. union REGS InRegs;
  831. union REGS OutRegs;
  832. struct SREGS SegRegs;
  833. InRegs.x.ax = 0x3f00;
  834. InRegs.x.bx = Handle;
  835. InRegs.x.cx = ReadLength;
  836. InRegs.x.dx = FP_OFF(BufferPtr);
  837. SegRegs.ds = FP_SEG(BufferPtr);
  838. intdosx(&InRegs,&OutRegs,&SegRegs);
  839. if (OutRegs.x.cflag) error(&InRegs,&OutRegs,&SegRegs);
  840. return(OutRegs.x.ax);
  841. }
  842. /* -------------------------------------------------------------------------- */
  843. unsigned DosWrite(Handle,BufferPtr,WriteLength)
  844. unsigned Handle;
  845. char far *BufferPtr;
  846. int WriteLength;
  847. {
  848. union REGS InRegs;
  849. union REGS OutRegs;
  850. struct SREGS SegRegs;
  851. union REGS InRegs2;
  852. union REGS OutRegs2;
  853. struct SREGS SegRegs2;
  854. InRegs.x.ax = 0x4000;
  855. InRegs.x.bx = Handle;
  856. InRegs.x.cx = WriteLength;
  857. InRegs.x.dx = FP_OFF(BufferPtr);
  858. SegRegs.ds = FP_SEG(BufferPtr);
  859. intdosx(&InRegs,&OutRegs,&SegRegs);
  860. if (OutRegs.x.cflag)
  861. { InRegs2.x.ax = 0x4000;
  862. InRegs2.x.bx = 1;
  863. InRegs2.x.cx = WriteLength;
  864. InRegs2.x.dx = FP_OFF(BufferPtr);
  865. SegRegs2.ds = FP_SEG(BufferPtr);
  866. /* intdosx(&InRegs2,&OutRegs2,&SegRegs2); */
  867. error(&InRegs,&OutRegs,&SegRegs);
  868. }
  869. return(OutRegs.x.ax);
  870. }
  871. /* -------------------------------------------------------------------------- */
  872. void LineInput(Handle,BufferPtr)
  873. unsigned Handle;
  874. char far *BufferPtr;
  875. {
  876. char c;
  877. char far *BufferPosition;
  878. BufferPosition = BufferPtr;
  879. *BufferPosition = NUL;
  880. if (DosRead( Handle, (char far *) &c, 1) != 1)
  881. EofFlags[Handle] = TRUE;
  882. while ( (c != (char) '\x0a') && !EofFlags[Handle])
  883. {
  884. *BufferPosition = c;
  885. if (c == (char) '\x0d') *BufferPosition = NUL;
  886. BufferPosition++;
  887. if (DosRead( Handle, (char far *) &c, 1) != 1)
  888. EofFlags[Handle] = TRUE;
  889. }
  890. *BufferPosition = NUL;
  891. return;
  892. }
  893. /*----------------------------------------------------------------------------*/
  894. void error(InRegs,OutRegs,SegRegs)
  895. union REGS *InRegs;
  896. union REGS *OutRegs;
  897. struct SREGS *SegRegs;
  898. {
  899. char far *s;
  900. char *t;
  901. char AsciizString[256];
  902. struct DOSERROR ErrorInformation;
  903. dosexterr(&ErrorInformation);
  904. printf("\n Function %02X, Error %d, Class %d, Action %d, Locus %d \n",
  905. InRegs->h.ah,
  906. ErrorInformation.exterror,ErrorInformation.class,
  907. ErrorInformation.action,ErrorInformation.locus);
  908. printf(" InRegs:\n");
  909. printf(" AX:%04X BX:%04X CX:%04X DX:%04X SI:%04X DI:%04X DS:%04X ES:%04X\n",
  910. InRegs->x.ax,InRegs->x.bx,InRegs->x.cx,InRegs->x.dx,InRegs->x.si,InRegs->x.di,
  911. SegRegs->ds,SegRegs->es);
  912. switch(InRegs->h.ah)
  913. {
  914. case 0x3d:
  915. case 0x3c:
  916. case 0x4e:
  917. FP_SEG(s) = SegRegs->ds;
  918. FP_OFF(s) = InRegs->x.dx;
  919. t = &AsciizString[0];
  920. while (*s != (char) '\0') *t++ = *s++;
  921. *t++ = (char) '\0';
  922. printf(" DS:DX -> [%s]\n",AsciizString);
  923. break;
  924. }
  925. printf(" OutRegs:\n");
  926. printf(" AX:%04X BX:%04X CX:%04X DX:%04X SI:%04X DI:%04X DS:%04X ES:%04X\n",
  927. OutRegs->x.ax,OutRegs->x.bx,OutRegs->x.cx,OutRegs->x.dx,OutRegs->x.si,OutRegs->x.di,
  928. SegRegs->ds,SegRegs->es);
  929. exit(1);
  930. }
  931. /* -------------------------------------------------------------------------- */
  932. char * MyMalloc(Length)
  933. int Length;
  934. {
  935. char *Ptr;
  936. Ptr = malloc(Length);
  937. if (Ptr == (char *) 0)
  938. { printf("ERROR: insufficient memory available, line %d\n",LineNumber);
  939. exit(1);
  940. }
  941. return (Ptr);
  942. }
  943. /* -------------------------------------------------------------------------- */
  944. unsigned IdxHandle;
  945. unsigned MsgHandle;
  946. void ReadCommon()
  947. {
  948. char IdxComponentName[16];
  949. long MsgOffset;
  950. int MsgCount;
  951. char Line[MAXLENGTH];
  952. char NextLine[MAXLENGTH];
  953. char CurrentIdxRecord[256];
  954. char CurrentMsgRecord[256];
  955. int CurrentIdxLevel;
  956. int CurrentMsgLevel;
  957. char RcdIDXType[32];
  958. struct Idx_Structure *IdxPtr;
  959. int i;
  960. int NumberOfMsg;
  961. int k;
  962. long n;
  963. int ComponentNameLen = 20;
  964. char *s, *p;
  965. unsigned len;
  966. char ContinueMessageInfo[32];
  967. int ContinueMessageInfoLen;
  968. /* initialize the things that need to be... */
  969. printf(" Loading messages from %s\n",CountryMsg);
  970. k = 32000;
  971. s = malloc(k);
  972. while ( (s == (char *) 0) && (k > 1) )
  973. {
  974. k -= 1000;
  975. s = malloc(k);
  976. }
  977. if (s != (char *) 0) free(s);
  978. printf(" (Available message memory space: %d bytes)\n",k);
  979. IdxHandle = DosOpen( (char far *) CountryIdx, READONLY);
  980. MsgHandle = DosOpen( (char far *) CountryMsg, READONLY);
  981. LineInput(IdxHandle, (char far *) &CurrentIdxRecord[0] );
  982. LineInput(MsgHandle, (char far *) &CurrentMsgRecord[0] );
  983. sscanf(CurrentIdxRecord," %d ",&CurrentIdxLevel);
  984. sscanf(CurrentIdxRecord," %d ",&CurrentMsgLevel);
  985. if ( CurrentIdxLevel != CurrentMsgLevel )
  986. {
  987. printf("\nERROR: %s and %s levels do not match\n",CountryIdx,CountryMsg);
  988. exit(1);
  989. }
  990. /* find out the offset into the big message file for COMMON error */
  991. /* EXTENDED */
  992. /* PARSER */
  993. /* Utility */
  994. while ( !EofFlags[IdxHandle] )
  995. {
  996. LineInput(IdxHandle, (char far *) &CurrentIdxRecord[0] );
  997. sscanf(CurrentIdxRecord, " %s %lx %d ",
  998. IdxComponentName, &MsgOffset, &MsgCount);
  999. if (Debugging) printf("---> [%s] %04lX %04d<---\n",IdxComponentName, MsgOffset, MsgCount);
  1000. strupr(IdxComponentName);
  1001. if (strcmp(IdxComponentName,"COMMON") == 0)
  1002. {
  1003. if ( !ReadCommonFlag )
  1004. {
  1005. ReadCommonFlag = TRUE;
  1006. DosLSeek( MsgHandle, MsgOffset, 0);
  1007. LineInput(MsgHandle, (char far *) &CurrentMsgRecord[0] );
  1008. if (strcmp(CurrentIdxRecord, CurrentMsgRecord) != 0)
  1009. {
  1010. printf("\nERROR: %s and %s COMMON headers do not match\n",CountryIdx,CountryMsg);
  1011. exit(1);
  1012. }
  1013. CommonMessageLines = 1;
  1014. ExtendedMessageLines = 1;
  1015. LineInput(MsgHandle, (char far *) &Line[0] );
  1016. while ( ( !isalpha(Line[0]) ) && (!EofFlags[MsgHandle]) )
  1017. {
  1018. p = strchr(Line, ' ') + 1; /* skip msg number */
  1019. p = strchr(p, ' ') + 1; /* skip status flag */
  1020. p = strchr(p, ' ') + 1; /* skip revision level */
  1021. len = strlen(p);
  1022. CommonErrorTexts[CommonMessageLines] = MyMalloc(len+1);
  1023. strcpy(CommonErrorTexts[CommonMessageLines], p);
  1024. if (Debugging) printf("CommonErrorTexts[%d] = (%s)\n",
  1025. CommonMessageLines,CommonErrorTexts[CommonMessageLines]);
  1026. CommonMessageLines++;
  1027. if (CommonMessageLines >= MAXCOMMONERROR)
  1028. {
  1029. printf("\nERROR: COMMON message number too large, %d\n",CommonMessageLines);
  1030. exit(1);
  1031. }
  1032. LineInput(MsgHandle, (char far *) &Line[0] );
  1033. }
  1034. }
  1035. }
  1036. else if (strcmp(IdxComponentName,"EXTEND") == 0)
  1037. {
  1038. if ( !ReadExtendFlag )
  1039. {
  1040. ReadExtendFlag = TRUE;
  1041. DosLSeek( MsgHandle, MsgOffset, 0);
  1042. LineInput(MsgHandle, (char far *) &CurrentMsgRecord[0] );
  1043. if (strcmp(CurrentIdxRecord, CurrentMsgRecord) != 0)
  1044. {
  1045. printf("\nERROR: %s and %s EXTEND headers do not match\n",CountryIdx,CountryMsg);
  1046. exit(1);
  1047. }
  1048. ExtendedMessageLines = 1;
  1049. LineInput(MsgHandle, (char far *) &Line[0] );
  1050. while ( ( !isalpha(Line[0]) ) && (!EofFlags[MsgHandle]) )
  1051. {
  1052. p = strchr(Line, ' ') + 1; /* skip msg number */
  1053. p = strchr(p, ' ') + 1; /* skip status flag */
  1054. p = strchr(p, ' ') + 1; /* skip revision level */
  1055. len = strlen(p);
  1056. ExtendedErrorTexts[ExtendedMessageLines] = MyMalloc(len+1);
  1057. strcpy(ExtendedErrorTexts[ExtendedMessageLines], p);
  1058. if (Debugging) printf("ExtendedErrorTexts[%d] = (%s)\n",
  1059. ExtendedMessageLines,ExtendedErrorTexts[ExtendedMessageLines]);
  1060. ExtendedMessageLines++;
  1061. if (ExtendedMessageLines >= MAXEXTENDEDERROR)
  1062. {
  1063. printf("\nERROR: EXTENDED message number too large, %d\n",ExtendedMessageLines);
  1064. exit(1);
  1065. }
  1066. LineInput(MsgHandle, (char far *) &Line[0] );
  1067. }
  1068. }
  1069. }
  1070. else if (strcmp(IdxComponentName,"PARSE") == 0)
  1071. {
  1072. if ( !ReadParserFlag )
  1073. {
  1074. ReadParserFlag = TRUE;
  1075. DosLSeek( MsgHandle, MsgOffset, 0);
  1076. LineInput(MsgHandle, (char far *) &CurrentMsgRecord[0] );
  1077. if (strcmp(CurrentIdxRecord, CurrentMsgRecord) != 0)
  1078. {
  1079. printf("\nERROR: %s and %s PARSE headers do not match\n",CountryIdx,CountryMsg);
  1080. exit(1);
  1081. }
  1082. ParserMessageLines = 1;
  1083. LineInput(MsgHandle, (char far *) &Line[0] );
  1084. while ( ( !isalpha(Line[0]) ) && (!EofFlags[MsgHandle]) )
  1085. {
  1086. p = strchr(Line, ' ') + 1;
  1087. p = strchr(p, ' ') + 1;
  1088. p = strchr(p, ' ') + 1;
  1089. len = strlen(p);
  1090. ParserErrorTexts[ParserMessageLines] = MyMalloc(len+1);
  1091. strcpy(ParserErrorTexts[ParserMessageLines], p);
  1092. if (Debugging) printf("ParserErrorTexts[%d] = (%s)\n",
  1093. ParserMessageLines,ParserErrorTexts[ParserMessageLines]);
  1094. ParserMessageLines++;
  1095. if (ParserMessageLines >= MAXPARSERERROR)
  1096. {
  1097. printf("\nERROR: PARSER message number too large, %d\n",ParserMessageLines);
  1098. exit(1);
  1099. }
  1100. LineInput(MsgHandle, (char far *) &Line[0] );
  1101. }
  1102. }
  1103. }
  1104. else if (strcmp(IdxComponentName,UtilityName) == 0)
  1105. {
  1106. if ( !ReadUtilFlag )
  1107. {
  1108. ReadUtilFlag = TRUE;
  1109. DosLSeek( MsgHandle, MsgOffset, 0);
  1110. LineInput(MsgHandle, (char far *) &CurrentMsgRecord[0] );
  1111. if (strcmp(CurrentIdxRecord, CurrentMsgRecord) != 0)
  1112. {
  1113. printf("\nERROR: %s and %s %s headers do not match\n",
  1114. CountryIdx,CountryMsg,UtilityName);
  1115. exit(1);
  1116. }
  1117. UtilMessageLines = 1;
  1118. LineInput(MsgHandle, (char far *) &Line[0] );
  1119. while ( ( !isalpha(Line[0]) ) && (!EofFlags[MsgHandle]) )
  1120. {
  1121. if ( !isdigit(Line[0]) )
  1122. {
  1123. MsgCount++;
  1124. /* need to fake MsgNumber, Status, Level fields*/
  1125. len = strlen(Line) + strlen(ContinueMessageInfo);
  1126. UtilErrorTexts[UtilMessageLines] = MyMalloc(len+1);
  1127. strcpy(UtilErrorTexts[UtilMessageLines], ContinueMessageInfo);
  1128. strcat(UtilErrorTexts[UtilMessageLines], Line);
  1129. if (Debugging) printf("UtilErrorTexts[%d] = (%s)\n",
  1130. UtilMessageLines,UtilErrorTexts[UtilMessageLines]);
  1131. }
  1132. else
  1133. {
  1134. len = strlen(Line);
  1135. UtilErrorTexts[UtilMessageLines] = MyMalloc(len+1);
  1136. strcpy(UtilErrorTexts[UtilMessageLines], Line);
  1137. if (Debugging) printf("UtilErrorTexts[%d] = (%s)\n",
  1138. UtilMessageLines,UtilErrorTexts[UtilMessageLines]);
  1139. strncpy(ContinueMessageInfo,Line,12);
  1140. ContinueMessageInfo[12] = (char) '\0';
  1141. if (Debugging) printf(" ContinueMessageInfo = (%s)\n",
  1142. ContinueMessageInfo);
  1143. }
  1144. UtilMessageLines++;
  1145. if (UtilMessageLines >= MAXUTILERROR)
  1146. {
  1147. printf("\nERROR: Utility message number too large, %d\n",UtilMessageLines);
  1148. exit(1);
  1149. }
  1150. LineInput(MsgHandle, (char far *) &Line[0] );
  1151. }
  1152. }
  1153. }
  1154. }
  1155. DosClose(IdxHandle);
  1156. DosClose(MsgHandle);
  1157. UtilMessageLines--;
  1158. CommonMessageLines--;
  1159. ParserMessageLines--;
  1160. ExtendedMessageLines--;
  1161. k = 32000;
  1162. s = malloc(k);
  1163. while ( (s == (char *) 0) && (k > 1) )
  1164. {
  1165. k -= 1000;
  1166. s = malloc(k);
  1167. }
  1168. if (s != (char *) 0) free(s);
  1169. printf(" (Still available message memory space: %d bytes)\n",k);
  1170. if (!ReadCommonFlag)
  1171. { printf("\nERROR: COMMON messages not found in %s\n",CountryIdx);
  1172. exit(1);
  1173. }
  1174. if (!ReadExtendFlag)
  1175. { printf("\nERROR: EXTEND messages not found in %s\n",CountryIdx);
  1176. exit(1);
  1177. }
  1178. if (!ReadParserFlag)
  1179. { printf("\nERROR: PARSE messages not found in %s\n",CountryIdx);
  1180. exit(1);
  1181. }
  1182. if (!ReadUtilFlag)
  1183. { printf("\nERROR: %s messages not found in %s\n",UtilityName,CountryIdx);
  1184. exit(1);
  1185. }
  1186. return;
  1187. }