GCC Code Coverage Report
Directory: cvmfs/ Exec Total Coverage
File: cvmfs/cache_plugin/libcvmfs_cache_options.cc Lines: 0 31 0.0 %
Date: 2019-02-03 02:48:13 Branches: 0 10 0.0 %

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