-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcitest.c
77 lines (63 loc) · 1.55 KB
/
citest.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/*
* $Id: citest.c,v 1.2 1996/07/17 16:01:04 grubba Exp $
*
* Codeinfo tester
*
* $Log: citest.c,v $
* Revision 1.1.1.1 1996/06/30 23:51:51 grubba
* Entry into CVS
*
* Revision 1.2 1996/06/19 11:08:25 grubba
* Some minor bugs fixed.
*
* Revision 1.1 1996/05/11 17:20:01 grubba
* Initial revision
*
*/
/*
* Includes
*/
#include <stdio.h>
#include "types.h"
#include "m68k.h"
#include "codeinfo.h"
/*
* Functions
*/
int main(int argc, char **argv)
{
struct seg_info *seg_tree = NULL;
char buf[1024];
dump_seg_tree(seg_tree);
printf("<>");
fflush(stdout);
while (fgets(buf, 1023, stdin)) {
U32 start, end;
if (buf[0] == 'h') {
printf("a <start> <end>\tAdd the range from <start> to <end>\n");
printf("d\t\tDump tree\n");
printf("D <val>\t\tDelete the node with the range containing <val>\n");
printf("f <start>\tFind the range containing <start>\n");
printf("h\t\tHelp\n");
printf("q\t\tQuit\n");
} else if (buf[0] == 'd') {
dump_seg_tree(seg_tree);
} else if (buf[0] == 'q') {
exit(0);
} else if (2==sscanf(buf, "a %d %d\n", &start, &end)) {
insert_seg(&seg_tree, start, end);
dump_seg_tree(seg_tree);
} else if (1==sscanf(buf, "f %d\n", &start)) {
dump_seg_tree(find_seg(seg_tree, start));
} else if (1==sscanf(buf, "D %d\n", &start)) {
struct seg_info *seg = find_seg(seg_tree, start);
if (seg) {
destroy_seg(&seg_tree, seg);
}
dump_seg_tree(seg_tree);
}
printf("<>");
fflush(stdout);
}
exit(0);
}