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

  1. /*
  2.  * GT CLIPPER STANDARD HEADER
  3.  *
  4.  * File......: gt_seg.c
  5.  * Author....: Brian Dukes
  6.  * BBS.......: THE CELLAR bbs
  7.  * Net/Node..: 013/203
  8.  * User Name.: Brian Dukes
  9.  * Date......: 10/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_SEGMENT()
  26.  *  $CATEGORY$
  27.  *      String
  28.  *  $ONELINER$
  29.  *      Returns the segment of the passed character string
  30.  *  $SYNTAX$
  31.  *      GT_Segment(<str>) --> nSegment
  32.  *  $ARGUMENTS$
  33.  *      <str>     - Character String
  34.  *  $RETURNS$
  35.  *      nSegment  - The segment of <str>.
  36.  *  $DESCRIPTION$
  37.  *      This function will become invaluable when calling GT_Int86()
  38.  *      functions, as some of these functions will need to know the address
  39.  *      of strings that are passed in.
  40.  *
  41.  *  $EXAMPLES$
  42.  *      ? GT_Segment(str)
  43.  *
  44.  *  $SEEALSO$
  45.  *      GT_OFFSET()   SYSTEM.EHO:GT_INT86()
  46.  *  $END$
  47.  */
  48.  
  49. /**** Compiled in MS/C v6.0  as  CL /AL /Gs /Zl -c gt_seg.c        ****/
  50.  
  51. #include <extend.h>
  52.  
  53. /* FP_SEG Ripped out of DOS.H - No need to include all the other junk from it */
  54.  
  55. #define FP_SEG(fp) (*((unsigned _far *)&(fp)+1))
  56.  
  57.  
  58. CLIPPER gt_segment()
  59. {
  60.    unsigned segment = 0 ;
  61.    char far * ptr ;
  62.  
  63.    if (_parinfo(1) == CHARACTER)
  64.       {
  65.          ptr = _parc(1) ;
  66.          segment = FP_SEG(ptr) ;
  67.       }
  68.  
  69.    _retni(segment) ;
  70. }
  71.  
  72. /**** end of function ****/
  73.