Changeset 71353 in vbox for trunk/src/VBox/NetworkServices/Dhcpd
- Timestamp:
- Mar 15, 2018 2:11:55 PM (7 years ago)
- svn:sync-xref-src-repo-rev:
- 121304
- Location:
- trunk/src/VBox/NetworkServices/Dhcpd
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/NetworkServices/Dhcpd/Config.cpp
r71306 r71353 193 193 194 194 195 static const RTGETOPTDEF g_aOptions[] = 196 { 197 { "--config", 'c', RTGETOPT_REQ_STRING }, 198 }; 199 200 201 Config *Config::create(int argc, char **argv) 202 { 203 RTGETOPTSTATE State; 204 int rc; 205 206 rc = RTGetOptInit(&State, argc, argv, 207 g_aOptions, RT_ELEMENTS(g_aOptions), 1, 208 RTGETOPTINIT_FLAGS_NO_STD_OPTS); 209 AssertRCReturn(rc, NULL); 210 211 std::unique_ptr<Config> config; 212 for (;;) 213 { 214 RTGETOPTUNION Val; 215 216 rc = RTGetOpt(&State, &Val); 217 if (rc == 0) /* done */ 218 break; 219 220 switch (rc) 221 { 222 case 'c': /* --config */ 223 if (config.get() != NULL) 224 { 225 printf("Duplicate option: --config '%s'\n", Val.psz); 226 return NULL; 227 } 228 229 printf("reading config from %s\n", Val.psz); 230 config.reset(Config::read(Val.psz)); 231 if (config.get() == NULL) 232 return NULL; 233 234 break; 235 236 case VINF_GETOPT_NOT_OPTION: 237 RTMsgError("Unexpected command line argument: '%s'", Val.psz); 238 return NULL; 239 240 default: 241 RTGetOptPrintError(rc, &Val); 242 return NULL; 243 } 244 } 245 246 if (config.get() == NULL) 247 return NULL; 248 249 if (!config->isSane()) 250 return NULL; 251 252 config->sanitizeBaseName(); 253 254 return config.release(); 255 } 256 257 195 258 Config *Config::read(const char *pszFileName) 196 259 { 260 std::unique_ptr<Config> config(new Config()); 261 197 262 RT_NOREF(pszFileName); 198 return NULL; /* not yet */263 return config.release(); 199 264 } 200 265 -
trunk/src/VBox/NetworkServices/Dhcpd/Config.h
r70836 r71353 54 54 public: /* factory methods */ 55 55 static Config *hardcoded(); /* for testing */ 56 static Config *create(int argc, char **argv); /* --config */ 56 57 static Config *compat(int argc, char **argv); /* old VBoxNetDHCP flags */ 57 static Config *read(const char *pszFileName);58 58 59 59 public: /* accessors */ … … 79 79 80 80 private: 81 static Config *read(const char *pszFileName); 82 81 83 void sanitizeBaseName(); 82 84 -
trunk/src/VBox/NetworkServices/Dhcpd/VBoxNetDhcpd.cpp
r71305 r71353 580 580 if (argc < 2) 581 581 m_Config = Config::hardcoded(); 582 else if (strcmp(argv[1], "--config") == 0) 583 m_Config = Config::create(argc, argv); 582 584 else 583 585 m_Config = Config::compat(argc, argv);
Note:
See TracChangeset
for help on using the changeset viewer.