/*********************************************************************/
/*  SUBROUTINE NAME: main                                            */
/*                                                                   */
/*  DESCRIPTION NAME: Make message file main routine.                */
/*  Determines the command line switches set and sets up internal    */
/*  control flags and variables.                                     */
/*                                                                   */
/*  FUNCTION: main(argc,argv)                                        */
/*                                                                   */
/*  NOTE: None.                                                      */
/*                                                                   */
/*  ENTRY POINT: main                                                */
/*                                                                   */
/*  INPUT: argc - string array of command line arguments             */
/*         argv - number of command line arguments                   */
/*                                                                   */
/*  EXIT-NORMAL: 0 - OK                                              */
/*                                                                   */
/*  EXIT-ERROR:  1 - Error                                           */
/*                                                                   */
/*  SIDE EFFECTS: Sets some global variables                         */
/*                                                                   */
/*  INTERNAL REFERENCES:                                             */
/*    vFatal      - Display message and exit MKMSGF                  */
/*    vGetCompID  - Get component id from text input file            */
/*    vInitMTab   - Initialize TK MKMSGF message in table            */
/*    vInitLTab   - Initialize the Language Table                    */
/*    vOpenFile   - Open @msgdef file since other fopen conflicts    */
/*    vCnvRecArgv - Convert @msgdef file record to argc,argv format  */
/*    vArgParse   - Parse the command line and determine switches    */
/*    msgcheck    - Check for TK MKMSGF errors and get msg count     */
/*    vCloseFile  - Close a @msgdef file                             */
/*    vError      - Display TK MKMSGF errors and quit                */
/*    vGetCompID  - Get component ID from input TXT file             */
/*    vNoFlags    - Create .MSG file                                 */
/*    vUErrMsg    - Display TK MKMSGF errors                         */
/*    vSys_Msg    - Display OSO001.MSG message                       */
/*    vAsmCFlag   - Create either a C/ASM include file               */
/*                                                                   */
/*  EXTERNAL REFERENCES:                                             */
/*                                                                   */
/*********************************************************************/
.pa
/************ SUBROUTINE: main      PSUEDO CODE (BEGIN) **************/
/*                                                                   */
/*  main(count, table_of_pointers)                                   */
/*  begin                                                            */
/*   call vInitMTab to initialize messages                           */
/*   call vInitLTab to initialize language family table              */
/*   if argcount == 2 and second_arg_first_char == @sign             */
/*   then                                                            */
/*      * ******************************************* *              */
/*      *     assume new method of MKMSGF execution   *              */
/*      * ******************************************* *              */
/*                                                                   */
/*     open msgdef_filename for read using vOpenFile                 */
/*     if no errors on vOpenFile                                     */
/*     then                                                          */
/*        read root file record from msgdef file using C fgets       */
/*        if no errors on fgets                                      */
/*        then                                                       */
/*          if not at end of file                                    */
/*          then                                                     */
/*            set flag to root file found                            */
/*            allocate memory for root record just read              */
/*            save root record into temporary storage                */
/*               for future decoding                                 */
/*            while not at end of file                               */
/*              read sub file record from msgdef file                */
/*              if no errors on fgets                                */
/*              then                                                 */
/*                if not at end of file                              */
/*                then                                               */
/*                  set flag to sub  file found                      */
/*                                                                   */
/*                   * **************************** *                */
/*                   * create man-made command line *                */
/*                   * **************************** *                */
/*                                                                   */
/*                  call vCnvRecArgv to create argc, argv            */
/*                      type structure                               */
/*                       from record in file for subfile creation    */
/*                   * **************************** *                */
/*                   * parse man-made command line  *                */
/*                   * **************************** *                */
/*                                                                   */
/*                  call vArgParse to parse the argc,argv            */
/*                      type structure for subfile creation          */
/*                  Initialize code page record for this file        */
/*                                                                   */
/*                  call vOpenFile to check for TK MKMSGF error      */
/*                  call msgcheck  to check for TK MKMSGF error      */
/*                  call vCloseFile to close input file              */
/*                  if no errors from msgcheck                       */
/*                  then                                             */
/*                    call malloc to allocate index table            */
/*                      using message count.                         */
/*                                                                   */
/*                  if /A or /C flags set                            */
/*                  then                                             */
/*                    call vFatal to display @msgdef filename        */
/*                         "cannot use /A or /C on subfile"          */
/*                  else                                             */
/*                                                                   */
/************ SUBROUTINE: main      PSUEDO CODE (CONTINUED) **********/
.pa
/************ SUBROUTINE: main      PSUEDO CODE (CONTINUED) **********/
/*                                                                   */
/*                     * **************************** *              */
/*                     * do component id from infile  *              */
/*                     * **************************** *              */
/*                                                                   */
/*                    call vGetCompID to get the component_id from   */
/*                        input file                                 */
/*                         and put into sub file header structure    */
/*                                                                   */
/*                    display  Creating output file from input file  */
/*                            using component id from profile file   */
/*                                                                   */
/*                     * **************************** *              */
/*                     * create a .msg file           *              */
/*                     * **************************** *              */
/*                                                                   */
/*                    call vNoFlags(flag,numsubs) to                 */
/*                         create a .msg sub file                    */
/*                  endif                                            */
/*                endif                                              */
/*              else                                                 */
/*                call computmsg to display error msg from rc        */
/*                close the msgdef file using C fclose               */
/*              endif                                                */
/*            end while                                              */
/*            fclose to close the msgdef file                        */
/*                                                                   */
/*             * ******************************************* *       */
/*             *     assume new method of MKMSGF execution   *       */
/*             *     building root header file now           *       */
/*             * ******************************************* *       */
/*                                                                   */
/*             * **************************** *                      */
/*             * create man-made command line *                      */
/*             * **************************** *                      */
/*                                                                   */
/*            call vCnvRecArgv to create argc, argv type structure   */
/*                 from record in file for rootfile creation         */
/*                                                                   */
/*             * **************************** *                      */
/*             * parse man-made command line  *                      */
/*             * **************************** *                      */
/*                                                                   */
/*            call vArgParse to parse the argc,argv type             */
/*                 structure for rootfile creation                   */
/*                                                                   */
/************ SUBROUTINE: main      PSUEDO CODE (CONTINUED) **********/
.pa
/************ SUBROUTINE: main      PSUEDO CODE (CONTINUED) **********/
/*             * **************************** *                      */
/*             * do component id from infile  *                      */
/*             * **************************** *                      */
/*                                                                   */
/*            call vGetCompID to get the component_id from input     */
/*                 file and put into root file header structure      */
/*                                                                   */
/*            display  Creating output file from input file          */
/*                    using component id from profile file           */
/*                                                                   */
/*             * **************************** *                      */
/*             * create a .msg file           *                      */
/*             * **************************** *                      */
/*                                                                   */
/*            call vNoFlags(flag,numsubs) to create a .msg root file */
/*              with sub files if flag indicates                     */
/*          else                                                     */
/*            close the msgdef file using C fclose                   */
/*            call vFatal to display fatal error message and end     */
/*          endif                                                    */
/*        else                                                       */
/*          call computmsg to display error msg from rc              */
/*          close the msgdef file using C fclose                     */
/*        endif                                                      */
/*                                                                   */
/*     else                                                          */
/*         call computmsg to display error msg from rc               */
/*     endif                                                         */
/*   else                                                            */
/*      * ******************************************* *              */
/*      *     assume old method of MKMSGF execution   *              */
/*      * ******************************************* *              */
/*                                                                   */
/*     call vArgParse to parse the argc,argv type structure          */
/*          for rootfile creation                                    */
/*                                                                   */
/************ SUBROUTINE: main      PSUEDO CODE (CONTINUED) **********/
.pa
/************ SUBROUTINE: main      PSUEDO CODE (CONTINUED) **********/
/*      * **************************** *                             */
/*      * do component id from infile  *                             */
/*      * **************************** *                             */
/*                                                                   */
/*     call vGetCompID to get the component_id from input file       */
/*          and put into root file header structure                  */
/*                                                                   */
/*     display  Creating output file from input file                 */
/*             using component id from profile file                  */
/*     if /A or /C flags set                                         */
/*     then                                                          */
/*        * **************************** *                           */
/*        * create a .h or .inc file     *                           */
/*        * **************************** *                           */
/*                                                                   */
/*       call vAsmCFlag to create either a .h or .inc file           */
/*                                                                   */
/*     else                                                          */
/*        * **************************** *                           */
/*        * create a .msg file           *                           */
/*        * **************************** *                           */
/*                                                                   */
/*       call vNoFlags(flag,numsubs) to create a .msg                */
/*            file with no subfiles                                  */
/*     endif                                                         */
/*   endif                                                           */
/*  display "Done"                                                   */
/*  end                                                              */
/*  exit mkmsgf program                                              */
/************ SUBROUTINE: main      PSUEDO CODE (END) ****************/
.pa
/*********************************************************************/
/*  SUBROUTINE NAME: vArgParse                                       */
/*                                                                   */
/*  DESCRIPTION NAME: Parse the command line and determine           */
/*  switches set. Determine sub file and dbcs requirements           */
/*  from command line switches.                                      */
/*                                                                   */
/*                                                                   */
/*                                                                   */
/*  FUNCTION: vArgParse(argc,                                        */
/*                      argv,                                        */
/*                      pexthdr);                                    */
/*                                                                   */
/*  NOTE:                                                            */
/*    vArgParse treats the argv table as a sequence of bins          */
/*    out of which it extracts /O OPTION or /OOPTION                 */
/*    as the case may be and then compacts the list to               */
/*    arrive at a contiguous sequence of filenames.                  */
/*                                                                   */
/*    |_| ... |_| |/O| |OPTION| |_| |_| ..... |_| |__                */
/*     0           j       i                       argc              */
/*                                                                   */
/*    In case of /OOPTION i == j before compaction.                  */
/*                                                                   */
/*                                                                   */
/*  ENTRY POINT: vArgParse                                           */
/*                                                                   */
/*  INPUT: argc     - string array of command line arguments         */
/*         argv     - number of command line arguments               */
/*         *cpcnt   - count of codepages                             */
/*         *cpinx   - index into code page table                     */
/*         *lfvalue - language family                                */
/*         *famvers - language version                               */
/*         cp_tab[] - code page table                                */
/*         flag     - type of record in process                      */
/*         cp_type  - code page type 1 = SBCS 2 = DBCS               */
/*                                                                   */
/*  EXIT-NORMAL: none                                                */
/*                                                                   */
/*  EXIT-ERROR:                                                      */
/*    aborts with a help message for incosistent arguments           */
/*    exits program with help message if MSGSPLIT /?                 */
/*    returns nothing otherwise                                      */
/*                                                                   */
/*  SIDE EFFECTS: Sets some global variables                         */
/*    strIn, strHelp, strMsg, and strDelim are initialized           */
/*    from defaults or commandline arguments if given.               */
/*                                                                   */
/*  INTERNAL REFERENCES:                                             */
/*    fGetDbcsVec      - get the system DBCS vector information      */
/*    vPrintHelpInfo   - print command line help                     */
/*    vFatal           - exit of MKMSGF                              */
/*    vExtrDbcs        - extract DBCS variables from system vector   */
/*    fSetDbcsFlags    - set DBCS control information                */
/*    casemapup        - convert filename t oupper case SBCS chars   */
/*    com_strchr       - search for the first occur of char          */
/*    fGetDbcsVec      - get DBCS environment vector                 */
/*    fSetDbcsFlags    - set local DBCS ranges                       */
/*    vCnvNum          - convert string to numbers                   */
/*    vError           - display error message                       */
/*    vExtrDbcs        - get DBCS ranges for a country               */
/*    vFatal           - display error message and exit              */
/*    vPrintHelpInfo   - print help information for all of MKMSGF    */
/*    vSearchLTab      - search lang/vers table for match            */
/*    vUErrMsg         - display TK MKMSGF error message             */
/*                                                                   */
/*                                                                   */
/*  EXTERNAL REFERENCES: none                                        */
/*    DOSGETCP         - get current path                            */
/*    DOSQFILEMODE     - test if file exists                         */
/*                                                                   */
/*********************************************************************/
.pa
/************ SUBROUTINE: vArgParse PSUEDO CODE (BEGIN) **************/
/*                                                                   */
/*  vArgParse(count,table_of_pointers,pointer to output structure)   */
/*        Get current enrironment                                    */
/*        loop until no more arguments                               */
/*           if argument is prefixed with a / or - then              */
/*              save index of current argument                       */
/*              switch(argument)                                     */
/*                                                                   */
/*              default case:                                        */
/*                call vFatal inform user to use mkmsgf /? for help  */
/*              endsub                                               */
/*                                                                   */
/*              /v case:                                             */
/*              /V case:    * be Verbose in process tracing *        */
/*                set /V found flag true                             */
/*              endsub                                               */
/*                                                                   */
/*              /? case:    * define include file to use *           */
/*                call vPrintHelpInfo to display help for MKMSGF     */
/*              endsub                                               */
/*                                                                   */
/*              /i case:                                             */
/*              /I case:   * define include directory *              */
/*                if character following I is not NULL then          */
/*                  assign directory name from same argument         */
/*                else                                               */
/*                  if after incing the arg ptr there is             */
/*                     still another argument                        */
/*                  then                                             */
/*                      assign this new arg as the directory name    */
/*                  else                                             */
/*                    call vFatal to display no argument for         */
/*                    option with arg included in message.           */
/*                  endif                                            */
/*                endif                                              */
/*              endsub                                               */
/*                                                                   */
/*              /d case:                                             */
/*              /D case:   * define dbcs range value *               */
/*                set new style header flag to TRUE                  */
/*                call vGetDbcsVec to get environment vector         */
/*                if succeeded                                       */
/*                then                                               */
/*                  if character following D is not NULL             */
/*                  then                                             */
/*                    call vExtrDbcs using this arg as DBCS value    */
/*                  else                                             */
/*                    if after incing the arg ptr there is still     */
/*                       another argument                            */
/*                    then                                           */
/*                      call vExtrDbcs using this new arg as         */
/*                        DBCS value                                 */
/*                    else                                           */
/*                      call vFatal to display no argument           */
/*                        for option with arg included in message.   */
/*                    endif                                          */
/*                  endif                                            */
/*                endif                                              */
/*              endsub                                               */
/*                                                                   */
/************ SUBROUTINE: vArgParse PSUEDO CODE (CONTINUED) **********/
.pa
/************ SUBROUTINE: vArgParse PSUEDO CODE (CONTINUED) **********/
/*              /p case:                                             */
/*              /P case:   * define codepage value *                 */
/*                set new style header flag to TRUE                  */
/*                if have not exceeded code page limit               */
/*                then                                               */
/*                  if character following P is not NULL then        */
/*                    use this arg as the codepage value and         */
/*                    converted to an integer                        */
/*                    call vCnvNum to convert the string to number   */
/*                    if error                                       */
/*                    then                                           */
/*                      call vUErrMsg to display error message       */
/*                    endif                                          */
/*                  else                                             */
/*                    if after incing the arg ptr there is still     */
/*                      another argument                             */
/*                    then                                           */
/*                      use this new arg as the codepage value       */
/*                      from and convert to an integer               */
/*                      call vCnvNum to convert the str to number    */
/*                      if error                                     */
/*                      then                                         */
/*                        call vUErrMsg to display error message     */
/*                      endif                                        */
/*                    else                                           */
/*                      call vFatal to display no argument for       */
/*                      option with argument included in message.    */
/*                    endif                                          */
/*                  endif                                            */
/*                else                                               */
/*                  call vUErrMsg to display warning messages        */
/*                endif                                              */
/*              endsub                                               */
/*                                                                   */
/*                                                                   */
/*              /C case:   * define c compatible include file  *     */
/*              /c case:   * output requested                  *     */
/*                set /C found flag to true                          */
/*              endsub                                               */
/*                                                                   */
/*              /A case:   * define asm compatible include file*     */
/*              /a case:   * output requested                  *     */
/*                set /A found flag to true                          */
/*              endsub                                               */
/************ SUBROUTINE: vArgParse PSUEDO CODE (CONTINUED) **********/
.pa
/************ SUBROUTINE: vArgParse PSUEDO CODE (CONTINUED) **********/
/*                                                                   */
/*              /l case:   * define language id  value *             */
/*              /L case:   * define language id  value *             */
/*                set new style header flag to TRUE                  */
/*                if not set yet                                     */
/*                then                                               */
/*                  if character following L is not NULL then        */
/*                  then                                             */
/*                    at the first occurrence of a comma insert a    */
/*                    null use this arg as the language value and    */
/*                    converted to an integer                        */
/*                    move byte pointer to first char following null */
/*                    use this arg as the language version           */
/*                    converted to an integer                        */
/*                    Call vCnvNum to convert string to number       */
/*                  else                                             */
/*                    if after incing the arg ptr there is still     */
/*                      another argument                             */
/*                    then                                           */
/*                      at the first occurrence of a comma insert    */
/*                      null use this arg as the language value and  */
/*                      convert to an integer                        */
/*                      move byte pointer to first char following    */
/*                      null use this arg as the language version to */
/*                      convert to an integer                        */
/*                      Call vCnvNum to convert string to number     */
/*                    else                                           */
/*                      call vFatal to display no argument for option*/
/*                      with arg included in message.                */
/*                    endif                                          */
/*                  endif                                            */
/*                  call vSearchLTab to search the language family   */
/*                    tbl for match on language and version.         */
/*                  if error                                         */
/*                  then                                             */
/*                    set language and family to 0 as the default    */
/*                  endif                                            */
/*                else                                               */
/*                  call vUErrMsg to display error                   */
/*                endif                                              */
/*              endsub                                               */
/*              endcase                                              */
/*        fix up argument counter to reflect the correct             */
/*          number of arguments                                      */
/*        end loop                                                   */
/*        if asking for both C header file and ASM include file      */
/*        then                                                       */
/*          call vFatal to display conflicting switch arguments      */
/*            and quit.                                              */
/*        endif                                                      */
/************ SUBROUTINE: vArgParse PSUEDO CODE (CONTINUED) **********/
.pa
/************ SUBROUTINE: mArgParse PSUEDO CODE (CONTINUED) **********/
/*        if fSetDbcsFlags fails                                     */
/*        then                                                       */
/*          display message that the number of DBCS ranges defined   */
/*            may overflow the table                                 */
/*        endif                                                      */
/*                                                                   */
/*        if we are just being backward compatible                   */
/*        then                                                       */
/*          zero out code page type, codepage numbers and header     */
/*            length in header                                       */
/*        endif                                                      */
/*                                                                   */
/*        if no INCLUDE environment variable setup                   */
/*        then                                                       */
/*          call getcwd to get current working directory             */
/*            to use in determining drive and path for h and inc     */
/*          if length of dir > 6 i.e. E:\DRV6                        */
/*          then                                                     */
/*            NULL out the release level i.e. 6 in above example     */
/*            if dir = DRV and next character is a number            */
/*            then                                                   */
/*              if creating inc file                                 */
/*              then                                                 */
/*                  concat latest inc dir setup to E:\DRVn\          */
/*              else                                                 */
/*                  concat latest h   dir setup to E:\DRVn\          */
/*              endif                                                */
/*              call DOSQFILEMODE to test for basemid.inc/h exist    */
/*              if no error                                          */
/*              then                                                 */
/*                if creating inc file                               */
/*                then                                               */
/*                  put null at end of inc path string               */
/*                else                                               */
/*                  put null at end of h   path string               */
/*                endif                                              */
/*                assign temporary include path to global path       */
/*              else                                                 */
/*                NULL out backslash following E:\DRVn               */
/*                if creating inc file                               */
/*                then                                               */
/*                  concat older  inc dir setup to E:\DRVn\          */
/*                else                                               */
/*                  concat older  h   dir setup to E:\DRVn\          */
/*                endif                                              */
/*                call DOSQFILEMODE to test for                      */
/*                    basemid.inc/h exist                            */
/************ SUBROUTINE: vArgParse PSUEDO CODE (CONTINUED) **********/
.pa
/************ SUBROUTINE: vArgParse PSUEDO CODE (CONTINUED) **********/
/*                if no error                                        */
/*                then                                               */
/*                  if creating inc file                             */
/*                  then                                             */
/*                      put null at end of inc path string           */
/*                  else                                             */
/*                      put null at end of h   path string           */
/*                  endif                                            */
/*                  assign temp include path to global path          */
/*                else                                               */
/*                  call vError to display error                     */
/*                endif                                              */
/*              endif                                                */
/*            endif                                                  */
/*          endif                                                    */
/*        endif                                                      */
/*                                                                   */
/*        if both /A and /C set                                      */
/*        then                                                       */
/*           call vError to display error                            */
/*        endif                                                      */
/*                                                                   */
/*        if no code pages defined yet                               */
/*        then                                                       */
/*          call DOSGETCP to get current process code page info      */
/*          save returned code page number in cp array in struct     */
/*          increment number of code pages defined in struct         */
/*          set SBCS as codepage type in struct                      */
/*        endif                                                      */
/*                                                                   */
/*        call fSetDbcsFlags to setup dbcs ranges                    */
/*        if error                                                   */
/*        then                                                       */
/*          call vUErrMsg to display TK MKMSGF error                 */
/*        endif                                                      */
/*                                                                   */
/*        switch(argument count)                                     */
/*          begincase                                                */
/*          case 3:                                                  */
/*            save second argument in output file name to            */
/*              override default value                               */
/*            save first  argument in  input file name to            */
/*              override default value                               */
/*          endsub                                                   */
/*                                                                   */
/*          default:                                                 */
/*            call vFatal inform user to issue MKMSGF /?             */
/*            to figure out how to use MKMSGF since an input         */
/*            and output file was not entered.                       */
/*          endsub                                                   */
/*          endcase                                                  */
/*                                                                   */
/*        initialize header length                                   */
/*        save filename in struct                                    */
/*                                                                   */
/*        if /V switch selected                                      */
/*        then                                                       */
/*          display current header controls                          */
/*        endif                                                      */
/*        return                                                     */
/*                                                                   */
/************ SUBROUTINE: vArgParse PSUEDO CODE (END) ****************/
.pa
/*********************************************************************/
/*  SUBROUTINE NAME: vOutMsgFileHeader                               */
/*                                                                   */
/*  DESCRIPTION NAME: Prep and write out message file header.        */
/*                                                                   */
/*  FUNCTION: vOutMsgFileHeader(pheader, pfile,vftype)               */
/*                                                                   */
/*  NOTE: None.                                                      */
/*                                                                   */
/*  ENTRY POINT: vOutMsgFileHeader                                   */
/*                                                                   */
/*  INPUT:                                                           */
/*    pheader - data structure of data to transfer to file.          */
/*    pfile   - .MSG file handle                                     */
/*                                                                   */
/*  EXIT-NORMAL:                                                     */
/*                                                                   */
/*  EXIT-ERROR: None.                                                */
/*                                                                   */
/*  SIDE EFFECTS: Writes data to message file                        */
/*                                                                   */
/*  INTERNAL REFERENCES:                                             */
/*    vError      - Display TK MKMSGF errors and quit                */
/*    vFatal      - Display message and exit MKMSGF                  */
/*    vWriteOut   - Write out message file header to MSG file        */
/*                                                                   */
/*  EXTERNAL REFERENCES: none                                        */
/*                                                                   */
/*********************************************************************/
.pa
/************ SUBROUTINE: vOutMsgFileheader PSUEDO CODE (BEGIN) ******/
/*                                                                   */
/*  call malloc to allocate buffer to use to write to file           */
/*  if error                                                         */
/*  then                                                             */
/*    call vError to display TK MKMSGF error message and exit.       */
/*  endif                                                            */
/*                                                                   */
/*  initialize buffer with blanks                                    */
/*  copy struct SIGNATURE MARK               to buffer               */
/*  copy struct COMPONENT ID                 to buffer               */
/*  copy struct NUMBER OF MESSAGES           to buffer               */
/*  copy struct BASE MESSAGE NUMBER          to buffer               */
/*  copy struct OFFSET TYPE 1=W 0=DW         to buffer               */
/*  copy struct VERSION NUMBER               to buffer               */
/*  copy struct LENGTH OF HEADER IN BYTES    to buffer               */
/*  copy struct OFFSET TO CODE PAGEs OF FILE to buffer               */
/*  copy struct OFFSET TO EXT.HEADER IF<>0   to buffer               */
/*  copy struct reserved value of zeroes     to buffer               */
/*  call vWriteOut to write buffer to begin of MSG file              */
/*  free buffer allocated                                            */
/*  return                                                           */
/*                                                                   */
/************ SUBROUTINE: vOutMsgFileheader PSUEDO CODE (END) ********/
.pa
/*********************************************************************/
/*  SUBROUTINE NAME: vOutMsgFileExtHeader                            */
/*                                                                   */
/*  DESCRIPTION NAME: Prep and write out message file header.        */
/*                                                                   */
/*  FUNCTION: vOutMsgFileExtHeader(pheader, pfile)                   */
/*                                                                   */
/*  NOTE: None.                                                      */
/*                                                                   */
/*  ENTRY POINT:                                                     */
/*                                                                   */
/*  INPUT:                                                           */
/*    pheader - data structure of data to transfer to file.          */
/*    pfile   - .MSG file handle                                     */
/*                                                                   */
/*  EXIT-NORMAL:                                                     */
/*                                                                   */
/*  EXIT-ERROR: None.                                                */
/*                                                                   */
/*  SIDE EFFECTS: Writes data to message file                        */
/*                                                                   */
/*  INTERNAL REFERENCES: vWriteOut                                   */
/*                                                                   */
/*  EXTERNAL REFERENCES: none                                        */
/*                                                                   */
/*********************************************************************/
.pa
/************ SUBROUTINE: vOutMsgFileExtheader PSUEDO CODE (BEGIN) ***/
/*                                                                   */
/*  vOutMsgFileExtheader( ptophdr, file )                            */
/*                                                                   */
/*  malloc buffers for extended header ctrl and header record        */
/*  if error                                                         */
/*  then                                                             */
/*      call vError to display TK MKMSGF error message               */
/*  endif                                                            */
/*  blank out extended header ctrl                                   */
/*  copy struct header length to buffer                              */
/*  copy struct number of records value to buffer                    */
/*  call vWriteOut to write buffer to MSG file                       */
/*  save struct number of records value in temporary variable        */
/*  while (temp varb > 0)                                            */
/*    blank out extended header record                               */
/*    copy struct code page type     to MsgFileExtHeader output bufr */
/*    copy struct country            to MsgFileExtHeader output bufr */
/*    copy struct language family id to MsgFileExtHeader output bufr */
/*    copy struct version id         to MsgFileExtHeader output bufr */
/*    copy struct code page count    to MsgFileExtHeader output bufr */
/*    copy struct code page table    to MsgFileExtHeader output bufr */
/*    copy struct filename           to MsgFileExtHeader output bufr */
/*    copy reserved zeroes           to MsgFileExtHeader output bufr */
/*                                                                   */
/*    call WriteOut to write MsgFileExtHeader buffer                 */
/*       to file after offsets table                                 */
/*    increment ptr to next struct of extended header data           */
/*    decrement the temp varb (# ext headers remaining to write)     */
/*  end while                                                        */
/*  free memory allocated for extended header control output buffer  */
/*  free memory allocated for extended header record output buffer   */
/*                                                                   */
/*  return                                                           */
/*                                                                   */
/************ SUBROUTINE: vOutMsgFileExtheader PSUEDO CODE (END) *****/
.pa
/*********************************************************************/
/*  SUBROUTINE NAME: vOutCodePageTable                               */
/*                                                                   */
/*  DESCRIPTION NAME: Prep and write out message file header.        */
/*                                                                   */
/*  FUNCTION: vOutCodePageTable(pheader, pfile)                      */
/*                                                                   */
/*  NOTE: None.                                                      */
/*                                                                   */
/*  ENTRY POINT:                                                     */
/*                                                                   */
/*  INPUT:                                                           */
/*    pheader - data structure of data to transfer to file.          */
/*    pfile   - .MSG file handle                                     */
/*                                                                   */
/*  EXIT-NORMAL:                                                     */
/*                                                                   */
/*  EXIT-ERROR: None.                                                */
/*                                                                   */
/*  SIDE EFFECTS: Writes data to message file                        */
/*                                                                   */
/*  INTERNAL REFERENCES: vWriteOut                                   */
/*                                                                   */
/*  EXTERNAL REFERENCES: none                                        */
/*                                                                   */
/*********************************************************************/
.pa
/************ SUBROUTINE: vOutCodePageTable    PSUEDO CODE (BEGIN) ***/
/*                                                                   */
/*  vOutCodePageTable( pheader, pfile )                              */
/*                                                                   */
/*  if  not extended headers then                                    */
/*  then                                                             */
/*      call vFatal to "Out of Memory." and exit                     */
/*  endif                                                            */
/*                                                                   */
/*  copy LANGUAGE FAMILY ID  table to MsgFileExtHeader output buffer */
/*  copy CODE PAGE COUNT     to MsgFileExtHeader output buffer       */
/*  copy CODE PAGE ID table  to MsgFileExtHeader output buffer       */
/*  copy REC_FILENAME        to MsgFileExtHeader output buffer       */
/*  copy reserved            to MsgFileExtHeader output buffer       */
/*                                                                   */
/*  call WriteOut to write MsgFileExtHeader buffer                   */
/*       to file after offsets table                                 */
/*  return                                                           */
/*                                                                   */
/************ SUBROUTINE: vOutCodePageTable    PSUEDO CODE (END) *****/
.pa
/*********************************************************************/
/*  SUBROUTINE NAME: vNoFlags                                        */
/*                                                                   */
/*  DESCRIPTION NAME: Write out .msg file                            */
/*                                                                   */
/*  FUNCTION: vNoFlags(flag)                                         */
/*                                                                   */
/*  NOTE: None.                                                      */
/*                                                                   */
/*  ENTRY POINT:                                                     */
/*                                                                   */
/*  INPUT:                                                           */
/*    flag    - indicates mkmsgf form- root, rootwsub, sub           */
/*                                                                   */
/*  EXIT-NORMAL:                                                     */
/*                                                                   */
/*  EXIT-ERROR: None.                                                */
/*                                                                   */
/*  SIDE EFFECTS: Writes data to message file                        */
/*                                                                   */
/*  INTERNAL REFERENCES:                                             */
/*    vOpenFile         - open input file                            */
/*    fResetInput       - reset file to begin                        */
/*    fGetNext          - get a message from file                    */
/*    iMsgNum           - output message                             */
/*    lenmsgUsed        - determine # chars used                     */
/*    vCloseFile        - close file                                 */
/*    vAdjTbl           - convert lengths to file offsets            */
/*    vOutMsgFileHeader - output file header                         */
/*    vWriteOut         - output data to file                        */
/*    vOutMess          - write message to file                      */
/*    vCloseFile        - close input file                           */
/*                                                                   */
/*  EXTERNAL REFERENCES: none                                        */
/*                                                                   */
/*********************************************************************/
.pa
/************ SUBROUTINE: vNoFlags  PSUEDO CODE (BEGIN) **************/
/*                                                                   */
/*                                                                   */
/*  vNoFlags(flag)                                                   */
/*    BEGIN                                                          */
/*      call vOpenFile to open input file                            */
/*      prepare for input                                            */
/*      dispose of first message                                     */
/*                                                                   */
/*      while last message not yet read                              */
/*        get next message from input                                */
/*                                                                   */
/*        if this is the first message                               */
/*        then                                                       */
/*            save the base pointer to the messages +                */
/*              length of the extender header table                  */
/*            reset first message flag to FALSE to !repeat           */
/*        endif                                                      */
/*        assign msg tbl element the length of this                  */
/*          message plus the length of the extender header table     */
/*      endwhile                                                     */
/*                                                                   */
/*                                                                   */
/*      close input file                                             */
/*      save count of messages in header table location.             */
/*      if we are in Verbose mode                                    */
/*      then                                                         */
/*          display the count of  messages scanned.                  */
/*            Writing output file...                                 */
/*      endif                                                        */
/************ SUBROUTINE: vNoFlags  PSUEDO CODE (CONTINUED) **********/
.pa
/************ SUBROUTINE: vNoFlags  PSUEDO CODE (CONTINUED) **********/
/*                                                                   */
/*      call vAdjTbl to convert lengths of file offsets              */
/*      if we are in Verbose mode                                    */
/*      then                                                         */
/*          display the Size of table entry                          */
/*      endif                                                        */
/*      save offset type in msgFileHeader                            */
/*      determine the size of table elements for offsets             */
/*                                                                   */
/*      call vOpenFile for output file                               */
/*      call vOpenFile for input file                                */
/*      calculate code page table offset                             */
/*      set extended header offeset to null                          */
/*      call vOutMsgFileHeader to output file header                 */
/*      call vWriteOut to output offsets table                       */
/*      call vOutCodePageTable to output code page table record      */
/*      call fResetInput to prepare to read input                    */
/*      call fGetNext to dispose of first message                    */
/*      while last message not yet read                              */
/*         call fGetNext to get next message from input              */
/*         call vOutMess to write message to file                    */
/*         increment number of bytes written                         */
/*      endwhile                                                     */
/*      switch(flag)                                                 */
/*        case rootonly:                                             */
/*          do nothing                                               */
/*        endsub                                                     */
/*        case rootwsubs:                                            */
/*          call vOutMsgFileExtHeader to write ext hdr to MSG file   */
/*          set extended header pointer in header record             */
/*          seek to the begin of file to write header record again   */
/*          call vOutMsgFileHeader to write updated hdr to MSG file  */
/*        endsub                                                     */
/*        case subfile:                                              */
/*          increment number of extended header records this file    */
/*          calculate position of this extended header record in list*/
/*          copy struct ext hdr rec to position in list              */
/*          reallocate list to be same size + len of 1 ext hdr rec   */
/*          update pointer in list to next ext hdr rec               */
/*          initialize ext hdr rec area in list                      */
/*          initialize ext hdr rec struct for next sub file          */
/*          initialize header rec for next sub file                  */
/*          initialize code page rec for next sub file               */
/*        endsub                                                     */
/*      endcase                                                      */
/*      attach extendedheader to extendedheader memory chain         */
/*      increment number of extended headers in memory chain         */
/*                                                                   */
/*      close input file                                             */
/*      close output file                                            */
/*      free input buffer                                            */
/*      free output buffer                                           */
/*      return                                                       */
/*    END                                                            */
/*                                                                   */
/*                                                                   */
/************ SUBROUTINE: vNoFlags  PSUEDO CODE (END) ****************/
.pa
/*********************************************************************/
/*  SUBROUTINE NAME:    vInitMTab                                    */
/*                                                                   */
/*  DESCRIPTION NAME:   Initialize language table                    */
/*                                                                   */
/*                                                                   */
/*                                                                   */
/*                                                                   */
/*                                                                   */
/*  FUNCTION:           Copy the language and id information to      */
/*                      table for input verification.                */
/*                                                                   */
/*  NOTE: None.                                                      */
/*                                                                   */
/*  ENTRY POINT:        vInitLTab                                    */
/*                                                                   */
/*  INPUT:              None                                         */
/*                                                                   */
/*  EXIT-NORMAL: none   Void                                         */
/*                                                                   */
/*  EXIT-ERROR:  None   None                                         */
/*                                                                   */
/*  SIDE EFFECTS: Initializes global array langtab                   */
/*                                                                   */
/*  INTERNAL REFERENCES: None.                                       */
/*                                                                   */
/*  EXTERNAL REFERENCES: None.                                       */
/*                                                                   */
/*                                                                   */
/*********************************************************************/
/************ SUBROUTINE: vInitMTab PSUEDO CODE (BEGIN) **************/
/*                                                                   */
/* copy strings of messages to ascending ordinal positions in        */
/*      the message vector.                                          */
/* return                                                            */
/*                                                                   */
/************ SUBROUTINE: vInitMTab PSUEDO CODE (END)   **************/
.pa
/*********************************************************************/
/*  SUBROUTINE NAME:    vInitLTab                                    */
/*                                                                   */
/*  DESCRIPTION NAME:   Initialize language table                    */
/*                                                                   */
/*                                                                   */
/*                                                                   */
/*                                                                   */
/*                                                                   */
/*  FUNCTION:           Copy the language and id information to      */
/*                      table for input verification.                */
/*                                                                   */
/*  NOTE: None.                                                      */
/*                                                                   */
/*  ENTRY POINT:        vInitLTab                                    */
/*                                                                   */
/*  INPUT:              None                                         */
/*                                                                   */
/*  EXIT-NORMAL: none   Void                                         */
/*                                                                   */
/*  EXIT-ERROR:  None   None                                         */
/*                                                                   */
/*  SIDE EFFECTS: Initializes global array langtab                   */
/*                                                                   */
/*  INTERNAL REFERENCES: None.                                       */
/*                                                                   */
/*  EXTERNAL REFERENCES: None.                                       */
/*                                                                   */
/*                                                                   */
/*********************************************************************/
/************ SUBROUTINE: vInitLTab PSUEDO CODE (BEGIN) **************/
/*                                                                   */
/* copy family to ordinal table entry                                */
/* copy sub language to ordinal table entry                          */
/* copy language string to ordinal table entry                       */
/* copy country string to ordinal table entry                        */
/* return                                                            */
/*                                                                   */
/************ SUBROUTINE: vInitLTab PSUEDO CODE (END)   **************/
.pa
/*********************************************************************/
/*  SUBROUTINE NAME:    vSearchLTab                                  */
/*                                                                   */
/*  DESCRIPTION NAME:   Search the language table for a match        */
/*                                                                   */
/*                                                                   */
/*                                                                   */
/*                                                                   */
/*                                                                   */
/*  FUNCTION:           Search the language and id information in    */
/*                      table to find a match.  If not then check    */
/*                      for valid range.                             */
/*  NOTE: None.                                                      */
/*                                                                   */
/*  ENTRY POINT:        vSearchLTab                                  */
/*                                                                   */
/*  INPUT:              family - family id                           */
/*                      subid  - sub id                              */
/*                                                                   */
/*  EXIT-NORMAL: none   TRUE                                         */
/*                                                                   */
/*  EXIT-ERROR:  None   FALSE                                        */
/*                                                                   */
/*  SIDE EFFECTS: None.                                              */
/*                                                                   */
/*  INTERNAL REFERENCES: None.                                       */
/*                                                                   */
/*  EXTERNAL REFERENCES: None.                                       */
/*                                                                   */
/*                                                                   */
/*********************************************************************/
.pa
/************ SUBROUTINE: vSearchLTab PSUEDO CODE (BEGIN) ************/
/* vSearchLTab(family,subid)                                         */
/*   search for match on passed family and subid with what is in     */
/*     the table                                                     */
/*   if not found in table                                           */
/*   search table for match on passed family value                   */
/*   if found then                                                   */
/*   then                                                            */
/*     set subid to default of 1                                     */
/*     set return code to success                                    */
/*   else                                                            */
/*     call vUErrMsg to display TK MKMSGF error message              */
/*   endif                                                           */
/*   if still not found                                              */
/*   then                                                            */
/*     if family and subid are outside of defined range but are      */
/*       in the overall valid ranges                                 */
/*     then                                                          */
/*       set return code to success                                  */
/*     endif                                                         */
/*   endif                                                           */
/*                                                                   */
/************ SUBROUTINE: vSearchLTab PSUEDO CODE (END)   ************/
.pa
/*********************************************************************/
/*  SUBROUTINE NAME:    vCnvNum                                      */
/*                                                                   */
/*  DESCRIPTION NAME:   Convert number and check range               */
/*                                                                   */
/*  FUNCTION:           Convert string to number and check for       */
/*                      multiple error conditions                    */
/*  NOTE: None.                                                      */
/*                                                                   */
/*  ENTRY POINT:        vCnvNum                                      */
/*                                                                   */
/*  INPUT:              str       - input string to convert to num   */
/*                      numdigits - number of digits to convert      */
/*                      lolimit   - lo limit to test val against     */
/*                      hilimit   - hi limit to test val against     */
/*                      retnum    - output converted number          */
/*                      exterr    - returned error condition         */
/*                                                                   */
/*  EXIT-NORMAL: none   TRUE  - number converted                     */
/*                                                                   */
/*  EXIT-ERROR:  None   FALSE - number failed conversion             */
/*                                                                   */
/*  SIDE EFFECTS: None.                                              */
/*                                                                   */
/*  INTERNAL REFERENCES: None.                                       */
/*                                                                   */
/*  EXTERNAL REFERENCES: None.                                       */
/*                                                                   */
/*                                                                   */
/*********************************************************************/
.pa
/************ SUBROUTINE: vArgParse PSUEDO CODE (BEGIN)     **********/
/*                                                                   */
/* vCnvNum(str,numdigits,lolimit,hilimit,retnum,exterr)              */
/*                                                                   */
/*    save location of begin of string                               */
/*    prime returned number to zero                                  */
/*    set type of error indicator                                    */
/*    get length of string                                           */
/*    eat space characters                                           */
/*    and increment string begin                                     */
/*    pointer to the first non                                       */
/*    blank character                                                */
/*    if pointer not at end of string                                */
/*    then                                                           */
/*      get the current len of string now                            */
/*      search string for first character that                       */
/*      is non zero incrementing the string                          */
/*      begin pointer to the first non zero                          */
/*      character.                                                   */
/*      if pointer not at end of string                              */
/*      then                                                         */
/*        if number of characters left is > 0                        */
/*        then                                                       */
/*          search for any punctuation character                     */
/*            and reset the end string pointer                       */
/*            to this char position                                  */
/*          test for number being too big in number                  */
/*            of characters desired to translate                     */
/*          save begin position of number                            */
/*            count total number of digits                           */
/*          if all digits                                            */
/*          then                                                     */
/*            if number digitis > 4 or GT number                     */
/*               digits requested                                    */
/*            then                                                   */
/*              if more digits than single word                      */
/*              then                                                 */
/*                set error return to overflow error                 */
/*                set error found                                    */
/*              else                                                 */
/*                perform long convert since 5 digits                */
/*                may convert to number GT single word               */
/*                if number converted <= single word                 */
/*                then                                               */
/*                  perform single word conversion                   */
/*                    for returned number                            */
/*                else                                               */
/*                  set error return to overflow error               */
/*                  set error found                                  */
/*                endif                                              */
/*            else                                                   */
/*               perform single word conversion                      */
/*                 for returned number                               */
/*            endif                                                  */
/************ SUBROUTINE: vCnvNum   PSUEDO CODE (CONTINUED) **********/
.pa
/************ SUBROUTINE: vCnvNum   PSUEDO CODE (CONTINUED) **********/
/*            if no errors in conversion                             */
/*            then                                                   */
/*              if value of number converted not equal to 0          */
/*              then                                                 */
/*                if lolimit not = 0 and hilimit not = 0             */
/*                then                                               */
/*                  if value of returned number                      */
/*                    >= lolimit and <= hilimit                      */
/*                  then                                             */
/*                    set flag that this is a good number            */
/*                  else                                             */
/*                    set error for out of range number              */
/*                  endif                                            */
/*                else                                               */
/*                  set return flag good for overall conversion      */
/*                endif                                              */
/*              else                                                 */
/*                set error for conversion problem                   */
/*              endif                                                */
/*            endif                                                  */
/*          else                                                     */
/*            set error for overflow occurred                        */
/*          endif                                                    */
/*        else                                                       */
/*          if number of digits = 0                                  */
/*          then                                                     */
/*            set error for underflow                                */
/*          else                                                     */
/*            set error for overflow                                 */
/*          endif                                                    */
/*        endif                                                      */
/*      else                                                         */
/*        set error for underflow                                    */
/*      endif                                                        */
/*    else                                                           */
/*      set error for number is all blanks                           */
/*    endif                                                          */
/*  return status of overall conversion                              */
/*                                                                   */
/************ SUBROUTINE: vArgParse PSUEDO CODE (END)       **********/
.pa
