modperl: Fail if modperl.pm can not be loaded

git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1147 726aef4b-f618-498e-8847-2d620e286838
This commit is contained in:
psychon
2008-07-24 10:16:52 +00:00
parent 13dd3996d5
commit 3106f3b90e
+18 -14
View File
@@ -238,23 +238,24 @@ public:
m_pPerl = NULL;
}
void SetupZNCScript()
bool SetupZNCScript()
{
CString sModule, sTmp;
if (CZNC::Get().FindModPath("modperl.pm", sModule, sTmp))
{
CString sBuffer, sScript;
CFile cFile(sModule);
if ((cFile.Exists()) && (cFile.Open(O_RDONLY)))
{
while (cFile.ReadLine(sBuffer))
sScript += sBuffer;
cFile.Close();
if (!CZNC::Get().FindModPath("modperl.pm", sModule, sTmp))
return false;
eval_pv(sScript.c_str(), FALSE);
}
}
CString sBuffer, sScript;
CFile cFile(sModule);
if (!cFile.Exists() || !cFile.Open(O_RDONLY))
return false;
while (cFile.ReadLine(sBuffer))
sScript += sBuffer;
cFile.Close();
eval_pv(sScript.c_str(), FALSE);
return true;
}
virtual EModRet OnConfigLine(const CString& sName, const CString& sValue, CUser* pUser, CChan* pChan)
@@ -1016,7 +1017,10 @@ bool CModPerl::OnLoad(const CString & sArgs, CString & sMessage)
newXS("ZNC::SetSockValue", XS_ZNC_SetSockValue, "modperl");
// this sets up the eval CB that we call from here on out. this way we can grab the error produced
SetupZNCScript();
if (!SetupZNCScript()) {
sMessage = "Failed to load modperl.pm";
return false;
}
HV *pZNCSpace = get_hv("ZNC::", TRUE);