-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcashed_shell_cli.c
54 lines (39 loc) · 1.02 KB
/
cashed_shell_cli.c
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
47
48
49
50
51
52
53
54
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<cashed_client.h>
int main(int argc, char** argv)
{
unsigned int port = 6969;
if(argc == 2)
sscanf(argv[1], "%u", &port);
transaction_client* cashed_client = new_cashed_client("127.0.0.1", port, 3);
char query_buffer[1024];
c_query q;
dstring io_string; init_dstring(&io_string, NULL, 0);
while(1)
{
printf("client ->");
scanf("%s", query_buffer);
if(strcmp(query_buffer, "exit") == 0)
break;
make_dstring_empty(&io_string);
concatenate_dstring(&io_string, &get_literal_cstring(query_buffer));
init_query(&q, ERR);
deserialize_query(&io_string, &q);
//print_query(&q);
promise* query_promise = queue_transaction(cashed_client, transact_cashed_query, &q);
if(query_promise != NULL)
{
c_result* r_p = get_result_for_transaction(query_promise);
printf("server ->");
print_result(r_p);
deinit_result(r_p);
free(r_p);
}
deinit_query(&q);
}
deinit_dstring(&io_string);
close_cashed_client(cashed_client);
return 0;
}