home *** CD-ROM | disk | FTP | other *** search
/ C!T ROM 2 / ctrom_ii_b.zip / ctrom_ii_b / PROGRAM / CLIPPER / NFORX11 / PEEK.C < prev    next >
C/C++ Source or Header  |  1993-08-17  |  2KB  |  62 lines

  1. /*
  2.  * File......: PEEK.C
  3.  * Author....: Ted Means
  4.  * Date......: $Date:   17 Aug 1993 19:40:16  $
  5.  * Revision..: $Revision:   1.1  $
  6.  * Log file..: $Logfile:   C:/nanfor/src/exo/peek.c_v  $
  7.  * 
  8.  * This function is an original work by Ted Means and is placed in the
  9.  * public domain.
  10.  *
  11.  * Modification history:
  12.  * ---------------------
  13.  *
  14.  * $Log:   C:/nanfor/src/exo/peek.c_v  $
  15.  * 
  16.  *    Rev 1.1   17 Aug 1993 19:40:16   GLENN
  17.  * Dieter Smode [CIS ID: 100034,243] noticed that the function creates a
  18.  * protected mode pointer but does not release the selector from the
  19.  * descriptor table.  Due to successive calls to FT_PEEK, the descriptor table
  20.  * would overflow.  Fixed.
  21.  * 
  22.  *    Rev 1.0   15 Jul 1993 22:46:16   GLENN
  23.  * Initial revision.
  24.  * 
  25.  */
  26.  
  27. /* Librarian's note:
  28.  *
  29.  * This source code is for a special version of ft_peek(), compatible
  30.  * with the ExoSpace (tm) DOS Extender from SofDesign, International.
  31.  * It is ExoSpace-specific and is maintained separately from the real
  32.  * mode version.
  33.  *
  34.  * The documentation can be found in the real-mode PEEK.C as
  35.  * distributed with the regular Nanforum Toolkit.
  36.  *
  37.  */ 
  38.  
  39.  
  40. #include "extend.h"
  41.  
  42. void *      ExoProtectedPtr(void *rmptr, unsigned int sizebytes);
  43. int         ExoFreeSelector(unsigned int);
  44.  
  45. CLIPPER FT_PEEK(void)
  46. {
  47.    auto unsigned char * byteptr;
  48.    auto unsigned char * pmptr;
  49.  
  50.    if ( (PCOUNT >= 2) && (ISNUM(1)) && (ISNUM(2)) )
  51.    {
  52.       * ((unsigned int *) &byteptr)     = _parni(2);
  53.       * ((unsigned int *) &byteptr + 1) = _parni(1);
  54.       pmptr = ExoProtectedPtr(byteptr, 8);
  55.       _retni( (unsigned int) (*pmptr) );
  56.     ExoFreeSelector(* ((unsigned int *) &pmptr + 1));
  57.    }
  58.    else
  59.       _retni( -1 );
  60.    return;
  61. }
  62.