home *** CD-ROM | disk | FTP | other *** search
/ Datatid 1999 #6 / Datatid_1999-06.iso / internet / Tango352Promo / P.SQL / PTKPKG.1 / FIXPARMS.C < prev    next >
Encoding:
C/C++ Source or Header  |  1997-01-03  |  39.5 KB  |  1,707 lines

  1. /****************************************************************************
  2. **
  3. **     Copyright (c) 1982-1997 Pervasive Software Inc. All Rights Reserved.
  4. **
  5. ****************************************************************************/
  6. /****************************************************************************
  7.  FIXPARMS.C
  8.     This module contains fixparms() and unfixparms() to handle the SRB.
  9.  
  10. ****************************************************************************/
  11. #include <stdlib.h>
  12. #include <string.h>
  13. #include <sqlapi.h>
  14. #include <sqlconst.h>
  15. #include <btitypes.h>
  16. #include <fixparms.h>
  17. #include <wxqlords.h>
  18. #include <malloc.h>
  19. #include <mem.h>
  20.  
  21. /*
  22. **  Defines
  23. */
  24.  
  25. #define MAX_FCN_PARMS   12                  /* max. value in FcnParmCount[] */
  26. #define LOW_WORD    0xffff
  27. #define EOF_ERR  9
  28. #undef NEAR
  29. #define NEAR
  30. #undef FAR
  31. #define FAR
  32.  
  33. /*
  34. **  Prototypes
  35. */
  36.  
  37. extern BTI_SINT cnvToSeq(
  38.                    BTI_ULONG sig,
  39.                    BTI_SINT fcnin,
  40.                    BTI_SINT *fcnout );
  41.  
  42. BTI_SINT GetMaxDataSize(
  43.             PARMBLOCK *pb,
  44.             char ***from,
  45.             BTI_SINT fcn,
  46.             BTI_SINT indx,
  47.             BTI_ULONG *dataLen,
  48.             BTI_ULONG *itemCount,
  49.             BTI_ULONG *saveitemCount,
  50.             BTI_SINT *updallParmCount );
  51.  
  52. BTI_SINT GetSendDataSize(
  53.             PARMBLOCK *pb,
  54.             char ***from,
  55.             BTI_SINT fcn,
  56.             BTI_SINT indx,
  57.             BTI_WORD *dataLen,
  58.             BTI_WORD *itemCount,
  59.             BTI_WORD *saveitemCount,
  60.             BTI_SINT *updallParmCount );
  61.  
  62. BTI_SINT GetRecvDataSize(
  63.             PARMBLOCK *pb,
  64.             BTI_SINT fcn,
  65.             BTI_SINT indx,
  66.             BTI_WORD *dataLen );
  67.  
  68. BTI_SINT SetPtrData(
  69.             char ***from,
  70.             char ***to,
  71.             char *dataBuf,
  72.             char **dataBufCrwl,
  73.             BTI_WORD len,
  74.             BTI_SINT indx );
  75.  
  76. BTI_SINT SetConstData(
  77.             BTI_SINT **from,
  78.             BTI_SINT **to,
  79.             BTI_SINT indx,
  80.             BTI_WORD *dataLen,
  81.             BTI_WORD *itemCount );
  82.  
  83. BTI_SINT SetLongData(
  84.             BTI_ULONG **from,
  85.             BTI_ULONG **to,
  86.             BTI_SINT  indx,
  87.             BTI_ULONG *dataLen,
  88.             BTI_ULONG *itemCount );
  89.  
  90. BTI_SINT MovPtrData(
  91.             PARMBLOCK *pb,
  92.             char ***from,
  93.             char ***to,
  94.             char *dataBuf,
  95.             BTI_SINT fcn,
  96.             BTI_SINT indx,
  97.             BTI_WORD *dataLen );
  98.  
  99. BTI_SINT MovConstData(
  100.             BTI_SINT **from,
  101.             BTI_SINT **to,
  102.             BTI_SINT indx,
  103.             BTI_WORD *dataLen );
  104.  
  105. BTI_SINT MovLongData(
  106.             BTI_ULONG **from,
  107.             BTI_ULONG **to,
  108.             BTI_SINT indx,
  109.             BTI_ULONG *dataLen );
  110.  
  111. BTI_SINT SendData(
  112.             BTI_SINT indx );
  113.  
  114. BTI_SINT RetData(
  115.             BTI_SINT indx );
  116.  
  117. BTI_SINT PtrParm(
  118.             BTI_SINT indx );
  119.  
  120. BTI_SINT StrParm(
  121.             BTI_SINT indx );
  122.  
  123. BTI_SINT DataParm(
  124.             BTI_SINT indx );
  125.  
  126. BTI_SINT ConstParm(
  127.             BTI_SINT indx );
  128.  
  129. BTI_SINT LongParm(
  130.             BTI_SINT indx );
  131.  
  132. BTI_SINT LenParm(
  133.             BTI_SINT indx );
  134.  
  135. BTI_SINT CntParm(
  136.             BTI_SINT indx );
  137.  
  138. BTI_SINT SpecParm(
  139.             BTI_SINT indx );
  140.  
  141.  
  142. extern BTI_ULONG startOfRealPtr;
  143.  
  144. /*
  145. *****************************************************************************
  146. **  GetDBufPtr
  147. **
  148. **  Prototype:
  149. **
  150. **      char *GetDBufPtr(BTI_WORD fcn, PARMBLOCK *pb)
  151. **
  152. **  Description:
  153. **
  154. **      Returns a pointer to the variable portion of the parameter block.
  155. **
  156. **  Preconditions:
  157. **
  158. **      None.
  159. **
  160. **  Parameters:
  161. **
  162. **      fcn:            SSQL function number.
  163. **        <input>
  164. **
  165. **      *pb:            Pointer to the parameter block.
  166. **        <input>
  167. **
  168. **
  169. **  Return value:
  170. **
  171. **      Pointer to variable portion of the parameter block.
  172. **
  173. **  Globals:
  174. **
  175. **      None.
  176. **
  177. **  Called Functions:
  178. **
  179. **      FcnVariableLen[]
  180. **
  181. **  Comments:
  182. **
  183. **      None.
  184. **
  185. **
  186. *****************************************************************************
  187. */
  188. char *GetDBufPtr( BTI_WORD fcn, PARMBLOCK *pb )
  189. {
  190.    BTI_CHAR_PTR         dataBuf;
  191.    BTI_CHAR_PTR         unionData;
  192.    BTI_SINT             varLen;
  193.  
  194.    varLen = FcnVariableLen[ fcn ];
  195.    unionData = ((BTI_CHAR_PTR) pb) + (PARM_FIXED_LEN);
  196.    dataBuf = unionData + varLen + 2;
  197.  
  198.    return( dataBuf );
  199.  
  200. } /* end GetDBufPtr */
  201.  
  202.  
  203.  
  204. /*
  205. *****************************************************************************
  206. **
  207. **  Prototype:
  208. **
  209. **      BTI_SINT fixParms(
  210. **                  PARMBLOCK *from,
  211. **                  PARMBLOCK *to)
  212. **
  213. **  Description:
  214. **
  215. **      This function copies/converts data from "hard to address"
  216. **      parameter block to "easily addressable" parameter block.
  217. **
  218. **      Converts 32-bit pointers in the parameter block to real-mode
  219. **      pointers.  Data is copied to a contiguous block of memory.
  220. **      The real-mode pointers point to the copied data in the contiguous
  221. **      block.
  222. **
  223. **  Preconditions:
  224. **
  225. **      None.
  226. **
  227. **  Parameters:
  228. **
  229. **      *from:          Pointer to the input parameter that contains
  230. **        <input>       32-bit addresses
  231. **
  232. **      *to:            Pointer to contiguous block of memory.  Pointers
  233. **        <output>      in the parameter block are converted to 16-bit
  234. **                      addresses.
  235. **
  236. **  Return value:
  237. **
  238. **      SS_SUCCESS
  239. **      SQL_MEM_M
  240. **
  241. **
  242. **  Globals:
  243. **
  244. **      initParmOffsets
  245. **      ParmOffsets[]
  246. **      FcnParmCount[]
  247. **
  248. **  Called Functions:
  249. **
  250. **      malloc()
  251. **      free()
  252. **      GetDBufPtr()
  253. **      GetMaxDataSize()
  254. **      PtrParm()
  255. **      SetPtrData()
  256. **      ConstParm()
  257. **      SetConstData()
  258. **      LongParm()
  259. **      SetLongData()
  260. **
  261. **  Comments:
  262. **
  263. **      None.
  264. **
  265. *****************************************************************************
  266. */
  267. BTI_SINT fixParms( PARMBLOCK *from, PARMBLOCK *to )
  268.  
  269. {
  270.     BTI_WORD    i;
  271.     char        **tmpFromP;
  272.     BTI_SINT    fcn = (BTI_SINT) from->fcn;
  273.     char        *beginFromP, *beginTopP;
  274.     char        *dataBufCrwl = NULL;
  275.     BTI_SINT    updallParmCount;
  276.     BTI_SINT    indx;
  277.     BTI_SINT    stat = SS_SUCCESS;
  278.     BTI_WORD    totalLen, lenArray[MAX_FCN_PARMS];
  279.     BTI_ULONG   dataLen, itemCount, saveitemCount;
  280.  
  281.     /*
  282.     **   initialize the ParmOffSets array
  283.     */
  284.     if ( initParmOffsets )
  285.     {
  286.         indx = 0;
  287.         for ( i = 0; i < MAX_SSQL_FUNCTIONS; i++ )
  288.         {
  289.             ParmOffsets[i] = indx;
  290.             indx += FcnParmCount[i];
  291.         }
  292.         initParmOffsets = FALSE;
  293.     }
  294.  
  295.     /*
  296.     ** Convert the function number into a sequenced function number that
  297.     ** will access the information in the parameter tables correctly.
  298.     */
  299.     cnvToSeq( *((BTI_ULONG *) &(from->XQL_ID)), fcn, &fcn );
  300.  
  301.    /* copy the invariant data */
  302. #if defined(BTI_DOS_16B)
  303.     _fmemcpy( to->XQL_ID, from->XQL_ID, 4 );
  304. #else
  305.     memcpy( to->XQL_ID, from->XQL_ID, 4 );
  306. #endif
  307.     to->fcn = fcn;
  308.     to->cursorid = from->cursorid;
  309.     to->stat = from->stat;
  310.     to->sessionid = from->sessionid;
  311.  
  312.     if ( fcn != -1 )
  313.     {
  314.        /*
  315.        **  Initialize dataBufCrwl to point to the start of the variant data
  316.        **  in the parameter block.
  317.        */
  318.        dataBufCrwl = GetDBufPtr( fcn, to );
  319.  
  320.        /*
  321.        **  Some functions (XQLLogout, XQLCursor, XQLFree, etc...) don't have
  322.        **  variant data to copy.  Check for that by looking at the number
  323.        **  of parameters in the FcnParmCount array.
  324.        */
  325.        itemCount = 1;
  326.        if ( FcnParmCount[fcn] )
  327.        {
  328.           BTI_WORD len;
  329.  
  330.           totalLen = 0;
  331.           dataLen  = 0;
  332.           beginFromP = (char *) &(from->v);
  333.  
  334.           indx = ParmOffsets[ fcn ];     /* starting index into parmFlags */
  335.           for ( i = 0; (i < FcnParmCount[fcn]) && (!stat); i++, indx++ )
  336.           {
  337.              len = GetMaxDataSize(
  338.                       from,
  339.                       (char ***) &beginFromP,
  340.                       fcn,
  341.                       indx,
  342.                       &dataLen,
  343.                       &itemCount,
  344.                       &saveitemCount,
  345.                       &updallParmCount );
  346.  
  347.              lenArray[i] = len;
  348.              totalLen += len;
  349.  
  350.                       /* for mallocing purposes, round up to nearest quad */
  351.              len += 4 - (len % 4);
  352.  
  353.           } /* end for */
  354.  
  355.           /* end if */
  356.  
  357.  
  358.           if ( stat == SS_SUCCESS )
  359.           {
  360.              beginFromP = (char *) &(from->v);
  361.              beginTopP = (char *) &(to->v);
  362.              indx = ParmOffsets[ fcn ];    /* starting index into parmFlags */
  363.              dataLen = 0;
  364.  
  365.              for ( i = 0; (i < FcnParmCount[fcn]) && (!stat); i++, indx++ )
  366.              {
  367.                 if ( PtrParm( indx ) )
  368.                 {
  369.                    stat = SetPtrData(
  370.                              (char ***) &beginFromP,
  371.                              (char ***) &beginTopP,
  372.                              (char *) to,   /* Beginning of parameter block */
  373.                              (char **) &dataBufCrwl,
  374.                              lenArray[i],
  375.                              indx );
  376.                 }
  377.                 else if ( ConstParm( indx ) )
  378.                 {
  379.                    stat = SetConstData(
  380.                              (BTI_SINT **) &beginFromP,
  381.                              (BTI_SINT **) &beginTopP,
  382.                              indx,
  383.                              (BTI_WORD *) &dataLen,
  384.                              (BTI_WORD *) &itemCount );
  385.                 }
  386.                 else if ( LongParm( indx ) )
  387.                 {
  388.                    stat = SetLongData(
  389.                              (BTI_ULONG **) &beginFromP,
  390.                              (BTI_ULONG **) &beginTopP,
  391.                              indx,
  392.                              &dataLen,
  393.                              &itemCount );
  394.                 } /* end if-else */
  395.              } /* end for */
  396.           } /* end if */
  397.  
  398.        } /* end if */
  399.     }
  400.     return( stat );
  401.  
  402. } /* end fixParms */
  403.  
  404. /*
  405. *****************************************************************************
  406. **  SetPtrData
  407. **
  408. **  Prototype:
  409. **
  410. **      BTI_SINT SetPtrData( char ***from, char ***to,
  411. **          char *dataBuf, char **dataBufCrwl, BTI_WORD len, BTI_SINT indx )
  412. **
  413. **  Description:
  414. **
  415. **      Copy pointer data from parameter block containing 32-bit pointers
  416. **      into contiguous memory locations in destination parameter block.
  417. **
  418. **  Preconditions:
  419. **
  420. **      None.
  421. **
  422. **  Parameters:
  423. **
  424. **      ***from:        Pointer to input parameter block containing
  425. **        <input/       32-bit pointers
  426. **         output>
  427. **
  428. **      ***to:          Pointer to output parameter block containing
  429. **        <input/       16-bit pointers.
  430. **         output>
  431. **
  432. **      *dataBuf:       Pointer to start of destination parameter block
  433. **        <input>
  434. **
  435. **      **dataBufCrwl:  Pointer to current position in the destination
  436. **        <input/       parameter block.
  437. **         output>
  438. **
  439. **      len:            Maximum length of the data to copy
  440. **        <input>
  441. **
  442. **      indx:           Index number of the SSQL parameter.
  443. **        <input>
  444. **
  445. **
  446. **  Return value:
  447. **
  448. **      0
  449. **
  450. **  Globals:
  451. **
  452. **      None.
  453. **
  454. **  Called Functions:
  455. **
  456. **      SendData()
  457. **      StrParm()
  458. **
  459. **  Comments:
  460. **
  461. **      None.
  462. **
  463. **
  464. *****************************************************************************
  465. */
  466. BTI_SINT SetPtrData( char ***from, char ***to,
  467.     char *dataBuf, char **dataBufCrwl, BTI_WORD len, BTI_SINT indx )
  468.  
  469. {
  470.    char *tmpFrom;
  471.  
  472.    tmpFrom = **from;
  473.  
  474.    if ( len && ( tmpFrom != NULL ) )
  475.    {
  476.       if ( SendData( indx ) )
  477.       {
  478.          **to = *dataBufCrwl;
  479. #if defined(BTI_DOS_16B)
  480.          _fmemcpy( **to, tmpFrom, len );
  481. #else
  482.          memcpy( **to, tmpFrom, len );
  483. #endif
  484.          if ( StrParm( indx ) )
  485.          {
  486.             /*
  487.             **  note that we reserve one byte for the 0 terminator
  488.             **  for strings in GetMaxDataSize().
  489.             */
  490.  
  491.             *((**to)+len-1) = 0;
  492.          } /* end if */
  493.       } /* end if */
  494.       /*
  495.       ** Calculate the offset of the current position from the beginning
  496.       ** of the block.  Then add this value to the address of our real-mode
  497.       ** buffer to calculate the 16-bit addresses.
  498.       */
  499.       **to = (char *) ((BTI_ULONG)(*dataBufCrwl - dataBuf) + startOfRealPtr);
  500.  
  501.       *dataBufCrwl += len;
  502.    }
  503.    else
  504.    {
  505.       **to = NULL;
  506.    } /* end if-else */
  507.  
  508.    /* advance over pointers */
  509.    (*to)++;
  510.    (*from)++;
  511.    return( 0 );
  512.  
  513. } /* end SetPtrData */
  514.  
  515.  
  516. /*
  517. *****************************************************************************
  518. **  SetConstData
  519. **
  520. **  Prototype:
  521. **
  522. **      BTI_SINT SetConstData(BTI_SINT **from, BTI_SINT **to, BTI_SINT indx,
  523. **          BTI_WORD *dataLen, BTI_WORD *itemCount)
  524. **
  525. **  Description:
  526. **
  527. **      copy two-byte data from "hard to address" parameter block to
  528. **      "easily addressable" parameter block.
  529. **
  530. **  Preconditions:
  531. **
  532. **      None.
  533. **
  534. **  Parameters:
  535. **
  536. **      **from:
  537. **        <input>
  538. **
  539. **      **to:
  540. **        <input>
  541. **
  542. **      indx:
  543. **        <input>
  544. **
  545. **      *dataLen:
  546. **        <input>
  547. **
  548. **      *itemCount:
  549. **        <input>
  550. **
  551. **
  552. **  Return value:
  553. **
  554. **      None.
  555. **
  556. **  Globals:
  557. **
  558. **      None.
  559. **
  560. **  Called Functions:
  561. **
  562. **      None.
  563. **
  564. **  Comments:
  565. **
  566. **       Since SetConstData() is also used while calculating max sizes
  567. **       to/from (i.e. it needs to be called to set *dataLen or *itemCount)
  568. **       "to" can be NULL.  This needs to be checked for.
  569. **
  570. *****************************************************************************
  571. */
  572. BTI_SINT SetConstData(BTI_SINT **from, BTI_SINT **to, BTI_SINT indx,
  573.     BTI_WORD *dataLen, BTI_WORD *itemCount)
  574.  
  575. {
  576.     *itemCount = 1;
  577.     if (SendData(indx))
  578.     {
  579.         if (LenParm(indx))
  580.         {
  581.             *dataLen = **from;
  582.         }
  583.         else if (CntParm(indx))
  584.         {
  585.             *itemCount = **from;
  586.         } /* end if-else */
  587.  
  588.         if (to != NULL)
  589.         {
  590.             **to = **from;
  591.         } /* end if */
  592.     } /* end if */
  593.  
  594.     (*from)++;
  595.  
  596.     if (to != NULL)
  597.     {
  598.         (*to)++;
  599.     } /* end if */
  600.  
  601.     return(0);
  602. }
  603.  
  604. /*
  605. *****************************************************************************
  606. **  SetLongData
  607. **
  608. **  Prototype:
  609. **
  610. **      BTI_SINT SetLongData( BTI_ULONG **from, BTI_ULONG **to, BTI_SINT indx,
  611. **                            BTI_ULONG *dataLen, BTI_ULONG *itemCount )
  612. **
  613. **  Description:
  614. **
  615. **      Copy four byte data from "hard to address" parameter block to
  616. **      "easily addressable" parameter block.
  617. **
  618. **  Preconditions:
  619. **
  620. **      None.
  621. **
  622. **  Parameters:
  623. **
  624. **      **from:
  625. **        <input>
  626. **
  627. **      **to:
  628. **        <input>
  629. **
  630. **
  631. **  Return value:
  632. **
  633. **      None.
  634. **
  635. **  Globals:
  636. **
  637. **      None.
  638. **
  639. **  Called Functions:
  640. **
  641. **      SendData()
  642. **      LenParm()
  643. **      CntParm()
  644. **
  645. **  Comments:
  646. **
  647. **      None.
  648. **
  649. *****************************************************************************
  650. */
  651. BTI_SINT SetLongData( BTI_ULONG **from, BTI_ULONG **to, BTI_SINT indx,
  652.     BTI_ULONG *dataLen, BTI_ULONG *itemCount )
  653.  
  654. {
  655.     *itemCount = 1;
  656.     if ( SendData( indx ) )
  657.     {
  658.         if ( LenParm( indx ) )
  659.         {
  660.             *dataLen = **from;
  661.         }
  662.         else if ( CntParm( indx ) )
  663.         {
  664.             *itemCount = **from;
  665.         } /* end if-else */
  666.  
  667.         if ( to != NULL )
  668.         {
  669.             **to = **from;
  670.         } /* end if */
  671.     } /* end if */
  672.  
  673.     (*from)++;
  674.  
  675.     if (to != NULL)
  676.     {
  677.         (*to)++;
  678.     } /* end if */
  679.  
  680.     return( 0 );
  681. }
  682.  
  683. /*
  684. *****************************************************************************
  685. **  GetMaxDataSize
  686. **
  687. **  Prototype:
  688. **
  689. **      BTI_SINT GetMaxDataSize( PARMBLOCK *pb,
  690. **          char ***from, BTI_SINT fcn, BTI_SINT indx,
  691. **          BTI_ULONG *dataLen, BTI_ULONG *itemCount,
  692. **          BTI_ULONG *saveitemCount, BTI_SINT *updallParmCoun      len = pb->v.tddattrData.bufsize;
  693.              else
  694.                 len = 0;
  695.              dontCalcLen = TRUE;
  696.              break;
  697.  
  698.           case spDDDrpFcn:
  699.              /*
  700.              ** Set itemCount to indicate that owner name follows index name
  701.              */
  702.              len = parmLength[ indx ];
  703.              *itemCount = 1;
  704.              if ( pb->v.tdddropData.filetype & 0x100 )
  705.              {
  706.                 *itemCount = 2;
  707.                 len += 9;                              er
  708. **        <input>
  709. **
  710. **      *dataLen:               Length of the data.
  711. **        <output>
  712. **
  713. **      *itemCount:             Number of items
  714. **        <output>
  715. **
  716. **      *saveitemCount:         Saved item count.
  717. **        <output>
  718. **
  719. **      *updallParmCount:       Parameter count for updall function.
  720. **        <output>
  721. **
  722. **
  723. **  Return value:
  724. **
  725. **      None.
  726. **
  727. **  Globals:
  728. **
  729. **      None.
  730. **
  731. **  Called Functions:
  732. **
  733. **      PtrParm()
  734. **      SendData()
  735. **      GetSendDataSize()
  736. **      RetData()
  737. **      GetRecvDataSize()
  738. **      ConstParm()
  739. **      SetConstData()
  740. **      LongParm()
  741. **      SetLongData()
  742. **
  743. **
  744. **  Comments:
  745. **
  746. **      None.
  747. **
  748. *****************************************************************************
  749. */
  750. BTI_SINT GetMaxDataSize( PARMBLOCK *pb,
  751.     char ***from, BTI_SINT fcn, BTI_SINT indx,
  752.     BTI_ULONG *dataLen, BTI_ULONG *itemCount, BTI_ULONG *saveitemCount,
  753.     BTI_SINT *updallParmCount)
  754.  
  755. {
  756.    BTI_WORD len, lenSend, lenRecv;
  757.  
  758.    len = lenSend = lenRecv = 0;
  759.  
  760.    /* advance over pointer */
  761.    if ( PtrParm( indx ) )
  762.    {
  763.       if ( SendData( indx ) )
  764.       {
  765.          lenSend = GetSendDataSize(
  766.                       pb,
  767.                       from,
  768.                       fcn,
  769.                       indx,
  770.                       (BTI_WORD *) dataLen,
  771.                       (BTI_WORD *) itemCount,
  772.                       (BTI_WORD *) saveitemCount,
  773.                       updallParmCount );
  774.       } /* end if */
  775.  
  776.       if ( RetData( indx ) )
  777.       {
  778.          lenRecv = GetRecvDataSize( pb, fcn, indx, (BTI_WORD *)dataLen );
  779.       } /* end if */
  780.  
  781.       (*from)++;
  782.    }
  783.    else if ( ConstParm( indx ) )
  784.    {
  785.       SetConstData( (BTI_SINT **) from, NULL, indx, (BTI_WORD *)dataLen,
  786.                    (BTI_WORD *)itemCount );
  787.    }
  788.    else if ( LongParm( indx ) )
  789.    {
  790.       SetLongData(
  791.          (BTI_ULONG **) from,
  792.          NULL,
  793.          indx,
  794.          dataLen,
  795.          itemCount );
  796.    } /* end if-else */
  797.  
  798.    /* take maximum */
  799.    len = max( lenSend, lenRecv );
  800.  
  801.    return( len );
  802.  
  803. } /* end GetMaxDataSize */
  804.  
  805.  
  806. /*
  807. *****************************************************************************
  808. **  GetSendDataSize
  809. **
  810. **  Prototype:
  811. **
  812. **      BTI_SINT GetSendDataSize(
  813. **                  PARMBLOCK *pb,
  814. **                  char ***from,
  815. **                  BTI_SINT fcn,
  816. **                  BTI_SINT indx,
  817. **                  BTI_WORD *dataLen,
  818. **                  BTI_WORD *itemCount,
  819. **                  BTI_WORD *saveitemCount,
  820. **                  BTI_SINT *updallParmCount )
  821. **
  822. **  Description:
  823. **
  824. **      Calculate the size of the current block being sent.
  825. **
  826. **  Preconditions:
  827. **
  828. **      None.
  829. **
  830. **  Parameters:
  831. **
  832. **      *pb:            Pointer to input parameter block.
  833. **        <input>
  834. **
  835. **      ***from:        Pointer to variant data in the parameter block
  836. **        <input>
  837. **
  838. **      fcn:            SSQL function number
  839. **        <input>
  840. **
  841. **      indx:           SSQL parameter index.
  842. **        <input>
  843. **
  844. **      *dataLen:       Contains the length of the data
  845. **        <output>
  846. **
  847. **      *itemCount:     Contains the number of items for a count parameter
  848. **        <output>
  849. **
  850. **      *saveitemCount: Saves the item count for a count parameter.
  851. **        <output>
  852. **
  853. **      *updallParmCount:  Parameter count for updall
  854. **        <output>
  855. **
  856. **
  857. **  Return value:
  858. **
  859. **      Length of the data.
  860. **
  861. **
  862. **  Globals:
  863. **
  864. **      None.
  865. **
  866. **  Called Functions:
  867. **
  868. **      SpecParm()
  869. **      StrParm()
  870. **
  871. **  Comments:
  872. **
  873. **      None.
  874. **
  875. *****************************************************************************
  876. */
  877. BTI_SINT GetSendDataSize(
  878.             PARMBLOCK *pb,
  879.             char ***from,
  880.             BTI_SINT fcn,
  881.             BTI_SINT indx,
  882.             BTI_WORD *dataLen,
  883.             BTI_WORD *itemCount,
  884.             BTI_WORD *saveitemCount,
  885.             BTI_SINT *updallParmCount )
  886.  
  887. {
  888.    char *f, *UserP;
  889.    int Count;
  890.    BTI_SINT dontCalcLen = FALSE;
  891.    BTI_SINT i, stat = SS_SUCCESS;
  892.    BTI_SINT len;  /* Will contain the number of bytes to copy for this call */
  893.    BTI_SINT maxlen;                  /* maximum length for individual item  */
  894.  
  895.  
  896.    len = 0;
  897.    if ( SpecParm( indx ) )
  898.    {
  899.       switch ( fcn )
  900.       {
  901.           case smCnvFcn:
  902.           case spCnvFcn:
  903.              len = ((pb->v.tcnvData.option & 0xFF) == 0) ?
  904.                       pb->v.tcnvData.size : pb->v.tcnvData.dsize;
  905.              if ( len <= 0 )
  906.                  stat = SQL_INVALID_DATA_SIZE;
  907.              else
  908.                  dontCalcLen = TRUE;
  909.              break;
  910.  
  911.           case spInsertFcn:
  912.           case spUpdateFcn:
  913.              len = 0;
  914.              if ( StrParm( indx ) )
  915.              {
  916.                 f = pb->v.teditData.filelist;
  917.  
  918.                 if ( f != NULL )
  919.                 {
  920.                    for (
  921.                       indx = len = 0;
  922.                       indx < pb->v.teditData.filecount;
  923.                       indx++ )
  924.                    {
  925.                       len += _fstrlen( f ) + sizeof(char);
  926.                       f += _fstrlen( f ) + sizeof(char);
  927.                    } /* end for */
  928.  
  929.                    len++;
  930.                 } /* end if */
  931.              }
  932.              else
  933.              {   /* count * record size */
  934.                 f = pb->v.teditData.buf;
  935.  
  936.                 if ( f != NULL )
  937.                 {
  938.                    for (
  939.                       indx = len = 0;
  940.                       indx < pb->v.teditData.editcount;
  941.                       indx++ )
  942.                    {
  943.                       BTI_SINT tmp;
  944.  
  945.                       tmp = *(BTI_SINT *) f;
  946.  
  947.                       len += tmp + sizeof(BTI_SINT);
  948.                       f += tmp + sizeof(BTI_SINT);
  949.                    } /* end for */
  950.                 } /* end if */
  951.              }
  952.              dontCalcLen = TRUE;
  953.              break;
  954.  
  955.           case spDescribeFcn:
  956.              if ( pb->v.tdescData.position == -1 )
  957.                 len = *dataLen;
  958.              else
  959.                 len = 0;
  960.              dontCalcLen = TRUE;
  961.              break;
  962.  
  963.           case spFetchFcn:
  964.              if ( (pb->v.tfetchData.option & 0x100) ||
  965.                   pb->v.tfetchData.option == 6 ||
  966.                   pb->v.tfetchData.option == 8 )
  967.                 len = *dataLen;
  968.              else
  969.                 len = 0;
  970.              dontCalcLen = TRUE;
  971.              break;
  972.  
  973.           case spDDAttrFcn:
  974.              if ( pb->v.tddattrData.fcn < 2 )
  975.                 len = pb->v.tddattrData.bufsize;
  976.              else
  977.                 len = 0;
  978.              dontCalcLen = TRUE;
  979.              break;
  980.  
  981.           case spDDDrpFcn:
  982.              /*
  983.              ** Set itemCount to indicate that owner name follows index name
  984.              */
  985.              len = parmLength[ indx ];
  986.              *itemCount = 1;
  987.              if ( pb->v.tdddropData.filetype & 0x100 )
  988.              {
  989.                 *itemCount = 2;
  990.                 len += 9;                               /* owner name size  */
  991.              }
  992.              break;
  993.  
  994.           case spDDFileFcn:
  995.              /*
  996.              ** owner name may be set on input in the output buffer
  997.              */
  998.              len = 9;                                   /* owner name size  */
  999.              break;
  1000.  
  1001.           case spDDCreFcn:
  1002.           case spDDModFcn:
  1003.              dontCalcLen = TRUE;
  1004.  
  1005.              if ( ((pb->v.tmodData.option & 0xFF) == 3) ||
  1006.                   ((pb->v.tmodData.option & 0xFF) == 4))
  1007.                 len = C20;
  1008.              else
  1009.              {
  1010.                 len = parmLength[ indx ];
  1011.                 len *= *itemCount;
  1012.              }
  1013.              break;
  1014.  
  1015.           case spUserFcn:
  1016.              if ( (pb->v.tuserData.fcn & 0xFF) == 4 )
  1017.                 len = C30;
  1018.              else
  1019.                 len = 0;
  1020.              dontCalcLen = TRUE;
  1021.              break;
  1022.  
  1023.           case spAccessFcn:
  1024.               if ( (pb->v.taccessData.fcn & 0xFF) < 2 )
  1025.                  len = pb->v.taccessData.buflen;
  1026.               else
  1027.                  len = 0;
  1028.               dontCalcLen = TRUE;
  1029.               break;
  1030.  
  1031.           case spStoreFcn:
  1032.               len = *dataLen;     /* use length from user  */
  1033.               dontCalcLen = TRUE;
  1034.               break;
  1035.  
  1036.           default:
  1037.               break;
  1038.       }
  1039.    }
  1040.    else
  1041.    {
  1042.       if ( fcn == spUpdallFcn )
  1043.       {
  1044.          /*
  1045.          ** for update field and replace field, item count is the same;
  1046.          ** loop below decrements itemCount so save it here, then restore
  1047.          ** for second time around.
  1048.          */
  1049.          (*updallParmCount)++;
  1050.          if ( *updallParmCount == 2 )
  1051.             *saveitemCount = *itemCount;
  1052.          else if ( *updallParmCount == 3 )
  1053.             *itemCount = *saveitemCount;
  1054.       }
  1055.  
  1056.       len = parmLength[ indx ];                          /* get max length  */
  1057.       if ( len )
  1058.       {
  1059.          if ( *itemCount && !StrParm( indx ) )
  1060.          {
  1061.             len *= *itemCount;
  1062.             dontCalcLen = TRUE;
  1063.          }
  1064.       }
  1065.       else
  1066.       {
  1067.          len = *dataLen;                            /* use length from user */
  1068.          if ( DataParm( indx ) )
  1069.             dontCalcLen = TRUE;
  1070.       }
  1071.    } /* end if-else */
  1072.  
  1073.    if ( len > 0 )
  1074.    {
  1075.       if ( !dontCalcLen )
  1076.       {   /* we've only got an idea of the _max_ that must be copied */
  1077.  
  1078.          maxlen = len;
  1079.          len = 0;
  1080.          Count = (int) *itemCount;
  1081.  
  1082.          UserP = **from;
  1083.  
  1084.          /*
  1085.          ** don't want to copy negative data do we?  Also, no sense in
  1086.          ** trying to access a NULL pointer.
  1087.          */
  1088.          if ( (Count < 0) || (UserP == NULL) )
  1089.             Count = 0;
  1090.  
  1091.          while ( Count )
  1092.          {
  1093.              /*
  1094.              **  xOrder fcn has 2 byte flags preceding
  1095.              **  each item name
  1096.              */
  1097.  
  1098.              if ( fcn == spOrderFcn )
  1099.              {
  1100.                 UserP += 2;
  1101.                 len += 2;
  1102.              }
  1103.  
  1104.              i = min( maxlen, _fstrlen( UserP ) );
  1105.              UserP += i;
  1106.              len += i;
  1107.              if ( (i < maxlen) || StrParm( indx ) )
  1108.              {
  1109.                  /* skip over 0 terminator */
  1110.                 UserP++;
  1111.                 len++;
  1112.              }
  1113.  
  1114.              Count--;
  1115.  
  1116.          } /* end while */
  1117.       } /* end if */
  1118.    }
  1119.  
  1120.    return( len );
  1121.  
  1122. }  /* end GetSendDataSize */
  1123.  
  1124.  
  1125. /*
  1126. *****************************************************************************
  1127. **  GetRecvDataSize
  1128. **
  1129. **  Prototype:
  1130. **
  1131. **      BTI_SINT GetRecvDataSize(
  1132. **                  PARMBLOCK *pb,
  1133. **                  BTI_SINT fcn,
  1134. **                  BTI_SINT indx,
  1135. **                  BTI_WORD *dataLen )
  1136. **
  1137. **  Description:
  1138. **
  1139. **      Calculate the size of the current block that could be returned.
  1140. **
  1141. **  Preconditions:
  1142. **
  1143. **      None.
  1144. **
  1145. **  Parameters:
  1146. **
  1147. **      *pb:            Pointer to input parameter block.
  1148. **        <input>
  1149. **
  1150. **      fcn:            SSQL sequenced function number
  1151. **        <input>
  1152. **
  1153. **      indx:           SSQL parameter index
  1154. **        <input>
  1155. **
  1156. **      *dataLen:       Length of the data value
  1157. **        <output>
  1158. **
  1159. **
  1160. **  Return value:
  1161. **
  1162. **      Length of the data
  1163. **
  1164. **  Globals:
  1165. **
  1166. **      None.
  1167. **
  1168. **  Called Functions:
  1169. **
  1170. **      None.
  1171. **
  1172. **  Comments:
  1173. **
  1174. **      None.
  1175. **
  1176. *****************************************************************************
  1177. */
  1178. BTI_SINT GetRecvDataSize(
  1179.             PARMBLOCK *pb,
  1180.             BTI_SINT fcn,
  1181.             BTI_SINT indx,
  1182.             BTI_WORD *dataLen )
  1183.  
  1184. {
  1185.    BTI_SINT len;
  1186.    BTI_SINT retlen = *dataLen;
  1187.  
  1188.  
  1189.    if ( SpecParm( indx ) )
  1190.    {
  1191.       switch ( fcn )
  1192.       {
  1193.           case smCnvFcn:
  1194.           case spCnvFcn:
  1195.               retlen = ((pb->v.tcnvData.option & 0xFF) == 0) ?
  1196.                   pb->v.tcnvData.dsize : pb->v.tcnvData.size;
  1197.               *dataLen = retlen;
  1198.               break;
  1199.  
  1200.           case spInsertFcn:
  1201.               /* what data could we return for an insert? */
  1202.               *dataLen = retlen = 0;
  1203.               break;
  1204.  
  1205.           case spFetchFcn:
  1206.               if (pb->v.tfetchData.option == 6 ||
  1207.                   pb->v.tfetchData.option == 8)
  1208.                   retlen = 0;
  1209.               break;
  1210.  
  1211.           case spDDAttrFcn:
  1212.               if (pb->v.tddattrData.fcn == 3)
  1213.                   retlen = pb->v.tddattrData.bufsize;
  1214.               else
  1215.                   *dataLen = retlen = 0;
  1216.               break;
  1217.  
  1218.           case spDDFileFcn:
  1219.               *dataLen = retlen;
  1220.               break;
  1221.  
  1222.           case spUserFcn:
  1223.               if ((pb->v.tuserData.fcn & 0xFF) == 3 ||
  1224.                   (pb->v.tuserData.fcn & 0xFF) >= 5)
  1225.                   retlen = pb->v.tuserData.buflen;
  1226.               else
  1227.                   *dataLen = retlen = 0;
  1228.               break;
  1229.  
  1230.           case spAccessFcn:
  1231.               if (pb->v.taccessData.fcn == 2)
  1232.                   retlen = pb->v.taccessData.buflen;
  1233.               else
  1234.                   *dataLen = retlen = 0;
  1235.               break;
  1236.  
  1237.           case smStatFcn:
  1238.               if (pb->v.xstData.option == 0)
  1239.                   retlen = 8;
  1240.               else if (pb->v.xstData.option != 2)
  1241.                   /* 2-8-93 rwa */
  1242.                   retlen = C30;
  1243.               else
  1244.                   retlen = 132;
  1245.               *dataLen = retlen;
  1246.               break;
  1247.  
  1248.           default:
  1249.               break;
  1250.       }
  1251.    }
  1252.    else
  1253.    {
  1254.       retlen = parmLength[indx];                       /* get max length  */
  1255.    } /* end if-else */
  1256.  
  1257.    /* use minimum of returned length vs. requested len */
  1258.    len = max( retlen, *dataLen );
  1259.  
  1260.    return( len );
  1261.  
  1262. }  /* end GetRecvDataSize */
  1263.  
  1264. /*
  1265. *****************************************************************************
  1266. **  unfixParms
  1267. **
  1268. **  Prototype:
  1269. **
  1270. **      BTI_SINT unfixParms( PARMBLOCK *from, PARMBLOCK *to )
  1271. **
  1272. **  Description:
  1273. **      unfixParms copies/converts data from "easily addressable" parameter
  1274. **      block to "hard to address" parameter block.
  1275. **
  1276. **  Preconditions:
  1277. **
  1278. **      None.
  1279. **
  1280. **  Parameters:
  1281. **
  1282. **      *from:          Input parameter block
  1283. **        <input>
  1284. **
  1285. **      *to:            Output parameter block
  1286. **        <output>
  1287. **
  1288. **  Return value:
  1289. **
  1290. **      None.
  1291. **
  1292. **
  1293. **  Globals:
  1294. **
  1295. **      None.
  1296. **
  1297. **  Called Functions:
  1298. **
  1299. **      PtrParm()
  1300. **      MovPtrData()
  1301. **      ConstParm()
  1302. **      MovConstData()
  1303. **      LongParm()
  1304. **      MovLongData()
  1305. **
  1306. **  Comments:
  1307. **
  1308. **      None.
  1309. **
  1310. *****************************************************************************
  1311. */
  1312. BTI_SINT unfixParms( PARMBLOCK *from, PARMBLOCK *to)
  1313.  
  1314. {
  1315.     void      *beginFromP, *beginToP;
  1316.     BTI_SINT  fcn = from->fcn;
  1317.     BTI_SINT  i, j;
  1318.     BTI_ULONG dataLen = 0;
  1319.     BTI_SINT  stat = SS_SUCCESS;
  1320.     BTI_SINT  XQLstat;
  1321.  
  1322.     /* copy the invariant data */
  1323. #if defined(BTI_DOS_16B)
  1324.     _fmemcpy( to->XQL_ID, from->XQL_ID, 4 );
  1325. #else
  1326.     memcpy( to->XQL_ID, from->XQL_ID, 4 );
  1327. #endif
  1328.     to->cursorid = from->cursorid;
  1329.     to->stat = from->stat;
  1330.     to->sessionid = from->sessionid;
  1331.  
  1332.     if ( fcn != -1 )
  1333.     {
  1334. //       dataBufCrwl = GetDBufPtr( fcn, from );
  1335.  
  1336.        /*
  1337.        **  Some functions (XQLLogout, XQLCursor, XQLFree, etc...) don't have
  1338.        **  variant data to copy.  Check for that.
  1339.        */
  1340.        if ( FcnParmCount[fcn] )
  1341.        {
  1342.           XQLstat = from->stat;
  1343.           beginFromP = (void *) &(from->v);
  1344.           beginToP = (void *) &(to->v);
  1345.  
  1346.           j = ParmOffsets[fcn];           /* starting index into parmFlags */
  1347.  
  1348.           if ( ( (XQLstat == SQL_BUFFER_TOO_SHORT )
  1349.               || (XQLstat == SQL_SHORT_BUF_M )
  1350.               || (XQLstat <= 0)
  1351.               || (XQLstat == EOF_ERR)
  1352.               || (fcn == spDDFileFcn)
  1353.               || (fcn == spDDFieldFcn)
  1354.               || (fcn == spDDIndexFcn)
  1355.               || (fcn == smCompFcn)
  1356.               || (XQLstat == SQL_DBNM_END_OF_FILE) )
  1357.               && (XQLstat != SQL_DATA_MESSAGE_BUFFER_TOO_SMALL ))
  1358.           {
  1359.              for ( i = 0;
  1360.                    (i < FcnParmCount[fcn]) && (stat == SS_SUCCESS);
  1361.                    i++, j++ )
  1362.              {
  1363.                 if ( PtrParm( j ) )
  1364.                 {
  1365.                    stat = MovPtrData(
  1366.                              from,
  1367.                              &beginFromP,
  1368.                              &beginToP,
  1369.                              (char *) from,
  1370.                              fcn,
  1371.                              j,
  1372.                              (BTI_WORD *) &dataLen );
  1373.                 }
  1374.                 else if ( ConstParm( j ) )
  1375.                 {
  1376.                    stat = MovConstData(
  1377.                              &beginFromP,
  1378.                              &beginToP,
  1379.                              j,
  1380.                              (BTI_WORD *) &dataLen );
  1381.                 }
  1382.                 else if ( LongParm( j ) )
  1383.                 {
  1384.                    stat = MovLongData(
  1385.                              &beginFromP,
  1386.                              &beginToP,
  1387.                              j,
  1388.                              (BTI_ULONG *) &dataLen );
  1389.                 }
  1390.              }
  1391.           }
  1392.        } /* end if */
  1393.     }
  1394.     return( stat );
  1395.  
  1396. } /* end unfixParms */
  1397.  
  1398.  
  1399. /*
  1400. *****************************************************************************
  1401. ** MovPtrData
  1402. **
  1403. **  Prototype:
  1404. **
  1405. **      BTI_SINT MovPtrData( PARMBLOCK *pb, char ***from,
  1406. **          char ***to, char *dataBuf,
  1407. **          BTI_SINT fcn, BTI_SINT indx, BTI_WORD *dataLen)
  1408. **
  1409. **  Description:
  1410. **
  1411. **      Copy pointer data from "easily addressable" parameter block to
  1412. **      "hard to address" parameter block.
  1413. **
  1414. **  Preconditions:
  1415. **
  1416. **      None.
  1417. **
  1418. **  Parameters:
  1419. **
  1420. **      *pb:                    Pointer to input parameter block
  1421. **        <input>
  1422. **
  1423. **      ***from:                Pointer to the pointer data
  1424. **        <input>
  1425. **
  1426. **      ***to:                  Output parameter block
  1427. **        <output>
  1428. **
  1429. **      *dataBuf:               Pointer to the start of the protected mode
  1430. **        <input>               parameter block
  1431. **
  1432. **      fcn:                    SSQL sequenced function number
  1433. **        <input>
  1434. **
  1435. **      indx:                   SSQL parameter index
  1436. **        <input>
  1437. **
  1438. **      *dataLen:               Length of the data.
  1439. **        <output>
  1440. **
  1441. **
  1442. **  Return value:
  1443. **
  1444. **      None.
  1445. **
  1446. **
  1447. **  Globals:
  1448. **
  1449. **      startOfRealPtr
  1450. **
  1451. **  Called Functions:
  1452. **
  1453. **      RetData()
  1454. **      GetRecvDataSize()
  1455. **      _fmemcpy()
  1456. **
  1457. **  Comments:
  1458. **
  1459. **      None.
  1460. **
  1461. **
  1462. *****************************************************************************
  1463. */
  1464. BTI_SINT MovPtrData( PARMBLOCK *pb, char ***from,
  1465.     char ***to, char *dataBuf, BTI_SINT fcn, BTI_SINT indx, BTI_WORD *dataLen)
  1466.  
  1467. {
  1468.     BTI_SINT stat = SS_SUCCESS;
  1469.     BTI_SINT len;
  1470.     char *tmpFrom, *tmpTo;
  1471.  
  1472.     /*
  1473.     **  Need to split our contiguous parameter block back to the
  1474.     **  individual pieces passed in from the user.
  1475.     */
  1476.     if ( RetData( indx ) )
  1477.     {
  1478.        /* Calculate the protected mode address of the data */
  1479.        **from = (char *) ((BTI_ULONG)(**from - startOfRealPtr) + dataBuf) ;
  1480.        tmpFrom = **from;
  1481.  
  1482.        len = GetRecvDataSize( pb, fcn, indx, dataLen );
  1483.        if ( len && (tmpFrom != NULL) )
  1484. #if defined(BTI_DOS_16B)
  1485.           _fmemcpy( **to, tmpFrom, len );
  1486. #else
  1487.           memcpy( **to, tmpFrom, len );
  1488. #endif
  1489.     } /* end if RetData() */
  1490.  
  1491.     /* advance over pointers */
  1492.     (*to)++;
  1493.     (*from)++;
  1494.  
  1495.     return( stat );
  1496.  
  1497. } /* end MovPtrData */
  1498.  
  1499.  
  1500. /*
  1501. *****************************************************************************
  1502. **  MovConstData
  1503. **
  1504. **  Prototype:
  1505. **
  1506. **      BTI_SINT MovConstData(BTI_SINT **from, BTI_SINT **to, BTI_SINT indx,
  1507. **          BTI_WORD *dataLen)
  1508. **
  1509. **  Description:
  1510. **
  1511. **      Copy two byte data from "easily addressable" Parm Block
  1512. **      to "hard to address" Parm block.
  1513. **
  1514. **
  1515. **  Preconditions:
  1516. **
  1517. **      None.
  1518. **
  1519. **  Parameters:
  1520. **
  1521. **      **from:         Pointer to input parameter block
  1522. **        <input>
  1523. **
  1524. **      **to:           Pointer to output parameter block
  1525. **        <output>
  1526. **
  1527. **      indx:           SSQL parameter index
  1528. **        <input>
  1529. **
  1530. **      *dataLen:       Length of the data
  1531. **        <output>
  1532. **
  1533. **
  1534. **  Return value:
  1535. **
  1536. **      None.
  1537. **
  1538. **
  1539. **  Globals:
  1540. **
  1541. **      None.
  1542. **
  1543. **  Called Functions:
  1544. **
  1545. **      RetData()
  1546. **      LenParm()
  1547. **
  1548. **  Comments:
  1549. **
  1550. **      None.
  1551. **
  1552. **
  1553. *****************************************************************************
  1554. */
  1555. BTI_SINT MovConstData( BTI_SINT **from, BTI_SINT **to, BTI_SINT indx,
  1556.     BTI_WORD *dataLen )
  1557.  
  1558. {
  1559.    if ( RetData( indx ) )
  1560.    {
  1561.       if ( LenParm( indx ) )
  1562.       {
  1563.          *dataLen = **from;
  1564.       }
  1565.  
  1566.       **to = **from;
  1567.  
  1568.    }
  1569.  
  1570.    (*to)++;
  1571.    (*from)++;
  1572.    return( 0 );
  1573. }
  1574.  
  1575.  
  1576. /*
  1577. *****************************************************************************
  1578. **  MovLongData
  1579. **
  1580. **  Prototype:
  1581. **
  1582. **      BTI_SINT MovLongData( BTI_ULONG **from, BTI_ULONG **to,
  1583. **                            BTI_SINT indx, BTI_ULONG *dataLen )
  1584. **
  1585. **  Description:
  1586. **
  1587. **      Copy four byte data from "easily addressable" parameter block
  1588. **      to "hard to address" parameter block.
  1589. **
  1590. **  Preconditions:
  1591. **
  1592. **      None.
  1593. **
  1594. **  Parameters:
  1595. **
  1596. **      **from:         Pointer to long data value in input parameter block
  1597. **        <input>
  1598. **
  1599. **      **to:           Pointer to long data value in output parameter block
  1600. **        <output>
  1601. **
  1602. **
  1603. **  Return value:
  1604. **
  1605. **      None.
  1606. **
  1607. **
  1608. **  Globals:
  1609. **
  1610. **      None.
  1611. **
  1612. **  Called Functions:
  1613. **
  1614. **      RetData()
  1615. **      LenParm()
  1616. **
  1617. **  Comments:
  1618. **
  1619. **      None.
  1620. **
  1621. *****************************************************************************
  1622. */
  1623. BTI_SINT MovLongData( BTI_ULONG **from, BTI_ULONG **to, BTI_SINT indx,
  1624.                       BTI_ULONG *dataLen )
  1625.  
  1626. {
  1627.    if ( RetData( indx ) )
  1628.    {
  1629.       if ( LenParm( indx ) )
  1630.       {
  1631.         *dataLen = **from;
  1632.       }
  1633.  
  1634.       **to = **from;
  1635.  
  1636.    }
  1637.    (*to)++;
  1638.    (*from)++;
  1639.    return( 0 );
  1640. }
  1641.  
  1642.  
  1643. /*
  1644. **  common functions
  1645. */
  1646.  
  1647. BTI_SINT SendData( BTI_SINT indx )
  1648.  
  1649. {
  1650.     return( (BTI_SINT) parmFlags[indx] & SEND_DATA );
  1651. }
  1652.  
  1653. BTI_SINT RetData(BTI_SINT indx)
  1654.  
  1655. {
  1656.     return((BTI_SINT) parmFlags[indx] & RET_DATA);
  1657. }
  1658.  
  1659. BTI_SINT PtrParm(BTI_SINT indx)
  1660.  
  1661. {
  1662.     return(StrParm(indx) || DataParm(indx));
  1663. }
  1664.  
  1665. BTI_SINT StrParm(BTI_SINT indx)
  1666.  
  1667. {
  1668.     return((BTI_SINT) parmFlags[indx] & STR_PARM);
  1669. }
  1670.  
  1671. BTI_SINT DataParm(BTI_SINT indx)
  1672.  
  1673. {
  1674.     return((BTI_SINT) parmFlags[indx] & DATA_PARM);
  1675. }
  1676.  
  1677. BTI_SINT ConstParm(BTI_SINT indx)
  1678.  
  1679. {
  1680.     return((BTI_SINT) parmFlags[indx] & CONST_VAL);
  1681. }
  1682.  
  1683. BTI_SINT LongParm(BTI_SINT indx)
  1684.  
  1685. {
  1686.     return((BTI_SINT) parmFlags[indx] & LONG_VAL);
  1687. }
  1688.  
  1689. BTI_SINT LenParm(BTI_SINT indx)
  1690.  
  1691. {
  1692.     return((BTI_SINT) parmFlags[indx] & LEN_VAL);
  1693. }
  1694.  
  1695. BTI_SINT CntParm(BTI_SINT indx)
  1696.  
  1697. {
  1698.     return((BTI_SINT) parmFlags[indx] & CNT_VAL);
  1699. }
  1700.  
  1701. BTI_SINT SpecParm(BTI_SINT indx)
  1702.  
  1703. {
  1704.     return((BTI_SINT) parmFlags[indx] & SPEC_PARM);
  1705. }
  1706.  
  1707.