home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / sd386v50.zip / sd386src.zip / ZOOMDATA.C < prev   
Text File  |  1996-05-16  |  54KB  |  881 lines

  1. /*****************************************************************************/
  2. /* File:                                             IBM INTERNAL USE ONLY   */
  3. /*   zoomdata.c                                                              */
  4. /*                                                                           */
  5. /* Description:                                                              */
  6. /*   expand data records in the data window.                                 */
  7. /*                                                                           */
  8. /*                                                                           */
  9. /* History:                                                                  */
  10. /*                                                                           */
  11. /*   02/08/91 Creation of 32-bit SD86, from 16-bit version.                  */
  12. /*                                                                           */
  13. /*****************************************************************************/
  14.  
  15. #include "all.h"
  16. static int iview=0;
  17.  
  18. extern uint        TopLine;
  19. extern KEY2FUNC    defk2f[];
  20. extern uint        DstatRow;
  21. extern uint        VideoRows;
  22. extern uint        TopLine;
  23. extern uint        LinesPer;
  24. extern uint        LinesPer;
  25. extern UINT        FnameRow;
  26.  
  27. /*****************************************************************************/
  28. /*  zoomrec()                                                                */
  29. /*                                                                           */
  30. /* Description:                                                              */
  31. /*   expand a data window record within a dfile node.                        */
  32. /*                                                                           */
  33. /* Parameters:                                                               */
  34. /*                                                                           */
  35. /*   fp        input - the afile for this dfile node.                        */
  36. /*   dfp       input - -> to the dfile node.                                 */
  37. /*   mem       input - the member within the dfile node.                     */
  38. /*                     = 1 for primitive types                               */
  39. /*                     = ? for complex types.                                */
  40. /*                                                                           */
  41. /* Return:                                                                   */
  42. /*   0         all ok.                                                       */
  43. /*   1         bad.                                                          */
  44. /*   key = ESC escape key to caller.                                         */
  45. /*   rc  = ESC to pass escape key up the recursive calling chain.            */
  46. /*                                                                           */
  47. /* Assumptions:                                                              */
  48. /*                                                                           */
  49. /*   The contents of the parent node located by dfp is assumed to be         */
  50. /*   valid. This also assumes that for a stack variable that the scope       */
  51. /*   is valid and that the sfx != 0. This implies "inactive".                */
  52. /*                                                                           */
  53. /*****************************************************************************/
  54. uint zoomrec(AFILE *fp, DFILE *dfp, int mem, AFILE **fpp)
  55.                                         /* -> afile structure for this node. */
  56.                                         /* -> data file node containing mem. */
  57.                                         /* dfile node member number or 1.    */
  58. {                                       /*                                   */
  59.  uint   memtypeno;                      /* member type number.               */
  60.  uint   typeno;                         /* type number.                   101*/
  61.  Trec  *tp;                             /* -> base rec for parent dfile node.*/
  62.  Trec  *tpmem;                          /* -> type record for child member.  */
  63.  TD_TYPELIST *typelist;                 /* -> typelist record.            813*/
  64.  Trec  *namelist;                       /* -> namelist record.               */
  65.  uint   mid;                            /* module id.                        */
  66.  DFILE *memdfp;                         /* -> child dfile node.              */
  67.  uchar *memname;                        /* -> to child member name.          */
  68.  int    memnamelen;                     /* length of the child member name.  */
  69.  uint   memberoffs;                     /* offset of child member in parent. */
  70.  uint   rows;                           /* rows needed to display the child. */
  71.  uint   atomtype;                       /* type of array element.         101*/
  72.  uint   atomsize;                       /* size of array element in bits.    */
  73.  uint   nbytes;                         /* # of bytes read by GetAppData().  */
  74.  uchar *dp;                             /* -> to buf read from user space.101*/
  75.  AFILE *newfp;
  76.  
  77. /*****************************************************************************/
  78. /* We are going to build a child dfile node from the member within the       */
  79. /* parent dfile node. The parent node is taken from the data window.         */
  80. /* The first thing we do is establish those items that are inherited from    */
  81. /* the parent.                                                               */
  82. /*                                                                           */
  83. /*****************************************************************************/
  84.  mid = dfp->mid;                        /* module id.                        */
  85.  memdfp=(DFILE*)Talloc(sizeof(DFILE));  /*clear the stack space for child.521*/
  86.  memdfp->mid      = dfp->mid;           /* inherit: mid - module id.         */
  87.  memdfp->lno      = dfp->lno;           /*          lno - source line number.*/
  88.  memdfp->sfx      = dfp->sfx;           /*          sfx - stack frame index. */
  89.  memdfp->scope    = dfp->scope;         /*          scope - symbol scope.    */
  90.  memdfp->baseaddr = dfp->baseaddr;      /*                                   */
  91.                                         /*                                   */
  92. /*****************************************************************************/
  93. /* The parent dfile record will contain a datatype and a showtype.           */
  94. /* If the datatype is < 512, then the parent is primitive else the parent is */
  95. /* complex.                                                                  */
  96. /*                                                                           */
  97. /*****************************************************************************/
  98.  if(dfp->datatype < 512 ||              /* if parent is primitive, or if the */
  99.     mem == 0 )                          /* child is to be an exact image of  */
  100.                                         /* the parent, then                  */
  101.  {                                      /*                                   */
  102.   memcpy(memdfp, dfp,sizeof(DFILE));    /* inherit everything and go make 101*/
  103.  }                                      /* new copy for possible reformat.   */
  104.  else                                   /*                                   */
  105.  {                                      /* parent is complex.                */
  106.   tp = QbasetypeRec(mid, dfp->datatype);/* get -> to parent base type rec.   */
  107.   if(!tp ) goto error;                  /* if this fails, then abort.        */
  108. /*****************************************************************************/
  109. /* At this point, we have a pointer to the base type record for the parent   */
  110. /* dfile node. The complex types handled are as follows:                     */
  111. /*                                                                           */
  112. /*        T_PTR     yes                                                      */
  113. /*        T_STRUCT  yes                                                      */
  114. /*        T_ARRAY   yes                                                      */
  115. /*        T_ENUM    no                                                       */
  116. /*        T_BITFLD  no                                                       */
  117. /*        T_TYPDEF  yes                                                      */
  118. /*        T_PROC    not applicable                                           */
  119. /*        T_LIST    not applicable                                           */
  120. /*        T_NULL    not applicable                                           */
  121. /*****************************************************************************/
  122.   switch(tp->RecType)                   /* switch on complex type of prnt.813*/
  123.   {                                     /*                                   */
  124.    case T_PTR:
  125.    case T_REF:
  126.    /**************************************************************************/
  127.    /* Get the type of the pointer and establish the datatype and             */
  128.    /* showtype fields of the child node.                                     */
  129.    /*                                                                        */
  130.    /* Resolve the pointer.                                                   */
  131.    /* Establish the number of lines needed for display.                      */
  132.    /*                                                                        */
  133.    /*                                                                        */
  134.    /**************************************************************************/
  135.    if(tp->RecType == T_PTR )
  136.     typeno = ((TD_POINTER*)tp)->TypeIndex;
  137.    else
  138.     typeno = ((TD_REF*)tp)->TypeIndex;
  139.  
  140.     memdfp->datatype = typeno;
  141.     memdfp->showtype = typeno;
  142.  
  143.     dp = GetAppData(memdfp->baseaddr,   /* resolve the pointer by getting    */
  144.                     sizeof(uint),       /* the address of what the pointer101*/
  145.                     &nbytes,            /* points to.                        */
  146.                     memdfp->sfx         /*                                   */
  147.                    );                   /*                                   */
  148.     if(!dp) goto error;                 /* abort if ptr won't resolve.       */
  149.     memdfp->baseaddr = *(uint*)dp;      /* establish base address of chld.101*/
  150.                                         /* now get # lines needed for display*/
  151.     memdfp->baseaddr = ResolveAddr(memdfp->baseaddr,dfp,dfp->datatype);
  152.                                         /* resolve address into flat addr 219*/
  153.     if(typeno < 512)                    /* if the pointer resolved to a      */
  154.      break;                             /* primitive, then we're done.       */
  155.     tpmem=QbasetypeRec(mid, typeno );   /* get -> to base type record.       */
  156.                                         /*                                   */
  157.     switch(tpmem->RecType)              /* select the appropriate method for */
  158.     {                                   /* number of lines calculation.      */
  159.      case T_CLASS:                      /* child is a structure.             */
  160.      {
  161.       USHORT  NameLen;
  162.       char   *pName;
  163.  
  164.       memdfp->lines = ((TD_CLASS*)tpmem)->NumMembers;
  165.       if( GetViewMemFncs() == FALSE )
  166.       {
  167.        memdfp->lines = GetLinesNoMemFncs( memdfp->mid, tpmem );
  168.       }
  169.       NameLen       = ((TD_CLASS*)tpmem)->NameLen;
  170.       pName         = ((TD_CLASS*)tpmem)->Name;
  171.  
  172.       strncpy(memdfp->expr, pName, NameLen );
  173.  
  174.       memdfp->expr[NameLen]  = '\0';
  175.  
  176.      }
  177.      break;
  178.  
  179.      case T_STRUCT:
  180.      {
  181.       int   NameLen;
  182.       char *pName;
  183.  
  184.       memdfp->lines = ((TD_STRUCT*)tpmem)->NumMembers;
  185.       NameLen       = ((TD_STRUCT*)tpmem)->NameLen;
  186.       pName         = ((TD_STRUCT*)tpmem)->Name;
  187.  
  188.       strncpy(memdfp->expr, pName, NameLen );
  189.  
  190.       memdfp->expr[NameLen]  = '\0';
  191.      }
  192.      break;
  193.  
  194.      case T_ARRAY:                      /* child is an array.                */
  195.                                         /*                                   */
  196.       atomtype = ((TD_ARRAY*)tpmem)->ElemType;                          /*813*/
  197.                                         /* get the type of array elements.   */
  198.                                         /*                                   */
  199.       atomsize = QtypeSize(mid,         /* get size of row in bytes.         */
  200.                            atomtype);   /*                                   */
  201.                                         /*                                   */
  202.       nbytes = ((TD_ARRAY*)tpmem)->ByteSize;                         /*813520*/
  203.       if(atomtype == TYPE_CHAR ||       /* if the type is char or         520*/
  204.          atomtype == TYPE_UCHAR )       /* unsigned char then             520*/
  205.       {                                 /* treat the array as a string.   520*/
  206.         memdfp->lines = nbytes/16;      /* this is base number of lines.  520*/
  207.         if( nbytes-memdfp->lines*16 > 0)/* if there is a vestigial, then  520*/
  208.           memdfp->lines += 1;           /* add a line for it.             520*/
  209.       }                                 /*                                520*/
  210.       else                              /* if the type is NOT char, then  520*/
  211.       {                                 /*                                520*/
  212.         memdfp->lines = nbytes;         /*                                520*/
  213.         memdfp->lines /= atomsize;      /* compute no of lines to display 520*/
  214.       }                                 /*                                520*/
  215.       break;                            /*                                   */
  216.                                         /*                                   */
  217.     }                                   /*                                   */
  218.     break;                              /*                                   */
  219.                                         /*                                   */
  220.    case T_STRUCT:                       /*                                   */
  221.    /**************************************************************************/
  222.    /* Get the typelist of the parent dfile node.                             */
  223.    /* Get the namelist of the parent dfile node.                             */
  224.    /* Compute the base address for the child node.                           */
  225.    /* Get a pointer to the base type record for the child.                   */
  226.    /* If the child type is a pointer, then resolve the pointer and type.     */
  227.    /* Establish the datatype and showtype of the child.                      */
  228.    /* Add the child member name.                                             */
  229.    /* Compute child display lines.                                           */
  230.    /*                                                                        */
  231.    /**************************************************************************/
  232.     typeno = ((TD_STRUCT*)tp)->TypeListIndex;                           /*813*/
  233.  
  234.     typelist = (TD_TYPELIST*)QtypeRec(mid, typeno); /* -> to typelist.    813*/
  235.                                         /*                                   */
  236.     typeno = ((TD_STRUCT*)tp)->NameListIndex;                           /*813*/
  237.                                         /*                                   */
  238.     namelist = QtypeRec(mid, typeno);   /* establish -> to namelist.         */
  239.                                         /*                                   */
  240.     memtypeno = typelist->TypeIndex[mem-1];                             /*813*/
  241.  
  242.     if( memtypeno == 0 ) goto error;    /* abort if ptr won't resolve.    405*/
  243.  
  244.     memberoffs = QNameList(namelist,MEMBEROFFSET, mem-1 );              /*813*/
  245.  
  246.     memdfp->baseaddr = dfp->baseaddr +  /* compute base address of child.    */
  247.                       memberoffs;       /*                                   */
  248.                                         /*                                   */
  249.     tpmem = QbasetypeRec(mid,memtypeno);/* get -> to child type.             */
  250.     if( tpmem &&                        /*                                   */
  251.        tpmem->RecType == T_PTR          /* if the child is a pointer, then   */
  252.       )                                 /* resolve base address and type.    */
  253.     {                                   /*                                   */
  254.      dp = GetAppData(memdfp->baseaddr,  /* resolve the base address.         */
  255.                      sizeof(uint),      /*                                101*/
  256.                      &nbytes,           /*                                   */
  257.                      memdfp->sfx        /*                                   */
  258.                     );                  /*                                   */
  259.      if(!dp) goto error;                /* abort if ptr won't resolve.       */
  260.      memdfp->baseaddr = *(uint*)dp;     /* update child base address.        */
  261.      memdfp->baseaddr = ResolveAddr(memdfp->baseaddr,dfp,memtypeno);
  262.  
  263.                                         /* resolve the child type number.    */
  264.      memtypeno = ((TD_POINTER*)tpmem)->TypeIndex;                       /*813*/
  265.     }                                   /*                                   */
  266.     memdfp->datatype = memtypeno;       /* establish datatype and showtype   */
  267.     memdfp->showtype = memtypeno;       /* of the child.                     */
  268.                                         /*                                   */
  269.                                         /* get the member name from namelist.*/
  270.     memname=(uchar *)QNameList(namelist, NAME, mem-1);                  /*813*/
  271.  
  272.     memnamelen = (int)*memname;         /* compute member name length.       */
  273.     memname += 2;                       /*                                907*/
  274.     strncpy(memdfp->expr,               /* put the name in the child node.   */
  275.             memname,                    /*                                   */
  276.             memnamelen                  /*                                   */
  277.            );                           /*                                   */
  278.     memdfp->expr[memnamelen] = '\0';    /* terminate the name.               */
  279.                                         /*                                   */
  280.                                         /* now, compute lines for display.   */
  281.     memdfp->lines = 1;                  /* assume 1.                         */
  282.     if(memdfp->datatype >= 512 )        /* if child is a complex data type,  */
  283.     {                                   /* then compute real number required.*/
  284.      tpmem=QbasetypeRec(mid,            /* get -> to base rec for child.     */
  285.                        memdfp->datatype);/*                                  */
  286.      switch(tpmem->RecType)             /* select the appropriate method for */
  287.      {                                  /* number of lines calculation.      */
  288.       case T_STRUCT:                    /* child is a structure.             */
  289.  
  290.  
  291.  
  292.        /**********************************************************************/
  293.        /* - put in a check for a structure with a reference to an            */
  294.        /*   undefined structure.                                             */
  295.        /**********************************************************************/
  296.        typeno = ((TD_STRUCT*)tpmem)->TypeListIndex;                     /*908*/
  297.        if(typeno == 0 )                                                 /*908*/
  298.        {                                                                /*908*/
  299.         Message(ERR_DATA_INVALID_STRUCT,TRUE,1,memdfp->expr);           /*908*/
  300.         return(0);                                                      /*908*/
  301.        }                                                                /*908*/
  302.  
  303.        memdfp->lines = ((TD_STRUCT*)tpmem)->NumMembers;                 /*813*/
  304.                                         /*                                   */
  305.        break;                           /*                                   */
  306.                                         /*                                   */
  307.       case T_ARRAY:                     /* child is an array.                */
  308.        atomtype = ((TD_ARRAY*)tpmem)->ElemType;                         /*813*/
  309.        atomsize = QtypeSize(mid, atomtype);
  310.        nbytes = ((TD_ARRAY*)tpmem)->ByteSize;                        /*813520*/
  311.        if(atomtype == TYPE_CHAR ||      /* if the type is char or         520*/
  312.           atomtype == TYPE_UCHAR )      /* unsigned char then             520*/
  313.        {                                /* treat the array as a string.   520*/
  314.          memdfp->lines = nbytes/16;     /* this is base number of lines.  520*/
  315.          if(nbytes-memdfp->lines*16 > 0)/* if there is a vestigial, then  520*/
  316.            memdfp->lines += 1;          /* add a line for it.             520*/
  317.        }                                /*                                520*/
  318.        else                             /* if the type is NOT char, then  520*/
  319.        {                                /*                                520*/
  320.          if(nbytes == 0 )                                               /*912*/
  321.           nbytes = atomsize;                                            /*912*/
  322.          memdfp->lines = nbytes;        /*                                520*/
  323.          memdfp->lines /= atomsize;     /* compute no of lines to display 520*/
  324.        }                                /*                                520*/
  325.        break;                           /*                                   */
  326.      }                                  /*                                   */
  327.     }                                   /* end case T_STRUCT                 */
  328.     break;                              /*                                   */
  329.  
  330.    case T_CLASS:                        /*                                   */
  331.    {
  332.     USHORT       ItemListIndex;
  333.     TD_TYPELIST *pClassItemList;
  334.     ULONG        memberoffs;
  335.     ULONG        membertype;
  336.     TD_CLASS    *pClass;
  337.  
  338.     pClass           = (TD_CLASS*)tp;
  339.     ItemListIndex    = pClass->ItemListIndex;
  340.  
  341.     if(ItemListIndex == 0 )
  342.      return(1);
  343.  
  344.     pClassItemList   = (TD_TYPELIST*)QtypeRec(mid, ItemListIndex);
  345.     memberoffs       = QClassItemList(mid, pClassItemList, MEMBEROFFSET, mem-1);
  346.     membertype       = QClassItemList(mid, pClassItemList, MEMBERTYPE,   mem-1);
  347.  
  348.     if(membertype == 0 )
  349.      return(1);
  350.  
  351.     memdfp->baseaddr = dfp->baseaddr + memberoffs;
  352.     tpmem            = QbasetypeRec(mid, membertype);
  353.     membertype       = Qbasetype(mid, membertype);
  354.     memname          = (UCHAR*)QClassItemList(mid, pClassItemList, NAME, mem-1);
  355.  
  356.     if(memname != NULL )
  357.     {
  358.      memnamelen = (int)*memname;
  359.      memname += 2;
  360.      strncpy(memdfp->expr, memname, memnamelen );
  361.      memdfp->expr[memnamelen] = '\0';
  362.     }
  363.  
  364.     if( tpmem && (tpmem->RecType == T_PTR) )
  365.     {
  366.      dp = GetAppData(memdfp->baseaddr, sizeof(uint), &nbytes, memdfp->sfx );
  367.      if(!dp)
  368.       goto error;
  369.      memdfp->baseaddr = *(uint*)dp;
  370.      memdfp->baseaddr = ResolveAddr(memdfp->baseaddr, dfp, membertype);
  371.  
  372.      membertype = ((TD_POINTER*)tpmem)->TypeIndex;
  373.     }
  374.     memdfp->datatype = membertype;
  375.     memdfp->showtype = membertype;
  376.  
  377.     memdfp->lines = 1;
  378.     if(memdfp->datatype >= 512 )
  379.     {
  380.      tpmem=QtypeRec(mid, memdfp->datatype);
  381.      switch(tpmem->RecType)
  382.      {
  383.       case T_MEMFNC:
  384.       {
  385.        AFILE     *fp;
  386.        TD_MEMFNC *pMemFnc;
  387.        char       buffer[256];
  388.        char      *cp;
  389.        char      *cpstart;
  390.        char      *cpend;
  391.        char      *cpp;
  392.  
  393.        memset( buffer, 0, sizeof(buffer) );
  394.  
  395.        pMemFnc  = (TD_MEMFNC*)tpmem;
  396.        cpstart  = pMemFnc->Name;
  397.        cpend    = cpstart + pMemFnc->NameLen - 1;
  398.        cpp      = buffer;
  399.        cp       = strstr(pMemFnc->Name, "__");
  400.        cp      += 2;
  401.  
  402.        /**********************************************************************/
  403.        /* - put in the first part of the public name.                        */
  404.        /**********************************************************************/
  405.        switch(pMemFnc->FuncType)
  406.        {
  407.         case FUNCTYPE_REGULAR:
  408.          strncpy(cpp, cpstart, cp - cpstart );
  409.          break;
  410.  
  411.         case FUNCTYPE_CTOR:
  412.          strcpy(cpp, "__ct__");
  413.          break;
  414.  
  415.         case FUNCTYPE_DTOR:
  416.          strcpy(cpp, "__dt__");
  417.          break;
  418.        }
  419.        cpp += strlen(cpp);
  420.  
  421.        /**********************************************************************/
  422.        /* - put in the class name length.                                    */
  423.        /**********************************************************************/
  424.        sprintf(cpp, "%d", pClass->NameLen);
  425.        cpp += strlen(cpp);
  426.  
  427.        /**********************************************************************/
  428.        /* - put in the class name.                                           */
  429.        /**********************************************************************/
  430.        strncpy(cpp, pClass->Name, pClass->NameLen);
  431.        cpp += strlen(cpp);
  432.  
  433.        /**********************************************************************/
  434.        /* - put in the suffix.                                               */
  435.        /* - it it's a const, throw in a C.                                   */
  436.        /**********************************************************************/
  437.        if( pMemFnc->TypeQual & FUNCQUAL_CONST )
  438.         *cpp++ = 'C';
  439.  
  440.        strncpy( cpp, cp, cpend - cp + 1 );
  441.  
  442.        fp = FindFuncOrAddr(buffer, FALSE);
  443.        if( fp )
  444.        {
  445.         fp->csr.col = 0;
  446.         *fpp = fp;
  447.         return(0);
  448.        }
  449.        else
  450.         return(1);
  451.       }
  452. //    break;
  453.  
  454.       case T_CLASS:
  455.       {
  456.        TD_TYPELIST *pClassItemList;
  457.        USHORT       FirstItemInList;
  458.        USHORT       ItemListIndex;
  459.        TD_CLASS    *pClass;
  460.  
  461.        pClass        = (TD_CLASS*)tpmem;
  462.        memdfp->lines = pClass->NumMembers;
  463.        if( GetViewMemFncs() == FALSE )
  464.        {
  465.         memdfp->lines = GetLinesNoMemFncs( memdfp->mid, tpmem );
  466.        }
  467.  
  468.        strncpy(memdfp->expr, pClass->Name, pClass->NameLen );
  469.        memdfp->expr[pClass->NameLen] = '\0';
  470.  
  471.        /**********************************************************************/
  472.        /* - set a flag for base/derived class.                               */
  473.        /* - at map time, an extra item was added to the list for             */
  474.        /*   base classes.                                                    */
  475.        /**********************************************************************/
  476.        ItemListIndex    = pClass->ItemListIndex;
  477.  
  478.        if(ItemListIndex == 0 )
  479.         return(1);
  480.  
  481.        pClassItemList   = (TD_TYPELIST*)QtypeRec(mid, ItemListIndex);
  482.        FirstItemInList  = pClassItemList->TypeIndex[0];
  483.  
  484.        if( FirstItemInList == 0 )
  485.         memdfp->DfpFlags.ClassType = DFP_BASE_CLASS;
  486.        else
  487.         memdfp->DfpFlags.ClassType = DFP_DERIVED_CLASS;
  488.  
  489.        /**********************************************************************/
  490.        /* - put in a check for a class with a reference to an                */
  491.        /*   undefined class.                                                 */
  492.        /**********************************************************************/
  493.        typeno = ((TD_CLASS*)tpmem)->ItemListIndex;
  494.        if(typeno == 0 )
  495.        {
  496.         Message(ERR_DATA_INVALID_STRUCT, TRUE, 1, memdfp->expr);
  497.         return(0);
  498.        }
  499.       }
  500.       break;
  501.  
  502.       case T_ARRAY:
  503.       {
  504.        atomtype = ((TD_ARRAY*)tpmem)->ElemType;
  505.        atomsize = QtypeSize(mid, atomtype);
  506.        nbytes = ((TD_ARRAY*)tpmem)->ByteSize;
  507.        if(atomtype == TYPE_CHAR ||
  508.           atomtype == TYPE_UCHAR )
  509.        {
  510.          memdfp->lines = nbytes/16;
  511.          if(nbytes-memdfp->lines*16 > 0)
  512.            memdfp->lines += 1;
  513.        }
  514.        else
  515.        {
  516.          if(nbytes == 0 )
  517.           nbytes = atomsize;
  518.          memdfp->lines = nbytes;
  519.          memdfp->lines /= atomsize;
  520.        }
  521.       }
  522.       break;
  523.      }
  524.     }
  525.    }
  526.    break;
  527.  
  528.  
  529.    case T_ARRAY:
  530.    /**************************************************************************/
  531.    /* get the atom type from the base type record.                           */
  532.    /* get the atom size.                                                     */
  533.    /* get the base address of this member of the array.                      */
  534.    /* get the pointer to the base type record for this member.               */
  535.    /* if this member is a pointer then resolve it:                           */
  536.    /*   get new type.                                                        */
  537.    /*   get new base address.                                                */
  538.    /* set the data type and showtype.                                        */
  539.    /* compute the number of lines needed for show.                           */
  540.    /*                                                                        */
  541.    /**************************************************************************/
  542.     atomtype = ((TD_ARRAY*)tp)->ElemType;   /* get array element type.    813*/
  543.     atomsize = QtypeSize(mid, atomtype);/* get array row size in bytes.      */
  544.                                         /*                                   */
  545.     memdfp->baseaddr=dfp->baseaddr +    /* establish child base address.     */
  546.                        (mem-1)*atomsize;/*                                   */
  547.                                         /*                                   */
  548.     tpmem = QbasetypeRec(mid,atomtype); /* get -> to child type.             */
  549.                                         /*                                   */
  550.     if( tpmem &&                        /* if child is a pointer, then       */
  551.        tpmem->RecType == T_PTR          /* resolve base address and type.    */
  552.       )                                 /*                                   */
  553.     {                                   /*                                   */
  554.                                         /*                                   */
  555.      dp = GetAppData(memdfp->baseaddr,  /* resolve base address.             */
  556.                      sizeof(uint),      /*                                101*/
  557.                      &nbytes,           /*                                   */
  558.                      memdfp->sfx        /*                                   */
  559.                     );                  /*                                   */
  560.      if(!dp) goto error;                /* abort if ptr won't resolve.       */
  561.      memdfp->baseaddr = *(uint*)dp;     /* establish resolved child base addr*/
  562.      memdfp->baseaddr = ResolveAddr(memdfp->baseaddr,dfp,atomtype);
  563.                                         /* resolve address into flat addr 219*/
  564.      atomtype = ((TD_POINTER*)tpmem)->TypeIndex;/* get type of array elmnt813*/
  565.     }                                   /*                                   */
  566.                                         /*                                   */
  567.     memdfp->datatype = atomtype;        /*                                   */
  568.     memdfp->showtype = atomtype;        /*                                   */
  569.                                         /*                                   */
  570.     memdfp->lines = 1;                  /*                                   */
  571.     if(memdfp->datatype >= 512 )        /* if child is a complex data type,  */
  572.     {                                   /* then compute real number required.*/
  573.      tpmem=QbasetypeRec(mid,            /* get -> to base rec for child.     */
  574.                        memdfp->datatype);/*                                  */
  575.      switch(tpmem->RecType)             /* select the appropriate method for */
  576.      {                                  /* number of lines calculation.      */
  577.       case T_STRUCT:
  578.        memdfp->lines = ((TD_STRUCT*)tpmem)->NumMembers;
  579.        break;
  580.  
  581.       case T_CLASS:
  582.        memdfp->lines = ((TD_CLASS*)tpmem)->NumMembers;
  583.        if( GetViewMemFncs() == FALSE )
  584.        {
  585.         memdfp->lines = GetLinesNoMemFncs( memdfp->mid, tpmem );
  586.        }
  587.        break;
  588.  
  589.       case T_ARRAY:
  590.        atomtype = ((TD_ARRAY*)tpmem)->ElemType;
  591.        atomsize = QtypeSize(mid, atomtype);
  592.  
  593.        nbytes = ((TD_ARRAY*)tpmem)->ByteSize;                        /*813520*/
  594.        if(atomtype == TYPE_CHAR ||      /* if the type is char or         520*/
  595.           atomtype == TYPE_UCHAR )      /* unsigned char then             520*/
  596.        {                                /* treat the array as a string.   520*/
  597.          memdfp->lines = nbytes/16;     /* this is base number of lines.  520*/
  598.          if(nbytes-memdfp->lines*16 > 0)/* if there is a vestigial, then  520*/
  599.            memdfp->lines += 1;          /* add a line for it.             520*/
  600.        }                                /*                                520*/
  601.        else                             /* if the type is NOT char, then  520*/
  602.        {                                /*                                520*/
  603.          memdfp->lines = nbytes;        /*                                520*/
  604.          memdfp->lines /= atomsize;     /* compute no of lines to display 520*/
  605.        }                                /*                                520*/
  606.        break;                           /*                                   */
  607.      }                                  /*                                   */
  608.     }                                   /* end compute # lines for cmplx type*/
  609.     break;                              /* end case T_ARRAY.                 */
  610.  
  611.    case T_ENUM:
  612.    case T_BITFLD:
  613.    case T_TYPDEF:
  614.    case T_PROC:
  615.    case T_LIST:
  616.    case T_NULL:
  617.     break;
  618.   }                                     /* end of switch                     */
  619.  }                                      /* end of else - handle complex types*/
  620. /*****************************************************************************/
  621. /* At this point, we have finally built the child node. We are going to      */
  622. /* display the info and then handle user input.                              */
  623. /*****************************************************************************/
  624.  {                                      /* begin k/b handling.               */
  625.   int    func;                          /* function associated with a key.   */
  626.   int    cursormem;                     /* cursor dfile node member.         */
  627.   int    firstmem;                      /* first member displayed in window. */
  628.   int    lastmem;                       /* last  member displayed in window. */
  629.   CSR    stgcsr;                        /* storage cursor.                   */
  630.   int    show;                          /* show flag.                        */
  631.   int    toobig;                        /* data too big to fit in window.    */
  632.   uint   rc;                            /* return code.                      */
  633.   int    ShowSource;                    /* show source flag.              519*/
  634.  
  635.   stgcsr.col = 0;                       /* initialize the cursor.            */
  636.   stgcsr.row = (uchar)(TopLine + 1);    /* column 0 & 1st row in window.     */
  637.   stgcsr.mode = CSR_NORMAL;             /* use a normal cursor.              */
  638.                                         /*                                   */
  639.   rows = VideoRows-4-TopLine;           /* number of rows in exp window.  519*/
  640.                                         /*                                   */
  641.   toobig = FALSE;                       /* assume the node will fit in the   */
  642.   if( memdfp->lines > rows )            /* window. If it doesn't, then set   */
  643.    toobig = TRUE;                       /* a flag.                           */
  644.                                         /*                                   */
  645.                                         /* initialize the entry display.     */
  646.   cursormem = 1;                        /* cursor on first member.           */
  647.   firstmem  = 1;                        /*                                   */
  648.   lastmem   = memdfp->lines;            /* last member = last member in node */
  649.   if( toobig )                          /* unless node is too big to fit the */
  650.    lastmem = rows;                      /* window.                           */
  651.   else                                  /*                                   */
  652.    rows = lastmem - firstmem + 1;       /* limit to the size of the struct519*/
  653.   if (rows == 0)                        /* if the number of rows is zero  521*/
  654.      rows = 1;                          /* display at least oneline.      521*/
  655.   memdfp->datatype = HandleUserDefs(memdfp->mid,memdfp->datatype);      /*512*/
  656.                                         /* Get primitive typeno in case   512*/
  657.                                         /* of primitive user defs.        512*/
  658.   SetShowType( memdfp,memdfp->datatype);/* set show function for child node. */
  659.   show = TRUE;                          /* set show flag for loop entry.     */
  660.   ShowSource = (iview!=VIEW_SHOW);                 /* set show source flag           519*/
  661.   SetMenuMask( EXPANDDATA );                                            /*701*/
  662.   for( ;; )                             /* begin user processing loop.       */
  663.   {                                     /*                                   */
  664.    if(show)                             /* redisplay the window if the show  */
  665.    {                                    /* flag is set.                      */
  666.     /*************************************************************************/
  667.     /* Is show source flag is set then depending on the shower of the fp  519*/
  668.     /* call functions to refresh part of the screen.                      519*/
  669.     /*************************************************************************/
  670.     if (ShowSource == TRUE)                                             /*519*/
  671.     {                                                                   /*519*/
  672.      int  StartRow, RowsToPaint;                                        /*801*/
  673.                                                                         /*801*/
  674.      if( fp->shower == showC )                                          /*701*/
  675.      {                                                                  /*801*/
  676.        StartRow    = TopLine + rows + 1;
  677.        RowsToPaint = LinesPer - rows - 1;
  678.        if( (StartRow + fp->topline) < fp->Tlines )                      /*801*/
  679.        {                                                                /*801*/
  680.          RefreshSrcPart( fp, StartRow, RowsToPaint, rows+1);            /*519*/
  681.        }                                                                /*801*/
  682.        else
  683.         ClrScr( StartRow, StartRow + RowsToPaint - 1, vaProgram );
  684.      }
  685.      else
  686.        RefreshAsmPart( TopLine + rows + 1, rows + 1);
  687.      ShowSource = FALSE;
  688.     }
  689.     (* memdfp->shower)(memdfp,          /* show the child node.              */
  690.                        TopLine+1,       /*                                   */
  691.                        rows,            /*                                   */
  692.                        firstmem - 1     /*                                   */
  693.                       );                /*                                   */
  694.     fmtdwinstat(DstatRow, TopLine);     /* refresh the status line.          */
  695.     show = FALSE;                       /* turn off the show flag.           */
  696.    }                                    /*                                   */
  697.    PutCsr( &stgcsr );                   /* put the cursor in the window.     */
  698.  
  699. #define RETURNESC 1                                                     /*701*/
  700.    func = GetFuncsFromEvents( RETURNESC, (void *)fp );                  /*701*/
  701.    switch( func )                       /* switch on function selection.     */
  702.    {                                    /*                                   */
  703.     case UPCURSOR:                      /* begin UPCURSOR.                   */
  704.      if(cursormem > firstmem)           /*                                   */
  705.      {                                  /* decrement the member.             */
  706.       cursormem--;                      /* decrement the cursor.             */
  707.       stgcsr.row -= 1;                  /*                                   */
  708.       break;                            /*                                   */
  709.      }                                  /*                                   */
  710.      switch( toobig )                   /* if the node fits inside the window*/
  711.      {                                  /* then we're done.                  */
  712.       case FALSE:                       /*                                   */
  713.        break;                           /*                                   */
  714.                                         /*                                   */
  715.       case TRUE:                        /* if it doesn't then                */
  716.        if( firstmem > 1 )               /* if we're trying to go above the   */
  717.        {                                /* the window, then we need to move  */
  718.         firstmem--;                     /* the window up. if we're at the    */
  719.         cursormem--;                    /* top of the window( firstmem=1)    */
  720.         lastmem  = firstmem + rows - 1; /* then don't do anything.           */
  721.         show = TRUE;                    /*                                   */
  722.        }                                /*                                   */
  723.        break;                           /*                                   */
  724.      }                                  /*                                   */
  725.      break;                             /* end UPCURSOR.                     */
  726.                                         /*                                   */
  727.     case DOWNCURSOR:                    /* begin DOWNCURSOR.                 */
  728.      if(cursormem < lastmem )           /*                                   */
  729.      {                                  /*                                   */
  730.       cursormem++;                      /* increment the cursor member.      */
  731.       stgcsr.row += 1;                  /* increment the cursor.             */
  732.       break;                            /*                                   */
  733.      }                                  /*                                   */
  734.                                         /*                                   */
  735.      switch( toobig )                   /* if the node fits in the window    */
  736.      {                                  /* then we're done.                  */
  737.       case FALSE:                       /*                                   */
  738.        break;                           /*                                   */
  739.                                         /*                                   */
  740.       case TRUE:                        /* if it doesn't we come here.       */
  741.        if( lastmem < (int)memdfp->lines)/*                                   */
  742.        {                                /* we now drag the window down one   */
  743.         lastmem++;                      /* line unless we're already bottomed*/
  744.         cursormem++;                    /* out(lastmem = memdfp->lines).     */
  745.         firstmem = lastmem - rows + 1;  /*                                   */
  746.         show = TRUE;                    /*                                   */
  747.        }                                /*                                   */
  748.        break;                           /*                                   */
  749.      }                                  /*                                   */
  750.      break;                             /* end of DOWNCURSOR.                */
  751.                                         /*                                   */
  752.     case LEFTCURSOR:                    /* LEFTCURSOR.                       */
  753.      Tfree((void*)memdfp);               /*  give memory back to OS/2.     521*/
  754.      return(0);                         /*                                   */
  755.                                         /*                                   */
  756.     case LEFTMOUSECLICK:                                                /*701*/
  757.     case RIGHTMOUSECLICK:                                               /*701*/
  758.     {                                                                   /*701*/
  759.       PEVENT Event;                                                     /*701*/
  760.                                                                         /*701*/
  761.       Event = GetCurrentEvent();                                        /*701*/
  762.       if( (Event->Row <= TopLine) || (Event->Row > TopLine + rows) )    /*701*/
  763.       {                                                                 /*701*/
  764.         if( func == RIGHTMOUSECLICK )                                   /*701*/
  765.           return( ESC );                                                /*701*/
  766.         beep();                                                         /*701*/
  767.         break;                                                          /*701*/
  768.       }                                                                 /*701*/
  769.       cursormem  = Event->Row - TopLine;                                /*701*/
  770.       stgcsr.row = Event->Row;                                          /*701*/
  771.       if( func == LEFTMOUSECLICK )                                      /*701*/
  772.         break;                                                          /*701*/
  773.     }                                                                   /*701*/
  774.     goto caseexpandvar;
  775. caseexpandvar:
  776.  
  777.     case EXPANDVAR:                     /* Expand variable in expansion win. */
  778.     case RIGHTCURSOR:                   /* RIGHTCURSOT.                      */
  779.      if(memdfp->datatype < 512)         /* if the data type is primitive  516*/
  780.      {                                  /* then there is no point in      516*/
  781.       beep();                           /* expanding it again.            516*/
  782.       putmsg("Nothing more to expand"); /*                                516*/
  783.       break;                            /*                                516*/
  784.      }                                  /*                                516*/
  785.      newfp = NULL;
  786.      rc=zoomrec(fp, memdfp, cursormem, &newfp);
  787.      if( newfp )
  788.      {
  789.       *fpp = newfp;
  790.       return(0);
  791.      }
  792.      if(rc==ESC)
  793.       return(rc);
  794.      else if(rc)
  795.      {
  796.       beep();
  797.       putmsg("can't expand this data"); /*                                   */
  798.      }                                  /*                                   */
  799.      show = TRUE;                       /* set the refresh flag.             */
  800.      ShowSource = TRUE;                 /* set show source flag           519*/
  801.      break;                             /*                                   */
  802.                                         /*                                   */
  803.     case PREVWINDOW:                    /* begin PREVWINDOW, alias PgUp.     */
  804.      if(!toobig)                        /* if node fits in window, then fall */
  805.       goto caseTopOfWindow;             /* thru to TOPOFWINDOW, alias C-PgUp.*/
  806.      lastmem = firstmem;                /* otherwise, drag the window up one */
  807.      firstmem = lastmem - rows + 1;     /* line unless already topped out.   */
  808.      if( firstmem < 1 )                 /*                                   */
  809.      {                                  /*                                   */
  810.       firstmem = 1;                     /*                                   */
  811.       lastmem = firstmem + rows - 1;    /*                                   */
  812.      }                                  /*                                   */
  813.      show = TRUE;                       /* set the refresh flag.             */
  814.      cursormem = firstmem;              /* put the cursor on the 1st member. */
  815.      stgcsr.row = (uchar)(TopLine + 1); /* set curosr on top row.            */
  816.      break;                             /* end PREVWINDOW, alias PgUp.       */
  817.                                         /*                                   */
  818.     case NEXTWINDOW:                    /* begin NEXTWINDOW, alias PgDn.     */
  819.      if(!toobig)                        /* if node fits in window fall thru  */
  820.       goto caseBotOfWindow;             /* to BOTOFWINDOW, alias C-PgDn.     */
  821.      firstmem = lastmem;                /* otherwise, move down one page.    */
  822.      lastmem = firstmem + rows - 1;     /* anchor last page at bottom of the */
  823.      if( lastmem > (int)memdfp->lines ) /* node.                             */
  824.      {                                  /*                                   */
  825.       lastmem = memdfp->lines;          /*                                   */
  826.       firstmem = lastmem - rows + 1;    /*                                   */
  827.      }                                  /*                                   */
  828.      show = TRUE;                       /* set the refresh flag.             */
  829.      cursormem = firstmem;              /* put the cursor on the 1st member. */
  830.      stgcsr.row = (uchar)(TopLine + 1); /* set curosr on top row.            */
  831.      break;                             /* end NEXTWINDOW, alias PgDn.       */
  832.                                         /*                                   */
  833.     case FIRSTWINDOW:                   /* begin FIRSTWINDOW, alias C-Home.  */
  834.      if(!toobig)                        /* if node fits in window, then fall */
  835.       goto caseTopOfWindow;             /* thru to TOPOFWINDOW.              */
  836.      stgcsr.row = (uchar)(TopLine + 1); /* otherwise, reset to the first page*/
  837.      cursormem = 1;                     /*                                   */
  838.      firstmem  = 1;                     /*                                   */
  839.      lastmem = rows;                    /*                                   */
  840.      show = TRUE;                       /* set the refresh flag.             */
  841.      break;                             /*                                   */
  842.                                         /*                                   */
  843.     caseTopOfWindow:                    /*                                   */
  844.     case TOPOFWINDOW:                   /* begin TOPOFWINDOW, alias C-PgUp.  */
  845.      cursormem = firstmem;              /* set node to first node member.    */
  846.      stgcsr.row = (uchar)(TopLine + 1); /* set curosr on top row.            */
  847.      break;                             /* end TOPOFWINDOW, alias C-PgUp.    */
  848.                                         /*                                   */
  849.     case LASTWINDOW:                    /* begin LASTWINDOW, alias C-end.    */
  850.      if(!toobig)                        /* if node fits in window, then      */
  851.       goto caseBotOfWindow;             /* fall thru to BOTOFWINDOW.         */
  852.      lastmem = memdfp->lines;           /* otherwise, move to the window to  */
  853.      firstmem = lastmem - rows + 1;     /* the bottom of the node.           */
  854.      stgcsr.row=(uchar)(TopLine + rows);/*                                   */
  855.      cursormem = lastmem;               /*                                   */
  856.      show = TRUE;                       /* set the refresh flag.             */
  857.      break;                             /* end LASTWINDOW, alias C-end.      */
  858.                                         /*                                   */
  859.     caseBotOfWindow:                    /*                                   */
  860.     case BOTOFWINDOW:                   /* begin BOTOFWINDOW, alias C-PgDn.  */
  861.      stgcsr.row += (uchar)(lastmem -    /* put cursor on last node member.   */
  862.                            cursormem);  /*                                   */
  863.      cursormem = lastmem;               /* set the cursor member.            */
  864.      break;                             /* end BOTOFWINDOW, alias C-PgDn.    */
  865.                                         /*                                   */
  866.     case QUIT:                                                          /*701*/
  867.     case ESCAPE:                        /*                                   */
  868.       return( ESC );                    /*                                   */
  869.    }                                    /* end switch( func ).               */
  870.   }                                     /* end user processing loop.         */
  871.  }                                      /* end of k/b handling.              */
  872. /*****************************************************************************/
  873. /* error handling                                                            */
  874. /*****************************************************************************/
  875. error:
  876.  if(memdfp)
  877.   Tfree((void*)memdfp);
  878.  return(1);
  879.  
  880. }
  881.