MCPcopy Create free account
hub / github.com/OpenVPN/openvpn3-linux / Load

Method Load

src/common/configfileparser.cpp:115–154  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

113
114
115void File::Load(const fs::path &cfgfile)
116{
117 std::string fname = cfgfile.empty() ? config_filename : cfgfile;
118 if (fname.empty())
119 {
120 throw ConfigFileException("No configuration filename provided");
121 }
122
123 std::ifstream cfgs(fname);
124 if (cfgs.eof() || cfgs.fail())
125 {
126 throw ConfigFileException(fname, "Could not open file");
127 }
128
129 // Read the configuration file
130 std::string line;
131 std::stringstream buf;
132 while (std::getline(cfgs, line))
133 {
134 buf << line << std::endl;
135 }
136
137 // Don't try to parse an empty file
138 if (0 == buf.tellp())
139 {
140 return;
141 }
142
143 // Parse the configuration file
144 Json::Value jcfg;
145 try
146 {
147 buf >> jcfg;
148 Parse(jcfg);
149 }
150 catch (const Json::Exception &excp)
151 {
152 throw ConfigFileException(fname, "Error parsing file:" + std::string(excp.what()));
153 }
154}
155
156
157std::vector<std::string> File::GetOptions(bool all_configured)

Callers 7

logger_serviceFunction · 0.80
configure_loggerFunction · 0.80
configure_netcfgFunction · 0.80
cmd_netcfg_serviceFunction · 0.80
manage_config_fileFunction · 0.80
NetCfgOptionsMethod · 0.80
TEST_FFunction · 0.80

Calls 4

ConfigFileExceptionClass · 0.85
ParseClass · 0.85
emptyMethod · 0.45
whatMethod · 0.45

Tested by 1

TEST_FFunction · 0.64