mirror of
https://github.com/nzbget/nzbget.git
synced 2026-08-07 07:52:06 -04:00
#126: replaced C-style strings with class "CString"
: replaced all data members.
This commit is contained in:
1 parent
6b0fdc881e
commit
558fce9b47
56 files changed
+550
-1237
No files matched your search
@@ -127,10 +127,9 @@ Connection::Connection(const char* host, int port, bool tls)
|
||||
{
|
||||
debug("Creating Connection");
|
||||
|
||||
m_host = NULL;
|
||||
m_host = host;
|
||||
m_port = port;
|
||||
m_tls = tls;
|
||||
m_cipher = NULL;
|
||||
m_status = csDisconnected;
|
||||
m_socket = INVALID_SOCKET;
|
||||
m_bufAvail = 0;
|
||||
@@ -144,21 +143,14 @@ Connection::Connection(const char* host, int port, bool tls)
|
||||
m_tlsSocket = NULL;
|
||||
m_tlsError = false;
|
||||
#endif
|
||||
|
||||
if (host)
|
||||
{
|
||||
m_host = strdup(host);
|
||||
}
|
||||
}
|
||||
|
||||
Connection::Connection(SOCKET socket, bool tls)
|
||||
{
|
||||
debug("Creating Connection");
|
||||
|
||||
m_host = NULL;
|
||||
m_port = 0;
|
||||
m_tls = tls;
|
||||
m_cipher = NULL;
|
||||
m_status = csConnected;
|
||||
m_socket = socket;
|
||||
m_bufAvail = 0;
|
||||
@@ -177,8 +169,6 @@ Connection::~Connection()
|
||||
|
||||
Disconnect();
|
||||
|
||||
free(m_host);
|
||||
free(m_cipher);
|
||||
free(m_readBuf);
|
||||
#ifndef DISABLE_TLS
|
||||
delete m_tlsSocket;
|
||||
@@ -196,12 +186,6 @@ void Connection::SetSuppressErrors(bool suppressErrors)
|
||||
#endif
|
||||
}
|
||||
|
||||
void Connection::SetCipher(const char* cipher)
|
||||
{
|
||||
free(m_cipher);
|
||||
m_cipher = cipher ? strdup(cipher) : NULL;
|
||||
}
|
||||
|
||||
bool Connection::Connect()
|
||||
{
|
||||
debug("Connecting");
|
||||
@@ -1044,7 +1028,7 @@ const char* Connection::GetRemoteAddr()
|
||||
if (getpeername(m_socket, (struct sockaddr*)&PeerName, (SOCKLEN_T*) &peerNameLength) >= 0)
|
||||
{
|
||||
#ifdef WIN32
|
||||
strncpy(m_remoteAddr, inet_ntoa(PeerName.sin_addr), sizeof(m_remoteAddr));
|
||||
strncpy(m_remoteAddr, inet_ntoa(PeerName.sin_addr), sizeof(m_remoteAddr));
|
||||
#else
|
||||
inet_ntop(AF_INET, &PeerName.sin_addr, m_remoteAddr, sizeof(m_remoteAddr));
|
||||
#endif
|
||||
|
||||
@@ -27,6 +27,8 @@
|
||||
#ifndef CONNECTION_H
|
||||
#define CONNECTION_H
|
||||
|
||||
#include "NString.h"
|
||||
|
||||
#ifndef HAVE_GETADDRINFO
|
||||
#ifndef HAVE_GETHOSTBYNAME_R
|
||||
#include "Thread.h"
|
||||
@@ -48,11 +50,11 @@ public:
|
||||
};
|
||||
|
||||
protected:
|
||||
char* m_host;
|
||||
CString m_host;
|
||||
int m_port;
|
||||
SOCKET m_socket;
|
||||
bool m_tls;
|
||||
char* m_cipher;
|
||||
CString m_cipher;
|
||||
char* m_readBuf;
|
||||
int m_bufAvail;
|
||||
char* m_bufPtr;
|
||||
@@ -131,7 +133,7 @@ public:
|
||||
int GetPort() { return m_port; }
|
||||
bool GetTls() { return m_tls; }
|
||||
const char* GetCipher() { return m_cipher; }
|
||||
void SetCipher(const char* cipher);
|
||||
void SetCipher(const char* cipher) { m_cipher = cipher; }
|
||||
void SetTimeout(int timeout) { m_timeout = timeout; }
|
||||
EStatus GetStatus() { return m_status; }
|
||||
void SetSuppressErrors(bool suppressErrors);
|
||||
|
||||
@@ -221,9 +221,9 @@ TlsSocket::TlsSocket(SOCKET socket, bool isClient, const char* certFile, const c
|
||||
{
|
||||
m_socket = socket;
|
||||
m_isClient = isClient;
|
||||
m_certFile = certFile ? strdup(certFile) : NULL;
|
||||
m_keyFile = keyFile ? strdup(keyFile) : NULL;
|
||||
m_cipher = cipher && strlen(cipher) > 0 ? strdup(cipher) : NULL;
|
||||
m_certFile = certFile;
|
||||
m_keyFile = keyFile;
|
||||
m_cipher = cipher;
|
||||
m_context = NULL;
|
||||
m_session = NULL;
|
||||
m_suppressErrors = false;
|
||||
@@ -233,9 +233,6 @@ TlsSocket::TlsSocket(SOCKET socket, bool isClient, const char* certFile, const c
|
||||
|
||||
TlsSocket::~TlsSocket()
|
||||
{
|
||||
free(m_certFile);
|
||||
free(m_keyFile);
|
||||
free(m_cipher);
|
||||
Close();
|
||||
}
|
||||
|
||||
@@ -328,7 +325,7 @@ bool TlsSocket::Start()
|
||||
|
||||
m_initialized = true;
|
||||
|
||||
const char* priority = m_cipher ? m_cipher : "NORMAL";
|
||||
const char* priority = !m_cipher.Empty() ? m_cipher : "NORMAL";
|
||||
|
||||
m_retCode = gnutls_priority_set_direct((gnutls_session_t)m_session, priority, NULL);
|
||||
if (m_retCode != 0)
|
||||
@@ -394,7 +391,7 @@ bool TlsSocket::Start()
|
||||
return false;
|
||||
}
|
||||
|
||||
if (m_cipher && !SSL_set_cipher_list((SSL*)m_session, m_cipher))
|
||||
if (!m_cipher.Empty() && !SSL_set_cipher_list((SSL*)m_session, m_cipher))
|
||||
{
|
||||
ReportError("Could not select cipher for TLS");
|
||||
Close();
|
||||
|
||||
@@ -27,13 +27,15 @@
|
||||
|
||||
#ifndef DISABLE_TLS
|
||||
|
||||
#include "NString.h"
|
||||
|
||||
class TlsSocket
|
||||
{
|
||||
private:
|
||||
bool m_isClient;
|
||||
char* m_certFile;
|
||||
char* m_keyFile;
|
||||
char* m_cipher;
|
||||
CString m_certFile;
|
||||
CString m_keyFile;
|
||||
CString m_cipher;
|
||||
SOCKET m_socket;
|
||||
bool m_suppressErrors;
|
||||
int m_retCode;
|
||||
|
||||
@@ -33,42 +33,17 @@ WebDownloader::WebDownloader()
|
||||
{
|
||||
debug("Creating WebDownloader");
|
||||
|
||||
m_url = NULL;
|
||||
m_outputFilename = NULL;
|
||||
m_connection = NULL;
|
||||
m_infoName = NULL;
|
||||
m_confirmedLength = false;
|
||||
m_status = adUndefined;
|
||||
m_originalFilename = NULL;
|
||||
m_force = false;
|
||||
m_retry = true;
|
||||
SetLastUpdateTimeNow();
|
||||
}
|
||||
|
||||
WebDownloader::~WebDownloader()
|
||||
void WebDownloader::SetUrl(const char* url)
|
||||
{
|
||||
debug("Destroying WebDownloader");
|
||||
|
||||
free(m_url);
|
||||
free(m_infoName);
|
||||
free(m_outputFilename);
|
||||
free(m_originalFilename);
|
||||
}
|
||||
|
||||
void WebDownloader::SetOutputFilename(const char* v)
|
||||
{
|
||||
m_outputFilename = strdup(v);
|
||||
}
|
||||
|
||||
void WebDownloader::SetInfoName(const char* v)
|
||||
{
|
||||
m_infoName = strdup(v);
|
||||
}
|
||||
|
||||
void WebDownloader::SetUrl(const char * url)
|
||||
{
|
||||
free(m_url);
|
||||
m_url = WebUtil::UrlEncode(url);
|
||||
m_url.Bind(WebUtil::UrlEncode(url));
|
||||
}
|
||||
|
||||
void WebDownloader::SetStatus(EStatus status)
|
||||
@@ -143,17 +118,17 @@ void WebDownloader::Run()
|
||||
{
|
||||
if (IsStopped())
|
||||
{
|
||||
detail("Download %s cancelled", m_infoName);
|
||||
detail("Download %s cancelled", *m_infoName);
|
||||
}
|
||||
else
|
||||
{
|
||||
error("Download %s failed", m_infoName);
|
||||
error("Download %s failed", *m_infoName);
|
||||
}
|
||||
}
|
||||
|
||||
if (Status == adFinished)
|
||||
{
|
||||
detail("Download %s completed", m_infoName);
|
||||
detail("Download %s completed", *m_infoName);
|
||||
}
|
||||
|
||||
SetStatus(Status);
|
||||
@@ -185,7 +160,7 @@ WebDownloader::EStatus WebDownloader::Download()
|
||||
}
|
||||
|
||||
// Okay, we got a Connection. Now start downloading.
|
||||
detail("Downloading %s", m_infoName);
|
||||
detail("Downloading %s", *m_infoName);
|
||||
|
||||
SendHeaders(&url);
|
||||
|
||||
@@ -224,7 +199,7 @@ WebDownloader::EStatus WebDownloader::DownloadWithRedirects(int maxRedirects)
|
||||
|
||||
if (status == adRedirect && maxRedirects < 0)
|
||||
{
|
||||
warn("Too many redirects for %s", m_infoName);
|
||||
warn("Too many redirects for %s", *m_infoName);
|
||||
status = adFailed;
|
||||
}
|
||||
|
||||
@@ -339,7 +314,7 @@ WebDownloader::EStatus WebDownloader::DownloadHeaders()
|
||||
{
|
||||
if (!IsStopped())
|
||||
{
|
||||
warn("URL %s failed: Unexpected end of file", m_infoName);
|
||||
warn("URL %s failed: Unexpected end of file", *m_infoName);
|
||||
}
|
||||
Status = adFailed;
|
||||
break;
|
||||
@@ -411,7 +386,7 @@ WebDownloader::EStatus WebDownloader::DownloadBody()
|
||||
|
||||
if (!IsStopped())
|
||||
{
|
||||
warn("URL %s failed: Unexpected end of file", m_infoName);
|
||||
warn("URL %s failed: Unexpected end of file", *m_infoName);
|
||||
}
|
||||
Status = adFailed;
|
||||
break;
|
||||
@@ -446,7 +421,7 @@ WebDownloader::EStatus WebDownloader::DownloadBody()
|
||||
|
||||
if (!end && Status == adRunning && !IsStopped())
|
||||
{
|
||||
warn("URL %s failed: file incomplete", m_infoName);
|
||||
warn("URL %s failed: file incomplete", *m_infoName);
|
||||
Status = adFailed;
|
||||
}
|
||||
|
||||
@@ -464,7 +439,7 @@ WebDownloader::EStatus WebDownloader::CheckResponse(const char* response)
|
||||
{
|
||||
if (!IsStopped())
|
||||
{
|
||||
warn("URL %s: Connection closed by remote host", m_infoName);
|
||||
warn("URL %s: Connection closed by remote host", *m_infoName);
|
||||
}
|
||||
return adConnectError;
|
||||
}
|
||||
@@ -472,7 +447,7 @@ WebDownloader::EStatus WebDownloader::CheckResponse(const char* response)
|
||||
const char* hTTPResponse = strchr(response, ' ');
|
||||
if (strncmp(response, "HTTP", 4) || !hTTPResponse)
|
||||
{
|
||||
warn("URL %s failed: %s", m_infoName, response);
|
||||
warn("URL %s failed: %s", *m_infoName, response);
|
||||
return adFailed;
|
||||
}
|
||||
|
||||
@@ -480,12 +455,12 @@ WebDownloader::EStatus WebDownloader::CheckResponse(const char* response)
|
||||
|
||||
if (!strncmp(hTTPResponse, "400", 3) || !strncmp(hTTPResponse, "499", 3))
|
||||
{
|
||||
warn("URL %s failed: %s", m_infoName, hTTPResponse);
|
||||
warn("URL %s failed: %s", *m_infoName, hTTPResponse);
|
||||
return adConnectError;
|
||||
}
|
||||
else if (!strncmp(hTTPResponse, "404", 3))
|
||||
{
|
||||
warn("URL %s failed: %s", m_infoName, hTTPResponse);
|
||||
warn("URL %s failed: %s", *m_infoName, hTTPResponse);
|
||||
return adNotFound;
|
||||
}
|
||||
else if (!strncmp(hTTPResponse, "301", 3) || !strncmp(hTTPResponse, "302", 3))
|
||||
@@ -501,7 +476,7 @@ WebDownloader::EStatus WebDownloader::CheckResponse(const char* response)
|
||||
else
|
||||
{
|
||||
// unknown error, no special handling
|
||||
warn("URL %s failed: %s", m_infoName, response);
|
||||
warn("URL %s failed: %s", *m_infoName, response);
|
||||
return adFailed;
|
||||
}
|
||||
}
|
||||
@@ -562,10 +537,9 @@ void WebDownloader::ParseFilename(const char* contentDisposition)
|
||||
|
||||
WebUtil::HttpUnquote(fname);
|
||||
|
||||
free(m_originalFilename);
|
||||
m_originalFilename = strdup(Util::BaseFileName(fname));
|
||||
m_originalFilename = Util::BaseFileName(fname);
|
||||
|
||||
debug("OriginalFilename: %s", m_originalFilename);
|
||||
debug("OriginalFilename: %s", *m_originalFilename);
|
||||
}
|
||||
|
||||
void WebDownloader::ParseRedirect(const char* location)
|
||||
@@ -619,7 +593,7 @@ void WebDownloader::ParseRedirect(const char* location)
|
||||
urlBuf[1024-1] = '\0';
|
||||
newLocation = urlBuf;
|
||||
}
|
||||
detail("URL %s redirected to %s", m_url, newLocation);
|
||||
detail("URL %s redirected to %s", *m_url, newLocation);
|
||||
SetUrl(newLocation);
|
||||
}
|
||||
|
||||
@@ -642,7 +616,7 @@ bool WebDownloader::Write(void* buffer, int len)
|
||||
|
||||
if (gZStatus == GUnzipStream::zlError)
|
||||
{
|
||||
error("URL %s: GUnzip failed", m_infoName);
|
||||
error("URL %s: GUnzip failed", *m_infoName);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#ifndef WEBDOWNLOADER_H
|
||||
#define WEBDOWNLOADER_H
|
||||
|
||||
#include "NString.h"
|
||||
#include "Observer.h"
|
||||
#include "Thread.h"
|
||||
#include "Connection.h"
|
||||
@@ -48,17 +49,17 @@ public:
|
||||
};
|
||||
|
||||
private:
|
||||
char* m_url;
|
||||
char* m_outputFilename;
|
||||
CString m_url;
|
||||
CString m_outputFilename;
|
||||
Connection* m_connection;
|
||||
Mutex m_connectionMutex;
|
||||
EStatus m_status;
|
||||
time_t m_lastUpdateTime;
|
||||
char* m_infoName;
|
||||
CString m_infoName;
|
||||
FILE* m_outFile;
|
||||
int m_contentLen;
|
||||
bool m_confirmedLength;
|
||||
char* m_originalFilename;
|
||||
CString m_originalFilename;
|
||||
bool m_force;
|
||||
bool m_redirecting;
|
||||
bool m_redirected;
|
||||
@@ -85,18 +86,17 @@ protected:
|
||||
|
||||
public:
|
||||
WebDownloader();
|
||||
virtual ~WebDownloader();
|
||||
EStatus GetStatus() { return m_status; }
|
||||
virtual void Run();
|
||||
virtual void Stop();
|
||||
EStatus Download();
|
||||
EStatus DownloadWithRedirects(int maxRedirects);
|
||||
bool Terminate();
|
||||
void SetInfoName(const char* v);
|
||||
void SetInfoName(const char* infoName) { m_infoName = infoName; }
|
||||
const char* GetInfoName() { return m_infoName; }
|
||||
void SetUrl(const char* url);
|
||||
const char* GetOutputFilename() { return m_outputFilename; }
|
||||
void SetOutputFilename(const char* v);
|
||||
void SetOutputFilename(const char* outputFilename) { m_outputFilename = outputFilename; }
|
||||
time_t GetLastUpdateTime() { return m_lastUpdateTime; }
|
||||
void SetLastUpdateTimeNow() { m_lastUpdateTime = ::time(NULL); }
|
||||
bool GetConfirmedLength() { return m_confirmedLength; }
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
|
||||
|
||||
#include "nzbget.h"
|
||||
#include "NString.h"
|
||||
#include "QueueScript.h"
|
||||
#include "NzbScript.h"
|
||||
#include "Options.h"
|
||||
@@ -35,14 +36,14 @@ static const char* QUEUE_EVENT_NAMES[] = { "FILE_DOWNLOADED", "URL_COMPLETED", "
|
||||
class QueueScriptController : public Thread, public NzbScriptController
|
||||
{
|
||||
private:
|
||||
char* m_nzbName;
|
||||
char* m_nzbFilename;
|
||||
char* m_url;
|
||||
char* m_category;
|
||||
char* m_destDir;
|
||||
CString m_nzbName;
|
||||
CString m_nzbFilename;
|
||||
CString m_url;
|
||||
CString m_category;
|
||||
CString m_destDir;
|
||||
int m_id;
|
||||
int m_priority;
|
||||
char* m_dupeKey;
|
||||
CString m_dupeKey;
|
||||
EDupeMode m_dupeMode;
|
||||
int m_dupeScore;
|
||||
NzbParameterList m_parameters;
|
||||
@@ -60,34 +61,23 @@ protected:
|
||||
virtual void AddMessage(Message::EKind kind, const char* text);
|
||||
|
||||
public:
|
||||
virtual ~QueueScriptController();
|
||||
virtual void Run();
|
||||
static void StartScript(NzbInfo* nzbInfo, ScriptConfig::Script* script, QueueScriptCoordinator::EEvent event);
|
||||
};
|
||||
|
||||
|
||||
QueueScriptController::~QueueScriptController()
|
||||
{
|
||||
free(m_nzbName);
|
||||
free(m_nzbFilename);
|
||||
free(m_url);
|
||||
free(m_category);
|
||||
free(m_destDir);
|
||||
free(m_dupeKey);
|
||||
}
|
||||
|
||||
void QueueScriptController::StartScript(NzbInfo* nzbInfo, ScriptConfig::Script* script, QueueScriptCoordinator::EEvent event)
|
||||
{
|
||||
QueueScriptController* scriptController = new QueueScriptController();
|
||||
|
||||
scriptController->m_nzbName = strdup(nzbInfo->GetName());
|
||||
scriptController->m_nzbFilename = strdup(nzbInfo->GetFilename());
|
||||
scriptController->m_url = strdup(nzbInfo->GetUrl());
|
||||
scriptController->m_category = strdup(nzbInfo->GetCategory());
|
||||
scriptController->m_destDir = strdup(nzbInfo->GetDestDir());
|
||||
scriptController->m_nzbName = nzbInfo->GetName();
|
||||
scriptController->m_nzbFilename = nzbInfo->GetFilename();
|
||||
scriptController->m_url = nzbInfo->GetUrl();
|
||||
scriptController->m_category = nzbInfo->GetCategory();
|
||||
scriptController->m_destDir = nzbInfo->GetDestDir();
|
||||
scriptController->m_id = nzbInfo->GetId();
|
||||
scriptController->m_priority = nzbInfo->GetPriority();
|
||||
scriptController->m_dupeKey = strdup(nzbInfo->GetDupeKey());
|
||||
scriptController->m_dupeKey = nzbInfo->GetDupeKey();
|
||||
scriptController->m_dupeMode = nzbInfo->GetDupeMode();
|
||||
scriptController->m_dupeScore = nzbInfo->GetDupeScore();
|
||||
scriptController->m_parameters.CopyFrom(nzbInfo->GetParameters());
|
||||
@@ -114,7 +104,7 @@ void QueueScriptController::Run()
|
||||
NzbInfo* nzbInfo = downloadQueue->GetQueue()->Find(m_id);
|
||||
if (nzbInfo)
|
||||
{
|
||||
PrintMessage(Message::mkWarning, "Cancelling download and deleting %s", m_nzbName);
|
||||
PrintMessage(Message::mkWarning, "Cancelling download and deleting %s", *m_nzbName);
|
||||
nzbInfo->SetDeleteStatus(NzbInfo::dsBad);
|
||||
downloadQueue->EditEntry(m_id, DownloadQueue::eaGroupDelete, 0, NULL);
|
||||
}
|
||||
@@ -212,7 +202,7 @@ void QueueScriptController::AddMessage(Message::EKind kind, const char* text)
|
||||
if (nzbInfo)
|
||||
{
|
||||
SetLogPrefix(NULL);
|
||||
PrintMessage(Message::mkWarning, "Marking %s as bad", m_nzbName);
|
||||
PrintMessage(Message::mkWarning, "Marking %s as bad", *m_nzbName);
|
||||
SetLogPrefix(m_script->GetDisplayName());
|
||||
nzbInfo->SetMarkStatus(NzbInfo::ksBad);
|
||||
}
|
||||
|
||||
@@ -29,11 +29,6 @@
|
||||
#include "Log.h"
|
||||
#include "Util.h"
|
||||
|
||||
SchedulerScriptController::~SchedulerScriptController()
|
||||
{
|
||||
free(m_script);
|
||||
}
|
||||
|
||||
void SchedulerScriptController::StartScript(const char* param, bool externalProcess, int taskId)
|
||||
{
|
||||
char** argv = NULL;
|
||||
@@ -46,7 +41,7 @@ void SchedulerScriptController::StartScript(const char* param, bool externalProc
|
||||
SchedulerScriptController* scriptController = new SchedulerScriptController();
|
||||
|
||||
scriptController->m_externalProcess = externalProcess;
|
||||
scriptController->m_script = strdup(param);
|
||||
scriptController->m_script = param;
|
||||
scriptController->m_taskId = taskId;
|
||||
|
||||
if (externalProcess)
|
||||
|
||||
@@ -26,12 +26,13 @@
|
||||
#ifndef SCHEDULERSCRIPT_H
|
||||
#define SCHEDULERSCRIPT_H
|
||||
|
||||
#include "NString.h"
|
||||
#include "NzbScript.h"
|
||||
|
||||
class SchedulerScriptController : public Thread, public NzbScriptController
|
||||
{
|
||||
private:
|
||||
char* m_script;
|
||||
CString m_script;
|
||||
bool m_externalProcess;
|
||||
int m_taskId;
|
||||
|
||||
@@ -42,7 +43,6 @@ protected:
|
||||
virtual void ExecuteScript(ScriptConfig::Script* script);
|
||||
|
||||
public:
|
||||
virtual ~SchedulerScriptController();
|
||||
virtual void Run();
|
||||
static void StartScript(const char* param, bool externalProcess, int taskId);
|
||||
};
|
||||
|
||||
@@ -44,13 +44,12 @@ ScriptConfig* g_ScriptConfig = NULL;
|
||||
ScriptConfig::ConfigTemplate::ConfigTemplate(Script* script, const char* templ)
|
||||
{
|
||||
m_script = script;
|
||||
m_template = strdup(templ ? templ : "");
|
||||
m_template = templ ? templ : "";
|
||||
}
|
||||
|
||||
ScriptConfig::ConfigTemplate::~ConfigTemplate()
|
||||
{
|
||||
delete m_script;
|
||||
free(m_template);
|
||||
}
|
||||
|
||||
ScriptConfig::ConfigTemplates::~ConfigTemplates()
|
||||
@@ -64,35 +63,14 @@ ScriptConfig::ConfigTemplates::~ConfigTemplates()
|
||||
|
||||
ScriptConfig::Script::Script(const char* name, const char* location)
|
||||
{
|
||||
m_name = strdup(name);
|
||||
m_location = strdup(location);
|
||||
m_displayName = strdup(name);
|
||||
m_name = name;
|
||||
m_location = location;
|
||||
m_displayName = name;
|
||||
m_postScript = false;
|
||||
m_scanScript = false;
|
||||
m_queueScript = false;
|
||||
m_schedulerScript = false;
|
||||
m_feedScript = false;
|
||||
m_queueEvents = NULL;
|
||||
}
|
||||
|
||||
ScriptConfig::Script::~Script()
|
||||
{
|
||||
free(m_name);
|
||||
free(m_location);
|
||||
free(m_displayName);
|
||||
free(m_queueEvents);
|
||||
}
|
||||
|
||||
void ScriptConfig::Script::SetDisplayName(const char* displayName)
|
||||
{
|
||||
free(m_displayName);
|
||||
m_displayName = strdup(displayName);
|
||||
}
|
||||
|
||||
void ScriptConfig::Script::SetQueueEvents(const char* queueEvents)
|
||||
{
|
||||
free(m_queueEvents);
|
||||
m_queueEvents = queueEvents ? strdup(queueEvents) : NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#ifndef SCRIPTCONFIG_H
|
||||
#define SCRIPTCONFIG_H
|
||||
|
||||
#include "NString.h"
|
||||
#include "Options.h"
|
||||
|
||||
class ScriptConfig
|
||||
@@ -34,22 +35,21 @@ public:
|
||||
class Script
|
||||
{
|
||||
private:
|
||||
char* m_name;
|
||||
char* m_location;
|
||||
char* m_displayName;
|
||||
CString m_name;
|
||||
CString m_location;
|
||||
CString m_displayName;
|
||||
bool m_postScript;
|
||||
bool m_scanScript;
|
||||
bool m_queueScript;
|
||||
bool m_schedulerScript;
|
||||
bool m_feedScript;
|
||||
char* m_queueEvents;
|
||||
CString m_queueEvents;
|
||||
|
||||
public:
|
||||
Script(const char* name, const char* location);
|
||||
~Script();
|
||||
const char* GetName() { return m_name; }
|
||||
const char* GetLocation() { return m_location; }
|
||||
void SetDisplayName(const char* displayName);
|
||||
void SetDisplayName(const char* displayName) { m_displayName = displayName; }
|
||||
const char* GetDisplayName() { return m_displayName; }
|
||||
bool GetPostScript() { return m_postScript; }
|
||||
void SetPostScript(bool postScript) { m_postScript = postScript; }
|
||||
@@ -61,7 +61,7 @@ public:
|
||||
void SetSchedulerScript(bool schedulerScript) { m_schedulerScript = schedulerScript; }
|
||||
bool GetFeedScript() { return m_feedScript; }
|
||||
void SetFeedScript(bool feedScript) { m_feedScript = feedScript; }
|
||||
void SetQueueEvents(const char* queueEvents);
|
||||
void SetQueueEvents(const char* queueEvents) { m_queueEvents = queueEvents; }
|
||||
const char* GetQueueEvents() { return m_queueEvents; }
|
||||
};
|
||||
|
||||
@@ -79,7 +79,7 @@ public:
|
||||
{
|
||||
private:
|
||||
Script* m_script;
|
||||
char* m_template;
|
||||
CString m_template;
|
||||
|
||||
friend class Options;
|
||||
|
||||
|
||||
@@ -37,9 +37,9 @@
|
||||
FeedCoordinator::FeedCacheItem::FeedCacheItem(const char* url, int cacheTimeSec,const char* cacheId,
|
||||
time_t lastUsage, FeedItemInfos* feedItemInfos)
|
||||
{
|
||||
m_url = strdup(url);
|
||||
m_url = url;
|
||||
m_cacheTimeSec = cacheTimeSec;
|
||||
m_cacheId = strdup(cacheId);
|
||||
m_cacheId = cacheId;
|
||||
m_lastUsage = lastUsage;
|
||||
m_feedItemInfos = feedItemInfos;
|
||||
m_feedItemInfos->Retain();
|
||||
@@ -47,8 +47,6 @@ FeedCoordinator::FeedCacheItem::FeedCacheItem(const char* url, int cacheTimeSec,
|
||||
|
||||
FeedCoordinator::FeedCacheItem::~FeedCacheItem()
|
||||
{
|
||||
free(m_url);
|
||||
free(m_cacheId);
|
||||
m_feedItemInfos->Release();
|
||||
}
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#ifndef FEEDCOORDINATOR_H
|
||||
#define FEEDCOORDINATOR_H
|
||||
|
||||
#include "NString.h"
|
||||
#include "Log.h"
|
||||
#include "Thread.h"
|
||||
#include "WebDownloader.h"
|
||||
@@ -50,9 +51,9 @@ private:
|
||||
class FeedCacheItem
|
||||
{
|
||||
private:
|
||||
char* m_url;
|
||||
CString m_url;
|
||||
int m_cacheTimeSec;
|
||||
char* m_cacheId;
|
||||
CString m_cacheId;
|
||||
time_t m_lastUsage;
|
||||
FeedItemInfos* m_feedItemInfos;
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ FeedFile::FeedFile(const char* fileName)
|
||||
{
|
||||
debug("Creating FeedFile");
|
||||
|
||||
m_fileName = strdup(fileName);
|
||||
m_fileName = fileName;
|
||||
m_feedItemInfos = new FeedItemInfos();
|
||||
m_feedItemInfos->Retain();
|
||||
|
||||
@@ -50,7 +50,6 @@ FeedFile::~FeedFile()
|
||||
debug("Destroying FeedFile");
|
||||
|
||||
// Cleanup
|
||||
free(m_fileName);
|
||||
m_feedItemInfos->Release();
|
||||
|
||||
#ifndef WIN32
|
||||
@@ -61,7 +60,7 @@ FeedFile::~FeedFile()
|
||||
|
||||
void FeedFile::LogDebugInfo()
|
||||
{
|
||||
info(" FeedFile %s", m_fileName);
|
||||
info(" FeedFile %s", *m_fileName);
|
||||
}
|
||||
|
||||
void FeedFile::AddItem(FeedItemInfo* feedItemInfo)
|
||||
|
||||
@@ -26,13 +26,14 @@
|
||||
#ifndef FEEDFILE_H
|
||||
#define FEEDFILE_H
|
||||
|
||||
#include "NString.h"
|
||||
#include "FeedInfo.h"
|
||||
|
||||
class FeedFile
|
||||
{
|
||||
private:
|
||||
FeedItemInfos* m_feedItemInfos;
|
||||
char* m_fileName;
|
||||
CString m_fileName;
|
||||
|
||||
FeedFile(const char* fileName);
|
||||
void AddItem(FeedItemInfo* feedItemInfo);
|
||||
|
||||
+16
-48
@@ -32,8 +32,6 @@
|
||||
|
||||
FeedFilter::Term::Term()
|
||||
{
|
||||
m_field = NULL;
|
||||
m_param = NULL;
|
||||
m_float = false;
|
||||
m_intParam = 0;
|
||||
m_fFloatParam = 0.0;
|
||||
@@ -43,8 +41,6 @@ FeedFilter::Term::Term()
|
||||
|
||||
FeedFilter::Term::~Term()
|
||||
{
|
||||
free(m_field);
|
||||
free(m_param);
|
||||
delete m_regEx;
|
||||
}
|
||||
|
||||
@@ -176,7 +172,7 @@ bool FeedFilter::Term::MatchText(const char* strValue)
|
||||
|
||||
int patlen = strlen(m_param) + 2 + 1;
|
||||
char* pattern = (char*)malloc(patlen);
|
||||
snprintf(pattern, patlen, format, m_param);
|
||||
snprintf(pattern, patlen, format, *m_param);
|
||||
pattern[patlen-1] = '\0';
|
||||
|
||||
WildMask mask(pattern, m_refValues != NULL);
|
||||
@@ -311,8 +307,8 @@ bool FeedFilter::Term::Compile(char* token)
|
||||
return false;
|
||||
}
|
||||
|
||||
m_field = field ? strdup(field) : NULL;
|
||||
m_param = strdup(token);
|
||||
m_field = field;
|
||||
m_param = token;
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -559,17 +555,12 @@ FeedFilter::Rule::Rule()
|
||||
{
|
||||
m_command = frAccept;
|
||||
m_isValid = false;
|
||||
m_category = NULL;
|
||||
m_priority = 0;
|
||||
m_addPriority = 0;
|
||||
m_pause = false;
|
||||
m_dupeKey = NULL;
|
||||
m_addDupeKey = NULL;
|
||||
m_dupeScore = 0;
|
||||
m_addDupeScore = 0;
|
||||
m_dupeMode = dmScore;
|
||||
m_rageId = NULL;
|
||||
m_series = NULL;
|
||||
m_hasCategory = false;
|
||||
m_hasPriority = false;
|
||||
m_hasAddPriority = false;
|
||||
@@ -584,22 +575,10 @@ FeedFilter::Rule::Rule()
|
||||
m_hasPatCategory = false;
|
||||
m_hasPatDupeKey = false;
|
||||
m_hasPatAddDupeKey = false;
|
||||
m_patCategory = NULL;
|
||||
m_patDupeKey = NULL;
|
||||
m_patAddDupeKey = NULL;
|
||||
}
|
||||
|
||||
FeedFilter::Rule::~Rule()
|
||||
{
|
||||
free(m_category);
|
||||
free(m_dupeKey);
|
||||
free(m_addDupeKey);
|
||||
free(m_rageId);
|
||||
free(m_series);
|
||||
free(m_patCategory);
|
||||
free(m_patDupeKey);
|
||||
free(m_patAddDupeKey);
|
||||
|
||||
for (TermList::iterator it = m_terms.begin(); it != m_terms.end(); it++)
|
||||
{
|
||||
delete *it;
|
||||
@@ -649,18 +628,15 @@ void FeedFilter::Rule::Compile(char* rule)
|
||||
|
||||
if (m_isValid && m_hasPatCategory)
|
||||
{
|
||||
m_patCategory = m_category;
|
||||
m_category = NULL;
|
||||
m_patCategory.Bind(m_category.Unbind());
|
||||
}
|
||||
if (m_isValid && m_hasPatDupeKey)
|
||||
{
|
||||
m_patDupeKey = m_dupeKey;
|
||||
m_dupeKey = NULL;
|
||||
m_patDupeKey.Bind(m_dupeKey.Unbind());
|
||||
}
|
||||
if (m_isValid && m_hasPatAddDupeKey)
|
||||
{
|
||||
m_patAddDupeKey = m_addDupeKey;
|
||||
m_addDupeKey = NULL;
|
||||
m_patAddDupeKey.Bind(m_addDupeKey.Unbind());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -734,8 +710,7 @@ char* FeedFilter::Rule::CompileOptions(char* rule)
|
||||
if (!strcasecmp(option, "category") || !strcasecmp(option, "cat") || !strcasecmp(option, "c"))
|
||||
{
|
||||
m_hasCategory = true;
|
||||
free(m_category);
|
||||
m_category = strdup(value);
|
||||
m_category = value;
|
||||
m_hasPatCategory = strstr(value, "${");
|
||||
}
|
||||
else if (!strcasecmp(option, "pause") || !strcasecmp(option, "p"))
|
||||
@@ -791,15 +766,13 @@ char* FeedFilter::Rule::CompileOptions(char* rule)
|
||||
else if (!strcasecmp(option, "dupekey") || !strcasecmp(option, "dk") || !strcasecmp(option, "k"))
|
||||
{
|
||||
m_hasDupeKey = true;
|
||||
free(m_dupeKey);
|
||||
m_dupeKey = strdup(value);
|
||||
m_dupeKey = value;
|
||||
m_hasPatDupeKey = strstr(value, "${");
|
||||
}
|
||||
else if (!strcasecmp(option, "dupekey+") || !strcasecmp(option, "dk+") || !strcasecmp(option, "k+"))
|
||||
{
|
||||
m_hasAddDupeKey = true;
|
||||
free(m_addDupeKey);
|
||||
m_addDupeKey = strdup(value);
|
||||
m_addDupeKey = value;
|
||||
m_hasPatAddDupeKey = strstr(value, "${");
|
||||
}
|
||||
else if (!strcasecmp(option, "dupemode") || !strcasecmp(option, "dm") || !strcasecmp(option, "m"))
|
||||
@@ -826,14 +799,12 @@ char* FeedFilter::Rule::CompileOptions(char* rule)
|
||||
else if (!strcasecmp(option, "rageid"))
|
||||
{
|
||||
m_hasRageId = true;
|
||||
free(m_rageId);
|
||||
m_rageId = strdup(value);
|
||||
m_rageId = value;
|
||||
}
|
||||
else if (!strcasecmp(option, "series"))
|
||||
{
|
||||
m_hasSeries = true;
|
||||
free(m_series);
|
||||
m_series = strdup(value);
|
||||
m_series = value;
|
||||
}
|
||||
|
||||
// for compatibility with older version we support old commands too
|
||||
@@ -850,8 +821,7 @@ char* FeedFilter::Rule::CompileOptions(char* rule)
|
||||
else
|
||||
{
|
||||
m_hasCategory = true;
|
||||
free(m_category);
|
||||
m_category = strdup(option);
|
||||
m_category = option;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -964,12 +934,9 @@ bool FeedFilter::Rule::MatchExpression(FeedItemInfo* feedItemInfo)
|
||||
return match;
|
||||
}
|
||||
|
||||
void FeedFilter::Rule::ExpandRefValues(FeedItemInfo* feedItemInfo, char** destStr, char* patStr)
|
||||
void FeedFilter::Rule::ExpandRefValues(FeedItemInfo* feedItemInfo, CString* destStr, char* patStr)
|
||||
{
|
||||
free(*destStr);
|
||||
|
||||
*destStr = strdup(patStr);
|
||||
char* curvalue = *destStr;
|
||||
char* curvalue = strdup(patStr);
|
||||
|
||||
int attempts = 0;
|
||||
while (char* dollar = strstr(curvalue, "${"))
|
||||
@@ -1005,8 +972,9 @@ void FeedFilter::Rule::ExpandRefValues(FeedItemInfo* feedItemInfo, char** destSt
|
||||
strcpy(newvalue + (dollar - curvalue) + newlen, end + 1);
|
||||
free(curvalue);
|
||||
curvalue = newvalue;
|
||||
*destStr = curvalue;
|
||||
}
|
||||
|
||||
destStr->Bind(curvalue);
|
||||
}
|
||||
|
||||
const char* FeedFilter::Rule::GetRefValue(FeedItemInfo* feedItemInfo, const char* varName)
|
||||
|
||||
+12
-11
@@ -26,6 +26,7 @@
|
||||
#ifndef FEEDFILTER_H
|
||||
#define FEEDFILTER_H
|
||||
|
||||
#include "NString.h"
|
||||
#include "DownloadInfo.h"
|
||||
#include "FeedInfo.h"
|
||||
#include "Util.h"
|
||||
@@ -53,9 +54,9 @@ private:
|
||||
{
|
||||
private:
|
||||
bool m_positive;
|
||||
char* m_field;
|
||||
CString m_field;
|
||||
ETermCommand m_command;
|
||||
char* m_param;
|
||||
CString m_param;
|
||||
int64 m_intParam;
|
||||
double m_fFloatParam;
|
||||
bool m_float;
|
||||
@@ -99,17 +100,17 @@ private:
|
||||
private:
|
||||
bool m_isValid;
|
||||
ERuleCommand m_command;
|
||||
char* m_category;
|
||||
CString m_category;
|
||||
int m_priority;
|
||||
int m_addPriority;
|
||||
bool m_pause;
|
||||
int m_dupeScore;
|
||||
int m_addDupeScore;
|
||||
char* m_dupeKey;
|
||||
char* m_addDupeKey;
|
||||
CString m_dupeKey;
|
||||
CString m_addDupeKey;
|
||||
EDupeMode m_dupeMode;
|
||||
char* m_series;
|
||||
char* m_rageId;
|
||||
CString m_series;
|
||||
CString m_rageId;
|
||||
bool m_hasCategory;
|
||||
bool m_hasPriority;
|
||||
bool m_hasAddPriority;
|
||||
@@ -124,9 +125,9 @@ private:
|
||||
bool m_hasPatAddDupeKey;
|
||||
bool m_hasSeries;
|
||||
bool m_hasRageId;
|
||||
char* m_patCategory;
|
||||
char* m_patDupeKey;
|
||||
char* m_patAddDupeKey;
|
||||
CString m_patCategory;
|
||||
CString m_patDupeKey;
|
||||
CString m_patAddDupeKey;
|
||||
TermList m_terms;
|
||||
RefValues m_refValues;
|
||||
|
||||
@@ -164,7 +165,7 @@ private:
|
||||
bool HasRageId() { return m_hasRageId; }
|
||||
bool HasSeries() { return m_hasSeries; }
|
||||
bool Match(FeedItemInfo* feedItemInfo);
|
||||
void ExpandRefValues(FeedItemInfo* feedItemInfo, char** destStr, char* patStr);
|
||||
void ExpandRefValues(FeedItemInfo* feedItemInfo, CString* destStr, char* patStr);
|
||||
const char* GetRefValue(FeedItemInfo* feedItemInfo, const char* varName);
|
||||
};
|
||||
|
||||
|
||||
+20
-122
@@ -31,51 +31,28 @@ FeedInfo::FeedInfo(int id, const char* name, const char* url, bool backlog, int
|
||||
const char* filter, bool pauseNzb, const char* category, int priority, const char* feedScript)
|
||||
{
|
||||
m_id = id;
|
||||
m_name = strdup(name ? name : "");
|
||||
m_url = strdup(url ? url : "");
|
||||
m_filter = strdup(filter ? filter : "");
|
||||
m_name = name ? name : "";
|
||||
m_url = url ? url : "";
|
||||
m_filter = filter ? filter : "";
|
||||
m_backlog = backlog;
|
||||
m_filterHash = Util::HashBJ96(m_filter, strlen(m_filter), 0);
|
||||
m_category = strdup(category ? category : "");
|
||||
m_category = category ? category : "";
|
||||
m_interval = interval;
|
||||
m_feedScript = strdup(feedScript ? feedScript : "");
|
||||
m_feedScript = feedScript ? feedScript : "";
|
||||
m_pauseNzb = pauseNzb;
|
||||
m_priority = priority;
|
||||
m_lastUpdate = 0;
|
||||
m_preview = false;
|
||||
m_status = fsUndefined;
|
||||
m_outputFilename = NULL;
|
||||
m_fetch = false;
|
||||
m_force = false;
|
||||
}
|
||||
|
||||
FeedInfo::~FeedInfo()
|
||||
{
|
||||
free(m_name);
|
||||
free(m_url);
|
||||
free(m_filter);
|
||||
free(m_category);
|
||||
free(m_outputFilename);
|
||||
free(m_feedScript);
|
||||
}
|
||||
|
||||
void FeedInfo::SetOutputFilename(const char* outputFilename)
|
||||
{
|
||||
free(m_outputFilename);
|
||||
m_outputFilename = strdup(outputFilename);
|
||||
}
|
||||
|
||||
|
||||
FeedItemInfo::Attr::Attr(const char* name, const char* value)
|
||||
{
|
||||
m_name = strdup(name ? name : "");
|
||||
m_value = strdup(value ? value : "");
|
||||
}
|
||||
|
||||
FeedItemInfo::Attr::~Attr()
|
||||
{
|
||||
free(m_name);
|
||||
free(m_value);
|
||||
m_name = name ? name : "";
|
||||
m_value = value ? value : "";
|
||||
}
|
||||
|
||||
|
||||
@@ -110,87 +87,34 @@ FeedItemInfo::Attr* FeedItemInfo::Attributes::Find(const char* name)
|
||||
FeedItemInfo::FeedItemInfo()
|
||||
{
|
||||
m_feedFilterHelper = NULL;
|
||||
m_title = NULL;
|
||||
m_filename = NULL;
|
||||
m_url = NULL;
|
||||
m_category = strdup("");
|
||||
m_category = "";
|
||||
m_size = 0;
|
||||
m_time = 0;
|
||||
m_imdbId = 0;
|
||||
m_rageId = 0;
|
||||
m_description = strdup("");
|
||||
m_season = NULL;
|
||||
m_episode = NULL;
|
||||
m_description = "";
|
||||
m_seasonNum = 0;
|
||||
m_episodeNum = 0;
|
||||
m_seasonEpisodeParsed = false;
|
||||
m_addCategory = strdup("");
|
||||
m_addCategory = "";
|
||||
m_pauseNzb = false;
|
||||
m_priority = 0;
|
||||
m_status = isUnknown;
|
||||
m_matchStatus = msIgnored;
|
||||
m_matchRule = 0;
|
||||
m_dupeKey = NULL;
|
||||
m_dupeScore = 0;
|
||||
m_dupeMode = dmScore;
|
||||
m_dupeStatus = NULL;
|
||||
}
|
||||
|
||||
FeedItemInfo::~FeedItemInfo()
|
||||
{
|
||||
free(m_title);
|
||||
free(m_filename);
|
||||
free(m_url);
|
||||
free(m_category);
|
||||
free(m_description);
|
||||
free(m_season);
|
||||
free(m_episode);
|
||||
free(m_addCategory);
|
||||
free(m_dupeKey);
|
||||
free(m_dupeStatus);
|
||||
}
|
||||
|
||||
void FeedItemInfo::SetTitle(const char* title)
|
||||
{
|
||||
free(m_title);
|
||||
m_title = title ? strdup(title) : NULL;
|
||||
}
|
||||
|
||||
void FeedItemInfo::SetFilename(const char* filename)
|
||||
{
|
||||
free(m_filename);
|
||||
m_filename = filename ? strdup(filename) : NULL;
|
||||
}
|
||||
|
||||
void FeedItemInfo::SetUrl(const char* url)
|
||||
{
|
||||
free(m_url);
|
||||
m_url = url ? strdup(url) : NULL;
|
||||
}
|
||||
|
||||
void FeedItemInfo::SetCategory(const char* category)
|
||||
{
|
||||
free(m_category);
|
||||
m_category = strdup(category ? category: "");
|
||||
}
|
||||
|
||||
void FeedItemInfo::SetDescription(const char* description)
|
||||
{
|
||||
free(m_description);
|
||||
m_description = strdup(description ? description: "");
|
||||
}
|
||||
|
||||
void FeedItemInfo::SetSeason(const char* season)
|
||||
{
|
||||
free(m_season);
|
||||
m_season = season ? strdup(season) : NULL;
|
||||
m_season = season;
|
||||
m_seasonNum = season ? ParsePrefixedInt(season) : 0;
|
||||
}
|
||||
|
||||
void FeedItemInfo::SetEpisode(const char* episode)
|
||||
{
|
||||
free(m_episode);
|
||||
m_episode = episode ? strdup(episode) : NULL;
|
||||
m_episode = episode;
|
||||
m_episodeNum = episode ? ParsePrefixedInt(episode) : 0;
|
||||
}
|
||||
|
||||
@@ -204,31 +128,18 @@ int FeedItemInfo::ParsePrefixedInt(const char *value)
|
||||
return atoi(val);
|
||||
}
|
||||
|
||||
void FeedItemInfo::SetAddCategory(const char* addCategory)
|
||||
{
|
||||
free(m_addCategory);
|
||||
m_addCategory = strdup(addCategory ? addCategory : "");
|
||||
}
|
||||
|
||||
void FeedItemInfo::SetDupeKey(const char* dupeKey)
|
||||
{
|
||||
free(m_dupeKey);
|
||||
m_dupeKey = strdup(dupeKey ? dupeKey : "");
|
||||
}
|
||||
|
||||
void FeedItemInfo::AppendDupeKey(const char* extraDupeKey)
|
||||
{
|
||||
if (!m_dupeKey || *m_dupeKey == '\0' || !extraDupeKey || *extraDupeKey == '\0')
|
||||
if (m_dupeKey.Empty() || Util::EmptyStr(extraDupeKey))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int len = (m_dupeKey ? strlen(m_dupeKey) : 0) + 1 + strlen(extraDupeKey) + 1;
|
||||
int len = m_dupeKey.Length() + 1 + strlen(extraDupeKey) + 1;
|
||||
char* newKey = (char*)malloc(len);
|
||||
snprintf(newKey, len, "%s-%s", m_dupeKey, extraDupeKey);
|
||||
snprintf(newKey, len, "%s-%s", *m_dupeKey, extraDupeKey);
|
||||
newKey[len - 1] = '\0';
|
||||
|
||||
free(m_dupeKey);
|
||||
m_dupeKey = newKey;
|
||||
}
|
||||
|
||||
@@ -236,29 +147,21 @@ void FeedItemInfo::BuildDupeKey(const char* rageId, const char* series)
|
||||
{
|
||||
int rageIdVal = rageId && *rageId ? atoi(rageId) : m_rageId;
|
||||
|
||||
free(m_dupeKey);
|
||||
|
||||
if (m_imdbId != 0)
|
||||
{
|
||||
m_dupeKey = (char*)malloc(20);
|
||||
snprintf(m_dupeKey, 20, "imdb=%i", m_imdbId);
|
||||
m_dupeKey.Format("imdb=%i", m_imdbId);
|
||||
}
|
||||
else if (series && *series && GetSeasonNum() != 0 && GetEpisodeNum() != 0)
|
||||
{
|
||||
int len = strlen(series) + 50;
|
||||
m_dupeKey = (char*)malloc(len);
|
||||
snprintf(m_dupeKey, len, "series=%s-%s-%s", series, m_season, m_episode);
|
||||
m_dupeKey[len-1] = '\0';
|
||||
m_dupeKey.Format("series=%s-%s-%s", series, *m_season, *m_episode);
|
||||
}
|
||||
else if (rageIdVal != 0 && GetSeasonNum() != 0 && GetEpisodeNum() != 0)
|
||||
{
|
||||
m_dupeKey = (char*)malloc(100);
|
||||
snprintf(m_dupeKey, 100, "rageid=%i-%s-%s", rageIdVal, m_season, m_episode);
|
||||
m_dupeKey[100-1] = '\0';
|
||||
m_dupeKey.Format("rageid=%i-%s-%s", rageIdVal, *m_season, *m_episode);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_dupeKey = strdup("");
|
||||
m_dupeKey = "";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -329,16 +232,11 @@ const char* FeedItemInfo::GetDupeStatus()
|
||||
|
||||
FeedHistoryInfo::FeedHistoryInfo(const char* url, FeedHistoryInfo::EStatus status, time_t lastSeen)
|
||||
{
|
||||
m_url = url ? strdup(url) : NULL;
|
||||
m_url = url;
|
||||
m_status = status;
|
||||
m_lastSeen = lastSeen;
|
||||
}
|
||||
|
||||
FeedHistoryInfo::~FeedHistoryInfo()
|
||||
{
|
||||
free(m_url);
|
||||
}
|
||||
|
||||
|
||||
FeedHistory::~FeedHistory()
|
||||
{
|
||||
|
||||
+28
-32
@@ -26,10 +26,10 @@
|
||||
#ifndef FEEDINFO_H
|
||||
#define FEEDINFO_H
|
||||
|
||||
#include "NString.h"
|
||||
#include "Util.h"
|
||||
#include "DownloadInfo.h"
|
||||
|
||||
|
||||
class FeedInfo
|
||||
{
|
||||
public:
|
||||
@@ -43,19 +43,19 @@ public:
|
||||
|
||||
private:
|
||||
int m_id;
|
||||
char* m_name;
|
||||
char* m_url;
|
||||
CString m_name;
|
||||
CString m_url;
|
||||
int m_interval;
|
||||
char* m_filter;
|
||||
CString m_filter;
|
||||
uint32 m_filterHash;
|
||||
bool m_pauseNzb;
|
||||
char* m_category;
|
||||
char* m_feedScript;
|
||||
CString m_category;
|
||||
CString m_feedScript;
|
||||
int m_priority;
|
||||
time_t m_lastUpdate;
|
||||
bool m_preview;
|
||||
EStatus m_status;
|
||||
char* m_outputFilename;
|
||||
CString m_outputFilename;
|
||||
bool m_fetch;
|
||||
bool m_force;
|
||||
bool m_backlog;
|
||||
@@ -64,7 +64,6 @@ public:
|
||||
FeedInfo(int id, const char* name, const char* url, bool backlog, int interval,
|
||||
const char* filter, bool pauseNzb, const char* category, int priority,
|
||||
const char* feedScript);
|
||||
~FeedInfo();
|
||||
int GetId() { return m_id; }
|
||||
const char* GetName() { return m_name; }
|
||||
const char* GetUrl() { return m_url; }
|
||||
@@ -82,7 +81,7 @@ public:
|
||||
EStatus GetStatus() { return m_status; }
|
||||
void SetStatus(EStatus Status) { m_status = Status; }
|
||||
const char* GetOutputFilename() { return m_outputFilename; }
|
||||
void SetOutputFilename(const char* outputFilename);
|
||||
void SetOutputFilename(const char* outputFilename) { m_outputFilename = outputFilename; }
|
||||
bool GetFetch() { return m_fetch; }
|
||||
void SetFetch(bool fetch) { m_fetch = fetch; }
|
||||
bool GetForce() { return m_force; }
|
||||
@@ -121,11 +120,10 @@ public:
|
||||
class Attr
|
||||
{
|
||||
private:
|
||||
char* m_name;
|
||||
char* m_value;
|
||||
CString m_name;
|
||||
CString m_value;
|
||||
public:
|
||||
Attr(const char* name, const char* value);
|
||||
~Attr();
|
||||
const char* GetName() { return m_name; }
|
||||
const char* GetValue() { return m_value; }
|
||||
};
|
||||
@@ -141,30 +139,30 @@ public:
|
||||
};
|
||||
|
||||
private:
|
||||
char* m_title;
|
||||
char* m_filename;
|
||||
char* m_url;
|
||||
CString m_title;
|
||||
CString m_filename;
|
||||
CString m_url;
|
||||
time_t m_time;
|
||||
int64 m_size;
|
||||
char* m_category;
|
||||
CString m_category;
|
||||
int m_imdbId;
|
||||
int m_rageId;
|
||||
char* m_description;
|
||||
char* m_season;
|
||||
char* m_episode;
|
||||
CString m_description;
|
||||
CString m_season;
|
||||
CString m_episode;
|
||||
int m_seasonNum;
|
||||
int m_episodeNum;
|
||||
bool m_seasonEpisodeParsed;
|
||||
char* m_addCategory;
|
||||
CString m_addCategory;
|
||||
bool m_pauseNzb;
|
||||
int m_priority;
|
||||
EStatus m_status;
|
||||
EMatchStatus m_matchStatus;
|
||||
int m_matchRule;
|
||||
char* m_dupeKey;
|
||||
CString m_dupeKey;
|
||||
int m_dupeScore;
|
||||
EDupeMode m_dupeMode;
|
||||
char* m_dupeStatus;
|
||||
CString m_dupeStatus;
|
||||
FeedFilterHelper* m_feedFilterHelper;
|
||||
Attributes m_attributes;
|
||||
|
||||
@@ -173,24 +171,23 @@ private:
|
||||
|
||||
public:
|
||||
FeedItemInfo();
|
||||
~FeedItemInfo();
|
||||
void SetFeedFilterHelper(FeedFilterHelper* feedFilterHelper) { m_feedFilterHelper = feedFilterHelper; }
|
||||
const char* GetTitle() { return m_title; }
|
||||
void SetTitle(const char* title);
|
||||
void SetTitle(const char* title) { m_title = title; }
|
||||
const char* GetFilename() { return m_filename; }
|
||||
void SetFilename(const char* filename);
|
||||
void SetFilename(const char* filename) { m_filename = filename; }
|
||||
const char* GetUrl() { return m_url; }
|
||||
void SetUrl(const char* url);
|
||||
void SetUrl(const char* url) { m_url = url; }
|
||||
int64 GetSize() { return m_size; }
|
||||
void SetSize(int64 size) { m_size = size; }
|
||||
const char* GetCategory() { return m_category; }
|
||||
void SetCategory(const char* category);
|
||||
void SetCategory(const char* category) { m_category = category; }
|
||||
int GetImdbId() { return m_imdbId; }
|
||||
void SetImdbId(int imdbId) { m_imdbId = imdbId; }
|
||||
int GetRageId() { return m_rageId; }
|
||||
void SetRageId(int rageId) { m_rageId = rageId; }
|
||||
const char* GetDescription() { return m_description; }
|
||||
void SetDescription(const char* description);
|
||||
void SetDescription(const char* description) { m_description = description ? description: ""; }
|
||||
const char* GetSeason() { return m_season; }
|
||||
void SetSeason(const char* season);
|
||||
const char* GetEpisode() { return m_episode; }
|
||||
@@ -198,7 +195,7 @@ public:
|
||||
int GetSeasonNum();
|
||||
int GetEpisodeNum();
|
||||
const char* GetAddCategory() { return m_addCategory; }
|
||||
void SetAddCategory(const char* addCategory);
|
||||
void SetAddCategory(const char* addCategory) { m_addCategory = addCategory ? addCategory : ""; }
|
||||
bool GetPauseNzb() { return m_pauseNzb; }
|
||||
void SetPauseNzb(bool pauseNzb) { m_pauseNzb = pauseNzb; }
|
||||
int GetPriority() { return m_priority; }
|
||||
@@ -212,7 +209,7 @@ public:
|
||||
int GetMatchRule() { return m_matchRule; }
|
||||
void SetMatchRule(int matchRule) { m_matchRule = matchRule; }
|
||||
const char* GetDupeKey() { return m_dupeKey; }
|
||||
void SetDupeKey(const char* dupeKey);
|
||||
void SetDupeKey(const char* dupeKey) { m_dupeKey = dupeKey ? dupeKey : ""; }
|
||||
void AppendDupeKey(const char* extraDupeKey);
|
||||
void BuildDupeKey(const char* rageId, const char* series);
|
||||
int GetDupeScore() { return m_dupeScore; }
|
||||
@@ -249,13 +246,12 @@ public:
|
||||
};
|
||||
|
||||
private:
|
||||
char* m_url;
|
||||
CString m_url;
|
||||
EStatus m_status;
|
||||
time_t m_lastSeen;
|
||||
|
||||
public:
|
||||
FeedHistoryInfo(const char* url, EStatus status, time_t lastSeen);
|
||||
~FeedHistoryInfo();
|
||||
const char* GetUrl() { return m_url; }
|
||||
EStatus GetStatus() { return m_status; }
|
||||
void SetStatus(EStatus Status) { m_status = Status; }
|
||||
|
||||
@@ -123,7 +123,6 @@ NCursesFrontend::NCursesFrontend()
|
||||
m_updateNextTime = false;
|
||||
m_lastEditEntry = -1;
|
||||
m_lastPausePars = false;
|
||||
m_hint = NULL;
|
||||
|
||||
// Setup curses
|
||||
#ifdef WIN32
|
||||
@@ -643,7 +642,7 @@ void NCursesFrontend::PrintKeyInputBar()
|
||||
int queueSize = CalcQueueSize();
|
||||
int inputBarRow = m_screenHeight - 1;
|
||||
|
||||
if (m_hint)
|
||||
if (!m_hint.Empty())
|
||||
{
|
||||
time_t time = ::time(NULL);
|
||||
if (time - m_startHint < 5)
|
||||
@@ -705,11 +704,9 @@ void NCursesFrontend::PrintKeyInputBar()
|
||||
|
||||
void NCursesFrontend::SetHint(const char* hint)
|
||||
{
|
||||
free(m_hint);
|
||||
m_hint = NULL;
|
||||
if (hint)
|
||||
m_hint = hint;
|
||||
if (!m_hint.Empty())
|
||||
{
|
||||
m_hint = strdup(hint);
|
||||
m_startHint = time(NULL);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
|
||||
#ifndef DISABLE_CURSES
|
||||
|
||||
#include "NString.h"
|
||||
#include "Frontend.h"
|
||||
#include "Log.h"
|
||||
#include "DownloadInfo.h"
|
||||
@@ -59,7 +60,7 @@ private:
|
||||
int m_lastEditEntry;
|
||||
bool m_lastPausePars;
|
||||
int m_queueScrollOffset;
|
||||
char* m_hint;
|
||||
CString m_hint;
|
||||
time_t m_startHint;
|
||||
int m_colWidthFiles;
|
||||
int m_colWidthTotal;
|
||||
|
||||
@@ -67,7 +67,6 @@ static char short_options[] = "c:hno:psvAB:DCE:G:K:LPR:STUQOVW:";
|
||||
CommandLineParser::CommandLineParser(int argc, const char* argv[])
|
||||
{
|
||||
m_noConfig = false;
|
||||
m_configFilename = NULL;
|
||||
m_errors = false;
|
||||
m_printVersion = false;
|
||||
m_printUsage = false;
|
||||
@@ -76,29 +75,20 @@ CommandLineParser::CommandLineParser(int argc, const char* argv[])
|
||||
m_editQueueIdList = NULL;
|
||||
m_editQueueIdCount = 0;
|
||||
m_editQueueOffset = 0;
|
||||
m_editQueueText = NULL;
|
||||
m_argFilename = NULL;
|
||||
m_lastArg = NULL;
|
||||
m_addCategory = NULL;
|
||||
m_addPriority = 0;
|
||||
m_addNzbFilename = NULL;
|
||||
m_addPaused = false;
|
||||
m_serverMode = false;
|
||||
m_daemonMode = false;
|
||||
m_remoteClientMode = false;
|
||||
m_printOptions = false;
|
||||
m_addTop = false;
|
||||
m_addDupeKey = NULL;
|
||||
m_addDupeScore = 0;
|
||||
m_addDupeMode = 0;
|
||||
m_logLines = 0;
|
||||
m_writeLogKind = 0;
|
||||
m_testBacktrace = false;
|
||||
m_webGet = false;
|
||||
m_webGetFilename = NULL;
|
||||
m_sigVerify = false;
|
||||
m_pubKeyFilename = NULL;
|
||||
m_sigFilename = NULL;
|
||||
m_matchMode = mmId;
|
||||
m_pauseDownload = false;
|
||||
|
||||
@@ -118,17 +108,7 @@ CommandLineParser::CommandLineParser(int argc, const char* argv[])
|
||||
|
||||
CommandLineParser::~CommandLineParser()
|
||||
{
|
||||
free(m_configFilename);
|
||||
free(m_argFilename);
|
||||
free(m_addCategory);
|
||||
free(m_editQueueText);
|
||||
free(m_lastArg);
|
||||
free(m_editQueueIdList);
|
||||
free(m_addNzbFilename);
|
||||
free(m_addDupeKey);
|
||||
free(m_webGetFilename);
|
||||
free(m_pubKeyFilename);
|
||||
free(m_sigFilename);
|
||||
|
||||
for (NameList::iterator it = m_editQueueNameList.begin(); it != m_editQueueNameList.end(); it++)
|
||||
{
|
||||
@@ -172,7 +152,7 @@ void CommandLineParser::InitCommandLine(int argc, const char* const_argv[])
|
||||
switch (c)
|
||||
{
|
||||
case 'c':
|
||||
m_configFilename = strdup(optarg);
|
||||
m_configFilename = optarg;
|
||||
break;
|
||||
case 'n':
|
||||
m_configFilename = NULL;
|
||||
@@ -234,8 +214,7 @@ void CommandLineParser::InitCommandLine(int argc, const char* const_argv[])
|
||||
ReportError("Could not parse value of option 'A'");
|
||||
return;
|
||||
}
|
||||
free(m_addCategory);
|
||||
m_addCategory = strdup(argv[optind-1]);
|
||||
m_addCategory = argv[optind-1];
|
||||
}
|
||||
else if (optarg && !strcasecmp(optarg, "N"))
|
||||
{
|
||||
@@ -245,8 +224,7 @@ void CommandLineParser::InitCommandLine(int argc, const char* const_argv[])
|
||||
ReportError("Could not parse value of option 'A'");
|
||||
return;
|
||||
}
|
||||
free(m_addNzbFilename);
|
||||
m_addNzbFilename = strdup(argv[optind-1]);
|
||||
m_addNzbFilename = argv[optind-1];
|
||||
}
|
||||
else if (optarg && !strcasecmp(optarg, "DK"))
|
||||
{
|
||||
@@ -256,8 +234,7 @@ void CommandLineParser::InitCommandLine(int argc, const char* const_argv[])
|
||||
ReportError("Could not parse value of option 'A'");
|
||||
return;
|
||||
}
|
||||
free(m_addDupeKey);
|
||||
m_addDupeKey = strdup(argv[optind-1]);
|
||||
m_addDupeKey = argv[optind-1];
|
||||
}
|
||||
else if (optarg && !strcasecmp(optarg, "DS"))
|
||||
{
|
||||
@@ -352,7 +329,7 @@ void CommandLineParser::InitCommandLine(int argc, const char* const_argv[])
|
||||
ReportError("Could not parse value of option 'L'");
|
||||
return;
|
||||
}
|
||||
m_editQueueText = strdup(argv[optind-1]);
|
||||
m_editQueueText = argv[optind-1];
|
||||
}
|
||||
break;
|
||||
case 'P':
|
||||
@@ -405,7 +382,7 @@ void CommandLineParser::InitCommandLine(int argc, const char* const_argv[])
|
||||
return;
|
||||
}
|
||||
optarg = argv[optind-1];
|
||||
m_webGetFilename = strdup(optarg);
|
||||
m_webGetFilename = optarg;
|
||||
}
|
||||
else if (!strcasecmp(optarg, "verify"))
|
||||
{
|
||||
@@ -417,7 +394,7 @@ void CommandLineParser::InitCommandLine(int argc, const char* const_argv[])
|
||||
return;
|
||||
}
|
||||
optarg = argv[optind-1];
|
||||
m_pubKeyFilename = strdup(optarg);
|
||||
m_pubKeyFilename = optarg;
|
||||
|
||||
optind++;
|
||||
if (optind > argc)
|
||||
@@ -426,7 +403,7 @@ void CommandLineParser::InitCommandLine(int argc, const char* const_argv[])
|
||||
return;
|
||||
}
|
||||
optarg = argv[optind-1];
|
||||
m_sigFilename = strdup(optarg);
|
||||
m_sigFilename = optarg;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -521,7 +498,7 @@ void CommandLineParser::InitCommandLine(int argc, const char* const_argv[])
|
||||
ReportError("Could not parse value of option 'E'");
|
||||
return;
|
||||
}
|
||||
m_editQueueText = strdup(argv[optind-1]);
|
||||
m_editQueueText = argv[optind-1];
|
||||
|
||||
if (!strchr(m_editQueueText, '='))
|
||||
{
|
||||
@@ -594,7 +571,7 @@ void CommandLineParser::InitCommandLine(int argc, const char* const_argv[])
|
||||
ReportError("Could not parse value of option 'E'");
|
||||
return;
|
||||
}
|
||||
m_editQueueText = strdup(argv[optind-1]);
|
||||
m_editQueueText = argv[optind-1];
|
||||
}
|
||||
else if (!strcasecmp(optarg, "N"))
|
||||
{
|
||||
@@ -611,7 +588,7 @@ void CommandLineParser::InitCommandLine(int argc, const char* const_argv[])
|
||||
ReportError("Could not parse value of option 'E'");
|
||||
return;
|
||||
}
|
||||
m_editQueueText = strdup(argv[optind-1]);
|
||||
m_editQueueText = argv[optind-1];
|
||||
}
|
||||
else if (!strcasecmp(optarg, "M"))
|
||||
{
|
||||
@@ -632,7 +609,7 @@ void CommandLineParser::InitCommandLine(int argc, const char* const_argv[])
|
||||
ReportError("Could not parse value of option 'E'");
|
||||
return;
|
||||
}
|
||||
m_editQueueText = strdup(argv[optind-1]);
|
||||
m_editQueueText = argv[optind-1];
|
||||
}
|
||||
else if (!strcasecmp(optarg, "O"))
|
||||
{
|
||||
@@ -649,7 +626,7 @@ void CommandLineParser::InitCommandLine(int argc, const char* const_argv[])
|
||||
ReportError("Could not parse value of option 'E'");
|
||||
return;
|
||||
}
|
||||
m_editQueueText = strdup(argv[optind-1]);
|
||||
m_editQueueText = argv[optind-1];
|
||||
|
||||
if (!strchr(m_editQueueText, '='))
|
||||
{
|
||||
@@ -672,7 +649,7 @@ void CommandLineParser::InitCommandLine(int argc, const char* const_argv[])
|
||||
ReportError("Could not parse value of option 'E'");
|
||||
return;
|
||||
}
|
||||
m_editQueueText = strdup(argv[optind-1]);
|
||||
m_editQueueText = argv[optind-1];
|
||||
|
||||
if (atoi(m_editQueueText) == 0 && strcmp("0", m_editQueueText))
|
||||
{
|
||||
@@ -727,8 +704,7 @@ void CommandLineParser::InitCommandLine(int argc, const char* const_argv[])
|
||||
break;
|
||||
case 'K':
|
||||
// switch "K" is provided for compatibility with v. 0.8.0 and can be removed in future versions
|
||||
free(m_addCategory);
|
||||
m_addCategory = strdup(optarg);
|
||||
m_addCategory = optarg;
|
||||
break;
|
||||
case 'S':
|
||||
optind++;
|
||||
@@ -907,18 +883,18 @@ void CommandLineParser::InitFileArg(int argc, const char* argv[])
|
||||
}
|
||||
else
|
||||
{
|
||||
m_lastArg = strdup(argv[optind]);
|
||||
m_lastArg = argv[optind];
|
||||
|
||||
// Check if the file-name is a relative path or an absolute path
|
||||
// If the path starts with '/' its an absolute, else relative
|
||||
const char* fileName = argv[optind];
|
||||
|
||||
#ifdef WIN32
|
||||
m_argFilename = strdup(fileName);
|
||||
m_argFilename = fileName;
|
||||
#else
|
||||
if (fileName[0] == '/' || !strncasecmp(fileName, "http://", 6) || !strncasecmp(fileName, "https://", 7))
|
||||
{
|
||||
m_argFilename = strdup(fileName);
|
||||
m_argFilename = fileName;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -927,7 +903,7 @@ void CommandLineParser::InitFileArg(int argc, const char* argv[])
|
||||
getcwd(fileNameWithPath, 1024);
|
||||
strcat(fileNameWithPath, "/");
|
||||
strcat(fileNameWithPath, fileName);
|
||||
m_argFilename = strdup(fileNameWithPath);
|
||||
m_argFilename = fileNameWithPath;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#ifndef COMMANDLINEPARSER_H
|
||||
#define COMMANDLINEPARSER_H
|
||||
|
||||
#include "NString.h"
|
||||
|
||||
class CommandLineParser
|
||||
{
|
||||
@@ -68,7 +69,7 @@ public:
|
||||
|
||||
private:
|
||||
bool m_noConfig;
|
||||
char* m_configFilename;
|
||||
CString m_configFilename;
|
||||
|
||||
// Parsed command-line parameters
|
||||
bool m_errors;
|
||||
@@ -85,16 +86,16 @@ private:
|
||||
int m_editQueueIdCount;
|
||||
NameList m_editQueueNameList;
|
||||
EMatchMode m_matchMode;
|
||||
char* m_editQueueText;
|
||||
char* m_argFilename;
|
||||
char* m_addCategory;
|
||||
CString m_editQueueText;
|
||||
CString m_argFilename;
|
||||
CString m_addCategory;
|
||||
int m_addPriority;
|
||||
bool m_addPaused;
|
||||
char* m_addNzbFilename;
|
||||
char* m_lastArg;
|
||||
CString m_addNzbFilename;
|
||||
CString m_lastArg;
|
||||
bool m_printOptions;
|
||||
bool m_addTop;
|
||||
char* m_addDupeKey;
|
||||
CString m_addDupeKey;
|
||||
int m_addDupeScore;
|
||||
int m_addDupeMode;
|
||||
int m_setRate;
|
||||
@@ -102,17 +103,16 @@ private:
|
||||
int m_writeLogKind;
|
||||
bool m_testBacktrace;
|
||||
bool m_webGet;
|
||||
char* m_webGetFilename;
|
||||
CString m_webGetFilename;
|
||||
bool m_sigVerify;
|
||||
char* m_pubKeyFilename;
|
||||
char* m_sigFilename;
|
||||
CString m_pubKeyFilename;
|
||||
CString m_sigFilename;
|
||||
bool m_pauseDownload;
|
||||
|
||||
void InitCommandLine(int argc, const char* argv[]);
|
||||
void InitFileArg(int argc, const char* argv[]);
|
||||
void ParseFileIdList(int argc, const char* argv[], int optind);
|
||||
void ParseFileNameList(int argc, const char* argv[], int optind);
|
||||
bool ParseTime(const char* time, int* hours, int* minutes);
|
||||
void ReportError(const char* errMessage);
|
||||
|
||||
public:
|
||||
|
||||
+52
-154
@@ -183,33 +183,17 @@ Options::OptEntry::OptEntry()
|
||||
|
||||
Options::OptEntry::OptEntry(const char* name, const char* value)
|
||||
{
|
||||
m_name = strdup(name);
|
||||
m_value = strdup(value);
|
||||
m_defValue = NULL;
|
||||
m_name = name;
|
||||
m_value = value;
|
||||
m_lineNo = 0;
|
||||
}
|
||||
|
||||
Options::OptEntry::~OptEntry()
|
||||
{
|
||||
free(m_name);
|
||||
free(m_value);
|
||||
free(m_defValue);
|
||||
}
|
||||
|
||||
void Options::OptEntry::SetName(const char* name)
|
||||
{
|
||||
free(m_name);
|
||||
m_name = strdup(name);
|
||||
}
|
||||
|
||||
void Options::OptEntry::SetValue(const char* value)
|
||||
{
|
||||
free(m_value);
|
||||
m_value = strdup(value);
|
||||
|
||||
m_value = value;
|
||||
if (!m_defValue)
|
||||
{
|
||||
m_defValue = strdup(value);
|
||||
m_defValue = value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -266,23 +250,12 @@ Options::OptEntry* Options::OptEntries::FindOption(const char* name)
|
||||
|
||||
Options::Category::Category(const char* name, const char* destDir, bool unpack, const char* postScript)
|
||||
{
|
||||
m_name = strdup(name);
|
||||
m_destDir = destDir ? strdup(destDir) : NULL;
|
||||
m_name = name;
|
||||
m_destDir = destDir;
|
||||
m_unpack = unpack;
|
||||
m_postScript = postScript ? strdup(postScript) : NULL;
|
||||
m_postScript = postScript;
|
||||
}
|
||||
|
||||
Options::Category::~Category()
|
||||
{
|
||||
free(m_name);
|
||||
free(m_destDir);
|
||||
free(m_postScript);
|
||||
|
||||
for (NameList::iterator it = m_aliases.begin(); it != m_aliases.end(); it++)
|
||||
{
|
||||
free(*it);
|
||||
}
|
||||
}
|
||||
|
||||
Options::Categories::~Categories()
|
||||
{
|
||||
@@ -354,17 +327,6 @@ void Options::Init(const char* exeName, const char* configFilename, bool noConfi
|
||||
m_fatalError = false;
|
||||
|
||||
// initialize options with default values
|
||||
m_configFilename = NULL;
|
||||
m_appDir = NULL;
|
||||
m_destDir = NULL;
|
||||
m_interDir = NULL;
|
||||
m_tempDir = NULL;
|
||||
m_queueDir = NULL;
|
||||
m_nzbDir = NULL;
|
||||
m_webDir = NULL;
|
||||
m_configTemplate = NULL;
|
||||
m_scriptDir = NULL;
|
||||
m_requiredDir = NULL;
|
||||
m_infoTarget = mtScreen;
|
||||
m_warningTarget = mtScreen;
|
||||
m_errorTarget = mtScreen;
|
||||
@@ -390,27 +352,14 @@ void Options::Init(const char* exeName, const char* configFilename, bool noConfi
|
||||
m_retries = 0;
|
||||
m_retryInterval = 0;
|
||||
m_controlPort = 0;
|
||||
m_controlIp = NULL;
|
||||
m_controlUsername = NULL;
|
||||
m_controlPassword = NULL;
|
||||
m_restrictedUsername = NULL;
|
||||
m_restrictedPassword = NULL;
|
||||
m_addUsername = NULL;
|
||||
m_addPassword = NULL;
|
||||
m_secureControl = false;
|
||||
m_securePort = 0;
|
||||
m_secureCert = NULL;
|
||||
m_secureKey = NULL;
|
||||
m_authorizedIp = NULL;
|
||||
m_lockFile = NULL;
|
||||
m_daemonUsername = NULL;
|
||||
m_outputMode = omLoggable;
|
||||
m_reloadQueue = false;
|
||||
m_urlConnections = 0;
|
||||
m_logBufferSize = 0;
|
||||
m_writeLog = wlAppend;
|
||||
m_rotateLog = 0;
|
||||
m_logFile = NULL;
|
||||
m_parCheck = pcManual;
|
||||
m_parRepair = false;
|
||||
m_parScan = psLimited;
|
||||
@@ -419,11 +368,6 @@ void Options::Init(const char* exeName, const char* configFilename, bool noConfi
|
||||
m_parBuffer = 0;
|
||||
m_parThreads = 0;
|
||||
m_healthCheck = hcNone;
|
||||
m_scriptOrder = NULL;
|
||||
m_postScript = NULL;
|
||||
m_scanScript = NULL;
|
||||
m_queueScript = NULL;
|
||||
m_feedScript = NULL;
|
||||
m_umask = 0;
|
||||
m_updateInterval = 0;
|
||||
m_cursesNzbName = false;
|
||||
@@ -448,12 +392,7 @@ void Options::Init(const char* exeName, const char* configFilename, bool noConfi
|
||||
m_resumeTime = 0;
|
||||
m_unpack = false;
|
||||
m_unpackCleanupDisk = false;
|
||||
m_unrarCmd = NULL;
|
||||
m_sevenZipCmd = NULL;
|
||||
m_unpackPassFile = NULL;
|
||||
m_unpackPauseQueue = false;
|
||||
m_extCleanupDisk = NULL;
|
||||
m_parIgnoreExt = NULL;
|
||||
m_feedHistory = 0;
|
||||
m_urlForce = false;
|
||||
m_timeCorrection = 0;
|
||||
@@ -464,7 +403,7 @@ void Options::Init(const char* exeName, const char* configFilename, bool noConfi
|
||||
|
||||
m_noDiskAccess = noDiskAccess;
|
||||
|
||||
m_configFilename = configFilename ? strdup(configFilename) : NULL;
|
||||
m_configFilename = configFilename;
|
||||
SetOption(OPTION_CONFIGFILE, "");
|
||||
|
||||
char filename[MAX_PATH + 1];
|
||||
@@ -482,7 +421,7 @@ void Options::Init(const char* exeName, const char* configFilename, bool noConfi
|
||||
char* end = strrchr(filename, PATH_SEPARATOR);
|
||||
if (end) *end = '\0';
|
||||
SetOption(OPTION_APPDIR, filename);
|
||||
m_appDir = strdup(filename);
|
||||
m_appDir = filename;
|
||||
|
||||
SetOption(OPTION_VERSION, Util::VersionRevision());
|
||||
|
||||
@@ -528,40 +467,6 @@ void Options::Init(const char* exeName, const char* configFilename, bool noConfi
|
||||
Options::~Options()
|
||||
{
|
||||
g_Options = NULL;
|
||||
free(m_configFilename);
|
||||
free(m_appDir);
|
||||
free(m_destDir);
|
||||
free(m_interDir);
|
||||
free(m_tempDir);
|
||||
free(m_queueDir);
|
||||
free(m_nzbDir);
|
||||
free(m_webDir);
|
||||
free(m_configTemplate);
|
||||
free(m_scriptDir);
|
||||
free(m_requiredDir);
|
||||
free(m_controlIp);
|
||||
free(m_controlUsername);
|
||||
free(m_controlPassword);
|
||||
free(m_restrictedUsername);
|
||||
free(m_restrictedPassword);
|
||||
free(m_addUsername);
|
||||
free(m_addPassword);
|
||||
free(m_secureCert);
|
||||
free(m_secureKey);
|
||||
free(m_authorizedIp);
|
||||
free(m_logFile);
|
||||
free(m_lockFile);
|
||||
free(m_daemonUsername);
|
||||
free(m_scriptOrder);
|
||||
free(m_postScript);
|
||||
free(m_scanScript);
|
||||
free(m_queueScript);
|
||||
free(m_feedScript);
|
||||
free(m_unrarCmd);
|
||||
free(m_sevenZipCmd);
|
||||
free(m_unpackPassFile);
|
||||
free(m_extCleanupDisk);
|
||||
free(m_parIgnoreExt);
|
||||
}
|
||||
|
||||
void Options::Dump()
|
||||
@@ -736,7 +641,7 @@ void Options::InitOptFile()
|
||||
// search for config file in default locations
|
||||
#ifdef WIN32
|
||||
char filename[MAX_PATH + 20];
|
||||
snprintf(filename, sizeof(filename), "%s\\nzbget.conf", m_appDir);
|
||||
snprintf(filename, sizeof(filename), "%s\\nzbget.conf", *m_appDir);
|
||||
|
||||
if (!Util::FileExists(filename))
|
||||
{
|
||||
@@ -753,17 +658,17 @@ void Options::InitOptFile()
|
||||
|
||||
if (Util::FileExists(filename))
|
||||
{
|
||||
m_configFilename = strdup(filename);
|
||||
m_configFilename = filename;
|
||||
}
|
||||
#else
|
||||
// look in the exe-directory first
|
||||
char filename[1024];
|
||||
snprintf(filename, sizeof(filename), "%s/nzbget.conf", m_appDir);
|
||||
snprintf(filename, sizeof(filename), "%s/nzbget.conf", *m_appDir);
|
||||
filename[1024-1] = '\0';
|
||||
|
||||
if (Util::FileExists(filename))
|
||||
{
|
||||
m_configFilename = strdup(filename);
|
||||
m_configFilename = filename;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -779,7 +684,7 @@ void Options::InitOptFile()
|
||||
|
||||
if (Util::FileExists(filename))
|
||||
{
|
||||
m_configFilename = strdup(filename);
|
||||
m_configFilename = filename;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -803,15 +708,14 @@ void Options::InitOptFile()
|
||||
}
|
||||
#endif
|
||||
|
||||
free(m_configFilename);
|
||||
m_configFilename = strdup(filename);
|
||||
m_configFilename = filename;
|
||||
|
||||
SetOption(OPTION_CONFIGFILE, m_configFilename);
|
||||
LoadConfigFile();
|
||||
}
|
||||
}
|
||||
|
||||
void Options::CheckDir(char** dir, const char* optionName,
|
||||
void Options::CheckDir(CString* dir, const char* optionName,
|
||||
const char* parentDir, bool allowEmpty, bool create)
|
||||
{
|
||||
char* usedir = NULL;
|
||||
@@ -819,7 +723,7 @@ void Options::CheckDir(char** dir, const char* optionName,
|
||||
|
||||
if (m_noDiskAccess)
|
||||
{
|
||||
*dir = strdup(tempdir);
|
||||
*dir = tempdir;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -829,7 +733,7 @@ void Options::CheckDir(char** dir, const char* optionName,
|
||||
{
|
||||
ConfigError("Invalid value for option \"%s\": <empty>", optionName);
|
||||
}
|
||||
*dir = strdup("");
|
||||
*dir = "";
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -879,6 +783,7 @@ void Options::CheckDir(char** dir, const char* optionName,
|
||||
ConfigError("Invalid value for option \"%s\" (%s): %s", optionName, usedir, errBuf);
|
||||
}
|
||||
*dir = usedir;
|
||||
free(usedir);
|
||||
}
|
||||
|
||||
void Options::InitOptions()
|
||||
@@ -893,32 +798,32 @@ void Options::InitOptions()
|
||||
CheckDir(&m_scriptDir, OPTION_SCRIPTDIR, mainDir, true, false);
|
||||
CheckDir(&m_nzbDir, OPTION_NZBDIR, mainDir, false, true);
|
||||
|
||||
m_requiredDir = strdup(GetOption(OPTION_REQUIREDDIR));
|
||||
m_requiredDir = GetOption(OPTION_REQUIREDDIR);
|
||||
|
||||
m_configTemplate = strdup(GetOption(OPTION_CONFIGTEMPLATE));
|
||||
m_scriptOrder = strdup(GetOption(OPTION_SCRIPTORDER));
|
||||
m_postScript = strdup(GetOption(OPTION_POSTSCRIPT));
|
||||
m_scanScript = strdup(GetOption(OPTION_SCANSCRIPT));
|
||||
m_queueScript = strdup(GetOption(OPTION_QUEUESCRIPT));
|
||||
m_feedScript = strdup(GetOption(OPTION_FEEDSCRIPT));
|
||||
m_controlIp = strdup(GetOption(OPTION_CONTROLIP));
|
||||
m_controlUsername = strdup(GetOption(OPTION_CONTROLUSERNAME));
|
||||
m_controlPassword = strdup(GetOption(OPTION_CONTROLPASSWORD));
|
||||
m_restrictedUsername = strdup(GetOption(OPTION_RESTRICTEDUSERNAME));
|
||||
m_restrictedPassword = strdup(GetOption(OPTION_RESTRICTEDPASSWORD));
|
||||
m_addUsername = strdup(GetOption(OPTION_ADDUSERNAME));
|
||||
m_addPassword = strdup(GetOption(OPTION_ADDPASSWORD));
|
||||
m_secureCert = strdup(GetOption(OPTION_SECURECERT));
|
||||
m_secureKey = strdup(GetOption(OPTION_SECUREKEY));
|
||||
m_authorizedIp = strdup(GetOption(OPTION_AUTHORIZEDIP));
|
||||
m_lockFile = strdup(GetOption(OPTION_LOCKFILE));
|
||||
m_daemonUsername = strdup(GetOption(OPTION_DAEMONUSERNAME));
|
||||
m_logFile = strdup(GetOption(OPTION_LOGFILE));
|
||||
m_unrarCmd = strdup(GetOption(OPTION_UNRARCMD));
|
||||
m_sevenZipCmd = strdup(GetOption(OPTION_SEVENZIPCMD));
|
||||
m_unpackPassFile = strdup(GetOption(OPTION_UNPACKPASSFILE));
|
||||
m_extCleanupDisk = strdup(GetOption(OPTION_EXTCLEANUPDISK));
|
||||
m_parIgnoreExt = strdup(GetOption(OPTION_PARIGNOREEXT));
|
||||
m_configTemplate = GetOption(OPTION_CONFIGTEMPLATE);
|
||||
m_scriptOrder = GetOption(OPTION_SCRIPTORDER);
|
||||
m_postScript = GetOption(OPTION_POSTSCRIPT);
|
||||
m_scanScript = GetOption(OPTION_SCANSCRIPT);
|
||||
m_queueScript = GetOption(OPTION_QUEUESCRIPT);
|
||||
m_feedScript = GetOption(OPTION_FEEDSCRIPT);
|
||||
m_controlIp = GetOption(OPTION_CONTROLIP);
|
||||
m_controlUsername = GetOption(OPTION_CONTROLUSERNAME);
|
||||
m_controlPassword = GetOption(OPTION_CONTROLPASSWORD);
|
||||
m_restrictedUsername = GetOption(OPTION_RESTRICTEDUSERNAME);
|
||||
m_restrictedPassword = GetOption(OPTION_RESTRICTEDPASSWORD);
|
||||
m_addUsername = GetOption(OPTION_ADDUSERNAME);
|
||||
m_addPassword = GetOption(OPTION_ADDPASSWORD);
|
||||
m_secureCert = GetOption(OPTION_SECURECERT);
|
||||
m_secureKey = GetOption(OPTION_SECUREKEY);
|
||||
m_authorizedIp = GetOption(OPTION_AUTHORIZEDIP);
|
||||
m_lockFile = GetOption(OPTION_LOCKFILE);
|
||||
m_daemonUsername = GetOption(OPTION_DAEMONUSERNAME);
|
||||
m_logFile = GetOption(OPTION_LOGFILE);
|
||||
m_unrarCmd = GetOption(OPTION_UNRARCMD);
|
||||
m_sevenZipCmd = GetOption(OPTION_SEVENZIPCMD);
|
||||
m_unpackPassFile = GetOption(OPTION_UNPACKPASSFILE);
|
||||
m_extCleanupDisk = GetOption(OPTION_EXTCLEANUPDISK);
|
||||
m_parIgnoreExt = GetOption(OPTION_PARIGNOREEXT);
|
||||
|
||||
m_downloadRate = ParseIntValue(OPTION_DOWNLOADRATE, 10) * 1024;
|
||||
m_articleTimeout = ParseIntValue(OPTION_ARTICLETIMEOUT, 10);
|
||||
@@ -1324,7 +1229,7 @@ void Options::InitCategories()
|
||||
|
||||
if (completed)
|
||||
{
|
||||
char* destDir = NULL;
|
||||
CString destDir;
|
||||
if (ndestdir && ndestdir[0] != '\0')
|
||||
{
|
||||
CheckDir(&destDir, destdiroptname, m_destDir, false, false);
|
||||
@@ -1333,15 +1238,13 @@ void Options::InitCategories()
|
||||
Category* category = new Category(nname, destDir, unpack, npostscript);
|
||||
m_categories.push_back(category);
|
||||
|
||||
free(destDir);
|
||||
|
||||
// split Aliases into tokens and create items for each token
|
||||
if (naliases)
|
||||
{
|
||||
Tokenizer tok(naliases, ",;");
|
||||
while (const char* aliasName = tok.Next())
|
||||
{
|
||||
category->GetAliases()->push_back(strdup(aliasName));
|
||||
category->GetAliases()->push_back(aliasName);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1674,7 +1577,7 @@ void Options::LoadConfigFile()
|
||||
|
||||
if (!infile)
|
||||
{
|
||||
ConfigError("Could not open file %s", m_configFilename);
|
||||
ConfigError("Could not open file %s", *m_configFilename);
|
||||
m_fatalError = true;
|
||||
return;
|
||||
}
|
||||
@@ -2023,17 +1926,12 @@ void Options::CheckOptions()
|
||||
|
||||
// if option "ConfigTemplate" is not set, use "WebDir" as default location for template
|
||||
// (for compatibility with versions 9 and 10).
|
||||
if (Util::EmptyStr(m_configTemplate) && !m_noDiskAccess)
|
||||
if (m_configTemplate.Empty() && !m_noDiskAccess)
|
||||
{
|
||||
free(m_configTemplate);
|
||||
int len = strlen(m_webDir) + 15;
|
||||
m_configTemplate = (char*)malloc(len);
|
||||
snprintf(m_configTemplate, len, "%s%s", m_webDir, "nzbget.conf");
|
||||
m_configTemplate[len-1] = '\0';
|
||||
m_configTemplate.Format("%s%s", *m_webDir, "nzbget.conf");
|
||||
if (!Util::FileExists(m_configTemplate))
|
||||
{
|
||||
free(m_configTemplate);
|
||||
m_configTemplate = strdup("");
|
||||
m_configTemplate = "";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2059,9 +1957,9 @@ void Options::CheckOptions()
|
||||
m_parBuffer = 400;
|
||||
}
|
||||
|
||||
if (!Util::EmptyStr(m_unpackPassFile) && !Util::FileExists(m_unpackPassFile))
|
||||
if (!m_unpackPassFile.Empty() && !Util::FileExists(m_unpackPassFile))
|
||||
{
|
||||
ConfigError("Invalid value for option \"UnpackPassFile\": %s. File not found", m_unpackPassFile);
|
||||
ConfigError("Invalid value for option \"UnpackPassFile\": %s. File not found", *m_unpackPassFile);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+44
-45
@@ -27,6 +27,7 @@
|
||||
#ifndef OPTIONS_H
|
||||
#define OPTIONS_H
|
||||
|
||||
#include "NString.h"
|
||||
#include "Thread.h"
|
||||
#include "Util.h"
|
||||
|
||||
@@ -92,9 +93,9 @@ public:
|
||||
class OptEntry
|
||||
{
|
||||
private:
|
||||
char* m_name;
|
||||
char* m_value;
|
||||
char* m_defValue;
|
||||
CString m_name;
|
||||
CString m_value;
|
||||
CString m_defValue;
|
||||
int m_lineNo;
|
||||
|
||||
void SetLineNo(int lineNo) { m_lineNo = lineNo; }
|
||||
@@ -104,8 +105,7 @@ public:
|
||||
public:
|
||||
OptEntry();
|
||||
OptEntry(const char* name, const char* value);
|
||||
~OptEntry();
|
||||
void SetName(const char* name);
|
||||
void SetName(const char* name) { m_name = name; }
|
||||
const char* GetName() { return m_name; }
|
||||
void SetValue(const char* value);
|
||||
const char* GetValue() { return m_value; }
|
||||
@@ -123,21 +123,20 @@ public:
|
||||
OptEntry* FindOption(const char* name);
|
||||
};
|
||||
|
||||
typedef std::vector<char*> NameList;
|
||||
typedef std::vector<CString> NameList;
|
||||
typedef std::vector<const char*> CmdOptList;
|
||||
|
||||
class Category
|
||||
{
|
||||
private:
|
||||
char* m_name;
|
||||
char* m_destDir;
|
||||
CString m_name;
|
||||
CString m_destDir;
|
||||
bool m_unpack;
|
||||
char* m_postScript;
|
||||
CString m_postScript;
|
||||
NameList m_aliases;
|
||||
|
||||
public:
|
||||
Category(const char* name, const char* destDir, bool unpack, const char* postScript);
|
||||
~Category();
|
||||
const char* GetName() { return m_name; }
|
||||
const char* GetDestDir() { return m_destDir; }
|
||||
bool GetUnpack() { return m_unpack; }
|
||||
@@ -180,17 +179,17 @@ private:
|
||||
// Options
|
||||
bool m_configErrors;
|
||||
int m_configLine;
|
||||
char* m_appDir;
|
||||
char* m_configFilename;
|
||||
char* m_destDir;
|
||||
char* m_interDir;
|
||||
char* m_tempDir;
|
||||
char* m_queueDir;
|
||||
char* m_nzbDir;
|
||||
char* m_webDir;
|
||||
char* m_configTemplate;
|
||||
char* m_scriptDir;
|
||||
char* m_requiredDir;
|
||||
CString m_appDir;
|
||||
CString m_configFilename;
|
||||
CString m_destDir;
|
||||
CString m_interDir;
|
||||
CString m_tempDir;
|
||||
CString m_queueDir;
|
||||
CString m_nzbDir;
|
||||
CString m_webDir;
|
||||
CString m_configTemplate;
|
||||
CString m_scriptDir;
|
||||
CString m_requiredDir;
|
||||
EMessageTarget m_infoTarget;
|
||||
EMessageTarget m_warningTarget;
|
||||
EMessageTarget m_errorTarget;
|
||||
@@ -209,28 +208,28 @@ private:
|
||||
bool m_saveQueue;
|
||||
bool m_flushQueue;
|
||||
bool m_dupeCheck;
|
||||
char* m_controlIp;
|
||||
char* m_controlUsername;
|
||||
char* m_controlPassword;
|
||||
char* m_restrictedUsername;
|
||||
char* m_restrictedPassword;
|
||||
char* m_addUsername;
|
||||
char* m_addPassword;
|
||||
CString m_controlIp;
|
||||
CString m_controlUsername;
|
||||
CString m_controlPassword;
|
||||
CString m_restrictedUsername;
|
||||
CString m_restrictedPassword;
|
||||
CString m_addUsername;
|
||||
CString m_addPassword;
|
||||
int m_controlPort;
|
||||
bool m_secureControl;
|
||||
int m_securePort;
|
||||
char* m_secureCert;
|
||||
char* m_secureKey;
|
||||
char* m_authorizedIp;
|
||||
char* m_lockFile;
|
||||
char* m_daemonUsername;
|
||||
CString m_secureCert;
|
||||
CString m_secureKey;
|
||||
CString m_authorizedIp;
|
||||
CString m_lockFile;
|
||||
CString m_daemonUsername;
|
||||
EOutputMode m_outputMode;
|
||||
bool m_reloadQueue;
|
||||
int m_urlConnections;
|
||||
int m_logBufferSize;
|
||||
EWriteLog m_writeLog;
|
||||
int m_rotateLog;
|
||||
char* m_logFile;
|
||||
CString m_logFile;
|
||||
EParCheck m_parCheck;
|
||||
bool m_parRepair;
|
||||
EParScan m_parScan;
|
||||
@@ -239,11 +238,11 @@ private:
|
||||
int m_parBuffer;
|
||||
int m_parThreads;
|
||||
EHealthCheck m_healthCheck;
|
||||
char* m_postScript;
|
||||
char* m_scriptOrder;
|
||||
char* m_scanScript;
|
||||
char* m_queueScript;
|
||||
char* m_feedScript;
|
||||
CString m_postScript;
|
||||
CString m_scriptOrder;
|
||||
CString m_scanScript;
|
||||
CString m_queueScript;
|
||||
CString m_feedScript;
|
||||
bool m_noConfig;
|
||||
int m_umask;
|
||||
int m_updateInterval;
|
||||
@@ -268,12 +267,12 @@ private:
|
||||
bool m_accurateRate;
|
||||
bool m_unpack;
|
||||
bool m_unpackCleanupDisk;
|
||||
char* m_unrarCmd;
|
||||
char* m_sevenZipCmd;
|
||||
char* m_unpackPassFile;
|
||||
CString m_unrarCmd;
|
||||
CString m_sevenZipCmd;
|
||||
CString m_unpackPassFile;
|
||||
bool m_unpackPauseQueue;
|
||||
char* m_extCleanupDisk;
|
||||
char* m_parIgnoreExt;
|
||||
CString m_extCleanupDisk;
|
||||
CString m_parIgnoreExt;
|
||||
int m_feedHistory;
|
||||
bool m_urlForce;
|
||||
int m_timeCorrection;
|
||||
@@ -313,7 +312,7 @@ private:
|
||||
bool SetOptionString(const char* option);
|
||||
bool ValidateOptionName(const char* optname, const char* optvalue);
|
||||
void LoadConfigFile();
|
||||
void CheckDir(char** dir, const char* optionName, const char* parentDir,
|
||||
void CheckDir(CString* dir, const char* optionName, const char* parentDir,
|
||||
bool allowEmpty, bool create);
|
||||
bool ParseTime(const char* time, int* hours, int* minutes);
|
||||
bool ParseWeekDays(const char* weekDays, int* weekDaysBits);
|
||||
|
||||
@@ -40,15 +40,10 @@ Scheduler::Task::Task(int id, int hours, int minutes, int weekDaysBits, ECommand
|
||||
m_minutes = minutes;
|
||||
m_weekDaysBits = weekDaysBits;
|
||||
m_command = command;
|
||||
m_param = param ? strdup(param) : NULL;
|
||||
m_param = param;
|
||||
m_lastExecuted = 0;
|
||||
}
|
||||
|
||||
Scheduler::Task::~Task()
|
||||
{
|
||||
free(m_param);
|
||||
}
|
||||
|
||||
|
||||
Scheduler::Scheduler()
|
||||
{
|
||||
@@ -208,7 +203,7 @@ void Scheduler::ExecuteTask(Task* task)
|
||||
switch (task->m_command)
|
||||
{
|
||||
case scDownloadRate:
|
||||
if (!Util::EmptyStr(task->m_param))
|
||||
if (!task->m_param.Empty())
|
||||
{
|
||||
g_Options->SetDownloadRate(atoi(task->m_param) * 1024);
|
||||
m_downloadRateChanged = true;
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#ifndef SCHEDULER_H
|
||||
#define SCHEDULER_H
|
||||
|
||||
#include "NString.h"
|
||||
#include "Thread.h"
|
||||
#include "Service.h"
|
||||
|
||||
@@ -56,13 +57,12 @@ public:
|
||||
int m_minutes;
|
||||
int m_weekDaysBits;
|
||||
ECommand m_command;
|
||||
char* m_param;
|
||||
CString m_param;
|
||||
time_t m_lastExecuted;
|
||||
|
||||
public:
|
||||
Task(int id, int hours, int minutes, int weekDaysBits, ECommand command,
|
||||
const char* param);
|
||||
~Task();
|
||||
friend class Scheduler;
|
||||
};
|
||||
|
||||
|
||||
@@ -38,12 +38,9 @@ ArticleDownloader::ArticleDownloader()
|
||||
{
|
||||
debug("Creating ArticleDownloader");
|
||||
|
||||
m_infoName = NULL;
|
||||
m_connectionName[0] = '\0';
|
||||
m_connection = NULL;
|
||||
m_status = adUndefined;
|
||||
m_format = Decoder::efUnknown;
|
||||
m_articleFilename = NULL;
|
||||
m_downloadedSize = 0;
|
||||
m_articleWriter.SetOwner(this);
|
||||
SetLastUpdateTimeNow();
|
||||
@@ -52,14 +49,11 @@ ArticleDownloader::ArticleDownloader()
|
||||
ArticleDownloader::~ArticleDownloader()
|
||||
{
|
||||
debug("Destroying ArticleDownloader");
|
||||
|
||||
free(m_infoName);
|
||||
free(m_articleFilename);
|
||||
}
|
||||
|
||||
void ArticleDownloader::SetInfoName(const char* infoName)
|
||||
{
|
||||
m_infoName = strdup(infoName);
|
||||
m_infoName = infoName;
|
||||
m_articleWriter.SetInfoName(m_infoName);
|
||||
}
|
||||
|
||||
@@ -130,9 +124,8 @@ void ArticleDownloader::Run()
|
||||
|
||||
m_connection->SetSuppressErrors(false);
|
||||
|
||||
snprintf(m_connectionName, sizeof(m_connectionName), "%s (%s)",
|
||||
m_connectionName.Format("%s (%s)",
|
||||
m_connection->GetNewsServer()->GetName(), m_connection->GetHost());
|
||||
m_connectionName[sizeof(m_connectionName) - 1] = '\0';
|
||||
|
||||
// check server retention
|
||||
bool retentionFailure = m_connection->GetNewsServer()->GetRetention() > 0 &&
|
||||
@@ -140,7 +133,7 @@ void ArticleDownloader::Run()
|
||||
if (retentionFailure)
|
||||
{
|
||||
detail("Article %s @ %s failed: out of server retention (file age: %i, configured retention: %i)",
|
||||
m_infoName, m_connectionName,
|
||||
*m_infoName, *m_connectionName,
|
||||
(time(NULL) - m_fileInfo->GetTime()) / 86400,
|
||||
m_connection->GetNewsServer()->GetRetention());
|
||||
status = adFailed;
|
||||
@@ -149,7 +142,7 @@ void ArticleDownloader::Run()
|
||||
|
||||
if (m_connection && !IsStopped())
|
||||
{
|
||||
detail("Downloading %s @ %s", m_infoName, m_connectionName);
|
||||
detail("Downloading %s @ %s", *m_infoName, *m_connectionName);
|
||||
}
|
||||
|
||||
// test connection
|
||||
@@ -174,7 +167,7 @@ void ArticleDownloader::Run()
|
||||
|
||||
if (!connected && m_connection)
|
||||
{
|
||||
detail("Article %s @ %s failed: could not establish connection", m_infoName, m_connectionName);
|
||||
detail("Article %s @ %s failed: could not establish connection", *m_infoName, *m_connectionName);
|
||||
}
|
||||
|
||||
if (status == adConnectError)
|
||||
@@ -256,12 +249,12 @@ void ArticleDownloader::Run()
|
||||
{
|
||||
if (level < g_ServerPool->GetMaxNormLevel())
|
||||
{
|
||||
detail("Article %s @ all level %i servers failed, increasing level", m_infoName, level);
|
||||
detail("Article %s @ all level %i servers failed, increasing level", *m_infoName, level);
|
||||
level++;
|
||||
}
|
||||
else
|
||||
{
|
||||
detail("Article %s @ all servers failed", m_infoName);
|
||||
detail("Article %s @ all servers failed", *m_infoName);
|
||||
status = adFailed;
|
||||
break;
|
||||
}
|
||||
@@ -285,13 +278,13 @@ void ArticleDownloader::Run()
|
||||
|
||||
if (IsStopped())
|
||||
{
|
||||
detail("Download %s cancelled", m_infoName);
|
||||
detail("Download %s cancelled", *m_infoName);
|
||||
status = adRetry;
|
||||
}
|
||||
|
||||
if (status == adFailed)
|
||||
{
|
||||
detail("Download %s failed", m_infoName);
|
||||
detail("Download %s failed", *m_infoName);
|
||||
}
|
||||
|
||||
SetStatus(status);
|
||||
@@ -391,7 +384,7 @@ ArticleDownloader::EStatus ArticleDownloader::Download()
|
||||
{
|
||||
if (!IsStopped())
|
||||
{
|
||||
detail("Article %s @ %s failed: Unexpected end of article", m_infoName, m_connectionName);
|
||||
detail("Article %s @ %s failed: Unexpected end of article", *m_infoName, *m_connectionName);
|
||||
}
|
||||
status = adFailed;
|
||||
break;
|
||||
@@ -425,8 +418,8 @@ ArticleDownloader::EStatus ArticleDownloader::Download()
|
||||
if (strncmp(p, m_articleInfo->GetMessageId(), strlen(m_articleInfo->GetMessageId())))
|
||||
{
|
||||
if (char* e = strrchr(p, '\r')) *e = '\0'; // remove trailing CR-character
|
||||
detail("Article %s @ %s failed: Wrong message-id, expected %s, returned %s", m_infoName,
|
||||
m_connectionName, m_articleInfo->GetMessageId(), p);
|
||||
detail("Article %s @ %s failed: Wrong message-id, expected %s, returned %s", *m_infoName,
|
||||
*m_connectionName, m_articleInfo->GetMessageId(), p);
|
||||
status = adFailed;
|
||||
break;
|
||||
}
|
||||
@@ -456,7 +449,7 @@ ArticleDownloader::EStatus ArticleDownloader::Download()
|
||||
|
||||
if (!end && status == adRunning && !IsStopped())
|
||||
{
|
||||
detail("Article %s @ %s failed: article incomplete", m_infoName, m_connectionName);
|
||||
detail("Article %s @ %s failed: article incomplete", *m_infoName, *m_connectionName);
|
||||
status = adFailed;
|
||||
}
|
||||
|
||||
@@ -478,7 +471,7 @@ ArticleDownloader::EStatus ArticleDownloader::Download()
|
||||
|
||||
if (status == adFinished)
|
||||
{
|
||||
detail("Successfully downloaded %s", m_infoName);
|
||||
detail("Successfully downloaded %s", *m_infoName);
|
||||
}
|
||||
|
||||
return status;
|
||||
@@ -491,18 +484,18 @@ ArticleDownloader::EStatus ArticleDownloader::CheckResponse(const char* response
|
||||
if (!IsStopped())
|
||||
{
|
||||
detail("Article %s @ %s failed, %s: Connection closed by remote host",
|
||||
m_infoName, m_connectionName, comment);
|
||||
*m_infoName, *m_connectionName, comment);
|
||||
}
|
||||
return adConnectError;
|
||||
}
|
||||
else if (m_connection->GetAuthError() || !strncmp(response, "400", 3) || !strncmp(response, "499", 3))
|
||||
{
|
||||
detail("Article %s @ %s failed, %s: %s", m_infoName, m_connectionName, comment, response);
|
||||
detail("Article %s @ %s failed, %s: %s", *m_infoName, *m_connectionName, comment, response);
|
||||
return adConnectError;
|
||||
}
|
||||
else if (!strncmp(response, "41", 2) || !strncmp(response, "42", 2) || !strncmp(response, "43", 2))
|
||||
{
|
||||
detail("Article %s @ %s failed, %s: %s", m_infoName, m_connectionName, comment, response);
|
||||
detail("Article %s @ %s failed, %s: %s", *m_infoName, *m_connectionName, comment, response);
|
||||
return adNotFound;
|
||||
}
|
||||
else if (!strncmp(response, "2", 1))
|
||||
@@ -513,7 +506,7 @@ ArticleDownloader::EStatus ArticleDownloader::CheckResponse(const char* response
|
||||
else
|
||||
{
|
||||
// unknown error, no special handling
|
||||
detail("Article %s @ %s failed, %s: %s", m_infoName, m_connectionName, comment, response);
|
||||
detail("Article %s @ %s failed, %s: %s", *m_infoName, *m_connectionName, comment, response);
|
||||
return adFailed;
|
||||
}
|
||||
}
|
||||
@@ -540,7 +533,7 @@ bool ArticleDownloader::Write(char* line, int len)
|
||||
}
|
||||
else
|
||||
{
|
||||
detail("Decoding %s failed: unsupported encoding", m_infoName);
|
||||
detail("Decoding %s failed: unsupported encoding", *m_infoName);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -584,7 +577,7 @@ ArticleDownloader::EStatus ArticleDownloader::DecodeCheck()
|
||||
}
|
||||
else
|
||||
{
|
||||
detail("Decoding %s failed: no binary data or unsupported encoding format", m_infoName);
|
||||
detail("Decoding %s failed: no binary data or unsupported encoding format", *m_infoName);
|
||||
return adFailed;
|
||||
}
|
||||
|
||||
@@ -594,8 +587,7 @@ ArticleDownloader::EStatus ArticleDownloader::DecodeCheck()
|
||||
{
|
||||
if (decoder->GetArticleFilename())
|
||||
{
|
||||
free(m_articleFilename);
|
||||
m_articleFilename = strdup(decoder->GetArticleFilename());
|
||||
m_articleFilename = decoder->GetArticleFilename();
|
||||
}
|
||||
|
||||
if (m_format == Decoder::efYenc)
|
||||
@@ -608,27 +600,27 @@ ArticleDownloader::EStatus ArticleDownloader::DecodeCheck()
|
||||
}
|
||||
else if (status == Decoder::dsCrcError)
|
||||
{
|
||||
detail("Decoding %s failed: CRC-Error", m_infoName);
|
||||
detail("Decoding %s failed: CRC-Error", *m_infoName);
|
||||
return adCrcError;
|
||||
}
|
||||
else if (status == Decoder::dsArticleIncomplete)
|
||||
{
|
||||
detail("Decoding %s failed: article incomplete", m_infoName);
|
||||
detail("Decoding %s failed: article incomplete", *m_infoName);
|
||||
return adFailed;
|
||||
}
|
||||
else if (status == Decoder::dsInvalidSize)
|
||||
{
|
||||
detail("Decoding %s failed: size mismatch", m_infoName);
|
||||
detail("Decoding %s failed: size mismatch", *m_infoName);
|
||||
return adFailed;
|
||||
}
|
||||
else if (status == Decoder::dsNoBinaryData)
|
||||
{
|
||||
detail("Decoding %s failed: no binary data found", m_infoName);
|
||||
detail("Decoding %s failed: no binary data found", *m_infoName);
|
||||
return adFailed;
|
||||
}
|
||||
else
|
||||
{
|
||||
detail("Decoding %s failed", m_infoName);
|
||||
detail("Decoding %s failed", *m_infoName);
|
||||
return adFailed;
|
||||
}
|
||||
}
|
||||
@@ -646,7 +638,7 @@ void ArticleDownloader::LogDebugInfo()
|
||||
#else
|
||||
ctime_r(&m_lastUpdateTime, time);
|
||||
#endif
|
||||
info(" Download: status=%i, LastUpdateTime=%s, InfoName=%s", m_status, time, m_infoName);
|
||||
info(" Download: status=%i, LastUpdateTime=%s, InfoName=%s", m_status, time, *m_infoName);
|
||||
}
|
||||
|
||||
void ArticleDownloader::Stop()
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#ifndef ARTICLEDOWNLOADER_H
|
||||
#define ARTICLEDOWNLOADER_H
|
||||
|
||||
#include "NString.h"
|
||||
#include "Observer.h"
|
||||
#include "DownloadInfo.h"
|
||||
#include "Thread.h"
|
||||
@@ -67,9 +68,9 @@ private:
|
||||
NntpConnection* m_connection;
|
||||
EStatus m_status;
|
||||
Mutex m_connectionMutex;
|
||||
char* m_infoName;
|
||||
char m_connectionName[250];
|
||||
char* m_articleFilename;
|
||||
CString m_infoName;
|
||||
CString m_connectionName;
|
||||
CString m_articleFilename;
|
||||
time_t m_lastUpdateTime;
|
||||
Decoder::EFormat m_format;
|
||||
YDecoder m_yDecoder;
|
||||
|
||||
@@ -34,10 +34,7 @@ ArticleWriter::ArticleWriter()
|
||||
{
|
||||
debug("Creating ArticleWriter");
|
||||
|
||||
m_tempFilename = NULL;
|
||||
m_outputFilename = NULL;
|
||||
m_resultFilename = NULL;
|
||||
m_infoName = NULL;
|
||||
m_format = Decoder::efUnknown;
|
||||
m_articleData = NULL;
|
||||
m_duplicate = false;
|
||||
@@ -48,10 +45,6 @@ ArticleWriter::~ArticleWriter()
|
||||
{
|
||||
debug("Destroying ArticleWriter");
|
||||
|
||||
free(m_outputFilename);
|
||||
free(m_tempFilename);
|
||||
free(m_infoName);
|
||||
|
||||
if (m_articleData)
|
||||
{
|
||||
free(m_articleData);
|
||||
@@ -64,11 +57,6 @@ ArticleWriter::~ArticleWriter()
|
||||
}
|
||||
}
|
||||
|
||||
void ArticleWriter::SetInfoName(const char* infoName)
|
||||
{
|
||||
m_infoName = strdup(infoName);
|
||||
}
|
||||
|
||||
void ArticleWriter::SetWriteBuffer(FILE* outFile, int recSize)
|
||||
{
|
||||
if (g_Options->GetWriteBuffer() > 0)
|
||||
@@ -153,7 +141,7 @@ bool ArticleWriter::Start(Decoder::EFormat format, const char* filename, int64 f
|
||||
|
||||
if (!m_articleData)
|
||||
{
|
||||
detail("Article cache is full, using disk for %s", m_infoName);
|
||||
detail("Article cache is full, using disk for %s", *m_infoName);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -191,7 +179,7 @@ bool ArticleWriter::Write(char* bufffer, int len)
|
||||
{
|
||||
if (m_articlePtr > m_articleSize)
|
||||
{
|
||||
detail("Decoding %s failed: article size mismatch", m_infoName);
|
||||
detail("Decoding %s failed: article size mismatch", *m_infoName);
|
||||
return false;
|
||||
}
|
||||
memcpy(m_articleData + m_articlePtr - len, bufffer, len);
|
||||
@@ -227,7 +215,7 @@ void ArticleWriter::Finish(bool success)
|
||||
if (!Util::MoveFile(m_tempFilename, m_resultFilename))
|
||||
{
|
||||
m_fileInfo->GetNzbInfo()->PrintMessage(Message::mkError,
|
||||
"Could not rename file %s to %s: %s", m_tempFilename, m_resultFilename,
|
||||
"Could not rename file %s to %s: %s", *m_tempFilename, m_resultFilename,
|
||||
Util::GetLastErrorMessage(errBuf, sizeof(errBuf)));
|
||||
}
|
||||
}
|
||||
@@ -258,7 +246,7 @@ void ArticleWriter::Finish(bool success)
|
||||
if (!Util::MoveFile(m_tempFilename, m_resultFilename))
|
||||
{
|
||||
m_fileInfo->GetNzbInfo()->PrintMessage(Message::mkError,
|
||||
"Could not move file %s to %s: %s", m_tempFilename, m_resultFilename,
|
||||
"Could not move file %s to %s: %s", *m_tempFilename, m_resultFilename,
|
||||
Util::GetLastErrorMessage(errBuf, sizeof(errBuf)));
|
||||
}
|
||||
}
|
||||
@@ -295,7 +283,7 @@ bool ArticleWriter::CreateOutputFile(int64 size)
|
||||
if (!Util::CreateSparseFile(m_outputFilename, size, errBuf, sizeof(errBuf)))
|
||||
{
|
||||
m_fileInfo->GetNzbInfo()->PrintMessage(Message::mkError,
|
||||
"Could not create file %s: %s", m_outputFilename, errBuf);
|
||||
"Could not create file %s: %s", *m_outputFilename, errBuf);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -313,7 +301,7 @@ void ArticleWriter::BuildOutputFilename()
|
||||
char tmpname[1024];
|
||||
snprintf(tmpname, 1024, "%s.tmp", filename);
|
||||
tmpname[1024-1] = '\0';
|
||||
m_tempFilename = strdup(tmpname);
|
||||
m_tempFilename = tmpname;
|
||||
|
||||
if (g_Options->GetDirectWrite())
|
||||
{
|
||||
@@ -333,7 +321,7 @@ void ArticleWriter::BuildOutputFilename()
|
||||
|
||||
m_fileInfo->UnlockOutputFile();
|
||||
|
||||
m_outputFilename = strdup(filename);
|
||||
m_outputFilename = filename;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -411,7 +399,7 @@ void ArticleWriter::CompleteFileParts()
|
||||
if (!outfile)
|
||||
{
|
||||
m_fileInfo->GetNzbInfo()->PrintMessage(Message::mkError,
|
||||
"Could not open file %s: %s", m_outputFilename, Util::GetLastErrorMessage(errBuf, sizeof(errBuf)));
|
||||
"Could not open file %s: %s", *m_outputFilename, Util::GetLastErrorMessage(errBuf, sizeof(errBuf)));
|
||||
return;
|
||||
}
|
||||
strncpy(tmpdestfile, m_outputFilename, 1024);
|
||||
@@ -540,7 +528,7 @@ void ArticleWriter::CompleteFileParts()
|
||||
if (!Util::MoveFile(m_outputFilename, ofn))
|
||||
{
|
||||
m_fileInfo->GetNzbInfo()->PrintMessage(Message::mkError,
|
||||
"Could not move file %s to %s: %s", m_outputFilename, ofn,
|
||||
"Could not move file %s to %s: %s", *m_outputFilename, ofn,
|
||||
Util::GetLastErrorMessage(errBuf, sizeof(errBuf)));
|
||||
}
|
||||
|
||||
@@ -549,7 +537,7 @@ void ArticleWriter::CompleteFileParts()
|
||||
if (!(!strncmp(nzbDestDir, m_outputFilename, len) &&
|
||||
(m_outputFilename[len] == PATH_SEPARATOR || m_outputFilename[len] == ALT_PATH_SEPARATOR)))
|
||||
{
|
||||
debug("Checking old dir for: %s", m_outputFilename);
|
||||
debug("Checking old dir for: %s", *m_outputFilename);
|
||||
char oldDestDir[1024];
|
||||
int maxlen = Util::BaseFileName(m_outputFilename) - m_outputFilename;
|
||||
if (maxlen > 1024-1) maxlen = 1024-1;
|
||||
@@ -622,7 +610,7 @@ void ArticleWriter::CompleteFileParts()
|
||||
|
||||
void ArticleWriter::FlushCache()
|
||||
{
|
||||
detail("Flushing cache for %s", m_infoName);
|
||||
detail("Flushing cache for %s", *m_infoName);
|
||||
|
||||
bool directWrite = g_Options->GetDirectWrite() && m_fileInfo->GetOutputInitialized();
|
||||
FILE* outfile = NULL;
|
||||
@@ -730,7 +718,8 @@ void ArticleWriter::FlushCache()
|
||||
|
||||
g_ArticleCache->UnlockFlush();
|
||||
|
||||
detail("Saved %i articles (%.2f MB) from cache into disk for %s", flushedArticles, (float)(flushedSize / 1024.0 / 1024.0), m_infoName);
|
||||
detail("Saved %i articles (%.2f MB) from cache into disk for %s", flushedArticles,
|
||||
(float)(flushedSize / 1024.0 / 1024.0), *m_infoName);
|
||||
}
|
||||
|
||||
bool ArticleWriter::MoveCompletedFiles(NzbInfo* nzbInfo, const char* oldDestDir)
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#ifndef ARTICLEWRITER_H
|
||||
#define ARTICLEWRITER_H
|
||||
|
||||
#include "NString.h"
|
||||
#include "DownloadInfo.h"
|
||||
#include "Decoder.h"
|
||||
|
||||
@@ -35,8 +36,8 @@ private:
|
||||
FileInfo* m_fileInfo;
|
||||
ArticleInfo* m_articleInfo;
|
||||
FILE* m_outFile;
|
||||
char* m_tempFilename;
|
||||
char* m_outputFilename;
|
||||
CString m_tempFilename;
|
||||
CString m_outputFilename;
|
||||
const char* m_resultFilename;
|
||||
Decoder::EFormat m_format;
|
||||
char* m_articleData;
|
||||
@@ -45,12 +46,10 @@ private:
|
||||
int m_articlePtr;
|
||||
bool m_flushing;
|
||||
bool m_duplicate;
|
||||
char* m_infoName;
|
||||
CString m_infoName;
|
||||
|
||||
bool PrepareFile(char* line);
|
||||
bool CreateOutputFile(int64 size);
|
||||
void BuildOutputFilename();
|
||||
bool IsFileCached();
|
||||
void SetWriteBuffer(FILE* outFile, int recSize);
|
||||
|
||||
protected:
|
||||
@@ -59,7 +58,7 @@ protected:
|
||||
public:
|
||||
ArticleWriter();
|
||||
~ArticleWriter();
|
||||
void SetInfoName(const char* infoName);
|
||||
void SetInfoName(const char* infoName) { m_infoName = infoName; }
|
||||
void SetFileInfo(FileInfo* fileInfo) { m_fileInfo = fileInfo; }
|
||||
void SetArticleInfo(ArticleInfo* articleInfo) { m_articleInfo = articleInfo; }
|
||||
void Prepare();
|
||||
|
||||
@@ -41,30 +41,16 @@ NewsServer::NewsServer(int id, bool active, const char* name, const char* host,
|
||||
m_maxConnections = maxConnections;
|
||||
m_joinGroup = joinGroup;
|
||||
m_tls = tls;
|
||||
m_host = strdup(host ? host : "");
|
||||
m_user = strdup(user ? user : "");
|
||||
m_password = strdup(pass ? pass : "");
|
||||
m_cipher = strdup(cipher ? cipher : "");
|
||||
m_name = name;
|
||||
m_host = host ? host : "";
|
||||
m_user = user ? user : "";
|
||||
m_password = pass ? pass : "";
|
||||
m_cipher = cipher ? cipher : "";
|
||||
m_retention = retention;
|
||||
m_blockTime = 0;
|
||||
|
||||
if (name && strlen(name) > 0)
|
||||
if (m_name.Empty())
|
||||
{
|
||||
m_name = strdup(name);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_name = (char*)malloc(20);
|
||||
snprintf(m_name, 20, "server%i", id);
|
||||
m_name[20-1] = '\0';
|
||||
m_name.Format("server%i", id);
|
||||
}
|
||||
}
|
||||
|
||||
NewsServer::~NewsServer()
|
||||
{
|
||||
free(m_name);
|
||||
free(m_host);
|
||||
free(m_user);
|
||||
free(m_password);
|
||||
free(m_cipher);
|
||||
}
|
||||
@@ -27,24 +27,26 @@
|
||||
#ifndef NEWSSERVER_H
|
||||
#define NEWSSERVER_H
|
||||
|
||||
#include "NString.h"
|
||||
|
||||
class NewsServer
|
||||
{
|
||||
private:
|
||||
int m_id;
|
||||
int m_stateId;
|
||||
bool m_active;
|
||||
char* m_name;
|
||||
CString m_name;
|
||||
int m_group;
|
||||
char* m_host;
|
||||
CString m_host;
|
||||
int m_port;
|
||||
char* m_user;
|
||||
char* m_password;
|
||||
CString m_user;
|
||||
CString m_password;
|
||||
int m_maxConnections;
|
||||
int m_level;
|
||||
int m_normLevel;
|
||||
bool m_joinGroup;
|
||||
bool m_tls;
|
||||
char* m_cipher;
|
||||
CString m_cipher;
|
||||
int m_retention;
|
||||
time_t m_blockTime;
|
||||
|
||||
@@ -53,7 +55,6 @@ public:
|
||||
const char* user, const char* pass, bool joinGroup,
|
||||
bool tls, const char* cipher, int maxConnections, int retention,
|
||||
int level, int group);
|
||||
~NewsServer();
|
||||
int GetId() { return m_id; }
|
||||
int GetStateId() { return m_stateId; }
|
||||
void SetStateId(int stateId) { m_stateId = stateId; }
|
||||
|
||||
@@ -43,7 +43,6 @@ NntpConnection::NntpConnection(NewsServer* newsServer) : Connection(newsServer->
|
||||
|
||||
NntpConnection::~NntpConnection()
|
||||
{
|
||||
free(m_activeGroup);
|
||||
free(m_lineBuf);
|
||||
}
|
||||
|
||||
@@ -179,7 +178,7 @@ bool NntpConnection::AuthInfoPass(int recur)
|
||||
|
||||
const char* NntpConnection::JoinGroup(const char* grp)
|
||||
{
|
||||
if (m_activeGroup && !strcmp(m_activeGroup, grp))
|
||||
if (!m_activeGroup.Empty() && !strcmp(m_activeGroup, grp))
|
||||
{
|
||||
// already in group
|
||||
strcpy(m_lineBuf, "211 ");
|
||||
@@ -195,8 +194,7 @@ const char* NntpConnection::JoinGroup(const char* grp)
|
||||
if (answer && !strncmp(answer, "2", 1))
|
||||
{
|
||||
debug("Changed group to %s on %s", grp, GetHost());
|
||||
free(m_activeGroup);
|
||||
m_activeGroup = strdup(grp);
|
||||
m_activeGroup = grp;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -255,7 +253,6 @@ bool NntpConnection::Disconnect()
|
||||
{
|
||||
Request("quit\r\n");
|
||||
}
|
||||
free(m_activeGroup);
|
||||
m_activeGroup = NULL;
|
||||
}
|
||||
return Connection::Disconnect();
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#ifndef NNTPCONNECTION_H
|
||||
#define NNTPCONNECTION_H
|
||||
|
||||
#include "NString.h"
|
||||
#include "NewsServer.h"
|
||||
#include "Connection.h"
|
||||
|
||||
@@ -34,7 +35,7 @@ class NntpConnection : public Connection
|
||||
{
|
||||
private:
|
||||
NewsServer* m_newsServer;
|
||||
char* m_activeGroup;
|
||||
CString m_activeGroup;
|
||||
char* m_lineBuf;
|
||||
bool m_authError;
|
||||
|
||||
|
||||
@@ -162,17 +162,12 @@ void RarLister::AddMessage(Message::EKind kind, const char* text)
|
||||
|
||||
DupeMatcher::DupeMatcher(const char* destDir, int64 expectedSize)
|
||||
{
|
||||
m_destDir = strdup(destDir);
|
||||
m_destDir = destDir;
|
||||
m_expectedSize = expectedSize;
|
||||
m_maxSize = -1;
|
||||
m_compressed = false;
|
||||
}
|
||||
|
||||
DupeMatcher::~DupeMatcher()
|
||||
{
|
||||
free(m_destDir);
|
||||
}
|
||||
|
||||
bool DupeMatcher::SizeDiffOK(int64 size1, int64 size2, int maxDiffPercent)
|
||||
{
|
||||
if (size1 == 0 || size2 == 0)
|
||||
|
||||
@@ -26,12 +26,13 @@
|
||||
#ifndef DUPEMATCHER_H
|
||||
#define DUPEMATCHER_H
|
||||
|
||||
#include "NString.h"
|
||||
#include "Log.h"
|
||||
|
||||
class DupeMatcher
|
||||
{
|
||||
private:
|
||||
char* m_destDir;
|
||||
CString m_destDir;
|
||||
int64 m_expectedSize;
|
||||
int64 m_maxSize;
|
||||
bool m_compressed;
|
||||
@@ -46,7 +47,6 @@ protected:
|
||||
|
||||
public:
|
||||
DupeMatcher(const char* destDir, int64 expectedSize);
|
||||
~DupeMatcher();
|
||||
bool Prepare();
|
||||
bool MatchDupeContent(const char* dupeDir);
|
||||
static bool SizeDiffOK(int64 size1, int64 size2, int maxDiffPercent);
|
||||
|
||||
@@ -190,7 +190,7 @@ void Repairer::BeginRepair()
|
||||
int threads = maxThreads > (int)missingblockcount ? (int)missingblockcount : maxThreads;
|
||||
|
||||
m_owner->PrintMessage(Message::mkInfo, "Using %i of max %i thread(s) to repair %i block(s) for %s",
|
||||
threads, maxThreads, (int)missingblockcount, m_owner->m_nzbName);
|
||||
threads, maxThreads, (int)missingblockcount, *m_owner->m_nzbName);
|
||||
|
||||
m_parallel = threads > 1;
|
||||
|
||||
@@ -378,27 +378,17 @@ ParChecker::SegmentList::~SegmentList()
|
||||
ParChecker::DupeSource::DupeSource(int id, const char* directory)
|
||||
{
|
||||
m_id = id;
|
||||
m_directory = strdup(directory);
|
||||
m_directory = directory;
|
||||
m_usedBlocks = 0;
|
||||
}
|
||||
|
||||
ParChecker::DupeSource::~DupeSource()
|
||||
{
|
||||
free(m_directory);
|
||||
}
|
||||
|
||||
|
||||
ParChecker::ParChecker()
|
||||
{
|
||||
debug("Creating ParChecker");
|
||||
|
||||
m_status = psFailed;
|
||||
m_destDir = NULL;
|
||||
m_nzbName = NULL;
|
||||
m_parFilename = NULL;
|
||||
m_infoName = NULL;
|
||||
m_errMsg = NULL;
|
||||
m_progressLabel = (char*)malloc(1024);
|
||||
m_repairer = NULL;
|
||||
m_fileProgress = 0;
|
||||
m_stageProgress = 0;
|
||||
@@ -416,11 +406,6 @@ ParChecker::~ParChecker()
|
||||
{
|
||||
debug("Destroying ParChecker");
|
||||
|
||||
free(m_destDir);
|
||||
free(m_nzbName);
|
||||
free(m_infoName);
|
||||
free(m_progressLabel);
|
||||
|
||||
Cleanup();
|
||||
}
|
||||
|
||||
@@ -449,35 +434,16 @@ void ParChecker::Cleanup()
|
||||
}
|
||||
m_dupeSources.clear();
|
||||
|
||||
free(m_errMsg);
|
||||
m_errMsg = NULL;
|
||||
}
|
||||
|
||||
void ParChecker::SetDestDir(const char * destDir)
|
||||
{
|
||||
free(m_destDir);
|
||||
m_destDir = strdup(destDir);
|
||||
}
|
||||
|
||||
void ParChecker::SetNzbName(const char * nzbName)
|
||||
{
|
||||
free(m_nzbName);
|
||||
m_nzbName = strdup(nzbName);
|
||||
}
|
||||
|
||||
void ParChecker::SetInfoName(const char * infoName)
|
||||
{
|
||||
free(m_infoName);
|
||||
m_infoName = strdup(infoName);
|
||||
}
|
||||
|
||||
void ParChecker::Run()
|
||||
{
|
||||
m_status = RunParCheckAll();
|
||||
|
||||
if (m_status == psRepairNotNeeded && m_parQuick && m_forceRepair && !m_cancelled)
|
||||
{
|
||||
PrintMessage(Message::mkInfo, "Performing full par-check for %s", m_nzbName);
|
||||
PrintMessage(Message::mkInfo, "Performing full par-check for %s", *m_nzbName);
|
||||
m_parQuick = false;
|
||||
m_status = RunParCheckAll();
|
||||
}
|
||||
@@ -490,7 +456,7 @@ ParChecker::EStatus ParChecker::RunParCheckAll()
|
||||
ParParser::ParFileList fileList;
|
||||
if (!ParParser::FindMainPars(m_destDir, &fileList))
|
||||
{
|
||||
PrintMessage(Message::mkError, "Could not start par-check for %s. Could not find any par-files", m_nzbName);
|
||||
PrintMessage(Message::mkError, "Could not start par-check for %s. Could not find any par-files", *m_nzbName);
|
||||
return psFailed;
|
||||
}
|
||||
|
||||
@@ -506,7 +472,7 @@ ParChecker::EStatus ParChecker::RunParCheckAll()
|
||||
if (!IsStopped() && !m_cancelled)
|
||||
{
|
||||
char fullParFilename[1024];
|
||||
snprintf(fullParFilename, 1024, "%s%c%s", m_destDir, (int)PATH_SEPARATOR, parFilename);
|
||||
snprintf(fullParFilename, 1024, "%s%c%s", *m_destDir, (int)PATH_SEPARATOR, parFilename);
|
||||
fullParFilename[1024-1] = '\0';
|
||||
|
||||
char infoName[1024];
|
||||
@@ -517,7 +483,7 @@ ParChecker::EStatus ParChecker::RunParCheckAll()
|
||||
infoName[maxlen] = '\0';
|
||||
|
||||
char parInfoName[1024];
|
||||
snprintf(parInfoName, 1024, "%s%c%s", m_nzbName, (int)PATH_SEPARATOR, infoName);
|
||||
snprintf(parInfoName, 1024, "%s%c%s", *m_nzbName, (int)PATH_SEPARATOR, infoName);
|
||||
parInfoName[1024-1] = '\0';
|
||||
|
||||
SetInfoName(parInfoName);
|
||||
@@ -554,12 +520,11 @@ ParChecker::EStatus ParChecker::RunParCheck(const char* parFilename)
|
||||
m_hasDamagedFiles = false;
|
||||
EStatus status = psFailed;
|
||||
|
||||
PrintMessage(Message::mkInfo, "Verifying %s", m_infoName);
|
||||
PrintMessage(Message::mkInfo, "Verifying %s", *m_infoName);
|
||||
|
||||
debug("par: %s", m_parFilename);
|
||||
|
||||
snprintf(m_progressLabel, 1024, "Verifying %s", m_infoName);
|
||||
m_progressLabel[1024-1] = '\0';
|
||||
m_progressLabel.Format("Verifying %s", *m_infoName);
|
||||
m_fileProgress = 0;
|
||||
m_stageProgress = 0;
|
||||
UpdateProgress();
|
||||
@@ -629,7 +594,7 @@ ParChecker::EStatus ParChecker::RunParCheck(const char* parFilename)
|
||||
|
||||
if (res == eSuccess || !m_hasDamagedFiles)
|
||||
{
|
||||
PrintMessage(Message::mkInfo, "Repair not needed for %s", m_infoName);
|
||||
PrintMessage(Message::mkInfo, "Repair not needed for %s", *m_infoName);
|
||||
status = psRepairNotNeeded;
|
||||
}
|
||||
else if (res == eRepairPossible)
|
||||
@@ -637,11 +602,10 @@ ParChecker::EStatus ParChecker::RunParCheck(const char* parFilename)
|
||||
status = psRepairPossible;
|
||||
if (g_Options->GetParRepair())
|
||||
{
|
||||
PrintMessage(Message::mkInfo, "Repairing %s", m_infoName);
|
||||
PrintMessage(Message::mkInfo, "Repairing %s", *m_infoName);
|
||||
|
||||
SaveSourceList();
|
||||
snprintf(m_progressLabel, 1024, "Repairing %s", m_infoName);
|
||||
m_progressLabel[1024-1] = '\0';
|
||||
m_progressLabel.Format("Repairing %s", *m_infoName);
|
||||
m_fileProgress = 0;
|
||||
m_stageProgress = 0;
|
||||
m_processedCount = 0;
|
||||
@@ -652,7 +616,7 @@ ParChecker::EStatus ParChecker::RunParCheck(const char* parFilename)
|
||||
res = repairer->Process(true);
|
||||
if (res == eSuccess)
|
||||
{
|
||||
PrintMessage(Message::mkInfo, "Successfully repaired %s", m_infoName);
|
||||
PrintMessage(Message::mkInfo, "Successfully repaired %s", *m_infoName);
|
||||
status = psRepaired;
|
||||
StatDupeSources(&m_dupeSources);
|
||||
DeleteLeftovers();
|
||||
@@ -660,7 +624,7 @@ ParChecker::EStatus ParChecker::RunParCheck(const char* parFilename)
|
||||
}
|
||||
else
|
||||
{
|
||||
PrintMessage(Message::mkInfo, "Repair possible for %s", m_infoName);
|
||||
PrintMessage(Message::mkInfo, "Repair possible for %s", *m_infoName);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -668,14 +632,14 @@ ParChecker::EStatus ParChecker::RunParCheck(const char* parFilename)
|
||||
{
|
||||
if (m_stage >= ptRepairing)
|
||||
{
|
||||
PrintMessage(Message::mkWarning, "Repair cancelled for %s", m_infoName);
|
||||
m_errMsg = strdup("repair cancelled");
|
||||
PrintMessage(Message::mkWarning, "Repair cancelled for %s", *m_infoName);
|
||||
m_errMsg = "repair cancelled";
|
||||
status = psRepairPossible;
|
||||
}
|
||||
else
|
||||
{
|
||||
PrintMessage(Message::mkWarning, "Par-check cancelled for %s", m_infoName);
|
||||
m_errMsg = strdup("par-check cancelled");
|
||||
PrintMessage(Message::mkWarning, "Par-check cancelled for %s", *m_infoName);
|
||||
m_errMsg = "par-check cancelled";
|
||||
status = psFailed;
|
||||
}
|
||||
}
|
||||
@@ -683,9 +647,9 @@ ParChecker::EStatus ParChecker::RunParCheck(const char* parFilename)
|
||||
{
|
||||
if (!m_errMsg && (int)res >= 0 && (int)res <= 8)
|
||||
{
|
||||
m_errMsg = strdup(Par2CmdLineErrStr[res]);
|
||||
m_errMsg = Par2CmdLineErrStr[res];
|
||||
}
|
||||
PrintMessage(Message::mkError, "Repair failed for %s: %s", m_infoName, m_errMsg ? m_errMsg : "");
|
||||
PrintMessage(Message::mkError, "Repair failed for %s: %s", *m_infoName, m_errMsg ? *m_errMsg : "");
|
||||
}
|
||||
|
||||
Cleanup();
|
||||
@@ -707,22 +671,22 @@ int ParChecker::PreProcessPar()
|
||||
|
||||
if (IsStopped())
|
||||
{
|
||||
PrintMessage(Message::mkError, "Could not verify %s: stopping", m_infoName);
|
||||
m_errMsg = strdup("par-check was stopped");
|
||||
PrintMessage(Message::mkError, "Could not verify %s: stopping", *m_infoName);
|
||||
m_errMsg = "par-check was stopped";
|
||||
return eRepairFailed;
|
||||
}
|
||||
|
||||
if (res == eInvalidCommandLineArguments)
|
||||
{
|
||||
PrintMessage(Message::mkError, "Could not start par-check for %s. Par-file: %s", m_infoName, m_parFilename);
|
||||
m_errMsg = strdup("Command line could not be parsed");
|
||||
PrintMessage(Message::mkError, "Could not start par-check for %s. Par-file: %s", *m_infoName, m_parFilename);
|
||||
m_errMsg = "Command line could not be parsed";
|
||||
return res;
|
||||
}
|
||||
|
||||
if (res != eSuccess)
|
||||
{
|
||||
PrintMessage(Message::mkWarning, "Could not verify %s: par2-file could not be processed", m_infoName);
|
||||
PrintMessage(Message::mkInfo, "Requesting more par2-files for %s", m_infoName);
|
||||
PrintMessage(Message::mkWarning, "Could not verify %s: par2-file could not be processed", *m_infoName);
|
||||
PrintMessage(Message::mkInfo, "Requesting more par2-files for %s", *m_infoName);
|
||||
bool hasMorePars = LoadMainParBak();
|
||||
if (!hasMorePars)
|
||||
{
|
||||
@@ -734,8 +698,8 @@ int ParChecker::PreProcessPar()
|
||||
|
||||
if (res != eSuccess)
|
||||
{
|
||||
PrintMessage(Message::mkError, "Could not verify %s: par2-file could not be processed", m_infoName);
|
||||
m_errMsg = strdup("par2-file could not be processed");
|
||||
PrintMessage(Message::mkError, "Could not verify %s: par2-file could not be processed", *m_infoName);
|
||||
m_errMsg = "par2-file could not be processed";
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -764,8 +728,7 @@ bool ParChecker::LoadMainParBak()
|
||||
bool requested = RequestMorePars(1, &blockFound);
|
||||
if (requested)
|
||||
{
|
||||
strncpy(m_progressLabel, "Awaiting additional par-files", 1024);
|
||||
m_progressLabel[1024-1] = '\0';
|
||||
m_progressLabel = "Awaiting additional par-files";
|
||||
m_fileProgress = 0;
|
||||
UpdateProgress();
|
||||
}
|
||||
@@ -813,7 +776,7 @@ int ParChecker::ProcessMorePars()
|
||||
|
||||
if (moreFilesLoaded)
|
||||
{
|
||||
PrintMessage(Message::mkInfo, "Need more %i par-block(s) for %s", missingblockcount, m_infoName);
|
||||
PrintMessage(Message::mkInfo, "Need more %i par-block(s) for %s", missingblockcount, *m_infoName);
|
||||
}
|
||||
|
||||
m_queuedParFilesMutex.Lock();
|
||||
@@ -826,8 +789,7 @@ int ParChecker::ProcessMorePars()
|
||||
bool requested = RequestMorePars(missingblockcount, &blockFound);
|
||||
if (requested)
|
||||
{
|
||||
strncpy(m_progressLabel, "Awaiting additional par-files", 1024);
|
||||
m_progressLabel[1024-1] = '\0';
|
||||
m_progressLabel = "Awaiting additional par-files";
|
||||
m_fileProgress = 0;
|
||||
UpdateProgress();
|
||||
}
|
||||
@@ -839,9 +801,7 @@ int ParChecker::ProcessMorePars()
|
||||
|
||||
if (!requested && !hasMorePars)
|
||||
{
|
||||
m_errMsg = (char*)malloc(1024);
|
||||
snprintf(m_errMsg, 1024, "not enough par-blocks, %i block(s) needed, but %i block(s) available", missingblockcount, blockFound);
|
||||
m_errMsg[1024-1] = '\0';
|
||||
m_errMsg.Format("not enough par-blocks, %i block(s) needed, but %i block(s) available", missingblockcount, blockFound);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -889,11 +849,11 @@ bool ParChecker::LoadMorePars()
|
||||
bool loadedOK = ((Repairer*)m_repairer)->LoadPacketsFromFile(parFilename);
|
||||
if (loadedOK)
|
||||
{
|
||||
PrintMessage(Message::mkInfo, "File %s successfully loaded for par-check", Util::BaseFileName(parFilename), m_infoName);
|
||||
PrintMessage(Message::mkInfo, "File %s successfully loaded for par-check", Util::BaseFileName(parFilename), *m_infoName);
|
||||
}
|
||||
else
|
||||
{
|
||||
PrintMessage(Message::mkInfo, "Could not load file %s for par-check", Util::BaseFileName(parFilename), m_infoName);
|
||||
PrintMessage(Message::mkInfo, "Could not load file %s for par-check", Util::BaseFileName(parFilename), *m_infoName);
|
||||
}
|
||||
free(parFilename);
|
||||
}
|
||||
@@ -947,7 +907,7 @@ bool ParChecker::AddSplittedFragments()
|
||||
debug("Found splitted fragment %s", filename);
|
||||
|
||||
char fullfilename[1024];
|
||||
snprintf(fullfilename, 1024, "%s%c%s", m_destDir, PATH_SEPARATOR, filename);
|
||||
snprintf(fullfilename, 1024, "%s%c%s", *m_destDir, PATH_SEPARATOR, filename);
|
||||
fullfilename[1024-1] = '\0';
|
||||
|
||||
CommandLine::ExtraFile extrafile(fullfilename, Util::FileSize(fullfilename));
|
||||
@@ -965,7 +925,7 @@ bool ParChecker::AddSplittedFragments()
|
||||
{
|
||||
m_extraFiles += extrafiles.size();
|
||||
m_verifyingExtraFiles = true;
|
||||
PrintMessage(Message::mkInfo, "Found %i splitted fragments for %s", (int)extrafiles.size(), m_infoName);
|
||||
PrintMessage(Message::mkInfo, "Found %i splitted fragments for %s", (int)extrafiles.size(), *m_infoName);
|
||||
fragmentsAdded = ((Repairer*)m_repairer)->VerifyExtraFiles(extrafiles);
|
||||
((Repairer*)m_repairer)->UpdateVerificationResults();
|
||||
m_verifyingExtraFiles = false;
|
||||
@@ -1028,11 +988,11 @@ bool ParChecker::AddExtraFiles(bool onlyMissing, bool externalDir, const char* d
|
||||
{
|
||||
if (externalDir)
|
||||
{
|
||||
PrintMessage(Message::mkInfo, "Performing dupe par-scan for %s in %s", m_infoName, Util::BaseFileName(directory));
|
||||
PrintMessage(Message::mkInfo, "Performing dupe par-scan for %s in %s", *m_infoName, Util::BaseFileName(directory));
|
||||
}
|
||||
else
|
||||
{
|
||||
PrintMessage(Message::mkInfo, "Performing extra par-scan for %s", m_infoName);
|
||||
PrintMessage(Message::mkInfo, "Performing extra par-scan for %s", *m_infoName);
|
||||
}
|
||||
|
||||
std::list<CommandLine::ExtraFile*> extrafiles;
|
||||
@@ -1166,8 +1126,7 @@ void ParChecker::signal_filename(std::string str)
|
||||
m_processedFiles.push_back(strdup(str.c_str()));
|
||||
}
|
||||
|
||||
snprintf(m_progressLabel, 1024, "%s %s", stageMessage[m_stage], str.c_str());
|
||||
m_progressLabel[1024-1] = '\0';
|
||||
m_progressLabel.Format("%s %s", stageMessage[m_stage], str.c_str());
|
||||
m_fileProgress = 0;
|
||||
UpdateProgress();
|
||||
}
|
||||
@@ -1319,7 +1278,7 @@ void ParChecker::Cancel()
|
||||
void ParChecker::WriteBrokenLog(EStatus status)
|
||||
{
|
||||
char brokenLogName[1024];
|
||||
snprintf(brokenLogName, 1024, "%s%c_brokenlog.txt", m_destDir, (int)PATH_SEPARATOR);
|
||||
snprintf(brokenLogName, 1024, "%s%c_brokenlog.txt", *m_destDir, (int)PATH_SEPARATOR);
|
||||
brokenLogName[1024-1] = '\0';
|
||||
|
||||
if (status != psRepairNotNeeded || Util::FileExists(brokenLogName))
|
||||
@@ -1331,24 +1290,24 @@ void ParChecker::WriteBrokenLog(EStatus status)
|
||||
{
|
||||
if (m_cancelled)
|
||||
{
|
||||
fprintf(file, "Repair cancelled for %s\n", m_infoName);
|
||||
fprintf(file, "Repair cancelled for %s\n", *m_infoName);
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(file, "Repair failed for %s: %s\n", m_infoName, m_errMsg ? m_errMsg : "");
|
||||
fprintf(file, "Repair failed for %s: %s\n", *m_infoName, m_errMsg ? *m_errMsg : "");
|
||||
}
|
||||
}
|
||||
else if (status == psRepairPossible)
|
||||
{
|
||||
fprintf(file, "Repair possible for %s\n", m_infoName);
|
||||
fprintf(file, "Repair possible for %s\n", *m_infoName);
|
||||
}
|
||||
else if (status == psRepaired)
|
||||
{
|
||||
fprintf(file, "Successfully repaired %s\n", m_infoName);
|
||||
fprintf(file, "Successfully repaired %s\n", *m_infoName);
|
||||
}
|
||||
else if (status == psRepairNotNeeded)
|
||||
{
|
||||
fprintf(file, "Repair not needed for %s\n", m_infoName);
|
||||
fprintf(file, "Repair not needed for %s\n", *m_infoName);
|
||||
}
|
||||
fclose(file);
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
|
||||
#ifndef DISABLE_PARCHECK
|
||||
|
||||
#include "NString.h"
|
||||
#include "Thread.h"
|
||||
#include "Log.h"
|
||||
|
||||
@@ -86,12 +87,11 @@ public:
|
||||
{
|
||||
private:
|
||||
int m_id;
|
||||
char* m_directory;
|
||||
CString m_directory;
|
||||
int m_usedBlocks;
|
||||
|
||||
public:
|
||||
DupeSource(int id, const char* directory);
|
||||
~DupeSource();
|
||||
int GetId() { return m_id; }
|
||||
const char* GetDirectory() { return m_directory; }
|
||||
int GetUsedBlocks() { return m_usedBlocks; }
|
||||
@@ -107,15 +107,15 @@ public:
|
||||
friend class Repairer;
|
||||
|
||||
private:
|
||||
char* m_infoName;
|
||||
char* m_destDir;
|
||||
char* m_nzbName;
|
||||
CString m_infoName;
|
||||
CString m_destDir;
|
||||
CString m_nzbName;
|
||||
const char* m_parFilename;
|
||||
EStatus m_status;
|
||||
EStage m_stage;
|
||||
// declared as void* to prevent the including of libpar2-headers into this header-file
|
||||
void* m_repairer;
|
||||
char* m_errMsg;
|
||||
CString m_errMsg;
|
||||
FileList m_queuedParFiles;
|
||||
Mutex m_queuedParFilesMutex;
|
||||
bool m_queuedParFilesChanged;
|
||||
@@ -125,7 +125,7 @@ private:
|
||||
int m_extraFiles;
|
||||
int m_quickFiles;
|
||||
bool m_verifyingExtraFiles;
|
||||
char* m_progressLabel;
|
||||
CString m_progressLabel;
|
||||
int m_fileProgress;
|
||||
int m_stageProgress;
|
||||
bool m_cancelled;
|
||||
@@ -189,11 +189,11 @@ public:
|
||||
ParChecker();
|
||||
virtual ~ParChecker();
|
||||
virtual void Run();
|
||||
void SetDestDir(const char* destDir);
|
||||
void SetDestDir(const char* destDir) { m_destDir = destDir; }
|
||||
const char* GetParFilename() { return m_parFilename; }
|
||||
const char* GetInfoName() { return m_infoName; }
|
||||
void SetInfoName(const char* infoName);
|
||||
void SetNzbName(const char* nzbName);
|
||||
void SetInfoName(const char* infoName) { m_infoName = infoName; }
|
||||
void SetNzbName(const char* nzbName) { m_nzbName = nzbName; }
|
||||
void SetParQuick(bool parQuick) { m_parQuick = parQuick; }
|
||||
bool GetParQuick() { return m_parQuick; }
|
||||
void SetForceRepair(bool forceRepair) { m_forceRepair = forceRepair; }
|
||||
|
||||
@@ -45,25 +45,16 @@ public:
|
||||
|
||||
ParRenamer::FileHash::FileHash(const char* filename, const char* hash)
|
||||
{
|
||||
m_filename = strdup(filename);
|
||||
m_hash = strdup(hash);
|
||||
m_filename = filename;
|
||||
m_hash = hash;
|
||||
m_fileExists = false;
|
||||
}
|
||||
|
||||
ParRenamer::FileHash::~FileHash()
|
||||
{
|
||||
free(m_filename);
|
||||
free(m_hash);
|
||||
}
|
||||
|
||||
ParRenamer::ParRenamer()
|
||||
{
|
||||
debug("Creating ParRenamer");
|
||||
|
||||
m_status = psFailed;
|
||||
m_destDir = NULL;
|
||||
m_infoName = NULL;
|
||||
m_progressLabel = (char*)malloc(1024);
|
||||
m_stageProgress = 0;
|
||||
m_cancelled = false;
|
||||
m_hasMissedFiles = false;
|
||||
@@ -74,10 +65,6 @@ ParRenamer::~ParRenamer()
|
||||
{
|
||||
debug("Destroying ParRenamer");
|
||||
|
||||
free(m_destDir);
|
||||
free(m_infoName);
|
||||
free(m_progressLabel);
|
||||
|
||||
Cleanup();
|
||||
}
|
||||
|
||||
@@ -101,18 +88,6 @@ void ParRenamer::ClearHashList()
|
||||
m_fileHashList.clear();
|
||||
}
|
||||
|
||||
void ParRenamer::SetDestDir(const char * destDir)
|
||||
{
|
||||
free(m_destDir);
|
||||
m_destDir = strdup(destDir);
|
||||
}
|
||||
|
||||
void ParRenamer::SetInfoName(const char * infoName)
|
||||
{
|
||||
free(m_infoName);
|
||||
m_infoName = strdup(infoName);
|
||||
}
|
||||
|
||||
void ParRenamer::Cancel()
|
||||
{
|
||||
m_cancelled = true;
|
||||
@@ -128,8 +103,7 @@ void ParRenamer::Run()
|
||||
m_hasMissedFiles = false;
|
||||
m_status = psFailed;
|
||||
|
||||
snprintf(m_progressLabel, 1024, "Checking renamed files for %s", m_infoName);
|
||||
m_progressLabel[1024-1] = '\0';
|
||||
m_progressLabel.Format("Checking renamed files for %s", *m_infoName);
|
||||
m_stageProgress = 0;
|
||||
UpdateProgress();
|
||||
|
||||
@@ -160,16 +134,16 @@ void ParRenamer::Run()
|
||||
|
||||
if (m_cancelled)
|
||||
{
|
||||
PrintMessage(Message::mkWarning, "Renaming cancelled for %s", m_infoName);
|
||||
PrintMessage(Message::mkWarning, "Renaming cancelled for %s", *m_infoName);
|
||||
}
|
||||
else if (m_renamedCount > 0)
|
||||
{
|
||||
PrintMessage(Message::mkInfo, "Successfully renamed %i file(s) for %s", m_renamedCount, m_infoName);
|
||||
PrintMessage(Message::mkInfo, "Successfully renamed %i file(s) for %s", m_renamedCount, *m_infoName);
|
||||
m_status = psSuccess;
|
||||
}
|
||||
else
|
||||
{
|
||||
PrintMessage(Message::mkInfo, "No renamed files found for %s", m_infoName);
|
||||
PrintMessage(Message::mkInfo, "No renamed files found for %s", *m_infoName);
|
||||
}
|
||||
|
||||
Cleanup();
|
||||
@@ -269,8 +243,7 @@ void ParRenamer::CheckFiles(const char* destDir, bool renamePars)
|
||||
|
||||
if (!Util::DirectoryExists(fullFilename))
|
||||
{
|
||||
snprintf(m_progressLabel, 1024, "Checking file %s", filename);
|
||||
m_progressLabel[1024-1] = '\0';
|
||||
m_progressLabel.Format("Checking file %s", filename);
|
||||
m_stageProgress = m_curFile * 1000 / m_fileCount;
|
||||
UpdateProgress();
|
||||
m_curFile++;
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
|
||||
#ifndef DISABLE_PARCHECK
|
||||
|
||||
#include "NString.h"
|
||||
#include "Thread.h"
|
||||
#include "Log.h"
|
||||
|
||||
@@ -43,13 +44,12 @@ public:
|
||||
class FileHash
|
||||
{
|
||||
private:
|
||||
char* m_filename;
|
||||
char* m_hash;
|
||||
CString m_filename;
|
||||
CString m_hash;
|
||||
bool m_fileExists;
|
||||
|
||||
public:
|
||||
FileHash(const char* filename, const char* hash);
|
||||
~FileHash();
|
||||
const char* GetFilename() { return m_filename; }
|
||||
const char* GetHash() { return m_hash; }
|
||||
bool GetFileExists() { return m_fileExists; }
|
||||
@@ -60,10 +60,10 @@ public:
|
||||
typedef std::deque<char*> DirList;
|
||||
|
||||
private:
|
||||
char* m_infoName;
|
||||
char* m_destDir;
|
||||
CString m_infoName;
|
||||
CString m_destDir;
|
||||
EStatus m_status;
|
||||
char* m_progressLabel;
|
||||
CString m_progressLabel;
|
||||
int m_stageProgress;
|
||||
bool m_cancelled;
|
||||
DirList m_dirList;
|
||||
@@ -100,9 +100,9 @@ public:
|
||||
ParRenamer();
|
||||
virtual ~ParRenamer();
|
||||
virtual void Run();
|
||||
void SetDestDir(const char* destDir);
|
||||
void SetDestDir(const char* destDir) { m_destDir = destDir; }
|
||||
const char* GetInfoName() { return m_infoName; }
|
||||
void SetInfoName(const char* infoName);
|
||||
void SetInfoName(const char* infoName) { m_infoName = infoName; }
|
||||
void SetStatus(EStatus status);
|
||||
EStatus GetStatus() { return m_status; }
|
||||
void Cancel();
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
|
||||
|
||||
#include "nzbget.h"
|
||||
#include "NString.h"
|
||||
#include "DiskState.h"
|
||||
#include "Options.h"
|
||||
#include "Log.h"
|
||||
@@ -1178,7 +1179,7 @@ bool DiskState::SaveFileInfo(FileInfo* fileInfo, const char* filename)
|
||||
fprintf(outfile, "%i\n", (int)fileInfo->GetGroups()->size());
|
||||
for (FileInfo::Groups::iterator it = fileInfo->GetGroups()->begin(); it != fileInfo->GetGroups()->end(); it++)
|
||||
{
|
||||
fprintf(outfile, "%s\n", *it);
|
||||
fprintf(outfile, "%s\n", **it);
|
||||
}
|
||||
|
||||
fprintf(outfile, "%i\n", (int)fileInfo->GetArticles()->size());
|
||||
@@ -1280,7 +1281,7 @@ bool DiskState::LoadFileInfo(FileInfo* fileInfo, const char * filename, bool fil
|
||||
{
|
||||
if (!fgets(buf, sizeof(buf), infile)) goto error;
|
||||
if (buf[0] != 0) buf[strlen(buf)-1] = 0; // remove traling '\n'
|
||||
if (fileSummary) fileInfo->GetGroups()->push_back(strdup(buf));
|
||||
if (fileSummary) fileInfo->GetGroups()->push_back(buf);
|
||||
}
|
||||
|
||||
if (fscanf(infile, "%i\n", &size) != 1) goto error;
|
||||
@@ -2578,14 +2579,13 @@ class ServerRef
|
||||
{
|
||||
public:
|
||||
int m_stateId;
|
||||
char* m_name;
|
||||
char* m_host;
|
||||
CString m_name;
|
||||
CString m_host;
|
||||
int m_port;
|
||||
char* m_user;
|
||||
CString m_user;
|
||||
bool m_matched;
|
||||
bool m_perfect;
|
||||
|
||||
~ServerRef();
|
||||
int GetStateId() { return m_stateId; }
|
||||
const char* GetName() { return m_name; }
|
||||
const char* GetHost() { return m_host; }
|
||||
@@ -2599,13 +2599,6 @@ public:
|
||||
|
||||
typedef std::deque<ServerRef*> ServerRefList;
|
||||
|
||||
ServerRef::~ServerRef()
|
||||
{
|
||||
free(m_name);
|
||||
free(m_host);
|
||||
free(m_user);
|
||||
}
|
||||
|
||||
enum ECriteria
|
||||
{
|
||||
name,
|
||||
@@ -2748,10 +2741,10 @@ bool DiskState::LoadServerInfo(Servers* servers, FILE* infile, int formatVersion
|
||||
|
||||
ServerRef* ref = new ServerRef();
|
||||
ref->m_stateId = i + 1;
|
||||
ref->m_name = strdup(name);
|
||||
ref->m_host = strdup(host);
|
||||
ref->m_name = name;
|
||||
ref->m_host = host;
|
||||
ref->m_port = port;
|
||||
ref->m_user = strdup(user);
|
||||
ref->m_user = user;
|
||||
ref->m_matched = false;
|
||||
ref->m_perfect = false;
|
||||
serverRefs.push_back(ref);
|
||||
|
||||
+12
-180
@@ -38,25 +38,6 @@ int NzbInfo::m_idMax = 0;
|
||||
DownloadQueue* DownloadQueue::g_DownloadQueue = NULL;
|
||||
bool DownloadQueue::g_Loaded = false;
|
||||
|
||||
NzbParameter::NzbParameter(const char* name)
|
||||
{
|
||||
m_name = strdup(name);
|
||||
m_value = NULL;
|
||||
}
|
||||
|
||||
NzbParameter::~NzbParameter()
|
||||
{
|
||||
free(m_name);
|
||||
free(m_value);
|
||||
}
|
||||
|
||||
void NzbParameter::SetValue(const char* value)
|
||||
{
|
||||
free(m_value);
|
||||
m_value = strdup(value);
|
||||
}
|
||||
|
||||
|
||||
NzbParameterList::~NzbParameterList()
|
||||
{
|
||||
Clear();
|
||||
@@ -131,18 +112,6 @@ void NzbParameterList::CopyFrom(NzbParameterList* sourceParameters)
|
||||
}
|
||||
|
||||
|
||||
ScriptStatus::ScriptStatus(const char* name, EStatus status)
|
||||
{
|
||||
m_name = strdup(name);
|
||||
m_status = status;
|
||||
}
|
||||
|
||||
ScriptStatus::~ScriptStatus()
|
||||
{
|
||||
free(m_name);
|
||||
}
|
||||
|
||||
|
||||
ScriptStatusList::~ScriptStatusList()
|
||||
{
|
||||
Clear();
|
||||
@@ -256,11 +225,11 @@ NzbInfo::NzbInfo() : m_fileList(true)
|
||||
debug("Creating NZBInfo");
|
||||
|
||||
m_kind = nkNzb;
|
||||
m_url = strdup("");
|
||||
m_filename = strdup("");
|
||||
m_destDir = strdup("");
|
||||
m_finalDir = strdup("");
|
||||
m_category = strdup("");
|
||||
m_url = "";
|
||||
m_filename = "";
|
||||
m_destDir = "";
|
||||
m_finalDir = "";
|
||||
m_category = "";
|
||||
m_name = NULL;
|
||||
m_fileCount = 0;
|
||||
m_parkedFileCount = 0;
|
||||
@@ -297,8 +266,8 @@ NzbInfo::NzbInfo() : m_fileList(true)
|
||||
m_parCleanup = false;
|
||||
m_cleanupDisk = false;
|
||||
m_unpackCleanedUpDisk = false;
|
||||
m_queuedFilename = strdup("");
|
||||
m_dupeKey = strdup("");
|
||||
m_queuedFilename = "";
|
||||
m_dupeKey = "";
|
||||
m_dupeScore = 0;
|
||||
m_dupeMode = dmScore;
|
||||
m_fullContentHash = 0;
|
||||
@@ -334,14 +303,6 @@ NzbInfo::~NzbInfo()
|
||||
{
|
||||
debug("Destroying NZBInfo");
|
||||
|
||||
free(m_url);
|
||||
free(m_filename);
|
||||
free(m_destDir);
|
||||
free(m_finalDir);
|
||||
free(m_category);
|
||||
free(m_name);
|
||||
free(m_queuedFilename);
|
||||
free(m_dupeKey);
|
||||
delete m_postInfo;
|
||||
|
||||
ClearCompletedFiles();
|
||||
@@ -385,22 +346,9 @@ void NzbInfo::ClearCompletedFiles()
|
||||
m_completedFiles.clear();
|
||||
}
|
||||
|
||||
void NzbInfo::SetDestDir(const char* destDir)
|
||||
{
|
||||
free(m_destDir);
|
||||
m_destDir = strdup(destDir);
|
||||
}
|
||||
|
||||
void NzbInfo::SetFinalDir(const char* finalDir)
|
||||
{
|
||||
free(m_finalDir);
|
||||
m_finalDir = strdup(finalDir);
|
||||
}
|
||||
|
||||
void NzbInfo::SetUrl(const char* url)
|
||||
{
|
||||
free(m_url);
|
||||
m_url = strdup(url);
|
||||
m_url = url;
|
||||
|
||||
if (!m_name)
|
||||
{
|
||||
@@ -418,8 +366,7 @@ void NzbInfo::SetFilename(const char* filename)
|
||||
{
|
||||
bool hadFilename = !Util::EmptyStr(m_filename);
|
||||
|
||||
free(m_filename);
|
||||
m_filename = strdup(filename);
|
||||
m_filename = filename;
|
||||
|
||||
if ((!m_name || !hadFilename) && !Util::EmptyStr(filename))
|
||||
{
|
||||
@@ -433,30 +380,6 @@ void NzbInfo::SetFilename(const char* filename)
|
||||
}
|
||||
}
|
||||
|
||||
void NzbInfo::SetName(const char* name)
|
||||
{
|
||||
free(m_name);
|
||||
m_name = name ? strdup(name) : NULL;
|
||||
}
|
||||
|
||||
void NzbInfo::SetCategory(const char* category)
|
||||
{
|
||||
free(m_category);
|
||||
m_category = strdup(category);
|
||||
}
|
||||
|
||||
void NzbInfo::SetQueuedFilename(const char * queuedFilename)
|
||||
{
|
||||
free(m_queuedFilename);
|
||||
m_queuedFilename = strdup(queuedFilename);
|
||||
}
|
||||
|
||||
void NzbInfo::SetDupeKey(const char* dupeKey)
|
||||
{
|
||||
free(m_dupeKey);
|
||||
m_dupeKey = strdup(dupeKey ? dupeKey : "");
|
||||
}
|
||||
|
||||
void NzbInfo::MakeNiceNzbName(const char * nzbFilename, char * buffer, int size, bool removeExt)
|
||||
{
|
||||
char postname[1024];
|
||||
@@ -1005,13 +928,10 @@ NzbInfo* NzbList::Find(int id)
|
||||
ArticleInfo::ArticleInfo()
|
||||
{
|
||||
//debug("Creating ArticleInfo");
|
||||
m_messageId = NULL;
|
||||
m_size = 0;
|
||||
m_segmentContent = NULL;
|
||||
m_segmentOffset = 0;
|
||||
m_segmentSize = 0;
|
||||
m_status = aiUndefined;
|
||||
m_resultFilename = NULL;
|
||||
m_crc = 0;
|
||||
}
|
||||
|
||||
@@ -1019,20 +939,6 @@ ArticleInfo::~ ArticleInfo()
|
||||
{
|
||||
//debug("Destroying ArticleInfo");
|
||||
DiscardSegment();
|
||||
free(m_messageId);
|
||||
free(m_resultFilename);
|
||||
}
|
||||
|
||||
void ArticleInfo::SetMessageId(const char * messageId)
|
||||
{
|
||||
free(m_messageId);
|
||||
m_messageId = strdup(messageId);
|
||||
}
|
||||
|
||||
void ArticleInfo::SetResultFilename(const char * v)
|
||||
{
|
||||
free(m_resultFilename);
|
||||
m_resultFilename = strdup(v);
|
||||
}
|
||||
|
||||
void ArticleInfo::AttachSegment(char* content, int64 offset, int size)
|
||||
@@ -1047,7 +953,6 @@ void ArticleInfo::DiscardSegment()
|
||||
{
|
||||
if (m_segmentContent)
|
||||
{
|
||||
free(m_segmentContent);
|
||||
m_segmentContent = NULL;
|
||||
g_ArticleCache->Free(m_segmentSize);
|
||||
}
|
||||
@@ -1058,11 +963,6 @@ FileInfo::FileInfo(int id)
|
||||
{
|
||||
debug("Creating FileInfo");
|
||||
|
||||
m_articles.clear();
|
||||
m_groups.clear();
|
||||
m_subject = NULL;
|
||||
m_filename = NULL;
|
||||
m_outputFilename = NULL;
|
||||
m_mutexOutputFile = NULL;
|
||||
m_filenameConfirmed = false;
|
||||
m_size = 0;
|
||||
@@ -1093,17 +993,8 @@ FileInfo::~ FileInfo()
|
||||
{
|
||||
debug("Destroying FileInfo");
|
||||
|
||||
free(m_subject);
|
||||
free(m_filename);
|
||||
free(m_outputFilename);
|
||||
delete m_mutexOutputFile;
|
||||
|
||||
for (Groups::iterator it = m_groups.begin(); it != m_groups.end() ;it++)
|
||||
{
|
||||
free(*it);
|
||||
}
|
||||
m_groups.clear();
|
||||
|
||||
ClearArticles();
|
||||
}
|
||||
|
||||
@@ -1148,17 +1039,6 @@ void FileInfo::SetPaused(bool paused)
|
||||
m_paused = paused;
|
||||
}
|
||||
|
||||
void FileInfo::SetSubject(const char* subject)
|
||||
{
|
||||
m_subject = strdup(subject);
|
||||
}
|
||||
|
||||
void FileInfo::SetFilename(const char* filename)
|
||||
{
|
||||
free(m_filename);
|
||||
m_filename = strdup(filename);
|
||||
}
|
||||
|
||||
void FileInfo::MakeValidFilename()
|
||||
{
|
||||
Util::MakeValidFilename(m_filename, '_', false);
|
||||
@@ -1174,12 +1054,6 @@ void FileInfo::UnlockOutputFile()
|
||||
m_mutexOutputFile->Unlock();
|
||||
}
|
||||
|
||||
void FileInfo::SetOutputFilename(const char* outputFilename)
|
||||
{
|
||||
free(m_outputFilename);
|
||||
m_outputFilename = strdup(outputFilename);
|
||||
}
|
||||
|
||||
void FileInfo::SetActiveDownloads(int activeDownloads)
|
||||
{
|
||||
m_activeDownloads = activeDownloads;
|
||||
@@ -1218,6 +1092,7 @@ void FileList::Remove(FileInfo* fileInfo)
|
||||
erase(std::find(begin(), end(), fileInfo));
|
||||
}
|
||||
|
||||
|
||||
CompletedFile::CompletedFile(int id, const char* fileName, EStatus status, uint32 crc)
|
||||
{
|
||||
m_id = id;
|
||||
@@ -1227,21 +1102,11 @@ CompletedFile::CompletedFile(int id, const char* fileName, EStatus status, uint3
|
||||
FileInfo::m_idMax = m_id;
|
||||
}
|
||||
|
||||
m_fileName = strdup(fileName);
|
||||
m_fileName = fileName;
|
||||
m_status = status;
|
||||
m_crc = crc;
|
||||
}
|
||||
|
||||
void CompletedFile::SetFileName(const char* fileName)
|
||||
{
|
||||
free(m_fileName);
|
||||
m_fileName = strdup(fileName);
|
||||
}
|
||||
|
||||
CompletedFile::~CompletedFile()
|
||||
{
|
||||
free(m_fileName);
|
||||
}
|
||||
|
||||
PostInfo::PostInfo()
|
||||
{
|
||||
@@ -1257,7 +1122,7 @@ PostInfo::PostInfo()
|
||||
m_unpackTried = false;
|
||||
m_passListTried = false;
|
||||
m_lastUnpackStatus = 0;
|
||||
m_progressLabel = strdup("");
|
||||
m_progressLabel = "";
|
||||
m_fileProgress = 0;
|
||||
m_stageProgress = 0;
|
||||
m_startTime = 0;
|
||||
@@ -1269,27 +1134,12 @@ PostInfo::PostInfo()
|
||||
PostInfo::~ PostInfo()
|
||||
{
|
||||
debug("Destroying PostInfo");
|
||||
|
||||
free(m_progressLabel);
|
||||
|
||||
for (ParredFiles::iterator it = m_parredFiles.begin(); it != m_parredFiles.end(); it++)
|
||||
{
|
||||
free(*it);
|
||||
}
|
||||
}
|
||||
|
||||
void PostInfo::SetProgressLabel(const char* progressLabel)
|
||||
{
|
||||
free(m_progressLabel);
|
||||
m_progressLabel = strdup(progressLabel);
|
||||
}
|
||||
|
||||
|
||||
DupInfo::DupInfo()
|
||||
{
|
||||
m_id = 0;
|
||||
m_name = NULL;
|
||||
m_dupeKey = NULL;
|
||||
m_dupeScore = 0;
|
||||
m_dupeMode = dmScore;
|
||||
m_size = 0;
|
||||
@@ -1298,12 +1148,6 @@ DupInfo::DupInfo()
|
||||
m_status = dsUndefined;
|
||||
}
|
||||
|
||||
DupInfo::~DupInfo()
|
||||
{
|
||||
free(m_name);
|
||||
free(m_dupeKey);
|
||||
}
|
||||
|
||||
void DupInfo::SetId(int id)
|
||||
{
|
||||
m_id = id;
|
||||
@@ -1313,18 +1157,6 @@ void DupInfo::SetId(int id)
|
||||
}
|
||||
}
|
||||
|
||||
void DupInfo::SetName(const char* name)
|
||||
{
|
||||
free(m_name);
|
||||
m_name = strdup(name);
|
||||
}
|
||||
|
||||
void DupInfo::SetDupeKey(const char* dupeKey)
|
||||
{
|
||||
free(m_dupeKey);
|
||||
m_dupeKey = strdup(dupeKey);
|
||||
}
|
||||
|
||||
|
||||
HistoryInfo::HistoryInfo(NzbInfo* nzbInfo)
|
||||
{
|
||||
|
||||
+56
-58
@@ -27,6 +27,7 @@
|
||||
#ifndef DOWNLOADINFO_H
|
||||
#define DOWNLOADINFO_H
|
||||
|
||||
#include "NString.h"
|
||||
#include "Observer.h"
|
||||
#include "Log.h"
|
||||
#include "Thread.h"
|
||||
@@ -83,13 +84,13 @@ public:
|
||||
|
||||
private:
|
||||
int m_partNumber;
|
||||
char* m_messageId;
|
||||
CString m_messageId;
|
||||
int m_size;
|
||||
char* m_segmentContent;
|
||||
CString m_segmentContent;
|
||||
int64 m_segmentOffset;
|
||||
int m_segmentSize;
|
||||
EStatus m_status;
|
||||
char* m_resultFilename;
|
||||
CString m_resultFilename;
|
||||
uint32 m_crc;
|
||||
|
||||
public:
|
||||
@@ -98,7 +99,7 @@ public:
|
||||
void SetPartNumber(int s) { m_partNumber = s; }
|
||||
int GetPartNumber() { return m_partNumber; }
|
||||
const char* GetMessageId() { return m_messageId; }
|
||||
void SetMessageId(const char* messageId);
|
||||
void SetMessageId(const char* messageId) { m_messageId = messageId; }
|
||||
void SetSize(int size) { m_size = size; }
|
||||
int GetSize() { return m_size; }
|
||||
void AttachSegment(char* content, int64 offset, int size);
|
||||
@@ -111,7 +112,7 @@ public:
|
||||
EStatus GetStatus() { return m_status; }
|
||||
void SetStatus(EStatus Status) { m_status = Status; }
|
||||
const char* GetResultFilename() { return m_resultFilename; }
|
||||
void SetResultFilename(const char* v);
|
||||
void SetResultFilename(const char* resultFilename) { m_resultFilename = resultFilename; }
|
||||
uint32 GetCrc() { return m_crc; }
|
||||
void SetCrc(uint32 crc) { m_crc = crc; }
|
||||
};
|
||||
@@ -120,7 +121,7 @@ class FileInfo
|
||||
{
|
||||
public:
|
||||
typedef std::vector<ArticleInfo*> Articles;
|
||||
typedef std::vector<char*> Groups;
|
||||
typedef std::vector<CString> Groups;
|
||||
|
||||
private:
|
||||
int m_id;
|
||||
@@ -128,8 +129,8 @@ private:
|
||||
Articles m_articles;
|
||||
Groups m_groups;
|
||||
ServerStatList m_serverStats;
|
||||
char* m_subject;
|
||||
char* m_filename;
|
||||
CString m_subject;
|
||||
CString m_filename;
|
||||
int64 m_size;
|
||||
int64 m_remainingSize;
|
||||
int64 m_successSize;
|
||||
@@ -146,7 +147,7 @@ private:
|
||||
bool m_parFile;
|
||||
int m_completedArticles;
|
||||
bool m_outputInitialized;
|
||||
char* m_outputFilename;
|
||||
CString m_outputFilename;
|
||||
Mutex* m_mutexOutputFile;
|
||||
bool m_extraPriority;
|
||||
int m_activeDownloads;
|
||||
@@ -170,9 +171,9 @@ public:
|
||||
Articles* GetArticles() { return &m_articles; }
|
||||
Groups* GetGroups() { return &m_groups; }
|
||||
const char* GetSubject() { return m_subject; }
|
||||
void SetSubject(const char* subject);
|
||||
void SetSubject(const char* subject) { m_subject = subject; }
|
||||
const char* GetFilename() { return m_filename; }
|
||||
void SetFilename(const char* filename);
|
||||
void SetFilename(const char* filename) { m_filename = filename; }
|
||||
void MakeValidFilename();
|
||||
bool GetFilenameConfirmed() { return m_filenameConfirmed; }
|
||||
void SetFilenameConfirmed(bool filenameConfirmed) { m_filenameConfirmed = filenameConfirmed; }
|
||||
@@ -208,7 +209,7 @@ public:
|
||||
void LockOutputFile();
|
||||
void UnlockOutputFile();
|
||||
const char* GetOutputFilename() { return m_outputFilename; }
|
||||
void SetOutputFilename(const char* outputFilename);
|
||||
void SetOutputFilename(const char* outputFilename) { m_outputFilename = outputFilename; }
|
||||
bool GetOutputInitialized() { return m_outputInitialized; }
|
||||
void SetOutputInitialized(bool outputInitialized) { m_outputInitialized = outputInitialized; }
|
||||
bool GetExtraPriority() { return m_extraPriority; }
|
||||
@@ -250,15 +251,14 @@ public:
|
||||
|
||||
private:
|
||||
int m_id;
|
||||
char* m_fileName;
|
||||
CString m_fileName;
|
||||
EStatus m_status;
|
||||
uint32 m_crc;
|
||||
|
||||
public:
|
||||
CompletedFile(int id, const char* fileName, EStatus status, uint32 crc);
|
||||
~CompletedFile();
|
||||
int GetId() { return m_id; }
|
||||
void SetFileName(const char* fileName);
|
||||
void SetFileName(const char* fileName) { m_fileName = fileName; }
|
||||
const char* GetFileName() { return m_fileName; }
|
||||
EStatus GetStatus() { return m_status; }
|
||||
uint32 GetCrc() { return m_crc; }
|
||||
@@ -269,16 +269,15 @@ typedef std::deque<CompletedFile*> CompletedFiles;
|
||||
class NzbParameter
|
||||
{
|
||||
private:
|
||||
char* m_name;
|
||||
char* m_value;
|
||||
CString m_name;
|
||||
CString m_value;
|
||||
|
||||
void SetValue(const char* value);
|
||||
void SetValue(const char* value) { m_value = value; }
|
||||
|
||||
friend class NzbParameterList;
|
||||
|
||||
public:
|
||||
NzbParameter(const char* name);
|
||||
~NzbParameter();
|
||||
NzbParameter(const char* name) : m_name(name) {}
|
||||
const char* GetName() { return m_name; }
|
||||
const char* GetValue() { return m_value; }
|
||||
};
|
||||
@@ -306,14 +305,14 @@ public:
|
||||
};
|
||||
|
||||
private:
|
||||
char* m_name;
|
||||
CString m_name;
|
||||
EStatus m_status;
|
||||
|
||||
friend class ScriptStatusList;
|
||||
|
||||
public:
|
||||
ScriptStatus(const char* name, EStatus status);
|
||||
~ScriptStatus();
|
||||
ScriptStatus(const char* name, EStatus status)
|
||||
: m_name(name), m_status(status) {}
|
||||
const char* GetName() { return m_name; }
|
||||
EStatus GetStatus() { return m_status; }
|
||||
};
|
||||
@@ -425,12 +424,12 @@ public:
|
||||
private:
|
||||
int m_id;
|
||||
EKind m_kind;
|
||||
char* m_url;
|
||||
char* m_filename;
|
||||
char* m_name;
|
||||
char* m_destDir;
|
||||
char* m_finalDir;
|
||||
char* m_category;
|
||||
CString m_url;
|
||||
CString m_filename;
|
||||
CString m_name;
|
||||
CString m_destDir;
|
||||
CString m_finalDir;
|
||||
CString m_category;
|
||||
int m_fileCount;
|
||||
int m_parkedFileCount;
|
||||
int64 m_size;
|
||||
@@ -469,7 +468,7 @@ private:
|
||||
bool m_addUrlPaused;
|
||||
bool m_deletePaused;
|
||||
bool m_manyDupeFiles;
|
||||
char* m_queuedFilename;
|
||||
CString m_queuedFilename;
|
||||
bool m_deleting;
|
||||
bool m_avoidHistory;
|
||||
bool m_healthPaused;
|
||||
@@ -477,7 +476,7 @@ private:
|
||||
bool m_parManual;
|
||||
bool m_cleanupDisk;
|
||||
bool m_unpackCleanedUpDisk;
|
||||
char* m_dupeKey;
|
||||
CString m_dupeKey;
|
||||
int m_dupeScore;
|
||||
EDupeMode m_dupeMode;
|
||||
uint32 m_fullContentHash;
|
||||
@@ -519,20 +518,20 @@ public:
|
||||
static int GenerateId();
|
||||
EKind GetKind() { return m_kind; }
|
||||
void SetKind(EKind kind) { m_kind = kind; }
|
||||
const char* GetUrl() { return m_url; } // needs locking (for shared objects)
|
||||
void SetUrl(const char* url); // needs locking (for shared objects)
|
||||
const char* GetUrl() { return m_url; }
|
||||
void SetUrl(const char* url);
|
||||
const char* GetFilename() { return m_filename; }
|
||||
void SetFilename(const char* filename);
|
||||
static void MakeNiceNzbName(const char* nzbFilename, char* buffer, int size, bool removeExt);
|
||||
static void MakeNiceUrlName(const char* url, const char* nzbFilename, char* buffer, int size);
|
||||
const char* GetDestDir() { return m_destDir; } // needs locking (for shared objects)
|
||||
void SetDestDir(const char* destDir); // needs locking (for shared objects)
|
||||
const char* GetFinalDir() { return m_finalDir; } // needs locking (for shared objects)
|
||||
void SetFinalDir(const char* finalDir); // needs locking (for shared objects)
|
||||
const char* GetCategory() { return m_category; } // needs locking (for shared objects)
|
||||
void SetCategory(const char* category); // needs locking (for shared objects)
|
||||
const char* GetName() { return m_name; } // needs locking (for shared objects)
|
||||
void SetName(const char* name); // needs locking (for shared objects)
|
||||
const char* GetDestDir() { return m_destDir; }
|
||||
void SetDestDir(const char* destDir) { m_destDir = destDir; }
|
||||
const char* GetFinalDir() { return m_finalDir; }
|
||||
void SetFinalDir(const char* finalDir) { m_finalDir = finalDir; }
|
||||
const char* GetCategory() { return m_category; }
|
||||
void SetCategory(const char* category) { m_category = category; }
|
||||
const char* GetName() { return m_name; }
|
||||
void SetName(const char* name) { m_name = name; }
|
||||
int GetFileCount() { return m_fileCount; }
|
||||
void SetFileCount(int fileCount) { m_fileCount = fileCount; }
|
||||
int GetParkedFileCount() { return m_parkedFileCount; }
|
||||
@@ -586,7 +585,7 @@ public:
|
||||
void SetMaxTime(time_t maxTime) { m_maxTime = maxTime; }
|
||||
void BuildDestDirName();
|
||||
void BuildFinalDirName(char* finalDirBuf, int bufSize);
|
||||
CompletedFiles* GetCompletedFiles() { return &m_completedFiles; } // needs locking (for shared objects)
|
||||
CompletedFiles* GetCompletedFiles() { return &m_completedFiles; }
|
||||
void ClearCompletedFiles();
|
||||
ERenameStatus GetRenameStatus() { return m_renameStatus; }
|
||||
void SetRenameStatus(ERenameStatus renameStatus) { m_renameStatus = renameStatus; }
|
||||
@@ -607,7 +606,7 @@ public:
|
||||
void SetExtraParBlocks(int extraParBlocks) { m_extraParBlocks = extraParBlocks; }
|
||||
void SetUrlStatus(EUrlStatus urlStatus) { m_urlStatus = urlStatus; }
|
||||
const char* GetQueuedFilename() { return m_queuedFilename; }
|
||||
void SetQueuedFilename(const char* queuedFilename);
|
||||
void SetQueuedFilename(const char* queuedFilename) { m_queuedFilename = queuedFilename; }
|
||||
bool GetDeleting() { return m_deleting; }
|
||||
void SetDeleting(bool deleting) { m_deleting = deleting; }
|
||||
bool GetDeletePaused() { return m_deletePaused; }
|
||||
@@ -626,15 +625,15 @@ public:
|
||||
void SetUnpackCleanedUpDisk(bool unpackCleanedUpDisk) { m_unpackCleanedUpDisk = unpackCleanedUpDisk; }
|
||||
bool GetAddUrlPaused() { return m_addUrlPaused; }
|
||||
void SetAddUrlPaused(bool addUrlPaused) { m_addUrlPaused = addUrlPaused; }
|
||||
FileList* GetFileList() { return &m_fileList; } // needs locking (for shared objects)
|
||||
NzbParameterList* GetParameters() { return &m_ppParameters; } // needs locking (for shared objects)
|
||||
ScriptStatusList* GetScriptStatuses() { return &m_scriptStatuses; } // needs locking (for shared objects)
|
||||
FileList* GetFileList() { return &m_fileList; }
|
||||
NzbParameterList* GetParameters() { return &m_ppParameters; }
|
||||
ScriptStatusList* GetScriptStatuses() { return &m_scriptStatuses; }
|
||||
ServerStatList* GetServerStats() { return &m_serverStats; }
|
||||
ServerStatList* GetCurrentServerStats() { return &m_currentServerStats; }
|
||||
int CalcHealth();
|
||||
int CalcCriticalHealth(bool allowEstimation);
|
||||
const char* GetDupeKey() { return m_dupeKey; } // needs locking (for shared objects)
|
||||
void SetDupeKey(const char* dupeKey); // needs locking (for shared objects)
|
||||
const char* GetDupeKey() { return m_dupeKey; }
|
||||
void SetDupeKey(const char* dupeKey) { m_dupeKey = dupeKey ? dupeKey : ""; }
|
||||
int GetDupeScore() { return m_dupeScore; }
|
||||
void SetDupeScore(int dupeScore) { m_dupeScore = dupeScore; }
|
||||
EDupeMode GetDupeMode() { return m_dupeMode; }
|
||||
@@ -715,7 +714,7 @@ public:
|
||||
ptFinished
|
||||
};
|
||||
|
||||
typedef std::vector<char*> ParredFiles;
|
||||
typedef std::vector<CString> ParredFiles;
|
||||
|
||||
private:
|
||||
NzbInfo* m_nzbInfo;
|
||||
@@ -729,7 +728,7 @@ private:
|
||||
bool m_passListTried;
|
||||
int m_lastUnpackStatus;
|
||||
EStage m_stage;
|
||||
char* m_progressLabel;
|
||||
CString m_progressLabel;
|
||||
int m_fileProgress;
|
||||
int m_stageProgress;
|
||||
time_t m_startTime;
|
||||
@@ -745,7 +744,7 @@ public:
|
||||
void SetNzbInfo(NzbInfo* nzbInfo) { m_nzbInfo = nzbInfo; }
|
||||
EStage GetStage() { return m_stage; }
|
||||
void SetStage(EStage stage) { m_stage = stage; }
|
||||
void SetProgressLabel(const char* progressLabel);
|
||||
void SetProgressLabel(const char* progressLabel) { m_progressLabel = progressLabel; }
|
||||
const char* GetProgressLabel() { return m_progressLabel; }
|
||||
int GetFileProgress() { return m_fileProgress; }
|
||||
void SetFileProgress(int fileProgress) { m_fileProgress = fileProgress; }
|
||||
@@ -798,8 +797,8 @@ public:
|
||||
|
||||
private:
|
||||
int m_id;
|
||||
char* m_name;
|
||||
char* m_dupeKey;
|
||||
CString m_name;
|
||||
CString m_dupeKey;
|
||||
int m_dupeScore;
|
||||
EDupeMode m_dupeMode;
|
||||
int64 m_size;
|
||||
@@ -809,13 +808,12 @@ private:
|
||||
|
||||
public:
|
||||
DupInfo();
|
||||
~DupInfo();
|
||||
int GetId() { return m_id; }
|
||||
void SetId(int id);
|
||||
const char* GetName() { return m_name; } // needs locking (for shared objects)
|
||||
void SetName(const char* name); // needs locking (for shared objects)
|
||||
const char* GetDupeKey() { return m_dupeKey; } // needs locking (for shared objects)
|
||||
void SetDupeKey(const char* dupeKey); // needs locking (for shared objects)
|
||||
const char* GetName() { return m_name; }
|
||||
void SetName(const char* name) { m_name = name; }
|
||||
const char* GetDupeKey() { return m_dupeKey; }
|
||||
void SetDupeKey(const char* dupeKey) { m_dupeKey = dupeKey; }
|
||||
int GetDupeScore() { return m_dupeScore; }
|
||||
void SetDupeScore(int dupeScore) { m_dupeScore = dupeScore; }
|
||||
EDupeMode GetDupeMode() { return m_dupeMode; }
|
||||
|
||||
@@ -36,8 +36,7 @@ NzbFile::NzbFile(const char* fileName, const char* category)
|
||||
{
|
||||
debug("Creating NZBFile");
|
||||
|
||||
m_fileName = strdup(fileName);
|
||||
m_password = NULL;
|
||||
m_fileName = fileName;
|
||||
m_nzbInfo = new NzbInfo();
|
||||
m_nzbInfo->SetFilename(fileName);
|
||||
m_nzbInfo->SetCategory(category);
|
||||
@@ -56,10 +55,6 @@ NzbFile::~NzbFile()
|
||||
{
|
||||
debug("Destroying NZBFile");
|
||||
|
||||
// Cleanup
|
||||
free(m_fileName);
|
||||
free(m_password);
|
||||
|
||||
#ifndef WIN32
|
||||
delete m_fileInfo;
|
||||
free(m_tagContent);
|
||||
@@ -70,7 +65,7 @@ NzbFile::~NzbFile()
|
||||
|
||||
void NzbFile::LogDebugInfo()
|
||||
{
|
||||
info(" NZBFile %s", m_fileName);
|
||||
info(" NZBFile %s", *m_fileName);
|
||||
}
|
||||
|
||||
void NzbFile::AddArticle(FileInfo* fileInfo, ArticleInfo* articleInfo)
|
||||
@@ -484,8 +479,7 @@ void NzbFile::ReadPassword()
|
||||
{
|
||||
*end = '\0';
|
||||
WebUtil::XmlDecode(metaPassword);
|
||||
free(m_password);
|
||||
m_password = strdup(metaPassword);
|
||||
m_password = metaPassword;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -511,7 +505,7 @@ bool NzbFile::Parse()
|
||||
doc->put_validateOnParse(VARIANT_FALSE);
|
||||
doc->put_async(VARIANT_FALSE);
|
||||
|
||||
_variant_t vFilename(m_fileName);
|
||||
_variant_t vFilename(*m_fileName);
|
||||
|
||||
// 1. first trying to load via filename without URL-encoding (certain charaters doesn't work when encoded)
|
||||
VARIANT_BOOL success = doc->load(vFilename);
|
||||
@@ -598,7 +592,7 @@ bool NzbFile::ParseNzb(IUnknown* nzb)
|
||||
if (node)
|
||||
{
|
||||
_bstr_t password(node->Gettext());
|
||||
m_password = strdup(password);
|
||||
m_password = password;
|
||||
}
|
||||
|
||||
MSXML::IXMLDOMNodeListPtr fileList = root->selectNodes("/nzb/file");
|
||||
@@ -623,7 +617,7 @@ bool NzbFile::ParseNzb(IUnknown* nzb)
|
||||
{
|
||||
MSXML::IXMLDOMNodePtr node = groupList->Getitem(g);
|
||||
_bstr_t group = node->Gettext();
|
||||
fileInfo->GetGroups()->push_back(strdup((const char*)group));
|
||||
fileInfo->GetGroups()->push_back((const char*)group);
|
||||
}
|
||||
|
||||
MSXML::IXMLDOMNodeListPtr segmentList = node->selectNodes("segments/segment");
|
||||
@@ -824,7 +818,7 @@ void NzbFile::Parse_EndElement(const char *name)
|
||||
}
|
||||
else if (!strcmp("meta", name) && m_hasPassword)
|
||||
{
|
||||
m_password = strdup(m_tagContent);
|
||||
m_password = m_tagContent;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#ifndef NZBFILE_H
|
||||
#define NZBFILE_H
|
||||
|
||||
#include "NString.h"
|
||||
#include "DownloadInfo.h"
|
||||
|
||||
class NzbFile
|
||||
@@ -36,8 +37,8 @@ public:
|
||||
|
||||
private:
|
||||
NzbInfo* m_nzbInfo;
|
||||
char* m_fileName;
|
||||
char* m_password;
|
||||
CString m_fileName;
|
||||
CString m_password;
|
||||
|
||||
void AddArticle(FileInfo* fileInfo, ArticleInfo* articleInfo);
|
||||
void AddFileInfo(FileInfo* fileInfo);
|
||||
|
||||
@@ -34,27 +34,22 @@
|
||||
|
||||
Scanner::FileData::FileData(const char* filename)
|
||||
{
|
||||
m_filename = strdup(filename);
|
||||
m_filename = filename;
|
||||
m_size = 0;
|
||||
m_lastChange = 0;
|
||||
}
|
||||
|
||||
Scanner::FileData::~FileData()
|
||||
{
|
||||
free(m_filename);
|
||||
}
|
||||
|
||||
|
||||
Scanner::QueueData::QueueData(const char* filename, const char* nzbName, const char* category,
|
||||
int priority, const char* dupeKey, int dupeScore, EDupeMode dupeMode,
|
||||
NzbParameterList* parameters, bool addTop, bool addPaused, NzbInfo* urlInfo,
|
||||
EAddStatus* addStatus, int* nzbId)
|
||||
{
|
||||
m_filename = strdup(filename);
|
||||
m_nzbName = strdup(nzbName);
|
||||
m_category = strdup(category ? category : "");
|
||||
m_filename = filename;
|
||||
m_nzbName = nzbName;
|
||||
m_category = category ? category : "";
|
||||
m_priority = priority;
|
||||
m_dupeKey = strdup(dupeKey ? dupeKey : "");
|
||||
m_dupeKey = dupeKey ? dupeKey : "";
|
||||
m_dupeScore = dupeScore;
|
||||
m_dupeMode = dupeMode;
|
||||
m_addTop = addTop;
|
||||
@@ -69,14 +64,6 @@ Scanner::QueueData::QueueData(const char* filename, const char* nzbName, const c
|
||||
}
|
||||
}
|
||||
|
||||
Scanner::QueueData::~QueueData()
|
||||
{
|
||||
free(m_filename);
|
||||
free(m_nzbName);
|
||||
free(m_category);
|
||||
free(m_dupeKey);
|
||||
}
|
||||
|
||||
void Scanner::QueueData::SetAddStatus(EAddStatus addStatus)
|
||||
{
|
||||
if (m_addStatus)
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#ifndef SCANNER_H
|
||||
#define SCANNER_H
|
||||
|
||||
#include "NString.h"
|
||||
#include "DownloadInfo.h"
|
||||
#include "Thread.h"
|
||||
#include "Service.h"
|
||||
@@ -44,13 +45,12 @@ private:
|
||||
class FileData
|
||||
{
|
||||
private:
|
||||
char* m_filename;
|
||||
CString m_filename;
|
||||
int64 m_size;
|
||||
time_t m_lastChange;
|
||||
|
||||
public:
|
||||
FileData(const char* filename);
|
||||
~FileData();
|
||||
const char* GetFilename() { return m_filename; }
|
||||
int64 GetSize() { return m_size; }
|
||||
void SetSize(int64 size) { m_size = size; }
|
||||
@@ -63,11 +63,11 @@ private:
|
||||
class QueueData
|
||||
{
|
||||
private:
|
||||
char* m_filename;
|
||||
char* m_nzbName;
|
||||
char* m_category;
|
||||
CString m_filename;
|
||||
CString m_nzbName;
|
||||
CString m_category;
|
||||
int m_priority;
|
||||
char* m_dupeKey;
|
||||
CString m_dupeKey;
|
||||
int m_dupeScore;
|
||||
EDupeMode m_dupeMode;
|
||||
NzbParameterList m_parameters;
|
||||
@@ -82,7 +82,6 @@ private:
|
||||
int priority, const char* dupeKey, int dupeScore, EDupeMode dupeMode,
|
||||
NzbParameterList* parameters, bool addTop, bool addPaused, NzbInfo* urlInfo,
|
||||
EAddStatus* addStatus, int* nzbId);
|
||||
~QueueData();
|
||||
const char* GetFilename() { return m_filename; }
|
||||
const char* GetNzbName() { return m_nzbName; }
|
||||
const char* GetCategory() { return m_category; }
|
||||
|
||||
@@ -33,28 +33,17 @@
|
||||
#include "DiskState.h"
|
||||
#include "QueueScript.h"
|
||||
|
||||
UrlDownloader::UrlDownloader() : WebDownloader()
|
||||
{
|
||||
m_category = NULL;
|
||||
}
|
||||
|
||||
UrlDownloader::~UrlDownloader()
|
||||
{
|
||||
free(m_category);
|
||||
}
|
||||
|
||||
void UrlDownloader::ProcessHeader(const char* line)
|
||||
{
|
||||
WebDownloader::ProcessHeader(line);
|
||||
|
||||
if (!strncmp(line, "X-DNZB-Category:", 16))
|
||||
{
|
||||
free(m_category);
|
||||
char* category = strdup(line + 16);
|
||||
m_category = strdup(Util::Trim(category));
|
||||
m_category = Util::Trim(category);
|
||||
free(category);
|
||||
|
||||
debug("Category: %s", m_category);
|
||||
debug("Category: %s", *m_category);
|
||||
}
|
||||
else if (!strncmp(line, "X-DNZB-", 7))
|
||||
{
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#ifndef URLCOORDINATOR_H
|
||||
#define URLCOORDINATOR_H
|
||||
|
||||
#include "NString.h"
|
||||
#include "Log.h"
|
||||
#include "Thread.h"
|
||||
#include "WebDownloader.h"
|
||||
@@ -71,14 +72,12 @@ class UrlDownloader : public WebDownloader
|
||||
{
|
||||
private:
|
||||
NzbInfo* m_nzbInfo;
|
||||
char* m_category;
|
||||
CString m_category;
|
||||
|
||||
protected:
|
||||
virtual void ProcessHeader(const char* line);
|
||||
|
||||
public:
|
||||
UrlDownloader();
|
||||
~UrlDownloader();
|
||||
void SetNzbInfo(NzbInfo* nzbInfo) { m_nzbInfo = nzbInfo; }
|
||||
NzbInfo* GetNzbInfo() { return m_nzbInfo; }
|
||||
const char* GetCategory() { return m_category; }
|
||||
|
||||
@@ -76,14 +76,12 @@ WebProcessor::WebProcessor()
|
||||
m_connection = NULL;
|
||||
m_request = NULL;
|
||||
m_url = NULL;
|
||||
m_origin = NULL;
|
||||
}
|
||||
|
||||
WebProcessor::~WebProcessor()
|
||||
{
|
||||
free(m_request);
|
||||
free(m_url);
|
||||
free(m_origin);
|
||||
}
|
||||
|
||||
void WebProcessor::SetUrl(const char* url)
|
||||
@@ -168,7 +166,7 @@ void WebProcessor::ParseHeaders()
|
||||
}
|
||||
if (!strncasecmp(p, "Origin: ", 8))
|
||||
{
|
||||
m_origin = strdup(p + 8);
|
||||
m_origin = p + 8;
|
||||
}
|
||||
if (!strncasecmp(p, "X-Auth-Token: ", 14))
|
||||
{
|
||||
@@ -395,7 +393,7 @@ void WebProcessor::SendOptionsResponse()
|
||||
"\r\n";
|
||||
char responseHeader[1024];
|
||||
snprintf(responseHeader, 1024, OPTIONS_RESPONSE_HEADER,
|
||||
m_origin ? m_origin : "",
|
||||
m_origin.Str(),
|
||||
Util::VersionRevision());
|
||||
|
||||
// Send the response answer
|
||||
@@ -499,7 +497,7 @@ void WebProcessor::SendBodyResponse(const char* body, int bodyLen, const char* c
|
||||
|
||||
char responseHeader[1024];
|
||||
snprintf(responseHeader, 1024, RESPONSE_HEADER,
|
||||
m_origin ? m_origin : "",
|
||||
m_origin.Str(),
|
||||
m_serverAuthToken[m_userAccess], bodyLen, contentTypeHeader,
|
||||
gzip ? "Content-Encoding: gzip\r\n" : "",
|
||||
Util::VersionRevision());
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#ifndef WEBSERVER_H
|
||||
#define WEBSERVER_H
|
||||
|
||||
#include "NString.h"
|
||||
#include "Connection.h"
|
||||
|
||||
class WebProcessor
|
||||
@@ -52,7 +53,7 @@ private:
|
||||
EHttpMethod m_httpMethod;
|
||||
EUserAccess m_userAccess;
|
||||
bool m_gzip;
|
||||
char* m_origin;
|
||||
CString m_origin;
|
||||
int m_contentLen;
|
||||
char m_authInfo[256+1];
|
||||
char m_authToken[48+1];
|
||||
|
||||
@@ -319,18 +319,12 @@ XmlRpcProcessor::XmlRpcProcessor()
|
||||
m_request = NULL;
|
||||
m_protocol = rpUndefined;
|
||||
m_httpMethod = hmPost;
|
||||
m_url = NULL;
|
||||
m_contentType = NULL;
|
||||
}
|
||||
|
||||
XmlRpcProcessor::~XmlRpcProcessor()
|
||||
{
|
||||
free(m_url);
|
||||
}
|
||||
|
||||
void XmlRpcProcessor::SetUrl(const char* url)
|
||||
{
|
||||
m_url = strdup(url);
|
||||
m_url = url;
|
||||
WebUtil::UrlDecode(m_url);
|
||||
}
|
||||
|
||||
@@ -359,7 +353,7 @@ void XmlRpcProcessor::Execute()
|
||||
}
|
||||
else
|
||||
{
|
||||
error("internal error: invalid rpc-request: %s", m_url);
|
||||
error("internal error: invalid rpc-request: %s", *m_url);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#ifndef XMLRPC_H
|
||||
#define XMLRPC_H
|
||||
|
||||
#include "NString.h"
|
||||
#include "Connection.h"
|
||||
#include "Util.h"
|
||||
|
||||
@@ -61,7 +62,7 @@ private:
|
||||
ERpcProtocol m_protocol;
|
||||
EHttpMethod m_httpMethod;
|
||||
EUserAccess m_userAccess;
|
||||
char* m_url;
|
||||
CString m_url;
|
||||
StringBuilder m_response;
|
||||
|
||||
void Dispatch();
|
||||
@@ -71,7 +72,6 @@ private:
|
||||
|
||||
public:
|
||||
XmlRpcProcessor();
|
||||
~XmlRpcProcessor();
|
||||
void Execute();
|
||||
void SetHttpMethod(EHttpMethod httpMethod) { m_httpMethod = httpMethod; }
|
||||
void SetUserAccess(EUserAccess userAccess) { m_userAccess = userAccess; }
|
||||
|
||||
+4
-19
@@ -46,7 +46,6 @@ Log::Log()
|
||||
m_messages.clear();
|
||||
m_idGen = 0;
|
||||
m_optInit = false;
|
||||
m_logFilename = NULL;
|
||||
m_lastWritten = 0;
|
||||
#ifdef DEBUG
|
||||
m_extraDebug = Util::FileExists("extradebug");
|
||||
@@ -56,7 +55,6 @@ Log::Log()
|
||||
Log::~Log()
|
||||
{
|
||||
Clear();
|
||||
free(m_logFilename);
|
||||
}
|
||||
|
||||
void Log::LogDebugInfo()
|
||||
@@ -78,7 +76,7 @@ void Log::LogDebugInfo()
|
||||
|
||||
void Log::Filelog(const char* msg, ...)
|
||||
{
|
||||
if (!m_logFilename)
|
||||
if (m_logFilename.Empty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -292,19 +290,7 @@ Message::Message(uint32 id, EKind kind, time_t time, const char* text)
|
||||
m_id = id;
|
||||
m_kind = kind;
|
||||
m_time = time;
|
||||
if (text)
|
||||
{
|
||||
m_text = strdup(text);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_text = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
Message::~ Message()
|
||||
{
|
||||
free(m_text);
|
||||
m_text = text;
|
||||
}
|
||||
|
||||
MessageList::~MessageList()
|
||||
@@ -429,8 +415,7 @@ void Log::RotateLog()
|
||||
baseName, tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, baseExt);
|
||||
fullFilename[1024-1] = '\0';
|
||||
|
||||
free(m_logFilename);
|
||||
m_logFilename = strdup(fullFilename);
|
||||
m_logFilename = fullFilename;
|
||||
#ifdef WIN32
|
||||
WebUtil::Utf8ToAnsi(m_logFilename, strlen(m_logFilename) + 1);
|
||||
#endif
|
||||
@@ -451,7 +436,7 @@ void Log::InitOptions()
|
||||
|
||||
if (g_Options->GetWriteLog() != Options::wlNone && g_Options->GetLogFile())
|
||||
{
|
||||
m_logFilename = strdup(g_Options->GetLogFile());
|
||||
m_logFilename = g_Options->GetLogFile();
|
||||
#ifdef WIN32
|
||||
WebUtil::Utf8ToAnsi(m_logFilename, strlen(m_logFilename) + 1);
|
||||
#endif
|
||||
|
||||
+3
-3
@@ -27,6 +27,7 @@
|
||||
#ifndef LOG_H
|
||||
#define LOG_H
|
||||
|
||||
#include "NString.h"
|
||||
#include "Thread.h"
|
||||
|
||||
void error(const char* msg, ...);
|
||||
@@ -58,13 +59,12 @@ private:
|
||||
uint32 m_id;
|
||||
EKind m_kind;
|
||||
time_t m_time;
|
||||
char* m_text;
|
||||
CString m_text;
|
||||
|
||||
friend class Log;
|
||||
|
||||
public:
|
||||
Message(uint32 id, EKind kind, time_t time, const char* text);
|
||||
~Message();
|
||||
uint32 GetId() { return m_id; }
|
||||
EKind GetKind() { return m_kind; }
|
||||
time_t GetTime() { return m_time; }
|
||||
@@ -97,7 +97,7 @@ private:
|
||||
MessageList m_messages;
|
||||
Debuggables m_debuggables;
|
||||
Mutex m_debugMutex;
|
||||
char* m_logFilename;
|
||||
CString m_logFilename;
|
||||
uint32 m_idGen;
|
||||
time_t m_lastWritten;
|
||||
bool m_optInit;
|
||||
|
||||
Reference in new issue
Block a user