home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 13 / 13.iso / s / s001 / 1.ddi / TS / SRC / CPYVARGS.C < prev    next >
Encoding:
C/C++ Source or Header  |  1990-01-08  |  1.2 KB  |  47 lines

  1.                  /******************************************
  2.            *        CPYVARGS.C             *
  3.                * Copyright TimeSlice, Inc. 1985, 86, 87. *
  4.                ******************************************/
  5. #include <ts.h>
  6.  
  7.  
  8. #if defined(MS) || defined(MD)
  9. #define CODEPTR 1
  10.  
  11. #else // if defined(MP) || defined(ML)
  12. #define CODEPTR 2
  13. #endif
  14.  
  15. /***
  16. * CPYVARGS( FRST, FROM, TO )
  17. * Copy all arguments of calling function from argument FROM.
  18. * These arguments are copied to end up just under TO. Thus TO will
  19. * point 1 byte above the last arg copied. The address of the first
  20. * argument of the callling function is passed as FRST.
  21. * Return a pointer to the bottom of the arguments copied.
  22. ***/
  23. int *cpyvargs( frst, from, to )
  24. int *frst, *from, *to;
  25. {
  26.   union {
  27.     int *ptr;
  28.     struct {
  29.       int off, seg;
  30.     } i;
  31.  } bp;
  32.  
  33. #if defined(TURBOC) && (defined(MS) || defined(MP))
  34. bp.i.off = frst[ - CODEPTR - 3 ];
  35. #elseif defined(TURBOC) && (defined(ML) || defined(MD))
  36. bp.i.off = frst[ - CODEPTR - 2 ];
  37. #else
  38. bp.i.off = frst[ - CODEPTR - 1 ];
  39. #endif
  40. #if defined(ML) || defined(MD)
  41.   bp.i.seg = d_seg( from );
  42. #endif
  43.   while( from < bp.ptr )
  44.     *--to = *--bp.ptr;
  45.   return to;
  46. }
  47.