private static string readNotecardText(NotecardReader reader) { if (reader.getLine() != "{") { throw new NotANotecardFormatException(reader.LineNumber); } string notecardString = string.Empty; string line; while ((line = reader.getLine()) != "}") { string[] data = line.Split(' '); if (data.Length == 0) { continue; } if (data[0] == "LLEmbeddedItems") { skipInventory(reader); } else if (data[0] == "Text" && data.Length == 3) { int length = Int32.Parse(data[2]); notecardString = reader.getBlock(length); } else if (line.IndexOf('{') >= 0) { throw new NotANotecardFormatException(reader.LineNumber); } } return(notecardString); }
private static void skipInventory(NotecardReader reader) { if (reader.getLine() != "{") { throw new NotANotecardFormatException(reader.LineNumber); } string line; while ((line = reader.getLine()) != "}") { string[] data = line.Split(' '); if (data[0] == "count") { int count = Int32.Parse(data[1]); for (int i = 0; i < count; ++i) { skipInventoryItems(reader); } } else if (line.IndexOf('{') >= 0) { throw new NotANotecardFormatException(reader.LineNumber); } } }
private static void skipInventoryItems(NotecardReader reader) { if (reader.getLine() != "{") { throw new NotANotecardFormatException(reader.LineNumber); } string line; while ((line = reader.getLine()) != "}") { string[] data = line.Split(' '); if (data.Length == 0) { continue; } if (data[0] == "inv_item") { skipInventoryItem(reader); } else if (line.IndexOf('{') >= 0) { throw new NotANotecardFormatException(reader.LineNumber); } } }
private static void skipSection(NotecardReader reader) { if (reader.getLine() != "{") { throw new NotANotecardFormatException(reader.LineNumber); } string line; while ((line = reader.getLine()) != "}") { if (line.IndexOf('{') >= 0) { throw new NotANotecardFormatException(reader.LineNumber); } } }
private static string readNotecard(byte[] rawInput) { string rawIntermedInput = string.Empty; /* make up a Raw Encoding here */ foreach (byte c in rawInput) { char d = (char)c; rawIntermedInput += d; } NotecardReader reader = new NotecardReader(rawIntermedInput); string line; try { line = reader.getLine(); } catch (Exception) { return(System.Text.Encoding.UTF8.GetString(rawInput)); } string[] versioninfo = line.Split(' '); if (versioninfo.Length < 3) { return(System.Text.Encoding.UTF8.GetString(rawInput)); } else if (versioninfo[0] != "Linden" || versioninfo[1] != "text") { return(System.Text.Encoding.UTF8.GetString(rawInput)); } else { /* now we actually decode the Encoding, before we needed it in raw */ string o = readNotecardText(reader); byte[] a = new byte[o.Length]; for (int i = 0; i < o.Length; ++i) { a[i] = (byte)o[i]; } return(System.Text.Encoding.UTF8.GetString(a)); } }
private static string readNotecard(byte[] rawInput) { string rawIntermedInput = string.Empty; /* make up a Raw Encoding here */ foreach(byte c in rawInput) { char d = (char)c; rawIntermedInput += d; } NotecardReader reader = new NotecardReader(rawIntermedInput); string line; try { line = reader.getLine(); } catch(Exception) { return System.Text.Encoding.UTF8.GetString(rawInput); } string[] versioninfo = line.Split(' '); if(versioninfo.Length < 3) { return System.Text.Encoding.UTF8.GetString(rawInput); } else if(versioninfo[0] != "Linden" || versioninfo[1] != "text") { return System.Text.Encoding.UTF8.GetString(rawInput); } else { /* now we actually decode the Encoding, before we needed it in raw */ string o = readNotecardText(reader); byte[] a = new byte[o.Length]; for(int i = 0; i < o.Length; ++i) { a[i] = (byte)o[i]; } return System.Text.Encoding.UTF8.GetString(a); } }
private static string readNotecardText(NotecardReader reader) { if (reader.getLine() != "{") throw new NotANotecardFormatException(reader.LineNumber); string notecardString = string.Empty; string line; while((line = reader.getLine()) != "}") { string[] data = line.Split(' '); if (data.Length == 0) { continue; } if (data[0] == "LLEmbeddedItems") { skipInventory(reader); } else if(data[0] == "Text" && data.Length == 3) { int length = Int32.Parse(data[2]); notecardString = reader.getBlock(length); } else if (line.IndexOf('{') >= 0) { throw new NotANotecardFormatException(reader.LineNumber); } } return notecardString; }
private static void skipInventory(NotecardReader reader) { if (reader.getLine() != "{") throw new NotANotecardFormatException(reader.LineNumber); string line; while((line = reader.getLine()) != "}") { string[] data = line.Split(' '); if(data[0] == "count") { int count = Int32.Parse(data[1]); for(int i = 0; i < count; ++i) { skipInventoryItems(reader); } } else if (line.IndexOf('{') >= 0) { throw new NotANotecardFormatException(reader.LineNumber); } } }
private static void skipInventoryItems(NotecardReader reader) { if(reader.getLine() != "{") { throw new NotANotecardFormatException(reader.LineNumber); } string line; while((line = reader.getLine()) != "}") { string[] data = line.Split(' '); if(data.Length == 0) { continue; } if(data[0] == "inv_item") { skipInventoryItem(reader); } else if (line.IndexOf('{') >= 0) { throw new NotANotecardFormatException(reader.LineNumber); } } }
private static void skipSection(NotecardReader reader) { if (reader.getLine() != "{") throw new NotANotecardFormatException(reader.LineNumber); string line; while ((line = reader.getLine()) != "}") { if(line.IndexOf('{')>=0) { throw new NotANotecardFormatException(reader.LineNumber); } } }