aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework
diff options
context:
space:
mode:
authorMelanie2010-03-06 12:37:24 +0000
committerMelanie2010-03-06 12:37:24 +0000
commit8180c72cbc9cafff247d614ac14db29499fc32a9 (patch)
treefd92204394e657b805e094a237ffecaf50066df6 /OpenSim/Framework
parentMerge branch 'master' into careminster-presence-refactor (diff)
parentMerge branch 'master' of melanie@opensimulator.org:/var/git/opensim (diff)
downloadopensim-SC_OLD-8180c72cbc9cafff247d614ac14db29499fc32a9.zip
opensim-SC_OLD-8180c72cbc9cafff247d614ac14db29499fc32a9.tar.gz
opensim-SC_OLD-8180c72cbc9cafff247d614ac14db29499fc32a9.tar.bz2
opensim-SC_OLD-8180c72cbc9cafff247d614ac14db29499fc32a9.tar.xz
Merge branch 'master' into careminster-presence-refactor
Diffstat (limited to '')
-rw-r--r--OpenSim/Framework/SLUtil.cs109
1 files changed, 108 insertions, 1 deletions
diff --git a/OpenSim/Framework/SLUtil.cs b/OpenSim/Framework/SLUtil.cs
index 9d5c30a..81d82be 100644
--- a/OpenSim/Framework/SLUtil.cs
+++ b/OpenSim/Framework/SLUtil.cs
@@ -1,10 +1,15 @@
1using System; 1using System;
2using System.Collections.Generic;
3using System.Reflection;
4using log4net;
2using OpenMetaverse; 5using OpenMetaverse;
3 6
4namespace OpenSim.Framework 7namespace OpenSim.Framework
5{ 8{
6 public static class SLUtil 9 public static class SLUtil
7 { 10 {
11// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
12
8 #region SL / file extension / content-type conversions 13 #region SL / file extension / content-type conversions
9 14
10 public static string SLAssetTypeToContentType(int assetType) 15 public static string SLAssetTypeToContentType(int assetType)
@@ -181,5 +186,107 @@ namespace OpenSim.Framework
181 } 186 }
182 187
183 #endregion SL / file extension / content-type conversions 188 #endregion SL / file extension / content-type conversions
189
190 /// <summary>
191 /// Parse a notecard in Linden format to a string of ordinary text.
192 /// </summary>
193 /// <param name="rawInput"></param>
194 /// <returns></returns>
195 public static string ParseNotecardToString(string rawInput)
196 {
197 string[] output = ParseNotecardToList(rawInput).ToArray();
198
199// foreach (string line in output)
200// m_log.DebugFormat("[PARSE NOTECARD]: ParseNotecardToString got line {0}", line);
201
202 return string.Join("\n", output);
203 }
204
205 /// <summary>
206 /// Parse a notecard in Linden format to a list of ordinary lines.
207 /// </summary>
208 /// <param name="rawInput"></param>
209 /// <returns></returns>
210 public static List<string> ParseNotecardToList(string rawInput)
211 {
212 string[] input = rawInput.Replace("\r", "").Split('\n');
213 int idx = 0;
214 int level = 0;
215 List<string> output = new List<string>();
216 string[] words;
217
218 while (idx < input.Length)
219 {
220 if (input[idx] == "{")
221 {
222 level++;
223 idx++;
224 continue;
225 }
226
227 if (input[idx]== "}")
228 {
229 level--;
230 idx++;
231 continue;
232 }
233
234 switch (level)
235 {
236 case 0:
237 words = input[idx].Split(' '); // Linden text ver
238 // Notecards are created *really* empty. Treat that as "no text" (just like after saving an empty notecard)
239 if (words.Length < 3)
240 return output;
241
242 int version = int.Parse(words[3]);
243 if (version != 2)
244 return output;
245 break;
246 case 1:
247 words = input[idx].Split(' ');
248 if (words[0] == "LLEmbeddedItems")
249 break;
250 if (words[0] == "Text")
251 {
252 int len = int.Parse(words[2]);
253 idx++;
254
255 int count = -1;
256
257 while (count < len)
258 {
259 // int l = input[idx].Length;
260 string ln = input[idx];
261
262 int need = len-count-1;
263 if (ln.Length > need)
264 ln = ln.Substring(0, need);
265
266// m_log.DebugFormat("[PARSE NOTECARD]: Adding line {0}", ln);
267 output.Add(ln);
268 count += ln.Length + 1;
269 idx++;
270 }
271
272 return output;
273 }
274 break;
275 case 2:
276 words = input[idx].Split(' '); // count
277 if (words[0] == "count")
278 {
279 int c = int.Parse(words[1]);
280 if (c > 0)
281 return output;
282 break;
283 }
284 break;
285 }
286 idx++;
287 }
288
289 return output;
290 }
184 } 291 }
185} 292} \ No newline at end of file