This repository was archived by the owner on Oct 9, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmcdcli.c
More file actions
56 lines (48 loc) · 1.25 KB
/
mcdcli.c
File metadata and controls
56 lines (48 loc) · 1.25 KB
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
55
56
#include <stdlib.h>
#include <unistd.h>
#include <getopt.h>
#include <string.h>
#include <db.h>
#include "mcddb.h"
#define BUFSZ 1024
int main(int argc, char **argv)
{
int ret, op, cnt, i;
extern char *optarg;
extern int optind;
DBT value;
char **keys, **values;
if (argc < 2 || argc > 4) {
//usage();
puts("BLAH");
}
op = getopt(argc, argv, "a:d:f:g:l");
if (open_db(NULL) == 1) {
puts("Error opening database");
}
switch(op) {
case 'a':
if (argc == 4 && (optarg != NULL) &&
(strlen(optarg) >= 1) &&
(argv[optind] != NULL)) {
ret = add_rec(optarg, argv[optind]);
if (ret == 1) {
printf("Key '%s' exists\n", optarg);
exit(EXIT_FAILURE);
}
else if (ret < 0) {
perror("mcdcli.c: add_rec");
exit(EXIT_FAILURE);
}
else if (ret > 0) {
printf("%i\n", ret);
perror("mcdcli.c: add_rec");
}
break;
}
else {
//usage();
puts("BLAH");
}
}
}