forked from crucially/timesplicedb
-
Notifications
You must be signed in to change notification settings - Fork 1
/
ngr_insert.c
47 lines (36 loc) · 895 Bytes
/
ngr_insert.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
#include "NGR.h"
#include <sys/time.h>
#include <stdio.h>;
#include <time.h>;
#include <assert.h>;
#include <string.h>
#include <stdlib.h>;
extern char *optarg;
int main(int argc, char * const *argv) {
int o, value;
time_t insert_time;
char *collection, *metric_s;
insert_time = value = 0;
while ((o = getopt(argc, argv,
"c:m:t:v:")) != -1) {
switch(o) {
case 'c':
collection = malloc(strlen(optarg)+1);
memcpy(collection, optarg, strlen(optarg)+1);
break;
case 'm':
metric_s = malloc(strlen(optarg)+1);
memcpy(metric_s, optarg, strlen(optarg)+1);
break;
case 't':
insert_time = atoi(optarg);
break;
case 'v':
value = atoi(optarg);
}
}
assert(collection);
assert(metric_s);
struct NGR_metric_t *metric = NGR_open(collection, metric_s);
NGR_insert(metric,insert_time, value);
}