Charles.Forsyth20060303-partialeea662d19 years agoHistory
129 lines · 2.9 KB · Text
RawDownload
.TH SPREE-ALLOW 2.SH NAMEAllow \- filter client actions.SH SYNOPSIS.EXinclude "spree.m";include "spree/allow.m";Clique, Member, Object: import Spree;allow := load Allow Allow->PATH; init:		fn(m: Spree, c: ref Clique);add:		fn(tag: int, member: ref Member, pattern: string);del:		fn(tag: int, member: ref Member);action:	fn(member: ref Member, cmd: string): (string, int, list of string);archive:	fn(archiveobj: ref Object);unarchive: fn(archiveobj: ref Object);.EE.SH DESCRIPTIONA.IR spree (2)client can send arbitrary actions to a runningengine.  The.B Allowmodule enables an engine to filter clients'actions, permitting only actions matchingcertain provided patterns to get through..PPAn action is conventionally formatted asa sequence of space-separated words.A.I patternis a string consisting of a sequence of such words.For a pattern to match a client's action, each word in the patternmust match each word in the action.Most pattern words are not special: they must matchliterally. The exceptions are:.TP.B *An asterisk matches any single word..TP.B "&"An ampersand matches any set of words.Any words in the pattern after this are ignored..TP.B %dMatches a decimal integer..TP.B %pMatches a valid player id (decimal integer)..TP.B %oMatches any valid object id (decimal integer).The corresponding word in the list returned by.B actionwill be changed to the local object id fromthe member's external representation..PP.B Initmust be called first with the spree module,.IR m ,and the current clique,.IR c ,to initialise the module..PP.B Addadds the new.I patternto the list of allowed actions;.I tagis an integer tag that the caller can later use to identify theaction, andI memberis the clique member that is allowed to perform the action(if nil, then any member will be allowed to perform the action)..B Deldeletes patterns tagged with.I tagfrom the list of allowed actions.If.I memberis non-nil, then only patterns specific tothat member will be deleted..PP.B Actionmatches.IR.IR cmd ,an action performed by.IR member ,against the list of all the allowed patterns.It returns a tuple, say.RI ( err\fR,\ \fItag\fR,\  \fItoks\fR).If.I cmddoes not match any pattern, then.I errwill be non-nil and holds a string describing thenature of the failure.If a match is made, then.I tagholds the matched pattern's tag, as passed to.BR add ,and.I toksholds the list of words in the action, withobject ids matched by.B %ochanged to their local representation using.IB member .obj\fR..PP.B Archivestores all the.I allowmodule's internal state as attributes on.I archiveobj(for card game engines, this is usually theobject returned from.B cardlib->archive(see.IR cardlib (2)))..B Unarchivereverses this, restoring the module's internal state from.IR archiveobj ..SH SOURCE/appl/spree/lib/allow.b.SH "SEE ALSO".IR spree (2) ,.IR spree-cardlib (2) ,.IR spree-objstore (2)