From 09f57c8dffd9a8ba0983cce13381aef716f43801 Mon Sep 17 00:00:00 2001 From: chatty Date: Tue, 28 Nov 2000 14:19:34 +0000 Subject: *** empty log message *** --- utils/testid.cc | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 utils/testid.cc (limited to 'utils/testid.cc') diff --git a/utils/testid.cc b/utils/testid.cc new file mode 100644 index 0000000..bb79ced --- /dev/null +++ b/utils/testid.cc @@ -0,0 +1,61 @@ +#include "IdTable.h" +#include "String.h" +#include +#include +#include + +CcuIdTableOf table (2); + +main () +{ + char line [256]; + char *s; + int i = 0; + + printf ("? to get help\n"); + + for (;;) { + s = gets (line); + if (! s) + break; + if (strcmp (s, ".") == 0) + break; + + /* help */ + if (strcmp (s, "?") == 0) { + printf ("name\tadd name\n"); + printf ("-id\tdelete name associated to id\n"); + printf ("#\tdump table\n"); + printf (".\tquit\n"); + + continue; + } + + if (strcmp (s, "#") == 0) { + CcuIdIter hi = table; + while (++hi) + printf ("%d: %s\n", hi.CurId (), *hi); + continue; + } + + /* delete */ + if (*s == '-') { + bool found; + CcuID id = (CcuID) (atoi (++s)); + printf ("searching id %d\n", id); + char* info = table.Remove (id, &found); + if (! found) + printf ("%s not found\n", s); + else { + printf ("%s had info %s\n", s, info); + FreeString (info); + } + continue; + } + + /* add */ + CcuID id = table.Store (NewString (s)); + printf ("-> %d\n", id); + } + +} -- cgit v1.1