home *** CD-ROM | disk | FTP | other *** search
- /* -*- Emacs Mode: C++ -*- */
-
- /* listlink.c - ListLink Class implementation
-
- Copyright (C) 1989, Integrity Software
- Author: Isaac J. Salzman (salzman@rand.org)
-
- This software may be freely used/modified/distributed
- as desired so long as this copyright notice remains
- in tact.
- */
-
- #ifndef lint
- static char *RcsId = "$Header: /tmp_mnt/amnt/lh/salzman/src/class/RCS/listlink.c,v 1.1 89/09/17 15:01:32 salzman Exp Locker: salzman $";
- #endif
-
- /*
- * $Log: listlink.c,v $
- * Revision 1.1 89/09/17 15:01:32 salzman
- * Initial revision
- *
- */
-
- #include <stdio.h>
- #include <string.h>
-
- #include "listlink.h"
-
- DEF_INIT(ListLink)(char *str, Link *lp) SUPER_INIT_ARGS((str))
- {
- list = lp;
-
- INIT_SUPER(StrLink,(str));
-
- RETURN_THIS;
- }
-
- DEF_DEST(ListLink)(void)
- {
- /* we *could* destroy all our member lists, but that's not
- necessarily a good idea since they should be able to go
- on living when this object dies -- and should be destroyed
- explicitly.
- */
-
- DESTROY_SUPER;
- }
-
- void ListLink::showval(void)
- {
- printf("list name = %s\n", string);
- if (list)
- list->showlist();
- }
-
- /* this method looks for a string in one of our sublists, or looks to
- see if it's the name of one of our sub lists, in which case it will
- display the contents of the entire sub list.
- */
-
- void ListLink::lookup(char *item)
- {
- register Link *lpp;
- register ListLink *lp;
-
- if (lp = (ListLink *) find(item))
- {
- printf("found list called \"%s\"\n", item);
- lp->showval();
- return ;
- }
- else
- {
- for (lp=(ListLink *) next();lp;lp = (ListLink *) lp->next())
- {
- if (lpp = lp->list->find(item))
- {
- printf("found item \"%s\" in list \"%s\"\n", item,
- lp->string);
- lpp->showval();
- return ;
- }
- }
- }
-
- /* this is never reached if something's found */
- printf("item \"%s\" not found\n", item);
-
- }
-
-