home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / sd386v50.zip / sd386src.zip / SHOWDZ.C < prev    next >
Text File  |  1995-12-11  |  31KB  |  729 lines

  1. /*****************************************************************************/
  2. /* File:                                             IBM INTERNAL USE ONLY   */
  3. /*   showdz.c                                                                */
  4. /*                                                                           */
  5. /* Description:                                                              */
  6. /*                                                                           */
  7. /*  data editing routines.                                                   */
  8. /*                                                                           */
  9. /*                                                                           */
  10. /* History:                                                                  */
  11. /*                                                                           */
  12. /*   02/08/91 Creation of 32-bit SD86, from 16-bit version.                  */
  13. /*                                                                           */
  14. /*...16->32 port.                                                            */
  15. /*...                                                                        */
  16. /*... 02/08/91  101   Joe       port to 32 bit.                              */
  17. /*... 02/08/91  108   Dave      port to 32 bit.                              */
  18. /*... 02/08/91  111   Christina port to 32 bit.                              */
  19. /*... 02/08/91  112   Joe       port to 32 bit.                              */
  20. /*                                                                           */
  21. /*...Release 1.00 (Pre-release 1)                                            */
  22. /*...                                                                        */
  23. /*... 07/09/91  205   srinivas  Hooking up of register variables.            */
  24. /*... 07/09/91  207   srinivas  modifying data in the data window.           */
  25. /*... 08/15/91  226   srinivas  modifying pointers in data window.           */
  26. /*... 08/19/91  228   srinivas  padding zeros in the hex fields.             */
  27. /*... 08/19/91  230   srinivas  Blank field in a hex field followed by ENTER */
  28. /*                              key should restore the previous contents.    */
  29. /*                                                                           */
  30. /*...Release 1.00 (Pre-release 1.08 10/10/91)                                */
  31. /*...                                                                        */
  32. /*... 02/07/92  512   Srinivas  Handle Toronto "C" userdefs.                 */
  33. /*... 02/12/92  521   Joe       Port to C-Set/2.                             */
  34. /*...                                                                        */
  35. /*...Release 1.01 (04/03/92)                                                 */
  36. /*...                                                                        */
  37. /*... 08/03/92  701   Joe       Cua Interface.                               */
  38. /*...                                                                        */
  39. /*...Release 1.02 (10/22/92)                                                 */
  40. /*...                                                                        */
  41. /*... 03/03/93  813   Joe       Revised types handling for HL03.             */
  42. /*...                           (Moved FormatdataItem to it's own file.)     */
  43. /*...                                                                        */
  44. /*****************************************************************************/
  45. #include "all.h"
  46.  
  47. #define TAB1 15                         /* first tab pos for data display    */
  48. #define TAB2 27                         /* second tab pos for data display   */
  49.  
  50. UCHAR CantZapMsg[] = "Can't modify this data!";
  51. UCHAR BadDataMsg[] = "Invalid value for data type";
  52.  
  53. extern uint   VideoCols;
  54. extern uchar  VideoAtr;
  55. extern uint   ExprAddr;  /* Set by ParseExpr -- Address value of expr 101*/
  56.  
  57. #define NTYPES 9
  58. ushort dtab[NTYPES] = {
  59.                        TYPE_CHAR   ,    /* 0x80                           101*/
  60.                        TYPE_SHORT  ,    /* 0X81                           101*/
  61.                        TYPE_LONG   ,    /* 0x82                           101*/
  62.                        TYPE_UCHAR  ,    /* 0x84                           101*/
  63.                        TYPE_USHORT ,    /* 0x85                           101*/
  64.                        TYPE_ULONG  ,    /* 0x86                           101*/
  65.                        TYPE_FLOAT  ,    /* 0x88                           101*/
  66.                        TYPE_DOUBLE ,    /* 0x89                           101*/
  67.                        TYPE_LDOUBLE     /* 0x8A                        813101*/
  68.                       };
  69.  
  70.  
  71. uint                                    /*                                521*/
  72. ZapPointer(DFILE *dfp ,uint  row, uint skip )
  73. {
  74.     return( skip ? FALSE :
  75.       KeyPointer(dfp->mid, dfp->showtype, dfp->sfx, row , 0 , ExprAddr) );
  76. }
  77.  
  78.  int
  79. KeyPointer(uint mid,uint tno,uint sfx,uint row,uint col,uint varptr )
  80. {
  81.     uint keycol, segcol, offcol, csroff;
  82.     ULONG helpid;
  83.     uint n;
  84.     uchar type;
  85.     uint ptr;
  86.     uchar buffer[DATALINESPAN];
  87.     PEVENT  Event;                      /*                                701*/
  88.     uint    key;                        /*                                701*/
  89.     uint    rc = TRUE;                  /*                                701*/
  90.  
  91.     memset( buffer, 0, sizeof(buffer) );
  92.     FormatDataItem( buffer+1, varptr, mid, tno, sfx );                  /*226*/
  93.  
  94. #if 0
  95.     /*************************************************************************/
  96.     /*   if we come in with a mouse event that is not in the storage      701*/
  97.     /*   area then just kick it back out.                                 701*/
  98.     /*************************************************************************/
  99.     Event = GetCurrentEvent();                                          /*701*/
  100.     if( Event->Type == TYPE_MOUSE_EVENT )                               /*701*/
  101.     {                                                                   /*701*/
  102.      if( GetStorageArea(Event) != STORAGEAREA )                         /*701*/
  103.       return( TRUE );                                                   /*701*/
  104.     }                                                                   /*701*/
  105. #endif
  106.     if (col)                            /* if the var is part of an array 226*/
  107.        {                                /* or struct indicated by its name226*/
  108.         if ( col <= TAB1 )  col = TAB1; /* displayed beyond STGCOL, move  226*/
  109.         else  col = TAB2;               /* to a TAB pos based on length of226*/
  110.        }                                /* name.                          226*/
  111.  
  112.     col += STGCOL-1;                                                    /*226*/
  113.     csroff = 0;                                                         /*226*/
  114.     helpid = HELP_DATA_OFFSET;                                          /*226*/
  115.  
  116.  
  117.     type = GetPtrType( mid,tno);
  118.     switch (type )
  119.  
  120.     {
  121.       case PTR_0_16:
  122.         buffer[0] = Attrib(vaStgPro);
  123.         buffer[5] = 0;
  124.         putrc( row, col, buffer );
  125.         for(;;)
  126.         {
  127.  
  128.           key=GetString(row,col,4, 4,&csroff, buffer,HEXKEYFLD,NULL);
  129.           switch( key )
  130.           {
  131.             case F1:
  132.               Help( helpid );
  133.               break;
  134.  
  135.             /*****************************************************************/
  136.             /* Treat up/down key like a left mouse click.                    */
  137.             /* Set up a fake event.                                          */
  138.             /*****************************************************************/
  139.             case UP:
  140.             case DOWN:
  141.             case LEFTMOUSECLICK:
  142.             case ENTER:
  143.             case DATAKEY:
  144.  
  145.             if( (key==UP) || (key==DOWN) )
  146.             {
  147.              Event = GetCurrentEvent();
  148.              Event->Type =  TYPE_MOUSE_EVENT;
  149.              Event->Col  =  col;
  150.              Event->Row  =  (key == DOWN )?row+1:row-1;
  151.             }
  152.  
  153.             if( (key==UP) || (key==DOWN) ||
  154.                 (key==LEFTMOUSECLICK) || (key==ENTER)
  155.               )
  156.             {
  157.               if( strlen(buffer) == 0 )
  158.                 return( TRUE );
  159.             }
  160.  
  161.             if( !ZapHexWord(varptr, sfx, buffer) )
  162.             {
  163.              beep();
  164.              break;
  165.             }
  166.  
  167.             /****************************************************************/
  168.             /* On a left mouse click:                                       */
  169.             /*                                                              */
  170.             /*  - format the data item.                                     */
  171.             /*  - put the storage field into it's normal color.             */
  172.             /*  - if the event is not in the data window, then              */
  173.             /*    simply return the key, else recirculate it.               */
  174.             /****************************************************************/
  175.             if( (key==LEFTMOUSECLICK) || (key==UP) || (key==DOWN) )
  176.             {
  177.              FormatDataItem( buffer+1, varptr, mid, tno, sfx );
  178.              buffer[0] = Attrib(vaStgVal);
  179.              putrc( row, col, buffer );
  180.              SetDataViewCsr();
  181.              rc = RECIRCULATE;
  182.              if( (GetEventView() != DATAVIEW) )
  183.               rc = key;
  184.             }
  185.             return(rc);
  186.  
  187.             case ESC:
  188.               return( rc );
  189.             default:
  190.               beep();
  191.           }
  192.         }
  193.      /* break; */
  194.  
  195.       case PTR_0_32:
  196.         buffer[0] = Attrib(vaStgPro);
  197.         buffer[10] = 0;
  198.         putrc( row, col, buffer );
  199.         for(;;)
  200.         {
  201.           key=GetString(row,col,8,8,&csroff,buffer,HEXKEYFLD,NULL);
  202.           switch( key )
  203.           {
  204.             case F1:
  205.               Help( helpid );
  206.               break;
  207.  
  208.             /*****************************************************************/
  209.             /* Treat up/down key like a left mouse click.                    */
  210.             /* Set up a fake event.                                          */
  211.             /*****************************************************************/
  212.             case UP:
  213.             case DOWN:
  214.             case LEFTMOUSECLICK:
  215.             case ENTER:
  216.             case DATAKEY:
  217.  
  218.             if( (key==UP) || (key==DOWN) )
  219.             {
  220.              Event = GetCurrentEvent();
  221.              Event->Type =  TYPE_MOUSE_EVENT;
  222.              Event->Col  =  col;
  223.              Event->Row  =  (key == DOWN )?row+1:row-1;
  224.             }
  225.  
  226.             if( (key==UP) || (key==DOWN) ||
  227.                 (key==LEFTMOUSECLICK) || (key==ENTER)
  228.               )
  229.             {
  230.               if( strlen(buffer) == 0 )
  231.                 return( TRUE );
  232.             }
  233.  
  234.             if( !ZapHexDWord(varptr, sfx, buffer) )
  235.             {
  236.                beep();
  237.                break;
  238.             }
  239.  
  240.             /****************************************************************/
  241.             /* On a left mouse click:                                       */
  242.             /*                                                              */
  243.             /*  - format the data item.                                     */
  244.             /*  - put the storage field into it's normal color.             */
  245.             /*  - if the event is not in the data window, then              */
  246.             /*    simply return the key, else recirculate it.               */
  247.             /****************************************************************/
  248.             if( (key==LEFTMOUSECLICK) || (key==UP) || (key==DOWN) )
  249.             {
  250.              FormatDataItem( buffer+1, varptr, mid, tno, sfx );
  251.              buffer[0] = Attrib(vaStgVal);
  252.              putrc( row, col, buffer );
  253.              SetDataViewCsr();
  254.              rc = RECIRCULATE;
  255.              if( (GetEventView() != DATAVIEW) )
  256.               rc = key;
  257.             }
  258.             return(rc);
  259.  
  260.  
  261.             case ESC:
  262.               return( rc);
  263.             default:
  264.               beep();
  265.           }
  266.         }
  267.     /*  break; */
  268.  
  269.       case PTR_16_16:
  270.         buffer[0] = Attrib(vaStgPro);
  271.         buffer[5] = 0;
  272.         putrc( row, segcol = col, buffer );
  273.         buffer[5] = Attrib(vaStgPro);
  274.         buffer[10] = 0;
  275.         putrc( row, offcol = col + 5, buffer + 5 );
  276.         keycol = offcol;
  277.  
  278.         FlipFlop:
  279.         if( keycol == segcol )  {
  280.           keycol = offcol;
  281.           ptr = varptr;
  282.           helpid = HELP_DATA_OFFSET; }
  283.         else                    {
  284.           keycol = segcol;
  285.           ptr = varptr + sizeof(OFFSET);
  286.           helpid = HELP_DATA_SEGMENT; }
  287.         for(;;)
  288.         {
  289.           key=GetString(row,keycol,4,4,&csroff,buffer,HEXKEYFLD,NULL);
  290.           switch( key )
  291.           {
  292.             case LEFT:
  293.               n=3;  goto UpdatePointer;
  294.             case DATAKEY:
  295.             case RIGHT:
  296.             case TAB:
  297.             case S_TAB:
  298.               n=0;  goto UpdatePointer;
  299.             case F1:
  300.               Help( helpid );
  301.               break;
  302.  
  303.             /*****************************************************************/
  304.             /* Treat up/down key like a left mouse click.                    */
  305.             /* Set up a fake event.                                          */
  306.             /*****************************************************************/
  307.             case UP:
  308.             case DOWN:
  309.             case LEFTMOUSECLICK:
  310.             case ENTER:
  311.             if( (key==UP) || (key==DOWN) )
  312.             {
  313.              Event = GetCurrentEvent();
  314.              Event->Type =  TYPE_MOUSE_EVENT;
  315.              Event->Col  =  col;
  316.              Event->Row  =  (key == DOWN )?row+1:row-1;
  317.             }
  318.  
  319.             if( strlen(buffer) == 0 )
  320.               return( TRUE );
  321.             if( !ZapHexWord(ptr, sfx, buffer) )
  322.               goto Complain;
  323.  
  324.             /****************************************************************/
  325.             /* On a left mouse click:                                       */
  326.             /*                                                              */
  327.             /*  - format the data item.                                     */
  328.             /*  - put the storage field into it's normal color.             */
  329.             /*  - if the event is not in the data window, then              */
  330.             /*    simply return the key, else recirculate it.               */
  331.             /****************************************************************/
  332.             if( (key==LEFTMOUSECLICK) || (key==UP) || (key==DOWN) )
  333.             {
  334.              if( key==LEFTMOUSECLICK )
  335.              {
  336.               Event = GetCurrentEvent();                                          /*701*/
  337.  
  338.               if( Event->Row == row )
  339.               {
  340.                if( (segcol<=Event->Col) && (Event->Col<(segcol+4)))
  341.                {
  342.                 keycol = offcol;
  343.                 csroff = Event->Col - segcol;
  344.                 goto FlipFlop;
  345.                }
  346.                else if((offcol<=Event->Col) && (Event->Col<(offcol+4)))
  347.                {
  348.                 keycol = segcol;
  349.                 csroff = Event->Col - offcol;
  350.                 goto FlipFlop;
  351.                }
  352.               }
  353.              }
  354.  
  355.              SetDataViewCsr();
  356.              FormatDataItem( buffer+1, varptr, mid, tno, sfx );
  357.              buffer[0] = Attrib(vaStgVal);
  358.              buffer[5] = 0;
  359.              putrc( row, segcol, buffer );
  360.              buffer[5] = Attrib(vaStgVal);
  361.              buffer[10] = 0;
  362.              putrc( row, offcol, buffer + 5 );
  363.              rc = RECIRCULATE;
  364.              if( (GetEventView() != DATAVIEW) )
  365.               rc = key;
  366.             }
  367.             return(rc);
  368.  
  369.             case ESC:
  370.               return( rc );
  371.  
  372.             UpdatePointer:
  373.               if( ZapHexWord(ptr, sfx, buffer) )
  374.               {
  375.                csroff = n;
  376.                goto FlipFlop;
  377.               }
  378.               beep();
  379.               break;
  380.  
  381.             default:
  382.             Complain:
  383.               beep();
  384.               break;
  385.           }
  386.         }
  387.     /*  break; */
  388.     }
  389.     return(FALSE);
  390. }
  391.  
  392.  
  393.  uint
  394. ZapHexWord(uint ptr, uint sfx, uchar *hexstr )
  395. {
  396.     ushort hexval;
  397.  
  398.     x4tou(hexstr, &hexval);
  399.     if(  PutAppData(ptr, sizeof(hexval), ( uchar * )&hexval, sfx) ){
  400.         fmterr( CantZapMsg );
  401.         return( FALSE );  }
  402.     return( TRUE );
  403. }
  404.  
  405.  uint
  406. ZapHexDWord(uint ptr, uint sfx, uchar *hexstr )                         /*226*/
  407. {                                                                       /*226*/
  408.     uint hexval;                                                        /*226*/
  409.                                                                         /*226*/
  410.     x8tou(hexstr, &hexval);                                             /*226*/
  411.     if(  PutAppData(ptr, sizeof(hexval), ( uchar * )&hexval, sfx) ){    /*226*/
  412.         fmterr( CantZapMsg );                                           /*226*/
  413.         return( FALSE );  }                                             /*226*/
  414.     return( TRUE );                                                     /*226*/
  415. }
  416.  
  417.  uint
  418. x4tou(uchar *hexstr,ushort *valptr )
  419. {
  420.     uint c, n, mask, shift;             /* was register.                  112*/
  421.  
  422.     shift = 12;
  423.     mask = 0xF000;
  424.     for( n=0 ; n < strlen(hexstr) ; ++n, shift -= 4, mask >>= 4 ){      /*228*/
  425.         if( ((c = hexstr[n] - '0') > 9)
  426.          && (((c = hexstr[n] - ('A'-10)) < 10) || (c > 15)) )
  427.           c = 0;                                                        /*228*/
  428.         *valptr &= ~mask;
  429.         *valptr |= (c << shift);
  430.      }
  431.     for(; n < 4 ; ++n, shift -= 4, mask >>= 4 )                         /*228*/
  432.         *valptr &= ~mask;                                               /*228*/
  433.     return( TRUE );
  434. }
  435.  
  436.  uint
  437. x8tou(uchar *hexstr, uint *valptr )                  /* added for ZapRegs 108*/
  438. {
  439.     uint c, n, mask, shift;             /* was register.                  112*/
  440.  
  441.     shift = 28;
  442.     mask = 0xF0000000;
  443.     for( n=0 ; n < strlen(hexstr) ; ++n, shift -= 4, mask >>= 4 ){      /*228*/
  444.         if( ((c = hexstr[n] - '0') > 9)
  445.          && (((c = hexstr[n] - ('A'-10)) < 10) || (c > 15)) )
  446.           c = 0;                                                        /*228*/
  447.         *valptr &= ~mask;
  448.         *valptr |= (c << shift);
  449.     }
  450.     for(; n < 8 ; ++n, shift -= 4, mask >>= 4 )                         /*228*/
  451.         *valptr &= ~mask;                                               /*228*/
  452.     return( TRUE );
  453. }
  454.  
  455.  
  456. #define NTYPES 9
  457. static uint dhid[NTYPES] = {
  458.                              HELP_DATA_CHAR,
  459.                              HELP_DATA_UCHAR,
  460.                              HELP_DATA_INT,
  461.                              HELP_DATA_UINT,
  462.                              HELP_DATA_LONG,
  463.                              HELP_DATA_ULONG,
  464.                              HELP_DATA_FLOAT,
  465.                              HELP_DATA_DOUBLE,
  466.                              HELP_DATA_LDOUBLE
  467.                            };
  468.  
  469. uint                                    /*                                521*/
  470. ZapScalar(DFILE *dfp , uint row, uint skip )
  471. {
  472.     return( skip ? FALSE :
  473.       KeyScalar(dfp->mid, dfp->showtype, dfp->sfx, row , 0 , ExprAddr) );
  474. }
  475.  
  476. /* Procedure:   KeyScalar
  477.  *
  478.  * Input:
  479.  *
  480.  * Description:
  481.  */
  482.  
  483. static  uchar ClrSfld[] = { Attrib(vaStgPro), RepCnt(0), ' ', 0 };
  484. #define ClrSfldLen ClrSfld[2]
  485.  
  486.  
  487.  int
  488. KeyScalar(uint mid,uint tno,uint sfx,uint row,uint col,uint varptr )
  489. {
  490.     uint n;                             /* was register.                  112*/
  491.     uint nbytes, csroff=0;
  492.     ULONG helpid;
  493.     uchar buffer[DATALINESPAN];
  494.     uchar answer[ sizeof(long double) ];/* was sizeof(double).            813*/
  495.     uint rc = TRUE;                     /*                                701*/
  496.     uint key;                           /*                                701*/
  497.     PEVENT Event;                       /*                                701*/
  498.  
  499.     /*************************************************************************/
  500.     /*   if we come in with a mouse event that is not in the storage      701*/
  501.     /*   area then just kick it back out.                                 701*/
  502.     /*************************************************************************/
  503.     Event = GetCurrentEvent();                                          /*701*/
  504.     if( Event->Type == TYPE_MOUSE_EVENT )                               /*701*/
  505.     {                                                                   /*701*/
  506.      if( GetStorageArea(Event) != STORAGEAREA )                         /*701*/
  507.       return( TRUE );                                                   /*701*/
  508.     }                                                                   /*701*/
  509.     ClrSfld[0] = Attrib(vaStgPro);                                      /*701*/
  510.  
  511.     tno = HandleUserDefs(mid,tno);      /* Get primitive typeno in case   512*/
  512.                                         /* of primitive user defs.        512*/
  513.  
  514.  
  515.     if( !(nbytes = QtypeSize(mid, tno))
  516.      || ((n = windex(dtab, NTYPES, tno)) == NTYPES)
  517.       ) return( FALSE );
  518.     helpid = dhid[n];
  519.  
  520.     if (col)                            /* if the var is part of an array    */
  521.        {                                /* or struct, indicated by its nam   */
  522.         if ( col <= TAB1 )  col = TAB1; /* displayed beyond STGCOL, move     */
  523.         else  col = TAB2;               /* to a TAB pos based on length of   */
  524.        }                                /* name.                             */
  525.  
  526.     col += STGCOL-1;
  527.  
  528.     ClrSfldLen = ( uchar )(VideoCols - col);
  529.     putrc( row, col, ClrSfld );
  530.  
  531.     memset( buffer,0, sizeof(buffer) );                                 /*101*/
  532.     FormatDataItem( buffer, varptr, mid, tno, sfx );
  533.     *(strchr(buffer,' ')) = '\0';                                           /*813*/
  534.     VideoAtr = vaStgPro;
  535.     putrc( row, col, buffer );
  536.  
  537.     for(;;){
  538.         key=GetString(row,col,ClrSfldLen,ClrSfldLen,&csroff,buffer,0, NULL);
  539.         switch( key )
  540.         {
  541.           case UP:
  542.           case DOWN:
  543.           case LEFTMOUSECLICK:
  544.           case ENTER:
  545.           if( (key==UP) || (key==DOWN) )
  546.           {
  547.            Event->Type =  TYPE_MOUSE_EVENT;
  548.            Event->Col  =  col;
  549.            Event->Row  =  (key == DOWN )?row+1:row-1;
  550.           }
  551.  
  552.           if( strlen(buffer) == 0 )
  553.               goto Fini;
  554.           if( !ParseScalar(buffer, tno, ( ulong * )answer) ){
  555.               fmterr( BadDataMsg );
  556.           }else if(  PutAppData(varptr, nbytes, answer, sfx) ){
  557.               fmterr( CantZapMsg );
  558.           }else
  559.           {
  560.            /****************************************************************/
  561.            /* On a left mouse click:                                       */
  562.            /*                                                              */
  563.            /*  - put the storage field into it's normal color.             */
  564.            /*  - set the default video attribute and write buffer.         */
  565.            /*  - format the data item.                                     */
  566.            /*  - set the cursor to the location of the click in the        */
  567.            /*    storage window.                                           */
  568.            /*  - recirculate or return the a LEFTMOUSECLICK.               */
  569.            /****************************************************************/
  570.            if( (key==LEFTMOUSECLICK) || (key==UP) || (key==DOWN) )
  571.            {
  572.             extern int DataRecalc;
  573.  
  574.               ClrSfld[0] = Attrib(vaStgVal);
  575.               putrc( row, col, ClrSfld );
  576.               VideoAtr = vaStgVal;
  577.               memset(buffer,' ',sizeof(buffer));
  578.               buffer[0] = Attrib(vaStgExp);
  579.               buffer[STGCOL] = Attrib(vaStgVal);
  580.               buffer[sizeof(buffer)-1] = 0;
  581.               DataRecalc = TRUE;
  582.               FormatDataItem( buffer, varptr, mid, tno, sfx );
  583.               putrc( row, col, buffer );
  584.               SetDataViewCsr();
  585.               rc = RECIRCULATE;
  586.               if( key == LEFTMOUSECLICK )
  587.                rc = key;
  588.            }
  589.            goto Fini;
  590.           }
  591.           break;
  592.  
  593.           case F1:
  594.             Help( helpid );
  595.             break;
  596.           case ESC:
  597.             goto Fini;
  598.           default:
  599.             beep();
  600.     }   }
  601.     Fini:
  602.         if( (key==UP) || (key==DOWN) )                                  /*701*/
  603.          return(key);                                                   /*701*/
  604.         return( rc   );                 /*                                701*/
  605. }
  606.  
  607.  
  608. static jmp_buf ConversionError = {0};
  609.  
  610.  int
  611. ParseScalar(uchar *strval,uint datatype,ulong *valptr )
  612. {
  613.     ulong ans, limit;                   /* was register.                  112*/
  614.  
  615.     if( setjmp(ConversionError) ){
  616.         goto Failed;  }
  617.  
  618.     switch( datatype ){
  619.       case TYPE_CHAR:
  620.         limit = 127;  goto SignedNumber;
  621.       case TYPE_UCHAR:
  622.         if( (ans = cvtnum(strval, FALSE)) > 255 )  goto Failed;  break;
  623.       case TYPE_SHORT:                  /*                                101*/
  624.         limit = MAXINT;  goto SignedNumber;
  625.       case TYPE_USHORT:                 /*                                101*/
  626.         if( (ans = cvtnum(strval, FALSE)) > MAXUINT )  goto Failed;  break;
  627.       case TYPE_LONG:
  628.         ans = cvtnum(strval, TRUE);  break;
  629.       case TYPE_ULONG:
  630.         ans = cvtnum(strval, FALSE);  break;
  631.       SignedNumber:
  632.         ans = cvtnum(strval, TRUE);
  633.         if( ((long)ans > (long)limit) || ((long)ans < (long)(-(int)(limit+1))) )
  634.             goto Failed;
  635.         break;
  636.  
  637.       case TYPE_FLOAT:                                                  /*813*/
  638.       case TYPE_DOUBLE:                                                 /*813*/
  639.       case TYPE_LDOUBLE:                                                /*813*/
  640.        /******************************************************************813*/
  641.        /* Mask all the floating point exceptions while we execute the .   813*/
  642.        /* sprintf. The debugger may trap if we don't do this.             813*/
  643.        /*                                                                 813*/
  644.        /******************************************************************813*/
  645.        _control87(0x37f,0xffff);                                        /*813*/
  646.        switch(datatype)                                                 /*813*/
  647.        {                                                                /*813*/
  648.         case TYPE_FLOAT:                                                /*813*/
  649.          *(float*)valptr = (float) atof(strval);                        /*813*/
  650.          break;                                                         /*813*/
  651.                                                                         /*813*/
  652.         case TYPE_DOUBLE:                                               /*813*/
  653.          *(double*)valptr = atof(strval);                               /*813*/
  654.          break;                                                         /*813*/
  655.                                                                         /*813*/
  656.         case TYPE_LDOUBLE:                                              /*813*/
  657.          *(long double*)valptr = _atold(strval);                        /*813*/
  658.          break;                                                         /*813*/
  659.        }                                                                /*813*/
  660.        /******************************************************************813*/
  661.        /* - Clear any exceptions that may have occurred.                  813*/
  662.        /* - Reset the control word to the default value.                  813*/
  663.        /******************************************************************813*/
  664.        _clear87();                                                      /*813*/
  665.        _control87(CW_DEFAULT,0xffff);                                   /*813*/
  666.        return( TRUE );                                                  /*813*/
  667.     }
  668.     *valptr = ans;
  669.     return( TRUE );
  670.  
  671.     Failed:
  672.         return( FALSE );
  673. }
  674.  
  675.  
  676. #define BASE16PREFIX ('0'|(256*'x'))
  677. #define CVTLIMIT ((ulong)0xFFFFFFFF/10)
  678.  
  679.      ulong
  680. cvtnum(uchar *cp,uint IsSigned )
  681. {
  682.     ulong ans = 0;                      /* was register.                  112*/
  683.     uint  Negate = 0;                   /* was register.                  112*/
  684.  
  685.     while( *cp == ' ' )
  686.         ++cp;
  687.     if( IsSigned && (*cp == '-') )
  688.         Negate = *cp++;
  689.     if( *(twoc*)cp == BASE16PREFIX ){
  690.         int  c;                         /* was register.                  521*/
  691.         for( ++cp , c = *++cp; c  ;c = *++cp  )
  692.         {
  693.             if( (((c = tolower(c) - '0') < 0) || (c > 9))
  694.              && (((c -= 'a' - '0' - 10) < 10) || (c > 15))
  695.               ) break;
  696.             if( ans & 0xF0000000 )
  697.                 longjmp( ConversionError, 3 );
  698.             ans = (ans << 4) | c;
  699.         }
  700.     }else{
  701.         while( (*cp >= '0') && (*cp <= '9') ){
  702.             if( (ans > CVTLIMIT) || ((ans == CVTLIMIT) && (*cp > '5')) )
  703.                 longjmp( ConversionError, 2 );
  704.             ans = 10*ans + (*cp++ - '0');
  705.     }   }
  706.     while( *cp == ' ' )
  707.         ++cp;
  708.     if( *cp )  /* extra characters following number */
  709.         longjmp( ConversionError, 1 );
  710.  
  711.     return( Negate ? -(int)ans : ans );                                 /*521*/
  712. }
  713.  
  714.  int
  715. PutAppData(uint addr, uint  nbytes, uchar *pdata, uint sfx )            /*207*/
  716. {
  717.  
  718.     if( TestBit(addr,STACKADDRBIT) )                                    /*207*/
  719.     {                                                                   /*207*/
  720.      addr = StackBPRelToAddr( addr , sfx );                             /*207*/
  721.      if( addr == NULL )                                                 /*207*/
  722.             return( FALSE );                                            /*207*/
  723.     }else if( (addr >> REGADDCHECKPOS) == REGISTERTYPEADDR ){           /*205*/
  724.         if( sfx != 1 ){                     /* If not in the executing frame */
  725.             return( FALSE );
  726.     }   }
  727.     return( DBPut(addr, nbytes, pdata) );
  728. }
  729.