"Beginning Installation of cmd-register @prog cmd-register 1 99999 d 1 i ( cmd-register $Date: 2004/04/15 00:50:56 $ $Revision: 1.18 $ ) ( Purpose: Handle registration of database items for virtual references ) ( Author: Unknown ) ( Contributors: Andy & Feaelin ) ( Dependencies: None ) ( --------------------------------------------------------------------------- ) ( $Log: cmd-register,v $ Revision 1.18 2004/04/15 00:50:56 feaelin Updated cmd-register's documentation again. Added some color and version display. Revision 1.17 2004/04/14 21:08:41 feaelin Updated cmd-register's documentation. Revision 1.16 2004/03/26 03:03:30 feaelin Further rcs-log fixes. Revision 1.15 2004/02/07 17:20:31 feaelin Using a $ in the propname now generates an error, preventing messy registry entries. Fixed the rcs-log. Revision 1.14 2004/02/07 17:19:18 feaelin Attempting to use a $ in the prop name now fails. Revision 1.13 2000/01/10 16:56:46 feaelin Added support for @view/_docs. Made #del prompts a littl easier to understand. Added some color to the output. Revision 1.12 1999/12/29 23:20:40 feaelin New Feature! You can now remove registry entries with @reg #del = Revision 1.11 1999/12/21 17:59:20 feaelin Cleaned up the log and header comments. Fixed any ansi colors to use ^SUCC^/^FAIL^ instead of ^GREEN^/^RED^, making cmd-register more site customizable. Revision 1.10 1999/04/16 20:29:19 Brought in line with FBMUF5.64. A minor idiot proofing with @reg #prop = Revision 1.9 1999/04/16 19:55:55 Changed the priority of the exit to M3. Revision 1.8 1998/07/27 21:12:30 Fixed annoying bug with updating the revision string used for comparing. Revision 1.7 1998/07/27 21:07:41 Fixed strip-rcs to handle a null revision string. Revision 1.6 1998/07/27 19:40:20 During earlier changes, messed up the wiz-m-level. It's now corrected. Revision 1.5 1998/07/27 02:35:25 Made strip-rcs actually work. Revision 1.3 1998/07/27 01:50:50 Added a rcs-info stripper to make the version number show up nicely. Revision 1.1 1998/07/26 20:14:21 Updated to bring it in line with any improvements made in FBMUF5.61. Cleaned up use of macros, e.g. made it so no macros or libs are required to run/compile cmd-register on a glowmuck server. Also added some pretty colors! Fixed _reg props to use refs instead of string props. Included backward compatibility with servers that are still using strings for those references. ) ( --------------------------------------------------------------------------- ) $define tell me @ swap ansi_notify $enddef lvar regobj lvar regprop : do-header "^WHITE^------------------------------------------------------------------------------" tell "^FOREST^cmd-register: " "$Revision: 1.18 $" 1 strcut swap pop dup strlen 2 - strcut pop strcat tell "^WHITE^------------------------------------------------------------------------------" tell ; : do-footer "^WHITE^------------------------------------------------------------------------------" tell ; : do-help do-header "^RESET^The @register program is used to make database items, particularly programs," tell "^RESET^globally available to all users. Basic syntax:" tell " " tell "^INFO^ @reg ^RESET^- to list globally registered items." tell "^INFO^ @reg ^RESET^- to list globally registered items in a" tell "^RESET^ particular directory." tell "^INFO^ @reg = ^RESET^ ^RESET^- to register as ." tell "^INFO^ @reg = /^RESET^- to register as in directory " tell "^INFO^ @reg #del = ^RESET^- to remove entry on ." tell " " tell "^RESET^By default, registrations are stored on #0. Of course, only wizards have" tell "^RESET^permission to change #0, but mortal players can still store registrations on" tell "^RESET^themselves or other items which they own, using the following options:" tell " ^INFO^@reg #me ^RESET^- makes the registration on the user." tell " ^INFO^@reg #prop : ^RESET^- makes the registration on " tell "^RESET^ in propdir " tell " " "^RESET^Some typical directories:" tell "^INFO^cmd ^RESET^- 'command' programs ^INFO^lib ^RESET^- program libararies" tell "^INFO^con ^RESET^- connect/disconnect programs ^INFO^lock ^RESET^- lock programs" tell "^INFO^game ^RESET^- games such as yahtzee ^INFO^par ^RESET^- parent rooms" tell "^RESET^Type '^INFO^@reg #help2^RESET^' for additional information." tell do-footer ; : do-help-2 do-header "^INFO^Example: '@reg #12345 = sample^RESET^'" tell "This registers database item #12345 as '_reg/sample' on #0, so that players" tell "can refer to it as '$sample' instead of '#12345'." tell " " tell "^INFO^Example: '@reg lib-reflist = lib/reflist'" tell "This registers the program lib-reflist as '_reg/lib/reflist' on #0," tell "so that coders can use '$include $lib/reflist' in their programs." tell " " tell "^INFO^Example: '@reg #me #20645 = pet'" tell "This registers database item #20645 as '_reg/pet' on the user. The user" tell "may now refer to #20645 as '$pet'. Since the registration is not" tell "on #0, only the user may use this reference." tell " " tell "^INFO^Example: '@reg #prop #9876:_arrive #12345=sample'" tell "This registers database item #12345 as '_arrive/sample' on #9876. Notice" tell "that it is not registered as '_reg/_arrive/sample'. The #prop" tell "option does not include '_reg' automatically." tell do-footer ; : split swap over over swap instr dup not if pop swap pop "" else 1 - strcut rot strlen strcut swap pop then ; ( Using RCS to automatically update the version prop? This prettifies the result! FM-IDE 1998July26 ) : strip-rcs ( s -- s' ) dup dup "$" instr dup if 1 - strcut dup "$Revis" "ion$" strcat stringcmp if 11 strcut swap pop dup "$" instr 2 - strcut dup " $" stringcmp if 2 strcut swap pop strcat else pop then strcat swap pop else pop swap pop then else pop pop then "^ ^" swap strcat ; : list-props ( d s -- ) begin dup while dup strlen 1 - strcut dup "/" strcmp if strcat break else pop then repeat "/" strcat over swap nextprop begin dup while over over getprop dup if dup number? if atoi dbref then dup ok? if dup unparseobj over "_version" getpropstr dup if strip-rcs " ^INFO^Ver. " swap strcat strcat else pop then swap "_lib-version" getpropstr dup if strip-rcs " ^INFO^Lib.ver. " swap strcat strcat else pop then else pop "^RED^^ ^" then over ": " strcat swap strcat regprop @ strlen strcut swap pop " " swap strcat tell else pop then over over propdir? if dup regprop @ strlen strcut swap pop " " swap strcat "/ (^SUCC^directory^ ^)" strcat tell then over swap nextprop repeat pop pop ; : cmd-@register "me" match dup "guest" flag? swap "truemage" flag? not and if me @ "^FAIL^This command is unavailable to guests." ansi_notify pop exit then "me" match me ! dup "#help2" stringcmp not if do-help-2 exit then dup "#help" over if over strlen strcut pop stringcmp not else pop pop 0 then if do-help exit then striplead dup tolower "#del" 3 strncmp not if " " split swap pop dup "=" instr dup not if me @ "^FAIL^Please specify both database item and registry entry to remove." ansi_notify depth popn exit then 1 - strcut 1 strcut swap pop swap match dup dup #-1 dbcmp swap ok? not or if me @ "^FAIL^Remove a registry entry from what database item?" ansi_notify depth popn exit then dup #-2 dbcmp if me @ "^INFO^I don't know which one you mean!" ansi_notify depth popn exit then dup #0 dbcmp me @ "arch" flag? not and if me @ "^FAIL^Sorry. Only Arch-Wizards can remove registry entries from #0." ansi_notify depth popn exit then swap dup "/_reg/" swap strcat 3 pick over getpropstr dup not if me @ "^FAIL^That registry entry does not exist." ansi_notify depth popn exit then dup string? if dup "#" instr if 1 strcut swap pop then atoi dbref else me @ "^FAIL^Strange...that registry entry isn't in a valid format." ansi_notify depth popn exit then unparseobj me @ swap "^INFO^Are you sure you want to delete the registry entry: '^NOTE^" 5 pick strcat "^INFO^' which is pointing to: '^NOTE^" strcat swap strcat "^INFO^' (yes/no)?" strcat ansi_notify read tolower dup "y" strcmp not if pop me @ "^INFO^Please type either 'yes' or 'no' entirely." ansi_notify me @ "^INFO^Try again:" ansi_notify read tolower then dup "no" strcmp not if me @ "^FAIL^Aborted..." ansi_notify depth popn exit then "yes" strcmp not if swap pop remove_prop me @ "^SUCC^Registry entry removed." ansi_notify else me @ "^FAIL^Invalid input...aborting." ansi_notify depth popn exit then depth popn exit then dup tolower "#me" 3 strncmp not if " " split swap pop me @ regobj ! "_reg/" regprop ! else dup tolower "#prop" 5 strncmp not if " " split swap pop " " split swap ":" split (rest obj prop) swap dup not if pop "me" then dup "@" strcmp not if pop "#0" then match dup not if me @ "^FAIL^I don't see that target database item here." ansi_notify pop pop pop exit then dup #-2 dbcmp if me @ "^FAIL^I don't know which target database item you mean." ansi_notify pop pop pop exit then me @ over owner dbcmp me @ "wizard" flag? or not if me @ "^FAIL^Permission Denied." ansi_notify pop pop pop exit then regobj ! dup not if pop "/" then (if no propdir selected, use default) dup dup strlen 1 - strcut swap pop "/" strcmp if "/" strcat then (if propdir doesn't end in /, append /) regprop ! else me @ "w" flag? not over "=" instr and if me @ "^FAIL^Permission denied." ansi_notify pop exit then #0 regobj ! "_reg/" regprop ! then then dup "=" instr not if regobj @ #0 dbcmp not if "You need to specify a value to set with @reg #prop" tell pop exit then "^SUCC^Registered database items on " regobj @ unparseobj strcat ":" strcat tell regobj @ regprop @ rot strcat list-props "^INFO^Done." tell exit then "=" split strip swap strip match dup not if "^FAIL^I don't see that database item here." tell pop exit then dup #-2 dbcmp if "^FAIL^I don't know which database item you mean." tell pop exit then swap " " split if pop pop "^FAIL^You cannot have spaces in the registration name." tell exit then dup "$" instr if pop pop "^FAIL^You cannot have a dollar sign ($) in the registration name." tell exit then regobj @ regprop @ 3 pick strcat getpropstr dup if dup "#" 1 strncmp not if 1 strcut swap pop then regprop @ 3 pick strcat " used to be registered to " strcat swap atoi dbref unparseobj strcat "^INFO^" swap strcat tell else pop then regobj @ regprop @ 3 pick strcat 4 pick setprop regprop @ swap strcat " is now registered to " strcat swap unparseobj strcat " on " strcat regobj @ unparseobj strcat "^INFO^" swap strcat tell ; . c q @set cmd-register=W2 @action @register;@registe;@regist;@regis;@regi;@reg=here=tmp/exit1 @link $tmp/exit1=cmd-register @set $tmp/exit1=M3 @set $tmp/exit1=/_/de:@$cmd/register #help @register cmd-register=cmd/register @set $cmd/register=_version:FM$Revision: 1.18 $ @set $cmd/register=_docs:@register #help "Installation of cmd-register finished.