blob: 0a0f62523ab67330ccad7831207c152b38ea5727 (
plain)
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 "includes.h"
#include "mdssvc.h"
#include "rpc_server/mdssvc/sparql_parser.tab.h"
#include "rpc_server/mdssvc/mdssvc_tracker.h"
/*
* Examples:
*
* $ ./spotlight2sparql '_kMDItemGroupId=="11"'
* ...
* $ ./spotlight2sparql '*=="test*"cwd||kMDItemTextContent=="test*"cwd'
* ...
*/
int main(int argc, char **argv)
{
struct sl_tracker_query *tq = NULL;
bool ok;
struct sl_query *slq;
if (argc != 2) {
printf("usage: %s QUERY\n", argv[0]);
return 1;
}
slq = talloc_zero(NULL, struct sl_query);
if (slq == NULL) {
printf("talloc error\n");
return 1;
}
slq->query_string = argv[1];
slq->path_scope = "/foo/bar";
tq = talloc_zero(slq, struct sl_tracker_query);
if (tq == NULL) {
printf("talloc error\n");
return 1;
}
slq->backend_private = tq;
ok = map_spotlight_to_sparql_query(slq);
printf("%s\n", ok ? tq->sparql_query : "*mapping failed*");
talloc_free(slq);
return ok ? 0 : 1;
}
|