DIRECTORY Rope USING [ROPE]; UserProfile: CEDAR DEFINITIONS = BEGIN OPEN Rope; Boolean: PROC [key: ROPE, default: BOOL _ FALSE] RETURNS [value: BOOL]; Number: PROC [key: ROPE, default: INT _ 0] RETURNS [value: INT]; Token: PROC [key: ROPE, default: ROPE _ NIL] RETURNS [value: ROPE]; ListOfTokens: PROC [key: ROPE, default: LIST OF ROPE _ NIL] RETURNS [value: LIST OF ROPE]; Line: PROC [key: ROPE, default: ROPE _ NIL] RETURNS [value: ROPE]; GetProfileName: PROC RETURNS [ROPE]; CallWhenProfileChanges: PROC [proc: ProfileChangedProc]; ProfileChangedProc: TYPE = PROC [reason: ProfileChangeReason]; ProfileChangeReason: TYPE = {firstTime, rollBack, edit}; ProfileChanged: PROC [reason: ProfileChangeReason]; GetErrorLog: PROC RETURNS [fileName: ROPE]; END. ¦UserProfile.mesa Copyright c 1985 by Xerox Corporation. All rights reserved. Teitelman on December 16, 1982 11:59 am Russ Atkinson (RRA) February 5, 1985 3:22:36 pm PST Overview UserProfile is a package for reading information from the disk file .profile, or if none exists, User.profile. The purpose of the profile is to allow personalized tailoring of the system. The current catalogue of ways the Cedar can be parameterized may be found in the file UserProfile.doc. Entries in the user's profile are of the form: : RETURN, where value is either (1) a BOOL, (2) an INT, (3) a TOKEN, or (4) a ListOfTokens (for more details, see UserProfile.doc). When Cedar is booted, rolledBack, or any file whose extension is "profile" is edited, the profile is parsed and a data structure which describes the information that was found in the profile is constructed. Comments (indicated using the standard "--" convention) can appear anywhere in the profile and will be ignored. The parsing will also ignore extra spaces or blank lines. Any errors or anomalies discovered when parsing or accessing the profile will cause diagnostics to be printed to the file UserProfile.log. The user will be informed that problems have been encountered via the Message Window. In no case however will the system break. Access to individual profile entries via the procedures below is relatively efficient, since this access does not require any file reads or parsing. Therefore, many simple applications can simply read information from the profile as needed. However, some applications derive complex data structures from the profile (consider the effect of the "UserCategory" profile entry on the state of Tioga), and hence cannot afford to interrogate the profile whenever some information derived from it is used. Such an application must register a ProfileChangedProc and perform all of its profile interrogations from within this procedure. This guarantees that the corresponding values will be updated whenever the profile changes. The ProfileChangedProc will be called when it is first registered, whenever the system is booted or rolled-back, or whenever a file with extension ".profile" is saved. Note: Since the ProfileChangedProc for an application is not called from that application's process(es), the application must explicitly synchronize its reads to variables derived from the profile with the ProfileChangedProc's writes to these variables. This may involve adding a monitor to an application that previously did not require one. Accessing the Profile The procedures described below all read simple results from the value field given a key. The default value is passed in as an argument so that the client can specify what the procedure returns should the value be absent or malformed, or the profile be missing. returns next token following :, i.e. effectively does an IO.GetRope[IDBreak]. If the first character encountered is ", then reads everything to the next matching ", and returns this as a single rope. For example, if your profile contains: PreRun: Clock.bcd, VersionMapOpsImpl.bcd, HideousKludge.bcd, -- just until 3.4 -- WalnutSend.bcd then ListOfTOkens["PreRun"] will return ("Clock.bcd", "VersionMapOpsImpl.bcd", "HideousKludge.bcd", "WalnutSend.bcd). Note that if the user profile contains Key:{cr}, then ListOfTokens["key", default] will return NIL, not default, i.e. the entry for "key" is neither malformed or absent. Like ListOfTokens except returns the result as a single rope, e.g. for above example, the value of Line["PreRun"] would be "Clock.bcd VersionMapOpsImpl.bcd HideousKludge.bcd WalnutSend.bcd". returns name of file used to build the profile, i.e. either .profile, or UserName.Profile. Returns NIL if no profile. Registering procedures for accessing the profile As mentioned above, if the result of accessing the user profile is going to be cached by the client, then the profile should not be accessed directly, but via a ProfileChangedProc which has been registered with CallWhenProfileChanges. This guarantees that the corresponding values will be updated whenever the profile changes. In other words, rather than writing: ClientCheckpointFlag: BOOL _ UserProfile.Boolean["ClientCheckpoint", TRUE]; the implementor should write: ClientCheckpointFlag: BOOL; Init: ProfileChangedProc = { ClientCheckpointFlag _ UserProfile.Boolean["ClientCheckpoint", TRUE]; }; UserProfile.CallWhenProfileChanges[Init]; proc is called when it is first registered with reason = firstTime. Calls all of the ProfileChangedProcs. This procedure is automatically called after a rollback, whenever the UserExec.Login is called, or whenever the a file with extension 'profile' is saved by tioga. if there were any errors reported, this closes the stream and returns the name of the file. Edited on December 14, 1982 3:50 pm, by Teitelman changes to comments only changes to: ListOfTokens, Line Russ Atkinson (RRA) February 5, 1985 3:21:37 pm PST reformatted Κ3– "Cedar" style˜codešœ™Kšœ Οmœ1™Kš‘œžœ˜8—K˜š‘œžœ˜3Kšœ£œH£œO™Ι—K™š‘ œžœžœ žœ˜+KšΟc\™\——K˜Kšžœ˜K˜š£1™1K™Kšœ Οr™—™3K™ —K™—…—έ