1 // Copyright 2000-2005 the Contributors, as shown in the revision logs.
2 // Licensed under the Apache Public Source License 2.0 ("the License").
3 // You may not use this file except in compliance with the License.
5 package org.ibex.mail.protocol;
7 import org.ibex.crypto.*;
8 import org.ibex.jinetd.Listener;
9 import org.ibex.mail.*;
10 import org.ibex.util.*;
11 import org.ibex.mail.target.*;
18 public static Message[] parse(Stream stream) {
19 StringBuffer buf = null;
21 for(String s = stream.readln(); ; s = stream.readln()) {
22 if (s == null || s.startsWith("From ")) {
24 if (buf != null) vec.addElement(Message.newMessage(new Fountain.StringFountain(buf.toString())));
25 } catch (Exception e) { Log.warn(Mbox.class, e); }
27 buf = new StringBuffer();
28 } else if (buf != null) {
29 if (buf.length() == 0 && s.length() == 0) continue; // skip blank line after From
34 return (Message[])vec.copyInto(new Message[vec.size()]);