summaryrefslogtreecommitdiff
path: root/utils/testid.cc
diff options
context:
space:
mode:
authorchatty2000-11-28 14:19:34 +0000
committerchatty2000-11-28 14:19:34 +0000
commit09f57c8dffd9a8ba0983cce13381aef716f43801 (patch)
tree49c5faa7cd1b76eea36169b5ecce09411b2802c2 /utils/testid.cc
parent2575756ec6f41bd05bf4505ccc0253fad0ed77c4 (diff)
downloadivy-league-09f57c8dffd9a8ba0983cce13381aef716f43801.zip
ivy-league-09f57c8dffd9a8ba0983cce13381aef716f43801.tar.gz
ivy-league-09f57c8dffd9a8ba0983cce13381aef716f43801.tar.bz2
ivy-league-09f57c8dffd9a8ba0983cce13381aef716f43801.tar.xz
*** empty log message ***
Diffstat (limited to 'utils/testid.cc')
-rw-r--r--utils/testid.cc61
1 files changed, 61 insertions, 0 deletions
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 <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+CcuIdTableOf <char> 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);
+ }
+
+}