Commit 7df3180a authored by Keliang's avatar Keliang

add some license

parent b98ec793
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this
*file except in compliance with the License. You may obtain a copy of the
*License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! file
brief
author Jian Yang,Fengjiao He,Hongxin Wang
date 2020
email: contact@openairinterface.org
*/
#include "logger.hpp"
#include "options.hpp"
#include "udr_config.hpp"
......@@ -8,7 +36,6 @@ using namespace config;
udr_config udr_cfg;
int main(int argc, char **argv) {
if (!Options::parse(argc, argv)) {
std::cout << "Options::parse() failed" << std::endl;
return 1;
......
......@@ -14,12 +14,13 @@
* limitations under the License.
*/
#include "options.hpp"
#include <getopt.h>
#include <iostream>
#include <stdlib.h>
#include <unistd.h>
#include "options.hpp"
#include <iostream>
int Options::options;
......@@ -45,7 +46,6 @@ void Options::help() {
//------------------------------------------------------------------------------
bool Options::parse(int argc, char **argv) {
bool ret = true;
ret = parseInputOptions(argc, argv);
......@@ -72,62 +72,63 @@ bool Options::parseInputOptions(int argc, char **argv) {
// Loop on arguments
while (1) {
c = getopt_long(argc, argv, "horc:", long_options, &option_index);
if (c == -1)
break; // Exit from the loop.
if (c == -1) break; // Exit from the loop.
switch (c) {
case 'h': {
help();
exit(0);
break;
}
case 'c': {
m_libconfigcfg = optarg;
options |= libconfigcfg;
break;
}
case 'o': {
m_log_stdout = true;
options |= log_stdout;
break;
}
case 'r': {
m_log_rot_file_log = true;
options |= log_rot_file_log;
break;
}
case '?': {
switch (optopt) {
case 'h': {
help();
exit(0);
break;
}
case 'c': {
std::cout << "Option -l (libconfig config) requires an argument"
<< std::endl;
m_libconfigcfg = optarg;
options |= libconfigcfg;
break;
}
case 'o': {
std::cout << "Option -o do not requires an argument, can be also set "
"with option -r."
<< std::endl;
m_log_stdout = true;
options |= log_stdout;
break;
}
case 'r': {
std::cout << "Option -r do not requires an argument, can be also set "
"with option -o."
<< std::endl;
m_log_rot_file_log = true;
options |= log_rot_file_log;
break;
}
default: {
std::cout << "Unrecognized option [" << c << "]" << std::endl;
case '?': {
switch (optopt) {
case 'c': {
std::cout << "Option -l (libconfig config) requires an argument"
<< std::endl;
break;
}
case 'o': {
std::cout
<< "Option -o do not requires an argument, can be also set "
"with option -r."
<< std::endl;
break;
}
case 'r': {
std::cout
<< "Option -r do not requires an argument, can be also set "
"with option -o."
<< std::endl;
break;
}
default: {
std::cout << "Unrecognized option [" << c << "]" << std::endl;
break;
}
}
result = false;
break;
}
default: {
std::cout << "Unrecognized option [" << c << "]" << std::endl;
result = false;
}
result = false;
break;
}
default: {
std::cout << "Unrecognized option [" << c << "]" << std::endl;
result = false;
}
}
}
return result;
......
......@@ -18,10 +18,11 @@
#define __OPTIONS_H
#include <stdint.h>
#include <string>
class Options {
public:
public:
static bool parse(int argc, char **argv);
static bool parseInputOptions(int argc, char **argv);
static bool parseJson();
......@@ -31,7 +32,7 @@ public:
static const bool &getlogRotFilelog() { return m_log_rot_file_log; }
static const bool &getlogStdout() { return m_log_stdout; }
private:
private:
enum OptionsSelected {
libconfigcfg = 0x01,
log_stdout = 0x02,
......@@ -47,4 +48,4 @@ private:
static std::string m_libconfigcfg;
};
#endif // #define __OPTIONS_H
#endif // #define __OPTIONS_H
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment