From c9cbeced5b3f2bdd7407e29c0811e65954132540 Mon Sep 17 00:00:00 2001 From: Root THC Date: Tue, 24 Feb 2026 12:42:47 +0000 Subject: initial --- other/Kermit/lib/DevMemPatt.cpp | 122 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 122 insertions(+) create mode 100644 other/Kermit/lib/DevMemPatt.cpp (limited to 'other/Kermit/lib/DevMemPatt.cpp') diff --git a/other/Kermit/lib/DevMemPatt.cpp b/other/Kermit/lib/DevMemPatt.cpp new file mode 100644 index 0000000..81fd6e9 --- /dev/null +++ b/other/Kermit/lib/DevMemPatt.cpp @@ -0,0 +1,122 @@ +/* + * DevMemPatt.cpp: + * written by palmers / teso + */ +#include + + + DevMemPatt::DevMemPatt () + { + rw = new rwKernel (); + } + + + DevMemPatt::DevMemPatt (rwKernel *a) + { + rw = a; + } + + + DevMemPatt::~DevMemPatt () + { + } + + + int DevMemPatt::compare_data_snippet (unsigned char *x, struct sfp *y) + { + bool i = false; + int ret = -1; + short a = 0, + b = 0; + + while ((b < y->length) && (a < READ_BUFF_SIZE)) + { + if ((x[a] == y->fp[b].val) || (y->fp[b].type == WWCARD)) + { + if (i == false) + { + i = true; + ret = a; + } + b++; + } + else if (i == true) + { + i = false; + ret = -1; + b = 0; + } + a++; + } + return ret; + } + + + unsigned int DevMemPatt::find_patt (unsigned int s, \ + unsigned int e, unsigned short l, unsigned char *snipp) + { + bool i = false; + int ret = -1; + unsigned short a = 0, + b = 0; + unsigned char *readBuff = NULL; + + readBuff = new unsigned char[READ_BUFF_SIZE]; + + while (s < e) + { + rw->read (readBuff, READ_BUFF_SIZE, s); + while ((b < l) && (a < READ_BUFF_SIZE)) + { + if (readBuff[a] == snipp[b]) + { + if (i == false) + { + i = true; + ret = a; + } + b++; + } + else if (i == true) + { + i = false; + ret = -1; + b = 0; + } + a++; + } + if (ret != -1) + { + if (ret == 0) + return s; + s = s + ret - READ_BUFF_SIZE; + } + s += READ_BUFF_SIZE; + } + return 0; + } + + + unsigned int DevMemPatt::find_patt (struct sfp *a) + { + int x = -1; + unsigned int s = a->start_addr, + e = a->stop_addr; + unsigned char *readBuff = NULL; + + readBuff = new unsigned char[READ_BUFF_SIZE]; + + while (s < e) + { + rw->read (readBuff, READ_BUFF_SIZE, s); + if ((x = compare_data_snippet (readBuff, a)) != -1) + { + if (x == 0) + return s; + s = s + x - READ_BUFF_SIZE; + } + s += READ_BUFF_SIZE; + } + return 0; + } + -- cgit v1.3