bool CamulewebApp::OnCmdLineParsed(wxCmdLineParser& parser) { wxString aMuleConfigFile; if (parser.Found(wxT("amule-config-file"), &aMuleConfigFile)) { aMuleConfigFile = FinalizeFilename(aMuleConfigFile); if (!::wxFileExists(aMuleConfigFile)) { fprintf(stderr, "FATAL ERROR: file '%s' does not exist.\n", (const char*)unicode2char(aMuleConfigFile)); return false; } CECFileConfig cfg(aMuleConfigFile); LoadAmuleConfig(cfg); // do not process any other command-line parameters, use defaults instead if (!(m_TemplateOk = GetTemplateDir(m_TemplateName, m_TemplateDir))) { // no reason to run webserver without a template fprintf(stderr, "FATAL ERROR: Cannot find template: %s\n", (const char *)unicode2char(m_TemplateName)); return true; } m_Verbose = false; m_KeepQuiet = true; m_LoadSettingsFromAmule = true; return true; } if (CaMuleExternalConnector::OnCmdLineParsed(parser)) { if ( parser.Found(wxT("no-php")) ) { fprintf(stderr, "WARNING: --no-php switch have no effect. Long live PHP\n"); } parser.Found(wxT("template"), &m_TemplateName); if (m_TemplateName.IsEmpty()) { m_TemplateName = wxT("default"); } if (!(m_TemplateOk = GetTemplateDir(m_TemplateName, m_TemplateDir))) { // no reason to run webserver without a template fprintf(stderr, "FATAL ERROR: Cannot find template: %s\n", (const char *)unicode2char(m_TemplateName)); return true; } long port; if (parser.Found(wxT("server-port"), &port)) { m_WebserverPort = port; } if (parser.Found(wxT("enable-upnp"))) { m_UPnPWebServerEnabled = true; } if (parser.Found(wxT("upnp-port"), &port)) { m_UPnPTCPPort = port; } if (parser.Found(wxT("enable-gzip"))) { m_UseGzip = true; } if (parser.Found(wxT("disable-gzip"))) { m_UseGzip = false; } if (parser.Found(wxT("allow-guest"))) { m_AllowGuest = true; } if (parser.Found(wxT("deny-guest"))) { m_AllowGuest = false; } wxString tmp; if ( parser.Found(wxT("admin-pass"), &tmp) ) { if (tmp.IsEmpty()) { m_AdminPass.Clear(); } else { m_AdminPass.Decode(MD5Sum(tmp).GetHash()); } } if ( parser.Found(wxT("guest-pass"), &tmp) ) { if (tmp.IsEmpty()) { m_GuestPass.Clear(); } else { m_GuestPass.Decode(MD5Sum(tmp).GetHash()); } } m_LoadSettingsFromAmule = parser.Found(wxT("load-settings")); return true; } else { return false; } }
bool CaMuleExternalConnector::OnCmdLineParsed(wxCmdLineParser& parser) { if (parser.Found(wxT("version"))) { printf("%s %s\n", m_appname, (const char *)unicode2char(GetMuleVersion())); return false; } if (!parser.Found(wxT("config-file"), &m_configFileName)) { m_configFileName = GetConfigDir() + wxT("remote.conf"); } wxString aMuleConfigFile; if (parser.Found(wxT("create-config-from"), &aMuleConfigFile)) { aMuleConfigFile = FinalizeFilename(aMuleConfigFile); if (!::wxFileExists(aMuleConfigFile)) { fprintf(stderr, "%s\n", (const char *)unicode2char(wxT("FATAL ERROR: File does not exist: ") + aMuleConfigFile)); exit(1); } CECFileConfig aMuleConfig(aMuleConfigFile); LoadAmuleConfig(aMuleConfig); SaveConfigFile(); m_configFile->Flush(); exit(0); } LoadConfigFile(); if ( !parser.Found(wxT("host"), &m_host) ) { if ( m_host.IsEmpty() ) { m_host = wxT("localhost"); } } long port; if (parser.Found(wxT("port"), &port)) { m_port = port; } wxString pass_plain; if (parser.Found(wxT("password"), &pass_plain)) { if (!pass_plain.IsEmpty()) { m_password.Decode(MD5Sum(pass_plain).GetHash()); } else { m_password.Clear(); } } if (parser.Found(wxT("write-config"))) { m_NeedsConfigSave = true; } parser.Found(wxT("locale"), &m_language); if (parser.Found(wxT("help"))) { parser.Usage(); return false; } m_KeepQuiet = parser.Found(wxT("quiet")); m_Verbose = parser.Found(wxT("verbose")); return true; }