diff options
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/Api/Implementation')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | 177 |
1 files changed, 176 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 |