Updated --version argument to give more detailed output.

This commit is contained in:
Thulinma 2015-09-03 17:54:20 +02:00
parent 2fb1459dff
commit 096b289cdf
15 changed files with 30 additions and 29 deletions

View file

@ -35,7 +35,6 @@
bool Util::Config::is_active = false;
unsigned int Util::Config::printDebugLevel = DEBUG;//
std::string Util::Config::libver = PACKAGE_VERSION;
Util::Config::Config() {
//global options here
@ -44,14 +43,10 @@ Util::Config::Config() {
vals["debug"]["arg"] = "integer";
vals["debug"]["help"] = "The debug level at which messages need to be printed.";
vals["debug"]["value"].append((long long)DEBUG);
/*capabilities["optional"]["debug level"]["name"] = "debug";
capabilities["optional"]["debug level"]["help"] = "The debug level at which messages need to be printed.";
capabilities["optional"]["debug level"]["option"] = "--debug";
capabilities["optional"]["debug level"]["type"] = "integer";*/
}
/// Creates a new configuration manager.
Util::Config::Config(std::string cmd, std::string version) {
Util::Config::Config(std::string cmd) {
vals.null();
long_count = 2;
vals["cmd"]["value"].append(cmd);
@ -61,8 +56,6 @@ Util::Config::Config(std::string cmd, std::string version) {
vals["help"]["long"] = "help";
vals["help"]["short"] = "h";
vals["help"]["help"] = "Display usage and version information, then exit.";
vals["version"]["value"].append((std::string)PACKAGE_VERSION);
vals["version"]["value"].append(version);
vals["debug"]["long"] = "debug";
vals["debug"]["short"] = "g";
vals["debug"]["arg"] = "integer";
@ -246,8 +239,17 @@ bool Util::Config::parseArgs(int & argc, char ** & argv) {
case '?':
printHelp(std::cout);
case 'v':
std::cout << "Library version: " PACKAGE_VERSION << std::endl;
std::cout << "Application version: " << getString("version") << std::endl;
std::cout << "Version: " PACKAGE_VERSION ", release " RELEASE << std::endl;
#ifdef NOCRASHCHECK
std::cout << "- Flag: No crash check. Will not attempt to detect and kill crashed processes." << std::endl;
#endif
#ifndef SHM_ENABLED
std::cout << "- Flag: Shared memory disabled. Will use shared files in stead of shared memory as IPC method." << std::endl;
#endif
#ifdef WITH_THREADNAMES
std::cout << "- Flag: With threadnames. Debuggers will show sensible human-readable thread names." << std::endl;
#endif
std::cout << "Built on " __DATE__ ", " __TIME__ << std::endl;
exit(1);
break;
default:

View file

@ -21,12 +21,11 @@ namespace Util {
static void signal_handler(int signum);
public:
//variables
static std::string libver; ///< Version number of the library as a string.
static bool is_active; ///< Set to true by activate(), set to false by the signal handler.
static unsigned int printDebugLevel;
//functions
Config();
Config(std::string cmd, std::string version);
Config(std::string cmd);
void addOption(std::string optname, JSON::Value option);
void printHelp(std::ostream & output);
bool parseArgs(int & argc, char ** & argv);

View file

@ -32,7 +32,7 @@ namespace Analysers {
}
int main(int argc, char ** argv){
Util::Config conf = Util::Config(argv[0], PACKAGE_VERSION);
Util::Config conf = Util::Config(argv[0]);
conf.parseArgs(argc, argv);
return Analysers::analyseAMF();

View file

@ -55,7 +55,7 @@ namespace Analysers {
/// Reads an DTSC file and prints all readable data about it
int main(int argc, char ** argv){
Util::Config conf = Util::Config(argv[0], PACKAGE_VERSION);
Util::Config conf = Util::Config(argv[0]);
conf.addOption("filename", JSON::fromString("{\"arg_num\":1, \"arg\":\"string\", \"help\":\"Filename of the DTSC file to analyse.\"}"));
conf.parseArgs(argc, argv);
return Analysers::analyseDTSC(conf);

View file

@ -17,7 +17,7 @@
///Debugging tool for FLV data.
/// Expects FLV data through stdin, outputs human-readable information to stderr.
int main(int argc, char ** argv){
Util::Config conf = Util::Config(argv[0], PACKAGE_VERSION);
Util::Config conf = Util::Config(argv[0]);
conf.addOption("filter", JSON::fromString("{\"arg\":\"num\", \"short\":\"f\", \"long\":\"filter\", \"default\":0, \"help\":\"Only print info about this tag type (8 = audio, 9 = video, 0 = all)\"}"));
conf.parseArgs(argc, argv);

View file

@ -35,7 +35,7 @@ namespace Analysers {
/// Debugging tool for MP4 data.
/// Expects MP4 data through stdin, outputs human-readable information to stderr.
int main(int argc, char ** argv){
Util::Config conf = Util::Config(argv[0], PACKAGE_VERSION);
Util::Config conf = Util::Config(argv[0]);
conf.parseArgs(argc, argv);
return Analysers::analyseMP4();
}

View file

@ -115,7 +115,7 @@ namespace Analysers {
}
int analyseOGG(int argc, char ** argv){
Util::Config conf = Util::Config(argv[0], PACKAGE_VERSION);
Util::Config conf = Util::Config(argv[0]);
conf.addOption("pages", JSON::fromString("{\"long\":\"pages\", \"short\":\"p\", \"long_off\":\"nopages\", \"short_off\":\"P\", \"default\":0, \"help\":\"Enable/disable printing of Ogg pages\"}"));
conf.parseArgs(argc, argv);

View file

@ -209,7 +209,7 @@ namespace Analysers {
}
int main(int argc, char ** argv){
Util::Config conf = Util::Config(argv[0], PACKAGE_VERSION);
Util::Config conf = Util::Config(argv[0]);
conf.addOption("detail",
JSON::fromString(
"{\"arg_num\":1, \"arg\":\"integer\", \"default\":0, \"help\":\"Bitmask, 1 = Reconstruct, 2 = Explicit media info, 4 = Verbose chunks\"}"));

View file

@ -133,7 +133,7 @@ int main(int argc, char ** argv){
if ( !stored_user["default"]){
stored_user["default"] = "root";
}
Controller::conf = Util::Config(argv[0], PACKAGE_VERSION " / " RELEASE);
Controller::conf = Util::Config(argv[0]);
Controller::conf.addOption("listen_port", stored_port);
Controller::conf.addOption("listen_interface", stored_interface);
Controller::conf.addOption("username", stored_user);

View file

@ -167,7 +167,7 @@ int Controller::handleAPIConnection(Socket::Connection & conn){
H.Clean();
H.SetHeader("Content-Type", "text/html");
H.SetHeader("X-Info", "To force an API response, request the file /api");
H.SetHeader("Server", "mistserver/" PACKAGE_VERSION "/" + Util::Config::libver + "/" RELEASE);
H.SetHeader("Server", "MistServer/" PACKAGE_VERSION);
H.SetHeader("Content-Length", server_html_len);
H.SendResponse("200", "OK", conn);
conn.SendNow(server_html, server_html_len);
@ -313,7 +313,7 @@ int Controller::handleAPIConnection(Socket::Connection & conn){
}
//sent current configuration, no matter if it was changed or not
Response["config"] = Controller::Storage["config"];
Response["config"]["version"] = PACKAGE_VERSION "/" + Util::Config::libver + "/" RELEASE;
Response["config"]["version"] = PACKAGE_VERSION;
Response["streams"] = Controller::Storage["streams"];
//add required data to the current unix time to the config, for syncing reasons
Response["config"]["time"] = Util::epoch();

View file

@ -12,7 +12,7 @@
#include <mist/procs.h>
int main(int argc, char * argv[]) {
Util::Config conf(argv[0], PACKAGE_VERSION);
Util::Config conf(argv[0]);
mistIn conv(&conf);
if (conf.parseArgs(argc, argv)) {
std::string streamName = conf.getString("streamname");

View file

@ -8,7 +8,7 @@ int spawnForked(Socket::Connection & S){
}
int main(int argc, char * argv[]) {
Util::Config conf(argv[0], PACKAGE_VERSION);
Util::Config conf(argv[0]);
mistOut::init(&conf);
if (conf.parseArgs(argc, argv)) {
if (conf.getBool("json")) {

View file

@ -143,7 +143,7 @@ namespace Mist {
if (H.url == "/crossdomain.xml"){
H.Clean();
H.SetHeader("Content-Type", "text/xml");
H.SetHeader("Server", "mistserver/" PACKAGE_VERSION "/" + Util::Config::libver);
H.SetHeader("Server", "MistServer/" PACKAGE_VERSION);
H.setCORSHeaders();
H.SetBody("<?xml version=\"1.0\"?><!DOCTYPE cross-domain-policy SYSTEM \"http://www.adobe.com/xml/dtds/cross-domain-policy.dtd\"><cross-domain-policy><allow-access-from domain=\"*\" /><site-control permitted-cross-domain-policies=\"all\"/></cross-domain-policy>");
H.SendResponse("200", "OK", myConn);

View file

@ -162,7 +162,7 @@ namespace Mist {
DEBUG_MSG(DLVL_MEDIUM, "Received request: %s => %s (%s)", H.getUrl().c_str(), handler.c_str(), H.GetVar("stream").c_str());
if (!handler.size()){
H.Clean();
H.SetHeader("Server", "mistserver/" PACKAGE_VERSION);
H.SetHeader("Server", "MistServer/" PACKAGE_VERSION);
H.SetBody("<!DOCTYPE html><html><head><title>Unsupported Media Type</title></head><body><h1>Unsupported Media Type</h1>The server isn't quite sure what you wanted to receive from it.</body></html>");
H.SendResponse("415", "Unsupported Media Type", myConn);
myConn.close();

View file

@ -147,7 +147,7 @@ namespace Mist {
if (H.url == "/crossdomain.xml"){
H.Clean();
H.SetHeader("Content-Type", "text/xml");
H.SetHeader("Server", "mistserver/" PACKAGE_VERSION);
H.SetHeader("Server", "MistServer/" PACKAGE_VERSION);
H.setCORSHeaders();
H.SetBody("<?xml version=\"1.0\"?><!DOCTYPE cross-domain-policy SYSTEM \"http://www.adobe.com/xml/dtds/cross-domain-policy.dtd\"><cross-domain-policy><allow-access-from domain=\"*\" /><site-control permitted-cross-domain-policies=\"all\"/></cross-domain-policy>");
H.SendResponse("200", "OK", myConn);
@ -157,7 +157,7 @@ namespace Mist {
if (H.url == "/clientaccesspolicy.xml"){
H.Clean();
H.SetHeader("Content-Type", "text/xml");
H.SetHeader("Server", "mistserver/" PACKAGE_VERSION);
H.SetHeader("Server", "MistServer/" PACKAGE_VERSION);
H.setCORSHeaders();
H.SetBody("<?xml version=\"1.0\" encoding=\"utf-8\"?><access-policy><cross-domain-access><policy><allow-from http-methods=\"*\" http-request-headers=\"*\"><domain uri=\"*\"/></allow-from><grant-to><resource path=\"/\" include-subpaths=\"true\"/></grant-to></policy></cross-domain-access></access-policy>");
H.SendResponse("200", "OK", myConn);
@ -169,7 +169,7 @@ namespace Mist {
H.Clean();
#include "../icon.h"
H.SetHeader("Content-Type", "image/x-icon");
H.SetHeader("Server", "mistserver/" PACKAGE_VERSION);
H.SetHeader("Server", "MistServer/" PACKAGE_VERSION);
H.SetHeader("Content-Length", icon_len);
H.SendResponse("200", "OK", myConn);
myConn.SendNow((const char*)icon_data, icon_len);
@ -180,7 +180,7 @@ namespace Mist {
if (H.url.length() > 6 && H.url.substr(H.url.length() - 5, 5) == ".html"){
H.Clean();
H.SetHeader("Content-Type", "text/html");
H.SetHeader("Server", "mistserver/" PACKAGE_VERSION);
H.SetHeader("Server", "MistServer/" PACKAGE_VERSION);
H.setCORSHeaders();
H.SetBody("<!DOCTYPE html><html><head><title>Stream "+streamName+"</title><style>BODY{color:white;background:black;}</style></head><body><script src=\"embed_"+streamName+".js\"></script></body></html>");
H.SendResponse("200", "OK", myConn);