Build on wheezy, and presumably precise
[invirt/third/libt4.git] / lock_client.cc
1 // RPC stubs for clients to talk to lock_server
2
3 #include "lock_client.h"
4 #include "rpc.h"
5 #include <arpa/inet.h>
6
7 #include <sstream>
8 #include <iostream>
9 #include <stdio.h>
10
11 lock_client::lock_client(std::string dst)
12 {
13     sockaddr_in dstsock;
14     make_sockaddr(dst.c_str(), &dstsock);
15     cl = new rpcc(dstsock);
16     if (cl->bind() < 0) {
17         printf("lock_client: call bind\n");
18     }
19 }
20
21 int
22 lock_client::stat(lock_protocol::lockid_t lid)
23 {
24     int r;
25     lock_protocol::status ret = cl->call(lock_protocol::stat, cl->id(), lid, r);
26     VERIFY (ret == lock_protocol::OK);
27     return r;
28 }
29
30 lock_protocol::status
31 lock_client::acquire(lock_protocol::lockid_t lid)
32 {
33     int r;
34     return cl->call(lock_protocol::acquire, cl->id(), lid, r);
35 }
36
37 lock_protocol::status
38 lock_client::release(lock_protocol::lockid_t lid)
39 {
40     int r;
41     return cl->call(lock_protocol::release, cl->id(), lid, r);
42 }
43
44 t4_lock_client *t4_lock_client_new(const char *dst) {
45     return (t4_lock_client *)new lock_client(dst);
46 }
47
48 void t4_lock_client_delete(t4_lock_client *client) {
49     delete (lock_client *)client;
50 }
51
52 t4_status t4_lock_client_acquire(t4_lock_client *client, t4_lockid_t lid) {
53     return ((lock_client *)client)->acquire(lid);
54 }
55
56 t4_status t4_lock_client_release(t4_lock_client *client, t4_lockid_t lid) {
57     return ((lock_client *)client)->acquire(lid);
58 }
59
60 t4_status t4_lock_client_stat(t4_lock_client *client, t4_lockid_t lid) {
61     return ((lock_client *)client)->stat(lid);
62 }
63