aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs63
1 files changed, 63 insertions, 0 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index 0650b90..828288d 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -3647,5 +3647,68 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3647 3647
3648 DropAttachmentAt(false, pos, rot); 3648 DropAttachmentAt(false, pos, rot);
3649 } 3649 }
3650
3651 public LSL_Integer osListenRegex(int channelID, string name, string ID, string msg, int regexBitfield)
3652 {
3653 CheckThreatLevel(ThreatLevel.Low, "osListenRegex");
3654 m_host.AddScriptLPS(1);
3655 UUID keyID;
3656 UUID.TryParse(ID, out keyID);
3657
3658 // if we want the name to be used as a regular expression, ensure it is valid first.
3659 if ((regexBitfield & ScriptBaseClass.OS_LISTEN_REGEX_NAME) == ScriptBaseClass.OS_LISTEN_REGEX_NAME)
3660 {
3661 try
3662 {
3663 Regex.IsMatch("", name);
3664 }
3665 catch (Exception)
3666 {
3667 OSSLShoutError("Name regex is invalid.");
3668 return -1;
3669 }
3670 }
3671
3672 // if we want the msg to be used as a regular expression, ensure it is valid first.
3673 if ((regexBitfield & ScriptBaseClass.OS_LISTEN_REGEX_MESSAGE) == ScriptBaseClass.OS_LISTEN_REGEX_MESSAGE)
3674 {
3675 try
3676 {
3677 Regex.IsMatch("", msg);
3678 }
3679 catch (Exception)
3680 {
3681 OSSLShoutError("Message regex is invalid.");
3682 return -1;
3683 }
3684 }
3685
3686 IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>();
3687 return (wComm == null) ? -1 : wComm.Listen(
3688 m_host.LocalId,
3689 m_item.ItemID,
3690 m_host.UUID,
3691 channelID,
3692 name,
3693 keyID,
3694 msg,
3695 regexBitfield
3696 );
3697 }
3698
3699 public LSL_Integer osRegexIsMatch(string input, string pattern)
3700 {
3701 CheckThreatLevel(ThreatLevel.Low, "osRegexIsMatch");
3702 m_host.AddScriptLPS(1);
3703 try
3704 {
3705 return Regex.IsMatch(input, pattern) ? 1 : 0;
3706 }
3707 catch (Exception)
3708 {
3709 OSSLShoutError("Possible invalid regular expression detected.");
3710 return 0;
3711 }
3712 }
3650 } 3713 }
3651} 3714}