CernVM-FS  2.13.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 <cassert>
9 #include <cstdlib>
10 #include <cstring>
11 #include <string>
12 
13 #include "libcvmfs.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 cvmfs_options_fini(SimpleOptionsParser *opts) { delete opts; }
27 
28 
29 void cvmfs_options_free(char *value) { free(value); }
30 
31 
32 char *cvmfs_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 
44  char *result = strdup(opts->Dump().c_str());
45  assert(result != NULL);
46  return result;
47 }
48 
49 
51 
52 
55  // In contrast to the fuse module, we don't want to taint the process'
56  // environment with parameters from the cvmfs configuration in libcvmfs
57  result->set_taint_environment(taint_environ);
58  // Not strictly necessary but avoids a failure log message
59  result->SetValue("CVMFS_MOUNT_DIR", "/cvmfs");
60  return result;
61 }
62 
63 
64 void cvmfs_options_set(SimpleOptionsParser *opts, const char *key,
65  const char *value) {
66  opts->SetValue(key, value);
67 }
68 
69 
70 int cvmfs_options_parse(SimpleOptionsParser *opts, const char *path) {
71  const bool result = opts->TryParsePath(path);
72  return result ? 0 : -1;
73 }
74 
75 void cvmfs_options_parse_default(SimpleOptionsParser *opts, const char *fqrn) {
76  opts->ParseDefault(fqrn);
77 }
78 
79 void cvmfs_options_unset(SimpleOptionsParser *opts, const char *key) {
80  opts->UnsetValue(key);
81 }
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:198
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:281
void SetValue(const std::string &key, const std::string &value)
Definition: options.cc:472
void cvmfs_options_fini(cvmfs_option_map *opts)
bool TryParsePath(const std::string &config_file)
Definition: options.cc:109
std::string Dump()
Definition: options.cc:447
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:369
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:480