File: hash.h

package info (click to toggle)
systemtap 1.2-5%2Bsqueeze1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 13,972 kB
  • ctags: 7,842
  • sloc: ansic: 35,121; cpp: 29,336; exp: 7,535; xml: 6,878; sh: 6,719; perl: 2,067; tcl: 821; makefile: 545; python: 473; ruby: 419
file content (50 lines) | stat: -rw-r--r-- 1,654 bytes parent folder | download
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
#include <string>
#include <vector>
#include <sstream>
#include <fstream>

extern "C" {
#include <string.h>
#include <mdfour.h>
}

// Grabbed from linux/module.h kernel include.
#define MODULE_NAME_LEN (64 - sizeof(unsigned long))

class hash
{
private:
  struct mdfour md4;
  std::ostringstream parm_stream;

public:
  hash() { start(); }
  hash(const hash &base) { md4 = base.md4; parm_stream << base.parm_stream.str(); }

  void start();

  void add(const unsigned char *buffer, size_t size);
  void add(const int x) { add((const unsigned char *)&x, sizeof(x)); }
  void add(const long x) { add((const unsigned char *)&x, sizeof(x)); }
  void add(const long long x) { add((const unsigned char *)&x, sizeof(x)); }
  void add(const unsigned int x) { add((const unsigned char *)&x, sizeof(x)); }
  void add(const unsigned long x) { add((const unsigned char *)&x,
					sizeof(x)); }
  void add(const unsigned long long x) { add((const unsigned char *)&x,
					     sizeof(x)); }
  void add(const char *s) { add((const unsigned char *)s, strlen(s)); }
  void add(const std::string& s) { add((const unsigned char *)s.c_str(),
				       s.length()); }
  void add_file(const std::string& filename);

  void result(std::string& r);
  std::string get_parms();
};

void find_script_hash (systemtap_session& s, const std::string& script);
void find_stapconf_hash (systemtap_session& s);
std::string find_tracequery_hash (systemtap_session& s,
                                  const std::vector<std::string>& headers);
std::string find_typequery_hash (systemtap_session& s, const std::string& name);

/* vim: set sw=2 ts=8 cino=>4,n-2,{2,^-2,t0,(0,u0,w1,M1 : */