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/src/load.cpp | 112 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 112 insertions(+) create mode 100644 other/Kermit/src/load.cpp (limited to 'other/Kermit/src/load.cpp') diff --git a/other/Kermit/src/load.cpp b/other/Kermit/src/load.cpp new file mode 100644 index 0000000..2d40735 --- /dev/null +++ b/other/Kermit/src/load.cpp @@ -0,0 +1,112 @@ +/* + * load.cpp: + * written by palmers / teso + */ +#include +#include +#include +#include +#include + +#define PROGRAM "load" +#define VERSION "0.0.1" +#define AUTHOR "palmers / teso" + +#define LINE_LENGTH 16384 + + +void usage (char *s) +{ + cout << PROGRAM << VERSION << " by " << AUTHOR << endl; + cout << "Usage: " << s << " [options] " << endl; + cout << "Options:" << endl; + cout << "\t-v:\t be verbose" << endl; + cout << "\t-E:\t proceed even if errors occour" << endl; + cout << endl; + exit (0); +} + + +int main (int argc, char **argv) +{ + bool verbose = false, + err_continue = false; + int x = 0; + ifstream fs; + char line[LINE_LENGTH + 1]; + Patch *tp = NULL; + rwKernel *rw = NULL; + SymbolTable *st = NULL; + Addr2AddrList *a2a = NULL; + + if (argc < 2) + usage (argv[0]); + + for (x = 1; x < argc; x++) + { + if (argv[x][0] == '-') + { + switch (argv[x][1]) + { + case 'v': + verbose = true; + break; + case 'E': + err_continue = true; + break; + default: + cout << "unknow option: " << argv[x] << endl; + usage (argv[0]); + break; + } + } + } + + rw = new rwKernel (); + genDummyValMap (); + st = new SymbolTable (rw); + a2a = genReplaceValMap (st); + + fs.open (argv[argc - 1]); + if (!fs.is_open ()) + { + cerr << "failed to open \"" << argv[argc - 1] << "\"" << endl; + abort (); + } + + if (verbose) + cout << "done." << endl; + + while (!fs.eof ()) + { + fs.getline (line, LINE_LENGTH, '\n'); + tp = new Patch (string (line), rw); + + if (tp->isClean ()) + tp->link (a2a); + + if (tp->isLinked ()) + tp->apply (); + else if (verbose) + { + cout << "#" << x << ": Linking Failed" << endl; + if (err_continue) + continue; + break; + } + if (tp->isApplied () && verbose) + cout << "#" << x << ": Success" << endl; + else + { + cout << "#" << x << ": Applying Failed" << endl; + if (err_continue) + continue; + break; + } + delete tp; + } + if (verbose) + cout << "done." << endl; + fs.close (); + return 0; +} -- cgit v1.3