home *** CD-ROM | disk | FTP | other *** search
- /* -*- Emacs Mode: C++ -*- */
-
- /* linktest.c - test program for Link class & subclasses
-
- 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/linktest.c,v 1.1 89/09/17 15:01:26 salzman Exp Locker: salzman $";
- #endif
-
- /*
- * $Log: linktest.c,v $
- * Revision 1.1 89/09/17 15:01:26 salzman
- * Initial revision
- *
- */
-
- #include <stdio.h>
- #ifdef THINK_C
- #include <stdlib.h>
- #else
- #ifdef __GNUG__
- #include <std.h>
- #endif
- #endif
-
- #include "strlink.h"
- #include "intlink.h"
- #include "listlink.h"
-
- main()
- {
- Link *list1, *list2;
- ListLink *listlist;
-
- char s[100], *gets(char *);
-
- /* create the lists */
- list1 = MakeObject(Link)();
- list2 = MakeObject(Link)();
-
- /* the params to MakeObject are essentially ignored for first link */
- listlist = MakeObject(ListLink)("a list of lists", (Link *)NULL);
-
- /* put some stuff in first list -- mix strings & int's, start with
- a prepend
- */
-
- list1->prepend(MakeObject(StrLink)("item 0"));
- list1->prepend(MakeObject(IntLink)(0));
- list1->append(MakeObject(StrLink)("item 1"));
- list1->append(MakeObject(IntLink)(1));
- list1->prepend(MakeObject(StrLink)("item 2"));
- list1->prepend(MakeObject(IntLink)(2));
- list1->append(MakeObject(StrLink)("item 3"));
- list1->append(MakeObject(IntLink)(3));
-
- /* put stuff in second list -- again mixing srings & int's, but
- start with an append
- */
-
- list2->append(MakeObject(StrLink)("item 4"));
- list2->append(MakeObject(IntLink)(4));
- list2->prepend(MakeObject(StrLink)("item 5"));
- list2->prepend(MakeObject(IntLink)(5));
- list2->append(MakeObject(StrLink)("item 6"));
- list2->append(MakeObject(IntLink)(6));
- list2->prepend(MakeObject(StrLink)("item 7"));
- list2->prepend(MakeObject(IntLink)(7));
-
- /* now append the to lists to our list list */
-
- listlist->append(MakeObject(ListLink)("list 1", list1));
- listlist->append(MakeObject(ListLink)("list 2", list2));
-
- /* and see if we can find anything! */
-
- for (;;)
- {
- printf("enter item to search for: ");
- if (gets(s) == NULL) /* until ^D */
- break;
-
- listlist->lookup(s);
- }
-
- printf("\n");
-
- listlist->showlist(); /* show entire list */
-
- DestroyObject(listlist);
- DestroyObject(list1);
- DestroyObject(list2);
-
- exit(0);
- }
-