diff options
Diffstat (limited to 'OpenSim/Region')
3 files changed, 237 insertions, 1 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index e9a3d0b..f0177db 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | |||
@@ -5130,5 +5130,180 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
5130 | UserAccount account = World.UserAccountService.GetUserAccount(World.RegionInfo.ScopeID, key); | 5130 | UserAccount account = World.UserAccountService.GetUserAccount(World.RegionInfo.ScopeID, key); |
5131 | return account.UserCountry; | 5131 | return account.UserCountry; |
5132 | } | 5132 | } |
5133 | |||
5134 | public LSL_String osStringSubString(LSL_String src, LSL_Integer offset) | ||
5135 | { | ||
5136 | m_host.AddScriptLPS(1); | ||
5137 | CheckThreatLevel(); | ||
5138 | |||
5139 | if (string.IsNullOrEmpty(src)) | ||
5140 | return ""; | ||
5141 | if (offset >= src.Length) | ||
5142 | return ""; | ||
5143 | if (offset <= 0) | ||
5144 | return src; | ||
5145 | return ((string)src).Substring(offset); | ||
5146 | } | ||
5147 | |||
5148 | public LSL_String osStringSubString(LSL_String src, LSL_Integer offset, LSL_Integer length) | ||
5149 | { | ||
5150 | m_host.AddScriptLPS(1); | ||
5151 | CheckThreatLevel(); | ||
5152 | |||
5153 | if (string.IsNullOrEmpty(src)) | ||
5154 | return ""; | ||
5155 | if (length <= 0 || offset >= src.Length) | ||
5156 | return ""; | ||
5157 | if (offset <= 0) | ||
5158 | { | ||
5159 | if(length == src.Length) | ||
5160 | return src; | ||
5161 | offset = 0; | ||
5162 | } | ||
5163 | if (length > src.Length - offset) | ||
5164 | length = src.Length - offset; | ||
5165 | return ((string)src).Substring(offset, length); | ||
5166 | } | ||
5167 | |||
5168 | public LSL_Integer osStringStartsWith(LSL_String src, LSL_String value, LSL_Integer ignorecase) | ||
5169 | { | ||
5170 | m_host.AddScriptLPS(1); | ||
5171 | CheckThreatLevel(); | ||
5172 | |||
5173 | if (string.IsNullOrEmpty(src)) | ||
5174 | return 0; | ||
5175 | if (string.IsNullOrEmpty(value)) | ||
5176 | return 0; | ||
5177 | |||
5178 | bool ign = (ignorecase != 0); | ||
5179 | return ((string)src).StartsWith(value, ignorecase, Culture.GetDefaultCurrentCulture()) ? 1 : 0; | ||
5180 | } | ||
5181 | |||
5182 | public LSL_Integer osStringEndsWith(LSL_String src, LSL_String value, LSL_Integer ignorecase) | ||
5183 | { | ||
5184 | m_host.AddScriptLPS(1); | ||
5185 | CheckThreatLevel(); | ||
5186 | |||
5187 | if (string.IsNullOrEmpty(src)) | ||
5188 | return 0; | ||
5189 | if (string.IsNullOrEmpty(value)) | ||
5190 | return 0; | ||
5191 | |||
5192 | bool ign = (ignorecase != 0); | ||
5193 | return ((string)src).EndsWith(value, ign, Culture.GetDefaultCurrentCulture()) ? 1 : 0; | ||
5194 | } | ||
5195 | |||
5196 | public LSL_Integer osStringIndexOf(LSL_String src, LSL_String value, LSL_Integer ignorecase) | ||
5197 | { | ||
5198 | m_host.AddScriptLPS(1); | ||
5199 | CheckThreatLevel(); | ||
5200 | |||
5201 | if (string.IsNullOrEmpty(src)) | ||
5202 | return -1; | ||
5203 | if (string.IsNullOrEmpty(value)) | ||
5204 | return -1; | ||
5205 | |||
5206 | if (ignorecase == 0) | ||
5207 | return ((string)src).IndexOf(value, StringComparison.CurrentCulture); | ||
5208 | return ((string)src).IndexOf(value, StringComparison.CurrentCultureIgnoreCase); | ||
5209 | } | ||
5210 | |||
5211 | public LSL_Integer osStringIndexOf(LSL_String src, LSL_String value, | ||
5212 | LSL_Integer offset, LSL_Integer count, LSL_Integer ignorecase) | ||
5213 | { | ||
5214 | m_host.AddScriptLPS(1); | ||
5215 | CheckThreatLevel(); | ||
5216 | |||
5217 | if (string.IsNullOrEmpty(src)) | ||
5218 | return -1; | ||
5219 | if (string.IsNullOrEmpty(value)) | ||
5220 | return -1; | ||
5221 | if (offset >= src.Length) | ||
5222 | return -1; | ||
5223 | else if (offset < 0) | ||
5224 | offset = 0; | ||
5225 | |||
5226 | if (count <= 0) | ||
5227 | count = src.Length - offset; | ||
5228 | else if (count > src.Length - offset) | ||
5229 | count = src.Length - offset; | ||
5230 | |||
5231 | if (ignorecase == 0) | ||
5232 | return ((string)src).IndexOf(value, offset, count, StringComparison.CurrentCulture); | ||
5233 | return ((string)src).IndexOf(value, offset, count, StringComparison.CurrentCultureIgnoreCase); | ||
5234 | } | ||
5235 | |||
5236 | public LSL_Integer osStringLastIndexOf(LSL_String src, LSL_String value, LSL_Integer ignorecase) | ||
5237 | { | ||
5238 | m_host.AddScriptLPS(1); | ||
5239 | CheckThreatLevel(); | ||
5240 | |||
5241 | if (string.IsNullOrEmpty(src)) | ||
5242 | return -1; | ||
5243 | if (string.IsNullOrEmpty(value)) | ||
5244 | return -1; | ||
5245 | |||
5246 | if (ignorecase == 0) | ||
5247 | return ((string)src).LastIndexOf(value, StringComparison.CurrentCulture); | ||
5248 | return ((string)src).LastIndexOf(value, StringComparison.CurrentCultureIgnoreCase); | ||
5249 | } | ||
5250 | |||
5251 | public LSL_Integer osStringLastIndexOf(LSL_String src, LSL_String value, | ||
5252 | LSL_Integer offset, LSL_Integer count, LSL_Integer ignorecase) | ||
5253 | { | ||
5254 | m_host.AddScriptLPS(1); | ||
5255 | CheckThreatLevel(); | ||
5256 | |||
5257 | if (string.IsNullOrEmpty(src)) | ||
5258 | return -1; | ||
5259 | if (string.IsNullOrEmpty(value)) | ||
5260 | return -1; | ||
5261 | if (offset >= src.Length) | ||
5262 | return -1; | ||
5263 | if (offset < 0) | ||
5264 | offset = 0; | ||
5265 | |||
5266 | if (count <= 0) | ||
5267 | count = src.Length - offset; | ||
5268 | else if (count > src.Length - offset) | ||
5269 | count = src.Length - offset; | ||
5270 | |||
5271 | if (ignorecase == 0) | ||
5272 | return ((string)src).LastIndexOf(value, offset, count, StringComparison.CurrentCulture); | ||
5273 | return ((string)src).LastIndexOf(value, offset, count, StringComparison.CurrentCultureIgnoreCase); | ||
5274 | } | ||
5275 | |||
5276 | public LSL_String osStringRemove(LSL_String src, LSL_Integer offset, LSL_Integer count) | ||
5277 | { | ||
5278 | if (string.IsNullOrEmpty(src)) | ||
5279 | return ""; | ||
5280 | if (offset >= src.Length) | ||
5281 | return ""; | ||
5282 | if (offset < 0) | ||
5283 | offset = 0; | ||
5284 | |||
5285 | if (count <= 0) | ||
5286 | count = src.Length - offset; | ||
5287 | else if (count > src.Length - offset) | ||
5288 | count = src.Length - offset; | ||
5289 | |||
5290 | if (count >= src.Length) | ||
5291 | return ""; | ||
5292 | |||
5293 | |||
5294 | return ((string)src).Remove(offset, count); | ||
5295 | } | ||
5296 | |||
5297 | public LSL_String osStringReplace(LSL_String src, LSL_String oldvalue, LSL_String newvalue) | ||
5298 | { | ||
5299 | if (string.IsNullOrEmpty(src)) | ||
5300 | return ""; | ||
5301 | if (string.IsNullOrEmpty(oldvalue)) | ||
5302 | return ""; | ||
5303 | if (string.IsNullOrEmpty(newvalue)) | ||
5304 | newvalue = null; | ||
5305 | |||
5306 | return ((string)src).Replace(oldvalue, newvalue); | ||
5307 | } | ||
5133 | } | 5308 | } |
5134 | } | 5309 | } \ No newline at end of file |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs index 2487a21..2ab1fff 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs | |||
@@ -529,5 +529,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces | |||
529 | 529 | ||
530 | LSL_String osDetectedCountry(LSL_Integer number); | 530 | LSL_String osDetectedCountry(LSL_Integer number); |
531 | LSL_String osGetAgentCountry(LSL_Key agentId); | 531 | LSL_String osGetAgentCountry(LSL_Key agentId); |
532 | |||
533 | LSL_String osStringSubString(LSL_String src, LSL_Integer start); | ||
534 | LSL_String osStringSubString(LSL_String src, LSL_Integer start, LSL_Integer length); | ||
535 | LSL_Integer osStringStartsWith(LSL_String src, LSL_String value, LSL_Integer ignorecase); | ||
536 | LSL_Integer osStringEndsWith(LSL_String src, LSL_String value, LSL_Integer ignorecase); | ||
537 | LSL_Integer osStringIndexOf(LSL_String src, LSL_String value, LSL_Integer ignorecase); | ||
538 | LSL_Integer osStringIndexOf(LSL_String src, LSL_String value, LSL_Integer start, LSL_Integer count, LSL_Integer ignorecase); | ||
539 | LSL_Integer osStringLastIndexOf(LSL_String src, LSL_String value, LSL_Integer ignorecase); | ||
540 | LSL_Integer osStringLastIndexOf(LSL_String src, LSL_String value, LSL_Integer start, LSL_Integer count, LSL_Integer ignorecase); | ||
541 | LSL_String osStringRemove(LSL_String src, LSL_Integer start, LSL_Integer count); | ||
542 | LSL_String osStringReplace(LSL_String src, LSL_String oldvalue, LSL_String newvalue); | ||
532 | } | 543 | } |
533 | } | 544 | } |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs index bc5aa5c..1c003a0 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs | |||
@@ -1287,5 +1287,55 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
1287 | { | 1287 | { |
1288 | return m_OSSL_Functions.osGetAgentCountry(agentId); | 1288 | return m_OSSL_Functions.osGetAgentCountry(agentId); |
1289 | } | 1289 | } |
1290 | |||
1291 | public LSL_String osStringSubString(LSL_String src, LSL_Integer offset) | ||
1292 | { | ||
1293 | return m_OSSL_Functions.osStringSubString(src, offset); | ||
1294 | } | ||
1295 | |||
1296 | public LSL_String osStringSubString(LSL_String src, LSL_Integer offset, LSL_Integer length) | ||
1297 | { | ||
1298 | return m_OSSL_Functions.osStringSubString(src, offset, length); | ||
1299 | } | ||
1300 | |||
1301 | public LSL_Integer osStringStartsWith(LSL_String src, LSL_String value, LSL_Integer ignorecase) | ||
1302 | { | ||
1303 | return m_OSSL_Functions.osStringStartsWith(src, value, ignorecase); | ||
1304 | } | ||
1305 | |||
1306 | public LSL_Integer osStringEndsWith(LSL_String src, LSL_String value, LSL_Integer ignorecase) | ||
1307 | { | ||
1308 | return m_OSSL_Functions.osStringEndsWith(src, value, ignorecase); | ||
1309 | } | ||
1310 | |||
1311 | public LSL_Integer osStringIndexOf(LSL_String src, LSL_String value, LSL_Integer ignorecase) | ||
1312 | { | ||
1313 | return m_OSSL_Functions.osStringIndexOf(src, value, ignorecase); | ||
1314 | } | ||
1315 | |||
1316 | public LSL_Integer osStringIndexOf(LSL_String src, LSL_String value, LSL_Integer offset, LSL_Integer count, LSL_Integer ignorecase) | ||
1317 | { | ||
1318 | return m_OSSL_Functions.osStringIndexOf(src, value, offset, count, ignorecase); | ||
1319 | } | ||
1320 | |||
1321 | public LSL_Integer osStringLastIndexOf(LSL_String src, LSL_String value, LSL_Integer ignorecase) | ||
1322 | { | ||
1323 | return m_OSSL_Functions.osStringLastIndexOf(src, value, ignorecase); | ||
1324 | } | ||
1325 | |||
1326 | public LSL_Integer osStringLastIndexOf(LSL_String src, LSL_String value, LSL_Integer offset, LSL_Integer count, LSL_Integer ignorecase) | ||
1327 | { | ||
1328 | return m_OSSL_Functions.osStringLastIndexOf(src, value, offset, count, ignorecase); | ||
1329 | } | ||
1330 | |||
1331 | public LSL_String osStringRemove(LSL_String src, LSL_Integer offset, LSL_Integer count) | ||
1332 | { | ||
1333 | return m_OSSL_Functions.osStringRemove(src, offset, count); | ||
1334 | } | ||
1335 | |||
1336 | public LSL_String osStringReplace(LSL_String src, LSL_String oldvalue, LSL_String newvalue) | ||
1337 | { | ||
1338 | return m_OSSL_Functions.osStringReplace(src, oldvalue, newvalue); | ||
1339 | } | ||
1290 | } | 1340 | } |
1291 | } | 1341 | } |