CernVM-FS  2.13.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 
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 
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  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 
44  char *result = strdup(opts->Dump().c_str());
45  assert(result != NULL);
46  return result;
47 }
48 
49 
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  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 }
void set_taint_environment(bool value)
Definition: options.h:198
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:471
bool TryParsePath(const std::string &config_file)
Definition: options.cc:109
std::string Dump()
Definition: options.cc:446
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:368
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:479
cvmcache_option_map * cvmcache_options_init()