home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / xbase / library / clipper / tts / tts_lib.c next >
Encoding:
C/C++ Source or Header  |  1992-05-26  |  14.5 KB  |  638 lines

  1. /*
  2. * TTS libray for Clipper 5.01
  3. *   Brian Connelly
  4. */
  5. #include <extend.h>
  6.  
  7.  
  8. #include "tts_lib.h"    // return codes, etc.
  9.  
  10. //>+*************************************************************************
  11. //>N*    TTSIsAvail()
  12. //>Q*    will tell you whether or not TTS is available and enabled
  13. //>T*
  14. //>S* Syntax
  15. //>T*    TTSIsAvail()    ->    iReturn
  16. //>T*
  17. //>R* Returns
  18. //>T*    iReturn :        00    not available
  19. //>T*                01    available
  20. //>T*                253 disabled
  21. //>T*
  22. //>D* Description
  23. //>T*    Simple clipper shell around TTSIsAvailable() call.
  24. //>T*
  25. //>W* Written by
  26. //>T*    Brian Connelly
  27. //>T*
  28. //>L* Language
  29. //>T*        Assembler
  30. //>T*        C
  31. //>T*
  32. //>E* Examples
  33. //>T*        ? TTSIsAvail()        //RESULT: 0 {hopefully}
  34. //>T*
  35. //>O* See also
  36. //>T*    TTSBegin()
  37. //>T*    TTSEnd()
  38. //>T*    TTSAbort()
  39. //>T*    TTSStatus()
  40. //>T*    TTSGetAppT()
  41. //>T*    TTSSetAppT()
  42. //>T*    TTSGetWksT()
  43. //>T*    TTSSetWksT()
  44. //>T*
  45. //>-*************************************************************************
  46.  
  47. CLIPPER ttsisavail (void)
  48. /* this function will tell you whether TTS is available and/or disabled
  49. */
  50. {
  51.     int rc = 0;
  52.  
  53.     _asm {
  54.     mov ah, 0xc7
  55.     mov al, 0x02
  56.     int 0x21
  57.     mov rc, al
  58.     }
  59.  
  60.     _retni( rc );
  61.  
  62. return;
  63. }
  64.  
  65. //>+*************************************************************************
  66. //>N*    TTSBegin()
  67. //>Q*    Begins an explicit transaction
  68. //>T*
  69. //>S* Syntax
  70. //>T*    TTSBegin()    ->    iReturn
  71. //>T*
  72. //>R* Returns
  73. //>T*    iReturn :        00    success
  74. //>T*                150 out of dynamic worksapce on server
  75. //>T*                255 explicit transaction already active
  76. //>T*                254 implicit transaction already active
  77. //>T*
  78. //>D* Description
  79. //>T*        Simple clipper shell around TTSBeginTransaction() call.
  80. //>T*    Note: On return code of 255 the explicit transaction will continue
  81. //>T*    normally. On a return code of 254 the implicit transaction will
  82. //>T*    as an explicit transaction. On a return code of 150, you are in some
  83. //>T*    serious trouble.
  84. //>T*
  85. //>W* Written by
  86. //>T*    Brian Connelly
  87. //>T*
  88. //>L* Language
  89. //>T*        Assembler
  90. //>T*        C
  91. //>T*
  92. //>E* Examples
  93. //>T*        ? TTSBegin()        //RESULT: 0 {hopefully}
  94. //>T*
  95. //>O* See also
  96. //>T*    TTSIsAvail()
  97. //>T*    TTSEnd()
  98. //>T*    TTSAbort()
  99. //>T*    TTSStatus()
  100. //>T*    TTSGetAppT()
  101. //>T*    TTSSetAppT()
  102. //>T*    TTSGetWksT()
  103. //>T*    TTSSetWksT()
  104. //>T*
  105. //>-*************************************************************************
  106.  
  107. CLIPPER ttsbegin (void)
  108. /* this functions notifies Netware to begin tts backups on all tts file
  109. *   output, from this moment on.
  110. */
  111. {
  112.     int rc = 0;
  113.  
  114.     _asm {
  115.     mov ah, 0xc7
  116.     mov al, 0x00
  117.     int 0x21
  118.     mov rc, al
  119.     }
  120.  
  121.     _retni( rc );
  122.  
  123. return;
  124. }
  125.  
  126. //>+*************************************************************************
  127. //>N*    TTSEnd()
  128. //>Q*    Ends an explicit (or implicit) transaction
  129. //>T*
  130. //>S* Syntax
  131. //>T*    TTSEnd( @<iTransNumber>)    ->    iReturn
  132. //>T*
  133. //>A* Arguments
  134. //>T*    <iTransNumber>        : optional transaction reference number for
  135. //>T*                call to TTSStatus()
  136. //>T*
  137. //>R* Returns
  138. //>T*    iReturn :        00    success
  139. //>T*                255 no explicit transaction active
  140. //>T*                254 transaction ended, records locked
  141. //>T*                253 tts is disabled
  142. //>T*                252 BAD PARAMETERS
  143. //>T*
  144. //>D* Description
  145. //>T*        Simple clipper shell around TTSEndTransaction() call.
  146. //>T*    Note: On return code of 254 the transaction was aborted, but the
  147. //>T*    records were left locked, this is only for implicit transactions.
  148. //>T*
  149. //>W* Written by
  150. //>T*    Brian Connelly
  151. //>T*
  152. //>L* Language
  153. //>T*        Assembler
  154. //>T*        C
  155. //>T*
  156. //>E* Examples
  157. //>T*        Local iRef := 0
  158. //>T*        ? TTSEnd( @iRef)        //RESULT: 0 {hopefully}
  159. //>T*
  160. //>O* See also
  161. //>T*    TTSIsAvail()
  162. //>T*    TTSBegin()
  163. //>T*    TTSAbort()
  164. //>T*    TTSStatus()
  165. //>T*    TTSGetAppT()
  166. //>T*    TTSSetAppT()
  167. //>T*    TTSGetWksT()
  168. //>T*    TTSSetWksT()
  169. //>T*
  170. //>-*************************************************************************
  171.  
  172. CLIPPER ttsend (void)
  173. /* this function notifies Netware to end the current transaction. It will
  174. *   return a completion code as well as a transaction number, that can
  175. *   be used to track when the transaction is actually written.
  176. */
  177. {
  178.     unsigned    ref = 0 , *ref_ptr = &ref;
  179.     int rc;
  180.  
  181.     if ( PCOUNT == 1 )
  182.     if ( !ISBYREF(1) || !ISNUM(1) ) {
  183.         _retni( 252 );
  184.         return;
  185.     }
  186.  
  187.     _asm {
  188.     mov ah, 0xc7
  189.     mov al, 0x01
  190.     int 0x21
  191.     cmp al, 0
  192.     jne NoRef
  193.     mov ref_ptr[0], cx
  194.     mov ref_ptr[2], dx
  195. NoRef:    mov rc, al
  196.     }
  197.  
  198.     if ( PCOUNT == 1)
  199.     _stornl( (long) ref, 1);
  200.  
  201.     _retni( rc );
  202.  
  203. return;
  204. }
  205.  
  206. //>+*************************************************************************
  207. //>N*    TTSAbort()
  208. //>Q*    Aborts all transactions.
  209. //>T*
  210. //>S* Syntax
  211. //>T*    TTSAbort()    ->    iReturn
  212. //>T*
  213. //>R* Returns
  214. //>T*    iReturn :        00    success
  215. //>T*                255 no explicit transaction active
  216. //>T*                254 transaction ends record locked
  217. //>T*                253 tts is disabled
  218. //>T*
  219. //>D* Description
  220. //>T*        Simple clipper shell around TTSAbortTransaction() call.
  221. //>T*    Note: On return code of 254 the transaction was aborted, but the
  222. //>T*    records were left locked, this is only for implicit transactions.
  223. //>T*
  224. //>W* Written by
  225. //>T*    Brian Connelly
  226. //>T*
  227. //>L* Language
  228. //>T*        Assembler
  229. //>T*        C
  230. //>T*
  231. //>E* Examples
  232. //>T*        ? TTSAbort()        //RESULT: 0 {hopefully}
  233. //>T*
  234. //>O* See also
  235. //>T*    TTSIsAvail()
  236. //>T*    TTSEnd()
  237. //>T*    TTSBegin()
  238. //>T*    TTSStatus()
  239. //>T*    TTSGetAppT()
  240. //>T*    TTSSetAppT()
  241. //>T*    TTSGetWksT()
  242. //>T*    TTSSetWksT()
  243. //>T*
  244. //>-*************************************************************************
  245.  
  246. CLIPPER ttsabort (void)
  247. /* this function aborts all current transactions, implicit or explicit
  248. */
  249. {
  250.     int rc = 0;
  251.  
  252.     _asm {
  253.     mov ah, 0xc7
  254.     mov al, 0x03
  255.     int 0x21
  256.     mov rc, al
  257.     }
  258.  
  259.     _retni( rc );
  260.  
  261. return;
  262. }
  263.  
  264. //>+*************************************************************************
  265. //>N*    TTSStatus()
  266. //>Q*    Get the status of an ended transaction
  267. //>T*
  268. //>S* Syntax
  269. //>T*    TTSAbort( <iTransNumber>)    ->    iReturn
  270. //>T*
  271. //>A* Arguments
  272. //>T*    <iTransNumber>        : transaction reference number from
  273. //>T*                call to TTSEnd()
  274. //>T*
  275. //>R* Returns
  276. //>T*    iReturn :        00    success
  277. //>T*                255 transaction not yet written
  278. //>T*                252 bad parameters
  279. //>T*
  280. //>D* Description
  281. //>T*        Simple clipper shell around TTSTransactionStatus() call.
  282. //>T*
  283. //>W* Written by
  284. //>T*    Brian Connelly
  285. //>T*
  286. //>L* Language
  287. //>T*        Assembler
  288. //>T*        C
  289. //>T*
  290. //>E* Examples
  291. //>T*        Local iRef := 0
  292. //>T*        ? TTSEnd( @iRef)
  293. //>T*        ? TTSStatus( iRef)        //RESULT:   0 {hopefully}
  294. //>T*
  295. //>O* See also
  296. //>T*    TTSIsAvail()
  297. //>T*    TTSBegin()
  298. //>T*    TTSAbort()
  299. //>T*    TTSEnd()
  300. //>T*    TTSGetAppT()
  301. //>T*    TTSSetAppT()
  302. //>T*    TTSGetWksT()
  303. //>T*    TTSSetWksT()
  304. //>T*
  305. //>-*************************************************************************
  306.  
  307. CLIPPER ttsstatus (void)
  308. /* this function tells you whether or not the chosen transaction has been
  309. *   written to disk yet.
  310. */
  311. {
  312.     unsigned  ref = 0 , *ref_ptr = &ref;
  313.     int rc = 0;
  314.  
  315.     if ( PCOUNT != 1 || !ISNUM(1) ) {
  316.     _retni( 252 );
  317.     return;
  318.     }
  319.  
  320.     ref = (unsigned) _parni( 1 );
  321.  
  322.     _asm {
  323.     mov ah, 0xc7
  324.     mov al, 0x04
  325.     mov cx, ref_ptr[0]
  326.     mov dx, ref_ptr[2]
  327.     int 0x21
  328.     mov rc, al
  329.     }
  330.  
  331.     _retni( rc );
  332.  
  333. return;
  334. }
  335.  
  336. //>+*************************************************************************
  337. //>N*    TTSGetAppT()
  338. //>Q*    Get the worstation thresholds for implicit transactions
  339. //>T*
  340. //>S* Syntax
  341. //>T*    TTSGetAppT( @<iLogLocks>, @<iPhysLocks>)    ->    iReturn
  342. //>T*
  343. //>A* Arguments
  344. //>T*        iLogLocks        : Number of logical locks before implicit trans
  345. //>T*                [0 - 255]
  346. //>T*        iPhysLocks        : Number of physical locks before implicit trans
  347. //>T*                [0 - 255]
  348. //>T*
  349. //>R* Returns
  350. //>T*    iReturn :        00    success
  351. //>T*                252 bad parameters
  352. //>T*
  353. //>D* Description
  354. //>T*        Simple clipper shell around TTSGetApplicationThresholds() call.
  355. //>T*    Default thresholds are 0. A value of 255 disables implicit transactions
  356. //>T*    of that type.
  357. //>T*
  358. //>W* Written by
  359. //>T*    Brian Connelly
  360. //>T*
  361. //>L* Language
  362. //>T*        Assembler
  363. //>T*        C
  364. //>T*
  365. //>E* Examples
  366. //>T*        Local iLogicals, iPhysicals
  367. //>T*        ? TTSGetAppT( @iLogicals, @iPhysicals)    //RESULT:   0
  368. //>T*
  369. //>O* See also
  370. //>T*    TTSIsAvail()
  371. //>T*    TTSBegin()
  372. //>T*    TTSAbort()
  373. //>T*    TTSEnd()
  374. //>T*    TTSStatus()
  375. //>T*    TTSSetAppT()
  376. //>T*    TTSGetWksT()
  377. //>T*    TTSSetWksT()
  378. //>T*
  379. //>-*************************************************************************
  380.  
  381. CLIPPER ttsgetappt (void)
  382. /* this call returns the physical and logical lock thresholds that will
  383. *   trigger implicit transaction tracking. These thresholds last only the
  384. *   duration of the application and supersede the workstation thresholds.
  385. */
  386. {
  387.     unsigned char plocks, llocks;
  388.     int rc = 0;
  389.  
  390.     if ( PCOUNT != 2 || !ISNUM(1) || !ISNUM(2) || !ISBYREF(1) || !ISBYREF(2) ) {
  391.     _retni( 252 );
  392.     return;
  393.     }
  394.  
  395.     _asm {
  396.     mov ah, 0xc7
  397.     mov al, 0x05
  398.     int 0x21
  399.     mov plocks, ch
  400.     mov llocks, cl
  401.     mov rc, al
  402.     }
  403.  
  404.     _storni(1, plocks);
  405.     _storni(2, llocks);
  406.     _retni( rc);
  407.  
  408. return;
  409. }
  410.  
  411. //>+*************************************************************************
  412. //>N*    TTSSetAppT()
  413. //>Q*    Set the worstation thresholds for implicit transactions
  414. //>T*
  415. //>S* Syntax
  416. //>T*    TTSGetAppT( <iLogLocks>, <iPhysLocks>)    ->    iReturn
  417. //>T*
  418. //>A* Arguments
  419. //>T*        iLogLocks        : Number of logical locks before implicit trans
  420. //>T*                [0 - 255]
  421. //>T*        iPhysLocks        : Number of physical locks before implicit trans
  422. //>T*                [0 - 255]
  423. //>T*
  424. //>R* Returns
  425. //>T*    iReturn :        00    success
  426. //>T*                252 bad parameters
  427. //>T*
  428. //>D* Description
  429. //>T*        Simple clipper shell around TTSSetApplicationThresholds() call.
  430. //>T*    Default thresholds are 0. A value of 255 disables implicit transactions
  431. //>T*    of that type.
  432. //>T*
  433. //>W* Written by
  434. //>T*    Brian Connelly
  435. //>T*
  436. //>L* Language
  437. //>T*        Assembler
  438. //>T*        C
  439. //>T*
  440. //>E* Examples
  441. //>T*        Local iLogicals := 255, iPhysicals := 255
  442. //>T*        ? TTSSetAppT( iLogicals, iPhysicals)    //RESULT:   0
  443. //>T*
  444. //>O* See also
  445. //>T*    TTSIsAvail()
  446. //>T*    TTSBegin()
  447. //>T*    TTSAbort()
  448. //>T*    TTSEnd()
  449. //>T*    TTSStatus()
  450. //>T*    TTSGetAppT()
  451. //>T*    TTSGetWksT()
  452. //>T*    TTSSetWksT()
  453. //>T*
  454. //>-*************************************************************************
  455.  
  456. CLIPPER ttssetappt (void)
  457. /* this call is used to set the physical and logical lock thresholds for
  458. *   implicit transaction tracking. These thresholds last only for the
  459. *   duration of the application and supersede the workstation thresholds.
  460. *   Setting a threshold to 0xff disables implict transactions for that kind
  461. *   of lock.
  462. */
  463. {
  464.     unsigned char plocks, llocks;
  465.     int rc = 0;
  466.  
  467.     if ( PCOUNT != 2 || !ISNUM(1) || !ISNUM(2) ) {
  468.     _retni( BAD_PARAMS );
  469.     return;
  470.     }
  471.  
  472.     _asm {
  473.     mov ah, 0xc7
  474.     mov al, 0x06
  475.     mov ch, plocks
  476.     mov cl, llocks
  477.     int 0x21
  478.     mov rc, al
  479.     }
  480.  
  481.     _retni( rc);
  482.  
  483. return;
  484. }
  485.  
  486. //>+*************************************************************************
  487. //>N*    TTSGetWksT()
  488. //>Q*    Get the worstation thresholds for implicit transactions
  489. //>T*
  490. //>S* Syntax
  491. //>T*    TTSGetWksT( @<iLogLocks>, @<iPhysLocks>)    ->    iReturn
  492. //>T*
  493. //>A* Arguments
  494. //>T*        iLogLocks        : Number of logical locks before implicit trans
  495. //>T*                [0 - 255]
  496. //>T*        iPhysLocks        : Number of physical locks before implicit trans
  497. //>T*                [0 - 255]
  498. //>T*
  499. //>R* Returns
  500. //>T*    iReturn :        00    success
  501. //>T*                252 bad parameters
  502. //>T*
  503. //>D* Description
  504. //>T*        Simple clipper shell around TTSGetWorkstationThresholds() call.
  505. //>T*    Default thresholds are 0. A value of 255 disables implicit transactions
  506. //>T*    of that type.
  507. //>T*
  508. //>W* Written by
  509. //>T*    Brian Connelly
  510. //>T*
  511. //>L* Language
  512. //>T*        Assembler
  513. //>T*        C
  514. //>T*
  515. //>E* Examples
  516. //>T*        Local iLogicals, iPhysicals
  517. //>T*        ? TTSGetWksT( @iLogicals, @iPhysicals)    //RESULT:   0
  518. //>T*
  519. //>O* See also
  520. //>T*    TTSIsAvail()
  521. //>T*    TTSBegin()
  522. //>T*    TTSAbort()
  523. //>T*    TTSEnd()
  524. //>T*    TTSStatus()
  525. //>T*    TTSSetAppT()
  526. //>T*    TTSGetAppT()
  527. //>T*    TTSSetWksT()
  528. //>T*
  529. //>-*************************************************************************
  530.  
  531. CLIPPER ttsgetwkst (void)
  532. /* this call returns the physical and logical lock thresholds that will
  533. *   trigger implicit transaction tracking. These thresholds last until reset.
  534. *   These values are used as the default for applications that don't set
  535. *   their own thresholds.
  536. */
  537. {
  538.     unsigned char plocks, llocks;
  539.     int rc = 0;
  540.  
  541.     if ( PCOUNT != 2 || !ISNUM(1) || !ISNUM(2) || !ISBYREF(1) || !ISBYREF(2) ) {
  542.     _retni( BAD_PARAMS );
  543.     return;
  544.     }
  545.  
  546.     _asm {
  547.     mov ah, 0xc7
  548.     mov al, 0x07
  549.     int 0x21
  550.     mov plocks, ch
  551.     mov llocks, cl
  552.     mov rc, al
  553.     }
  554.  
  555.     _storni(1, plocks);
  556.     _storni(2, llocks);
  557.  
  558.     _retni( rc);
  559.  
  560. return;
  561. }
  562.  
  563. //>+*************************************************************************
  564. //>N*    TTSSetWksT()
  565. //>Q*    Set the worstation thresholds for implicit transactions
  566. //>T*
  567. //>S* Syntax
  568. //>T*    TTSSetWksT( <iLogLocks>, <iPhysLocks>)    ->    iReturn
  569. //>T*
  570. //>A* Arguments
  571. //>T*        iLogLocks        : Number of logical locks before implicit trans
  572. //>T*                [0 - 255]
  573. //>T*        iPhysLocks        : Number of physical locks before implicit trans
  574. //>T*                [0 - 255]
  575. //>T*
  576. //>R* Returns
  577. //>T*    iReturn :        00    success
  578. //>T*                252 bad parameters
  579. //>T*
  580. //>D* Description
  581. //>T*        Simple clipper shell around TTSSetWorkstationThresholds() call.
  582. //>T*    Default thresholds are 0. A value of 255 disables implicit transactions
  583. //>T*    of that type.
  584. //>T*
  585. //>W* Written by
  586. //>T*    Brian Connelly
  587. //>T*
  588. //>L* Language
  589. //>T*        Assembler
  590. //>T*        C
  591. //>T*
  592. //>E* Examples
  593. //>T*        Local iLogicals := 255, iPhysicals := 255
  594. //>T*        ? TTSSetWksT( iLogicals, iPhysicals)    //RESULT:   0
  595. //>T*
  596. //>O* See also
  597. //>T*    TTSIsAvail()
  598. //>T*    TTSBegin()
  599. //>T*    TTSAbort()
  600. //>T*    TTSEnd()
  601. //>T*    TTSStatus()
  602. //>T*    TTSGetAppT()
  603. //>T*    TTSGetWksT()
  604. //>T*    TTSSetAppT()
  605. //>T*
  606. //>-*************************************************************************
  607.  
  608. CLIPPER ttssetwkst (void)
  609. /* this call sets the physical and logical lock thresholds that will
  610. *   trigger implicit transaction tracking. These thresholds last until reset.
  611. *   These values are used as the default for applications that don't set
  612. *   their own thresholds.
  613. *   Setting a threshold to 0xff disables implict transactions for that kind
  614. *   of lock.
  615. */
  616. {
  617.     unsigned char plocks, llocks;
  618.     int rc = 0;
  619.  
  620.     if ( PCOUNT != 2 || !ISNUM(1) || !ISNUM(2) ) {
  621.     _retni( 252 );
  622.     return;
  623.     }
  624.  
  625.     _asm {
  626.     mov ah, 0xc7
  627.     mov al, 0x08
  628.     mov ch, plocks
  629.     mov cl, llocks
  630.     int 0x21
  631.     mov rc, al
  632.     }
  633.  
  634.     _retni( rc);
  635.  
  636. return;
  637. }
  638.