DIRECTORY BasicTime USING [GMT], IO USING [STREAM], Rope USING [ROPE], ViewerTools USING [TiogaContents], WalnutKernelDefs USING [LogEntry, WhichTempLog]; WalnutLog: CEDAR DEFINITIONS = BEGIN GMT: TYPE = BasicTime.GMT; ROPE: TYPE = Rope.ROPE; STREAM: TYPE = IO.STREAM; LogEntry: TYPE = WalnutKernelDefs.LogEntry; WhichTempLog: TYPE = WalnutKernelDefs.WhichTempLog; TiogaContents: TYPE = ViewerTools.TiogaContents; ExpungeMsgs: PROC RETURNS[at, next: INT]; WriteExpungeLog: PROC RETURNS[at, next: INT]; CreateMsgSet: PROC[name: ROPE] RETURNS[at, next: INT]; EmptyMsgSet: PROC[msgSet: ROPE] RETURNS[at, next: INT]; DestroyMsgSet: PROC[msgSet: ROPE] RETURNS[at, next: INT]; AddMsg: PROC[msg: ROPE, to: ROPE] RETURNS[at, next: INT]; RemoveMsg: PROC[msg: ROPE, from: ROPE] RETURNS[at, next: INT]; MoveMsg: PROC[msg: ROPE, from, to: ROPE] RETURNS[at, next: INT]; DestroyMsg: PROC[msg: ROPE] RETURNS[at, next: INT]; HasBeenRead: PROC[msg: ROPE] RETURNS[at, next: INT]; RecordNewMailInfo: PROC[logLen: INT, when: GMT, server: ROPE, num: INT] RETURNS[at, next: INT]; StartCopyNewMail: PROC RETURNS[at, next: INT]; -- endCopy written by WalnutLogImpl AcceptNewMail: PROC RETURNS[at, next: INT]; StartReadArchiveFile: PROC[file: ROPE, msgSet: ROPE] RETURNS[at, next: INT]; EndReadArchiveFile: PROC RETURNS[at, next: INT]; StartCopyReadArchive: PROC RETURNS[at, next: INT]; -- endCopy written by WalnutLogImpl WriteMessage: PROC [msg: ROPE, body: TiogaContents] RETURNS[at: INT]; SetPosition: PROC[startPos: INT] RETURNS[charsSkipped: INT]; SetIndex: PROC[pos: INT]; NextAt: PROC RETURNS[at: INT]; NextEntry: PROC RETURNS[le: LogEntry, at: INT]; QuickScan: PUBLIC PROC RETURNS[le: LogEntry, at: INT]; ArchiveEntry: PUBLIC PROC[to: IO.STREAM] RETURNS[ok: BOOL]; CopyBytesToArchive: PROC[to: IO.STREAM, startPos, num: INT]; AcquireWriteLock: PROC; ForgetLogStreams: PROC; CloseLogStreams: PROC; LogLength: PROC RETURNS[length: INT]; OpenLogStreams: PROC; ReleaseWriteLock: PROC; ResetLog: PROC[newLength: INT]; ReturnCurrentLogStreams: PROC; ShutdownLog: PROC; PrepareToCopyTempLog: PROC[which: WhichTempLog, pagesAlreadyCopied: INT, reportProc: PROC[msg1, msg2, msg3: ROPE _ NIL] ] RETURNS[ok: BOOL]; CopyTempLog: PROC[ which: WhichTempLog, startCopyPos, fromPos: INT, reportProc: PROC[msg1, msg2, msg3: ROPE _ NIL] ]; FinishTempLogCopy: PROC[which: WhichTempLog]; CreateArchiveLog: PROC[ fileToRead: STREAM, msgSet: ROPE, reportProc: PROC[msg1, msg2, msg3: ROPE_ NIL]] RETURNS[ok: BOOL]; GetTiogaContents: PROC[textStart, textLen, formatLen: INT] RETURNS[contents: TiogaContents]; GetRefTextFromLog: PROC[startPos, length: INT, text: REF TEXT]; END. °WalnutLog.Mesa Copyright c 1984 by Xerox Corporation. All rights reserved. Willie-Sue, July 3, 1985 11:06:32 am PDT Donahue, August 5, 1985 2:25:20 pm PDT Contents: types and procedures which take the current log file as implicit parameter Last Edited by: Willie-Sue, January 10, 1985 12:24:49 pm PST Last Edited by: Donahue, December 11, 1984 1:09:54 pm PST Types Logging of operations that perform actions on the Walnut database Write a message on the current log Writes a CreateMsg entry on the log. Caller is expected to have manufactured a unique name for the message. This operation flushes the log. Parsing a log (used by Scavenge and Replay) Set the position of the log to begin at the first log entry at or beyond startPos. Each of the parsing operations below take the current position of the log as an implicit argument. This procedure will skip ahead to the beginning of a log entry if startPos is not one -- the number of characters skipped is returned in charsSkipped. sets the current log to the indicated position; used during expunge. The difference with SetPosition is that this asserts that the position is at the beginning of a log entry. returns the same value that NextEntry would return for at The returned values include the entry found and the position it occupies on the log. If entry = NIL, then no more entries remain in the log (at = logLength); if at = -1 then the current read position does not point to the beginning of a log entry. A valid entry is "consumed", ie., a subsequent call to NextEntry will return a different position for "at". Note: Successive calls to NextEntry may reuse the log entry returned -- if you need to keep information, copy it! Basically the same as NextEntry, but does not parse a message entry into its headers, but just returns the length of the headers section - used for the lazy enumeration of messages. Copies the next entry of the current log to an archive stream. used to copy (parts) of messages to an archive stream; the format of the archive log bears little resemblence to walnut's log - it conforms to the laurel standard Managing the current Log upgrades the lock on the log to write - used for long running operations clears WalnutLog's local variables - to be used when the transaction has aborted call this when there has been no recent activity returns the length of the current log file for now, simply closes and re-opens the streams to downgrade the lock to none closes any open currentLog or expungeLog streams; does a commitAndContinue of the transaction; may raise WalnutDefs.Error does more thorough job of shutting down the log Copying NewMail/ReadArchive logs makes sure there is enough space to copy the WhichTempLog onto the currentLog; returns FALSE if there is not enough space to extend the log copies the which templog, starting at fromPos to the end of the currentLog; writes an EndCopy log entry, and sets the length of which to 0, as an atomic operation; if the operation fails, WalnutDefs.Error is raised releases the write lock on on the currentLog and reset the length of the temp log to something reasonable reads fileToRead from the beginning and writes the readArchiveLog; writes an endReadArchive entry on the currentLog; returns TRUE if all went well; leaves the readArchiveLog closed, fileToRead open Utilities reads tioga text from log, returns NIL if EndOfStream is encountered reads length characters from log, sets length of text to 0 if EndOfStream is encountered Κσ˜šΟb™Jšœ Οmœ1™J˜Jš  œŸœŸœ ŸœŸœ Ÿœ˜@J˜Jš   œŸœŸœŸœ Ÿœ˜3J˜Jš   œŸœŸœŸœ Ÿœ˜4J˜š  œŸœ ŸœŸœ ŸœŸœ˜GJšŸœ Ÿœ˜—J˜Jš  œŸœŸœ ŸœΟc#˜RJ˜Jš  œŸœŸœ Ÿœ˜+J˜Jš  œŸœŸœ ŸœŸœ Ÿœ˜LJ˜Jš œŸœŸœ Ÿœ˜0J˜Jš œŸ œ Ÿœ‘#˜V—š"™"š   œŸœŸœŸœŸœ˜EJšœ™——š+™+š   œŸœ ŸœŸœŸœ˜—J™š  œŸœŸœŸœŸœ˜‘ œ™X—J™J˜—JšŸœ˜—…— p