/* Copyright (C) 1991, Marcus J. Ranum. All rights reserved. */ #ifndef lint static char RCSid[] = "$Header: /usr/users/mjr/hacks/umud/CMD/RCS/_ladd.c,v 1.1 91/07/04 17:33:21 mjr Rel $"; #endif /* configure all options BEFORE including system stuff. */ #include "config.h" #include "mud.h" #include "match.h" #include "vars.h" /* add the given item to the named list and set it back into the object. no checks whatsoever are made here. this is wizard stuff. know what you are doing, or don't do at all. */ /* ARGSUSED */ cmd__ladd(argc,argv,who,aswho) int argc; char *argv[]; char *who; char *aswho; { Obj *op; char *ap; char *ins; char ob[MAXOID]; if(matchlocal(who,argv[1],ut_loc(who),MTCH_UNIQ|MTCH_MEOK|MTCH_NONLOC,ob)) return(1); if((op = cache_get(ob)) == (Obj *)0) { say(who,"cannot find object ",ob,"\n",(char *)0); return(1); } if((ap = objattr(op,argv[2],(int *)0)) == (char *)0) { /* empty list is the thing to add */ ins = argv[3]; } else { /* add to existing list */ if(!attistype(ap,typ_list)) { say(who,argv[1],".",argv[2]," is not a list",(char *)0); return(1); } if((ap = attdata(ap)) == (char *)0) { say(who,argv[1],".",argv[2],"'s malformed\n",(char *)0); return(1); } if((ins = lstadd(ap,argv[3],(int *)0)) == (char *)0) { say(who,"error adding to list.\n",(char *)0); return(1); } } if(objsetattr(op,typ_list,argv[2],ins)) { say(who,"error modifying object.\n",(char *)0); return(1); } if(cache_put(op,argv[1])) { say(who,"cannot write object ",argv[1],"\n",(char *)0); return(1); } return(0); }