/* $Header: /belch_a/users/rearl/tinymuck/src/RCS/utils.c,v 1.3 90/09/16 04:43:15 rearl Exp $ */ /* * $Log: utils.c,v $ * Revision 1.3 90/09/16 04:43:15 rearl * Preparation code added for disk-based MUCK. * * Revision 1.2 90/08/11 04:12:19 rearl * *** empty log message *** * * Revision 1.1 90/07/19 23:04:18 casie * Initial revision * * */ #include "copyright.h" #include "config.h" #include "db.h" /* remove the first occurence of what in list headed by first */ dbref remove_first(dbref first, dbref what) { dbref prev; /* special case if it's the first one */ if(first == what) { return DBFETCH(first)->next; } else { /* have to find it */ DOLIST(prev, first) { if(DBFETCH(prev)->next == what) { DBSTORE(prev, next, DBFETCH(what)->next); return first; } } return first; } } int member(dbref thing, dbref list) { DOLIST(list, list) { if(list == thing) return 1; } return 0; } dbref reverse(dbref list) { dbref newlist; dbref rest; newlist = NOTHING; while(list != NOTHING) { rest = DBFETCH(list)->next; PUSH(list, newlist); DBDIRTY(newlist); list = rest; } return newlist; }