-- WalnutStream.Mesa
-- Contents: types and procedures which take an explicit stream parameter

-- Last Edited by: Willie-Sue, May 18, 1983 3:05 pm


DIRECTORY
 GVRetrieve USING[Handle],
IO USING [STREAM],
 WalnutLog;

WalnutStream: CEDAR DEFINITIONS =

BEGIN OPEN WalnutLog;

-- * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
-- utility routines for parsing log-style files

ReadPrefixInfo: PROC[strm: IO.STREAM, headersPos: INT]
  RETURNS[msgID: ROPE, categories: ROPE, outOfSynch: BOOL];

FindStartOfEntry: PROC[strm: IO.STREAM, doReport: BOOL]
RETURNS[startPos, prefixLength, entryLength: INT, entryChar: CHAR];

TagAndValue: PROC[strm: IO.STREAM, inc: INT] RETURNS[tag, value: ROPE];

RopeFromStream: PROC[strm: IO.STREAM, startPos, len: INT] RETURNS[ROPE];
-- reads arbitrary length ROPE from a stream

MsgRecFromStream: PROC[strm: IO.STREAM, prefixLength, msgLength: INT]
RETURNS[msgRec: MsgRec];

ReadOldMailFile: PROC[strm: IO.STREAM, defaultPrefix: ROPE] RETURNS [ok: BOOL];

-- UpdateFromStream is implemented in WalnutUpdateImpl

UpdateFromStream: PROC[strm: IO.STREAM, startPos: INT] RETURNS[success: BOOL];
-- reads entries from strm, starting at startPos, and updates the database by making
-- calls into WalnutDB

ExpungeFromStream: PROC[strm, tempLog: IO.STREAM, doUpdates, tailRewrite: BOOL]
  RETURNS[startExpungePos: INT, ok: BOOL];
-- Dumping is driven from the log file (strm) & preserves the bits that came from Grapevine
-- Dumps all the Msgs in the database to a tempLog, setting all
-- their body pointers to reference the NEW log; does NOT copy tempLog to strm

-- * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
-- the following procs write on strm

MakeLogEntry: PROC [
 strm: IO.STREAM, entryType: LogEntryType, entryText: ROPE, msgID: ROPENIL]
RETURNS [endStrmPos: INT];

GVLogEntry: PROC [strm: IO.STREAM, gvH: GVRetrieve.Handle, prefix: ROPE]
RETURNS [lastIndex: INT, ok: BOOL];

END.