CernVM-FS  2.12.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
libcvmfs_cache_options.cc
Go to the documentation of this file.
1 
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 
22  *reinterpret_cast<SimpleOptionsParser *>(opts));
23  return result;
24 }
25 
26 
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 
49  char *result = strdup(opts->Dump().c_str());
50  assert(result != NULL);
51  return result;
52 }
53 
54 
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 
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 }
void set_taint_environment(bool value)
Definition: options.h:193
char * cvmcache_options_dump(cvmcache_option_map *opts)
assert((mem||(size==0))&&"Out Of Memory")
void SetValue(const std::string &key, const std::string &value)
Definition: options.cc:473
bool TryParsePath(const std::string &config_file)
Definition: options.cc:110
std::string Dump()
Definition: options.cc:454
void cvmcache_options_free(char *value)
void cvmcache_options_fini(cvmcache_option_map *opts)
SimpleOptionsParser * cvmcache_options_clone(SimpleOptionsParser *opts)
bool GetValue(const std::string &key, std::string *value) const
Definition: options.cc:376
int cvmcache_options_parse(cvmcache_option_map *opts, const char *path)
void cvmcache_options_unset(cvmcache_option_map *opts, const char *key)
char * cvmcache_options_get(cvmcache_option_map *opts, const char *key)
void cvmcache_options_set(cvmcache_option_map *opts, const char *key, const char *value)
void UnsetValue(const std::string &key)
Definition: options.cc:481
cvmcache_option_map * cvmcache_options_init()