|
@@ -262,67 +262,88 @@ int mangle(int fd, std::string &buffer) {
|
|
|
}
|
|
|
|
|
|
int level = harry_level();
|
|
|
+ std::ostringstream new_buffer;
|
|
|
+ std::smatch match;
|
|
|
|
|
|
- if (level > 2) {
|
|
|
+ if (level) {
|
|
|
// Strings are good, but Regex is better
|
|
|
// Mystic BBS v1.12 A43 for Linux Node 1
|
|
|
- static std::regex bbs("Mystic BBS v[0-9.]+ A[0-9]+ for Linux Node [0-9]+");
|
|
|
- std::smatch match;
|
|
|
-
|
|
|
- if (std::regex_search(buffer, match, bbs)) {
|
|
|
- // We have a match
|
|
|
- std::string old_string =
|
|
|
- buffer.substr(match.position(0), match.length(0));
|
|
|
-
|
|
|
- // Build a new and better string
|
|
|
- std::ostringstream new_buffer;
|
|
|
- std::string new_string;
|
|
|
- const char *bbs_systems[] = {"Haunted BBS", "Harry's BBS",
|
|
|
- "Scary BBS Software", "Screaming BBS"};
|
|
|
- const char *operating_systems[] = {
|
|
|
- "OS/360", "CP/M", "OS/9", "Xenix", "MS-DOS",
|
|
|
- "PC-DOS", "DR-DOS", "QNX", "Novell Netware", "AmigaOS",
|
|
|
- "Windows NT", "Windows CE", "AIX", "OS/2", "OS/400",
|
|
|
- "NeXTSTEP", "MINIX", "Solaris", "Plan 9", "FreeBSD",
|
|
|
- "Windows 95", "Palm OS", "Mac OS X", "Windows XP"};
|
|
|
-
|
|
|
- int r = randint(sizeof(bbs_systems) / sizeof(char *));
|
|
|
- new_buffer << bbs_systems[r] << " v" << randint(10) << "." << randint(80);
|
|
|
- new_buffer << " for ";
|
|
|
-
|
|
|
- r = randint(sizeof(operating_systems) / sizeof(char *));
|
|
|
- new_buffer << operating_systems[r] << " Node " << randint(100 * level);
|
|
|
- new_string = new_buffer.str();
|
|
|
- // reset buffer
|
|
|
- new_buffer.str(std::string());
|
|
|
- new_buffer.clear();
|
|
|
-
|
|
|
- replace(buffer, old_string, new_string);
|
|
|
- replace(work, old_string, new_string);
|
|
|
- level = 0; // turn off the manglers! ;)
|
|
|
+ // Mystic BBS Version 1.12 A45
|
|
|
+ static int bbs_match = 0;
|
|
|
+
|
|
|
+ if (!bbs_match) {
|
|
|
+ std::regex bbs_what("Mystic BBS Version [0-9.]+ A[0-9]+");
|
|
|
+ // Mystic BBS v[0-9.]+ A[0-9]+ for Linux Node [0-9]+
|
|
|
+
|
|
|
+ if (std::regex_search(buffer, match, bbs_what)) {
|
|
|
+ // We have a match
|
|
|
+ ZF_LOGD("bbs_seen");
|
|
|
+ bbs_match = 1;
|
|
|
+ std::string old_string =
|
|
|
+ buffer.substr(match.position(0), match.length(0));
|
|
|
+
|
|
|
+ // Build a new and better string
|
|
|
+ std::string new_string;
|
|
|
+ const char *bbs_systems[] = {
|
|
|
+ "Haunted BBS", "Harry's BBS", "Scary BBS Software",
|
|
|
+ "Screaming BBS", "Fright BBS", "Gravestone BBS",
|
|
|
+ };
|
|
|
+ const char *operating_systems[] = {
|
|
|
+ "OS/360", "CP/M", "OS/9",
|
|
|
+ "Xenix", "MS-DOS", "PC-DOS",
|
|
|
+ "DR-DOS", "QNX", "Novell Netware",
|
|
|
+ "AmigaOS", "Windows NT", "Windows CE",
|
|
|
+ "AIX", "OS/2", "OS/400",
|
|
|
+ "NeXTSTEP", "MINIX", "Solaris",
|
|
|
+ "Plan 9", "FreeBSD", "Windows 95",
|
|
|
+ "Palm OS", "Mac OS X", "Windows XP",
|
|
|
+ "DESQview",
|
|
|
+ };
|
|
|
|
|
|
+ int r = randint(sizeof(bbs_systems) / sizeof(char *));
|
|
|
+ new_buffer << bbs_systems[r] << " v" << randint(10) << "."
|
|
|
+ << randint(80);
|
|
|
+ new_buffer << " for ";
|
|
|
+
|
|
|
+ r = randint(sizeof(operating_systems) / sizeof(char *));
|
|
|
+ new_buffer << operating_systems[r] << " Node " << randint(150 * level);
|
|
|
+ new_string = new_buffer.str();
|
|
|
+ // reset buffer
|
|
|
+ new_buffer.str(std::string());
|
|
|
+ new_buffer.clear();
|
|
|
+
|
|
|
+ replace(buffer, old_string, new_string);
|
|
|
+ replace(work, old_string, new_string);
|
|
|
+ level = 0; // turn off the manglers! ;)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ static int author_match = 0;
|
|
|
+
|
|
|
+ if (!author_match) {
|
|
|
static std::regex author("Copyright \\(C\\) [0-9-]+ By James Coyle");
|
|
|
- std::smatch match;
|
|
|
|
|
|
if (std::regex_search(buffer, match, author)) {
|
|
|
// We have a match
|
|
|
+ ZF_LOGD("author seen");
|
|
|
+ author_match = 1;
|
|
|
std::string old_author =
|
|
|
buffer.substr(match.position(0), match.length(0));
|
|
|
|
|
|
// Build a new and better string
|
|
|
- std::string new_author;
|
|
|
const char *coder_names[] = {"Horrible Harry", "Ghost Writer",
|
|
|
"Sands of Time", "Spector Software",
|
|
|
"Creepy Coder"};
|
|
|
- if (randint(10) < 4)
|
|
|
- new_buffer << "Copywrong ";
|
|
|
+ if (randint(10) < 5)
|
|
|
+ new_buffer << "Copyfright ";
|
|
|
else
|
|
|
new_buffer << "Copyright ";
|
|
|
+
|
|
|
new_buffer << "(C) " << 1000 + randint(999) << "-" << randint(24000)
|
|
|
<< " By ";
|
|
|
int r = randint(sizeof(coder_names) / sizeof(char *));
|
|
|
new_buffer << coder_names[r];
|
|
|
- new_author = new_buffer.str();
|
|
|
+ std::string new_author = new_buffer.str();
|
|
|
|
|
|
replace(buffer, old_author, new_author);
|
|
|
replace(work, old_author, new_author);
|
|
@@ -341,7 +362,6 @@ int mangle(int fd, std::string &buffer) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- // Ok, maybe the work string was a bad idea?
|
|
|
static std::string text;
|
|
|
static std::vector<int> text_offsets;
|
|
|
size_t stri;
|
|
@@ -350,8 +370,6 @@ int mangle(int fd, std::string &buffer) {
|
|
|
text_offsets.clear();
|
|
|
|
|
|
for (stri = 0; stri < buffer.size(); ++stri) {
|
|
|
- // why wasn't \x1b[?1000h handled by console_char?
|
|
|
- // what happened to \x0c ? It is there.
|
|
|
termchar tc = console_char(&console, work[stri]);
|
|
|
|
|
|
if (tc.in_ansi) {
|
|
@@ -385,11 +403,11 @@ int mangle(int fd, std::string &buffer) {
|
|
|
}
|
|
|
|
|
|
ZF_LOGV("Buffer: %s", logrepr(buffer.c_str()));
|
|
|
+ ZF_LOGV("Work: %s", logrepr(work.c_str()));
|
|
|
+ ZF_LOGV("Text: %s", logrepr(text.c_str()));
|
|
|
// ZF_LOGV_MEM(buffer.data(), buffer.size(), "Buffer:");
|
|
|
// ZF_LOGV_MEM(work.data(), work.size(), "Work:");
|
|
|
- ZF_LOGV("Work: %s", logrepr(work.c_str()));
|
|
|
// ZF_LOGV_MEM(text.data(), text.size(), "Text Buffer:");
|
|
|
- ZF_LOGV("Text: %s", logrepr(text.c_str()));
|
|
|
|
|
|
// Output vector contents
|
|
|
std::ostringstream oss;
|
|
@@ -420,7 +438,10 @@ int mangle(int fd, std::string &buffer) {
|
|
|
if (level) {
|
|
|
ZF_LOGD("CharMan");
|
|
|
CharMan cm(buffer, work, text, text_offsets);
|
|
|
- ZF_LOGD("CharMan %d, %d chars", cm.mangle_count, cm.mangle_chars);
|
|
|
+ ZF_LOGD("CharMan %d, %d chars, render %d", cm.mangle_count, cm.mangle_chars,
|
|
|
+ cm.need_render);
|
|
|
+ if (cm.need_render)
|
|
|
+ need_render = 1;
|
|
|
};
|
|
|
|
|
|
if (need_render) {
|