DIRECTORY BasicTime USING [GMT], IO USING [STREAM, Value], Rope USING [ROPE], ViewerTools USING [TiogaContents], WalnutDefs USING [CheckReportProc, WalnutOpsHandle], WalnutKernelDefs USING [LogEntry, WhichTempLog], WalnutRoot USING [InternalLogInfo]; WalnutLog: CEDAR DEFINITIONS = BEGIN GMT: TYPE = BasicTime.GMT; ROPE: TYPE = Rope.ROPE; STREAM: TYPE = IO.STREAM; LogEntry: TYPE = WalnutKernelDefs.LogEntry; WhichTempLog: TYPE = WalnutKernelDefs.WhichTempLog; CheckReportProc: TYPE = WalnutDefs.CheckReportProc; WalnutOpsHandle: TYPE = WalnutDefs.WalnutOpsHandle; InternalLogInfo: TYPE = WalnutRoot.InternalLogInfo; TiogaContents: TYPE = ViewerTools.TiogaContents; LogHandle: TYPE = REF LogHandleRec; LogHandleRec: TYPE = RECORD[ scanning: BOOL ¬ FALSE, strm: STREAM, scanningLog: InternalLogInfo, -- for logical start and end; also for lastLog entryLengthHint: INT ¬ -1, entryPos: INT ¬ -1 ]; ExpungeMsgs: PROC[opsH: WalnutOpsHandle] RETURNS[at, next: INT]; WriteExpungeLog: PROC[opsH: WalnutOpsHandle] RETURNS[at, next: INT]; CreateMsgSet: PROC[opsH: WalnutOpsHandle, name: ROPE] RETURNS[at, next: INT]; EmptyMsgSet: PROC[opsH: WalnutOpsHandle, msgSet: ROPE] RETURNS[at, next: INT]; DestroyMsgSet: PROC[opsH: WalnutOpsHandle, msgSet: ROPE] RETURNS[at, next: INT]; AddMsg: PROC[opsH: WalnutOpsHandle, msg: ROPE, to: ROPE] RETURNS[at, next: INT]; RemoveMsg: PROC[opsH: WalnutOpsHandle, msg: ROPE, from: ROPE] RETURNS[at, next: INT]; MoveMsg: PROC[opsH: WalnutOpsHandle, msg: ROPE, from, to: ROPE] RETURNS[at, next: INT]; HasBeenRead: PROC[opsH: WalnutOpsHandle, msg: ROPE] RETURNS[at, next: INT]; RecordNewMailInfo: PROC[opsH: WalnutOpsHandle, logLen: INT, when: GMT, server: ROPE, num: INT] RETURNS[at, next: INT]; StartCopyNewMail: PROC[opsH: WalnutOpsHandle] RETURNS[at, next: INT]; -- endCopy written by WalnutLogImpl AcceptNewMail: PROC[opsH: WalnutOpsHandle] RETURNS[at, next: INT]; StartReadArchiveFile: PROC[opsH: WalnutOpsHandle, file: ROPE, msgSet: ROPE] RETURNS[at, next: INT]; EndReadArchiveFile: PROC[opsH: WalnutOpsHandle] RETURNS[at, next: INT]; StartCopyReadArchive: PROC[opsH: WalnutOpsHandle] RETURNS[at, next: INT]; -- endCopy written by WalnutLogImpl WriteMessage: PROC [opsH: WalnutOpsHandle, msg: ROPE, body: TiogaContents] RETURNS[at: INT]; SetPosition: PROC[opsH: WalnutOpsHandle, startPos: INT] RETURNS[charsSkipped: INT]; SetIndex: PROC[opsH: WalnutOpsHandle, pos: INT]; NextAt: PROC[opsH: WalnutOpsHandle] RETURNS[at: INT]; NextEntry: PROC[opsH: WalnutOpsHandle] RETURNS[le: LogEntry, at: INT]; QuickScan: PUBLIC PROC[opsH: WalnutOpsHandle] RETURNS[le: LogEntry, at: INT]; ArchiveEntry: PUBLIC PROC[opsH: WalnutOpsHandle, to: STREAM] RETURNS[ok: BOOL]; CopyBytesToArchive: PROC[opsH: WalnutOpsHandle, to: STREAM, startPos, num: INT]; InitLogStream: PROC[opsH: WalnutOpsHandle] RETURNS[ok: BOOL]; LogLength: PROC[opsH: WalnutOpsHandle] RETURNS[length: INT]; OpenLogStreams: PROC[opsH: WalnutOpsHandle]; ReleaseWriteLock: PROC[opsH: WalnutOpsHandle]; ResetLog: PUBLIC PROC[opsH: WalnutOpsHandle, newLength: INT]; ForgetLogStreams: PROC[opsH: WalnutOpsHandle]; ShutdownLog: PROC[opsH: WalnutOpsHandle]; PrepareToCopyTempLog: PROC[ opsH: WalnutOpsHandle, which: WhichTempLog, pagesAlreadyCopied: INT, reportProc: CheckReportProc] RETURNS[ok: BOOL]; CopyTempLog: PROC[opsH: WalnutOpsHandle, which: WhichTempLog, startCopyPos, fromPos: INT, reportProc: CheckReportProc ]; FinishTempLogCopy: PROC[opsH: WalnutOpsHandle, which: WhichTempLog]; CreateArchiveLog: PROC[ opsH: WalnutOpsHandle, fileToRead: STREAM, msgSet: ROPE, reportProc: CheckReportProc] RETURNS[ok: BOOL]; GetTiogaContents: PROC[opsH: WalnutOpsHandle, textStart, textLen, formatLen: INT] RETURNS[contents: TiogaContents]; GetRefTextFromLog: PROC[opsH: WalnutOpsHandle, startPos, length: INT, text: REF TEXT]; END. € WalnutLog.Mesa Copyright Σ 1984, 1988, 1992 by Xerox Corporation. All rights reserved. Willie-Sue, May 23, 1988 6:37:25 pm PDT Contents: types and procedures which take the current log file as explicit parameter 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 will 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 getting off the ground - must be called first, does OpenLogStreams returns the length of the current log file for now, simply closes and re-opens the streams to downgrade the lock to none used by parser for doing StartReadArchiveFile forgets the current state of the log streams 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 Κ€•NewlineDelimiter –(cedarcode) style™codešΟb™Kšœ Οeœ=™HKšœ'™'K™KšœT™T—K˜šΟk ˜ Kšœ ŸœŸœ˜KšŸœŸœŸœ ˜KšœŸœŸœ˜Kšœ Ÿœ˜"Kšœ Ÿœ$˜4KšœŸœ˜0Kšœ Ÿœ˜#K˜—KšΟn œŸœŸ œ˜K˜KšŸ˜K™š™KšŸœŸœ Ÿœ˜KšŸœŸœŸœ˜KšŸœŸœŸœŸœ˜K˜Kšœ Ÿœ˜+KšœŸœ!˜3K˜KšœŸœ˜3KšœŸœ˜3KšœŸœ˜3K˜KšœŸœ˜0K˜Kšœ ŸœŸœ˜#šœŸœŸœ˜Kšœ ŸœŸœ˜KšœŸœ˜KšœΟc.˜MKšœŸœ˜Kšœ Ÿœ˜K˜—K˜—šA™AK˜Kš  œŸœŸœ Ÿœ˜@K˜Kš œŸœŸœ Ÿœ˜DK™Kš   œŸœŸœŸœ Ÿœ˜MK˜Kš   œŸœ ŸœŸœ Ÿœ˜NK˜Kš   œŸœ ŸœŸœ Ÿœ˜PK˜Kš  œŸœŸœŸœŸœ Ÿœ˜PK˜Kš   œŸœŸœŸœŸœ Ÿœ˜UK˜Kš  œŸœŸœ ŸœŸœ Ÿœ˜WK˜Kš   œŸœŸœŸœ Ÿœ˜KK˜š  œŸœ ŸœŸœ ŸœŸœ˜^KšŸœ Ÿœ˜—K˜Kš  œŸœŸœ Ÿœ‘#˜iK˜Kš  œŸœŸœ Ÿœ˜BK˜Kš  œŸœŸœ ŸœŸœ Ÿœ˜cK˜Kš œŸœŸœ Ÿœ˜GK˜Kš  œŸœŸœ Ÿœ‘#˜m—K™š"™"K˜š   œŸœŸœŸœŸœ˜\Kšœ™——K™š+™+K˜š   œŸœ"ŸœŸœŸœ˜SKšœŽ‘@™Ξ—K˜š œŸœŸœ˜0K™°—K˜š œŸœŸœŸœ˜5K™:—K˜š  œŸœŸœŸœ˜FKšœaŸœ™εK™Kš œB‘,™r—K™š   œŸœŸœŸœŸœ˜MK™΅—K™š   œŸœŸœŸœŸœŸœ˜OK™>—K™š œŸœŸœŸœ˜PK™’——K™š™K˜š  œŸœŸœŸœ˜=K™B—K˜š  œŸœŸœ Ÿœ˜