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/unload.cpp | 95 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 other/Kermit/src/unload.cpp (limited to 'other/Kermit/src/unload.cpp') diff --git a/other/Kermit/src/unload.cpp b/other/Kermit/src/unload.cpp new file mode 100644 index 0000000..90630ea --- /dev/null +++ b/other/Kermit/src/unload.cpp @@ -0,0 +1,95 @@ +/* + * unload.cpp: + * written by palmers / teso + */ +#include +#include +#include +#include +#include + +#define PROGRAM "unload" +#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-l:\t restore in linear order [default: reversed order]" << endl; + cout << endl; + exit (0); +} + + +int main (int argc, char **argv) +{ + bool linear = false; + int x = 0; + ifstream fs; + char line[LINE_LENGTH + 1]; + Patch *tp = NULL; + rwKernel *rw = NULL; + + if (argc < 2) + usage (argv[0]); + + for (x = 1; x < argc; x++) + { + if (argv[x][0] == '-') + { + switch (argv[x][1]) + { + case 'l': + linear = true; + break; + default: + cout << "unknow option: " << argv[x] << endl; + usage (argv[0]); + break; + } + } + } + + fs.open (argv[argc - 1]); + if (!fs.is_open ()) + { + cerr << "failed to open \"" << argv[argc - 1] << "\"" << endl; + abort (); + } + + if (linear) + { + while (!fs.eof ()) + { + fs.getline (line, LINE_LENGTH, '\n'); + tp = new Patch (string (line), rw); + tp->remove (); + delete tp; + } + } + else + { + stack pstack; + while (!fs.eof ()) + { + fs.getline (line, LINE_LENGTH, '\n'); + tp = new Patch (string (line), rw); + pstack.push (tp); + } + + while (!pstack.empty ()) + { + tp = pstack.top (); + tp->remove (); + delete tp; + pstack.pop (); + } + } + + return 0; +} -- cgit v1.3