CernVM-FS  2.12.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
libcvmfs_options.cc
Go to the documentation of this file.
1 
8 #include "libcvmfs.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 cvmfs_options_free(char *value) {
33  free(value);
34 }
35 
36 
37 char *cvmfs_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 
56  return cvmfs_options_init_v2(0);
57 }
58 
59 
62  // In contrast to the fuse module, we don't want to taint the process'
63  // environment with parameters from the cvmfs configuration in libcvmfs
64  result->set_taint_environment(taint_environ);
65  // Not strictly necessary but avoids a failure log message
66  result->SetValue("CVMFS_MOUNT_DIR", "/cvmfs");
67  return result;
68 }
69 
70 
72  SimpleOptionsParser *opts,
73  const char *key, const
74  char *value)
75 {
76  opts->SetValue(key, value);
77 }
78 
79 
80 int cvmfs_options_parse(SimpleOptionsParser *opts, const char *path) {
81  bool result = opts->TryParsePath(path);
82  return result ? 0 : -1;
83 }
84 
85 void cvmfs_options_parse_default(SimpleOptionsParser *opts, const char *fqrn) {
86  opts->ParseDefault(fqrn);
87 }
88 
89 void cvmfs_options_unset(SimpleOptionsParser *opts, const char *key) {
90  opts->UnsetValue(key);
91 }
int cvmfs_options_parse(cvmfs_option_map *opts, const char *path)
void cvmfs_options_parse_default(cvmfs_option_map *opts, const char *fqrn)
void set_taint_environment(bool value)
Definition: options.h:199
cvmfs_option_map * cvmfs_options_clone(cvmfs_option_map *opts)
cvmfs_option_map * cvmfs_options_init()
assert((mem||(size==0))&&"Out Of Memory")
void cvmfs_options_set(cvmfs_option_map *opts, const char *key, const char *value)
void ParseDefault(const std::string &fqrn)
Definition: options.cc:282
void SetValue(const std::string &key, const std::string &value)
Definition: options.cc:479
void cvmfs_options_fini(cvmfs_option_map *opts)
bool TryParsePath(const std::string &config_file)
Definition: options.cc:110
std::string Dump()
Definition: options.cc:454
char * cvmfs_options_get(cvmfs_option_map *opts, const char *key)
char * cvmfs_options_dump(cvmfs_option_map *opts)
cvmfs_option_map * cvmfs_options_init_v2(int taint_environ)
bool GetValue(const std::string &key, std::string *value) const
Definition: options.cc:376
void cvmfs_options_free(char *value)
void cvmfs_options_unset(cvmfs_option_map *opts, const char *key)
void UnsetValue(const std::string &key)
Definition: options.cc:487