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.jinetd.Worker;
10 import org.ibex.mail.*;
11 import org.ibex.util.*;
12 import org.ibex.mail.target.*;
19 public static Message[] parse(Stream stream) {
20 StringBuffer buf = null;
22 for(String s = stream.readln(); ; s = stream.readln()) {
23 if (s == null || s.startsWith("From ")) {
25 if (buf != null) vec.addElement(Message.newMessage(new Fountain.StringFountain(buf.toString())));
26 } catch (Exception e) { Log.warn(Mbox.class, e); }
28 buf = new StringBuffer();
29 } else if (buf != null) {
30 if (buf.length() == 0 && s.length() == 0) continue; // skip blank line after From
35 return (Message[])vec.copyInto(new Message[vec.size()]);