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]; GetRopeProfile: PROC RETURNS [Rope.ROPE]; SetRopeProfile: PROC [rope: Rope.ROPE ¬ NIL]; CallWhenProfileChanges: PROC [proc: ProfileChangedProc]; ProfileChangedProc: TYPE = PROC [reason: ProfileChangeReason]; ProfileChangeReason: TYPE = {firstTime, rollBack, edit, newUser}; ProfileChanged: PROC [reason: ProfileChangeReason]; GetErrorLog: PROC RETURNS [fileName: ROPE]; END. $ UserProfile.mesa Copyright Σ 1985, 1986, 1987, 1991 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 Doug Wyatt, January 18, 1987 11:09:25 pm PST JKF August 31, 1988 3:13:06 pm PDT 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 system can be parameterized may be found in the file UserProfileDoc.tioga. 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 UserProfileDoc.tioga). 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.GetTokenRope[... 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 Foo.bcd Bar.bcd then Token["PreRun"] will return "Clock.bcd". if your profile contains: PreRun: "nay doo run run run" Foo.bcd Bar.bcd then Token["PreRun"] will return "nay doo run run run". 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. -- Formerly of UserProfileExtras: RopeProfile is another source of profile information and is last in the evaluation "chain". The RopeProfile is set to NIL anytime ProfileChanged is called with a reason other than firstTime. For example, editing of a profile file will NIL-out any existing RopeProfile. Returns the current RopeProfile. Sets the RopeProfile to a new value, causes re-evaluation of all profile information, and all ProfileChangedProcs to be called. The syntax of the RopeProfile is identical to that of a profile file. Duplicate entries in the RopeProfile are not considered to be an error and are not reported. The filename "RopeProfile" is used if and when any errors are reported. 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 a file with extension 'profile' is saved by tioga, or whenever the logged-in user changes. 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 Jim Foote August 31, 1988 3:11:10 pm PDT Folded in UserProfileExtras. ΚΟ•NewlineDelimiter –(cedarcode) style™codešœ™Kšœ ΟeœC™NKšœ'™'K™3K™,K™"—K˜šΟk œžœžœ˜K˜—š Οb œžœž œžœžœ˜1K™Kšœ™™Kšœ£Ÿœ™ΈK™Kš œ=Πosœžœ žœžœΙ™ΗK™Kšœ˜Οnœ«‘œ‘™ψ™KšΟsΧ™ΧK™———™K™Kšœ„™„K˜Kš‘œžœžœ žœžœžœ žœ˜GK˜Kš ‘œžœžœ žœžœ žœ˜@K˜š‘œžœžœ žœžœžœ žœ˜CKšœ>žœ•™Υšœ'™'KšΠpr"™"—Kšœ-™-šœ™Kš£.™.—Kšœ7™7—K˜š‘ œžœžœ žœžœžœžœžœ žœžœžœ˜Zšœ'™'Kš£a™a—Kšœ£œ £Lœ™uK™Kšœ©™©—K˜š‘œžœžœ žœžœžœ žœ˜BKšœc£œ £C™Ύ——˜š‘œžœžœžœ˜$Kšœ™Kšœ™—K™!KšœŽ™ŽK™šΠbnœžœžœžœ˜)K™ K™—š€œžœ žœžœ˜-K™νK™——™0K™šœ‘‘œ ‘œ]™ΖK™—šœ%™%Kšœžœ+žœ™KK™—šœ™Kšœžœ™šœ™Kšœ?žœ™EK™—Kšœ)™)—K˜š‘œžœ˜8Kšœ0£œ™C—˜Kš‘œžœžœ˜>Kš‘œžœ(˜A—K˜š‘œžœ˜3Kšœ£œ£™Η—K™š‘ œžœžœ žœ˜+KšΟc\™\——K˜Kšžœ˜K˜š£1™1K™Kšœ Οr™—™3K™ —™(K™—K™—…—dW