virtual void OnGetAvailableMods(set<CModInfo>& ssMods, CModInfo::EModuleType eType) { unsigned int a = 0; CDir Dir; CModules::ModDirList dirs = CModules::GetModDirs(); while (!dirs.empty()) { Dir.FillByWildcard(dirs.front().first, "*.pm"); dirs.pop(); for (a = 0; a < Dir.size(); a++) { CFile& File = *Dir[a]; CString sName = File.GetShortName(); CString sPath = File.GetLongName(); CModInfo ModInfo; sName.RightChomp(3); PSTART; PUSH_STR(sPath); PUSH_STR(sName); PUSH_PTR(CModInfo*, &ModInfo); PCALL("ZNC::Core::ModInfoByPath"); if (!SvTRUE(ERRSV) && ret == 2) { ssMods.insert(ModInfo); } PEND; } } }
virtual EModRet OnModuleLoading(const CString& sModName, const CString& sArgs, CModInfo::EModuleType eType, bool& bSuccess, CString& sRetMsg) { EModRet result = HALT; PSTART; PUSH_STR(sModName); PUSH_STR(sArgs); mXPUSHi(eType); PUSH_PTR(CUser*, GetUser()); PUSH_PTR(CIRCNetwork*, GetNetwork()); PCALL("ZNC::Core::LoadModule"); if (SvTRUE(ERRSV)) { sRetMsg = PString(ERRSV); bSuccess = false; result = HALT; DEBUG("Perl ZNC::Core::LoadModule died: " << sRetMsg); } else if (ret < 1 || 2 < ret) { sRetMsg = "Error: Perl ZNC::Core::LoadModule returned " + CString(ret) + " values."; bSuccess = false; result = HALT; } else { ELoadPerlMod eLPM = static_cast<ELoadPerlMod>(SvUV(ST(0))); if (Perl_NotFound == eLPM) { result = CONTINUE; // Not a Perl module } else { sRetMsg = PString(ST(1)); result = HALT; bSuccess = eLPM == Perl_Loaded; } } PEND; return result; }
virtual void OnGetAvailableMods(set<CModInfo>& ssMods, bool bGlobal) { if (bGlobal) { return; } unsigned int a = 0; CDir Dir; CModules::ModDirList dirs = CModules::GetModDirs(); while (!dirs.empty()) { Dir.FillByWildcard(dirs.front().first, "*.pm"); dirs.pop(); for (a = 0; a < Dir.size(); a++) { CFile& File = *Dir[a]; CString sName = File.GetShortName(); CString sPath = File.GetLongName(); CModInfo ModInfo; sName.RightChomp(3); PSTART; PUSH_STR(sPath); PUSH_STR(sName); PCALL("ZNC::Core::ModInfoByPath"); if (!SvTRUE(ERRSV) && ret == 1) { ModInfo.SetGlobal(false); ModInfo.SetDescription(PString(ST(0))); ModInfo.SetName(sName); ModInfo.SetPath(sPath); ssMods.insert(ModInfo); } PEND; } } }
void CPerlSocket::ReadLine(const CString& sLine) { CPerlModule* pMod = AsPerlModule(GetModule()); if (pMod) { SOCKSTART; PUSH_STR("OnReadLine"); PUSH_STR(sLine); SOCKCBCHECK(); } }
CPerlTimer::~CPerlTimer() { CPerlModule* pMod = AsPerlModule(GetModule()); if (pMod) { PSTART; PUSH_STR(pMod->GetPerlID()); PUSH_STR(GetPerlID()); PCALL("ZNC::Core::RemoveTimer"); PEND; } }
void CPerlTimer::RunJob() { CPerlModule* pMod = AsPerlModule(GetModule()); if (pMod) { PSTART; PUSH_STR(pMod->GetPerlID()); PUSH_STR(GetPerlID()); PCALL("ZNC::Core::CallTimer"); PEND; } }
Csock* CPerlSocket::GetSockObj(const CString& sHost, unsigned short uPort) { CPerlModule* pMod = AsPerlModule(GetModule()); Csock* result = NULL; if (pMod) { SOCKSTART; PUSH_STR("_Accepted"); PUSH_STR(sHost); mXPUSHi(uPort); SOCKCBCHECK( result = SvToPtr<CPerlSocket>("CPerlSocket*")(ST(0)); ); }
ELoadPerlMod LoadPerlModule(const CString& sModule, const CString& sArgs, CUser* pUser, CString& sRetMsg) { ELoadPerlMod result = Perl_LoadError; PSTART; PUSH_STR(sModule); PUSH_STR(sArgs); PUSH_PTR(CUser*, pUser); PCALL("ZNC::Core::LoadModule"); if (SvTRUE(ERRSV)) { sRetMsg = PString(ERRSV); } else if (2 == ret) { result = static_cast<ELoadPerlMod>(SvUV(ST(0))); sRetMsg = PString(ST(1)); } DEBUG(__PRETTY_FUNCTION__ << " " << sRetMsg); PEND; return result; }
void CPerlSocket::ReadData(const char *data, size_t len) { CPerlModule* pMod = AsPerlModule(GetModule()); if (pMod) { SOCKSTART; PUSH_STR("OnReadData"); XPUSHs(sv_2mortal(newSVpvn(data, len))); mXPUSHi(len); SOCKCBCHECK(); } }
int usc_mrcp_service_set_option(HANDLE_MRCPINTF Handle,int option_id, const char* value) { char buf[48]; off_t offset = 0; PUSH_FUN(buf, offset, sizeof(buf)); PUSH_INT(buf, offset, sizeof(buf), option_id, sizeof(option_id)); PUSH_STR(buf, offset, sizeof(buf), value); PUSH_HEAD(buf, offset, sizeof(buf)); writen(Handle, buf, offset + 4); return 0; }
virtual EModRet OnGetModInfo(CModInfo& ModInfo, const CString& sModule, bool& bSuccess, CString& sRetMsg) { PSTART; PUSH_STR(sModule); PCALL("ZNC::Core::GetModInfo"); EModRet result = CONTINUE; if (SvTRUE(ERRSV)) { bSuccess = false; sRetMsg = PString(ERRSV); } else if (0 < ret) { switch(static_cast<ELoadPerlMod>(SvUV(ST(0)))) { case Perl_NotFound: result = CONTINUE; break; case Perl_Loaded: result = HALT; if (3 == ret) { ModInfo.SetGlobal(false); ModInfo.SetDescription(PString(ST(2))); ModInfo.SetName(sModule); ModInfo.SetPath(PString(ST(1))); bSuccess = true; } else { bSuccess = false; sRetMsg = "Something weird happened"; } break; case Perl_LoadError: result = HALT; bSuccess = false; if (2 == ret) { sRetMsg = PString(ST(1)); } else { sRetMsg = "Something weird happened"; } } } else { result = HALT; bSuccess = false; sRetMsg = "Something weird happened"; } PEND; DEBUG(__PRETTY_FUNCTION__ << " " << sRetMsg); return result; }
virtual EModRet OnGetModInfo(CModInfo& ModInfo, const CString& sModule, bool& bSuccess, CString& sRetMsg) { PSTART; PUSH_STR(sModule); PUSH_PTR(CModInfo*, &ModInfo); PCALL("ZNC::Core::GetModInfo"); EModRet result = CONTINUE; if (SvTRUE(ERRSV)) { bSuccess = false; sRetMsg = PString(ERRSV); } else if (0 < ret) { switch(static_cast<ELoadPerlMod>(SvUV(ST(0)))) { case Perl_NotFound: result = CONTINUE; break; case Perl_Loaded: result = HALT; if (1 == ret) { bSuccess = true; } else { bSuccess = false; sRetMsg = "Something weird happened"; } break; case Perl_LoadError: result = HALT; bSuccess = false; if (2 == ret) { sRetMsg = PString(ST(1)); } else { sRetMsg = "Something weird happened"; } } } else { result = HALT; bSuccess = false; sRetMsg = "Something weird happened"; } PEND; return result; }
/* *|---------total len------------| *|--4 bytes---|offset len-------| */ int usc_mrcp_asr_init(HANDLE_MRCPINTF* asr, const char* configFile,unsigned int sessionNum) { char buf[512]; off_t offset = 0; //private_init(); int s = sock_connect(ip, port); if (s == -1) return -1; *asr = s; PUSH_FUN(buf, offset, sizeof(buf)); PUSH_STR(buf, offset, sizeof(buf), configFile); PUSH_INT(buf, offset, sizeof(buf), sessionNum, sizeof(unsigned int)); PUSH_HEAD(buf, offset, sizeof(buf)); writen(s, buf, offset + 4); /*read return value*/ return 0; }