summaryrefslogtreecommitdiff
path: root/other/Kermit/src/findsym.cpp
blob: cceefab7507b891ea9dad0957abfa905c573189d (plain)
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
/*
 * findsym.cpp:
 * written by palmers / teso
 */
#include <DevMemPatt.hpp>
#include <SymbolFingp.hpp>
#include <iostream>


#define PROGRAM		"findsym"
#define AUTHOR		"palmers / teso"
#define VERSION		"0.0.2"


void usage (char *s)
{
  cout << PROGRAM << VERSION << " by " << AUTHOR << endl;
  cout << "Usage: " << s << " [Options] name0 [name1 ... nameN]" << endl;
  cout << "Options:" << endl;
  cout << "\t-s:\t\t silent mode" << endl;
  cout << "\t-f <file>:\t set config file to <file>" << endl;
  cout << endl;
  exit (0);
}


int main (int argc, char **argv)
{
  bool silent = false;
  int x = 1;
  DevMemPatt *a = new DevMemPatt ();
  SymbolFingp *b = new SymbolFingp ();

  if (argc < 2)
    usage (argv[0]);

  cout.setf (ios::hex, ios::basefield);
  while (x < argc)
    {
      if (argv[x][0] == '-')
	{
	  switch (argv[x][1])
	    {
	      case 's':
		if (silent == false)
		  silent = true;
		else
		  silent = false;
		break;
	      case 'f':
		if (b != NULL)
		  delete b;
		b = new SymbolFingp (string (argv[++x]));
		break;
	      default:
		cerr << "Illegal option!" << endl;
		usage (argv[0]);
		break;
	    }
	}
      else
	{
	  if (silent)
	    cout << a->find_patt (b->getFinger (string (argv[x]))) << endl;
	  else
	    cout << argv[x] << '\t' << a->find_patt (b->getFinger (string (argv[x]))) << endl;
	}
      x++;
    }

  delete a;
  delete b;
  return 0;
}