home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / sd386v50.zip / sd386src.zip / PRNTTYPS.C < prev    next >
Text File  |  1994-05-27  |  58KB  |  1,582 lines

  1. #include "all.h"
  2.  
  3. #include "prnttyps.h"
  4.  
  5. #define GOODRECORD  0
  6. #define BADRECORD   1
  7.  
  8. uchar  DebugVersion;
  9.  
  10. extern void   dumptext( char *, UINT);
  11. extern void   dumpline( char *, UINT);
  12. extern void   dumphbuf( char *, UINT, UINT);
  13. extern void   dumphlin( char *, UINT);
  14. extern void   dumphex( UCHAR);
  15. extern void   PrintRegType( UINT);
  16. void   PrintTypeIndex( ushort );
  17.  
  18. static uint  Prt_HLF_Span(uchar **, uchar *, uchar *, uchar);
  19. static uint  Prt_HLF_Text(uchar **, uchar *, uchar *);
  20. static uint  Prt_HLF_Index(uchar **, uchar *, uchar *);
  21. static uint  Prt_HLF_Index2(uchar **, uchar *, uchar *);
  22. static uint  Prt_HLF_String(uchar **, uchar *, uchar *);
  23. static uint  Prt_HLF_String2(uchar **, uchar *, uchar *);
  24. static uint  Prt_HLF_Precision(uchar **, uchar *, uchar *, uchar *);
  25.  
  26. void   DumpModules( char *, int, FILE *, long * );
  27. void   DumpModule( FILE *, ulong, ulong );
  28.  
  29. void PrtHLType( UCHAR *, UCHAR *);
  30. FILE *ostream;                         /* text-style output                  */
  31.  
  32. typedef union                          /* input options from user            */
  33.   {                                    /* what to display                    */
  34.     struct                             /* if bit set then show it            */
  35.     {
  36.        UINT h :1;                       /* header (t.o.c.)                    */
  37.        UINT f :1;                       /* files & libs                       */
  38.        UINT p :1;                       /* pubs                               */
  39.        UINT t :1;                       /* types                              */
  40.        UINT s :1;                       /* symbols                            */
  41.        UINT y :1;                       /* symbols - old format               */
  42.        UINT l :1;                       /* line nums                          */
  43.        UINT x :1;                       /* hex output                     1.01*/
  44.        UINT q :1;                       /* dump debug info stats              */
  45.        UINT o :1;                       /* option specified                   */
  46.        UINT z :1;                       /* invalid option                     */
  47.     } opt;
  48.     UINT  w;
  49.   } options;
  50.        options o;                      /* input options from user            */
  51. #define MAXNAMELENX 60
  52.  
  53. /****** PrtHLType ************************************************************/
  54. /*                                                                           */
  55. /*  Description:                                                             */
  56. /*      print to output stream                                               */
  57. /*                                                                           */
  58. /*  Parameters:                                                              */
  59. /*                                                                           */
  60. /*  Returns:                                                                 */
  61. /*      void                                                                 */
  62. /*                                                                           */
  63. /*  Global Data:                                                             */
  64. /*      o - options specified by user                                        */
  65. /*                                                                           */
  66. /*****************************************************************************/
  67.  
  68. void  PrtHLType( uchar *TempBufPtr, uchar *TempBufEnd)
  69. {
  70.   uint    TypeIndex = 512;              /* convention: 512=1st $$TYPES index  */
  71.   uchar  *p, *pend, TypeQual, Type, flag, Name[20];
  72.   uint    n, itemcount, i;
  73.   uint    BadRecord;
  74.   uint    totn;                        /* total number of bytes in rec   1.01*/
  75.  
  76.   ostream = fopen( "types.dmp", "a" );
  77.   fprintf(ostream, "\n\nType information\n");
  78.   fprintf(ostream, "================\n");
  79.  
  80.   fprintf(ostream, "\n");
  81.   while (TempBufPtr < TempBufEnd)
  82.     {
  83.       fprintf(ostream, " %5u)", TypeIndex++);  /* move to line up        1.01*/
  84.       BadRecord = FALSE;
  85.  
  86.       if (TempBufPtr + sizeof(HLTrec2) - 1 > TempBufEnd)
  87.         {
  88.           fclose( ostream );
  89.           return;
  90.         }
  91.         n = (uint)(((HLTrec2 *)TempBufPtr)->reclen);
  92.         p = TempBufPtr + 2;
  93.  
  94.       totn = n;
  95.  
  96.       /*
  97.       ** make sure we don't have a record that exceeds what we're supposed
  98.       ** to display.  If so, then dump the rest of the type information.
  99.       */
  100.       if (p + n > TempBufEnd)
  101.         {
  102.           fprintf(ostream, " ");
  103.           dumptext(TempBufPtr, TempBufEnd-TempBufPtr);
  104.           fprintf(ostream, "\n");
  105.           return;
  106.         }
  107.  
  108.       /* setup type record end */
  109.       pend = p + n;
  110.  
  111.       Type = *(p);
  112.       /* setup type qualifier */
  113.       TypeQual = *(p+1);
  114.       /* point to sub-record data */
  115.       p += 2;
  116.  
  117. /*       don't skip recs with length 1 - handle as usual 1.03
  118.       check to see if we have a primitive or a complex type
  119.       if (n == 1)
  120.         {
  121.           fprintf(ostream, " 0x%X\n", Type);
  122.           goto SkipTypeRecord;
  123.         }
  124. */
  125.  
  126.       /* check for type in the table, if we find it then print type name */
  127.       for (i=0; i<NoOfHLTRecs; i++)
  128.         {
  129.           if (Type == recordtype[i].code)
  130.             {
  131.               fprintf(ostream, " %s:", recordtype[i].name);
  132.               break;
  133.             }
  134.         }
  135.  
  136.       /* check to see if didn't find the type in the table */
  137.       if (i == NoOfHLTRecs)
  138.       {
  139.         fprintf( ostream, "\n" );
  140.         goto SkipTypeRecord;
  141.       }
  142.  
  143.       /* print out sub-record specific data */
  144.       switch (Type)
  145.         {
  146.           case HLT_ARRAY:              /* array                              */
  147.               if (TypeQual & 0x01)
  148.                 fprintf(ostream, " ColMjr");
  149.               else
  150.                 fprintf(ostream, " RowMjr");
  151.  
  152.               if (TypeQual & 0x02)
  153.                 fprintf(ostream, " Packed");
  154.               else
  155.                 fprintf(ostream, " Unpacked");
  156.  
  157.               if (TypeQual & 0x04)
  158.                 fprintf(ostream, " Desc-prov");
  159.               else
  160.                 fprintf(ostream, " No-Desc-Req");
  161.  
  162.               if (p + 4 > pend)
  163.                 goto DumpTypeRecord;
  164.  
  165.               fprintf(ostream, " Bytes:%lu", *(DWORD *)p);
  166.               p += 4;
  167.  
  168.               if (BadRecord = Prt_HLF_Index(&p, pend, "Bounds"))
  169.                 goto DumpTypeRecord;
  170.               if (BadRecord = Prt_HLF_Index(&p, pend, "Type"))
  171.                 goto DumpTypeRecord;
  172.               BadRecord = Prt_HLF_String(&p, pend,
  173.                                          "\n                  Name");
  174.               break;
  175.  
  176.           case HLT_BASECLASS:           /* baseclass                          */
  177. #if 0
  178.               if (TypeQual & 0x01)
  179.                 fprintf(ostream, " Is-virtual");
  180.               else
  181.                 fprintf(ostream, " Not-virtual");
  182.  
  183.               if (p + 1 > pend)
  184.                 goto DumpTypeRecord;
  185.  
  186.               fprintf(ostream, " Prot:");
  187.               switch (*p)
  188.                 {
  189.                   case 0:
  190.                     fprintf(ostream, "private");
  191.                     break;
  192.                   case 1:
  193.                     fprintf(ostream, "protected");
  194.                     break;
  195.                   case 2:
  196.                     fprintf(ostream, "public");
  197.                     break;
  198.                   default:
  199.                     goto DumpTypeRecord;
  200.                 }
  201.               p += 1;
  202.  
  203.               if (BadRecord = Prt_HLF_Index2(&p, pend, "Type"))
  204.                 goto DumpTypeRecord;
  205.               if (BadRecord = Prt_HLF_Span(&p, pend, "Offset"))
  206.                 goto DumpTypeRecord;
  207. #endif
  208.               break;
  209.  
  210.           case HLT_BITSTRING:          /* bit string                         */
  211.  
  212.               if (TypeQual & 0x01)
  213.                 {
  214.                   fprintf(ostream, " Varying");
  215.                   strcpy(Name, "MaxSize");
  216.                 }
  217.               else
  218.                 {
  219.                   fprintf(ostream, " Fixed");
  220.                   strcpy(Name, "Size");
  221.                 }
  222.  
  223.               if (TypeQual & 0x02)
  224.                 fprintf(ostream, " Signed");
  225.               else
  226.                 fprintf(ostream, " Unsigned");
  227.  
  228.               if (TypeQual & 0x04)
  229.                 fprintf(ostream, " Word-Align");
  230.               else
  231.                 fprintf(ostream, " Byte-Align");
  232.  
  233.               if (TypeQual & 0x08)
  234.                 fprintf(ostream, " Displ-as-Value");
  235.               else
  236.                 fprintf(ostream, " Displ-as-0/1-Str");
  237.  
  238.               if (TypeQual & 0x10)
  239.                 fprintf(ostream, " Desc-prov");
  240.               else
  241.                 {
  242.                   fprintf(ostream, " No-Desc-Req");
  243.                   fprintf(ostream, "\n                  Offset:%u", *(BYTE *)p);
  244.                   p += 1;
  245.                   BadRecord = Prt_HLF_Span(&p, pend, Name, 1);
  246.                 }
  247.                 p += 1;                 /* get past base type field.         */
  248.               break;
  249.  
  250. #if 0
  251.           case HLT_CHARSTRING:         /* character string                   */
  252.               switch (TypeQual)
  253.                 {
  254.                   case 0x00:
  255.                     fprintf(ostream, " fixed");
  256.                     BadRecord = Prt_HLF_Span(&p, pend, "Size");
  257.                     break;
  258.                   case 0x01:
  259.                     fprintf(ostream, " len-prfx");
  260.                     BadRecord = Prt_HLF_Span(&p, pend, "MaxSize");
  261.                     break;
  262.                   case 0x02:
  263.                     fprintf(ostream, " adjustable");
  264.                     break;
  265.                   case 0x03:
  266.                     fprintf(ostream, " null-term");
  267.                     BadRecord = Prt_HLF_Span(&p, pend, "MaxSize");
  268.                     break;
  269.                   case 0x04:
  270.                     fprintf(ostream, " DBCS");
  271.                     BadRecord = Prt_HLF_Span(&p, pend, "MaxSize");
  272.                     break;
  273.                   case 0x05:
  274.                     fprintf(ostream, " DBCS-edited");
  275.                     break;
  276.                   default:
  277.                     /*
  278.                     ** bad type qualifier, move pointer back and display
  279.                     ** from type qualifier to the end of the record
  280.                     */
  281.                     p--;
  282.                     break;
  283.                 }
  284.               break;
  285.  
  286.           case HLT_CLASS:               /* class                              */
  287.               if (TypeQual & 0x01)
  288.                 fprintf(ostream, " Is-a-struct");
  289.               else
  290.                 fprintf(ostream, " Not-a-struct");
  291.  
  292.               if (p + 4 > pend)
  293.                 goto DumpTypeRecord;
  294.  
  295.               fprintf(ostream, " Bytes:%lu", *(DWORD *)p);
  296.               p += 4;
  297.  
  298.               if (p + 2 > pend)
  299.                 goto DumpTypeRecord;
  300.  
  301.               fprintf(ostream, " N:%u", *(WORD *)p);
  302.               p += 2;
  303.  
  304.               if (BadRecord = Prt_HLF_Index2(&p, pend, "ItemList"))
  305.                 goto DumpTypeRecord;
  306.               BadRecord = Prt_HLF_String2(&p, pend, "Name");
  307.  
  308.               #ifdef STATS
  309.               TypeStringSize[Type] += TempStringSize;
  310.               #endif /* STATS */
  311.               break;
  312.           case HLT_CLASS_DEF:           /* class definition                   */
  313.               if (p + 1 > pend)
  314.                 goto DumpTypeRecord;
  315.  
  316.               fprintf(ostream, " Prot:");
  317.               switch (*p)
  318.                 {
  319.                   case 0:
  320.                     fprintf(ostream, "private");
  321.                     break;
  322.                   case 1:
  323.                     fprintf(ostream, "protected");
  324.                     break;
  325.                   case 2:
  326.                     fprintf(ostream, "public");
  327.                     break;
  328.                   default:
  329.                     goto DumpTypeRecord;
  330.                 }
  331.               p += 1;
  332.  
  333.               if (BadRecord = Prt_HLF_Index2(&p, pend, "Type"))
  334.                 goto DumpTypeRecord;
  335.               if (DebugVersion >= 0x03)
  336.                 {
  337.                   if (BadRecord = Prt_HLF_Index2(&p, pend, "DefClass"))
  338.                     goto DumpTypeRecord;
  339.                 }
  340.               break;
  341.           case HLT_CLASS_MEMBER:        /* class member                       */
  342.               if (TypeQual & 0x01)
  343.                 fprintf(ostream, " is-static");
  344.               else
  345.                 fprintf(ostream, " not-static");
  346.  
  347.               if (TypeQual & 0x02)
  348.                 fprintf(ostream, " is-vtbl-ptr");
  349.               else
  350.                 fprintf(ostream, " not-vtbl-ptr");
  351.  
  352.               if (TypeQual & 0x04)
  353.                 fprintf(ostream, " is-vbase-ptr");
  354.               else
  355.                 fprintf(ostream, " not-vbase-ptr");
  356.  
  357.               if (TypeQual & 0x08)
  358.                 fprintf(ostream, " const");
  359.               else
  360.                 fprintf(ostream, " non-const");
  361.  
  362.               if (TypeQual & 0x10)
  363.                 fprintf(ostream, " volatile");
  364.               else
  365.                 fprintf(ostream, " non-volatile");
  366.  
  367.               if (p + 1 > pend)
  368.                 goto DumpTypeRecord;
  369.  
  370.               fprintf(ostream, "\n                  Prot:");
  371.               switch (*p)
  372.                 {
  373.                   case 0:
  374.                     fprintf(ostream, "private");
  375.                     break;
  376.                   case 1:
  377.                     fprintf(ostream, "protected");
  378.                     break;
  379.                   case 2:
  380.                     fprintf(ostream, "public");
  381.                     break;
  382.                   default:
  383.                     goto DumpTypeRecord;
  384.                 }
  385.               p += 1;
  386.  
  387.               if (BadRecord = Prt_HLF_Index2(&p, pend, "Type"))
  388.                 goto DumpTypeRecord;
  389.               if (BadRecord = Prt_HLF_Span(&p, pend, "Offset"))
  390.                 goto DumpTypeRecord;
  391.               if (BadRecord = Prt_HLF_String2(&p, pend, "Name"))
  392.                 goto DumpTypeRecord;
  393.  
  394.               #ifdef STATS
  395.               TypeStringSize[Type] += TempStringSize;
  396.               #endif /* STATS */
  397.  
  398.               BadRecord = Prt_HLF_String2(&p, pend, "Name");
  399.  
  400.               #ifdef STATS
  401.               TypeStringSize[Type] += TempStringSize;
  402.               #endif /* STATS */
  403.               break;
  404.           case HLT_CODELABEL:          /* code label                         */
  405.           case HLT_FORMATLABEL:        /* format label                       */
  406.               switch (TypeQual & 0x03)
  407.                 {
  408.                   case 0x00:
  409.                     fprintf(ostream, " offset-16");
  410.                     break;
  411.                   case 0x01:
  412.                     fprintf(ostream, " offset-32");
  413.                     break;
  414.                   case 0x02:
  415.                     fprintf(ostream, " segment-32");
  416.                     break;
  417.                   case 0x03:
  418.                     fprintf(ostream, " segment-48");
  419.                     break;
  420.                 }
  421.               break;
  422. #endif
  423.           case HLT_ENTRY:              /* entry                              */
  424.           case HLT_FUNCTION:           /* function                           */
  425.           case HLT_PROCEDURE:          /* procedure                          */
  426.               if (TypeQual & 0x01)
  427.                 fprintf(ostream, " Args(Pushed R->L");
  428.               else
  429.                 fprintf(ostream, " Args(Pushed L->R");
  430.  
  431.               if (TypeQual & 0x02)
  432.                 fprintf(ostream, ", Caller Pops)");
  433.               else
  434.                 fprintf(ostream, ", Callee Pops)");
  435.  
  436.               switch (TypeQual & 0x0C)
  437.                 {
  438.                   case 0x00:
  439.                     fprintf(ostream, " offset-16");
  440.                     break;
  441.                   case 0x04:
  442.                     fprintf(ostream, " offset-32");
  443.                     break;
  444.                   case 0x08:
  445.                     fprintf(ostream, " segment-32");
  446.                     break;
  447.                   case 0x0C:
  448.                     fprintf(ostream, " segment-48");
  449.                     break;
  450.                 }
  451.  
  452.               if (p + 2 > pend)
  453.                 goto DumpTypeRecord;
  454.  
  455.               fprintf(ostream, " Args:%u", *(WORD *)p);
  456.               p += 2;
  457.  
  458.               if (p + 2 > pend)
  459.                 goto DumpTypeRecord;
  460.  
  461.               fprintf(ostream, " MaxArgs:%u", *(WORD *)p);
  462.               p += 2;
  463.  
  464.               if (BadRecord = Prt_HLF_Index(&p, pend,
  465.                                             "\n                  RetType"))
  466.                 goto DumpTypeRecord;
  467.               BadRecord = Prt_HLF_Index(&p, pend, "TypeList");
  468.               break;
  469.  
  470.           case HLT_SCALAR:
  471.               p--;
  472.               if (BadRecord = Prt_HLF_Index(&p, pend, "Type"))
  473.                 goto DumpTypeRecord;
  474.               break;
  475.  
  476.           case HLT_ENUM:               /* enumerated                         */
  477.               p--;
  478.               if (BadRecord = Prt_HLF_Index(&p, pend, "Type"))
  479.                 goto DumpTypeRecord;
  480.               if (BadRecord = Prt_HLF_Index(&p, pend, "NdxLst"))
  481.                 goto DumpTypeRecord;
  482.               if (BadRecord = Prt_HLF_Span(&p, pend, "MinNdx", 4))
  483.                 goto DumpTypeRecord;
  484.               if (BadRecord = Prt_HLF_Span(&p, pend, "MaxNdx", 4))
  485.                 goto DumpTypeRecord;
  486.               BadRecord = Prt_HLF_String(&p, pend, "Name");
  487.               break;
  488.  
  489.           case HLT_FILE:               /* file                               */
  490.               break;
  491. #if 0
  492.           case HLT_FRIEND:             /* friend                             */
  493.               if (TypeQual & 0x01)
  494.                 fprintf(ostream, " Friend-class");
  495.               else
  496.                 fprintf(ostream, " Friend-fcn");
  497.  
  498.               if (BadRecord = Prt_HLF_Index2(&p, pend, "Type"))
  499.                 goto DumpTypeRecord;
  500.               BadRecord = Prt_HLF_String2(&p, pend, "Name");
  501.  
  502.               #ifdef STATS
  503.               TypeStringSize[Type] += TempStringSize;
  504.               #endif /* STATS */
  505.               break;
  506.           case HLT_GRAPHIC:            /* graphic                            */
  507.               switch (TypeQual)
  508.                 {
  509.                   case 0x00:
  510.                     fprintf(ostream, " fixed");
  511.                     BadRecord = Prt_HLF_Span(&p, pend, "Size");
  512.                     break;
  513.                   case 0x01:
  514.                     fprintf(ostream, " len-prfx");
  515.                     BadRecord = Prt_HLF_Span(&p, pend, "MaxSize");
  516.                     break;
  517.                   case 0x02:
  518.                     fprintf(ostream, " adjustable");
  519.                     break;
  520.                   default:
  521.                     /*
  522.                     ** bad type qualifier, move pointer back and display
  523.                     ** from type qualifier to the end of the record
  524.                     */
  525.                     p--;
  526.                     break;
  527.                 }
  528.               break;
  529. #endif
  530.           case HLT_LIST:               /* list                               */
  531.               itemcount = 0;
  532.               switch (TypeQual)
  533.                 {
  534.                   case 0x01:           /* list of types                      */
  535.                     while (!BadRecord && (p < pend))
  536.                       {
  537.                         itemcount++;
  538.                         /* can usually fit 5 list types per line */
  539.                         if ((itemcount % 6) == 0)
  540.                           {
  541.                             fprintf(ostream, "\n                 ");
  542.                             itemcount = 1;
  543.                           }
  544.                         BadRecord = Prt_HLF_Index(&p, pend, "Type");
  545.                       }
  546.                     break;
  547.  
  548.                   case 0x02:           /* list of name-offsets               */
  549.                     while (!BadRecord && (p < pend))
  550.                       {
  551.                         itemcount++;
  552.                         /* can usually fit 3 list name/offsets per line */
  553.                         if ((itemcount % 4) == 0)
  554.                           {
  555.                             fprintf(ostream, "\n                 ");
  556.                             itemcount = 1;
  557.                           }
  558.                         if (BadRecord = Prt_HLF_String(&p, pend, "Name"))
  559.                           goto DumpTypeRecord;
  560.  
  561.                         BadRecord = Prt_HLF_Span(&p, pend, "Offset", 4);
  562.                         fprintf(ostream, " ");
  563.                       }
  564.                     break;
  565.                   case 0x03:           /* list of name-indexes               */
  566. #if 0
  567.                     while (!BadRecord && (p < pend))
  568.                       {
  569.                         itemcount++;
  570.                         /* can usually fit 5 list name-indexes per line */
  571.                         if ((itemcount % 6) == 0)
  572.                           {
  573.                             fprintf(ostream, "\n                 ");
  574.                             itemcount = 1;
  575.                           }
  576.                         if (BadRecord = Prt_HLF_String(&p, pend, "Name"))
  577.                           goto DumpTypeRecord;
  578.  
  579.                         BadRecord = Prt_HLF_Span(&p, pend, "Ndx");
  580.                         fprintf(ostream, " ");
  581.                       }
  582. #endif
  583.                     break;
  584.                   case 0x04:           /* list of parameter types            */
  585. #if 0
  586.                     while (!BadRecord && (p < pend))
  587.                       {
  588.                         itemcount++;
  589.                         /* can usually fit 3 list parameter types per line */
  590.                         if ((itemcount % 4) == 0)
  591.                           {
  592.                             fprintf(ostream, "\n                 ");
  593.                             itemcount = 1;
  594.                           }
  595.                         flag = *p++;
  596.                         if (BadRecord = Prt_HLF_Index(&p, pend, "Type"))
  597.                           goto DumpTypeRecord;
  598.  
  599.                         if (flag & 0x01)
  600.                           fprintf(ostream, " (Val,");
  601.                         else
  602.                           fprintf(ostream, " (Addr,");
  603.  
  604.                         if (flag & 0x02)
  605.                           fprintf(ostream, " Dsc-Prov)");
  606.                         else
  607.                           fprintf(ostream, " No-Dsc-Req)");
  608.  
  609.                         fprintf(ostream, " ");
  610.                       }
  611. #endif
  612.                     break;
  613.                   default:
  614.                     /*
  615.                     ** bad type qualifier, move pointer back and display
  616.                     ** from type qualifier to the end of the record
  617.                     */
  618.                     p--;
  619.                     break;
  620.                 }
  621.               break;
  622. #if 0
  623.           case HLT_LOGICAL:            /* logical                            */
  624.               switch (TypeQual)
  625.                 {
  626.                   case 0x01:
  627.                     fprintf(ostream, " (Fortran 4)");
  628.                     break;
  629.                   case 0x02:
  630.                     fprintf(ostream, " (Fortran 1)");
  631.                     break;
  632.                   case 0x04:
  633.                     fprintf(ostream, " (RPG)");
  634.                     break;
  635.                   default:
  636.                     /*
  637.                     ** bad type qualifier, move pointer back and display
  638.                     ** from type qualifier to the end of the record
  639.                     */
  640.                     p--;
  641.                     break;
  642.                 }
  643.               break;
  644.           case HLT_MACRO:              /* macro                              */
  645.               /* don't do anything with macros yet */
  646.               break;
  647.           case HLT_MEMBER_FUNCTION:     /* member function                    */
  648.               if (DebugVersion >= 0x03)
  649.                 {
  650.                   fprintf(ostream, " Attr(");
  651.  
  652.                   if (TypeQual & 0x01)
  653.                     fprintf(ostream, "static");
  654.                   else
  655.                     fprintf(ostream, "non-static");
  656.  
  657.                   if (TypeQual & 0x02)
  658.                     fprintf(ostream, ", inline");
  659.                   else
  660.                     fprintf(ostream, ", non-inline");
  661.  
  662.                   if (TypeQual & 0x04)
  663.                     fprintf(ostream, ", const");
  664.                   else
  665.                     fprintf(ostream, ", non-const");
  666.  
  667.                   if (TypeQual & 0x08)
  668.                     fprintf(ostream, ", volatile");
  669.                   else
  670.                     fprintf(ostream, ", non-volatile");
  671.  
  672.                   if (TypeQual & 0x10)
  673.                     fprintf(ostream, "\n                  virtual)");
  674.                   else
  675.                     fprintf(ostream, "\n                  non-virtual)");
  676.  
  677.                   if (p + 1 > pend)
  678.                     goto DumpTypeRecord;
  679.  
  680.                   fprintf(ostream, " Prot:");
  681.                   switch (*p)
  682.                     {
  683.                       case 0:
  684.                         fprintf(ostream, "private");
  685.                         break;
  686.                       case 1:
  687.                         fprintf(ostream, "protected");
  688.                         break;
  689.                       case 2:
  690.                         fprintf(ostream, "public");
  691.                         break;
  692.                       default:
  693.                         goto DumpTypeRecord;
  694.                     }
  695.                   p += 1;
  696.  
  697.                   if (p + 1 > pend)
  698.                     goto DumpTypeRecord;
  699.  
  700.                   fprintf(ostream, " FcnType:");
  701.                   switch (*(BYTE *)p)
  702.                     {
  703.                       case 0:
  704.                         fprintf(ostream, "regular");
  705.                         break;
  706.                       case 1:
  707.                         fprintf(ostream, "constructor");
  708.                         break;
  709.                       case 2:
  710.                         fprintf(ostream, "destructor");
  711.                         break;
  712.                       default:
  713.                         goto DumpTypeRecord;
  714.                     }
  715.                   p += 1;
  716.  
  717.                   if (p + 2 > pend)
  718.                     goto DumpTypeRecord;
  719.  
  720.                   if (BadRecord = Prt_HLF_Index2(&p, pend, "FcnInfo"))
  721.                     goto DumpTypeRecord;
  722.  
  723.                   /* see if we have the virtual bit set                       */
  724.                   if (TypeQual & 0x10)
  725.                     {
  726.                       if (p + 4 > pend)
  727.                         goto DumpTypeRecord;
  728.  
  729.                       if (BadRecord = Prt_HLF_Span(&p, pend,
  730.                                                  "\n                  VirtNo"))
  731.                         goto DumpTypeRecord;
  732.  
  733.                       if (BadRecord = Prt_HLF_String2(&p, pend, "Name"))
  734.                         goto DumpTypeRecord;
  735.                     }
  736.                   else
  737.                     {
  738.                       if (BadRecord = Prt_HLF_String2(&p, pend,
  739.                                                      "\n                  Name"))
  740.                         goto DumpTypeRecord;
  741.                     }
  742.  
  743.                   #ifdef STATS
  744.                   TypeStringSize[Type] += TempStringSize;
  745.                   #endif /* STATS */
  746.                 }
  747.               else
  748.                 {
  749.                   if (TypeQual & 0x01)
  750.                     fprintf(ostream, " Args(Pushed R->L");
  751.                   else
  752.                     fprintf(ostream, " Args(Pushed L->R");
  753.  
  754.                   if (TypeQual & 0x02)
  755.                     fprintf(ostream, ", Caller Pops");
  756.                   else
  757.                     fprintf(ostream, ", Callee Pops");
  758.  
  759.                   switch (TypeQual & 0x0C)
  760.                     {
  761.                       case 0x00:
  762.                         fprintf(ostream, " offset-16");
  763.                         break;
  764.                       case 0x04:
  765.                         fprintf(ostream, " offset-32");
  766.                         break;
  767.                       case 0x08:
  768.                         fprintf(ostream, " segment-32");
  769.                         break;
  770.                       case 0x0C:
  771.                         fprintf(ostream, " segment-48");
  772.                         break;
  773.                     }
  774.  
  775.                   if (TypeQual & 0x10)
  776.                     fprintf(ostream, ", var num parms");
  777.                   else
  778.                     fprintf(ostream, ", fixed num parms");
  779.  
  780.                   if (TypeQual & 0x20)
  781.                     fprintf(ostream, ",\n                  OS/2 call conv)");
  782.                   else
  783.                     fprintf(ostream, ",\n                  priv call conv)");
  784.  
  785.                   if (p + 1 > pend)
  786.                     goto DumpTypeRecord;
  787.  
  788.                   fprintf(ostream, " Prot:");
  789.                   switch (*p)
  790.                     {
  791.                       case 0:
  792.                         fprintf(ostream, "private");
  793.                         break;
  794.                       case 1:
  795.                         fprintf(ostream, "protected");
  796.                         break;
  797.                       case 2:
  798.                         fprintf(ostream, "public");
  799.                         break;
  800.                       default:
  801.                         goto DumpTypeRecord;
  802.                     }
  803.                   p += 1;
  804.  
  805.                   if (p + 1 > pend)
  806.                     goto DumpTypeRecord;
  807.  
  808.                   fprintf(ostream, " FcnType:");
  809.                   switch (*(BYTE *)p)
  810.                     {
  811.                       case 0:
  812.                         fprintf(ostream, "regular");
  813.                         break;
  814.                       case 1:
  815.                         fprintf(ostream, "constructor");
  816.                         break;
  817.                       case 2:
  818.                         fprintf(ostream, "destructor");
  819.                         break;
  820.                       default:
  821.                         goto DumpTypeRecord;
  822.                     }
  823.                   p += 1;
  824.  
  825.                   if (p + 4 > pend)
  826.                     goto DumpTypeRecord;
  827.  
  828.                   fprintf(ostream, " VirtNo:%lu", *(DWORD *)p);
  829.                   p += 4;
  830.  
  831.                   if (p + 1 > pend)
  832.                     goto DumpTypeRecord;
  833.  
  834.                   fprintf(ostream, "\n                  Attr(");
  835.                   {
  836.                     BYTE  attr;
  837.                     attr = *(BYTE *)p;
  838.  
  839.                     if (attr & 0x01)
  840.                       fprintf(ostream, "static");
  841.                     else
  842.                       fprintf(ostream, "non-static");
  843.  
  844.                     if (attr & 0x02)
  845.                       fprintf(ostream, ", inline");
  846.                     else
  847.                       fprintf(ostream, ", non-inline");
  848.  
  849.                     if (attr & 0x04)
  850.                       fprintf(ostream, ", const");
  851.                     else
  852.                       fprintf(ostream, ", non-const");
  853.  
  854.                     if (attr & 0x08)
  855.                       fprintf(ostream, ", volatile");
  856.                     else
  857.                       fprintf(ostream, ", non-volatile");
  858.  
  859.                     if (attr & 0x10)
  860.                       fprintf(ostream, "\n                  virtual)");
  861.                     else
  862.                       fprintf(ostream, "\n                  non-virtual)");
  863.                   }
  864.                   p += 1;
  865.  
  866.                   if (p + 2 > pend)
  867.                     goto DumpTypeRecord;
  868.  
  869.                   fprintf(ostream, " Args:%u", *(WORD *)p);
  870.                   p += 2;
  871.  
  872.                   if (p + 2 > pend)
  873.                     goto DumpTypeRecord;
  874.  
  875.                   fprintf(ostream, " MaxArgs:%u", *(WORD *)p);
  876.                   p += 2;
  877.  
  878.                   if (BadRecord = Prt_HLF_Index(&p, pend, "RetType"))
  879.                     goto DumpTypeRecord;
  880.  
  881.                   if (BadRecord = Prt_HLF_Index(&p, pend, "TypeList"))
  882.                     goto DumpTypeRecord;
  883.  
  884.                   if (BadRecord = Prt_HLF_String(&p, pend,
  885.                                                  "\n                  Name"))
  886.                     goto DumpTypeRecord;
  887.  
  888.                   #ifdef STATS
  889.                   TypeStringSize[Type] += TempStringSize;
  890.                   #endif /* STATS */
  891.  
  892.                   if (BadRecord = Prt_HLF_Text(&p, pend, "Body"))
  893.                     goto DumpTypeRecord;
  894.                 }
  895.               break;
  896.           case HLT_MEMBER_POINTER:      /* member pointer                     */
  897.               if (TypeQual & 0x01)
  898.                 fprintf(ostream, " has-vbases");
  899.               else
  900.                 fprintf(ostream, " no-vbases");
  901.  
  902.               if (TypeQual & 0x02)
  903.                 fprintf(ostream, " mult-inh");
  904.               else
  905.                 fprintf(ostream, " no-mult-inh");
  906.  
  907.               if (TypeQual & 0x04)
  908.                 fprintf(ostream, " const");
  909.               else
  910.                 fprintf(ostream, " non-const");
  911.  
  912.               if (TypeQual & 0x08)
  913.                 fprintf(ostream, " volatile");
  914.               else
  915.                 fprintf(ostream, " non-volatile");
  916.  
  917.               if (BadRecord = Prt_HLF_Index(&p, pend,
  918.                                             "\n                  ChildType"))
  919.                 goto DumpTypeRecord;
  920.  
  921.               if (BadRecord = Prt_HLF_Index2(&p, pend, "ClassType"))
  922.                 goto DumpTypeRecord;
  923.  
  924.               if (BadRecord = Prt_HLF_Index2(&p, pend, "RepType"))
  925.                 goto DumpTypeRecord;
  926.               break;
  927.           case HLT_PICTURE:            /* picture                            */
  928.               switch (TypeQual)
  929.                 {
  930.                   case 0x00:
  931.                     fprintf(ostream, " (char)");
  932.  
  933.                     if (p + 2 > pend)
  934.                       goto DumpTypeRecord;
  935.  
  936.                     fprintf(ostream, " Len:%u", *(WORD *)p);
  937.                     p += 2;
  938.                     break;
  939.                   case 0x01:
  940.                     /* don't do this type yet */
  941.                     fprintf(ostream, " (dec arith)");
  942.                     break;
  943.                   default:
  944.                     /*
  945.                     ** bad type qualifier, move pointer back and display
  946.                     ** from type qualifier to the end of the record
  947.                     */
  948.                     p--;
  949.                     break;
  950.                 }
  951.               break;
  952. #endif
  953.           case HLT_POINTER:            /* pointer                            */
  954.               switch (TypeQual & 0x03)
  955.                 {
  956.                   case 0x00:
  957.                     fprintf(ostream, " offset-16");
  958.                     break;
  959.                   case 0x01:
  960.                     fprintf(ostream, " offset-32");
  961.                     break;
  962.                   case 0x02:
  963.                     fprintf(ostream, " segment-32");
  964.                     break;
  965.                   case 0x03:
  966.                     fprintf(ostream, " segment-48");
  967.                     break;
  968.                 }
  969.  
  970.               if (BadRecord = Prt_HLF_Index(&p, pend, "Type"))
  971.                 goto DumpTypeRecord;
  972.               BadRecord = Prt_HLF_String(&p, pend, "Name");
  973.               break;
  974. #if 0
  975.           case HLT_REFERENCE:          /* reference                          */
  976.               if (BadRecord = Prt_HLF_Index2(&p, pend, "Type"))
  977.                 goto DumpTypeRecord;
  978.               break;
  979.  
  980.           case HLT_SCALAR:             /* scalar                             */
  981.               if (TypeQual & 0x01)
  982.                 fprintf(ostream, " Packed");
  983.               else
  984.                 fprintf(ostream, " Unpacked");
  985.  
  986.               if (TypeQual & 0x02)
  987.                 fprintf(ostream, " Complex");
  988.               else
  989.                 fprintf(ostream, " Real");
  990.  
  991.               if (TypeQual & 0x04)
  992.                 fprintf(ostream, " Float");
  993.               else
  994.                 fprintf(ostream, " Fixed");
  995.  
  996.               if (TypeQual & 0x08)
  997.                 fprintf(ostream, " Decimal");
  998.               else
  999.                 fprintf(ostream, " Binary");
  1000.  
  1001.               if (BadRecord = Prt_HLF_Index(&p, pend, "Type"))
  1002.                 goto DumpTypeRecord;
  1003.               BadRecord = Prt_HLF_Precision(&p, pend, "Precision",
  1004.                                             "\n                  ScaleFactor");
  1005.               break;
  1006.           case HLT_SET:                /* set                                */
  1007.               if (BadRecord = Prt_HLF_Index(&p, pend, "Type"))
  1008.                 goto DumpTypeRecord;
  1009.               BadRecord = Prt_HLF_String(&p, pend, "Name");
  1010.  
  1011.               #ifdef STATS
  1012.               TypeStringSize[Type] += TempStringSize;
  1013.               #endif /* STATS */
  1014.               break;
  1015.           case HLT_STACK:              /* stack                              */
  1016.               switch (TypeQual & 0x03)
  1017.                 {
  1018.                   case 0x00:
  1019.                     fprintf(ostream, " offset-16");
  1020.                     break;
  1021.                   case 0x01:
  1022.                     fprintf(ostream, " offset-32");
  1023.                     break;
  1024.                   case 0x02:
  1025.                     fprintf(ostream, " segment-32");
  1026.                     break;
  1027.                   case 0x03:
  1028.                     fprintf(ostream, " segment-48");
  1029.                     break;
  1030.                 }
  1031.  
  1032.               if (p + 4 > pend)
  1033.                 goto DumpTypeRecord;
  1034.  
  1035.               fprintf(ostream, " Bytes:%lu", *(DWORD *)p);
  1036.               p += 4;
  1037.  
  1038.               BadRecord = Prt_HLF_String(&p, pend, "Name");
  1039.  
  1040.               #ifdef STATS
  1041.               TypeStringSize[Type] += TempStringSize;
  1042.               #endif /* STATS */
  1043.               break;
  1044. #endif
  1045.           case HLT_STRUCTURE:          /* structure                          */
  1046.               p--;
  1047.               fprintf(ostream, " Unpacked");
  1048.  
  1049.               if (p + 4 > pend)
  1050.                 goto DumpTypeRecord;
  1051.  
  1052.               fprintf(ostream, " Bytes:%lu", *(DWORD *)p);
  1053.               p += 4;
  1054.  
  1055.               if (p + 2 > pend)
  1056.                 goto DumpTypeRecord;
  1057.  
  1058.               fprintf(ostream, " N:%u", *(WORD *)p);
  1059.               p += 2;
  1060.  
  1061.               if (BadRecord = Prt_HLF_Index(&p, pend, "TypeList"))
  1062.                 goto DumpTypeRecord;
  1063.               if (BadRecord = Prt_HLF_Index(&p, pend, "NameList"))
  1064.                 goto DumpTypeRecord;
  1065.               BadRecord = Prt_HLF_String(&p, pend,
  1066.                                          "\n                  Name");
  1067.               break;
  1068. #if 0
  1069.           case HLT_SUBRANGE:           /* subrange                           */
  1070.               if (BadRecord = Prt_HLF_Index(&p, pend, "Type"))
  1071.                 goto DumpTypeRecord;
  1072.               if (BadRecord = Prt_HLF_Span(&p, pend, "Start"))
  1073.                 goto DumpTypeRecord;
  1074.               if (BadRecord = Prt_HLF_Span(&p, pend, "End"))
  1075.                 goto DumpTypeRecord;
  1076.               BadRecord = Prt_HLF_String(&p, pend, "Name");
  1077.  
  1078.               #ifdef STATS
  1079.               TypeStringSize[Type] += TempStringSize;
  1080.               #endif /* STATS */
  1081.               break;
  1082. #endif
  1083.           case HLT_USERDEF:            /* user-defined                       */
  1084.               p--;
  1085.               if (BadRecord = Prt_HLF_Index(&p, pend, "Type"))
  1086.                 goto DumpTypeRecord;
  1087.               BadRecord = Prt_HLF_String(&p, pend, "Name");
  1088.               break;
  1089.  
  1090.           case HLT_SKIP:               /* Skip                               */
  1091.               p--;
  1092.               fprintf(ostream, " New Index : %d", *(ushort *)p);
  1093.               TypeIndex = *(ushort *)p;
  1094.               p += 2;
  1095.               break;
  1096.  
  1097.           default:
  1098.               fprintf(ostream, "\n");
  1099.               break;
  1100.         }
  1101.  
  1102. DumpTypeRecord:
  1103.       if (p < pend)
  1104.         {
  1105.           fprintf(ostream, " ");
  1106.           dumptext(p, pend-p);
  1107.         }
  1108.       else
  1109.         {
  1110.           fprintf(ostream, "\n");
  1111.           /*
  1112.           ** dump record in hex if hex output wanted
  1113.           ** 1.01
  1114.           */
  1115.           if (o.opt.x)
  1116.             {
  1117.               fprintf(ostream, "                  ");
  1118.               if (DebugVersion >= 0x03)
  1119.                 dumphbuf(TempBufPtr+2, totn, 18);
  1120.               else
  1121.                 dumphbuf(TempBufPtr+3, totn, 18);
  1122.               fprintf(ostream, "\n\n");
  1123.             }
  1124.         }
  1125.  
  1126. SkipTypeRecord:
  1127.         TempBufPtr = (uchar *)NextHLTypeRec2(TempBufPtr);
  1128.     }
  1129.   fclose( ostream );
  1130. }
  1131.  
  1132. /****** Prt_HLF_Span *********************************************************/
  1133. /*                                                                           */
  1134. /*  Description:                                                             */
  1135. /*      Based on the value of the HLF_span, one, two, or four uchars of      */
  1136. /*      signed or unsigned value is extracted.  The pointer pointing at the  */
  1137. /*      FID's is advanced to the next field.                                 */
  1138. /*                                                                           */
  1139. /*  Parameters:                                                              */
  1140. /*      uchar **SubRecPtr           pointer at beginning of field            */
  1141. /*                                                                           */
  1142. /*  Returns:                                                                 */
  1143. /*      long    Value               the value extracted                      */
  1144. /*      0                           Error encountered                        */
  1145. /*                                                                           */
  1146. /*****************************************************************************/
  1147.  
  1148.   static uint
  1149. Prt_HLF_Span (uchar **SubRecPtr, uchar *SubRecEnd, uchar *SpanName, uchar size)
  1150. {
  1151.   if (*SubRecPtr > SubRecEnd)
  1152.     return(BADRECORD);
  1153.  
  1154.   if (*SubRecPtr == SubRecEnd)
  1155.     return(GOODRECORD);
  1156.  
  1157.   switch( size )
  1158.     {
  1159.       case 1:
  1160.         fprintf(ostream, " %s:%hd", SpanName, (short)*(signed char *)(*SubRecPtr));
  1161.         (*SubRecPtr) += 1;
  1162.         return(GOODRECORD);
  1163.  
  1164.       case 2:
  1165.         fprintf(ostream, " %s:%hd", SpanName, *(short *)(*SubRecPtr));
  1166.         (*SubRecPtr) += 2;
  1167.         return(GOODRECORD);
  1168.  
  1169.       case 4:
  1170.         fprintf(ostream, " %s:%hd", SpanName, *(long *)(*SubRecPtr));
  1171.         (*SubRecPtr) += 4;
  1172.         return(GOODRECORD);
  1173.     }
  1174. }
  1175.  
  1176. /****** Prt_HLF_Text *********************************************************/
  1177. /*                                                                           */
  1178. /*  Description:                                                             */
  1179. /*      based on the value of the HLF_span, one, two, or four uchars of      */
  1180. /*      signed or unsigned value is extracted.  the pointer pointing at the  */
  1181. /*      FID's is advanced to the next field.                                 */
  1182. /*                                                                           */
  1183. /*  Parameters:                                                              */
  1184. /*      uchar **SubRecPtr           pointer to start of field                */
  1185. /*                                                                           */
  1186. /*  Returns:                                                                 */
  1187. /*      uint                        good/bad record flag                     */
  1188. /*                                                                           */
  1189. /*  Global Data:                                                             */
  1190. /*                                                                           */
  1191. /*****************************************************************************/
  1192.  
  1193.   static uint
  1194. Prt_HLF_Text (uchar **SubRecPtr, uchar *SubRecEnd, uchar *SpanName)
  1195. {
  1196.   int  SpanLen;
  1197.  
  1198.   if (*SubRecPtr > SubRecEnd)
  1199.     return(BADRECORD);
  1200.  
  1201.   if (*SubRecPtr == SubRecEnd)
  1202.     return(GOODRECORD);
  1203.  
  1204.   switch (*((uchar*)*SubRecPtr))
  1205.     {
  1206.       case HLF_SPAN_8S:
  1207.         /* make sure we won't exceed the record */
  1208.         if ((*SubRecPtr + 2) > SubRecEnd)
  1209.           return(BADRECORD);
  1210.  
  1211.         if (*(char *)(*SubRecPtr+1) < 0)
  1212.           return(BADRECORD);
  1213.  
  1214.         if ((*SubRecPtr + 2 + *(char *)(*SubRecPtr+1)) > SubRecEnd)
  1215.           return(BADRECORD);
  1216.  
  1217.         SpanLen = *(char *)(*SubRecPtr+1);
  1218.  
  1219.         fprintf(ostream, " %s:%.*s", SpanName, SpanLen, (*SubRecPtr+2));
  1220.         (*SubRecPtr) += (2 + *(char *)(*SubRecPtr+1));
  1221.         return(GOODRECORD);
  1222.       case HLF_SPAN_16S:
  1223.         /* make sure we won't exceed the record */
  1224.         if ((*SubRecPtr + 3) > SubRecEnd)
  1225.           return(BADRECORD);
  1226.  
  1227.         if (*(short *)(*SubRecPtr+1) < 0)
  1228.           return(BADRECORD);
  1229.  
  1230.         if ((*SubRecPtr + 3 + *(short *)(*SubRecPtr+1)) > SubRecEnd)
  1231.           return(BADRECORD);
  1232.  
  1233.         SpanLen = *(short *)(*SubRecPtr+1);
  1234.  
  1235.         fprintf(ostream, " %s:%.*s", SpanName, SpanLen, (*SubRecPtr+3));
  1236.         (*SubRecPtr) += (3 + *(short *)(*SubRecPtr+1));
  1237.         return(GOODRECORD);
  1238.       case HLF_SPAN_32S:
  1239.         /* make sure we won't exceed the record */
  1240.         if ((*SubRecPtr + 5) > SubRecEnd)
  1241.           return(BADRECORD);
  1242.  
  1243.         if (*(long *)(*SubRecPtr+1) < 0)
  1244.           return(BADRECORD);
  1245.  
  1246.         if ((*SubRecPtr + 5 + *(long *)(*SubRecPtr+1)) > SubRecEnd)
  1247.           return(BADRECORD);
  1248.  
  1249.         SpanLen = *(long *)(*SubRecPtr+1);
  1250.  
  1251.         fprintf(ostream, " %s:%.*s", SpanName, SpanLen, (*SubRecPtr+5));
  1252.         (*SubRecPtr) += (5 + *(long *)(*SubRecPtr+1));
  1253.         return(GOODRECORD);
  1254.       case HLF_SPAN_8U:
  1255.         /* make sure we won't exceed the record */
  1256.         if ((*SubRecPtr + 2) > SubRecEnd)
  1257.           return(BADRECORD);
  1258.  
  1259.         if ((*SubRecPtr + 2 + *(uchar *)(*SubRecPtr+1)) > SubRecEnd)
  1260.           return(BADRECORD);
  1261.  
  1262.         SpanLen = *(uchar *)(*SubRecPtr+1);
  1263.  
  1264.         fprintf(ostream, " %s:%.*s", SpanName, SpanLen, (*SubRecPtr+2));
  1265.         (*SubRecPtr) += (2 + *(uchar *)(*SubRecPtr+1));
  1266.         return(GOODRECORD);
  1267.       case HLF_SPAN_16U:
  1268.         /* make sure we won't exceed the record */
  1269.         if ((*SubRecPtr + 3) > SubRecEnd)
  1270.           return(BADRECORD);
  1271.  
  1272.         if ((*SubRecPtr + 3 + *(ushort *)(*SubRecPtr+1)) > SubRecEnd)
  1273.           return(BADRECORD);
  1274.  
  1275.         SpanLen = *(ushort *)(*SubRecPtr+1);
  1276.  
  1277.         fprintf(ostream, " %s:%.*s", SpanName, SpanLen, (*SubRecPtr+3));
  1278.         (*SubRecPtr) += (3 + *(ushort *)(*SubRecPtr+1));
  1279.         return(GOODRECORD);
  1280.       case HLF_SPAN_32U:
  1281.         /* make sure we won't exceed the record */
  1282.         if ((*SubRecPtr + 5) > SubRecEnd)
  1283.           return(BADRECORD);
  1284.  
  1285.         if ((*SubRecPtr + 5 + *(ulong *)(*SubRecPtr+1)) > SubRecEnd)
  1286.           return(BADRECORD);
  1287.  
  1288.         SpanLen = *(ulong *)(*SubRecPtr+1);
  1289.  
  1290.         fprintf(ostream, " %s:%.*s", SpanName, SpanLen, (*SubRecPtr+5));
  1291.         (*SubRecPtr) += (5 + *(ulong *)(*SubRecPtr+1));
  1292.         return(GOODRECORD);
  1293.       default:
  1294.         /* we didn't get a Fid Span */
  1295.         return(BADRECORD);
  1296.     }
  1297. }
  1298.  
  1299. /****** Prt_HLF_Index ********************************************************/
  1300. /*                                                                           */
  1301. /*  Description:                                                             */
  1302. /*                                                                           */
  1303. /*  Parameters:                                                              */
  1304. /*      uchar **SubRecPtr           pointer at beginning of field            */
  1305. /*                                                                           */
  1306. /*  Returns:                                                                 */
  1307. /*                                                                           */
  1308. /*****************************************************************************/
  1309.  
  1310.   static uint
  1311. Prt_HLF_Index (uchar **SubRecPtr, uchar *SubRecEnd, uchar *IndexName)
  1312. {
  1313.   if (*SubRecPtr > SubRecEnd)
  1314.     return(BADRECORD);
  1315.  
  1316.   if (*SubRecPtr == SubRecEnd)
  1317.     return(GOODRECORD);
  1318.  
  1319.   /* make sure we won't exceed the record */
  1320.   if ((*SubRecPtr + 2) > SubRecEnd)
  1321.     return(BADRECORD);
  1322.  
  1323.   fprintf(ostream, " %s:", IndexName);
  1324.   PrintTypeIndex(*(ushort *)(*SubRecPtr));
  1325.   (*SubRecPtr) += 2;
  1326.   return(GOODRECORD);
  1327.  
  1328. }
  1329.  
  1330. /****** Prt_HLF_Index2 *******************************************************/
  1331. /*                                                                           */
  1332. /*  Description:                                                             */
  1333. /*                                                                           */
  1334. /*  Parameters:                                                              */
  1335. /*      uchar **SubRecPtr           pointer to start of field                */
  1336. /*                                                                           */
  1337. /*  Returns:                                                                 */
  1338. /*      uint                        good/bad record flag                     */
  1339. /*                                                                           */
  1340. /*  Global Data:                                                             */
  1341. /*                                                                           */
  1342. /*****************************************************************************/
  1343.  
  1344.   static uint
  1345. Prt_HLF_Index2 (uchar **SubRecPtr, uchar *SubRecEnd, uchar *IndexName)
  1346. {
  1347.   if (*SubRecPtr > SubRecEnd)
  1348.     return(BADRECORD);
  1349.  
  1350.   if (*SubRecPtr == SubRecEnd)
  1351.     return(GOODRECORD);
  1352.  
  1353.   /* make sure we won't exceed the record */
  1354.   if ((*SubRecPtr + 2) > SubRecEnd)
  1355.     return(BADRECORD);
  1356.  
  1357.   fprintf(ostream, " %s:", IndexName);
  1358.   PrintTypeIndex(*(ushort *)(*SubRecPtr));
  1359.   (*SubRecPtr) += 2;
  1360.   return(GOODRECORD);
  1361. }
  1362.  
  1363. /****** Prt_HLF_String *******************************************************/
  1364. /*                                                                           */
  1365. /*  Description:                                                             */
  1366. /*                                                                           */
  1367. /*  Parameters:                                                              */
  1368. /*      uchar  **SubRecPtr          pointer at beginning of field            */
  1369. /*      MTETAB  *pMteTabEntry       module table entry pointer               */
  1370. /*                                                                           */
  1371. /*  Returns:                                                                 */
  1372. /*                                                                           */
  1373. /*****************************************************************************/
  1374.  
  1375.   static uint
  1376. Prt_HLF_String (uchar **SubRecPtr, uchar *SubRecEnd, uchar *StringName)
  1377. {
  1378.   ushort NameSpan;
  1379.  
  1380.   #ifdef STATS
  1381.   TempStringSize = 0;
  1382.   #endif /* STATS */
  1383.  
  1384.   if (*SubRecPtr > SubRecEnd)
  1385.     return(BADRECORD);
  1386.  
  1387.   if (*SubRecPtr == SubRecEnd)
  1388.     return(GOODRECORD);
  1389.  
  1390.   if (NameSpan = *(ushort *)(*SubRecPtr))
  1391.     {
  1392.       /* make sure we won't exceed the record */
  1393.       if ((*SubRecPtr + NameSpan + 2) > SubRecEnd)
  1394.         return(BADRECORD);
  1395.  
  1396.       if (NameSpan <= MAXNAMELENX)
  1397.         fprintf(ostream, " %s:%.*s", StringName, NameSpan, *SubRecPtr+2);
  1398.       else
  1399.         fprintf(ostream, " %s:%.*s", StringName, MAXNAMELENX, *SubRecPtr+2);
  1400.     }
  1401.   else
  1402.     fprintf(ostream, " NoName");
  1403.  
  1404.   *SubRecPtr += NameSpan + 2;
  1405.   return(GOODRECORD);
  1406. }
  1407.  
  1408. /****** Prt_HLF_String2 ******************************************************/
  1409. /*                                                                           */
  1410. /*  Description:                                                             */
  1411. /*                                                                           */
  1412. /*  Parameters:                                                              */
  1413. /*      uchar  **SubRecPtr          pointer to start of field                */
  1414. /*      MTETAB  *pMteTabEntry       module table entry pointer               */
  1415. /*                                                                           */
  1416. /*  Returns:                                                                 */
  1417. /*      uint                        good/bad record flag                     */
  1418. /*                                                                           */
  1419. /*  Global Data:                                                             */
  1420. /*                                                                           */
  1421. /*****************************************************************************/
  1422.  
  1423.   static uint
  1424. Prt_HLF_String2 (uchar **SubRecPtr, uchar *SubRecEnd, uchar *StringName)
  1425. {
  1426.   uchar  NameSpan;
  1427.   uchar  NameLen = 1;
  1428.  
  1429.   if (DebugVersion < 0x03)
  1430.     return(Prt_HLF_String(SubRecPtr, SubRecEnd, StringName));
  1431.  
  1432.   #ifdef STATS
  1433.   TempStringSize = 0;
  1434.   #endif /* STATS */
  1435.  
  1436.   if (*SubRecPtr > SubRecEnd)
  1437.     return(BADRECORD);
  1438.  
  1439.   if (*SubRecPtr == SubRecEnd)
  1440.     return(GOODRECORD);
  1441.  
  1442.   if (NameSpan = **SubRecPtr)
  1443.     {
  1444.       if (NameSpan & 0x80)
  1445.         {
  1446.           if (*SubRecPtr + 1 > SubRecEnd)
  1447.             return(BADRECORD);
  1448.  
  1449.           NameSpan = ((NameSpan & 0x80) << 8) + *(*SubRecPtr + 1);
  1450.           NameLen++;
  1451.         }
  1452.  
  1453.       /* make sure we won't exceed the record                                 */
  1454.       if ((*SubRecPtr + NameSpan + NameLen) > SubRecEnd)
  1455.         return(BADRECORD);
  1456.  
  1457.       if (NameSpan <= MAXNAMELENX)
  1458.         fprintf(ostream, " %s:%.*s", StringName, NameSpan, *SubRecPtr+NameLen);
  1459.       else
  1460.         fprintf(ostream, " %s:%.*s", StringName, MAXNAMELENX, *SubRecPtr+NameLen);
  1461.     }
  1462.   else
  1463.     fprintf(ostream, " NoName");
  1464.  
  1465.   #ifdef STATS
  1466.   TempStringSize = NameSpan;
  1467.   if (NameSpan < 128)
  1468.     ShortTypeStrings++;
  1469.   #endif /* STATS */
  1470.  
  1471.   *SubRecPtr += NameSpan + NameLen;
  1472.   return(GOODRECORD);
  1473. }
  1474.  
  1475. /****** Prt_HLF_Precision****************************************************/
  1476. /*                                                                          */
  1477. /*  Description:                                                            */
  1478. /*                                                                          */
  1479. /*  Parameters:                                                             */
  1480. /*      uchar **SubRecPtr           pointer at beginning of field           */
  1481. /*                                                                          */
  1482. /*  Returns:                                                                */
  1483. /*                                                                          */
  1484. /****************************************************************************/
  1485.  
  1486.   static uint
  1487. Prt_HLF_Precision (uchar **SubRecPtr, uchar *SubRecEnd, uchar *PrecisionName,
  1488.                    uchar *ScaleName)
  1489. {
  1490.   uchar  Precision;
  1491.  
  1492.   if (*SubRecPtr > SubRecEnd)
  1493.     return(BADRECORD);
  1494.  
  1495.   if (*SubRecPtr == SubRecEnd)
  1496.     return(GOODRECORD);
  1497.  
  1498.   if (*((uchar *)*SubRecPtr) == HLF_PRECISION)
  1499.     {
  1500.       /* make sure we won't exceed the record */
  1501.       if ((*SubRecPtr + 3) > SubRecEnd)
  1502.         return(BADRECORD);
  1503.  
  1504.       fprintf(ostream, " %s:%u", PrecisionName, *(uchar *)(*SubRecPtr+1));
  1505.       fprintf(ostream, " %s:%hd", ScaleName, (short)(*(uchar *)(*SubRecPtr+2) - 128));
  1506.       *SubRecPtr += 3;
  1507.       return(GOODRECORD);
  1508.     }
  1509.   else
  1510.     {
  1511.       /* we didn't get a Fid Precision */
  1512.       return(BADRECORD);
  1513.     }
  1514. }
  1515.  
  1516. /****** PrintTypeIndex *******************************************************/
  1517. /*                                                                           */
  1518. /*  Description:                                                             */
  1519. /*      print to output stream                                               */
  1520. /*                                                                           */
  1521. /*  Parameters:                                                              */
  1522. /*                                                                           */
  1523. /*  Returns:                                                                 */
  1524. /*      void                                                                 */
  1525. /*                                                                           */
  1526. /*  Global Data:                                                             */
  1527. /*                                                                           */
  1528. /*****************************************************************************/
  1529.  
  1530.   void
  1531. PrintTypeIndex (ushort n)
  1532. {
  1533.  
  1534.   typedef struct recsymnames
  1535.     {
  1536.       int     code;
  1537.       char    name[20];
  1538.     };
  1539.  
  1540. static struct recsymnames
  1541.        PrimTypeNames[9] = {
  1542.            0x80,   "CHAR",
  1543.            0x81,   "SHORT",
  1544.            0x82,   "LONG",
  1545.            0x84,   "UCHAR",
  1546.            0x85,   "USHORT",
  1547.            0x86,   "ULONG",
  1548.            0x88,   "FLOAT",
  1549.            0x89,   "DOUBLE",
  1550.            0x97,   "VOID"
  1551.   };
  1552.  
  1553.   uchar *cp;
  1554.   ushort baseN, primN, i;
  1555.  
  1556.   baseN = (n & 0x0060) >> 5;
  1557.   primN = n & 0xFF9F;
  1558.  
  1559.   for (i=0; i<9; i++)
  1560.     {
  1561.       if (primN == PrimTypeNames[i].code)
  1562.         {
  1563.           fprintf(ostream, "%s", PrimTypeNames[i].name);
  1564.           switch (baseN)
  1565.             {
  1566.               case 0x01:
  1567.                 fprintf(ostream, "* NEAR");
  1568.                 break;
  1569.               case 0x02:
  1570.                 fprintf(ostream, "* FAR");
  1571.                 break;
  1572.               case 0x03:
  1573.                 fprintf(ostream, "* HUGE");
  1574.                 break;
  1575.             }
  1576.           return;
  1577.         }
  1578.     }
  1579.  
  1580.   fprintf(ostream, "%u", n);
  1581. }
  1582.