Line |
Branch |
Exec |
Source |
1 |
|
|
/** |
2 |
|
|
* This file is part of the CernVM File System. |
3 |
|
|
* |
4 |
|
|
* Implements the C wrapper of the OptionsManager |
5 |
|
|
*/ |
6 |
|
|
|
7 |
|
|
|
8 |
|
|
#include <cassert> |
9 |
|
|
#include <cstdlib> |
10 |
|
|
#include <cstring> |
11 |
|
|
#include <string> |
12 |
|
|
|
13 |
|
|
#include "libcvmfs_cache.h" |
14 |
|
|
#include "options.h" |
15 |
|
|
|
16 |
|
|
using namespace std; // NOLINT |
17 |
|
|
|
18 |
|
|
|
19 |
|
✗ |
SimpleOptionsParser *cvmcache_options_clone(SimpleOptionsParser *opts) { |
20 |
|
|
SimpleOptionsParser *result = new SimpleOptionsParser( |
21 |
|
✗ |
*reinterpret_cast<SimpleOptionsParser *>(opts)); |
22 |
|
✗ |
return result; |
23 |
|
|
} |
24 |
|
|
|
25 |
|
|
|
26 |
|
✗ |
void cvmcache_options_fini(SimpleOptionsParser *opts) { delete opts; } |
27 |
|
|
|
28 |
|
|
|
29 |
|
✗ |
void cvmcache_options_free(char *value) { free(value); } |
30 |
|
|
|
31 |
|
|
|
32 |
|
✗ |
char *cvmcache_options_get(SimpleOptionsParser *opts, const char *key) { |
33 |
|
✗ |
string arg; |
34 |
|
✗ |
const bool retval = opts->GetValue(key, &arg); |
35 |
|
✗ |
if (!retval) |
36 |
|
✗ |
return NULL; |
37 |
|
✗ |
char *result = strdup(arg.c_str()); |
38 |
|
✗ |
assert(result != NULL); |
39 |
|
✗ |
return result; |
40 |
|
|
} |
41 |
|
|
|
42 |
|
|
|
43 |
|
✗ |
char *cvmcache_options_dump(SimpleOptionsParser *opts) { |
44 |
|
✗ |
char *result = strdup(opts->Dump().c_str()); |
45 |
|
✗ |
assert(result != NULL); |
46 |
|
✗ |
return result; |
47 |
|
|
} |
48 |
|
|
|
49 |
|
|
|
50 |
|
✗ |
SimpleOptionsParser *cvmcache_options_init() { |
51 |
|
✗ |
SimpleOptionsParser *result = new SimpleOptionsParser(); |
52 |
|
|
// In contrast to the fuse module, we don't want to taint the process' |
53 |
|
|
// environment with parameters from the cvmfs configuration in libcvmfs |
54 |
|
✗ |
result->set_taint_environment(false); |
55 |
|
|
// Not strictly necessary but avoids a failure log message |
56 |
|
✗ |
result->SetValue("CVMFS_MOUNT_DIR", "/cvmfs"); |
57 |
|
✗ |
return result; |
58 |
|
|
} |
59 |
|
|
|
60 |
|
|
|
61 |
|
✗ |
void cvmcache_options_set(SimpleOptionsParser *opts, const char *key, |
62 |
|
|
const char *value) { |
63 |
|
✗ |
opts->SetValue(key, value); |
64 |
|
|
} |
65 |
|
|
|
66 |
|
|
|
67 |
|
✗ |
int cvmcache_options_parse(SimpleOptionsParser *opts, const char *path) { |
68 |
|
✗ |
const bool result = opts->TryParsePath(path); |
69 |
|
✗ |
return result ? 0 : -1; |
70 |
|
|
} |
71 |
|
|
|
72 |
|
|
|
73 |
|
✗ |
void cvmcache_options_unset(SimpleOptionsParser *opts, const char *key) { |
74 |
|
✗ |
opts->UnsetValue(key); |
75 |
|
|
} |
76 |
|
|
|