@q
@program D-Lock.muf
1 9999 d
i
( D-Lock.muf    v1.0    Jessy @ FurryMUCK    4/97
  
  A small anti-spam utility. Global commands locked to D-Lock will
  exit with a graceful fail when the program is set Debug, rather
  than subjecting unsuspecting players to epic spam. You can create
  a new, temporary command to run the program from when debugging,
  or you can @chown the program: D-Lock always passes for the program's
  owner. The lock on the global will release when you're through 
  debugging.
  
  INSTALLATION:
  
  There are no special installation requirements for using D-Lock
  simply as a lock, though a registered name is convenient. To add a
  locking utility, create an action named '@dlock' and link it to 
  D-Lock.muf. The program requires Mucker level 2, but runs better at
  W: permission is denied if the user doesn't control the trigger, and
  attempts to @dlock unauthorized objects won't crash.
  
  USE:
  
  To d-lock a command without setting a fail, simply lock the command 
  to D-Lock.muf. For example,
      
      @lock page=<D-Lock.muf's #dbref>
      
  The locking utility sets the lock and adds a fail of 'This command 
  is currently down for maintenance.'.  Ex:
  
      @dlock page
      
  D-Lock.muf may be freely ported. Please comment any changes.
)
  
: DoSetLock
    
    match
    dup not if
        "I don't see that here!" .tell exit
    then
    dup #-2 dbcmp if
        "I'm not sure which one you mean!" .tell exit
    then
    dup me @ swap controls not if
        "Permission denied." .tell exit
    then
    dup "_/lok" getprop if
        "This command is already locked. Please @unlock it so I "
        "won't accidently overwrite something you really need."
        strcat .tell exit
    then
    dup program? if
        "You need to lock the command action, not the program."
        .tell exit
    then
    dup getlink not if
        "The command needs to be linked to a program." .tell exit
    then
    dup "#" prog intostr strcat setlockstr pop
    "This command is currently down for maintenance." setfail
    
    "Locked." .tell
;
  
: main
    
    "me" match me !
    command @ "@dlock" smatch if
        DoSetLock exit
    then
    trig getlink dup ok? if
        dup program? if
            dup owner me @ dbcmp if
                pop 1 exit
            then
            "D" flag? if
                pop 0
                else
                    pop 1
             then
            else
                pop 1
         then
        else
            pop 1
    then
;
.
c
q