.fo off
/*********************************************************************/
/*  SUBROUTINE NAME: WriteMsgSeg()                                   */
/*                                                                   */
/*  DESCRIPTION NAME: Write Message Segment                          */
/*                                                                   */
/*  FUNCTION: Write message segment into the end of the selected     */
/*            user EXE file.                                         */
/*                                                                   */
/*  NOTE: None.                                                      */
/*                                                                   */
/*  ENTRY POINT: WriteMsgSeg(fill)                                   */
/*                                                                   */
/*  INPUT: fill : flag for new style 32 bit exe                      */
/*                                                                   */
/*  EXIT-NORMAL: New message segment is writen into EXE file         */
/*               Return the number of bytes written                  */
/*                                                                   */
/*  EXIT-ERROR: Unable to open input file                            */
/*                                                                   */
/*  SIDE EFFECTS: None.                                              */
/*                                                                   */
/*  INTERNAL REFERENCES: fillpage                                    */
/*                                                                   */
/*  EXTERNAL REFERENCES: MyAlloc, MyRead, MySeek, MyWrite, MyTell    */
/*                       MyCopy                                      */
/*                                                                   */
/*********************************************************************/
/* Pseudo Code Begin */
   Set offset pointer to message data
*DCR361*   If message segment exists
*DCR361*      If current message table exists and current version > 1
*DCR361*         Determine position in output file
*DCR361*         Seek to beginning of message segment
*DCR361*         Read message segment header
*DCR361*         Reset to new version number
*DCR361*         Write message segment header
*DCR361*         Seek to original position in output file
*DCR361*   Else if message object segment exists (32 bit executable)
*DCR361*         Determine position in output file
*DCR361*         Seek to beginning of message segment using pointer to
*DCR361*            32 bit segment
*DCR361*         Read message segment header
*DCR361*         Reset to new version number
*DCR361*         Write message segment header
*DCR361*         Seek to original position in output file
*DCR361*   EndIf

   If message segment exists
     If minimum allocation equals segment size
       Move over old message segment data, ready to overwrite
     End If
   End if
   Write to output file number to message files
   Increment bytes written counter by storage size of message data
      and number message files
   Increment offset by storage size of number of message files
      and offset file name table entries

*DCR361* Set pointer to working msgfile to root of message file table

   Write filename offset table
      For i = 0 to number of message files
         Write to output file the offset
         Increment bytes written counter by storage size of offset
         Set file name pointer to message file pointer
         Increment offset by length of file name + 1

*DCR361* Calculate Pointer to Language data for this message file
*DCR361*    If current message table exists
*DCR361*       and current version > 1   DCR361
*DCR361*       Set pointer of working definition to present working
*DCR361*          file pointer
*DCR361*       Increment offset by sizeof (extended header length)
*DCR361*       For j = 0 to number of SubFiles
*DCR361*          Increment offset by sizeof (Language structure)
*DCR361*          Increment offset by sizeof (CodePage structure)
*DCR361*          Increment offset by sizeof (filename)
*DCR361*          Set pointer of extended header to offset
*DCR361*          If next definition doesnt exists
*DCR361*             Set pointer of extended header to zero
*DCR361*          EndIf
*DCR361*          Set pointer of working definition to next working definition
*DCR361*       EndFor
*DCR361*    Set pointer of working msgfile to next message file
*DCR361*    EndIf
      End For

   Write message segment offset table
      For i = 0 to number of message files
         Write to output file the offset
         Increment bytes written counter by storage size of offset
         Increment offset by storage size of component id and
           number of messages and number of elements in the message offset table
      End For

*DCR361* Set pointer to working msgfile to root of message file table

   Write filename table
      For i = 0 to number of message files
         Retrieve filename
         Write to output file the filename
         Increment bytes written counter by length of filename + 1

