home *** CD-ROM | disk | FTP | other *** search
/ Power CD-ROM!! 7 / POWERCD7.ISO / prgmming / clipper / gt_ucmpn.c < prev    next >
C/C++ Source or Header  |  1993-10-14  |  3KB  |  118 lines

  1. /*
  2.  * GT CLIPPER STANDARD HEADER
  3.  *
  4.  * File......: gt_ucmpn.c
  5.  * Author....: Brian Dukes
  6.  * BBS.......: THE CELLAR bbs
  7.  * Net/Node..: 013/203
  8.  * User Name.: Brian Dukes
  9.  * Date......: 28/5/93
  10.  * Revision..: 1.0
  11.  *
  12.  * This is an original work by Brian Dukes and is placed in the
  13.  * public domain.
  14.  *
  15.  * Modification history:
  16.  * ---------------------
  17.  *
  18.  * $Log$
  19.  *
  20.  */
  21.  
  22. /*
  23.  *  $DOC$
  24.  *  $FUNCNAME$
  25.  *      GT_UNCOMPN()
  26.  *  $CATEGORY$
  27.  *      Compression
  28.  *  $ONELINER$
  29.  *      UN-Compress a String to a Clipper Numeric value
  30.  *  $SYNTAX$
  31.  *      <numeric> := GT_UnCompN(<string>,<size>)
  32.  *  $ARGUMENTS$
  33.  *      <str>     - Character String to uncompress
  34.  *      <size>    - Number of Bytes of string to uncompress (1/2/4/8)
  35.  *  $RETURNS$
  36.  *      <numeric> - Clipper value uncompressed
  37.  *  $DESCRIPTION$
  38.  *      This function works hand-in-hand with GT_CompN(), this function
  39.  *      uncompress's strings that have previously been compressed.
  40.  *
  41.  *  $EXAMPLES$
  42.  *      #include "gt_compn.h"
  43.  *
  44.  *         s_w := GT_CompN( w, GT_BYTE)
  45.  *         s_x := GT_CompN( x, GT_INT )
  46.  *         s_y := GT_CompN( y, GT_LONG)
  47.  *         s_z := GT_CompN( z, GT_DOUBLE)
  48.  *
  49.  *         * Display the Values that were Stored
  50.  *
  51.  *         ? GT_UnCompN( s_w, GT_BYTE)
  52.  *         ? GT_UnCompN( s_x, GT_INT )
  53.  *         ? GT_UnCompN( s_y, GT_LONG)
  54.  *         ? GT_UnCompN( s_z, GT_DOUBLE)
  55.  *
  56.  *  $SEEALSO$
  57.  *      GT_COMPN()
  58.  *  $END$
  59.  */
  60.  
  61. /**** Compiled in MS/C v6.0  as  CL /AL /Gs /Zl -c gt_ucmpn.c        ****/
  62.  
  63. #include <extend.h>
  64. #include "gt_compn.h"
  65.  
  66. CLIPPER GT_UNCompN()
  67. {
  68.    char far * out   = _parc( 1 )  ;  /* Get pointer to Clipper string */
  69.    unsigned int siz = _parni( 2 ) ;  /* Get the SIZE of the Variable  */
  70.    int i_var    = 0 ;
  71.    long l_var   = 0 ;
  72.    double d_var = 0.00 ;
  73.  
  74.    switch (siz)
  75.       {
  76.          case GT_BYTE :
  77.             i_var = out[0] ;
  78.             _retni( i_var ) ;
  79.             break;
  80.  
  81.          case GT_INT :
  82.             _gt_copy_far(&i_var,out,GT_INT) ;
  83.             _retni( i_var ) ;
  84.             break;
  85.  
  86.          case GT_LONG :
  87.             _gt_copy_far(&l_var,out,GT_LONG) ;
  88.             _retnl( l_var ) ;
  89.             break;
  90.  
  91.          case GT_DOUBLE :
  92.             _gt_copy_far(&d_var,out,GT_DOUBLE) ;
  93.             _retnd( d_var ) ;
  94.             break;
  95.       }
  96.  
  97.    return ;
  98. }
  99.  
  100. /***************************************************************************
  101.  _gt_copy_far() - Copy Far Memory to Near Memory
  102.  ***************************************************************************/
  103.  
  104. int _gt_copy_far( char * out , char far * in , int len)
  105. {
  106.    int i = 0 ;
  107.    char far * fp = in ;
  108.    char * p = out ;
  109.  
  110.    while (i < len)
  111.       {
  112.          *p++ = *fp++ ;
  113.          ++i ;
  114.       }
  115.  
  116.    return (len) ;
  117. }
  118.