Token tokCopy(Token t) { TokenTag tag = tokTag(t); switch (tag) { case TK_Id: case TK_Blank: return tokNew(t->pos, t->end, tag, t->val.sym); case TK_Int: case TK_Float: case TK_String: case TK_Comment: case TK_PreDoc: case TK_PostDoc: case TK_SysCmd: case TK_Error: return tokNew(t->pos, t->end, tag, t->val.str); default: return tokNew(t->pos, t->end, tag, t->val.str); } }
void QueueEditor::SetNzbCategory(NzbInfo* nzbInfo, const char* category, bool applyParams) { debug("QueueEditor: setting category '%s' for '%s'", category, nzbInfo->GetName()); bool oldUnpack = g_Options->GetUnpack(); const char* oldPostScript = g_Options->GetPostScript(); if (applyParams && !Util::EmptyStr(nzbInfo->GetCategory())) { Options::Category* categoryObj = g_Options->FindCategory(nzbInfo->GetCategory(), false); if (categoryObj) { oldUnpack = categoryObj->GetUnpack(); if (!Util::EmptyStr(categoryObj->GetPostScript())) { oldPostScript = categoryObj->GetPostScript(); } } } g_QueueCoordinator->SetQueueEntryCategory(m_downloadQueue, nzbInfo, category); if (!applyParams) { return; } bool newUnpack = g_Options->GetUnpack(); const char* newPostScript = g_Options->GetPostScript(); if (!Util::EmptyStr(nzbInfo->GetCategory())) { Options::Category* categoryObj = g_Options->FindCategory(nzbInfo->GetCategory(), false); if (categoryObj) { newUnpack = categoryObj->GetUnpack(); if (!Util::EmptyStr(categoryObj->GetPostScript())) { newPostScript = categoryObj->GetPostScript(); } } } if (oldUnpack != newUnpack) { nzbInfo->GetParameters()->SetParameter("*Unpack:", newUnpack ? "yes" : "no"); } if (strcasecmp(oldPostScript, newPostScript)) { // add new params not existed in old category Tokenizer tokNew(newPostScript, ",;"); while (const char* newScriptName = tokNew.Next()) { bool found = false; const char* oldScriptName; Tokenizer tokOld(oldPostScript, ",;"); while ((oldScriptName = tokOld.Next()) && !found) { found = !strcasecmp(newScriptName, oldScriptName); } if (!found) { nzbInfo->GetParameters()->SetParameter(BString<1024>("%s:", newScriptName), "yes"); } } // remove old params not existed in new category Tokenizer tokOld(oldPostScript, ",;"); while (const char* oldScriptName = tokOld.Next()) { bool found = false; const char* newScriptName; Tokenizer tokNew(newPostScript, ",;"); while ((newScriptName = tokNew.Next()) && !found) { found = !strcasecmp(newScriptName, oldScriptName); } if (!found) { nzbInfo->GetParameters()->SetParameter(BString<1024>("%s:", oldScriptName), "no"); } } } }