*DCR361* Write Language data for this message file
*DCR361*    If current message table exists
*DCR361*       and current version > 1   DCR361
*DCR361*       Set pointer of working definition to present working
*DCR361*          file pointer
*DCR361*       Increment offset by sizeof (extended header length)
*DCR361*       For j = 0 to number of SubFiles
*DCR361*          Increment offset by sizeof (Language structure)
*DCR361*          Increment offset by sizeof (CodePage structure)
*DCR361*          Increment offset by sizeof (filename)
*DCR361*          Set pointer of extended header to offset
*DCR361*          If next definition doesnt exists
*DCR361*             Set pointer of extended header to zero
*DCR361*          EndIf
*DCR361*          Set pointer of working definition to next working definition
*DCR361*       EndFor
*DCR361*    Set pointer of working msgfile to next message file
*DCR361*    EndIf

      End For

   Write message offset table
      For i = 0 to number of message files
         Set pointer to message table entry
         Write to output file the component id
         Increment bytes written counter by storage size of component id
         Write to output file the number of messages
         Increment bytes written counter by storage size of number of messages
         Set pointer to messages
         While messages in list
            Write to output file the offset
            Increment bytes written counter by storage size of offset
            Increment offset by storage size of message number,
               storage size of message length, and message length
            Next message
         End While
      End For
   If message segment exists
      Set segment size to offset
      Set minimum allocation to offset
   End If
   Write messages from message file
      For i = 0 to number of message file
         Set pointer to message file
         Open message file
         Set pointer to message table
         Set pointer to messages
         While messages in list
            Write to output file the message number
            Increment bytes written counter by storage size of message number
            Write to output file the message length
            Increment bytes written counter by storage size of message length
            Move to message offset in input file
            Copy from input file to output file the message
            Increment bytes written counter by message length
            Next message
         End While
         If message segment doesnt exists ( new style exe )
            Fill page to nearest boundary
               Set fill bytes to page size minus modulo of written bytes
                  with page size
               If fill bytes gt zero fill it
         End If
         Close input file
      End For
/* Pseudo Code End */
.fo on
.pa
:h4.Multi-CodePage Message Intra-Component Interfaces
:h4.***** MSGBIND *****
.fo off

/*********************************************************************/
/*  SUBROUTINE NAME: READCPDATA                                      */
/*                                                                   */
/*  DESCRIPTION NAME: Read Code Page Data.                           */
/*                                                                   */
/*  FUNCTION: Read and store into linked list the Language, Code     */
/*            Page, and Filename data for the message files          */
/*                                                                   */
/*  NOTE: None.                                                      */
/*                                                                   */
/*  ENTRY POINT: ReadCPData()                                        */
/*                                                                   */
/*  INPUT: wRootFile : pointer to the first entry in message file    */
/*                     linked list                                   */
/*                                                                   */
/*  EXIT-NORMAL:                                                     */
/*                                                                   */
/*  EXIT-ERROR:                                                      */
/*                                                                   */
/*  SIDE EFFECTS: None.                                              */
/*                                                                   */
/*  INTERNAL REFERENCES:                                             */
/*                                                                   */
/*                                                                   */
/*  EXTERNAL REFERENCES: MySeek                                      */
/*                                                                   */
/*********************************************************************/

*DCR361*/* Pseudo Code Begin */
*DCR361*   Set current pointer to last entry in list of message files
*DCR361*   Seek in message file to offset of the Code Page segment
*DCR361*   Read Language data into current entry
*DCR361*   Read Code Page data into current entry
*DCR361*   Read Message FileName into current entry
*DCR361*   Copy data to current entry
*DCR361*/* Pseudo Code End */
.fo on
ReadFileDef()
.pa
:h4.Multi-CodePage Message Intra-Component Interfaces
:h4.***** MSGBIND *****
.fo off

/*********************************************************************/
/*  SUBROUTINE NAME: READFILEDEF                                     */
/*                                                                   */
/*  DESCRIPTION NAME: Read File Definitions.                         */
/*                                                                   */
/*  FUNCTION: Read and store into linked list the Language, Code     */
/*            Page, and Filename data for the subfile definitions    */
/*                                                                   */
/*  NOTE: None.                                                      */
/*                                                                   */
/*  ENTRY POINT: ReadFileDef()                                       */
/*                                                                   */
/*  INPUT: wRootFile : pointer to the first entry in message file    */
/*                     linked list                                   */
/*                                                                   */
/*  EXIT-NORMAL:                                                     */
/*                                                                   */
/*  EXIT-ERROR:                                                      */
/*                                                                   */
/*  SIDE EFFECTS: None.                                              */
/*                                                                   */
/*  INTERNAL REFERENCES:                                             */
/*                                                                   */
/*  EXTERNAL REFERENCES: MySeek                                      */
/*                                                                   */
/*********************************************************************/
*DCR361*/* Pseudo Code Begin */
*DCR361*   If extender header offset exists
*DCR361*      Set current pointer to last entry in list of message files
*DCR361*      Set next definition pointer to null
*DCR361*      Seek in message file to extended header offset
*DCR361*      Read extended header length
*DCR361*      Set extended header length
*DCR361*      Read extended header number of files
*DCR361*      For i = 0 to number of message file
*DCR361*         Set current to the root entry of message files
*DCR361*         Set current pointer to last entry in list of subfile definitions
*DCR361*         Allocate new entry
*DCR361*         Read Language data into new entry
*DCR361*         Read Code Page data into new entry
*DCR361*         Read Message FileName into new entry
*DCR361*         Set current next definition pointer to the new entry
*DCR361*      EndFor
*DCR361*   EndIf
*DCR361*/* Pseudo Code End */
