File: locktest.cpp

package info (click to toggle)
libxbase 2.0.0-8.2
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 2,456 kB
  • ctags: 2,128
  • sloc: cpp: 15,115; sh: 6,819; makefile: 165; ansic: 35
file content (46 lines) | stat: -rw-r--r-- 1,006 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/*  $Id: locktest.cpp,v 1.4 2000/11/10 19:04:17 dbryson Exp $

    this debugging program tests Xbase locking functions
*/

#include "xbase/xbase.h"
#include <stdlib.h>
#include <stdio.h>

int main(int, char**)
{
#if 0 // FIXME - seriously
#ifdef XB_LOCKING_ON
   xbShort rc;

   if(2!=ac){
     cout << "\nUsage: locktest filename\n";
     return 1;
   }

   if(( rc = d.OpenDatabase( av[1] )) != XB_NO_ERROR ) {
     cout << "\nError " << rc << " opening file " << av[1] << endl;
     exit(0);
   }
   xbXBase x;
   xbDbf d( &x );

   cout << "\nGoing to lock database..." << endl;
   rc = d.LockDatabase( F_SETLKW, F_WRLCK, 1L );
   if ( rc == -1 ){
     perror("Lock Error");
     return 2;
   }
   cout << "Database locked\n\nEnter a keystroke to release lock\n";
   char xx[4];
   cin  >> xx;

   rc = d.LockDatabase( F_SETLK, F_UNLCK, 1L );
   cout << "Unlock database rc = " << rc << "\n";
   d.CloseDatabase();
#else
   cout << "\nXB_LOCKING_ON is not compiled in\n";
#endif
#endif
   return 0;
}