using System; using System.Collections; using System.Collections.Specialized; using System.Diagnostics; using System.Text; using System.IO; namespace NntpLib { public abstract class ArticleDecoder { protected Stream outStream = null; public ArticleDecoder(Stream OutputStream) { outStream = OutputStream; } public abstract bool DecodeLine(string line); } public class YencDecoder : ArticleDecoder { bool inBody = false; bool inCode = false; string beginLine; public YencDecoder(Stream OutputStream, string BeginLine) : base(OutputStream) { this.beginLine = BeginLine; } /// /// Returns true when we're done (we've found the /// encoded block, and completed decoding it) /// public override bool DecodeLine(string line) { if (!inBody) { if (line.StartsWith("=ybegin ")) { inBody = true; return false; }; } if (line.StartsWith("=yend ")) { // Done return true; } if (!inCode) { if (line.StartsWith("=ypart ")) inCode = true; return false; }; if (line.EndsWith("=")) { Debugger.Break(); }; byte[] lineBytes = Encoding.UTF8.GetBytes(line); byte[] outBytes = new byte[lineBytes.Length]; int outByte = 0; for (int i=0; i public override bool DecodeLine(string line) { if (line.Length == 0 && !inBody) { inBody = true; return false; }; if (inBody && line.StartsWith("begin")) { inCode = true; return false; }; if (inCode) { if (line.Length < 5) return true; byte[] data = uuDecode(line); outStream.Write(data, 0, data.Length); }; return false; } } }