diff --git a/src/configbbs.cpp b/src/configbbs.cpp index d7cb1dc..6636849 100755 --- a/src/configbbs.cpp +++ b/src/configbbs.cpp @@ -109,7 +109,6 @@ void checkcfg(std::string cfgdata) if (temp[0] == '#') return; // Sets if LOGGING is on / off - id1 = 0; id1 = temp.find("Set SYSOP_NAME", 0); if (id1 != std::string::npos) { std::string temp1; diff --git a/src/conio.cpp b/src/conio.cpp index cc76e2a..5dc768c 100755 --- a/src/conio.cpp +++ b/src/conio.cpp @@ -578,7 +578,7 @@ void ConsoleIO::node_message(int display) if (toupper(c) == 'Q' || c == 27) { return; - } else if (c == 10 || c == '\n') { + } else if (c == '\n') { continue; } diff --git a/src/mb_jam.h b/src/mb_jam.h index c419d7e..08d1929 100755 --- a/src/mb_jam.h +++ b/src/mb_jam.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2004-2014 by Michael Griffin * + * Copyright (C) 2004-2017 by Michael Griffin * * mrmisticismo@hotmail.com * * * * Purpose: * @@ -12,12 +12,6 @@ * (at your option) any later version. * ***************************************************************************/ -// Enthral SVN: $Id: mb_jam.h 1 2014-03-29 07:30:21Z mercyful $ -// Source: $HeadURL: file:///home/merc/repo/enthral/trunk/src/mb_jam.h $ -// $LastChangedDate: 2014-03-29 02:30:21 -0500 (Sat, 29 Mar 2014) $ -// $LastChangedRevision: 1 $ -// $LastChangedBy: mercyful $ - # ifndef MSG_MBJAM_H # define MSG_MBJAM_H @@ -96,15 +90,11 @@ struct MemMessage { uint8_t Type; uint16_t Flags; - uint32_t HighWater; // Total Messages (Includes Deleted) - uint32_t Active; // Active Messages (Excludes Deleted) - uint32_t CurrMsg; // Current Message + uint32_t HighWater; + uint32_t Active; + uint32_t CurrMsg; std::string TextChunks; - - //struct jbList TextChunks; - //struct jbList SeenBy; - //struct jbList Path; }; struct openbase { @@ -115,13 +105,13 @@ struct openbase { struct jam_Area { struct jam_Area *Next; - mb_list_rec *area; // struct Area *area; + mb_list_rec *area; s_JamBase *Base_PS; uint32_t BaseNum; uint32_t OldNum; uint32_t OldHighWater; uint32_t HighWater; - uint32_t Active; // Only Active, Excluding delete messages. + uint32_t Active; BOOL newmsg; }; diff --git a/src/menu_func.cpp b/src/menu_func.cpp index 64619b5..8d3ca89 100755 --- a/src/menu_func.cpp +++ b/src/menu_func.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2004-2014 by Michael Griffin * + * Copyright (C) 2004-2017 by Michael Griffin * * mrmisticismo@hotmail.com * * * * Purpose: * @@ -12,18 +12,10 @@ * (at your option) any later version. * ***************************************************************************/ -// Enthral SVN: $Id: menu_func.cpp 1 2014-03-29 07:30:21Z mercyful $ -// Source: $HeadURL: file:///home/merc/repo/enthral/trunk/src/menu_func.cpp $ -// $LastChangedDate: 2014-03-29 02:30:21 -0500 (Sat, 29 Mar 2014) $ -// $LastChangedRevision: 1 $ -// $LastChangedBy: mercyful $ - -// Automake # ifdef HAVE_CONFIG_H # include # endif -// Automake. # ifdef HAVE_PYTHON # include "pyenthral.h" # endif @@ -54,13 +46,13 @@ # include # include # include -# include // Stream Numbers to Strings. +# include # include # include # include -# include // gcc 4.3 -# include // gcc 4.7 +# include +# include # include # include @@ -73,13 +65,7 @@ using namespace std; */ menu_func::menu_func() { - ////errlog2("menu_func() menu_func new instance!"); _loadnew = false; - - // _curmenu.clear(); - // _premenu.clear(); - // _gosub.clear(); - menur2 = 0; cmdr2 = 0; @@ -93,16 +79,12 @@ menu_func::menu_func() TotMsgs = 0; choice = 0; - // For Lightbar Starting Position - // Now uses menu system for lightbars. CURRENT_AREA = 0; - //menu_reset(); } menu_func::~menu_func() { - ////errlog2("~menu_func()"); if (menur2 != 0) delete menur2; if (cmdr2 != 0) delete [] cmdr2; @@ -117,8 +99,6 @@ menu_func::~menu_func() execnum2 = 0; execnum3 = 0; choice = 0; - ////errlog2("~menu_func() Done!"); - } @@ -154,7 +134,6 @@ int menu_func::mnuparse(std::string cfgdata) { std::string::size_type id1 = 0; - // Disgards any Config lines with the # Character if (cfgdata[0] == '#') return FALSE; id1 = cfgdata.find("MenuName ", 0); @@ -229,7 +208,7 @@ int menu_func::mnuparse(std::string cfgdata) else menur2->MFlags.EscPassing = FALSE; return FALSE; // Last Menu Setting, don't need to parse rest of file. } - // End of Screen, now get X/Y and put lightbars there, instead of hard coded xY + id1 = cfgdata.find("EOSPrompt ", 0); if (id1 != std::string::npos) { chkparse(cfgdata); @@ -255,7 +234,6 @@ int menu_func::menu_read(std::string MenuName) ifstream iFS; iFS.open( path.c_str() ); if (!iFS.is_open()) { -// errlog((char *)"Couldn't Open Menu Area: %s",(char *)path.c_str()); return FALSE; } @@ -271,7 +249,6 @@ int menu_func::menu_read(std::string MenuName) } iFS.close(); - //memcpy(menur,&_menur,sizeof(CommandRec)); return TRUE; } @@ -283,7 +260,6 @@ void menu_func::cmdparse(std::string cfgdata, int idx) std::string::size_type id1 = 0; char sText[200] = {0}; - // Disgards any Config lines with the # Character if (cfgdata[0] == '#') return ; sprintf(sText,"LDesc[%.03d]",idx); @@ -342,16 +318,6 @@ void menu_func::cmdparse(std::string cfgdata, int idx) return; } - /* - id1 = -1; - sprintf(sText,"MidString[%.03d]",idx); - id1 = cfgdata.find(sText, 0); - if (id1 != -1) { - chkparse(cfgdata); - strcpy(cmdr->MidString,(char *)cfgdata.c_str()); - return; - }*/ - sprintf(sText,"LoString[%.03d]",idx); id1 = cfgdata.find(sText, 0); if (id1 != std::string::npos) { @@ -405,7 +371,6 @@ void menu_func::cmdparse(std::string cfgdata, int idx) cmdr2[idx].STLen = atoi((char *)cfgdata.c_str()); return; } - } /* @@ -423,7 +388,6 @@ int menu_func::cmdexist(std::string MenuName, int idx) ifstream iFS2; iFS2.open( path.c_str() ); if (!iFS2.is_open()) { - //errlog((char *)"Couldn't Open Menu Command [cmdexist()]: %s\n", path.c_str()); return ret; } @@ -438,20 +402,9 @@ int menu_func::cmdexist(std::string MenuName, int idx) } iFS2.close(); - - //if (ret==TRUE) sprintf(sText,"EXISTS! CommandRec [%.03d]",idx); - //else sprintf(sText,"NOT EXISTS! CommandRec [%.03d]",idx); - //putline(sText); - return ret; } - -/* - * Right now this loops through the menu too many times! haha - * Make it parse once for the max command rec found, save cpu! :) - * Files are small, so no rush! :) - */ int menu_func::cnt_cmds(std::string MenuName) { int cnt = 0; @@ -470,23 +423,13 @@ int menu_func::cmds_read(std::string MenuName, int idx) path += MenuName; path += ".txt"; - //CommandRec _cmdr; - //memset(&_cmdr,0,sizeof(CommandRec)); - - //check if the command can be found in the file, else return false! - // Don't need to Run through parsing each command, - // Just do an initial Cnt_cmds and don't go over it! :) - int ret; ret = cmdexist(MenuName,idx); if (ret < 1) return FALSE; - - // Else Read and Parse it ifstream iFS; iFS.open( path.c_str() ); if (!iFS.is_open()) { - //errlog((char *)"Couldn't Open Menu Commands: %s\n", path.c_str()); return FALSE; } @@ -494,168 +437,22 @@ int menu_func::cmds_read(std::string MenuName, int idx) for (;;) { std::getline(iFS,cfgdata,'\n'); cmdparse(cfgdata,idx); - //cfgdata += "\r\n"; (5 Times per menu., need to rewrite.!!) - //putline((char *)cfgdata.c_str()); if(iFS.eof()) break; } iFS.close(); - //memcpy(cmdr,&_cmdr,sizeof(CommandRec)); return TRUE; } -/* -// Convert From Old .DAT format to TEXT. -int menu_func::convert_read(std::string menu, CommandRec *cmdr, int idx) -{ - std::string path = MENUPATH; - path += menu; - path += ".mnu"; - - int x = 0; - FILE *stream = fopen(path.c_str(),"rb+"); - if(stream == NULL) - { - return x; - } - fclose(stream); - - stream = fopen(path.c_str(), "rb"); - if(fseek(stream,(int)idx*sizeof(CommandRec),SEEK_SET)==0) - x = fread(cmdr,sizeof(CommandRec),1,stream); - fclose(stream); - return x; -} -*/ - -// Convert From Old .DAT format to TEXT. -// Make these either XML or insert into a SQL table. :) -void menu_func::menu_convert(std::string menuname) -{ - /* Outdated, save for update from char to std::string. - CommandRec cmdr; - memset(&cmdr,0,sizeof(CommandRec)); - - std::string mname = MENUPATH; - mname += menuname; - mname += ".txt"; - - ofstream oFS2; - oFS2.open( mname.c_str(), ofstream::out | ofstream::trunc ); - if (!oFS2.is_open()) { - printf("Error Creating Menu!"); - return; - } - - char sText[255]={0}; - std::string sTmp; - int idx = 0; - - oFS2 << sTmp << endl; - oFS2 << "#" << endl; - oFS2 << "# This is an Example Menu" << endl; - oFS2 << "#" << endl; - oFS2 << "#" << endl; - oFS2 << endl; - oFS2 << "[MenuRec]" << endl; - oFS2 << "MenuName = \"\"" << endl; - oFS2 << "Directive = \"\"" << endl; - oFS2 << "MenuPrompt = \"\"" << endl; - oFS2 << "Acs = \"\"" << endl; - oFS2 << "Password = \"\"" << endl; - oFS2 << "ForceInput = \"0\"" << endl; - oFS2 << "ForceHelpLevel = \"0\"" << endl; - oFS2 << "Lightbar = \"TRUE\"" << endl; - oFS2 << endl; - oFS2 << "[MenuFlags]" << endl; - oFS2 << "ClrScrBefore = \"FLASE\"" << endl; - oFS2 << "NoMenuPrompt = \"FLASE\"" << endl; - oFS2 << "ForcePause = \"FLASE\"" << endl; - oFS2 << "ClrScrAfter = \"FLASE\"" << endl; - oFS2 << "UseGlobal = \"FLASE\"" << endl; - oFS2 << endl; - - while (convert_read(menuname, &cmdr, idx)) { - - sprintf(sText,"[CommandRec%.03d]",idx); - sTmp = sText; - oFS2 << sTmp << endl; - - sprintf(sText,"LDesc[%.03d] = \"%s\"",idx,cmdr.LDesc); - sTmp = sText; - oFS2 << sTmp << endl; - sprintf(sText,"SDesc[%.03d] = \"%s\"",idx,cmdr.SDesc); - sTmp = sText; - oFS2 << sTmp << endl; - sprintf(sText,"CKeys[%.03d] = \"%s\"",idx,cmdr.CKeys); - sTmp = sText; - oFS2 << sTmp << endl; - sprintf(sText,"Acs[%.03d] = \"%s\"",idx,cmdr.Acs); - sTmp = sText; - oFS2 << sTmp << endl; - sprintf(sText,"CmdKeys[%.03d] = \"%s\"",idx,cmdr.CmdKeys); - sTmp = sText; - oFS2 << sTmp << endl; - sprintf(sText,"MString[%.03d] = \"%s\"",idx,cmdr.MString); - sTmp = sText; - oFS2 << sTmp << endl; - sprintf(sText,"HiString[%.03d] = \"%s\"",idx,cmdr.HiString); - sTmp = sText; - oFS2 << sTmp << endl; - sprintf(sText,"LoString[%.03d] = \"%s\"",idx,cmdr.LoString); - sTmp = sText; - oFS2 << sTmp << endl; - - //menur->MFlags.EOSPrompt = TRUE - - - sprintf(sText,"Xcoord[%.03d] = \"%d\"",idx,cmdr.Xcoord); - sTmp = sText; - oFS2 << sTmp << endl; - sprintf(sText,"Ycoord[%.03d] = \"%d\"",idx,cmdr.Ycoord); - sTmp = sText; - oFS2 << sTmp << endl; - sprintf(sText,"LBarCmd[%.03d] = \"%i\"",idx,cmdr.LBarCmd); - sTmp = sText; - oFS2 << sTmp << endl; - sprintf(sText,"SText[%.03d] = \"%i\"",idx,cmdr.SText); - sTmp = sText; - oFS2 << sTmp << endl; - sprintf(sText,"STLen[%.03d] = \"%i\"",idx,cmdr.STLen); - sTmp = sText; - oFS2 << sTmp << endl; - oFS2 << endl; - ++idx; - } - oFS2.close(); - */ -} - - - /** * Loads All Commands into Class. */ void menu_func::insert_cmdr() { - //menus _mnu; - //CommandRec cmdr; - //memset(&cmdr,0,sizeof(CommandRec)); - // int idx = 0; - // while (menu_read(_curmenu)) - // { - // ++idx; - // if (noc == idx) break; -// } - int idx = 0; while (cmds_read(_curmenu,idx)) { - //cmdr2[noc] = *cmdr; - //memset(&cmdr,0,sizeof(CommandRec)); ++idx; - //if (noc == MAX_MENU_COMMANDS-1) break; } - } /** @@ -663,43 +460,13 @@ void menu_func::insert_cmdr() */ void menu_func::menu_reset() { - xx = 1;// = 1; // Holds X Coord - yy = 1;// = 1; // Holds Y Coord - - noc = 0; // Number of Commands. - iNoc = 0;// = 0 // Holds Lightbar # of choices - sNoc = 0;// = 0; // Holds Scroll Text # of choices - //choice = 0;// = 0; // Holds Currect Lightbar # - cntEscCmds = 0; // = 0; // Number of ESC Commands. - //memset(&execnum,0,sizeof(execnum)); //={0}; // Holds commands which are Lightbars - - /* - ////errlog2(" *** menu_reset()"); - - ////errlog2(" *** menu_reset() - Delete menur2"); - if (menur2) delete menur2; - ////errlog2(" *** menu_reset() - Delete cmdr2"); - if (cmdr2) delete [] cmdr2; - - // Clear - ////errlog2(" *** menu_reset() - Delete execnum"); - if (execnum) delete [] execnum; - ////errlog2(" *** menu_reset() - Delete execnum2"); - if (execnum2) delete [] execnum2; - ////errlog2(" *** menu_reset() - Delete execnum3"); - if (execnum3) delete [] execnum3; - - ////errlog2(" *** menu_reset() - cont"); + xx = 1; // Holds X Coord + yy = 1; // Holds Y Coord - menur2 = 0; - cmdr2 = 0; - execnum = 0; - execnum2 = 0; - execnum3 = 0; - */ - - //memset(&execnum2,0,sizeof(execnum2));//={0}; // Holds commands which are Scroll Text - //memset(&execnum3,0,sizeof(execnum3));//={0}; // Holds commands which are Scroll Text + noc = 0; // Number of Commands. + iNoc = 0; // Holds Lightbar # of choices + sNoc = 0; // Holds Scroll Text # of choices + cntEscCmds = 0; // Number of ESC Commands. c = '\0'; cc = '\0'; // Hold Input / Lightbar Key @@ -710,9 +477,10 @@ void menu_func::menu_reset() p = 0; // For passing Menu command to new thread tScroll = false; executed = 0; // Test's for hot keys commands excuted, if non pass through loop - // This is so scrolling isn't killed with invalid menu input! + + // This is so scrolling isn't killed + // with invalid menu input! exe = 0; - } @@ -721,9 +489,6 @@ void menu_func::menu_reset() */ int menu_func::menu_exists() { - ////errlog2("readin() 3"); - /// Check if Menu Exists first! - std::string path; path = MENUPATH; path += _curmenu; @@ -732,14 +497,12 @@ int menu_func::menu_exists() FILE *fstr; fstr = fopen(path.c_str(),"rb+"); if(fstr == NULL) { -// errlog((char *)"Menu not Found! : %s ",(char *)_curmenu.c_str()); sleep(1); return FALSE; } else { fclose(fstr); } return TRUE; - } @@ -756,18 +519,14 @@ void menu_func::menu_readin() path += ".txt"; // If we have the same menu, abort and return, no reason to re-load same! - ////errlog2("readin() 1 %s,%s",(char *)_premenu.c_str(),(char *)_curmenu.c_str()); if (_premenu == _curmenu || _curmenu == "") { _loadnew = false; return ; } - ////errlog2("readin() 3"); - /// Check if Menu Exists first! FILE *fstr; fstr = fopen(path.c_str(),"rb+"); if(fstr == NULL) { -// errlog((char *)"Menu not Found! : %s ",(char *)_curmenu.c_str()); sleep(1); _loadnew = false; return; @@ -778,30 +537,16 @@ void menu_func::menu_readin() // Setup the Default Setting and And Clear Allocations. menu_reset(); // Loading new Menu, Clear! - ////errlog2("readin() 2"); - //memset(&menur2,0,sizeof(MenuRec)); - // Setup The Data Area - if (menur2 != 0) { - ////errlog2("readin() delete menur2;"); delete menur2; menur2 = 0; } - ////errlog2("readin() new menur2;"); menur2 = new MenuRec; if (!menur2) { -// errlog((char *)"Unable to Allocate Memory for Menu: %s, returning...",(char *)_curmenu.c_str()); return; } -// else errlog((char *)"Unable to Allocate Memory for Menu 1: %s, returning...",(char *)_curmenu.c_str()); - - // menu_read(_curmenu); - // noc = cnt_cmds(_curmenu); - // Allocate global menu commands if any - ////errlog2("readin() 4"); - if(!menu_read(_curmenu)) return; @@ -813,27 +558,16 @@ void menu_func::menu_readin() noc = cnt_cmds(_curmenu); - // Allocate & Load Commands - //memset(&cmdr2,0,sizeof(CommandRec[MAX_MENU_COMMANDS])); - ////errlog2("readin() 5, %i, %i",noc,nogc); - if (cmdr2 != 0) { - ////errlog2("readin() delete [] cmdr2;"); delete [] cmdr2; cmdr2 = 0; } - ////errlog2("readin() new [] cmdr2;"); cmdr2 = new CommandRec[noc+nogc+1]; if (!cmdr2) { -// errlog((char *)"Unable to Allocate Memory for cmdr2: %s, returning...",(char *)_curmenu.c_str()); return; } -// else errlog((char *)"Unable to Allocate Memory for cmdr2 1: %s, returning...",(char *)_curmenu.c_str()); - - ////errlog2("readin() 7.1 - %i, %i",noc,nogc); - insert_cmdr(); if (nogc > 0) { idx = 0; @@ -845,7 +579,6 @@ void menu_func::menu_readin() // Reset Load New Menu Flag _loadnew = false; - ////errlog2("readin() 8 Done, %i, %i",noc,nogc); } @@ -855,12 +588,9 @@ void menu_func::menu_readin() */ void *ScrollingText(void *p1) { - // Thanks to Darkwing for original reference code :) PASSING *p = (PASSING*)p1; ConsoleIO s; - //s.////errlog2("ScrollingText!! 1"); - // Only run scrolling text if were in ANSI Mode. if (isANSI == FALSE || p->Active == false) { p->Active = false; @@ -871,10 +601,8 @@ void *ScrollingText(void *p1) usleep(11*11800); - //s.////errlog2("ScrollingText!! 2"); unsigned short boxlen, loop, xpos = 0, ypos = 0, loop2; - //char sidecolor[04], midcolor[04], std::string clear, quotestr, q2, output; std::string midcolor; std::string sidecolor; @@ -886,18 +614,14 @@ void *ScrollingText(void *p1) output.clear(); q2.clear(); - //s.////errlog2("ScrollingText!! 3"); boxlen = p->cmdr2->STLen; if ( boxlen-1 > (int)p->cmdr2->MString.size() ) { for (int i = 0; i != boxlen; i++) quotestr += " "; } - //s.////errlog2("ScrollingText!! 4"); xpos = p->cmdr2->Xcoord; ypos = p->cmdr2->Ycoord; - //strcpy(midcolor, p->cmdr2->HiString); - //strcpy(sidecolor, p->cmdr2->LoString); midcolor = p->cmdr2->HiString; sidecolor = p->cmdr2->LoString; @@ -905,8 +629,6 @@ void *ScrollingText(void *p1) loop2 = quotestr.size(); quotestr += quotestr.substr ( 0, boxlen-1 ); - // s.////errlog2("ScrollingText!! 5"); - // Loop Scrolling Text Here do { if (PAUSE_SCROLING) { usleep(12*11800); @@ -929,13 +651,13 @@ void *ScrollingText(void *p1) output += q2; ++loop; s.pipe2ansi((char*)output.c_str()); - // Give small delay to Slow Text Scrolling Down + usleep(10*11800); } while (p->Active); - //s.////errlog2("ScrollingText!! 6"); + delete p; p = 0; - //s.////errlog2("ScrollingText!! 7"); + return NULL; } @@ -946,13 +668,9 @@ void *ScrollingText(void *p1) */ void *DelayedOneliners(void *p1) { - // Thanks to Darkwing for original reference code :) - PASSING *p = (PASSING*)p1; ConsoleIO s; - //s.////errlog2("ScrollingText!! 1"); - // Only run scrolling text if were in ANSI Mode. if (isANSI == FALSE || p->Active == false) { p->Active = false; @@ -961,10 +679,8 @@ void *DelayedOneliners(void *p1) return NULL; } - //s.////errlog2("ScrollingText!! 2"); unsigned short boxlen, loop, xpos = 0, ypos = 0, loop2; - //char sidecolor[04], midcolor[04], std::string clear, quotestr, q2, output; std::string midcolor; std::string sidecolor; @@ -976,18 +692,14 @@ void *DelayedOneliners(void *p1) output.clear(); q2.clear(); - //s.////errlog2("ScrollingText!! 3"); boxlen = p->cmdr2->STLen; if ( boxlen-1 > (int)p->cmdr2->MString.size() ) { for (int i = 0; i != boxlen; i++) quotestr += " "; } - //s.////errlog2("ScrollingText!! 4"); xpos = p->cmdr2->Xcoord; ypos = p->cmdr2->Ycoord; - //strcpy(midcolor, p->cmdr2->HiString); - //strcpy(sidecolor, p->cmdr2->LoString); midcolor = p->cmdr2->HiString; sidecolor = p->cmdr2->LoString; @@ -995,8 +707,6 @@ void *DelayedOneliners(void *p1) loop2 = quotestr.size(); quotestr += quotestr.substr ( 0, boxlen-1 ); - // s.////errlog2("ScrollingText!! 5"); - // Loop Scrolling Text Here do { if (PAUSE_SCROLING) { @@ -1020,13 +730,13 @@ void *DelayedOneliners(void *p1) output += q2; ++loop; s.pipe2ansi((char*)output.c_str()); - // Give small delay to Slow Text Scrolling Down + usleep(10*11800); } while (p->Active); - //s.////errlog2("ScrollingText!! 6"); + delete p; p = 0; - //s.////errlog2("ScrollingText!! 7"); + return NULL; } @@ -1036,15 +746,12 @@ void *DelayedOneliners(void *p1) */ void menu_func::menu_clear() { - // Clear - ////errlog2(" *** menu_clearbars()"); if (execnum) delete [] execnum; if (execnum2) delete [] execnum2; if (execnum3) delete [] execnum3; execnum = 0; execnum2 = 0; execnum3 = 0; - } @@ -1069,7 +776,6 @@ void menu_func::display_menu(BOOL forcelevel) output += text; output += "|CR|CR|07|16"; - memset(&text,0,1024); ulong cnt=0; @@ -1112,7 +818,7 @@ void menu_func::display_menu(BOOL forcelevel) cmd_color, (char *)cmdr2[i].CKeys.c_str(), bracket2_color); -// errlog (text2); + output += text2; ++cnt; @@ -1152,85 +858,49 @@ void menu_func::menu_bars(char *inPut) std::vector< list_bar > lbar; std::string::size_type id1 = 0; - //putline("make it to menu bars!!"); - ////errlog2("menu_bars() 1"); - // If no Menu Commands Return! / Add fallback menu lateron!! if (noc == 0) return; - // Read Menu Ansi to String that will hold lightbars, Push to screen sametime - // Will speed up display and make ghosting not apear as much - ////errlog2("menu_bars() 2"); - BOOL menufile = FALSE; if (menur2->Directive != "") { - //readinAnsi(menur2.Directive,output); - menufile = ansiPrintf((char *)menur2->Directive.c_str()); + ansiPrintf((char *)menur2->Directive.c_str()); } - ////errlog2("menu_bars() 3"); // Count Cmds with lightbar or scrolling flag only and ESC Keys int Xc = 0; if (menur2->MFlags.EOSPrompt == TRUE) { - ////errlog2("menu_bars() 3.1"); getxy(); Xc = ansi_getx(); - - //pusprintf(outstring,"\x1b[u\x1b[K%s",(char *)sLine[iCnt].c_str()); - //pipe2ansi(outstring); } - //printf("\ncur: %s, pre: %s",_curmenu,_premenu); // Not the Same Menu Loaded, ok to Load New One! - ////errlog2("menu_bars() 5.1"); if (_premenu != _curmenu) { - //menu_clear(); - - //if (!menur2) - ////errlog2("menu_bars() 5.1 * !menur2"); - - //if (!cmdr2) - ////errlog2("menu_bars() 5.1 * !cmdr2"); - - - ////errlog2("menu_bars() 5.2 execnum"); if (execnum != 0) { - ////errlog2("menu_bars() delete execnum;"); delete [] execnum; execnum = 0; } - if (execnum == 0) { - execnum = new short[noc+1]; // Set to # of comamnd for now, preload. + execnum = new short[noc+1]; if (!execnum) { -// errlog((char *)"Unable to Allocate Memory for process_menu_area: %s - execnum[], returning...",(char *)_curmenu.c_str()); return; } } -// else errlog((char *)"Unable to Allocate Memory for process_menu_area: %s - execnum[] 1, returning...",(char *)_curmenu.c_str()); - // Check for Text Scrolling Commands - ////errlog2("menu_bars() 5.3 execnum2"); if (execnum2 != 0) { - ////errlog2("menu_bars() delete execnum2;"); delete [] execnum2; execnum2 = 0; } if (execnum2 == 0) { - execnum2 = new short[noc+1]; // Set to # of comamnd for now, preload. + execnum2 = new short[noc+1]; if (!execnum2) { -// errlog((char *)"Unable to Allocate Memory for process_menu_area: %s - execnum2[], returning...",(char *)_curmenu.c_str()); return; } } -// else errlog((char *)"Unable to Allocate Memory for process_menu_area: %s - execnum2[] 1, returning...",(char *)_curmenu.c_str()); // Check for Text Scrolling Commands - ////errlog2("menu_bars() 5.3 execnum3"); if (execnum3 != 0) { - ////errlog2("menu_bars() delete execnum3;"); delete [] execnum3; execnum3 = 0; } @@ -1238,11 +908,9 @@ void menu_func::menu_bars(char *inPut) if (execnum3 == 0) { execnum3 = new short[noc+1]; // Set to # of comamnd for now, preload. if (!execnum3) { -// errlog((char *)"Unable to Allocate Memory for process_menu_area: %s - execnum3[], returning...",(char *)_curmenu.c_str()); return; } } -// else errlog((char *)"Unable to Allocate Memory for process_menu_area: %s - execnum3[] 1, returning...",(char *)_curmenu.c_str()); iNoc = 0; sNoc = 0; @@ -1250,45 +918,31 @@ void menu_func::menu_bars(char *inPut) cntEscCmds = 0; for (int i = 0; i != noc; i++) { - ////errlog2("menu_bars() 6"); // If were overwridding placement of Row on which we display Lightbars // This is Mesage prompts and variables lenghts. // Place All Lightbars Accross on Same Horzontal Line! if (menur2->MFlags.EOSPrompt == TRUE) { - ////errlog2("menu_bars() 6.1 - EOS"); cmdr2[i].Ycoord = Xc; - /// This needs to be fixed, defaulting to TRUE!!! } // If we find a FIRSTCMD, Execute it right away! if (cmdr2[i].CKeys == "FIRSTCMD") { - ////errlog2("menu_bars() 6.2 - FIRSTCMD"); menu_docmd(&cmdr2[i]); - // Count /Commands, if we execute all FIRSTCMDS then return when completed. ++exe; } // Get Ligthbar Commands if (cmdr2[i].LBarCmd && isANSI == TRUE) { - ////errlog2("menu_bars() 6.3 - Lightbar"); execnum[iNoc] = i; ++iNoc; } if (cmdr2[i].SText) { - ////errlog2("menu_bars() 6.4 - Scrolling"); execnum2[sNoc] = i; ++sNoc; } - //while running throguh each command, put into a vector formatted. - // No ansi menu file, generate menu commands. - if (!menufile && iNoc == 0) { - //errlog((char *)"menu_bars() 6.4 - Setting Menu Command Layout"); - // Insert code here for generating generic menu with commands. - } - ////errlog2("menu_bars() 10"); // Count Escape Keys in Menu System to override passthrough if (cmdr2[i].CKeys == "ESC") { execnum3[cntEscCmds] = i; @@ -1305,22 +959,7 @@ void menu_func::menu_bars(char *inPut) } else if (cmdr2[i].CKeys == "DOWN") { execnum3[cntEscCmds] = i; ++cntEscCmds; - } - /* - else - if (cmdr2[i].CKeys == "HOME") - { - execnum3[cntEscCmds] = i; - ++cntEscCmds; - } - else - if (cmdr2[i].CKeys == "END") - { - execnum3[cntEscCmds] = i; - ++cntEscCmds; - }*/ - - else if (cmdr2[i].CKeys == "PAGEUP") { + } else if (cmdr2[i].CKeys == "PAGEUP") { execnum3[cntEscCmds] = i; ++cntEscCmds; } else if (cmdr2[i].CKeys == "PAGEDN") { @@ -1329,28 +968,22 @@ void menu_func::menu_bars(char *inPut) } } - ////errlog2("menu_bars() 11"); // Return if we executed all comamnds as FRISTCMD! if (exe == noc) { return; } - ////errlog2("menu_bars() 11.1"); // Make sure there is more then 1 to Randomize if (sNoc > 0) { srand(time(NULL)); sRand = rand()%sNoc; } - _premenu = _curmenu; } - ////errlog2("menu_bars() 13"); // Start Text Scrolling Thread here... if (sNoc > 0 && execnum2[0] != '\0' && (int)execnum2[0] != 19 && isANSI == TRUE) { - ////errlog2("menu_bars() 14"); - //tScroll = true; tScroll = true; p = new PASSING; p->Active = true; @@ -1358,95 +991,39 @@ void menu_func::menu_bars(char *inPut) pthread_create(&ahThread, NULL, ScrollingText,(void *)p); } - ////errlog2("menu_bars() 15"); - // Setup of first Command, Highlited menu lightbar - output.clear(); - ////errlog2("menu_bars() 16"); - //Throw out a menu prompt if there is one available. - Add MCI Parsing too! - // Use Same X Row, these got reversed somehow!!! grrrr + + output.clear(); if (iNoc == 0) { - ////errlog2("menu_bars() 16- MENU PROMPT 1"); -// MENU PROMPT NOT NEEDED HERE, IS BELOW WITH MENU DISPLAY -// sprintf(outBuff,"%s",(char *)menur2->MenuPrompt.c_str()); -// output += outBuff; } else { - ////errlog2("menu_bars() 16- MENU PROMPT 2"); //Throw out a menu prompt if there is one available. - Add MCI Parsing too! // Use Same X Row, these got reversed somehow!!! grrrr xx = 1; yy = cmdr2[execnum[0]].Ycoord; - // sprintf(outBuff,"\x1b[%i;%iH%s",yy,xx,(char *)menur2->MenuPrompt.c_str()); -// // output += outBuff; } - - - /* - // Lightbar menu then draw - if (iNoc > 0) { - xx = cmdr2[execnum[0]].Xcoord; yy = cmdr2[execnum[0]].Ycoord; - sprintf(outBuff,"\x1b[%i;%iH%s",yy,xx,cmdr2[execnum[0]].HiString); - output += outBuff; - - // Setup of Remaining Lightbars in Low highlight Form - for (int rep = 1; rep != iNoc; rep++) { - xx = cmdr2[execnum[rep]].Xcoord; yy = cmdr2[execnum[rep]].Ycoord; - sprintf(outBuff,"\x1b[%i;%iH%s",yy,xx,cmdr2[execnum[rep]].LoString); - output += outBuff; - } - - // Write out all the Lightbars * and reset cursor position. - //output += "\x1b[24;79H"; - sprintf(outBuff,"\x1b[%i;79H",yy); - output += outBuff; - - pipe2ansi((char*)output.c_str()); - } - // Not Lightbars, print out menu ansi. - else { - pipe2ansi((char*)output.c_str()); - } - */ - ////errlog2("menu_bars() 17"); - - // For Title Scan and Other Interfaces, newscan doesn't - // Always start on first message, just to - -// errlog((char *)"#### choice1: %lu = CURRENT_AREA: %lu;",choice, CURRENT_AREA); - //choice = CURRENT_AREA; -// errlog((char *)"#### choice2: %lu = CURRENT_AREA: %lu;",choice, CURRENT_AREA); - std::string sMenu = _curmenu; while (1) { - ////errlog2("menu_bars() 18"); // Lightbar menu then draw if (iNoc > 0) { - ////errlog2("menu_bars() 19 - Lightbar Processing here!!"); + // Setup of Remaining Lightbars in Low highlight Form for (int rep = 0; rep != iNoc; rep++) { if (rep != choice) { - ////errlog2("menu_bars() 19.1"); xx = cmdr2[execnum[rep]].Xcoord; yy = cmdr2[execnum[rep]].Ycoord; - ////errlog2("menu_bars() 19.2"); sprintf(outBuff,"\x1b[%i;%iH%s",yy,xx,(char *)cmdr2[execnum[rep]].LoString.c_str()); - ////errlog2("menu_bars() 19.3"); output += outBuff; } else { - ////errlog2("menu_bars() 19.4"); xx = cmdr2[execnum[rep]].Xcoord; yy = cmdr2[execnum[rep]].Ycoord; - ////errlog2("menu_bars() 19.5"); sprintf(outBuff,"\x1b[%i;%iH%s",yy,xx,(char *)cmdr2[execnum[rep]].HiString.c_str()); - ////errlog2("menu_bars() 19.6"); output += outBuff; } } // Write out all the Lightbars * and reset cursor position. - //output += "\x1b[24;79H"; sprintf(outBuff,"\x1b[%i;79H",yy); output += outBuff; @@ -1455,21 +1032,12 @@ void menu_func::menu_bars(char *inPut) } // Not Lightbars, print out menu ansi. else { - ////errlog2("menu_bars() 19 - NO Lightbar Processing"); pipe2ansi((char*)output.c_str()); - - // Write out commands. - Check for Helplevel!! display_menu(); } - ////errlog2("menu_bars() 20 - GETKEY!"); memset(&EscapeKey,0,sizeof(EscapeKey)); - - //Can display global prompt here! - output.clear(); - - //Replcae Messages Left... output.clear(); output = menur2->MenuPrompt; @@ -1499,31 +1067,21 @@ void menu_func::menu_bars(char *inPut) pipe2ansi((char *)output.c_str()); } - // Main System / Menu System input. c = getkey(true); - ////errlog2("menu_bars() 21 - GOT KEY NOW PROCESS!"); - // Check here for Arrow Key / Escaped Input was Received if ((int)c == 27) { cc = EscapeKey[1]; if (cc == '0') { - // Tranlate to Terminal Escape with Preceding 0 cc = EscapeKey[2]; } EscHit = true; } else { EscHit = false; - /* - // Only display alpha Numeric - if( (int)c >= 33 && (int)c <= 127) { - putline((char *)&c); - }*/ } - ////errlog2("menu_bars() 22"); output.clear(); // If were in prompt and receive Int/Digit, @@ -1532,18 +1090,12 @@ void menu_func::menu_bars(char *inPut) if (menur2->MFlags.DigitPassing == TRUE) { inPut[0] = '#'; inPut[1] = c; - //menu_clear(); return; } } - ////errlog2("menu_bars() 23 .0 "); executed = 0; if (EscHit) { - // Input Key is Escaped Meaning Arrow Keys - ////errlog2("menu_bars() 23.1"); - - //elog ("* ESC Hit: %c, cntEscCmds: %ld",cc,cntEscCmds); // Run through and check for any Menu commands that overive default passthrough! if (cntEscCmds > 0) { @@ -1552,7 +1104,6 @@ void menu_func::menu_bars(char *inPut) if (EscapeKey[1] == '\0' || EscapeKey[1] == ' ') { if (cmdr2[execnum3[ckey]].CKeys == "ESC") { - //elog("- ESC EXECUTED! %s",(const char*)cmdr2[execnum3[ckey]].CmdKeys); if (tScroll) p->Active = false; ++executed; menu_docmd(&cmdr2[execnum3[ckey]]); @@ -1560,7 +1111,6 @@ void menu_func::menu_bars(char *inPut) } } else if (cc == 'A') { if (cmdr2[execnum3[ckey]].CKeys == "UP") { - ////errlog2("- UP EXECUTED! %s",(const char*)cmdr2[execnum3[ckey]].CmdKeys.c_str()); if (tScroll) p->Active = false; ++executed; menu_docmd(&cmdr2[execnum3[ckey]]); @@ -1568,7 +1118,6 @@ void menu_func::menu_bars(char *inPut) } } else if (cc == 'B') { if (cmdr2[execnum3[ckey]].CKeys == "DOWN") { - ////errlog2("- DOWN EXECUTED! %s",(const char*)cmdr2[execnum3[ckey]].CmdKeys.c_str()); if (tScroll) p->Active = false; ++executed; menu_docmd(&cmdr2[execnum3[ckey]]); @@ -1576,7 +1125,6 @@ void menu_func::menu_bars(char *inPut) } } else if (cc == 'C') { if (cmdr2[execnum3[ckey]].CKeys == "RIGHT") { - //elog("- RIGHT EXECUTED! %s",(const char*)cmdr2[execnum3[ckey]].CmdKeys); if (tScroll) p->Active = false; ++executed; menu_docmd(&cmdr2[execnum3[ckey]]); @@ -1584,7 +1132,6 @@ void menu_func::menu_bars(char *inPut) } } else if (cc == 'D') { if (cmdr2[execnum3[ckey]].CKeys == "LEFT") { - //elog("- LEFT EXECUTED! %s",(const char*)cmdr2[execnum3[ckey]].CmdKeys); if (tScroll) p->Active = false; ++executed; menu_docmd(&cmdr2[execnum3[ckey]]); @@ -1594,7 +1141,6 @@ void menu_func::menu_bars(char *inPut) else if ((cc == '5' && EscapeKey[2] == '~') || cc == 'V') { if (cmdr2[execnum3[ckey]].CKeys == "PAGEUP") { - //elog("- LEFT EXECUTED! %s",(const char*)cmdr2[execnum3[ckey]].CmdKeys); if (tScroll) p->Active = false; ++executed; menu_docmd(&cmdr2[execnum3[ckey]]); @@ -1604,74 +1150,12 @@ void menu_func::menu_bars(char *inPut) else if ((cc == '6' && EscapeKey[2] == '~') || cc == 'U') { if (cmdr2[execnum3[ckey]].CKeys == "PAGEDN") { - //elog("- LEFT EXECUTED! %s",(const char*)cmdr2[execnum3[ckey]].CmdKeys); if (tScroll) p->Active = false; ++executed; menu_docmd(&cmdr2[execnum3[ckey]]); strcpy(inPut,(const char*)cmdr2[execnum3[ckey]].CmdKeys.c_str()); } } - - - // Now check for extended arrors from terminals with preceeding 0. - /* - else if (cc == '0') - { - if (EscapeKey[2] == '\0' || EscapeKey[2] == ' ') - { - if (cmdr2[execnum3[ckey]].CKeys == "ESC") - { - //elog("- ESC EXECUTED! %s",(const char*)cmdr2[execnum3[ckey]].CmdKeys); - if (tScroll) p->Active = false; - ++executed; - menu_docmd(&cmdr2[execnum3[ckey]]); - strcpy(inPut,(const char*)cmdr2[execnum3[ckey]].CmdKeys.c_str()); - } - } - if (EscapeKey[2] == 'A') - { - if (cmdr2[execnum3[ckey]].CKeys == "UP") - { - ////errlog2("- UP EXECUTED! %s",(const char*)cmdr2[execnum3[ckey]].CmdKeys.c_str()); - if (tScroll) p->Active = false; - ++executed; - menu_docmd(&cmdr2[execnum3[ckey]]); - strcpy(inPut,(const char*)cmdr2[execnum3[ckey]].CmdKeys.c_str()); - } - } - else if (EscapeKey[2] == 'B') - { - if (cmdr2[execnum3[ckey]].CKeys == "DOWN") - { - ////errlog2("- DOWN EXECUTED! %s",(const char*)cmdr2[execnum3[ckey]].CmdKeys.c_str()); - if (tScroll) p->Active = false; - ++executed; - menu_docmd(&cmdr2[execnum3[ckey]]); - strcpy(inPut,(const char*)cmdr2[execnum3[ckey]].CmdKeys.c_str()); - } - } - else if (EscapeKey[2] == 'C') - { - if (cmdr2[execnum3[ckey]].CKeys == "RIGHT") - { - //elog("- RIGHT EXECUTED! %s",(const char*)cmdr2[execnum3[ckey]].CmdKeys); - if (tScroll) p->Active = false; - ++executed; - menu_docmd(&cmdr2[execnum3[ckey]]); - strcpy(inPut,(const char*)cmdr2[execnum3[ckey]].CmdKeys.c_str()); - } - } - else if (EscapeKey[2] == 'D') - { - if (cmdr2[execnum3[ckey]].CKeys == "LEFT") - { - //elog("- LEFT EXECUTED! %s",(const char*)cmdr2[execnum3[ckey]].CmdKeys); - if (tScroll) p->Active = false; - ++executed; - menu_docmd(&cmdr2[execnum3[ckey]]); - strcpy(inPut,(const char*)cmdr2[execnum3[ckey]].CmdKeys.c_str()); - } - }*/ } // Executed == 0, Then Key Pressed was not valid! :) // Pass through the ESC then @@ -1679,12 +1163,9 @@ void menu_func::menu_bars(char *inPut) if (executed == 0) { inPut[0] = cc; - // Translater to Terminal ESC Keys if (cc == '0') cc = EscapeKey[2]; } else { - ////errlog2("menu_bars() 23.2 return"); - //menu_clear(); return; } } @@ -1692,19 +1173,12 @@ void menu_func::menu_bars(char *inPut) // If True, means we pass A and B up/dn through to system! if (menur2->MFlags.EscPassing == FALSE) { // Arrow Keys - ////errlog2("menu_bars() 23.3 - ESC PASSING!!!"); if (cc == 'A') cc = 'D'; else if (cc == 'B') cc = 'C'; } - //elog ("Start Lightbar Processing... CMD: %c, cntEscCmds: %ld", cc, cntEscCmds); if (iNoc > 0) { - ////errlog2("menu_bars() 23.4 - iNoc > 0"); if (cc == 'D' && executed == 0) { - // Up & Left - ////errlog2("menu_bars() 23.4 - D"); - //printf ("\n D!"); - xx = cmdr2[execnum[choice]].Xcoord; yy = cmdr2[execnum[choice]].Ycoord; sprintf(outBuff,"\x1b[%i;%iH%s",yy,xx,(char *)cmdr2[execnum[choice]].LoString.c_str()); @@ -1720,9 +1194,6 @@ void menu_func::menu_bars(char *inPut) // Send Lightbar output pipe2ansi((char*)output.c_str()); } else if (cc == 'C' && executed == 0) { - // Down & Right - ////errlog2("menu_bars() 23.4 - C"); - //printf ("\n C!"); xx = cmdr2[execnum[choice]].Xcoord; yy = cmdr2[execnum[choice]].Ycoord; sprintf(outBuff,"\x1b[%i;%iH%s",yy,xx,(char *)cmdr2[execnum[choice]].LoString.c_str()); @@ -1735,13 +1206,9 @@ void menu_func::menu_bars(char *inPut) yy = cmdr2[execnum[choice]].Ycoord; sprintf(outBuff,"\x1b[%i;%iH%s\x1b[%i;79H",yy,xx,(char *)cmdr2[execnum[choice]].HiString.c_str(),yy); output += outBuff; - // Send Lightbar output - //errlog2((char*)output.c_str()); pipe2ansi((char*)output.c_str()); } else if ((cc == 'H' || (cc == '1' && EscapeKey[2] == '~')) && executed == 0 && menur2->MFlags.EscPassing == TRUE) { - // Home Key - ////errlog2("menu_bars() 23.4 - H / 1"); xx = cmdr2[execnum[choice]].Xcoord; yy = cmdr2[execnum[choice]].Ycoord; sprintf(outBuff,"\x1b[%i;%iH%s",yy,xx,(char *)cmdr2[execnum[choice]].LoString.c_str()); @@ -1751,12 +1218,9 @@ void menu_func::menu_bars(char *inPut) yy = cmdr2[execnum[choice]].Ycoord; sprintf(outBuff,"\x1b[%i;%iH%s\x1b[%i;79H",yy,xx,(char *)cmdr2[execnum[choice]].HiString.c_str(),yy); output += outBuff; - // Send Lightbar output pipe2ansi((char*)output.c_str()); } else if ((cc == 'K' || cc == 'F' || (cc == '4' && EscapeKey[2] == '~')) && executed == 0 && menur2->MFlags.EscPassing == TRUE) { - ////errlog2("menu_bars() 23.4 - 4 / K"); - // || menur2.MFlags.EndHomeLightbar == TRUE) { // End Key xx = cmdr2[execnum[choice]].Xcoord; yy = cmdr2[execnum[choice]].Ycoord; sprintf(outBuff,"\x1b[%i;%iH%s",yy,xx,(char *)cmdr2[execnum[choice]].LoString.c_str()); @@ -1769,41 +1233,14 @@ void menu_func::menu_bars(char *inPut) // Send Lightbar output pipe2ansi((char*)output.c_str()); } else { - ////errlog2("menu_bars() 23.5 - ELSE"); - - // printf ("\n ELSE!"); - - // If we have Escape, check if menu command, otherwise pass it through! - // Lateron Add SAPCE and TAB - /* - if ((cc == '\0' || cc == ' ') && executed == 0) { - executed = 0; - for (int ckey = 0; ckey != noc; ckey++) { - if (strcmp(cmdr2[ckey].CKeys,"ESC") == 0) { - if (tScroll) p->Active = false; - ++executed; - menu_docmd(cmdr2[ckey].CmdKeys,cmdr2[ckey].MString); - strcpy(inPut,(const char*)cmdr2[ckey].CmdKeys); - } - } - // Executed == 0, Then Key Pressed was not valid! :) - // Pass through the ESC then - if (tScroll) p->Active = false; - if (executed == 0) inPut[0] = cc; - return; - } - else {*/ // Pass through the Key. if (tScroll) p->Active = false; inPut[0] = cc; - //menu_clear(); return; - //} } } // else { // normal Key Input. - ////errlog2("menu_bars() 23.6 - ELSE"); if ((int)c == 10) { executed = 0; // Here Loop through and execute stacked Commands @@ -1822,12 +1259,10 @@ void menu_func::menu_bars(char *inPut) } if (executed > 0) { - //menu_clear(); return; } else { // Redraw screen! if (menur2->Directive != "") { - //readinAnsi(menur2.Directive,output); ansiPrintf((char *)menur2->Directive.c_str()); } } @@ -1857,7 +1292,6 @@ void menu_func::menu_bars(char *inPut) } // Executed == 0, Then Key Pressed was not valid!, and no stacked commands to loop :) if (executed > 0) { - //menu_clear(); return; } } // @@ -1869,9 +1303,7 @@ void menu_func::menu_bars(char *inPut) // also catch any stacked keys and execute in order! if ((int)c == 10 && iNoc > 0) { - // Only Executte [ENTER] on Lightbars! executed = 0; - // Here Loop through and execute stacked Commands for (int ckey = 0; ckey != noc; ckey++) { if (cmdr2[ckey].CKeys == cmdr2[execnum[choice]].CKeys) { if (tScroll) p->Active = false; @@ -1881,20 +1313,16 @@ void menu_func::menu_bars(char *inPut) } } if (executed > 0) { - //menu_clear(); - ////errlog2("Excuted Return Passthrough or Normal Key!"); return; } else { // Redraw screen! if (menur2->Directive != "") { - //readinAnsi(menur2.Directive,output); ansiPrintf((char *)menur2->Directive.c_str()); } } } else if ((int)c == 10 && iNoc == 0) { // Check for ENTER CKEY! executed = 0; - // Here Loop through and execute stacked Commands for (int ckey = 0; ckey != noc; ckey++) { if (cmdr2[ckey].CKeys == "ENTER") { if (tScroll) p->Active = false; @@ -1904,12 +1332,10 @@ void menu_func::menu_bars(char *inPut) } } if (executed > 0) { - //menu_clear(); return; } else { // Redraw screen! if (menur2->Directive != "") { - //readinAnsi(menur2.Directive,output); ansiPrintf((char *)menur2->Directive.c_str()); } } @@ -1936,7 +1362,7 @@ void menu_func::menu_bars(char *inPut) strcpy(inPut,(const char*)cmdr2[ckey].CmdKeys.c_str()); } } - // Executed == 0, Then Key Pressed was not valid!, and no stacked commands to loop :) + if (executed > 0) { //menu_clear(); return; @@ -1954,11 +1380,7 @@ void menu_func::menu_proc(char *mString, uint32_t area) { CURRENT_AREA = area; strcpy(mString,""); - ////errlog2("menu_proc1 noc(%i)",noc); if (noc == 0) { - // Don't reallu need to exit the system here.. fix lateron.. :) - ////errlog2("Err: menu_proc registering noc(%i) for ()",noc,(char *)_curmenu.c_str()); - //putline((char *)"Menu (%s) is Registering - 0 commands, please fix this!",(char *)_curmenu.c_str()); menu_reset(); startpause(); System_Alive = FALSE; @@ -1977,14 +1399,12 @@ int menu_func::logon_system(unsigned char c) switch (c) { case 'L' : if (lgn.logon_system(urec)) { - // User Login Successful, Setup Login Defaults! _curmenu = (char *)urec->startmenu; - CURRENT_MAREA = 0;//urec->lastmbarea; - CURRENT_FAREA = 0;//1; // 0 Sysop Base! - CURRENT_MSGTITLE = 0;//1; // 0 Sysop Base! + CURRENT_MAREA = 0; + CURRENT_FAREA = 0; + CURRENT_MSGTITLE = 0; return 1; } else { - // User Login Failed ++logins; if (logins >= 3) return 2; return 0; @@ -2021,174 +1441,13 @@ void menu_func::msgedit_system() _medit.mbeditmenu(); } - /** * Command Execute - file System Editor */ void menu_func::fileedit_system() { - // file_edit _fedit; - // _fedit.fbeditmenu(); -} - - -/* -// Start General Areas Message Reader, Email Scan throguh this needs work!! -int menu_func::msgread_system(unsigned char c, char *mString) { - - errlog((char *)"msgread_system() 1"); - //printf ("c = %c, mString = %s",c, mString); - // Handle to Message Reader Class - msg_read _mread; - int tmpMbase = 0; - int ret = TRUE; - - CURRENT_MAREA = urec->lastmbarea; - tmpMbase = 0; // Not used yet. - - //urec->lastmbarea = CURRENT_MAREA; - //tmpMbase = CURRENT_MAREA; - - - errlog((char *)" *** CURRENT_MAREA %lu = urec->lastmbarea %lu tmpMbase %lu",CURRENT_MAREA,urec->lastmbarea,tmpMbase); - //CURRENT_MAREA = urec->lastmbarea; - - - // If were in email area, skip to email/netmail reader. -// if (CURRENT_MAREA == 0) { // Fix later to detect board type, email/netmail. - - switch(c) { - case 'R': - // After reading, return, not skipping to next area. - errlog((char *)"emailread_system case 'R'"); - ret = emailread_system(c,mString); - return ret; - break; - - case 'N': - errlog((char *)"emailread_system case 'N'"); - // After newscanning, move on to normal areas. - ret = emailread_system(c,mString); - ++CURRENT_MAREA; - ++urec->lastmbarea; - break; - - case 'M' : - errlog((char *)"emailread_system case 'M'"); - ret = emailread_system((unsigned char)'N',mString); - ++CURRENT_MAREA; - ++urec->lastmbarea; - break; - - } -// } - - - else { - - // Setup - _mread.start(urec); - - switch(c) { - case 'R': - // Start Normal Message Reading / Get Starting Msg # - ////errlog2("msgread_system() 1.1 R"); - ret = _mread.StartReader(FALSE); - break; - - case 'N': - ////errlog2("msgread_system() 1.2 N"); - // Current area newscan - ret = _mread.StartReader(TRUE); - break; - - case 'M': // Multi-Scan, Scan all Areas!! - ////errlog2("msgread_system() 1.3 M"); - // Current area newscan - ret = _mread.StartReader(TRUE,TRUE); - break; - - } - //} - //urec->lastmbarea = tmpMbase; - //CURRENT_MAREA = tmpMbase; - return ret; -} -*/ - -/* Left Off commented out Origarea = urec->lastmbarea; so that each base selected - would current newscan proeprly. Problem with global newscan, starting at current - not first area, but other problem is email being first.. !! - - */ - -/* -// Start Email TitleScan / Message Reader - Seems good For Emails. -int menu_func::emailread_system(unsigned char c, char *mString) { - - - errlog((char *)"emailread_system 1"); - - // Handle to Message Reader Class - msg_read _mread; - unsigned long Origarea; - int SysopScan = FALSE; - - ////errlog2("emailread_system 2"); - // Lets Sysop / Admin Read All Email in the System. - if (strcmp(mString,"sysop") == 0) { - SysopScan = TRUE; - } - - ////errlog2("emailread_system 3"); - Origarea = urec->lastmbarea; - - ////errlog2("emailread_system 4"); - - if (atoi(mString) != 0) { - urec->lastmbarea = atoi(mString); - } - else { - urec->lastmbarea = 0; - } - -// CURRENT_MAREA = urec->lastmbarea; - - _mread.start(urec); // Check! - int ret = TRUE; - - ////errlog2("emailread_system 5"); - switch(c) { - case 'R': - errlog((char *)"emailread_system case 'R'"); - ////errlog2("emailread_system 6.1"); - // Start Normal Message Reading / Get Starting Msg # - //_mread.StartReader(FALSE,FALSE);//,TRUE); - //ret = _mread.StartEmailReader(FALSE,SysopScan); - ret = _mread.title_scan(FALSE,SysopScan); - break; - - case 'N': - errlog((char *)"emailread_system case 'N'"); - // Newscan - //ret = _mread.StartReader(TRUE,FALSE);//,TRUE); - ////errlog2("emailread_system 6.2"); -// ret = _mread.StartEmailReader(TRUE); - ret = _mread.title_scan(TRUE,SysopScan); - break; - } - - ////errlog2("emailread_system 7"); - // Reset back to original. - // urec->lastmbarea = Origarea; - // CURRENT_MAREA = Origarea; - return ret; } -*/ - -// - /** * Command Execute - For Reading / Scanning all and new messages. */ @@ -2198,9 +1457,6 @@ int menu_func::msgscan_system(unsigned char c, char *mString) unsigned long Origarea = 0; Origarea = urec->lastmbarea; - - // Always set starting message to 0. - // Gets reset to last read on newscan. urec->lastmsg = 0; _mread.start(urec); // Check! @@ -2208,64 +1464,30 @@ int menu_func::msgscan_system(unsigned char c, char *mString) int MiltiScan = FALSE; int NewScan = FALSE; - // TESTING OUTPUT - //pipe2ansi((char *)"|CR|15mstring: "); - //pipe2ansi((char *)mString); - //pipe2ansi((char *)"|CR|PA"); - - switch(c) { case 'R': // Read Area -// errlog((char *)"msgscan_system case 'R'"); - ////errlog2("emailread_system 6.1"); - // Start Normal Message Reading / Get Starting Msg # - //_mread.StartReader(FALSE,FALSE); - //ret = _mread.StartEmailReader(FALSE,SysopScan); ret = _mread.title_scan(NewScan,MiltiScan,mString); break; case 'N': // NewScan Current Area -// errlog((char *)"msgscan_system case 'N'"); - // Newscan Current - //ret = _mread.StartReader(TRUE,FALSE);//,TRUE); NewScan = TRUE; ret = _mread.title_scan(NewScan,MiltiScan,mString); break; case 'M': // NewScan All Areas -// errlog((char *)"msgscan_system case 'M'"); - ////errlog2("msgread_system() 1.3 M"); - // Current area newscan - //ret = _mread.StartReader(TRUE,TRUE); NewScan = TRUE; MiltiScan = TRUE; ret = _mread.title_scan(NewScan,MiltiScan,mString); break; } - //if (MiltiScan == TRUE) - // urec->lastmbarea = Origarea; - urec->lastmbarea = Origarea; CURRENT_MAREA = Origarea; - // Always reset last message to 0. urec->lastmsg = 0; return ret; } -/* -// Email Startup -void menu_func::msgemail_system() -{ - msg_read _mread; - _mread.start(urec); - CURRENT_MAREA = urec->lastmbarea; - _mread.DoPostEmail(FALSE); -} -*/ - - /** * Command Execute - Post a Message in current Area */ @@ -2277,9 +1499,9 @@ void menu_func::msgpost_system(char *mString) unsigned long Origarea = 0; Origarea = urec->lastmbarea; - std::stringstream iconvert(mString); // In + std::stringstream iconvert(mString); int i = 0; - // Convert String to Int + if (iconvert >> i) { urec->lastmbarea = i; CURRENT_MAREA = i; @@ -2295,53 +1517,13 @@ void menu_func::msgpost_system(char *mString) if (mr.Pubpriv == PRIVATE) { _mread.DoPostEmail(FALSE); } else { - _mread.SetupMsgPost(); // Freezing On Return with Abort. + _mread.SetupMsgPost(); } - // Reset to Original Area if we forced changed by menu command. CURRENT_MAREA = Origarea; urec->lastmbarea = Origarea; } -// Pack Message Areas (WIP) -/* -void menu_func::msgpack_system(int all) { - - msg_pack _mpack; - // Before Language String - if (all == TRUE) { - _mpack.PackAllAreas(); - } - else { - _mpack.PackCurrentArea(urec->lastmbarea); - } - - // After Language String - pipe2ansi((char *)"|CR|04completed. |07"); - getkey(true); // Pause -} - -// Pack Message Areas -void menu_func::msgtrunc_system(int all) { - - msg_pack _mpack; - // Before Language String - int MaxMsgs = 200; - - if (all == TRUE) { - _mpack.TruncAllAreas(); - } - else { - _mpack.TruncCurrentArea(urec->lastmbarea,MaxMsgs); - } - - // After Language String - pipe2ansi((char *)"|CR|04completed. |07"); - getkey(true); // Pause -} -*/ - - /** * Command Execute - Change Message Area */ @@ -2369,20 +1551,13 @@ void menu_func::msgarea_change(int change) */ void menu_func::msgarea_list() { - //UserRec trec; - //memcpy(&trec,urec,sizeof(UserRec)); - msg_area _marea; _marea.SetupList(urec); _marea.init_db(); - //_marea.StartList(); - // when exiting list, reset user area - // to global that was selected in list. urec->lastmbarea = CURRENT_MAREA; } - /** * Command Execute - User Listing */ @@ -2398,45 +1573,6 @@ int menu_func::usrlist_list() return idx; } -/* -// Change Message Area -void menu_func::filearea_change(int change) -{ - int total = file_count(); - --total; - - if (urec->lastmbarea > total) - urec->lastmbarea = CURRENT_FAREA; - - switch(change) - { - case 1: - if(urec->lastmbarea < total) ++urec->lastmbarea; - break; - - case 2: - if(urec->lastmbarea > 1) --urec->lastmbarea; - break; - } - CURRENT_FAREA = urec->lastmbarea; -} - -// Set file Area List -void menu_func::filearea_list() -{ - UserRec trec; - memcpy(&trec,urec,sizeof(UserRec)); - - std::string tmp; - ParseFArea(&trec, tmp); - - file_area _farea; - _farea.SetupList(urec); - _farea.StartList((char *)tmp.c_str()); -} -*/ - - /** * Command Execute - Write Private Mail. */ @@ -2449,7 +1585,6 @@ void menu_func::write_email() memset(&u,0,sizeof(UserRec)); - // Ask for Users Handle / Or User Number while (1) { strcpy(rBuffer,""); lang_get(text,42); @@ -2458,7 +1593,7 @@ void menu_func::write_email() getline(rBuffer,len); if (strcmp(rBuffer,"") != 0 && strcmp(rBuffer,"\n") != 0) { - // Check if already exists + if(idx_match(rBuffer)) { strcpy((char *)u.handle, rBuffer); break; @@ -2469,22 +1604,18 @@ void menu_func::write_email() pipe2ansi(text); } } - // List all users or Abort on blank! pipe2ansi((char *)"|15|17"); } } - /** * Command Execute - Read Private Mail. */ void menu_func::email_list() { - msg_email _email; _email.SetupList(urec); _email.StartList(); - } /** @@ -2503,10 +1634,8 @@ void menu_func::start_external(char *mString) struct tm *time_p; int tmp = 0; - // Setup Current Date etc,, time_t ctime; ctime = user->dtlaston; - // Now Create Door.SYS time_p = localtime(&ctime); sprintf(file,"%sDORINFO%d.DEF",path.c_str(),NODE_NUM); @@ -2536,24 +1665,9 @@ void menu_func::start_external(char *mString) fprintf(fp, " 0\r\n"); fprintf(fp, "%s\r\n", buffer1); fprintf(fp, "%s\r\n", buffer2); - - /* - if (user.user_zipcity[0] == 0) - fprintf(fp, "No City Supplied\r\n"); - else - fprintf(fp, "%s\r\n", "n/a"); - */ fprintf(fp, "No City Supplied\r\n"); - - /* - if (ansi == 1) - fprintf(fp, "1\r\n"); - else - fprintf(fp, "0\r\n"); - */ fprintf(fp, "1\r\n"); - if (isSysop == TRUE) fprintf(fp, "%d\r\n", 255); else @@ -2566,7 +1680,6 @@ void menu_func::start_external(char *mString) // Outdated DOOR.SYS Format Though from DD sprintf(file,"%sDOOR.SYS",path.c_str()); - //elog2(file); if ((fp = fopen(file, "w")) == NULL) return; @@ -2583,25 +1696,9 @@ void menu_func::start_external(char *mString) fprintf(fp, "Y\r\n"); fprintf(fp, "Y\r\n"); fprintf(fp, "%s\r\n", user->handle); - - /* - if (user.user_zipcity[0] == 0) - fprintf(fp, "No City Supplied\r\n"); - else - fprintf(fp, "%s\r\n", user.user_zipcity); - if (user.user_voicephone[0] == 0) { - fprintf(fp, "No Phone Supplied\r\n"); - fprintf(fp, "No Phone Supplied\r\n"); - } else { - fprintf(fp, "%s\r\n", "n/a"); - fprintf(fp, "%s\r\n", "n/a"); - } - */ - fprintf(fp, "Not Supplied\r\n"); fprintf(fp, "Not Supplied\r\n"); fprintf(fp, "Not Supplied\r\n"); - fprintf(fp, "\r\n"); if (isSysop == TRUE) @@ -2613,20 +1710,9 @@ void menu_func::start_external(char *mString) fprintf(fp, "%s\r\n", buffer1); fprintf(fp, "%d\r\n", 256 * 60); fprintf(fp, "%d\r\n", 256); - - /* - if (ansi == 1) - fprintf(fp, "GR\r\n"); - else - fprintf(fp, "NG\r\n"); - */ fprintf(fp, "GR\r\n"); - - fprintf(fp, "%d\r\n", TERM_HEIGHT); // Screen Length - - //fprintf(fp, "%c\r\n", (user.user_toggles & (1L << 4) ? 'Y' : 'N')); + fprintf(fp, "%d\r\n", TERM_HEIGHT); fprintf(fp, "Y\r\n"); - fprintf(fp, "1,2,3,4,6,7\r\n"); fprintf(fp, "1\r\n"); fprintf(fp, "01/01/99\r\n"); @@ -2641,105 +1727,64 @@ void menu_func::start_external(char *mString) } sprintf(file,"%sCHAIN.TXT",path.c_str()); - //elog2(file); if ((fp = fopen(file, "w")) == NULL) return; else { - // Chain.txt - //1 User number fprintf(fp, "%lu\r\n", (ulong)user->num); - //MRBILL User alias fprintf(fp, "%s\r\n", (char *)user->handle); - //Bill User real name - We don't keep these! fprintf(fp, "%s\r\n", (char *)user->handle); - // User callsign (HAM radio) fprintf(fp, "\r\n"); - //21 User age - fprintf(fp, "25\r\n"); // Default Age - //M User sex + fprintf(fp, "25\r\n"); fprintf(fp, "%s\r\n", buffer1 ); - //16097.00 User gold fprintf(fp, "16097.00\r\n"); - //05/19/89 User last logon date memset(&buffer1,0,sizeof(buffer1)); strftime(buffer1, 26, "%m/%d/%y", time_p); fprintf(fp, "%s\r\n",buffer1); - //80 User colums fprintf(fp, "%i\r\n",TERM_WIDTH); - //25 User width fprintf(fp, "%i\r\n",TERM_HEIGHT); - //255 User security level (0-255) if (isSysop == TRUE) { fprintf(fp, "%d\r\n", 255); - //1 1 if Co-SysOp, 0 if not - //1 1 if SysOp, 0 if not - //1 1 if ANSI, 0 if not - //0 1 if at remote, 0 if local console fprintf(fp, "%d\r\n", 1); fprintf(fp, "%d\r\n", 1); fprintf(fp, "%d\r\n", 1); fprintf(fp, "%d\r\n", 1); } else { fprintf(fp, "%d\r\n", 50); - //1 1 if Co-SysOp, 0 if not - //1 1 if SysOp, 0 if not - //1 1 if ANSI, 0 if not - //0 1 if at remote, 0 if local console fprintf(fp, "%d\r\n", 0); fprintf(fp, "%d\r\n", 0); fprintf(fp, "%d\r\n", 1); fprintf(fp, "%d\r\n", 1); } - //2225.78 User number of seconds left till logoff fprintf(fp, "%d\r\n", 2225); - //F:\WWIV\GFILES\ System GFILES directory (gen. txt files) fprintf(fp, "%s\r\n", ANSIPATH); - //F:\WWIV\DATA\ System DATA directory fprintf(fp, "%s\r\n", DATAPATH); - //890519.LOG System log of the day memset(&buffer1,0,sizeof(buffer1)); strftime(buffer1, 26, "%y%m%d.log", time_p); fprintf(fp, "%s\r\n", buffer1); - //2400 User baud rate fprintf(fp, "%d\r\n", 19200); - //2 System com port fprintf(fp, "%d\r\n", 0); - //MrBill's Abode (the original) System name - //The incredible inedible MrBill System SysOp fprintf(fp, "%s\r\n", SYSTEM_NAME); fprintf(fp, "%s\r\n", SYSOP_NAME); - //83680 Time user logged on/# of secs. from midn. fprintf(fp, "%d\r\n", 83680); - fprintf(fp, "%d\r\n", 1); // User number of seconds on system so far - //5050 User number of uploaded k - //22 User number of uploads - //42 User amount of downloaded k - //1 User number of downloads + fprintf(fp, "%d\r\n", 1); fprintf(fp, "%d\r\n", 0); fprintf(fp, "%d\r\n", 0); fprintf(fp, "%d\r\n", 0); fprintf(fp, "%d\r\n", 0); - //8N1 User parity fprintf(fp, "8N1\r\n"); - //2400 Com port baud rate fprintf(fp, "%d\r\n", 19200); - //7400 WWIVnet node number fprintf(fp, "%d\r\n", 0); fclose(fp); } - // Execute Exteral Command (form later to another process!!! // Test Setting the Terminal back to Original. before running door. tcflush( STDOUT_FILENO, TCIFLUSH); if ( tcsetattr( STDOUT_FILENO, TCSADRAIN,&old_termios ) ) { - //return( 2 ); pipe2ansi((char *)" |CS Unable to set old_termios! |PA"); } - //pipe2ansi("|CS"); - //int iRet = system((char *)mString); } @@ -2755,7 +1800,6 @@ void menu_func::da_system(char *mString) _da.data_loop(); } - /** * Command Execute - Create User Auto Signature) */ @@ -2766,7 +1810,6 @@ void menu_func::msg_autosig() _mread.SetupUserSig(); } - /** * Menu System - Run Menu Command */ @@ -2777,26 +1820,17 @@ void menu_func::menu_docmd(CommandRec *cmdr) int ret; - ////errlog2("menu_docmd!! 2"); std::string parse; char sNode[60] = {0}; std::string::size_type id1; - // elog("Do MenuCmd: %c, %c",CmdKey[0],CmdKey[1]); - - // _loadnew = false; - ////errlog2("menu_docmd!! 3"); switch (c1) { - // Message Reader Return right away - case '!' : -// errlog((char *)"menu_docmd!! 3.2 - passthrough with !"); - // getting passed through + case '!' : break; // Data Area Menu Commands case 'D' : - ////errlog2("menu_docmd!! 4"); switch (c2) { case 'A' : // Execute This Data Area da_system((char *)cmdr->MString.c_str()); @@ -2804,9 +1838,6 @@ void menu_func::menu_docmd(CommandRec *cmdr) break; case '-' : //Execute Program/Door - - // Parse the mString for a Node Numbare and replace - // %NN = Node Number parse = cmdr->MString; while (1) { id1 = parse.find("%NN",0); @@ -2824,35 +1855,22 @@ void menu_func::menu_docmd(CommandRec *cmdr) } start_external((char *)parse.c_str()); - // Flush when returning from doors fflush(stdout); open_keyboard(); - - // pipe2ansi((char *)"|CS"); break; case 'L' : //Execute Program Download -// elog2(mString); start_external((char *)cmdr->MString.c_str()); - // Flush when returning from doors fflush(stdout); open_keyboard(); - // pipe2ansi((char *)"|CR"); - // startpause(); break; case 'P' : //Execute Python Script # ifdef HAVE_PYTHON - - // Some terms needs terminal reset for proper display. - // Ansi terminals are ok! pybbs_run((char *)cmdr->MString.c_str(), user); - // Flush when returning from scripts. fflush(stdout); open_keyboard(); - - //pipe2ansi((char *)"|CR|07Returned from script... |PA"); # endif break; @@ -2863,7 +1881,6 @@ void menu_func::menu_docmd(CommandRec *cmdr) // Data Area Menu Commands case 'U' : - ////errlog2("menu_docmd!! 5"); switch (c2) { case 'L' : //Execute Program Download start_external((char *)cmdr->MString.c_str()); @@ -2876,15 +1893,13 @@ void menu_func::menu_docmd(CommandRec *cmdr) // Matrix Menu Commands case '*' : - ////errlog2("menu_docmd!! 6"); switch (c2) { case 'L' : // Login ret = logon_system(c2); if (ret == 2) System_Alive = FALSE; else if (ret == 1) { _loadnew = true; - //_node.node_global_announce_login(); - lineolm_login(TRUE); + lineolm_login(TRUE); } break; @@ -2897,7 +1912,7 @@ void menu_func::menu_docmd(CommandRec *cmdr) // Display Logoff Ansi here! ansiPrintf((char *)"logoff"); - term_option(0); // Put Echo Back on! Cywing + term_option(0); break; case 'P' : //Forgot Password @@ -2915,7 +1930,6 @@ void menu_func::menu_docmd(CommandRec *cmdr) // Message System Commands case 'M' : - ////errlog2("menu_docmd!! 7"); switch (c2) { case 'R' : // Message Reader msgscan_system(c2,(char *)cmdr->MString.c_str()); @@ -2962,67 +1976,14 @@ void menu_func::menu_docmd(CommandRec *cmdr) } break; - /* - case 'F' : - ////errlog2("menu_docmd!! 8"); - switch (c2) - { - case 'A' : // File Area List - filearea_list(); - break; - - case '+' : // Next File Area - filearea_change(1); - break; - - case '-' : // Previous File Area - filearea_change(2); - break; - - case 'L' : // List Files - // fileidx_display(); // Testing only! - break; - } - break;*/ - - // Email - /* - case 'E' : - ////errlog2("menu_docmd!! 9"); - switch (c2) - { - case 'W' : // Write Email - msgemail_system(); - _loadnew = true; - break; - case 'R' : // Email Reader - msgscan_system(c2,(char *)cmdr->MString.c_str()); - _loadnew = true; - break; - - case 'N' : // Email NewScan - msgscan_system(c2,(char *)cmdr->MString.c_str()); - _loadnew = true; - break; - - - default: // None Found! - break; - } - break; - */ - // Sysop Commands case '%' : - ////errlog2("menu_docmd!! 10"); // Only Sysop can have these commands execute! if (isSysop == TRUE) { switch (c2) { case 'I' : // File Import -// import_filedir(); break; case '#' : // Menu Editor - //menu_edit(); _loadnew = true; break; @@ -3035,19 +1996,15 @@ void menu_func::menu_docmd(CommandRec *cmdr) break; case 'C' : // Pack Current Mesasge Area -// msgpack_system(FALSE); break; case 'P' : // Pack All Mesasge Areas -// msgpack_system(TRUE); break; case 'T' : // Truncate All Message Areas -// msgtrunc_system(TRUE); break; case 'R' : // Truncate Current Area -// msgtrunc_system(FALSE); break; case 'E' : // Sysop Email Scan @@ -3061,11 +2018,9 @@ void menu_func::menu_docmd(CommandRec *cmdr) break; case '-' : - ////errlog2("menu_docmd!! 11"); switch (c2) { case '^' : // Change Menu - //strcpy(_curmenu,mString); _curmenu.clear(); _curmenu = cmdr->MString; _loadnew = true; @@ -3112,17 +2067,13 @@ void menu_func::menu_docmd(CommandRec *cmdr) } break; - // Node case 'N' : // Node switch (c2) { case 'W' : // Whois Online. - //_node.whoisonline(); node_message(TRUE); break; case 'M' : // Node Messages - WIP not yet setup correctly - //lineolm(1, "hi, testing this a test message"); - // Lists and sends a node mode per selection. node_message(); break; default : @@ -3142,30 +2093,22 @@ void menu_func::menu_docmd(CommandRec *cmdr) void menu_func::menu_setuser(UserRec *user) { urec = user; - start_session(urec); // Pass User Info to STDIO Conio Class + start_session(urec); } - /** * Menu System - Main System Loop Starts Here. */ void menu_func::menu_mainloop(UserRec *user) { urec = user; - start_session(urec); // Pass User Info to STDIO Conio Class + start_session(urec); char mString[255]= {0}; while (System_Alive) { - // System is Active - ////errlog2("main_loop: readin() 1"); menu_readin(); - - ////errlog2("main_loop: readin() 2 , %i",noc);//,nogc); - ////errlog2("main_loop: menu_proc 3"); menu_proc(mString); - ////errlog2("main_loop: menu_proc 4"); } - // Done, Send Logoff Message. lineolm_login(FALSE); } diff --git a/src/menu_func.h b/src/menu_func.h index f4b6aad..308a868 100755 --- a/src/menu_func.h +++ b/src/menu_func.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2004-2014 by Michael Griffin * + * Copyright (C) 2004-2017 by Michael Griffin * * mrmisticismo@hotmail.com * * * * Purpose: * @@ -12,12 +12,6 @@ * (at your option) any later version. * ***************************************************************************/ -// Enthral SVN: $Id: menu_func.h 1 2014-03-29 07:30:21Z mercyful $ -// Source: $HeadURL: file:///home/merc/repo/enthral/trunk/src/menu_func.h $ -// $LastChangedDate: 2014-03-29 02:30:21 -0500 (Sat, 29 Mar 2014) $ -// $LastChangedRevision: 1 $ -// $LastChangedBy: mercyful $ - # ifndef MENU_FUNC_H # define MENU_FUNC_H @@ -72,27 +66,25 @@ class menu_func : private ConsoleIO, unsigned long cntEscCmds; // = 0; int c, cc; - bool EscHit;// = false; // Is Input key Escaped char, or Normal Key + bool EscHit; // Is Input key Escaped char, or Normal Key char outBuff[1024]; // Holds Formatted Lightbar Data std::string output; // Buffer for writing all lightbars at the same time - short sRand;// = 0; // Randmise Text Scrollies - PASSING *p;// = 0; // For passing Menu command to new thread + short sRand; // Randmise Text Scrollies + PASSING *p; // For passing Menu command to new thread pthread_t ahThread; bool tScroll; int executed; // Test's for hot keys commands excuted, if non pass through loop + // This is so scrolling isn't killed with invalid menu input! - int exe;// = 0; + int exe; uint32_t CURRENT_AREA; // Lightbar Starting Position for Interfaces. - // This needs access from ie Title Scan Class. menu_func(); menu_func(UserRec *tu); ~menu_func(); - //void start_menu_func(UserRec *user); - // Below here are Menu Processing Functions bool _loadnew; @@ -126,28 +118,20 @@ class menu_func : private ConsoleIO, void menu_proc(char *mString, uint32_t area=0); // Initalizes the User Logon / Application Process - int logon_system(unsigned char c); // Init Logon Sequence / Application + int logon_system(unsigned char c); void fileedit_system(); void filearea_change(int change); void filearea_list(); - void msgedit_system(); // Init Message Base Editor + void msgedit_system(); - //int msgread_system(unsigned char c, char *mString=0); // Init Message Reader System - // For the Email Reader -// int emailread_system(unsigned char c, char *mString=0); int msgscan_system(unsigned char c, char *mString=0); void msgemail_system(); void msgpost_system(char *mString=(char *)"\0"); - // WIP Not finished@@@ - void msgpack_system(int all); - void msgtrunc_system(int all); - // WIP Not finished@@@ - void msgarea_change(int change); void msgarea_list(); diff --git a/src/msg_area.cpp b/src/msg_area.cpp index 719620b..9432915 100755 --- a/src/msg_area.cpp +++ b/src/msg_area.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2004-2014 by Michael Griffin * + * Copyright (C) 2004-2017 by Michael Griffin * * mrmisticismo@hotmail.com * * * * Purpose: Message Area Full Screen Listing * @@ -12,12 +12,6 @@ * (at your option) any later version. * ***************************************************************************/ -// Enthral SVN: $Id: msg_area.cpp 1 2014-03-29 07:30:21Z mercyful $ -// Source: $HeadURL: file:///home/merc/repo/enthral/trunk/src/msg_area.cpp $ -// $LastChangedDate: 2014-03-29 02:30:21 -0500 (Sat, 29 Mar 2014) $ -// $LastChangedRevision: 1 $ -// $LastChangedBy: mercyful $ - # include "struct.h" # include "language.h" # include "menu_func.h" @@ -199,14 +193,11 @@ void msgarea_ini::msga_check(std::string cfgdata) */ int msgarea_ini::msga_parse(int idx) { - if (!msga_exists()) { perror("Error unable to read msgarea.ini, check permissions!"); return 0; } - //msga_create(); - char name[255]= {0}; char name2[255]= {0}; @@ -247,40 +238,15 @@ int msgarea_ini::msga_parse(int idx) */ msg_area::msg_area() { - tTop = 1; tBot = 1; } - /** * Message Area - Startup */ void msg_area::init_db() { - - - /* - bbs_cfg bcfg; - bcfg.parseconfig(); - - // Setup in Config file now. - std::string node = bcfg.SQL_LOGINSERVER, - base = bcfg.SQL_DATABASENAME, - user = bcfg.SQL_LOGINNAME, - pass = bcfg.SQL_LOGINPASSWORD; - - StderrLog log; - std::string err; - Database::Mutex mutex; - - Database db(mutex,node,user,pass,base, (IError*)&log); - Query q(db); - if (!q.Connected()) { - cout << "\r\nSQL: Not Connected!" << endl; - } - StartList(q); - */ StartList(); } @@ -290,33 +256,10 @@ void msg_area::init_db() */ vector< mb_list_rec > msg_area::read_areas() { - - /* - bbs_cfg bcfg; - bcfg.parseconfig(); - - // Setup in Config file now. - std::string node = bcfg.SQL_LOGINSERVER, - base = bcfg.SQL_DATABASENAME, - user = bcfg.SQL_LOGINNAME, - pass = bcfg.SQL_LOGINPASSWORD; - - StderrLog log; - std::string err; - Database::Mutex mutex; - - Database db(mutex,node,user,pass,base, (IError*)&log); - Query q(db); - if (!q.Connected()) { - cout << "\r\nSQL: Not Connected!" << endl; - }*/ - ConsoleIO s; mb_list_rec mbl; std::vector< mb_list_rec > result; -// s . errlog((char *)"read_areas"); - ulong idx = 0; //Start at 1, 0 is Email, skip email is public area listing while(read_mbaselist(&mbl,idx)) { mbl . idx = idx; @@ -324,53 +267,6 @@ vector< mb_list_rec > msg_area::read_areas() ++idx; } - /* - ulong in = 0; - q . get_result("SELECT msg_area, msg_desc, msg_type, msg_status, msg_group_id, msg_security_id FROM marea_cfg order by sortorder"); - ulong numrows = q . num_rows(); // get how many rows returned. - - //cout << "\r\nNumrows: " << numrows << endl; - s . errlog((char *)"Numrows: ",numrows); - - in = 0; - while(q . fetch_row()) { - //s . errlog((char *)"loop"); - ++in; - std::string str; - - str = q . getstr(0); - //s . errlog((char *)"msg_area: %s",str.c_str()); - snprintf((char *)mbl . msg_area, sizeof(mbl . msg_area), "%s", str.c_str()); - - str = q . getstr(1); - //s . errlog((char *)"msg_desc: %s",str.c_str()); - snprintf((char *)mbl . msg_desc, sizeof(mbl . msg_desc), "%s", str.c_str()); - - mbl . msg_type = q . getval(2); - mbl . msg_status = q . getval(3); - mbl . msg_group_id = q . getval(4); - mbl . msg_security_id = q . getval(5); - - result . push_back(mbl); - } - - - //s . errlog((char *)"read_areas cnt: %lu", in); - q . free_result(); - - s . errlog((char *)"read_areas Done!"); - - // Just looping through to test results not really needed. - ulong max_areas = result.size(); - s . errlog((char *)"vector max_areas: %lu",max_areas); - */ - - - /* Testing. - for (ulong i = 0; i != max_areas; i++) { - s . errlog((char *)"vector str1: %s",(char *)result[i].msg_area); - s . errlog((char *)"vector str2: %s",(char *)result[i].msg_desc); - } */ return result; } @@ -383,16 +279,13 @@ vector< mb_list_rec > msg_area::read_areas() */ vector< list_bar > msg_area::build_arealist(UserRec *usr, std::string &temp) //, Query &qry) { { - mb_list_rec mbl; list_bar mbar; std::vector result; std::vector mareas; - ConsoleIO s(usr); // Pass User Incase there are MCI Codes for User Info. - -// s . errlog((char *)" * build_areas * "); + ConsoleIO s(usr); int c = 0; //std::string temp = ""; @@ -405,16 +298,12 @@ vector< list_bar > msg_area::build_arealist(UserRec *usr, std::string &temp) / long idx = 1; long cnt = 0; long i = 0; -// long basenum = 0; -// long lr = 0; char MCI[3]= {0}; char temp2[100]= {0}; int space = 0; int foundr = FALSE; int foundl = FALSE; -// int reset = FALSE; -// int dont = FALSE; std::string ans = ""; std::string ans1 = ""; @@ -467,33 +356,16 @@ vector< list_bar > msg_area::build_arealist(UserRec *usr, std::string &temp) / } fclose(inStream); - int area_cnt = 0; - - /* - qry.get_result("SELECT COUNT(*) FROM marea_cfg"); - qry.fetch_row(); - basenum = qry.getval(); - qry.free_result(); - */ - //while(read_mbaselist(&mb,idx)) { - // Read All Areas - mareas = read_areas(); - + int area_cnt = 0; + mareas = read_areas(); long num_areas = 0; long max_areas = mareas.size(); - - - //s . errlog((char *)"build_arealist basenum %lu", basenum); -// s . errlog((char *)"build_arealist max_areas %lu", max_areas); - usr->lastmsg = 0; + usr->lastmsg = 0; while(area_cnt < max_areas) { if (num_areas == max_areas) break; mbl = mareas[num_areas]; - -// s . errlog((char *)"build_arealist mbl . idx %lu", mbl.idx); - ++num_areas; ++idx; @@ -502,11 +374,8 @@ vector< list_bar > msg_area::build_arealist(UserRec *usr, std::string &temp) / ans = ans4; // Dispaly HighLight (New Messages) ans = ans3; // Dispaly LowLight (New Messages) - -// reset = FALSE; temp3.erase(); - for (int icnt = 0; icnt < 4; icnt++) { switch (icnt) { @@ -603,26 +472,6 @@ vector< list_bar > msg_area::build_arealist(UserRec *usr, std::string &temp) / // Count how many unread messages cnt = CountNewMsgs(mbl . idx,usr); - /* - if (cnt == -1) cnt = 0; - //else ++cnt; - - lr = JamAreaGetLast(usr->idx,&mbl); - lr = 0; - if (lr == -1) lr = 0; - if (lr > cnt ) lr = cnt; - else if (lr != 0) --lr; - if (cnt == 0) lr = 0; - - // Re-Process and Reset to Correct Mid Ansi - //if (cnt-lr >= 1 && reset == FALSE && (ans != ans2 || ans != ans4)) { - // reset = TRUE; - // goto RESTART; - //} - - */ - - // sprintf(temp2,"%ld",cnt-lr); sprintf(temp2,"%ld",cnt); if (foundl) { s.lspacing(temp2,space); @@ -646,7 +495,6 @@ vector< list_bar > msg_area::build_arealist(UserRec *usr, std::string &temp) / break; case '\n' : - // temp3 += '\r'; break; default : @@ -676,36 +524,15 @@ vector< list_bar > msg_area::build_arealist(UserRec *usr, std::string &temp) / break; } - //result . push_back(mbar); - //temp += temp3; temp3.erase(); - } // End of (4) Look for each string. - - /* - s . errlog((char *)"mbar: 1 %s",mbar . ansi_1.c_str()); - s . errlog((char *)"mbar: 2 %s",mbar . ansi_2.c_str()); - s . errlog((char *)"mbar: 3 %s",mbar . ansi_3.c_str()); - s . errlog((char *)"mbar: 4 %s",mbar . ansi_4.c_str()); - - - s . pipe2ansi((char *)mbar . ansi_1.c_str()); - s . pipe2ansi((char *)mbar . ansi_2.c_str()); - s . pipe2ansi((char *)mbar . ansi_3.c_str()); - s . pipe2ansi((char *)mbar . ansi_4.c_str()); - */ - //s . startpause(); + } result . push_back(mbar); temp3.erase(); ++area_cnt; - //s . errlog((char *)"area_cnt: %i",area_cnt); - } - // Update Clear Screen -// s . errlog((char *)"build_areas Done!"); -// s . errlog((char *)"Done, import - return result vector list"); return result; } @@ -716,7 +543,6 @@ vector< list_bar > msg_area::build_arealist(UserRec *usr, std::string &temp) / */ void msg_area::ParseHeader(char *filename) { - std::string temp; std::string path = ANSIPATH; path += filename; @@ -727,7 +553,6 @@ void msg_area::ParseHeader(char *filename) char MCI[3] = {0}; // Holds MCI Codes to Parse char sTemp[255] = {0}; int space = 0, foundr = 0 , foundl = 0; -// int c = 0; std::string buff; // Reads in Ansi file into Buffer Only @@ -736,32 +561,27 @@ void msg_area::ParseHeader(char *filename) int id1 = 0; while (id1 != -1) { - // parse justify spacing right / left passing in string before - // replacing mci code. to Properly Space Output Ansi. id1 = buff.find("%", 0); if (id1 == -1) break; memset(&MCI,0,sizeof(MCI)); space = 0; - // Check if MCI Code is Justified then Process this. + if (buff[id1+3] == '{') { // Left Justify - //elog("left justify: %c%c",buff[id1+4],buff[id1+5]); - MCI[0] = buff[id1+4]; // Get first Digit - MCI[1] = buff[id1+5]; // Get Second Digit + MCI[0] = buff[id1+4]; + MCI[1] = buff[id1+5]; space = atoi(MCI); foundr = FALSE; foundl = TRUE; } else if (buff[id1+3] == '}') { // Right Justify - //elog("right justify: %c%c",buff[id1+4],buff[id1+5]); - MCI[0] = buff[id1+4]; // Get first Digit - MCI[1] = buff[id1+5]; // Get Second Digit + MCI[0] = buff[id1+4]; + MCI[1] = buff[id1+5]; space = atoi(MCI); - //elog("right justify: %i",space); foundl = FALSE; foundr = TRUE; } // Now Get MCI Code - MCI[0] = buff[id1+1]; // Get first Digit - MCI[1] = buff[id1+2]; // Get Second Digit + MCI[0] = buff[id1+1]; + MCI[1] = buff[id1+2]; memset(&sTemp,0,sizeof(sTemp)); // Insert MCI Parsing here so we can reaplace full result with propering spacing. @@ -771,7 +591,6 @@ void msg_area::ParseHeader(char *filename) sprintf(sTemp,"%s", (char *)sTHEME_NAME); } - // MCI Translation . if (foundl == TRUE) { lspacing(sTemp,space); @@ -781,10 +600,9 @@ void msg_area::ParseHeader(char *filename) //If we Parsed Justify, then Erase that MCI Code as well. (space != 0) ? - buff.replace(id1,6,sTemp): - buff.replace(id1,3,sTemp); + buff.replace(id1,6,sTemp): + buff.replace(id1,3,sTemp); } - //elog("Finished Parsing MCI Codes..."); pipe2ansi((char *)buff.c_str()); } @@ -794,9 +612,7 @@ void msg_area::ParseHeader(char *filename) */ void msg_area::SetupList(UserRec *user) { - thisuser = user; - // Check What Theme user has selected. if (msga_parse(thisuser->readertheme) == FALSE) { msga_parse(); } @@ -809,10 +625,8 @@ void msg_area::SetupList(UserRec *user) */ int msg_area::change_theme(int idx) { - // Check What Theme user has selected. if (msga_parse(idx) == FALSE) { - // Theme Doesn't Exist. return FALSE; } thisuser->readertheme = idx; @@ -830,13 +644,11 @@ int msg_area::change_theme(int idx) return TRUE; } - /** * Message Areas - Area List Startup. */ char *msg_area::StartList() { - bool more = false; bool showmore = false; char mString[10] = {0}; @@ -844,8 +656,6 @@ char *msg_area::StartList() std::string _output; char outBuffer[200]; - // Startup Friend Classes - //language _lang; menu_func _mnuf; msg_readll mLink; @@ -858,8 +668,6 @@ char *msg_area::StartList() _usr.users_write(thisuser,thisuser->idx); _usr.users_read(&usr,thisuser->idx); -// errlog((char *)"Build AreaList - ThisUserID %lu, %s",usr.idx, usr.handle); - ConsoleIO s(&usr); _mnuf.menu_setuser(thisuser); @@ -874,65 +682,49 @@ char *msg_area::StartList() std::string rBuff; std::string::size_type id1 = 0; //id2, -// int num, num2; int len; std::string tmp; -// UserRec trec; // For Next / Prev Message Areas int CurrentPage = 0; -// int PreviousPage = 0; int bSize = 0; int boxsize = 0; bSize = tBot - tTop; ++bSize; - - //CURRENT_MAREA = 0; - //usr.lastmbarea = 0; - - // Run through Main Loop until exit from user - This Loop Probably not needed anymore. vector result; - -// errlog((char *)"Build AreaList - UserID %lu, %lu",usr.idx, usr.handle); - result = build_arealist(&usr, tmp); //, qry); + result = build_arealist(&usr, tmp); mLink.GetVector(result); while (1) { - // Jump to Current Page boxsize = mLink.Bot - mLink.Top; CurrentPage = CURRENT_MAREA / boxsize; - ParseHeader(sANSI_FILE); // Display Ansi - //tmp.erase(); + ParseHeader(sANSI_FILE); -// errlog((char *)"PutBuffer msg_area()"); - // Make sure we have areas. if (result.size() > 0) { - mLink.box_start_vector(CurrentPage,CURRENT_MAREA); // Draw Message Inside of Box + mLink.box_start_vector(CurrentPage,CURRENT_MAREA); } else { return NULL; } -// errlog((char *)"box_start done msg_area()"); // Start Input Loop. while(1) { _output.erase(); _output = "|16"; more = false; showmore = false; - //if (mLink.line_count() > 0) more = true; if (mLink.Page+1 != mLink.TotPages) more = true; // Show Down Arrow More! if (more) { - sprintf(outBuffer,"%s\x19",sMOREDOWN); // On + sprintf(outBuffer,"%s\x19",sMOREDOWN); showmore = true; } else { - sprintf(outBuffer,"%s ",sMOREDOWN); // Off + sprintf(outBuffer,"%s ",sMOREDOWN); } _output += outBuffer; @@ -963,12 +755,9 @@ char *msg_area::StartList() pipe2ansi((char *)_output.c_str()); - // Blank out the previous menu so we can reload, / redraw on restart. - //memset(&_mnuf._premenu,0,sizeof(_mnuf._premenu)); - // Make Msgqp2 Prompt Optional, Use if exists! // Also Let user Toggle on / off - if (_mnuf.cmdexist(sMENU_PROMPT2,0) /*&& thisuser->msgp2*/ ) { + if (_mnuf.cmdexist(sMENU_PROMPT2,0)) { if (more || mLink.Page > 1) { _mnuf._curmenu.clear(); _mnuf._curmenu = sMENU_PROMPT2; @@ -981,8 +770,7 @@ char *msg_area::StartList() _mnuf._curmenu = sMENU_PROMPT; } - // Readin the Menu Prompt and get or wait for input. -// So we don't reload all of the menu and propmts for a bad key, just ask again! + // Readin the Menu Prompt and get or wait for input. JMPINPUT: // Draw Input Box @@ -990,14 +778,13 @@ char *msg_area::StartList() strcpy(text,sINPUT_BOX); sprintf(outBuffer,"%d",mLink.Tot); - len = strlen(outBuffer)+1; // Last Ourbuf is Message Number + len = strlen(outBuffer)+1; inputfield(text,len); _output = text; _output += "|16"; pipe2ansi((char *)_output.c_str()); - _mnuf.menu_readin(); _mnuf.menu_proc(mString); ch = mString[1]; @@ -1007,18 +794,13 @@ char *msg_area::StartList() switch (toupper(ch)) { case 'Q': // Quit mLink.dispose_list(); - //_mnuf.~menu_func(); memcpy(thisuser,&usr,sizeof(UserRec)); -// errlog((char *)thisuser->handle); - vector() . swap(result); // Free Vector Up. - return NULL; //qBuf; + vector() . swap(result); + return NULL; case 'U': // UP if (CurrentPage != 0) { --CurrentPage; - - // Reset Bar to first Listing on each Page. - // CurrentPage = CURRENT_MAREA / boxsize; CURRENT_MAREA = CurrentPage * boxsize; mLink.box_start_vector(CurrentPage,CURRENT_MAREA); } else @@ -1028,9 +810,6 @@ char *msg_area::StartList() case 'D': // DN if (CurrentPage+1 != mLink.TotPages) { ++CurrentPage; - - // Reset Bar to first Listing on each Page. - // CurrentPage = CURRENT_MAREA / boxsize; CURRENT_MAREA = CurrentPage * boxsize; mLink.box_start_vector(CurrentPage,CURRENT_MAREA); } else @@ -1038,62 +817,38 @@ char *msg_area::StartList() break; case '+': // Next Area - Move Down - -// s . errlog((char *)"CURRENT_MAREA+1: %i. Listing: %i ", CURRENT_MAREA+1,mLink.listing.size()); if (CURRENT_MAREA+1 == (signed)mLink.listing.size() || (signed)mLink.listing.size() == 0) goto JMPINPUT; ++CURRENT_MAREA; thisuser->lastmbarea = CURRENT_MAREA; - -// s . errlog((char *)"CurrentPage: %i. PreviousPage: %i ", CurrentPage, PreviousPage); -// s . errlog((char *)"boxsize: %i. TotPages: %i. Page: %i ", boxsize, mLink.TotPages, mLink.Page); -// PreviousPage = CurrentPage; - - //Calculate if we go down, ++Current Area, are we on next page or not. - // Becasue 0 Based, need to add +1 - // Test if we moved to next page. if (CURRENT_MAREA+1 < (boxsize*(CurrentPage+1))+1) { // Still on Same Page if (mLink.listing[CURRENT_MAREA-1].isnew) { -// errlog((char *)"!!! isNEW = 'Y' 3"); -// s . errlog((char *)"CURRENT_MAREA+1 %i < (boxsize*CurrentPage+1)+1, %i",CURRENT_MAREA+1,boxsize*(CurrentPage+1)+1); - // Lowlight Current, then Highlight Next. sprintf(rBuffer, "\x1b[%i;%iH|16%s", mLink.current_selection, 1, (char *)mLink.listing[CURRENT_MAREA-1].ansi_3.c_str()); -// s . errlog((char *)rBuffer); } else { -// errlog((char *)"!!! isNEW = 'N' 1"); -// s . errlog((char *)"CURRENT_MAREA+1 %i < (boxsize*CurrentPage+1)+1, %i",CURRENT_MAREA+1,boxsize*(CurrentPage+1)+1); - // Lowlight Current, then Highlight Next. sprintf(rBuffer, "\x1b[%i;%iH|16%s", mLink.current_selection, 1, (char *)mLink.listing[CURRENT_MAREA-1].ansi_1.c_str()); -// s . errlog((char *)rBuffer); } _output += rBuffer; mLink.current_selection += 1; if (mLink.listing[CURRENT_MAREA].isnew) { -/// errlog((char *)"!!! isNEW = 'Y' 4"); sprintf(rBuffer, "\x1b[%i;%iH|16%s", mLink.current_selection, 1, (char *)mLink.listing[CURRENT_MAREA].ansi_4.c_str()); -// s . errlog((char *)rBuffer); } else { -// errlog((char *)"!!! isNEW = 'N' 2"); sprintf(rBuffer, "\x1b[%i;%iH|16%s", mLink.current_selection, 1, (char *)mLink.listing[CURRENT_MAREA].ansi_2.c_str()); -// s . errlog((char *)rBuffer); } _output += rBuffer; pipe2ansi((char *)_output.c_str()); _output.erase(); - goto JMPINPUT; //Not moving down a page. + goto JMPINPUT; } else { // Move to next Page! -// s . errlog((char *)"DN - CURRENT_MAREA !< Move next Page"); ++CurrentPage; mLink.box_start_vector(CurrentPage,CURRENT_MAREA); } break; case '-': // Previous Area - Move Up - // Skipping to JMPINPUT bypasses redraws, much faster! if (CURRENT_MAREA != 0) --CURRENT_MAREA; else @@ -1103,67 +858,38 @@ char *msg_area::StartList() goto JMPINPUT; thisuser->lastmbarea = CURRENT_MAREA; - -// s . errlog((char *)"!!! CurrentPage: %i. PreviousPage: %i ", CurrentPage, PreviousPage); -// s . errlog((char *)"boxsize: %i. TotPages: %i. Page: %i ", boxsize, mLink.TotPages, mLink.Page); -// PreviousPage = CurrentPage; - -// s . errlog((char *)"!!! CurrentPage: %i. PreviousPage: %i ", CurrentPage, PreviousPage); - //Calculate if we go down, --Current Area, are we on next page or not. - // Becasue 0 Based, need to add +1 - // Test if we moved to next page. if (CURRENT_MAREA+1 > (boxsize*(CurrentPage))) { - // Still on Same Page -// s . errlog((char *)"CURRENT_MAREA+1 %i > (boxsize*CurrentPage+1)+1, %i",CURRENT_MAREA+1, ((boxsize*CurrentPage)+1) ); - // Lowlight Current, then Highlight Next. if (mLink.listing[CURRENT_MAREA+1].isnew) { -// errlog((char *)"!!! isNEW = 'Y' 1"); sprintf(rBuffer, "\x1b[%i;%iH|16%s", mLink.current_selection, 1, (char *)mLink.listing[CURRENT_MAREA+1].ansi_3.c_str()); -// s . errlog((char *)rBuffer); + } else { -// errlog((char *)"!!! isNEW = 'N' 3"); sprintf(rBuffer, "\x1b[%i;%iH|16%s", mLink.current_selection, 1, (char *)mLink.listing[CURRENT_MAREA+1].ansi_1.c_str()); -// s . errlog((char *)rBuffer); } _output = rBuffer; mLink.current_selection -= 1; if (mLink.listing[CURRENT_MAREA].isnew) { -// errlog((char *)"!!! isNEW = 'Y' 4"); sprintf(rBuffer, "\x1b[%i;%iH|16%s", mLink.current_selection, 1, (char *)mLink.listing[CURRENT_MAREA].ansi_4.c_str()); -// s . errlog((char *)rBuffer); } else { -// errlog((char *)"!!! isNEW = 'N' 2"); sprintf(rBuffer, "\x1b[%i;%iH|16%s", mLink.current_selection, 1, (char *)mLink.listing[CURRENT_MAREA].ansi_2.c_str()); -// s . errlog((char *)rBuffer); } _output += rBuffer; pipe2ansi((char *)_output.c_str()); _output.erase(); -// s . errlog((char *)"CurrentPage: %i. PreviousPage: %i ", CurrentPage, PreviousPage); -// s . errlog((char *)"boxsize: %i. TotPages: %i. Page: %i ", boxsize, mLink.TotPages, mLink.Page); - goto JMPINPUT; //Not moving down a page. + goto JMPINPUT; break; } else { - // Move to next Page! -// s . errlog((char *)"2!!!! UP - CURRENT_MAREA !< Move prev Page"); -// s . errlog((char *)"First CurrentPage: %i. PreviousPage: %i ", CurrentPage, PreviousPage); --CurrentPage; -// s . errlog((char *)"Now CurrentPage: %i. PreviousPage: %i ", CurrentPage, PreviousPage); -// s . errlog((char *)"boxsize: %i. TotPages: %i. Page: %i ", boxsize, mLink.TotPages, mLink.Page); - mLink.box_start_vector(CurrentPage,CURRENT_MAREA); - //goto JMPINPUT; } break; default : // Executing a menu command and returning back to list. - //goto JMPINPUT; - vector() . swap(result); // Free Vector Up. + vector() . swap(result); tmp.erase(); - result = build_arealist(&usr, tmp); //, qry); + result = build_arealist(&usr, tmp); mLink.GetVector(result); ParseHeader(sANSI_FILE); @@ -1173,64 +899,43 @@ char *msg_area::StartList() } // of IF [!] else { if (mString[0] == '#') { -// s . errlog((char *)"# - CURRENT_MAREA "); - // received Digit Input From Menu Prompt memset(&rBuffer,0, sizeof(rBuffer)); memset(&text,0, sizeof(text)); strcpy(text,sINPUT_BOX); sprintf(outBuffer,"%d",mLink.Tot); - len = strlen(outBuffer)+1; // Last Ourbuf is Message Number + len = strlen(outBuffer)+1; inputfield(text,len); pipe2ansi(text); sprintf(sNum,"%c",ch); getline(rBuffer,len,sNum); -// num = 0; -// num2 = 0; - // Catch any invalid input id1 = atoi(rBuffer); - //if (id1 == 0) - //goto JMPINPUT; - // Verify Area Input Range. if (id1 > mLink.listing.size() || id1 < 1) { -// s . errlog((char *)"# - Incorrect Input"); - // Redraw input box memset(&text,0, sizeof(text)); strcpy(text,sINPUT_BOX); - sprintf(outBuffer,"%d",mLink.Tot); - len = strlen(outBuffer)+1; // Last Ourbuf is Message Number - + len = strlen(outBuffer)+1; inputfield(text,len); pipe2ansi(text); goto JMPINPUT; } else { -// s . errlog((char *)"# - Jump to area id1 %i",id1); - //Justjump to area, then reset to page that area is in. CURRENT_MAREA = id1-1; thisuser->lastmbarea = CURRENT_MAREA; - - // Jump to Current Page CurrentPage = CURRENT_MAREA / boxsize; -// s . errlog((char *)"# - Jump to area box_start_vector - CurrentPage %i",CurrentPage); ParseHeader(sANSI_FILE); mLink.box_start_vector(CurrentPage,CURRENT_MAREA); - // mLink.box_start_vector(CurrentPage); } } // End if [#] else { // Not #, Check for Escaped Key Input - ch = mString[0]; switch (toupper(ch)) { case 'A': // UP if (CurrentPage != 0) { --CurrentPage; - - // Reset Bar to first Listing on each Page. CURRENT_MAREA = CurrentPage * boxsize; mLink.box_start_vector(CurrentPage,CURRENT_MAREA); } else @@ -1240,7 +945,6 @@ char *msg_area::StartList() case 'B': // DN if (CurrentPage+1 != mLink.TotPages) { ++CurrentPage; - // Reset Bar to first Listing on each Page. CURRENT_MAREA = CurrentPage * boxsize; mLink.box_start_vector(CurrentPage,CURRENT_MAREA); } else @@ -1248,12 +952,10 @@ char *msg_area::StartList() break; default : - - vector() . swap(result); // Free Vector Up. + vector() . swap(result); tmp.erase(); - result = build_arealist(&usr, tmp); //, qry); + result = build_arealist(&usr, tmp); mLink.GetVector(result); - ParseHeader(sANSI_FILE); mLink.box_start_vector(CurrentPage,CURRENT_MAREA); break; diff --git a/src/msg_area.h b/src/msg_area.h index d9a374f..2ede686 100755 --- a/src/msg_area.h +++ b/src/msg_area.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2004-2014 by Michael Griffin * + * Copyright (C) 2004-2017 by Michael Griffin * * mrmisticismo@hotmail.com * * * * Purpose: * @@ -12,16 +12,9 @@ * (at your option) any later version. * ***************************************************************************/ -// Enthral SVN: $Id: msg_area.h 1 2014-03-29 07:30:21Z mercyful $ -// Source: $HeadURL: file:///home/merc/repo/enthral/trunk/src/msg_area.h $ -// $LastChangedDate: 2014-03-29 02:30:21 -0500 (Sat, 29 Mar 2014) $ -// $LastChangedRevision: 1 $ -// $LastChangedBy: mercyful $ - # ifndef MSG_AREA_H # define MSG_AREA_H -//# include # include # include @@ -79,16 +72,13 @@ class msg_area : private mbapi_jam, msgarea_ini, msgs void init_db(); std::vector read_areas(); - std::vector build_arealist(UserRec *usr, std::string &temp);//, Query &qry); + std::vector build_arealist(UserRec *usr, std::string &temp); void ParseHeader(char *filename); int change_theme(int idx); void SetupList(UserRec *user); - //char *StartList(char *OrgMsg); - char *StartList(); - //char *StartList(Query &qry); }; diff --git a/src/msg_edit.cpp b/src/msg_edit.cpp index 5b05bf9..e14a166 100755 --- a/src/msg_edit.cpp +++ b/src/msg_edit.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2004-2014 by Michael Griffin * + * Copyright (C) 2004-2017 by Michael Griffin * * mrmisticismo@hotmail.com * * * * Purpose: * @@ -12,12 +12,6 @@ * (at your option) any later version. * ***************************************************************************/ -// Enthral SVN: $Id: msg_edit.cpp 1 2014-03-29 07:30:21Z mercyful $ -// Source: $HeadURL: file:///home/merc/repo/enthral/trunk/src/msg_edit.cpp $ -// $LastChangedDate: 2014-03-29 02:30:21 -0500 (Sat, 29 Mar 2014) $ -// $LastChangedRevision: 1 $ -// $LastChangedBy: mercyful $ - # include "struct.h" # include "mb_api.h" @@ -43,44 +37,19 @@ char posttyp[2][11]= {"Public","Private"}; # define MSG_ORIGIN 3 - /** * Message Area Editor - Inital New Message Area */ void msg_edit::init_mbase(mb_list_rec *mb) { - memset(mb,0,sizeof(mb_list_rec)); - sprintf((char *)mb->mbdisplay,"%s",(char *)"New Message Base"); // Description - sprintf((char *)mb->mbpath,"%s",(char *)MESGPATH); // Path to Message Files - sprintf((char *)mb->mbfile,"%s",(char *)"newbase"); // Filename -// mb->Type = MSGTYPE_JAM; // Default to JAM + sprintf((char *)mb->mbdisplay,"%s",(char *)"New Message Base"); + sprintf((char *)mb->mbpath,"%s",(char *)MESGPATH); + sprintf((char *)mb->mbfile,"%s",(char *)"newbase"); + mb->Kind = 0; // Local mb->Pubpriv = 0; // Public - /* - copy_ACS(&mb->SysopACS, &config.DefMsg.SysopACS); - copy_ACS(&mb->ReadACS, &config.DefMsg.ReadACS); - copy_ACS(&mb->WriteACS, &config.DefMsg.WriteACS); - copy_ACS(&mb->NetworkACS, &config.DefMsg.NetworkACS); - - strcpy(mb->OriginLine,config.DefMsg.OriginLine); - - mb->colors[MSG_QUOTE] =config.DefMsg.colors[MSG_QUOTE]; - mb->colors[MSG_TEXT] =config.DefMsg.colors[MSG_TEXT]; - mb->colors[MSG_TEAR] =config.DefMsg.colors[MSG_TEAR]; - mb->colors[MSG_ORIGIN] =config.DefMsg.colors[MSG_ORIGIN]; - - mb->Kind = config.DefMsg.Kind; - mb->Type = config.DefMsg.Type; - mb->Pubpriv = config.DefMsg.Pubpriv; - mb->Allowalias = config.DefMsg.Allowalias; - mb->scantype = config.DefMsg.scantype; - mb->fidoaddr = config.DefMsg.fidoaddr; - mb->MaxMsgs = config.DefMsg.MaxMsgs; - mb->MaxAge = config.DefMsg.MaxAge; - */ - // Setup Bit Flags for Toggable options. WIP BitClr(mb->flags.mbrealname,0); // 0x01 == off, 0x02 == on BitClr(mb->flags.mbvisible,0); // 0x01 @@ -93,7 +62,6 @@ void msg_edit::init_mbase(mb_list_rec *mb) BitClr(mb->flags.mbinternet,0); // 0x01 BitClr(mb->flags.mbfileattach,0); // 0x01 BitClr(mb->flags.mbstripcolor,0); // 0x01 - } /** @@ -101,7 +69,6 @@ void msg_edit::init_mbase(mb_list_rec *mb) */ void msg_edit::kill_mbase(int mbnum) { - mb_list_rec mbin; int i1=0,count=0; char ppath[1024]= {0}; @@ -118,13 +85,10 @@ void msg_edit::kill_mbase(int mbnum) i1++; } - // Remove Normal file sprintf(ppath,"%smsgforums.dat",DATAPATH); remove(ppath); - // Rename Tmp to Original sprintf(ppath2,"%smsgforums.tmp",DATAPATH); rename(ppath2, ppath); - // Remove Tmp remove(ppath2); } @@ -133,7 +97,6 @@ void msg_edit::kill_mbase(int mbnum) */ void msg_edit::delete_mbase() { - char ttxt[21]= {0}; int num, total_mbases; char sLine[200]= {0}; @@ -142,6 +105,7 @@ void msg_edit::delete_mbase() if (total_mbases < 1) { return; } + int len = 4; sprintf(sLine,"|CR |09Delete which? |07[|151|07-|15%d|07]|08: ", total_mbases); inputfield(sLine,len); @@ -159,15 +123,12 @@ void msg_edit::delete_mbase() */ void msg_edit::poke_mbase(int pokenum) { - mb_list_rec mbin; int total_mbases; total_mbases = _mfunc.msg_count(); memset(&mbin,0,sizeof(mb_list_rec)); - //printf ("\n pokenum %i, total_mbases %i", pokenum,total_mbases); - //Append At End of File if (pokenum > total_mbases) { init_mbase(&mbin); @@ -198,7 +159,6 @@ void msg_edit::poke_mbase(int pokenum) */ void msg_edit::insert_mbase() { - char sLine[200]; mb_list_rec mbin; memset(&mbin,0,sizeof(mb_list_rec)); @@ -238,18 +198,13 @@ void msg_edit::insert_mbase() */ void msg_edit::swap_mbase(int iFrom, int iTo) { - mb_list_rec mbfrom, mbin; - int total_mbases;//, count; - - // First Read in the Base here! + int total_mbases; memset(&mbfrom,0,sizeof(mb_list_rec)); _mfunc.read_mbaselist(&mbfrom, iFrom); - // Next Purge the the Original.. kill_mbase(iFrom); - total_mbases = _mfunc.msg_count(); //Append At End of File @@ -270,6 +225,7 @@ void msg_edit::swap_mbase(int iFrom, int iTo) _mfunc.save_mbaselist(&mbin,i1); } } + _mfunc.save_mbaselist(&mbfrom,iTo); return; } @@ -280,7 +236,6 @@ void msg_edit::swap_mbase(int iFrom, int iTo) */ void msg_edit::move_mbase() { - char ttxt[21]= {0}; char sLine[200]= {0}; int num = 0, num1 = 0, total_mbases = 0; @@ -318,7 +273,6 @@ void msg_edit::move_mbase() */ void msg_edit::modify_mbase() { - char ttxt[21]= {0}; char sLine[200]= {0}; int num; @@ -348,7 +302,6 @@ void msg_edit::modify_mbase() */ void msg_edit::edit_aka(mb_list_rec *mr) { - char sLine[200]= {0}; char ttxt[16]= {0}; char *p; @@ -359,9 +312,6 @@ void msg_edit::edit_aka(mb_list_rec *mr) pipe2ansi(sLine); getline(ttxt,sizeof(ttxt)); if (strcmp(ttxt," ") == 0) return; - //strcpy(mbl.mbdisplay,ttxt); - - //get_aka(ttxt); Maybe Impliment Later p=strtok(ttxt,":/."); if(p) mr->aka.zone=atoi(p); @@ -371,30 +321,16 @@ void msg_edit::edit_aka(mb_list_rec *mr) if(p) mr->aka.node=atoi(p); p=strtok(NULL,":/."); if(p) mr->aka.point=atoi(p); - - //mci("~SM`09Domain`0F: `1F"); - //ttxt[0]='\0'; - //get_str(config.aka[num].domain,21); } -/* -void msg_edit::ACS(ACSrec *acs, char *fstr) { - - class acs_levels *level = new acs_levels; - level->ACS_setup(acs, fstr); - delete level; -}*/ - - /** * Message Area Editor - Update Area */ void msg_edit::mod_mbase(int mbnum) { - mb_list_rec mbl; char faka[41]= {0}; - //char sigtxt[3][21]={"None","Short Sig.","Long Sig."}; + std::string TF; char rBuffer[200]= {0}; @@ -418,10 +354,6 @@ void msg_edit::mod_mbase(int mbnum) output += sLine; sprintf(sLine,"|CR |15B|07. Filename |11%s|16", (char *)mbl.mbfile); output += sLine; - - //if (mbl.Type == MSGTYPE_JAM) TF = "JAM"; - //else TF = "SQUISH"; - TF = "JAM"; sprintf(sLine,"|CR |15C|07. Message Type |11%s|16", TF.c_str()); @@ -430,7 +362,6 @@ void msg_edit::mod_mbase(int mbnum) output += sLine; sprintf(sLine,"|CR |15E|07. Posting Type |11%s|16", posttyp[mbl.Pubpriv]); output += sLine;; - //sprintf(sLine,"|CR |15F|07. [Unused] |15|19%s|16", mbl.infofile); if ((mbl.flags.mbvisible & 0x01) == 0) TF = "no"; @@ -438,10 +369,7 @@ void msg_edit::mod_mbase(int mbnum) TF = "yes"; sprintf(sLine,"|CR |15F|07. Sysop Area |11%s|16", TF.c_str()); - output += sLine; - //if (mbl.Allowalias) TF = "yes"; - //else TF = "no"; TF.erase(); if ((mbl.flags.mbrealname & 0x01) == 0) @@ -456,22 +384,6 @@ void msg_edit::mod_mbase(int mbnum) output += sLine; sprintf(sLine,"|CR |15L|07. AKA Address |11%s|16", faka); output += sLine; - - /* - mci("%sQuoted (%d)`0F, ", - ansic(mbl.colors[MSG_QUOTE]), - mbl.colors[MSG_QUOTE]); - mci("%sText (%d)`0F,", - ansic(mbl.colors[MSG_TEXT]), - mbl.colors[MSG_TEXT]); - mci("%sTear (%d)`0F,", - ansic(mbl.colors[MSG_TEAR]), - mbl.colors[MSG_TEAR]); - mci("%sOrigin (%d)~SM", - ansic(mbl.colors[MSG_ORIGIN]), - mbl.colors[MSG_ORIGIN]); - */ - sprintf(sLine,"|CR |15M|07. Origin Line |11%s|16", mbl.origin_line); output += sLine; output += "|CR|CR |15q|07.uit |15] +|07. next |15[ -|07. prev: \x1b[1;44m \x1b[D"; @@ -495,8 +407,6 @@ void msg_edit::mod_mbase(int mbnum) break; case 'C': - //if(mbl.Type == MSGTYPE_JAM) mbl.Type = MSGTYPE_SQUISH; - //else mbl.Type = MSGTYPE_JAM; break; case 'D': @@ -567,14 +477,8 @@ void msg_edit::mod_mbase(int mbnum) break; case 'G': - //mbl.Allowalias = (mbl.Allowalias)?0:1; break; mbl.flags.mbrealname = (mbl.flags.mbrealname)?0:1; break; - - /* case 'H': ACS(&mbl.WriteACS,mbl.mbdisplay); break; - case 'I': ACS(&mbl.ReadACS, mbl.mbdisplay); break; - case 'J': ACS(&mbl.SysopACS,mbl.mbdisplay); break;*/ - case 'K': mbl.sigtype++; if(mbl.sigtype<0 || mbl.sigtype>2) @@ -583,7 +487,6 @@ void msg_edit::mod_mbase(int mbnum) case 'L': edit_aka(&mbl); - //mbl.fidoaddr=pick_aka(); break; case 'M': @@ -595,12 +498,10 @@ void msg_edit::mod_mbase(int mbnum) case 'Q': _mfunc.save_mbaselist(&mbl, mbnum-1); -// _mfunc.save_msgbase(&mbl); return; case '+': case ']': _mfunc.save_mbaselist(&mbl, mbnum-1); -// _mfunc.save_msgbase(&mbl); if (mbnum+1 > total_mbases) break; @@ -609,13 +510,10 @@ void msg_edit::mod_mbase(int mbnum) memset(&mbl,0,sizeof(mb_list_rec)); _mfunc.read_mbaselist(&mbl, mbnum-1); if(mbl.sigtype < 0 || mbl.sigtype > 2) mbl.sigtype = 0; - - //total_mbases = _mfunc.msg_count(); break; case '-': case '[': _mfunc.save_mbaselist(&mbl, mbnum-1); -// _mfunc.save_msgbase(&mbl); if (mbnum != 1) { --mbnum; @@ -633,7 +531,6 @@ void msg_edit::mod_mbase(int mbnum) */ char *msg_edit::faddr2char(char *s,fidoaddr *fa) { - if(fa->point > 0) sprintf(s,"%u:%u/%u.%u", fa->zone,fa->net,fa->node,fa->point); @@ -643,51 +540,11 @@ char *msg_edit::faddr2char(char *s,fidoaddr *fa) return(s); } - -/* -void msg_edit::compile_mbase() -{ - - int total_mbases = _mfunc.msg_count(); - if (total_mbases < 1) - { - pipe2ansi((char *)"|CR|CR |08C|07om|15piling Areas|08... |10No Areas Found!"); - return; - } - - pipe2ansi((char *)"|CR|CR |08C|07om|15piling Areas|08..."); - - mb_list_rec mbl; - - int i = _mfunc.msg_count(); - int areaNum = 0; - if (i<1) return; - - // Purge Foruns2.dat - //_mfunc.purgeForums2(); - - // Recreate Forums2.dat - i = 0; - areaNum = 0; - while(_mfunc.read_mbaselist(&mbl,i)) - { - // Not SysOp Area - // if ((mbl.flags.mbvisible & 0x01) == 0) { // old forums 2 recompile. - _mfunc.save_mbaselist(&mbl, areaNum); - ++areaNum; - // } - ++i; - } - pipe2ansi((char *)"|CR|CR |08C|07om|15piling Areas Completed|08! |CR|CR|PA"); -} -*/ - /** * Message Area Editor - List Message Areas (Generic!) */ int msg_edit::list_message_bases(int page) { - mb_list_rec mbl; char disp[61] = {0}, tType[12]= {0}; @@ -706,8 +563,6 @@ int msg_edit::list_message_bases(int page) rno=(page*14); if(_mfunc.read_mbaselist(&mbl,rno+i1)) { - // while(_mfunc.read_mbaselist(&mbl,i+rno)) { - //++i1; if ((mbl.flags.mbvisible & 0x01) == 0) TF = "no"; else @@ -716,8 +571,6 @@ int msg_edit::list_message_bases(int page) strcpy(disp, (char *)mbl.mbdisplay); strcpy(tType,"Jam"); - //if(mbl.Type == MSGTYPE_JAM) strcpy(tType,"Jam"); - //if(mbl.Type == MSGTYPE_SQUISH) strcpy(tType,"Squish"); sprintf(outbuff, "|15%3d. |09%-30s |03%-10s |11%7.7s |07%7.7s |08%7.7s |15%s|CR", (rno+i1)+1, @@ -728,7 +581,6 @@ int msg_edit::list_message_bases(int page) posttyp[mbl.Pubpriv], (char *)TF.c_str()); pipe2ansi(outbuff); - } } } else { @@ -743,8 +595,6 @@ int msg_edit::list_message_bases(int page) */ void msg_edit::mbeditmenu() { - -// int x = 0; int page = 0; unsigned char ch; std::string output; @@ -752,60 +602,7 @@ void msg_edit::mbeditmenu() int total_mbases = 0,total_pages = 0; - /* - mb_list_rec_OLD mbl_old; - mb_list_rec mbl; - - - /// Temp for copying old to new format_paragraph - - memset(&mbl,0,sizeof(mb_list_rec)); - - int i = 0; - while(_mfunc.read_mbaseoldlist(&mbl_old,i)) - { - mbl.idx = mbl_old.idx; - mbl.Type = mbl_old.Type; - mbl.Kind = mbl_old.Kind; - mbl.Active = mbl_old.Active; - mbl.Pubpriv = mbl_old.Pubpriv; - mbl.Allowalias = mbl_old.Allowalias; - mbl.scantype = mbl_old.scantype; - mbl.fidoaddr = mbl_old.fidoaddr; - mbl.sigtype = mbl_old.sigtype; - - strcpy((char *)mbl.mbdisplay,mbl_old.mbdisplay); - strcpy((char *)mbl.mbfile,mbl_old.mbfile); - strcpy((char *)mbl.mbpath,mbl_old.mbpath); - strcpy((char *)mbl.password,mbl_old.password); - - strcpy((char *)mbl.origin_line,mbl_old.OriginLine); - strcpy((char *)mbl.colors,(char *)mbl_old.colors); - strcpy((char *)mbl.infofile,mbl_old.infofile); - - mbl.MaxMsgs = mbl_old.MaxMsgs; - mbl.MaxAge = mbl_old.MaxAge; - mbl.first = mbl_old.first; - mbl.last = mbl_old.last; - mbl.current = mbl_old.current; - mbl.lastread = mbl_old.lastread; - mbl.status = mbl_old.status; - - - mbl.aka.zone = mbl_old.aka.zone; - mbl.aka.net = mbl_old.aka.net; - mbl.aka.node = mbl_old.aka.node; - mbl.aka.point = mbl_old.aka.point; - strcpy((char *)mbl.aka.domain,(char *)mbl_old.aka.domain); - - _mfunc.save_mbaselist(&mbl,i++); - } - - return;*/ - - while(1) { - total_mbases = _mfunc.msg_count(); if (total_mbases > 14) { total_pages = (total_mbases / 14); @@ -824,13 +621,7 @@ void msg_edit::mbeditmenu() output += sLine; pipe2ansi((char *)output.c_str()); - // Display Areas - //x=list_message_bases(page); list_message_bases(page); - - //pipe2ansi("|CR|15d|07.elete, |15e|07.dit, |15i|07.nsert, |15m|07.ove, |15q|07.uit : \x1b[1;44m \x1b[D"); - //pipe2ansi((char *)"|CR |15c|07.ompile areas|08. |09Generate Mesg Area List for Normal Users|08!"); - //pipe2ansi((char *)"|CR |15t|07.oggle Sysop View|08. |09Shows all areas as how a normal user would see them|08!"); pipe2ansi((char *)"|CR |15i|07.nsert, |15e|07.dit, |15m|07.ove, |15d|07.elete, |15[|07.prev page, |15]|07.next page |15q|07.uit : \x1b[1;44m \x1b[D"); ch = getkey(true); @@ -847,12 +638,6 @@ void msg_edit::mbeditmenu() case 'M': move_mbase(); break; - /* - case 'C': - compile_mbase(); - break;*/ - - //case 'B': import_backbone(); break; case 'Q': isSysop = TRUE; return; diff --git a/src/msg_edit.h b/src/msg_edit.h index 3792b6d..3d1fca4 100755 --- a/src/msg_edit.h +++ b/src/msg_edit.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2004-2014 by Michael Griffin * + * Copyright (C) 2004-2017 by Michael Griffin * * mrmisticismo@hotmail.com * * * * Purpose: * @@ -12,12 +12,6 @@ * (at your option) any later version. * ***************************************************************************/ -// Enthral SVN: $Id: msg_edit.h 1 2014-03-29 07:30:21Z mercyful $ -// Source: $HeadURL: file:///home/merc/repo/enthral/trunk/src/msg_edit.h $ -// $LastChangedDate: 2014-03-29 02:30:21 -0500 (Sat, 29 Mar 2014) $ -// $LastChangedRevision: 1 $ -// $LastChangedBy: mercyful $ - # ifndef MSG_EDIT_H # define MSG_EDIT_H @@ -41,7 +35,7 @@ class msg_edit : private ConsoleIO void insert_mbase(); void edit_aka(mb_list_rec *mr); - //void ACS(ACSrec *acs, char *fstr); + void mod_mbase(int mbnum); void modify_mbase(); void swap_mbase(int iFrom, int iTo); diff --git a/src/msg_email.cpp b/src/msg_email.cpp index 9037d7f..f5a04f5 100755 --- a/src/msg_email.cpp +++ b/src/msg_email.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2004-2014 by Michael Griffin * + * Copyright (C) 2004-2017 by Michael Griffin * * mrmisticismo@hotmail.com * * * * Purpose: * @@ -12,12 +12,6 @@ * (at your option) any later version. * ***************************************************************************/ -// Enthral SVN: $Id: msg_email.cpp 1 2014-03-29 07:30:21Z mercyful $ -// Source: $HeadURL: file:///home/merc/repo/enthral/trunk/src/msg_email.cpp $ -// $LastChangedDate: 2014-03-29 02:30:21 -0500 (Sat, 29 Mar 2014) $ -// $LastChangedRevision: 1 $ -// $LastChangedBy: mercyful $ - # include "struct.h" # include "language.h" # include "menu_func.h" @@ -34,7 +28,7 @@ # include # include # include -# include //gcc 4.7 +# include using namespace std; @@ -126,7 +120,6 @@ void msgemail_ini::msga_create() */ void msgemail_ini::msga_check(std::string cfgdata) { - std::string temp = cfgdata; std::string::size_type id1 = 0; @@ -134,7 +127,6 @@ void msgemail_ini::msga_check(std::string cfgdata) if (temp[0] == '#') return; // Sets if LOGGING is on / off - id1 = -1; id1 = temp.find("set TOP ", 0); if (id1 != std::string::npos) { std::string temp1; @@ -155,7 +147,6 @@ void msgemail_ini::msga_check(std::string cfgdata) } // Sets Download Path - id1 = -1; id1 = temp.find("set BOT ", 0); if (id1 != std::string::npos) { std::string temp1; @@ -176,7 +167,6 @@ void msgemail_ini::msga_check(std::string cfgdata) } // Sets XY PAGE Num - id1 = -1; id1 = temp.find("set PAGENUM ", 0); if (id1 != std::string::npos) { std::string temp1; @@ -196,7 +186,6 @@ void msgemail_ini::msga_check(std::string cfgdata) } // Sets XY PAGE Num - id1 = -1; id1 = temp.find("set PAGETOTAL ", 0); if (id1 != std::string::npos) { std::string temp1; @@ -216,7 +205,6 @@ void msgemail_ini::msga_check(std::string cfgdata) } // Sets XY PAGE Num - id1 = -1; id1 = temp.find("set MOREUP ", 0); if (id1 != std::string::npos) { std::string temp1; @@ -236,7 +224,6 @@ void msgemail_ini::msga_check(std::string cfgdata) } // Sets XY PAGE Num - id1 = -1; id1 = temp.find("set MOREUP_CHAR ", 0); if (id1 != std::string::npos) { std::string temp1; @@ -256,7 +243,6 @@ void msgemail_ini::msga_check(std::string cfgdata) } // Sets XY PAGE Num - id1 = -1; id1 = temp.find("set MOREDOWN ", 0); if (id1 != std::string::npos) { std::string temp1; @@ -276,7 +262,6 @@ void msgemail_ini::msga_check(std::string cfgdata) } // Sets XY PAGE Num - id1 = -1; id1 = temp.find("set MOREDOWN_CHAR ", 0); if (id1 != std::string::npos) { std::string temp1; @@ -296,7 +281,6 @@ void msgemail_ini::msga_check(std::string cfgdata) } // Sets XY PAGE Num - id1 = -1; id1 = temp.find("set MOREMSG_ON ", 0); if (id1 != std::string::npos) { std::string temp1; @@ -316,7 +300,6 @@ void msgemail_ini::msga_check(std::string cfgdata) } // Sets XY PAGE Num - id1 = -1; id1 = temp.find("set MOREMSG_WORD_ON ", 0); if (id1 != std::string::npos) { std::string temp1; @@ -335,8 +318,7 @@ void msgemail_ini::msga_check(std::string cfgdata) return; } -// Sets XY PAGE Num - id1 = -1; + // Sets XY PAGE Num id1 = temp.find("set MOREMSG_OFF ", 0); if (id1 != std::string::npos) { std::string temp1; @@ -356,7 +338,6 @@ void msgemail_ini::msga_check(std::string cfgdata) } // Sets XY PAGE Num - id1 = -1; id1 = temp.find("set MOREMSG_WORD_OFF ", 0); if (id1 != std::string::npos) { std::string temp1; @@ -376,7 +357,6 @@ void msgemail_ini::msga_check(std::string cfgdata) } // Sets XY PAGE Num - id1 = -1; id1 = temp.find("set INPUT_BOX ", 0); if (id1 != std::string::npos) { std::string temp1; @@ -396,7 +376,6 @@ void msgemail_ini::msga_check(std::string cfgdata) } // Sets XY PAGE Num - id1 = -1; id1 = temp.find("set TEXT_COLOR ", 0); if (id1 != std::string::npos) { std::string temp1; @@ -416,7 +395,6 @@ void msgemail_ini::msga_check(std::string cfgdata) } // Sets XY PAGE Num - id1 = -1; id1 = temp.find("set MAX_AREAS ", 0); if (id1 != std::string::npos) { std::string temp1; @@ -434,49 +412,6 @@ void msgemail_ini::msga_check(std::string cfgdata) strcpy(sMAX_AREAS,(char *)temp1.c_str()); return; } - - /* - // Sets XY PAGE Num - id1 = -1; - id1 = temp.find("set TEXT_HILIGHT ", 0); - if (id1 != std::string::npos) { - std::string temp1; - int st1 = -1; - int st2 = -1; - signed int ct = -1; - - st1 = temp.find('"', 0); - st2 = temp.find('"', st1+1); - ++st1; - temp1 = temp.substr(st1,st2); - ct = st2 - st1; - if (temp1.length() > ct) - temp1.erase(ct,temp1.length()); - strcpy(sTEXT_HILIGHT,(char *)temp1.c_str()); - return; - }*/ - - - // Sets XY PAGE Num - /* - id1 = -1; - id1 = temp.find("set TOT_MSG ", 0); - if (id1 != std::string::npos) { - std::string temp1; - int st1 = -1; - int st2 = -1; - signed int ct = -1; - - st1 = temp.find('"', 0); - st2 = temp.find('"', st1+1); - ++st1; - temp1 = temp.substr(st1,st2); - ct = st2 - st1; - if (temp1.length() > ct) - temp1.erase(ct,temp1.length()); - strcpy(sTOT_MSG,(char *)temp1.c_str()); - return; - }*/ } /** diff --git a/src/msg_email.h b/src/msg_email.h index b54de7d..76c7379 100755 --- a/src/msg_email.h +++ b/src/msg_email.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2004-2014 by Michael Griffin * + * Copyright (C) 2004-2017 by Michael Griffin * * mrmisticismo@hotmail.com * * * * Purpose: * @@ -12,24 +12,13 @@ * (at your option) any later version. * ***************************************************************************/ -// Enthral SVN: $Id: msg_email.h 1 2014-03-29 07:30:21Z mercyful $ -// Source: $HeadURL: file:///home/merc/repo/enthral/trunk/src/msg_email.h $ -// $LastChangedDate: 2014-03-29 02:30:21 -0500 (Sat, 29 Mar 2014) $ -// $LastChangedRevision: 1 $ -// $LastChangedBy: mercyful $ - # ifndef MSG_EMAIL_H # define MSG_EMAIL_H -//# include - # include "struct.h" -# include "mb_api.h" // Mainly for SESSION and i/o functions. +# include "mb_api.h" # include "msgs.h" -// pickup thisuser and session from msg_api - - # include typedef struct msgemail_ini { @@ -62,8 +51,6 @@ typedef struct msgemail_ini { class msg_email : private mbapi_jam, msgemail_ini, msgs { - - //private: UserRec *thisuser; public: @@ -72,7 +59,6 @@ class msg_email : private mbapi_jam, msgemail_ini, msgs msg_email(); void ParseHeader(char *filename); - //void SetupList(); void SetupList(UserRec *user); char *StartList(); diff --git a/src/msg_fse.cpp b/src/msg_fse.cpp index ea780d2..c740898 100755 --- a/src/msg_fse.cpp +++ b/src/msg_fse.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2004-2013 by Michael Griffin * + * Copyright (C) 2004-2017 by Michael Griffin * * mrmisticismo@hotmail.com * * * * Purpose: Full Screen Message Editor w/ Own LinkList Seperated * @@ -12,13 +12,6 @@ * (at your option) any later version. * ***************************************************************************/ -// Enthral SVN: $Id: msg_fse.cpp 1 2014-03-29 07:30:21Z mercyful $ -// Source: $HeadURL: file:///home/merc/repo/enthral/trunk/src/msg_fse.cpp $ -// $LastChangedDate: 2014-03-29 02:30:21 -0500 (Sat, 29 Mar 2014) $ -// $LastChangedRevision: 1 $ -// $LastChangedBy: mercyful $ - - # include "struct.h" # include "console.h" # include "conio.h" @@ -35,15 +28,14 @@ # include # include -# include // gcc 4.3 -# include // gcc 4.3 -# include // gcc 4.7 +# include +# include +# include using namespace std; -//# define READ_BUFF_SIZE 512 -# define MAX_WIDTH 79 +# define MAX_WIDTH 79 /** * Full Screen Editor - Startup with User Info @@ -54,17 +46,14 @@ msg_fse::msg_fse(UserRec *urec) current_node = 0; last = 0; - // Setup Defaults Row = 0; // Y - Row Col = 0; // X - Colume Len = 0; // Line Length - // Just incase ini is not read, set defaults. Top = 0; // Top Margin Bot = 0; // Bottom Margin Num = 0; // Number of Current line were at in Link List Tot = 0; // Total Number of Lines in Link List - //Line = ""; // Current String of Chars - //TLine = ""; // Temp Line Data + OVERWRITE = false; MSG_REPLY = false; @@ -72,10 +61,8 @@ msg_fse::msg_fse(UserRec *urec) cont = false; // If continious wrappign is on or off thisuser = urec; // Setup Users Information for Posting And Message Stats - // Not Used yet! bPush = FALSE; // If were pushing from the middle of the line. - //buffer.erase(); strcpy(sTHEME_NAME,""); strcpy(sANSI_FILE,""); strcpy(sTEXT_COLOR,""); @@ -84,9 +71,6 @@ msg_fse::msg_fse(UserRec *urec) msg_fse::~msg_fse() { - //if (head) delete head; - //if (current_node) delete current_node; - //if (last) delete last; } @@ -98,19 +82,14 @@ void msg_fse::add_to_list(std::string add_data) { LineRec *add = new LineRec; if (!add) { -// errlog((char *)"unable to allocate memory fse add_to_list()"); exit (1); } - //errlog2((char *)"add_to_list fse Done 1"); - //errlog2((char *)add_data.c_str()); add->data = add_data; add->flag = FALSE; add->lineNum = 0; - //errlog2((char *)"add_to_list fse Done 2"); if (current_node == 0) { // New Frist Add! - //errlog2((char *)"add_to_list fse Done 2.1"); add->up_link = 0; add->dn_link = 0; head = add; @@ -144,7 +123,6 @@ void msg_fse::add_to_list(std::string add_data) */ void msg_fse::stripCRONLY(char *ostr) { - int id1; std::string tstr = ostr; while ((id1=tstr.find("\n",0)) != -1) tstr.erase(id1,1); @@ -153,7 +131,6 @@ void msg_fse::stripCRONLY(char *ostr) strcpy(ostr,(char *)tstr.c_str()); } - /** * Full Screen Editor - Copy Data From buffer (Mesage Quoter) into Link List (Message) * Or Any Text Being passed to the Interface ie AutoSig! @@ -171,21 +148,12 @@ void msg_fse::PutBuffer(char *mBuff) while(1) { Line.erase(); - while (1) { // Only delete Carriage Return on First Char of Line + while (1) { if (MsgText.find("\r", 0) == 0) MsgText.erase(0,1); else break; } - /* - while (1) { // Delete all New Lines - id1 = MsgText.find("\n", 0); - if (id1 != -1) - MsgText.erase(id1,1); - else break; - } - */ - // Now get Carriage return at end of line to mark next line. id1 = MsgText.find("\r", 0); @@ -198,7 +166,7 @@ void msg_fse::PutBuffer(char *mBuff) if (Line.size() > 0) { strcpy(TmpStrip,(char *)Line.c_str()); stripCRONLY(TmpStrip); - /// Bug Fix! + // If first line already exists, use it before adding a new one!! if (current_node != 0 && i == 0) { current_node->data = TmpStrip; @@ -209,7 +177,7 @@ void msg_fse::PutBuffer(char *mBuff) } } } - add_to_list(""); // Add 1 Blank line to end of Quotation! + add_to_list(""); } /** @@ -218,14 +186,10 @@ void msg_fse::PutBuffer(char *mBuff) */ void msg_fse::save_all() { - - // (Delete and Move Up) remove any blank lines from bottom going up... - // For Cleaner Message Formatting with no extra lines. buffer.erase(); LineRec *tmp; // Remove any blank lines at the bottom of Text! Clean it up. - //current_node = last; Last_Line(); for (;;) { if (current_node->data == "" || current_node->data.size() < 1) { @@ -251,30 +215,25 @@ void msg_fse::save_all() } // Make Sure Link List Stays at current if there is none! - current_node = head; //->dn_link; + current_node = head; do { - // Skip \r on Last Line! Adds Extrata Line! - //if (current_node != 0) - current_node->data += '\r'; // Fix this, not all lines need \r + current_node->data += '\r'; buffer += current_node->data; if (current_node->dn_link == 0) break; current_node = current_node->dn_link; } while ( current_node != 0 ); - } - /** * Full Screen Editor - Move to Previous Line */ int msg_fse::move_up() { - if(current_node == 0) { return FALSE; } - // Make Sure Link List Stays at current if there is none! + if (current_node->up_link == 0) { return FALSE; } @@ -288,11 +247,10 @@ int msg_fse::move_up() */ int msg_fse::move_down() { - if(current_node == 0) { return FALSE; } - // Make Sure Link List Stays at current if there is none! + if (current_node->dn_link == 0) { return FALSE; } @@ -300,7 +258,6 @@ int msg_fse::move_down() return TRUE; } - /** * Full Screen Editor - Reset to Begining of Link List. */ @@ -310,7 +267,6 @@ void msg_fse::move_first() Num = 1; } - /** * Full Screen Editor - Jump to End of Message */ @@ -321,7 +277,6 @@ void msg_fse::MoveAllDown() if (head == 0) return; Last_Line(); - // Fix line totals for proper row position. Tot = line_total(); Num = Tot; if (Tot <= (Bot-Top)) { @@ -338,23 +293,19 @@ void msg_fse::MoveAllDown() */ void msg_fse::move_last() { - //is Empty? if(head == 0) { return; } current_node = head; while (1) { // Goto LAst! - //errlog2(" $$$ box_scrolldn 2.1 LOOP X"); if (current_node->dn_link == 0) { - //errlog2(" $$$ box_scrolldn 2.2"); break; } current_node = current_node->dn_link; } - // Fix line totals for proper row position. Tot = line_total(); Num = Tot; if (Tot <= (Bot-Top)) { @@ -363,20 +314,19 @@ void msg_fse::move_last() Row = Bot-Top; } - /** * Full Screen Editor - Count how many lines in list from * current all the way down */ int msg_fse::line_count() { - int count = 0; // Don't include current + int count = 0; LineRec *lineTmp; if(current_node == 0) { return 0; } - // Make Sure Link List Stays at current if there is none! + lineTmp = current_node; while ( lineTmp->dn_link != 0 ) { lineTmp = lineTmp->dn_link; @@ -390,7 +340,7 @@ int msg_fse::line_count() */ int msg_fse::line_total() { - int count = 1; // Include Current Line + int count = 1; LineRec *lineTmp; if(head == 0) { @@ -399,60 +349,44 @@ int msg_fse::line_total() lineTmp = head; - // Count how many Lines from Current to Bottom while ( lineTmp->dn_link != 0 ) { lineTmp = lineTmp->dn_link; ++count; } Tot = count; - //errlog2("line_total msgfse: %i",Tot); return count; - } - /** - * Full Screen Editor - Delete Line and Move up One Line then to the End (for Backspaces) + * Full Screen Editor - Delete Line and Move up + * One Line then to the End (for Backspaces) */ void msg_fse::delete_line_up() { - LineRec *tmp; - //int Total = line_total(); if(current_node == 0) { return; } - if ( current_node->up_link != 0) { // Make sure at least 1 Line above current - - //errlog2((char *)"delete_line_up 1"); + if ( current_node->up_link != 0) { + tmp = current_node; - //Reset one above to one below, as were are deleting this one! - - - //errlog2((char *)"delete_line_up 2"); if (current_node->dn_link != 0) { current_node->up_link->dn_link = current_node->dn_link; current_node->dn_link->up_link = current_node->up_link; } else { - //errlog2((char *)"delete_line_up 3"); current_node->up_link->dn_link = 0; } - //errlog2((char *)"delete_line_up 4"); current_node = current_node->up_link; - - //errlog2((char *)"delete_line_up 5"); delete tmp; tmp = 0; - //errlog2((char *)"delete_line_up 6"); if (current_node->dn_link == 0) last = current_node; - //errlog2((char *)"delete_line_up 7"); Line.erase(); Line = current_node->data; Col = Line.size()+1; @@ -460,7 +394,6 @@ void msg_fse::delete_line_up() --Num; Tot = line_total(); return; - } head = current_node; @@ -481,7 +414,6 @@ void msg_fse::delete_line_up() */ void msg_fse::delete_line() { - LineRec *tmp; int Total = line_total(); @@ -491,23 +423,14 @@ void msg_fse::delete_line() return; } - //errlog2((char *)" *** fse del y"); - - if (current_node->dn_link != 0) { //Any Lines Below to Remove? - ///Delete line below current if one exists - //tmp = current_node->dn_link; // Line we want to delete! Mopve down 1. - //tmp->up_link = current_node; - //current_node->dn_link = tmp->dn_link; - - ///Delete current line, and move line below up to current! + if (current_node->dn_link != 0) { tmp = current_node; - //Reset one above to one below, as were are deleting this one! + if (current_node->up_link != 0) { current_node->up_link->dn_link = current_node->dn_link; } current_node = current_node->dn_link; - // Check if Line above if not, set as HEad, and reset last. if (tmp->up_link != 0) { current_node->up_link = tmp->up_link; } else { @@ -525,11 +448,8 @@ void msg_fse::delete_line() --Tot; } - //Where at the current line, delete and if we ca move up! else { - /// We have a line Above the current one, delete current then move up! if (current_node->up_link != 0) { - //errlog2((char *)"move down del y"); // Delete Line tmp = current_node; @@ -538,16 +458,14 @@ void msg_fse::delete_line() delete tmp; tmp = 0; - last = current_node; // Delete 1 at a time, reset last! + last = current_node; Line = current_node->data; Col = 1; --Row; --Num; --Tot; } - /// Top Line / Last Line, just clear it of text. else { - //errlog2((char *)"clear up else!! del y"); head = current_node; last = current_node; current_node->data.erase(); @@ -560,26 +478,6 @@ void msg_fse::delete_line() } } -// Testing Only -void msg_fse::display_list(void) -{ - LineRec *print; - long int i = 0; - - if(head == 0) { - return; - } - - print = head; - while(print != 0) { - print = print->dn_link; - ++i; - } - //get_chr(pass,c); -} - - - /** * Full Screen Editor - Remove all enteries in list */ @@ -593,47 +491,32 @@ void msg_fse::dispose_list() delete tmp; tmp = 0; } - //delete head; + head = 0; current_node = 0; last = 0; } - /** * Full Screen Editor - Remove all enteries in list */ void msg_fse::clear_all() { dispose_list(); - - //head = new LineRec; - //head->data = ""; - //head->up_link = head; - //head->dn_link = head; - //current_node = head; - - //current_node->data.erase(); Line.erase(); - Num = 1; Col = 1; Row = 1; Tot = 1; } - /** * Full Screen Editor - Insert line in middle of paragraph on screen */ void msg_fse::insert_line() { current_node->data = Line; - //add_to_list(current_node->data); add_to_list(""); - //move_up(); - //current_node = current_node->up_link; - //current_node->data.erase(); ++Tot; Line.erase(); Col = 1; @@ -645,17 +528,15 @@ void msg_fse::insert_line() */ void msg_fse::box_clear() { - // Fist Get Box Size int boxsize = Bot - Top; std::string _editbox = ""; char capture[200]= {0}; - // Now clear the box First for (int t = 0; t != boxsize; t++) { sprintf(capture, "\x1b[%i;%iH\x1b[K", (Top)+t, 1); _editbox += capture; } - // Reset Cursor Position + sprintf(capture, "\x1b[%i;%iH", Top+1, 1); _editbox += capture; @@ -664,7 +545,7 @@ void msg_fse::box_clear() Tot = 1; Num = 1; Row = 1; - add_to_list(""); // Add Blank line to end of Quotation! + add_to_list(""); } /** @@ -674,15 +555,13 @@ void msg_fse::box_redraw() { LineRec *cur; char capture[200]= {0}; - // Init and Set Text Color. std::string _editbox = ""; - // Set Text Color pipe2ansi(sTEXT_COLOR); // Check here if We are Scrolling all the lines in the Box up by 1 if (Row == (Bot-Top+1)) { - --Row; // Reset the Line Position + --Row; } // Fist Get Box Size @@ -709,16 +588,13 @@ void msg_fse::box_redraw() _editbox += capture; if (!move_down()) break; } - // Reset Cursor and Record to Current Position + current_node = cur; - // Reset to Current Cursor Position sprintf(capture, "\x1b[%i;%iH", Row+Top-1, Col); _editbox += capture; putline((char *)_editbox.c_str()); } - - /** * Full Screen Editor - Normal word wrapping, End of Line. */ @@ -728,19 +604,13 @@ void msg_fse::word_wrap() std::string::size_type id1; iPos = Line.find_last_of(" ",MAX_WIDTH-1); - int iLineSize = Line.size(); // Cut out Last Word and move to next line if a Space is found in the line. if (iPos != std::string::npos) { - // First cut out the word from the current line Buffer TLine = Line.substr(iPos+1,iLineSize-1); Line.erase(iPos,iPos-iLineSize-1); - - // Assign modified line to Current current_node->data = Line; - - // Create new Line that new word wrap text goes to add_to_list(""); Line.erase(); Line = TLine; @@ -749,10 +619,10 @@ void msg_fse::word_wrap() current_node->data = Line; Col = Line.size()+1; - ++Row; // Goto Next Row - ++Num; // Currrent Line is Next + ++Row; + ++Num; ++Tot; - // Redraw Screen Text inside of Input Box + box_redraw(); } // No Space was found ,so just grab the last letter in the line! @@ -761,7 +631,6 @@ void msg_fse::word_wrap() Line.erase(iLineSize-1,1); current_node->data = Line; - // Create new Line that new word wrap text goes to add_to_list(""); Line.erase(); Line = TLine; @@ -769,10 +638,10 @@ void msg_fse::word_wrap() current_node->data = Line; Col = Line.size()+1; - ++Row; // Goto Next Row - ++Num; // Currrent Line is Next + ++Row; + ++Num; ++Tot; - // Redraw Screen Text inside of Input Box + box_redraw(); } } @@ -782,26 +651,12 @@ void msg_fse::word_wrap() */ int msg_fse::format_paragraph() { - - // pipe2ansi("|XY0101FormatPara: "); std::string sTmpLine; std::string::size_type iLineSize = 0; // Current Line Size std::string::size_type iPos = 0; // String Position int iRet = 0; - /* - - This Process will Loop and check each line that has been appended to - If this line is greater then MAX_WIDTH, it will cut last word or letter - and Append to the lower line, then recheck the next line untill we are done. - - This is a bit different then word_wrapex in the fact that when we get here - the line will have a word or more past MAX_WIDTH, where as in word_wrapex - there is only 1 char past max_width, so we have act accordingly. - - */ - Line.erase(); Line = current_node->data; iLineSize = Line.size(); @@ -814,50 +669,24 @@ int msg_fse::format_paragraph() } if (iLineSize >= MAX_WIDTH) { - // Were going to find the last word, and cut that off of current and move to next! - //iPos = Line.rfind(" ", iRet); iPos = Line.find_last_of(" ", iRet); if (iPos != std::string::npos) { - // ++iPos; // Ignore Space, and cut just the word! sTmpLine = Line.substr(iPos,iPos-(iLineSize-1)); Line.erase(iPos,iPos-(iLineSize-1)); current_node->data.erase(); current_node->data = Line; iRet = TRUE; } else { - // Grab the difference, past the Max Width. - // Since there is no space, we are wrapping continious letters... -// iWidth = (MAX_WIDTH) - (iLineSize-1); -// sTmpLine = Line.substr(MAX_WIDTH-1,iWidth); -// Line.erase(MAX_WIDTH-1,iWidth); - - // Working mroe or less!! - Cuts 2 from end of line at time, but acceptable! sTmpLine = Line.substr(iRet,iRet-(iLineSize-1)); Line.erase(iRet,iRet-(iLineSize-1)); - - // {not Workling properly. - Lets 1 past max!! - // sTmpLine = Line.substr(iLineSize-1,1); - // Line.erase(iLineSize-1,1); - current_node->data.erase(); current_node->data = Line; iRet = FALSE; } - /* - - Now Were going to Append the Temp Word / Letter we've cut off to the line below - If it doesn't exist, we'll create a new one. After Word this like will be - Tested and modified accordingly - - */ - // Append if (current_node->dn_link != 0) { - //tmp_node = current_node; current_node = current_node->dn_link; - // move_down(); - //remove only leading Spaces while (1) { @@ -872,28 +701,22 @@ int msg_fse::format_paragraph() else break; } - if (iRet == TRUE) current_node->data = sTmpLine + " " + current_node->data; else current_node->data = sTmpLine + current_node->data; - /* - - Since We've Appended, Now we will loop through each line we've appended to - and reformat the paragraph as needed. We Return TRUE to keep the loop going! - - */ if (current_node->data.size()-1 >= MAX_WIDTH) { return TRUE; } else return FALSE; } + // Create New else { add_to_list(""); current_node->data.erase(); - //while ((id1=sTmpLine.find(" ",0)) != -1) sTmpLine.erase(id1,1); + //remove only leading Spaces while (1) { if (sTmpLine[0] == ' ') @@ -906,50 +729,34 @@ int msg_fse::format_paragraph() sTmpLine.erase((int)sTmpLine.size()-1,1); else break; } + current_node->data = sTmpLine; ++Tot; - //move_up(); current_node = current_node->up_link; return FALSE; } } - + return FALSE; - } - /** * Full Screen Editor - Extended Word Wrapping, For Insert Pushing inside Current Line */ void msg_fse::word_wrapex() { - - // pipe2ansi("|XY0101WordWrapEx: "); - LineRec *tmp_node; current_node->data.erase(); current_node->data = Line; std::string sTmpLine; - std::string::size_type iLineSize; // Current Line Size - std::string::size_type iPos; // String Position + std::string::size_type iLineSize; + std::string::size_type iPos; std::string::size_type id1; int iRet; iLineSize = Line.size(); -// iColPos = Col-1; - - /* - - If Were pusing forward and the line has hit the MAX_WIDTH - We need to cut the last word, or letter, and move it down - a line. - - If this line exists, append to begining, else create then append. - - */ //Find the Lesser of, if it's the line, make sure it's less then last char! if ((MAX_WIDTH-1) < (iLineSize-1)) { @@ -961,16 +768,12 @@ void msg_fse::word_wrapex() // Were going to find the last word, and cut that off of current and move to next! iPos = Line.find_last_of(" ",iRet); if (iPos != std::string::npos) { - //iPos != (iLineSize-1) && iPos != std::string::npos) { - //++iPos; // Ignore Space, and cut just the word! sTmpLine = Line.substr(iPos,iPos-(iLineSize-1)); Line.erase(iPos,iPos-(iLineSize-1)); current_node->data.erase(); current_node->data = Line; iRet = TRUE; } else { - // If the line is full with no spaces, then just grab last char! - // Since there is no space, we are wrapping continious letters... sTmpLine = Line.substr(iLineSize-1,1); Line.erase(iLineSize-1,1); current_node->data.erase(); @@ -978,14 +781,6 @@ void msg_fse::word_wrapex() iRet = FALSE; } - /* - - Now Were going to Append the Temp Word / Letter we've cut off to the line below - If it doesn't exist, we'll create a new one. After Word this like will be - Tested and modified accordingly - - */ - // Append if (current_node->dn_link != 0) { tmp_node = current_node; @@ -994,23 +789,13 @@ void msg_fse::word_wrapex() while ((id1=sTmpLine.find(" ",0)) != std::string::npos) sTmpLine.erase(id1,1); if (iRet == TRUE) current_node->data = sTmpLine + " " + current_node->data; - else // // Since there is no space, we are wrapping continious letters... + else current_node->data = sTmpLine + current_node->data; - /* - - Since We've Appended, Now we will loop through each line we've appended to - and reformat the paragraph as needed. - - */ - if (current_node->data.size() >= MAX_WIDTH) { do { iRet = format_paragraph(); } while(iRet == TRUE); - //Line.erase(); - //Line = current_node->data; - // goto JMP; } current_node = tmp_node; @@ -1026,9 +811,7 @@ void msg_fse::word_wrapex() while ((id1=sTmpLine.find(" ",0)) != std::string::npos) sTmpLine.erase(id1,1); current_node->data = sTmpLine; ++Tot; - // move_up(); current_node = current_node->up_link; - } Line.erase(); @@ -1036,7 +819,6 @@ void msg_fse::word_wrapex() box_redraw(); } - /** * Full Screen Editor - Add char to current line, and test what mode were in */ @@ -1053,15 +835,6 @@ void msg_fse::add_char(unsigned char c) sCharTemp = c; - /* - In this first Part were going to test where we are, if were in the middle of a - Line were going to insert the char. If were at the end, were going to append it. - If the cursor is past the current lines total length we'll buffer it up. - - Afterwards we'll test the length of the current line, then transform the current - Line and or paragraph accordingly. - */ - // Test if were Pushing from Middle of the Line. if (iColPos < iLineSize) bPush = TRUE; @@ -1071,7 +844,6 @@ void msg_fse::add_char(unsigned char c) // First Eval if were pushing text from the middle of a line. if (bPush == TRUE) { Line.insert(iColPos, sCharTemp); - //pipe2ansi("|XY0102|12 insertt! "); } // Else were Appending Normal Text to the End of the Line. else { @@ -1082,15 +854,15 @@ void msg_fse::add_char(unsigned char c) Line += ' '; } } - // Testing, keep an eye on this! Fixed for now. + if (c == '%') { Line += "%"; - //pipe2ansi("|XY0101|12 percent! "); + } else { - //pipe2ansi("|XY0101|12 not percent! "); Line += sCharTemp; } } + ++Col; ++iColPos; iLineSize = Line.size(); @@ -1098,25 +870,11 @@ void msg_fse::add_char(unsigned char c) current_node->data.erase(); current_node->data = Line; - // if (iLineSize < MAX_WIDTH) return; - - //sprintf(sLine,"|XY0101*** iColPos: %i, iLineSize: %i", iColPos,iLineSize); - //pipe2ansi(sLine); - - /* - Now that we've Appended/Inserted into the line and the line is now modified. - Where going to parse the line and see if we need to reformat the line, and or - Paragraph accordingly. - */ - // If we were pushing from the middle of the line, if (bPush == TRUE) { if (iLineSize >= MAX_WIDTH) { word_wrapex(); } else { - //pipe2ansi("|XY0101|12 test ! "); - //sprintf(sLine,"\x1b[%i;%iH\x1b[K%s\x1b[%i;%iH", Row+Top-1, 1, Line.c_str(),Row+Top-1, Col); - //putline(sLine); return; } } @@ -1129,33 +887,14 @@ void msg_fse::add_char(unsigned char c) } } - /* - Now that the text has been re-formatted, See if we need to reset the cursor position. - Then Redraw Accordingly. Ie. Max Col Count, then Move down to next line. - - WordWrap and WordWrap EX both Return to here! - */ - - /* - if (Col >= MAX_WIDTH) { - Col = 1; - move_down(); - ++Num; - } - */ box_redraw(); } - - -// Add Some Extra Logic here to Only refresh when at Numb 1, or last num of Box and going down! -// Faster Display!!!! /** * Full Screen Editor - Move up A Line */ void msg_fse::up_arrow() { - current_node->data = Line; move_up(); Line = current_node->data; @@ -1169,14 +908,11 @@ void msg_fse::up_arrow() box_redraw(); } -// Add Some Extra Logic here to Only refresh when at Numb 1, or last num of Box and going down! -// Faster Display!!!! /** * Full Screen Editor - Move down A Line */ void msg_fse::dn_arrow() { - if (Tot == Num) return; current_node->data = Line; @@ -1199,8 +935,7 @@ void msg_fse::dn_arrow() */ void msg_fse::rt_arrow() { - - if (Col < MAX_WIDTH) { // Not at End of Line + if (Col < MAX_WIDTH) { ++Col; write(0,"\x1b[C",3); } else if (Col > MAX_WIDTH) { @@ -1213,8 +948,7 @@ void msg_fse::rt_arrow() */ void msg_fse::lt_arrow() { - - if (Col != 1) { // Not at Begining of Line + if (Col != 1) { write(0,"\x1b[D",3); --Col; } @@ -1225,7 +959,6 @@ void msg_fse::lt_arrow() */ void msg_fse::home_cursor() { - Col = 1; char sLine[50]= {0}; sprintf(sLine,"\x1b[%i;%iH", Row+Top-1, Col); @@ -1237,7 +970,6 @@ void msg_fse::home_cursor() */ void msg_fse::end_cursor() { - Col = Line.size()+1; char sLine[50]= {0}; sprintf(sLine,"\x1b[%i;%iH", Row+Top-1, Col); @@ -1254,18 +986,14 @@ void msg_fse::Last_Line() } current_node = head; - while (1) { // Goto LAst! - //errlog2(" $$$ box_scrolldn 2.1 LOOP X"); + while (1) { if (current_node->dn_link == 0) { - //errlog2(" $$$ box_scrolldn 2.2"); break; } - current_node = current_node->dn_link; } } -// Not being used!! /** * Full Screen Editor - Last Page, Scroll from Bottom up */ @@ -1304,7 +1032,6 @@ void msg_fse::box_scrolldn() Line = current_node->data; } - /** * Full Screen Editor - Parse Subject for Regarding (reply) */ @@ -1338,18 +1065,15 @@ int msg_fse::options_prompt(unsigned char c) char mString[10] = {0}; unsigned char ch; char qText[100]= {0}; - //char qBuff[BUFLEN]={0}; + std::string qbuf; std::string QuoteStr; std::string sOrgMsg; int idx = 0; int id1 = 0; -//RESTART: - // Check if Pass through FSE input ie.. /s sent. or Lightbar Menu if (c == '\0') { - // Setup Lightbar Menu Prompts _mnuf._premenu.clear(); _mnuf._premenu = _mnuf._curmenu; _mnuf._curmenu.clear(); @@ -1359,10 +1083,9 @@ int msg_fse::options_prompt(unsigned char c) } while (1) { - // Check if Pass through. Then Setup! if (c == '\0') { _mnuf.menu_proc(mString); - ch = mString[1]; //mString[0] should = ! + ch = mString[1]; } else { mString[0] = '!'; ch = c; @@ -1373,41 +1096,29 @@ int msg_fse::options_prompt(unsigned char c) switch (toupper(ch)) { case 'S' : // Save Message - - // If Empty, Return False. (Aborted!) if (line_total() == 1 && Line.size() == 0 && current_node == head) { dispose_list(); -// errlog((char *)" *** Dispost list, abort message! %lu %lu", line_total(), Line.size()); return FALSE; } -// errlog((char *)" *** Dispost list, save message! %lu %lu", line_total(), Line.size()); if (Line != "") { current_node->data = Line; - //add_to_list(""); } + // Redraw.. ansi_file(sANSI_FILE); box_redraw(); - // Now Save! save_all(); dispose_list(); - // Reset Top / Botom Margins - //putline("\x1b[1;24r"); // Think this is no londer is use! - //_mnuf.~menu_func(); return TRUE; - //break; case 'A' : // Abort Message dispose_list(); - //putline("\x1b[1;24r"); // Think this is no londer is use! - //_mnuf.~menu_func(); return FALSE; case 'X' : // Continue with Current Message ansi_file(sANSI_FILE); box_redraw(); - //_mnuf.~menu_func(); return (2); case '?' : // Display list of HotKey Commands @@ -1418,15 +1129,13 @@ int msg_fse::options_prompt(unsigned char c) else { ansi_file(sANSI_FILE); box_redraw(); - //_mnuf.~menu_func(); return (2); } case 'Q' : // Quote Message Text - if (!MSG_REPLY) { // Not in Reply Mode, just return! + if (!MSG_REPLY) { ansi_file(sANSI_FILE); box_redraw(); - //_mnuf.~menu_func(); return(2); } _msgq.setup_quoter(); @@ -1434,16 +1143,14 @@ int msg_fse::options_prompt(unsigned char c) // Get Quoted Text from QUOTE Class then throw it in the FSE if (qbuf.size() > 0) { - // Starting Quote _lang.lang_get(qText,29); if (strlen(qText) > 0) { - parsere(qText); // PArse for |RE MCI Coded, (Reguarding) + parsere(qText); QuoteStr = qText; QuoteStr += '\r'; } // Text QuoteStr += qbuf; - // Ending Quote _lang.lang_get(qText,30); if (strlen(qText) > 0) { parsere(qText); @@ -1453,7 +1160,6 @@ int msg_fse::options_prompt(unsigned char c) // Append Quoted Text into message. PutBuffer((char *)QuoteStr.c_str()); - ansi_file(sANSI_FILE); add_to_list(""); MoveAllDown(); @@ -1461,28 +1167,24 @@ int msg_fse::options_prompt(unsigned char c) ansi_file(sANSI_FILE); box_redraw(); } - //_mnuf.~menu_func(); return (2); case 'C' : // Clear Message box_clear(); - //_mnuf.~menu_func(); return (2); case ']': // Next Theme - idx = thisuser->fsetheme; ++idx; id1 = change_theme(idx); - // Reset Colors and Ansi to new Theme - if (id1 == FALSE) { // Reset Theme Back + + if (id1 == FALSE) { change_theme(thisuser->fsetheme); } else { thisuser->fsetheme = idx; } ansi_file(sANSI_FILE); box_redraw(); - //_mnuf.~menu_func(); return (2); case '[': // Previous Theme @@ -1497,28 +1199,28 @@ int msg_fse::options_prompt(unsigned char c) id1 = change_theme(idx); } - if (id1 == FALSE) { // Reset Theme Back + if (id1 == FALSE) { change_theme(thisuser->fsetheme); } else { thisuser->fsetheme = idx; } ansi_file(sANSI_FILE); box_redraw(); - //_mnuf.~menu_func(); return (2); } } } /** - * Full Screen Editor - Insert Lines Comming from Message Reader stright into FSE List for Message Edit. + * Full Screen Editor - Insert Lines Comming from Message + * Reader stright into FSE List for Message Edit. * Used on Reply or Edit. */ void msg_fse::insert_lines() { LineRec *lineTmp; if(reader_list->head == 0) { - return; // Empty + return; } dispose_list(); @@ -1535,10 +1237,8 @@ void msg_fse::insert_lines() } -// Not Used Yet. Tokenize String into list of words. /** * Full Screen Editor - Split line into seperate list of words. - * Future Spell Check?!? :) */ std::vector inline msg_fse::split_string(const std::string &source, const char *delimiter, @@ -1584,17 +1284,12 @@ void msg_fse::delete_key() //if ((signed)Line.size() < (Col-1)) if (Col < (signed)Line.size()+1) { - //putline("\r\ndel"); Line.erase(Col-1,1); current_node->data = Line; - // Delete Current Line then redraw it sprintf(sLine,"\x1b[%i;%iH\x1b[K%s\x1b[%i;%iH", Row+Top-1, 1,Line.c_str(), Row+Top-1, Col); putline(sLine); } - //((signed)Line.size()+1 > Col) // Were in Insert Mode - // If were at the end of a line, pull text from line below up. else { - // First Make sure all characters on currnet are saved. current_node->data = Line; // Second we need to check if cursor is past line size, if so we need to pad it @@ -1616,21 +1311,16 @@ void msg_fse::delete_key() } current_node->data = Line; - - - // Currnet Line, Make Backup for testing. TLine = current_node->data; if (!move_down()) return; - // Line Below current sTmp = current_node->data; // First check if line below is empty, // if it is, just delete it and return if (sTmp.size() == 0) { - //putline("\r\nempty"); ++Row; delete_line_up(); --Row; @@ -1640,62 +1330,34 @@ void msg_fse::delete_key() } // First Check if Currnet Line we are on TLine has room on it - // If TLine has no room, then don't do anything with Line! - // errlog2((char *)"FSE Backspace 2.2"); if ((TLine.size()) <= MAX_WIDTH) { - // Now check if Full "Line" Can fit in TLine if (TLine.size()+sTmp.size() <= MAX_WIDTH) { - // errlog2((char *)"FSE Backspace 2.3"); ++Num; delete_line_up(); - // if (Row > 1) --Row; - //if (Num > 1) --Num; - //if (Tot > 1) --Tot; - //Col = current_node->data.size()+1; // doesn't change. current_node->data += " " + sTmp; Line = current_node->data; - Col = TCol; // Restore original Col Position. + Col = TCol; box_redraw(); } else { - - // New Logic, come from the back string, so we catch leading spaces if any, - // Loop through each space untill we get enough words that will fit in - // the line above us. id1 = sTmp.size()-1; id1 = sTmp.rfind(" ",id1); while ( (TLine.size()+id1+1) > MAX_WIDTH && id1 != std::string::npos) { - //putline("loop"); id1 = sTmp.rfind(" ",id1-1); } if ((TLine.size()+id1+1) <= MAX_WIDTH && id1 != std::string::npos) { - //errlog2((char *)"FSE Backspace 2.5"); move_up(); - - // Append and Assign update line - //TLine.append(" "); // Padd Concat with 1 space. - //TCol = TLine.size()+1; // Update Column poition TLine.append(sTmp.substr(0, id1)); + current_node->data = TLine; - current_node->data = TLine; // Now Concat - - // Move back down to original line, and cut out text moved - // To the Above line. move_down(); - sTmp.erase(0,id1+1); // +1 to remove the space. - //add_to_list(Line); + sTmp.erase(0,id1+1); current_node->data = sTmp; - // Now move back up and assign cusor to end of line. move_up(); - - // Reset Line Data to Current Line Line = current_node->data; - //Col = TCol; // Assing position - //if (Row > 1) --Row; - //if (Num > 1) --Num; - box_redraw(); // Redraw + box_redraw(); } } } @@ -1708,12 +1370,6 @@ void msg_fse::delete_key() */ int msg_fse::poll_chr(int reply, int msg_edit, MsgHead *mH, msg_readll *mL) { - - //* NOTE REMINDER Col = 1; // Line.size()+1; casue if size = 0, then Col Starting = 1 :) - - //pipe2ansi("|XY0101 - TEST"); - //getkey(true); - // Variables for Client Side Key Sequences std::string changemsg; @@ -1730,12 +1386,9 @@ int msg_fse::poll_chr(int reply, int msg_edit, MsgHead *mH, msg_readll *mL) memcpy(&mHLocal,mH,sizeof(MsgHead)); - // Check What Theme user has selected. if (fse_parse(thisuser->fsetheme) == FALSE) fse_parse(); - // Setup inital first line here! - // Make sure we have a 1 line current in here. if (head == 0) { add_to_list(""); @@ -1750,7 +1403,7 @@ int msg_fse::poll_chr(int reply, int msg_edit, MsgHead *mH, msg_readll *mL) Tot = 1; // Total Lines unsigned char c; // Holds Char Input - int TCol = 0; // Temp Colume + int TCol = 0; // Temp Column std::string::size_type id1; // Setup Line and Cursor Position top of Input Box @@ -1760,7 +1413,6 @@ int msg_fse::poll_chr(int reply, int msg_edit, MsgHead *mH, msg_readll *mL) // If were Replying to a message, Start Message Quoter if (reply == TRUE) { - // Send Message To msg_quote Class as Quote. MSG_REPLY = TRUE; reader_list = mL; // Copy of Original Message in Link List. options_prompt('Q'); // Jump right into Quoter if a Message Reply. @@ -1774,11 +1426,9 @@ int msg_fse::poll_chr(int reply, int msg_edit, MsgHead *mH, msg_readll *mL) insert_lines(); // Copy Original Read_list to mLink for FSE. add_to_list(""); // Add Line to the End. move_first(); - Line = current_node->data; // Make Sure Data is reassign on current line - + Line = current_node->data; Num = 1; Row = 1; - // move_last(); line_total(); } ansi_file(sANSI_FILE); @@ -1786,8 +1436,6 @@ int msg_fse::poll_chr(int reply, int msg_edit, MsgHead *mH, msg_readll *mL) } while (1) { - - // Filp Backspace and DEL chars betwene Windows Telnet and *nix terminals if (thisuser->bsdel_swap == TRUE) { clientBS = DELETE; clientDEL = BACKSPACE; @@ -1796,7 +1444,6 @@ int msg_fse::poll_chr(int reply, int msg_edit, MsgHead *mH, msg_readll *mL) clientDEL = DELETE; } - sprintf(sLine,"%s%s%.2d%s%.2d\x1b[%i;%iH",sTEXT_COLOR,sRow,Num,sCol,Col,Row+Top-1, Col); pipe2ansi(sLine); @@ -1804,15 +1451,8 @@ int msg_fse::poll_chr(int reply, int msg_edit, MsgHead *mH, msg_readll *mL) strcpy(EscapeKey,""); c = getkey(true); - // pipe2ansi("|XY0101"); - // sprintf(sLine,"- val %i, %c",int(c), c); - // pipe2ansi(sLine); - - // Make sure current is always equal to line before any processing! - // So no typed data is missed current_node->data = Line; - // Swap BackSpace and DEL if (c == 0x18) { // CTRL X changemsg.erase(); @@ -1834,7 +1474,6 @@ int msg_fse::poll_chr(int reply, int msg_edit, MsgHead *mH, msg_readll *mL) } // Do Delete else if (c == clientDEL ) { - // Moved to Function delete_key(); } @@ -1843,106 +1482,74 @@ int msg_fse::poll_chr(int reply, int msg_edit, MsgHead *mH, msg_readll *mL) // to avoid confusion this has to be disabled unless we make a toggle. // Becaseu it's also used as DEL. else if (c == clientBS) { - // || c == 0x0e00) { if ((signed)Line.size() < (Col-1)) { -// errlog2((char *)"FSE Backspace lt_arrow"); lt_arrow(); } else if (Line == "") { // Empty, just move cursor up and end! - //errlog2((char *)"FSE Backspace 0"); delete_line_up(); if (Row > 1) --Row; box_redraw(); } // Normal Destructive Backspace.. Normal from end of Line! else if (Col != 1 ) { - //errlog2((char *)"FSE Backspace 1"); Line.erase(Col-2, 1); current_node->data = Line; - // Delete Current Line only, and then Redraw it! --Col; sprintf(sLine,"\x1b[%i;%iH\x1b[K%s\x1b[%i;%iH", Row+Top-1, 1,Line.c_str(), Row+Top-1, Col); putline(sLine); } else { - //errlog2((char *)"FSE Backspace 2"); tmp2 = Line; // Were in Insert Mode, Made sure were not on the First Row! if (Num != 1) { // if 1st Row, Do Nothing!!! - // Check if in Inset Mode, if So move text to upper line - //errlog2((char *)"FSE Backspace 2.1"); if ((signed)Line.size()+1 > Col) { // Were in Insert Mode - // Get Data From Both lines to compare sizes - // errlog2((char *)"FSE Backspace 2.1.1"); current_node->data = Line; move_up(); - // Line Above.. TLine = current_node->data; TCol = TLine.size()+1; move_down(); - // Current Line Line = current_node->data; - // First Check if Upper TLine has room on it - // If TLine has no room, then don't do anything with Line! - // errlog2((char *)"FSE Backspace 2.2"); if ((TLine.size()) <= MAX_WIDTH) { - // Now check if Full "Line" Can fit in TLine if (TLine.size()+Line.size() <= MAX_WIDTH) { - // errlog2((char *)"FSE Backspace 2.3"); delete_line_up(); if (Row > 1) --Row; - //if (Num > 1) --Num; - //if (Tot > 1) --Tot; Col = current_node->data.size()+1; current_node->data += " " + tmp2; Line = current_node->data; box_redraw(); } else { - // New Logic, come from the back string, so we catch leading spaces if any, - // Loop through each space untill we get enough words that will fit in - // the line above us. id1 = tmp2.size()-1; id1 = tmp2.rfind(" ",id1); while ( (TLine.size()+id1+1) > MAX_WIDTH && id1 != std::string::npos) { - //putline("loop"); id1 = tmp2.rfind(" ",id1-1); } if ((TLine.size()+id1+1) <= MAX_WIDTH && id1 != std::string::npos) { - //errlog2((char *)"FSE Backspace 2.5"); move_up(); - // Append and Assign update line - //TLine.append(" "); // Padd Concat with 1 space. - TCol = TLine.size()+1; // Update Column poition + TCol = TLine.size()+1; TLine.append(Line.substr(0, id1)); - - current_node->data = TLine; // Now Concat + current_node->data = TLine; // Move back down to original line, and cut out text moved // To the Above line. move_down(); - Line.erase(0,id1+1); // +1 to remove the space. - //add_to_list(Line); + Line.erase(0,id1+1); current_node->data = Line; - - // Now move back up and assign cusor to end of line. move_up(); // Reset Line Data to Current Line Line = current_node->data; - Col = TCol; // Assing position + Col = TCol; if (Row > 1) --Row; if (Num > 1) --Num; - box_redraw(); // Redraw + box_redraw(); } } } } else { delete_line_up(); if (Row > 1) --Row; - //if (Num > 1) --Num; - //if (Tot > 1) --Tot; box_redraw(); } } @@ -1996,13 +1603,12 @@ int msg_fse::poll_chr(int reply, int msg_edit, MsgHead *mH, msg_readll *mL) case ' ' : // ESC id1 = options_prompt(); if (id1 == 2) { - //putline("\nid1 == 2"); ansi_file(sANSI_FILE); box_redraw(); break; } // Continue else { - return id1; // Else Save or Abort! + return id1; } default : @@ -2017,30 +1623,27 @@ int msg_fse::poll_chr(int reply, int msg_edit, MsgHead *mH, msg_readll *mL) TLine = Line.substr(Col-1, Line.size()); Line.erase(Col-1, (Col-1)-Line.size()); current_node->data = Line; - // Now Create New Line, and move from cursor position to end to new line - add_to_list(""); // Create Next Line + add_to_list(""); current_node->data = TLine; Line = current_node->data; - Col = 1; // Line.size()+1; casue if size = 0, then Col = 1 :) + Col = 1; - ++Tot; // Add To Total # of Lines - ++Row; // Goto Next Row - ++Num; // Currrent Line is Next + ++Tot; + ++Row; + ++Num; box_redraw(); } else { - current_node->data = Line; // Add Current Line to Current Node - add_to_list(""); // Create Next Line + current_node->data = Line; + add_to_list(""); Col = 1; Line = ""; - ++Tot; // Add To Total # of Lines - ++Row; // Goto Next Row - ++Num; // Currrent Line is Next - // Redraw Screen Text inside of Input Box + ++Tot; + ++Row; + ++Num; box_redraw(); } } // Check for Normal Letters, Numbers, Ascii Printable chars Etc.. - //else if (((int)c > 31 && (int)c < 126) || c == '~' || c == '`') else if (((int)c > 31 && (int)c <= 255) || c == '~' || c == '`') { // Jump into Options Prompt... if (Col == 1 && c == '/') { @@ -2048,13 +1651,12 @@ int msg_fse::poll_chr(int reply, int msg_edit, MsgHead *mH, msg_readll *mL) if (id1 == 2) { ansi_file(sANSI_FILE); box_redraw(); - // break; } // Continue else { - return id1; // Else Save or Abort! + return id1; } } else { - add_char(c); // Add Char to line + add_char(c); sprintf(sLine,"\x1b[%i;%iH\x1b[K%s\x1b[%i;%iH", Row+Top-1, 1,(char *)Line.c_str(), Row+Top-1, Col); putline(sLine); @@ -2069,25 +1671,6 @@ int msg_fse::poll_chr(int reply, int msg_edit, MsgHead *mH, msg_readll *mL) else if (c == CTRLN) { // CTRL N insert_line(); } - - /* - // Clear - else if (c == CTRLC || c == CTRLD) { // CTRL C or CTRL D - options_prompt('L'); - } - else if ((int)c == 24) { // CTRL X - Abort - options_prompt('A'); - } - else if ((int)c == 26) { // CTRL Z - Save - options_prompt('S'); - } - else if ((int)c == 21) { // CTRL U - Quote Message - if (reply) { - options_prompt('Q'); - } - }*/ - // Testing Char Input - // else printf("char %i",(int)c); } } @@ -2096,14 +1679,11 @@ int msg_fse::poll_chr(int reply, int msg_edit, MsgHead *mH, msg_readll *mL) */ int msg_fse::change_theme(int idx) { - - // Check What Theme user has selected. if (fse_parse(idx) == FALSE) return FALSE; thisuser->fsetheme = idx; - // Save User Settings after successful Theme Switch. UserRec usr; usr = *thisuser; users _usr; @@ -2117,13 +1697,12 @@ int msg_fse::change_theme(int idx) */ void msg_fse::ansi_file(char *filename) { - int c = 0; std::string temp = ""; std::string path = ANSIPATH; path += filename; path += ".ans"; - char MCI[3] = {0}; // Holds MCI Codes to Parse + char MCI[3] = {0}; char sTemp[255] = {0}; std::string::size_type id1 = 0; @@ -2176,13 +1755,11 @@ void msg_fse::ansi_file(char *filename) pipe2ansi((char *)temp.c_str()); } - /** * Full Screen Editor INI - Check INI Exists */ bool msg_fse::fse_exists() { - std::string path = INIPATH; path += "fse.ini"; @@ -2201,7 +1778,6 @@ bool msg_fse::fse_exists() */ void msg_fse::fse_create() { - std::string name = INIPATH; name += "fse.ini"; @@ -2222,7 +1798,6 @@ void msg_fse::fse_create() */ void msg_fse::fse_chkpar(std::string &temp) { - std::string temp1; std::string::size_type st1 = 0; std::string::size_type st2 = 0; @@ -2243,7 +1818,6 @@ void msg_fse::fse_chkpar(std::string &temp) */ void msg_fse::fse_check(std::string cfgdata) { - std::string::size_type id1 = 0; if (cfgdata[0] == '#') return; else if (cfgdata.find("set THEME_NAME ", 0) @@ -2288,11 +1862,9 @@ void msg_fse::fse_check(std::string cfgdata) */ int msg_fse::fse_parse(int idx) { - if (!fse_exists()) { perror("Error unable to open fse.ini, check permissions!"); } - //fse_create(); char name[1024] = {0}; char name2[1024] = {0}; @@ -2303,10 +1875,9 @@ int msg_fse::fse_parse(int idx) // Check if Default Theme, else look for requested. if (idx != 0) strcpy(name,name2); - // Check if Theme Exists, if not return FALSE. FILE *stream; stream = fopen(name,"rb+"); - if(stream == NULL) { // File is not Present + if(stream == NULL) { return FALSE; } fclose(stream); diff --git a/src/msg_fse.h b/src/msg_fse.h index 3f44bf9..8303969 100755 --- a/src/msg_fse.h +++ b/src/msg_fse.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2004-2013 by Michael Griffin * + * Copyright (C) 2004-2017 by Michael Griffin * * mrmisticismo@hotmail.com * * * * Purpose: * @@ -12,17 +12,10 @@ * (at your option) any later version. * ***************************************************************************/ -// Enthral SVN: $Id: msg_fse.h 1 2014-03-29 07:30:21Z mercyful $ -// Source: $HeadURL: file:///home/merc/repo/enthral/trunk/src/msg_fse.h $ -// $LastChangedDate: 2014-03-29 02:30:21 -0500 (Sat, 29 Mar 2014) $ -// $LastChangedRevision: 1 $ -// $LastChangedBy: mercyful $ - # ifndef MSG_FSE_H # define MSG_FSE_H # include "struct.h" -//# include "msg_api.h" # include "mb_api.h" # include "msg_readll.h" @@ -32,13 +25,12 @@ using namespace std; -class msg_fse : - //private msg_api -private mbapi_jam +class msg_fse + : private mbapi_jam { private: - // Main List for Holding All Data + LineRec *head; // Pointer to Fist in List LineRec *current_node; // Current Pointer in List LineRec *last; // Pointer to Last Element in List. @@ -47,7 +39,6 @@ private mbapi_jam msg_readll *reader_list; MsgHead mHLocal; - // Editor Variables int Row, // Y - Row [Lines] Col, // X - Colume [Char in Line] Len, // Line Length @@ -60,18 +51,17 @@ private mbapi_jam bool MSG_REPLY; - // Holds String Data for Current Line in use std::string Line; // Line Data std::string TLine; // Temp Line Data bool OVERWRITE; // Do Replace or Insert - int TRow; // Temp Row, that were Line Wrapping On (garbage NOT IN USE!) - bool cont; // If continious wrappign is on or off (word wrap es, NOT IN USE!) - int bPush; // If were pushing from the middle of the line + int TRow; // Temp Row, that were Line Wrapping On (garbage NOT IN USE!) + bool cont; // If continious wrappign is on or off (word wrap es, NOT IN USE!) + int bPush; // If were pushing from the middle of the line - char sRow[15]; // Row - char sCol[15]; // Colume for FSE Ansi Display + char sRow[15]; + char sCol[15]; char sANSI_FILE[15]; char sTHEME_NAME[20]; char sTEXT_COLOR[15]; @@ -83,7 +73,6 @@ private mbapi_jam std::string buffer; - // Link List Functions - Note can move this to reference msg_ll.cpp / h void add_to_list(std::string); void stripCRONLY(char *ostr); void PutBuffer(char *mBuff); @@ -135,7 +124,7 @@ private mbapi_jam int poll_chr(int reply, int msg_edit, MsgHead *mH, msg_readll *mL = 0); private: - // fse.ini + int change_theme(int idx=0); void ansi_file(char *filename); bool fse_exists(); diff --git a/src/msg_newscan.cpp b/src/msg_newscan.cpp index 193a5e9..9b2641f 100755 --- a/src/msg_newscan.cpp +++ b/src/msg_newscan.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2004-2014 by Michael Griffin * + * Copyright (C) 2004-2017 by Michael Griffin * * mrmisticismo@hotmail.com * * * * Purpose: Message NewScan Toggles for Active and Inactive Areas * @@ -12,35 +12,20 @@ * (at your option) any later version. * ***************************************************************************/ -// Enthral SVN: $Id: msg_newscan.cpp 1 2014-03-29 07:30:21Z mercyful $ -// Source: $HeadURL: file:///home/merc/repo/enthral/trunk/src/msg_newscan.cpp $ -// $LastChangedDate: 2014-03-29 02:30:21 -0500 (Sat, 29 Mar 2014) $ -// $LastChangedRevision: 1 $ -// $LastChangedBy: mercyful $ - # include "struct.h" # include "msg_newscan.h" # include # include -# include // gcc 4/7 +# include using namespace std; -/* - (WIP) - When ever a message base is created, a newscan file /record should be created for - each user with a default of TRUE - - When a new user is added they should be added to each newscan dat - */ - /** * NewScan Config - Lock File */ int msg_newscan::new_lockSet(int onoff) { - std::string path = LOCKPATH; path += "mnewscan.lck"; @@ -49,7 +34,6 @@ int msg_newscan::new_lockSet(int onoff) return TRUE; } - //While lock file missing, loop untill it disapears. FILE *stream; while(1) { stream = fopen(path.c_str(),"rb+"); @@ -73,7 +57,6 @@ int msg_newscan::new_lockSet(int onoff) */ int msg_newscan::new_read(NewScan *ns, int idx, char *mbase) { - char path[255]; sprintf(path,"%s%s.ns", MESGPATH, mbase); new_lockSet(TRUE); @@ -100,7 +83,6 @@ int msg_newscan::new_read(NewScan *ns, int idx, char *mbase) */ int msg_newscan::new_write(NewScan *ns, int idx, char *mbase) { - char path[255]; sprintf(path,"%s%s.ns", MESGPATH, mbase); new_lockSet(TRUE); @@ -129,7 +111,6 @@ int msg_newscan::new_write(NewScan *ns, int idx, char *mbase) */ int msg_newscan::new_count(char *mbase) { - int i = 0; NewScan ns; @@ -146,7 +127,6 @@ int msg_newscan::new_count(char *mbase) */ int msg_newscan::read_mbase(mb_list_rec *mr, int rec) { - int x = 0; std::string path = DATAPATH; path += "forums.dat"; @@ -172,7 +152,6 @@ int msg_newscan::read_mbase(mb_list_rec *mr, int rec) */ int msg_newscan::check_mbase(UserRec *thisuser) { - mb_list_rec mr; NewScan ns; int i; diff --git a/src/msg_newscan.h b/src/msg_newscan.h index 7b23fb8..78fe46a 100755 --- a/src/msg_newscan.h +++ b/src/msg_newscan.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2004-2014 by Michael Griffin * + * Copyright (C) 2004-2017 by Michael Griffin * * mrmisticismo@hotmail.com * * * * Purpose: * @@ -12,12 +12,6 @@ * (at your option) any later version. * ***************************************************************************/ -// Enthral SVN: $Id: msg_newscan.h 1 2014-03-29 07:30:21Z mercyful $ -// Source: $HeadURL: file:///home/merc/repo/enthral/trunk/src/msg_newscan.h $ -// $LastChangedDate: 2014-03-29 02:30:21 -0500 (Sat, 29 Mar 2014) $ -// $LastChangedRevision: 1 $ -// $LastChangedBy: mercyful $ - # ifndef MSG_NEWSCAN_H # define MSG_NEWSCAN_H @@ -29,12 +23,9 @@ typedef struct msg_newscan { int new_read(NewScan *ns, int idx, char *mbase); int new_write(NewScan *ns, int idx, char *mbase); int new_count(char *mbase); - - // Message NewScan Functions int read_mbase(mb_list_rec *mr, int rec); int check_mbase(UserRec *thisuser); - } msg_newscan; # endif diff --git a/src/msg_pack.cpp b/src/msg_pack.cpp index c1c98d6..c708a7f 100755 --- a/src/msg_pack.cpp +++ b/src/msg_pack.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2004-2014 by Michael Griffin * + * Copyright (C) 2004-2017 by Michael Griffin * * mrmisticismo@hotmail.com * * * * Purpose: Message Area Truncation and Pack Function, WIP!!! * @@ -11,578 +11,3 @@ * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * ***************************************************************************/ - -// Enthral SVN: $Id: msg_pack.cpp 1 2014-03-29 07:30:21Z mercyful $ -// Source: $HeadURL: file:///home/merc/repo/enthral/trunk/src/msg_pack.cpp $ -// $LastChangedDate: 2014-03-29 02:30:21 -0500 (Sat, 29 Mar 2014) $ -// $LastChangedRevision: 1 $ -// $LastChangedBy: mercyful $ - -/* - -# include "users.h" -# include "struct.h" -# include "conio.h" -# include "msg_pack.h" - -# include -# include - -# include -# include -# include - - - -using namespace std; - - - - Work in Progress, Only Packs 1 Base So Far, have to update Reply Links - Later on and a few extras, although not keep track of it at the moment. - - also add a header count for jam, so we can see how many purged messages - have been packed, can't seem to tell otherwise. -*/ -/* - -msg_pack::msg_pack() { - -// mh = NULL; - // AHandle = NULL; - lastmsg = 0; // Current Message - total = 0; // Total Areas - mbnum = 0; // Current Message Base Number Starting at 0; - msgProcessed = 0; // Count total messages termed / skipped. -} - -int msg_pack::ReadMessages() { - - char path[255]={0}; - - // Since this isn't in out data file for areas, open it manually. - sprintf(path,"%spacktmp",mb.mbpath); - - // Open Mesasge Area and Readin Current Message. - if (AHandle != NULL) MsgCloseArea(AHandle); - AHandle = MsgOpenArea((byte *)path, MSGAREA_CRIFNEC, mb.Type); - if (AHandle == NULL) return(FALSE); - else Add2MsgInfo(); - - - - // Make sure were not past the highest message in this area. - if(lastmsg > MI.high_msg) { - return FALSE; - } - - // Open Message Area - mh = MsgOpenMsg(AHandle, MOPEN_RW, lastmsg); - if(mh == NULL) return FALSE; - - // Read in Message - if (GetMsg() == FALSE) { - // If we skipped a killed message. - //++msgProcessed; - } - MsgCloseMsg(mh); - - //if (xmsg.attr & MSGLOCKED) ++msgProcessed; - - // Now save it back to orininal mesage area. - SaveMsg(mbnum,lastmsg,TRUE); - return TRUE; -} - -// Read in only current are and truncate mesasge base. -void msg_pack::TruncCurrentArea(int iArea, int MaxMsgs) { - - // Add Lock Files Lateron. - mbnum = CURRENT_MAREA+1; - int prevmessages = 0; - int newmessages = 0; - - // Readin Current Message Base to Clone it's basic setup - memset(&mb,0,sizeof(mb_list_rec)); - total = _msgf.msg_count(); // Count Message Areas - prevmessages = _msgf.CountMsgs(mbnum); // Count Messages in Current Area - _msgf.read_mbaselist(&mb, mbnum); - - if (AHandle != NULL) { - CloseMsgArea(); - } - - if (prevmessages < MaxMsgs) return; - - //rename to avoid duplicate files - char sLine[200], sLine1[200], sLine2[200], sLine3[200]; - char sNLine[200], sNLine1[200], sNLine2[200]; - - // Original Message Areas - sprintf(sLine,"%s%s.jdt", mb.mbpath, mb.mbfile); - sprintf(sLine1,"%s%s.jhr", mb.mbpath, mb.mbfile); - sprintf(sLine2,"%s%s.jdx", mb.mbpath, mb.mbfile); - sprintf(sLine3,"%s%s.jlr", mb.mbpath, mb.mbfile); - - // NewTemp Message Areas (Tmp Packing Base) - sprintf(sNLine,"%spacktmp.jdt", mb.mbpath); - sprintf(sNLine1,"%spacktmp.jhr", mb.mbpath); - sprintf(sNLine2,"%spacktmp.jdx", mb.mbpath); - - // Rename Current to packing - //putline(sLine); putline(sNLine); - rename(sLine,sNLine); - rename(sLine1,sNLine1); - rename(sLine2,sNLine2); - - remove(sLine3); // Reset all Last Reads on this area to 0! - - // Re-Create Original Message Base - // So we can Copy Messages into it fresh! - _msgf.save_msgbase(&mb); - - // Now Loop throguh Each Mesasge And Copy form Temp back to Original - // Skipping any Purged / Deleted Messages for Clean Up. - //lastmsg = 0; - - lastmsg = prevmessages - (MaxMsgs-1); - - do { - ++lastmsg; - } - while(ReadMessages() == TRUE); - - // Remove Left Over Temp (Packing) Area - remove(sNLine); - remove(sNLine1); - remove(sNLine2); - - if (AHandle != NULL) { - CloseMsgArea(); - } - - newmessages = _msgf.CountMsgs(mbnum); - - if (AHandle != NULL) { - CloseMsgArea(); - } - - // Display Total of Messages Copied. - - - pipe2ansi(sLine); - - // Reset Evenyone's Last Read Pointer if it's Greater Then message num = -1! - users _usr; - int iTotal = _usr.idx_count(); - int idx; - - lastmsg = prevmessages - (MaxMsgs-1); - - //Basically where resetting all high message pointers - //if current pointer is higher then where we start, then add this difference, else set to 0 - for (int iCnt = 0; iCnt != iTotal; iCnt++) { - idx = GetLastRead(iCnt); - // Last Read, >= Deleted Message, set Last Read Down - if (idx > lastmsg) { - idx = idx - lastmsg; - } - else { - idx = 0; - } - SetLastRead(iCnt,idx); - } -} - - -// Read in only current are and pack mesasge base. -void msg_pack::PackCurrentArea(int iArea) { - - // Add Lock Files Lateron. - mbnum = CURRENT_MAREA+1; - int prevmessages = 0; - int newmessages = 0; - - // Readin Current Message Base to Clone it's basic setup - memset(&mb,0,sizeof(mb_list_rec)); - total = _msgf.msg_count(); // Count Message Areas - prevmessages = _msgf.CountMsgs(mbnum); // Count Messages in Current Area - _msgf.read_mbaselist(&mb, mbnum); - - if (AHandle != NULL) { - CloseMsgArea(); - } - - //rename to avoid duplicate files - char sLine[200], sLine1[200], sLine2[200], sLine3[200]; - char sNLine[200], sNLine1[200], sNLine2[200]; - - // Original Message Areas - sprintf(sLine,"%s%s.jdt", mb.mbpath, mb.mbfile); - sprintf(sLine1,"%s%s.jhr", mb.mbpath, mb.mbfile); - sprintf(sLine2,"%s%s.jdx", mb.mbpath, mb.mbfile); - sprintf(sLine3,"%s%s.jlr", mb.mbpath, mb.mbfile); - - // NewTemp Message Areas (Tmp Packing Base) - sprintf(sNLine,"%spacktmp.jdt", mb.mbpath); - sprintf(sNLine1,"%spacktmp.jhr", mb.mbpath); - sprintf(sNLine2,"%spacktmp.jdx", mb.mbpath); - - // Rename Current to packing - //putline(sLine); putline(sNLine); - rename(sLine,sNLine); - rename(sLine1,sNLine1); - rename(sLine2,sNLine2); - - remove(sLine3); - - // Re-Create Original Message Base - // So we can Copy Messages into it fresh! - _msgf.save_msgbase(&mb); - - // Now Loop throguh Each Mesasge And Copy form Temp back to Original - // Skipping any Purged / Deleted Messages for Clean Up. - lastmsg = 0; - do { - ++lastmsg; - } - while(ReadMessages() == TRUE); - - // Remove Left Over Temp (Packing) Area - remove(sNLine); - remove(sNLine1); - remove(sNLine2); - - if (AHandle != NULL) { - CloseMsgArea(); - } - - newmessages = _msgf.CountMsgs(mbnum); - - if (AHandle != NULL) { - CloseMsgArea(); - } - - // Display Total of Messages Copied. - - pipe2ansi(sLine); -} - -// Change to next message area, if doesn't exist return FALSE! -int msg_pack::ChangeNextArea() { - - total = _msgf.msg_count(); // count Message Areas - --total; - if(mbnum < total) { - ++mbnum; - lastmsg = 1; - return (TRUE); - } - return (FALSE); - -} - -// Loop throguh each message area and pack bases. -void msg_pack::PackAllAreas() { - - // Loop though each area. - mbnum = 0; - lastmsg = 1; - int done = FALSE; - - pipe2ansi((char *)"|CSPacking Message Areas..."); - do { - PackCurrentArea(mbnum); - if (ChangeNextArea() == FALSE) - done = TRUE; - } - while (done == FALSE); -} - -// Loop throguh each message area and pack bases. -void msg_pack::TruncAllAreas() { - - // Loop though each area. - mbnum = 0; - lastmsg = 1; - int done = FALSE; - - int MaxMesgs = 200; - pipe2ansi((char *)"|CSTruncating Message Areas..."); - do { - TruncCurrentArea(mbnum,MaxMesgs); // Supply Max # of Message PEr Area here. - if (ChangeNextArea() == FALSE) - done = TRUE; - } - while (done == FALSE); -} - - - - -// New Message Function for Packing Message Areas. - -#include "msgapi.h" -#include "prog.h" - - -#define PROGRAM_NAME "sqpack v1.2.4-release" - -unsigned long msgCopied, msgProcessed; // per Area -unsigned long totaloldMsg, totalmsgCopied; - -#define UINT32 unsigned int -#define UINT16 unsigned short -#define ULONG unsigned long - - -// returns zero if msg was killed, nonzero if it was copied - -int processMsg(dword msgNum, dword numMsg, HAREA oldArea, HAREA newArea, - s_area *area, UINT32 shift) -{ - HMSG msg, newMsg; - XMSG xmsg; - struct tm tmTime; - time_t ttime, actualTime = time(NULL); - char *text, *ctrlText; - dword textLen, ctrlLen; - int unsent, i, rc = 0; - - // unsigned long offset; - - msg = MsgOpenMsg(oldArea, MOPEN_RW, msgNum); - if (msg == NULL) return rc; - - if (MsgReadMsg(msg, &xmsg, 0, 0, NULL, 0, NULL)==(dword)-1L) { - MsgCloseMsg(msg); - msgProcessed++; - return rc; - } - - unsent = ((xmsg.attr & MSGLOCAL) && !(xmsg.attr & MSGSENT)) || (xmsg.attr & MSGLOCKED); - - if (unsent || (((area -> max == 0) || ((numMsg - msgProcessed + msgCopied) <= area -> max) || - (area -> keepUnread && !(xmsg.attr & MSGREAD))) && !((xmsg.attr & MSGREAD) && area -> killRead))) { - //only max msgs should be in new area - - if (xmsg.attr & MSGLOCAL) { - DosDate_to_TmDate((SCOMBO*)&(xmsg.date_written), &tmTime); - } else { - DosDate_to_TmDate((SCOMBO*)&(xmsg.date_arrived), &tmTime); - } - // DosDate_to_TmDate(&(xmsg.attr & MSGLOCAL ? xmsg.date_written - //xmsg.date_arrived), &tmTime); - ttime = mktime(&tmTime); - if (ttime == 0xfffffffflu) ttime = 0; // emx - - if (unsent || (area -> purge == 0) || ttime == 0 || - (abs(actualTime - ttime) <= (area -> purge * 24 *60 * 60))) { - xmsg.replyto = MsgUidToMsgn(oldArea, xmsg.replyto, UID_EXACT) > shift ? MsgUidToMsgn(oldArea, xmsg.replyto, UID_EXACT) - shift : 0; - if ((area->msgbType & MSGTYPE_SQUISH) == MSGTYPE_SQUISH){ - - for (i = 0; i < MAX_REPLY; i++) - xmsg.replies[i] = MsgUidToMsgn(oldArea, xmsg.replies[i], UID_EXACT) > shift ? MsgUidToMsgn(oldArea, xmsg.replies[i], UID_EXACT) - shift : 0; - }else { - xmsg.replies[0] = MsgUidToMsgn(oldArea, xmsg.replies[0], UID_EXACT) > shift ? MsgUidToMsgn(oldArea, xmsg.replies[0], UID_EXACT) - shift : 0; - xmsg.xmreplynext = MsgUidToMsgn(oldArea, xmsg.xmreplynext, UID_EXACT) > shift ? MsgUidToMsgn(oldArea, xmsg.xmreplynext, UID_EXACT) - shift : 0; - } - // copy msg - textLen = MsgGetTextLen(msg); - ctrlLen = MsgGetCtrlLen(msg); - - text = (char *) malloc(textLen+1); - text[textLen] = '\0'; - - ctrlText = (char *) malloc(ctrlLen+1); - ctrlText[ctrlLen] = '\0'; - - MsgReadMsg(msg, NULL, 0, textLen, (byte*)text, ctrlLen, (byte*)ctrlText); - - if (area->msgbType & MSGTYPE_SDM) - MsgWriteMsg(msg, 0, &xmsg, (byte*)text, textLen, textLen, ctrlLen, (byte*)ctrlText); - else { - newMsg = MsgOpenMsg(newArea, MOPEN_CREATE, 0); - MsgWriteMsg(newMsg, 0, &xmsg, (byte*)text, textLen, textLen, ctrlLen, (byte*)ctrlText); - MsgCloseMsg(newMsg); - } - - msgCopied++; - free(text); - free(ctrlText); - rc = 1; - } - - } - MsgCloseMsg(msg); - msgProcessed++; - return rc; -} - -UINT32 getShiftedNum(UINT32 msgNum, UINT32 rmCount, UINT32 *rmMap) -{ - UINT32 i, nMsgNum = msgNum; - msgNum += rmMap[1]; - for (i = 0; i < rmCount; i+=2) - if (msgNum >= rmMap[i]) - nMsgNum -= rmMap[i + 1]; - else - break; - return msgNum > 0L ? msgNum : 0L; -} - -void updateMsgLinks(UINT32 msgNum, HAREA area, UINT32 rmCount, UINT32 *rmMap, int areaType) -{ - HMSG msg; - XMSG xmsg; - int i; - - msg = MsgOpenMsg(area, MOPEN_RW, getShiftedNum(msgNum, rmCount, rmMap)); - if (msg == NULL) return; - - MsgReadMsg(msg, &xmsg, 0, 0, NULL, 0, NULL); - - xmsg.replyto = getShiftedNum(xmsg.replyto, rmCount, rmMap); - if ((areaType & MSGTYPE_SQUISH) == MSGTYPE_SQUISH) - for (i = 0; i < MAX_REPLY; i++) - xmsg.replies[i] = getShiftedNum(xmsg.replies[i], rmCount, rmMap); - else { - xmsg.replies[0] = getShiftedNum(xmsg.replies[0], rmCount, rmMap); - xmsg.xmreplynext = getShiftedNum(xmsg.xmreplynext, rmCount, rmMap); - } - - MsgWriteMsg(msg, 0, &xmsg, NULL, 0, 0, 0, NULL); - MsgCloseMsg(msg); -} - - - -void purgeArea(s_area *area) -{ - char *oldName = area -> fileName; - char *newName=NULL; - HAREA oldArea=NULL, newArea = NULL; - dword highMsg, i, j, numMsg, hw=0; - int areaType = area -> msgbType & (MSGTYPE_JAM | MSGTYPE_SQUISH | MSGTYPE_SDM); - - UINT32 *oldLastread, *newLastread = NULL; - UINT32 *removeMap; - UINT32 rmIndex = 0; - - if (area->nopack) { - printf(" No purging needed!\n"); - return; - } - - //generated tmp-FileName - xstrscat(&newName, oldName, "_tmp", NULL); - - //oldArea = MsgOpenArea((byte *) oldName, MSGAREA_NORMAL, -1, -1, -1, MSGTYPE_SQUISH); - oldArea = MsgOpenArea((byte *) oldName, MSGAREA_NORMAL, (word) areaType); - - //if (oldArea) newArea = MsgOpenArea((byte *) newName, MSGAREA_CREATE, area.fperm, area.uid, area.gid,MSGTYPE_SQUISH); - if (oldArea) { - if (areaType == MSGTYPE_SDM) - newArea = oldArea; - else - newArea = MsgOpenArea((byte *) newName, MSGAREA_CREATE, (word) areaType); - } - - if ((oldArea != NULL) && (newArea != NULL)) { - ULONG lcount; - - highMsg = MsgGetHighMsg(oldArea); - numMsg = MsgGetNumMsg(oldArea); - if (areaType != MSGTYPE_SDM) hw = MsgGetHighWater(oldArea); - readLastreadFile(oldName, &oldLastread, &lcount, oldArea, areaType); - if (oldLastread) { - newLastread = (UINT32 *) malloc(lcount * sizeof(UINT32)); - memcpy(newLastread, oldLastread, lcount * sizeof(UINT32)); - } - - removeMap = (UINT32 *) calloc(2, sizeof(UINT32)); - - for (i = j = 1; i <= highMsg; i++, j++) { - if (!processMsg(j, numMsg, oldArea, newArea, area, - removeMap[1])) { - if (!(rmIndex & 1)) { - // We started to delete new portion of - removeMap = (UINT32 *) realloc(removeMap, (rmIndex + 2) * sizeof(UINT32)); - removeMap[rmIndex++] = i; - removeMap[rmIndex] = 0; - }; - removeMap[rmIndex]++; // Anyway, update counter - if (areaType == MSGTYPE_SDM) - MsgKillMsg(oldArea, j--); - } else { - // We are copying msgs - if (rmIndex & 1) rmIndex++; - }; - }; - - if (rmIndex && areaType == MSGTYPE_SDM) { - // renumber the area - char oldmsgname[PATHLEN], newmsgname[PATHLEN]; - for (i = j = 1; i <= highMsg; i++) { - strncpy(oldmsgname, oldName, PATHLEN); - Add_Trailing(oldmsgname, PATH_DELIM); - strncpy(newmsgname, oldmsgname, PATHLEN); - sprintf(oldmsgname+strlen(oldmsgname), "%u.msg", (unsigned int)i); - sprintf(newmsgname+strlen(newmsgname), "%u.msg", (unsigned int)j); - if (access(oldmsgname, 0)) - continue; - if (i == j) { - j++; - continue; - } - if (rename(oldmsgname, newmsgname) == 0) - j++; - } - } - - if (rmIndex > 2) { // there were several areas with deleted msgs - for (j = 1; j <= highMsg; j++) - updateMsgLinks(i, newArea, rmIndex + 1, removeMap, areaType); - } - - if (rmIndex) { // someting was removed, maybe need to update lastreadfile - for (j = 0; j < lcount; j++) { - for (i=0; i= removeMap[i]) { - if (oldLastread[j] >= removeMap[i] + removeMap[i+1]) { - newLastread[j] -= removeMap[i+1]; - } else { - newLastread[j] -= oldLastread[j] - removeMap[i] + 1; - } - } - } - } - } - - writeLastreadFile(oldName, newLastread, lcount, newArea, areaType); - - MsgCloseArea(oldArea); - if (areaType != MSGTYPE_SDM) { - if ((numMsg - msgCopied) > hw) hw=0; - else hw -= (numMsg - msgCopied); - MsgSetHighWater(newArea, hw); - MsgCloseArea(newArea); - } - - printf(" oldMsg: %lu newMsg: %lu\n", (unsigned long)numMsg, msgCopied); - totaloldMsg+=numMsg; totalmsgCopied+=msgCopied; // total - - free(oldLastread); - free(newLastread); - - //rename oldArea to newArea - renameArea(areaType, oldName, newName); - } - else { - if (oldArea) MsgCloseArea(oldArea); - printf("Could not open %s or create %s.\n", oldName, newName); - } - free(newName); -} - -*/ diff --git a/src/msg_pack.h b/src/msg_pack.h index 5e70bcc..9599035 100755 --- a/src/msg_pack.h +++ b/src/msg_pack.h @@ -1,8 +1,8 @@ /*************************************************************************** - * Copyright (C) 2004-2014 by Michael Griffin * + * Copyright (C) 2004-2017 by Michael Griffin * * mrmisticismo@hotmail.com * * * - * Purpose: * + * Purpose: Incomplete * * * * * * * @@ -12,51 +12,8 @@ * (at your option) any later version. * ***************************************************************************/ -// Enthral SVN: $Id: msg_pack.h 1 2014-03-29 07:30:21Z mercyful $ -// Source: $HeadURL: file:///home/merc/repo/enthral/trunk/src/msg_pack.h $ -// $LastChangedDate: 2014-03-29 02:30:21 -0500 (Sat, 29 Mar 2014) $ -// $LastChangedRevision: 1 $ -// $LastChangedBy: mercyful $ - # ifndef MSG_PACK_H # define MSG_PACK_H -/* -# include "struct.h" -# include "mb_api.h" -# include "msgs.h" - -# include - - -class msg_pack : private mbapi_jam { - - unsigned long lastmsg; - unsigned long total; - unsigned long mbnum; - unsigned long msgProcessed; // # of Termed Messages. - - mb_list_rec mb; - msgs _msgf; - - public: - msg_pack(); - int ReadMessages(); - - // Read in only current are and truncate mesasge base. - void TruncCurrentArea(int iArea, int MaxMsgs); - - // Read in only current are and pack mesasge base. - void PackCurrentArea(int iArea); - // Change to next message area, if doesn't exist return FALSE! - int ChangeNextArea(); - // Loop throguh each message area and pack bases. - void PackAllAreas(); - - // Loop through and Truncate All Message areas. - void TruncAllAreas(); - -}; -*/ # endif diff --git a/src/msg_quote.cpp b/src/msg_quote.cpp index ad59871..b9560fa 100755 --- a/src/msg_quote.cpp +++ b/src/msg_quote.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2004-2014 by Michael Griffin * + * Copyright (C) 2004-2017 by Michael Griffin * * mrmisticismo@hotmail.com * * * * Purpose: * @@ -12,12 +12,6 @@ * (at your option) any later version. * ***************************************************************************/ -// Enthral SVN: $Id: msg_quote.cpp 1 2014-03-29 07:30:21Z mercyful $ -// Source: $HeadURL: file:///home/merc/repo/enthral/trunk/src/msg_quote.cpp $ -// $LastChangedDate: 2014-03-29 02:30:21 -0500 (Sat, 29 Mar 2014) $ -// $LastChangedRevision: 1 $ -// $LastChangedBy: mercyful $ - # include "struct.h" # include "msg_readll.h" # include "menu_func.h" @@ -29,19 +23,17 @@ # include # include # include -# include // gcc 4.3 -# include // gcc 4.3 -# include // gcc 4.7 +# include +# include +# include using namespace std; - /* * Message FullScreen Quoter INI - INI Exists */ bool msgquote_ini::msg_exists() { - iTop = 0; iBot = 0; @@ -78,7 +70,6 @@ bool msgquote_ini::msg_exists() */ void msgquote_ini::msg_create() { - std::string name = INIPATH; name += "msgquote.ini"; @@ -124,7 +115,6 @@ void msgquote_ini::msg_create() */ void msgquote_ini::msg_chkpar(std::string &data) { - std::string temp1; std::string::size_type st1 = 0; std::string::size_type st2 = 0; @@ -145,7 +135,6 @@ void msgquote_ini::msg_chkpar(std::string &data) */ void msgquote_ini::msg_check(std::string cfgdata) { - std::string temp = cfgdata; int id1 = -1; @@ -153,7 +142,6 @@ void msgquote_ini::msg_check(std::string cfgdata) if (temp[0] == '#') return; // Sets if LOGGING is on / off - id1 = -1; id1 = temp.find("set TOP ", 0); if (id1 != -1) { msg_chkpar(temp); @@ -163,7 +151,6 @@ void msgquote_ini::msg_check(std::string cfgdata) } // Sets Download Path - id1 = -1; id1 = temp.find("set BOT ", 0); if (id1 != -1) { msg_chkpar(temp); @@ -173,7 +160,6 @@ void msgquote_ini::msg_check(std::string cfgdata) } // Sets XY PAGE Num - id1 = -1; id1 = temp.find("set PAGENUM ", 0); if (id1 != -1) { msg_chkpar(temp); @@ -182,7 +168,6 @@ void msgquote_ini::msg_check(std::string cfgdata) } // Sets XY PAGE Num - id1 = -1; id1 = temp.find("set PAGETOTAL ", 0); if (id1 != -1) { msg_chkpar(temp); @@ -191,7 +176,6 @@ void msgquote_ini::msg_check(std::string cfgdata) } // Sets XY PAGE Num - id1 = -1; id1 = temp.find("set MOREUP ", 0); if (id1 != -1) { msg_chkpar(temp); @@ -200,7 +184,6 @@ void msgquote_ini::msg_check(std::string cfgdata) } // Sets XY PAGE Num - id1 = -1; id1 = temp.find("set MOREUP_CHAR ", 0); if (id1 != -1) { msg_chkpar(temp); @@ -209,7 +192,6 @@ void msgquote_ini::msg_check(std::string cfgdata) } // Sets XY PAGE Num - id1 = -1; id1 = temp.find("set MOREDOWN ", 0); if (id1 != -1) { msg_chkpar(temp); @@ -218,7 +200,6 @@ void msgquote_ini::msg_check(std::string cfgdata) } // Sets XY PAGE Num - id1 = -1; id1 = temp.find("set MOREDOWN_CHAR ", 0); if (id1 != -1) { msg_chkpar(temp); @@ -227,7 +208,6 @@ void msgquote_ini::msg_check(std::string cfgdata) } // Sets XY PAGE Num - id1 = -1; id1 = temp.find("set MOREMSG_ON ", 0); if (id1 != -1) { msg_chkpar(temp); @@ -236,7 +216,6 @@ void msgquote_ini::msg_check(std::string cfgdata) } // Sets XY PAGE Num - id1 = -1; id1 = temp.find("set MOREMSG_WORD_ON ", 0); if (id1 != -1) { msg_chkpar(temp); @@ -244,8 +223,7 @@ void msgquote_ini::msg_check(std::string cfgdata) return; } -// Sets XY PAGE Num - id1 = -1; + // Sets XY PAGE Num id1 = temp.find("set MOREMSG_OFF ", 0); if (id1 != -1) { msg_chkpar(temp); @@ -254,7 +232,6 @@ void msgquote_ini::msg_check(std::string cfgdata) } // Sets XY PAGE Num - id1 = -1; id1 = temp.find("set MOREMSG_WORD_OFF ", 0); if (id1 != -1) { msg_chkpar(temp); @@ -262,8 +239,7 @@ void msgquote_ini::msg_check(std::string cfgdata) return; } - // Sets XY PAGE Num - id1 = -1; + // Sets XY PAGE Num id1 = temp.find("set INPUT_BOX ", 0); if (id1 != -1) { msg_chkpar(temp); @@ -272,7 +248,6 @@ void msgquote_ini::msg_check(std::string cfgdata) } // Sets XY PAGE Num - id1 = -1; id1 = temp.find("set TEXT_COLOR ", 0); if (id1 != -1) { msg_chkpar(temp); @@ -281,7 +256,6 @@ void msgquote_ini::msg_check(std::string cfgdata) } // Sets XY PAGE Num - id1 = -1; id1 = temp.find("set TEXT_HILIGHT ", 0); if (id1 != -1) { msg_chkpar(temp); @@ -290,7 +264,6 @@ void msgquote_ini::msg_check(std::string cfgdata) } // Sets XY PAGE Num - id1 = -1; id1 = temp.find("set QUOTE_RANGE ", 0); if (id1 != -1) { msg_chkpar(temp); @@ -304,14 +277,12 @@ void msgquote_ini::msg_check(std::string cfgdata) */ void msgquote_ini::msg_parse() { - std::string name = INIPATH; name += "msgquote.ini"; ifstream inStream; inStream.open( name.c_str() ); if (!inStream.is_open()) { - //printf("Couldn't Open Config File: %s\n", name.c_str()); perror("Error unable to parse msgquote.ini, check permissions!"); return; } @@ -326,13 +297,11 @@ void msgquote_ini::msg_parse() return; } - /* * Message FullScreen Quoter - Class */ msg_quote::msg_quote() { - tTop = 1; tBot = 1; } @@ -342,13 +311,12 @@ msg_quote::msg_quote() */ void msg_quote::ParseMQuote(char *filename) { - int c = 0; std::string temp; std::string path = ANSIPATH; path += filename; path += ".ans"; - // Get Filesize to Allocate Buffer + FILE *inStream; std::string::size_type id1 = 0; @@ -357,8 +325,9 @@ void msg_quote::ParseMQuote(char *filename) return; } - char MCI[3] = {0}; // Holds MCI Codes to Parse - temp = ""; // Holds Ansi + char MCI[3] = {0}; + temp = ""; + do { memset(&MCI,0,sizeof(MCI)); c = getc(inStream); @@ -366,12 +335,9 @@ void msg_quote::ParseMQuote(char *filename) MCI[0] = getc(inStream); MCI[1] = getc(inStream); - /* ie example... - if (strcmp(MCI,"TI") == 0) { temp += mHead.time; } - else if (strcmp(MCI,"FM") == 0) { temp += mHead.from; } - */ c = getc(inStream); if (c != EOF) temp += c; + } else if (c == '\n') {} //temp += '\r'; else { if (c != EOF) temp += c; @@ -381,14 +347,14 @@ void msg_quote::ParseMQuote(char *filename) temp += "\n"; // Extra Space to Fix Next Ansi Sequence - do { // Fix, adds ESC[h - Home Cusror to Clear SCreen for Redraws. + // Fix, adds ESC[h - Home Cusror to Clear Screen for Redraws. + do { id1 = temp.find("\x1b[2J",0); if (id1 != std::string::npos-1) { temp.replace(id1,4,"|CS"); } } while(id1 != std::string::npos); - //write(0,(char *)temp.c_str(),temp.size()); pipe2ansi((char *)temp.c_str()); } @@ -397,27 +363,22 @@ void msg_quote::ParseMQuote(char *filename) */ void msg_quote::setup_quoter() { - - // Do quick Message Quoter ini parsing if (!msg_exists()) { perror("Error unable to read msgquote.ini, check permissions!"); return; - //msg_create(); } + msg_parse(); tTop = iTop; tBot = iBot; } - /* * Message FullScreen Quoter - Insert Lines into Quoters Link List. * Passed from FSE via Link List. */ void msg_quote::insert_lines(LineRec *orgLink, msg_readll *mLink) { - - int count = 1; std::string::size_type id1 = 0, id2 = 0; std::string currLine; @@ -452,31 +413,18 @@ void msg_quote::insert_lines(LineRec *orgLink, msg_readll *mLink) } else break; } - // Add to Vecor for New Parsing. newList.push_back(lineTmp->data); - - // Next Line if (lineTmp->dn_link == 0) break; lineTmp = lineTmp->dn_link; } - newLine.erase(); std::string qInitials; - //Loop Vecor List and Word Wrap for(std::string str : newList) { - // When quoting quoted text, removing starting "> " - // This doesn't wrap properly. - - //id1 = str.find(" II> "); Find initial. - - - // When quoting quoted text, removing starting "> " - // This doesn't wrap properly. id1 = str.find("> "); if (id1 != std::string::npos) { if (id1 == 0) @@ -550,11 +498,9 @@ void msg_quote::insert_lines(LineRec *orgLink, msg_readll *mLink) if ((signed)str.size() > 74) { id1 = str.rfind(" ",74); if (id1 != std::string::npos) { - // Space in Line, cut at last Word mLink->add_to_list(str.substr(0,id1)); newLine = str.substr(id1+1); } else { - // No Spaces in line, cut and wrap at 74. mLink->add_to_list(str.substr(0,74)); newLine = str.substr(75); } @@ -577,13 +523,11 @@ void msg_quote::insert_lines(LineRec *orgLink, msg_readll *mLink) return; } - /* * Message FullScreen Quoter - Parse Range and Selections */ void msg_quote::par_qstring(char *rBuffer, msg_readll *mLink) { - char cBuff2[20]= {0}; char cBuff3[20]= {0}; std::string rBuff; @@ -598,10 +542,9 @@ void msg_quote::par_qstring(char *rBuffer, msg_readll *mLink) rBuff = rBuffer; id1 = rBuff.find("-",0); id2 = rBuff.find(",",0); - // Check if Range and Single Line Selection Are both Present + if (id1 != std::string::npos && id2 != std::string::npos) { - // Chop up String between each ',' char... then process seperatly. num2 = id2; memset(&cBuff2,0, sizeof(cBuff2)); for (int i = 0; i != (signed)id2; i++) { @@ -642,9 +585,7 @@ void msg_quote::par_qstring(char *rBuffer, msg_readll *mLink) if ((signed)id1 > mLink->Tot || (signed)id1 == 0) break; mLink->flag_line(id1); } - // Done, Loop Though and Process next part of Original String. } - // Then check if only Range ... 1-6 - Working! else if (id1 != std::string::npos) { // id1 = '-' Position num = id1; memset(&cBuff2,0, sizeof(cBuff2)); @@ -669,7 +610,6 @@ void msg_quote::par_qstring(char *rBuffer, msg_readll *mLink) } break; } - // Then check if only Selections 1,6 - Working! else if (id2 != std::string::npos) { // id2 = ',' Position num2 = id2; num = id2; @@ -703,7 +643,6 @@ void msg_quote::par_qstring(char *rBuffer, msg_readll *mLink) */ void msg_quote::StartQuoter(LineRec *orgLink, std::string &retbuf) { - bool more = false; bool showmore = false; char mString[10] = {0}; @@ -711,7 +650,6 @@ void msg_quote::StartQuoter(LineRec *orgLink, std::string &retbuf) std::string _output; char outBuffer[1024] = {0}; - // Startup Message Reader Link List for Holding Message Lines menu_func _mnuf; // Menu System for Lightbars msg_readll mLink; // Link List for Holding Message Quote Data @@ -729,24 +667,12 @@ void msg_quote::StartQuoter(LineRec *orgLink, std::string &retbuf) std::string::size_type id1 = 0, id2 = 0; int len; - // Quote Buffer to return to FSE. - // We Return - //static char qBuf[BUFLEN]; - //memset(&qBuf,0,BUFLEN); - std::string qbuf; qbuf.erase(); - - - //errlog2((char *)" &&& Start Quote!"); - insert_lines(orgLink,&mLink); // Take Original List and Copy it to Message Quoter - //mLink.line_total(); - - //errlog2((char *)" &&& Start Quote 2 !"); + insert_lines(orgLink,&mLink); // Run through Main Reader Loop until exit from user - This Loop Probably not needed anymore. while (1) { - // Setup a new Message Quoter ansi ansiPrintf((char *)"mquote"); mLink.box_refresh(CURRENT_MAREA); // So Always Displayed Highlighting on Current Page! @@ -755,8 +681,7 @@ void msg_quote::StartQuoter(LineRec *orgLink, std::string &retbuf) more = false; showmore = false; if (mLink.Page != mLink.TotPages) more = true; - /*-------------------------------------------------------*/ - // Show Down Arrow More! + if (more) { sprintf(outBuffer,"%s\x19",sMOREDOWN); // On showmore = true; @@ -785,19 +710,16 @@ void msg_quote::StartQuoter(LineRec *orgLink, std::string &retbuf) _output += outBuffer; sprintf(outBuffer,"%s%.2d",sPAGETOTAL,mLink.TotPages); _output += outBuffer; + // Max Quote Range sprintf(outBuffer,"%s%d",sQUOTE_RANGE,mLink.Tot); _output += outBuffer; - /*-------------------------------------------------------*/ + pipe2ansi((char *)_output.c_str()); - // If more, Select Menu Prompt with PGDN as Default - // Otherwise Select Prompt with Next as Default! - // Make Msgqp2 Prompt Optional, Use if exists! - // Also Let user Toggle on / off _mnuf._premenu.clear(); _mnuf._premenu = _mnuf._curmenu; - if (_mnuf.cmdexist((char *)"msg_qprompt2",0) /*&& thisuser->msgp2*/ ) { + if (_mnuf.cmdexist((char *)"msg_qprompt2",0)) { if (more || mLink.Page > 1) { _mnuf._curmenu.clear(); _mnuf._curmenu = "msg_qprompt2"; @@ -810,12 +732,8 @@ void msg_quote::StartQuoter(LineRec *orgLink, std::string &retbuf) _mnuf._curmenu = "msg_qprompt"; } - // Readin the Menu Prompt _mnuf.menu_readin(); - // Process Messeage Promt with lightbar menu _mnuf.menu_proc(mString); - // Process Return Input from Lightbars, Next, Prev, Quit ... - //mString[0] should = ! ch = mString[1]; // For Menu CmdKey Input @@ -823,10 +741,8 @@ void msg_quote::StartQuoter(LineRec *orgLink, std::string &retbuf) switch (toupper(ch)) { case 'Q': // Quit Message Reading - //strcpy(qBuf,mLink.GetBuffer()); mLink.GetBuffer(retbuf); mLink.dispose_list(); - //_mnuf.~menu_func(); return; case 'U': // Page UP @@ -841,19 +757,16 @@ void msg_quote::StartQuoter(LineRec *orgLink, std::string &retbuf) ansiPrintf((char *)"mreadhlp"); getkey(true); ansiPrintf((char *)"mquote"); - //mLink.box_refresh(); mLink.box_overdraw(CURRENT_MAREA); break; case 'A': // Select all Text To Quote mLink.select_all(); - //mLink.box_refresh(); mLink.box_overdraw(CURRENT_MAREA); break; case 'C': // Clear All Quoted Text. mLink.clear_all(); - //mLink.box_refresh(); mLink.box_overdraw(CURRENT_MAREA); break; @@ -861,7 +774,6 @@ void msg_quote::StartQuoter(LineRec *orgLink, std::string &retbuf) break; } // end of case else if (mString[0] == '#') { - // received Digist Input From Menu Prompt, Start Input for Quoting Text! memset(&rBuffer,0, sizeof(rBuffer)); memset(&text,0, sizeof(text)); strcpy(text,sINPUT_BOX); @@ -873,11 +785,9 @@ void msg_quote::StartQuoter(LineRec *orgLink, std::string &retbuf) getline(rBuffer,len,sNum,FALSE,(char *)"1234567890,-"); rBuff = rBuffer; - // For # & ENTER, Then DIGIT & ENTER Again. id1 = rBuff.find("-",0); id2 = rBuff.find(",",0); - // If a Single #, Check if Valid if (id1 == std::string::npos && id2 == std::string::npos) { id1 = atol(rBuffer); @@ -905,13 +815,10 @@ void msg_quote::StartQuoter(LineRec *orgLink, std::string &retbuf) ch = mString[0]; switch (toupper(ch)) { case 'A': - // Scroll Up 1 Line ( forced to paeg up / down for now) - // Don't care much for single scrolling, anoying online! - // Page is much nicer and faster ;) mLink.box_pgup(); break; - case 'B': // Scroll down 1 Line ( forced to paeg up / down for now) + case 'B': mLink.box_pgdn(); break; diff --git a/src/msg_quote.h b/src/msg_quote.h index 0d2b158..c57ad4f 100755 --- a/src/msg_quote.h +++ b/src/msg_quote.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2004-2014 by Michael Griffin * + * Copyright (C) 2004-2017 by Michael Griffin * * mrmisticismo@hotmail.com * * * * Purpose: * @@ -12,12 +12,6 @@ * (at your option) any later version. * ***************************************************************************/ -// Enthral SVN: $Id: msg_quote.h 1 2014-03-29 07:30:21Z mercyful $ -// Source: $HeadURL: file:///home/merc/repo/enthral/trunk/src/msg_quote.h $ -// $LastChangedDate: 2014-03-29 02:30:21 -0500 (Sat, 29 Mar 2014) $ -// $LastChangedRevision: 1 $ -// $LastChangedBy: mercyful $ - # ifndef MSG_QUOTE_H # define MSG_QUOTE_H diff --git a/src/msg_read.cpp b/src/msg_read.cpp index d75b45b..b3de1d4 100644 --- a/src/msg_read.cpp +++ b/src/msg_read.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2004-2014 by Michael Griffin * + * Copyright (C) 2004-2017 by Michael Griffin * * mrmisticismo@hotmail.com * * * * Purpose: * @@ -10,13 +10,6 @@ * (at your option) any later version. * ***************************************************************************/ -// Enthral SVN: $Id: msg_read.cpp 1 2014-03-29 07:30:21Z mercyful $ -// Source: $HeadURL: file:///home/merc/repo/enthral/trunk/src/msg_read.cpp $ -// $LastChangedDate: 2014-03-29 02:30:21 -0500 (Sat, 29 Mar 2014) $ -// $LastChangedRevision: 1 $ -// $LastChangedBy: mercyful $ - - # include "struct.h" # include "msgs.h" # include "conio.h" @@ -33,15 +26,15 @@ # include # include -# include // Stream Numbers to Strings. -# include // Sort and Reverse +# include +# include # include # include # include -# include // gcc 4.3 -# include // gcc 4.3 -# include // gcc 4.7 +# include +# include +# include using namespace std; @@ -140,7 +133,7 @@ void msgread_ini::msg_chkpar(std::string &data) */ void msgread_ini::msg_check(std::string cfgdata) { - int id1; + std::string::size_type id1; std::string temp = cfgdata; if (temp[0] == '#') return; else if (temp.find("set VIEW_TYPE ", 0) != @@ -268,11 +261,9 @@ int msgread_ini::msg_parse(int idx) if (idx != 0) strcpy(name,name2); - // Check if Theme Exists, if not return FALSE. FILE *stream; stream = fopen(name,"rb+"); if(stream == NULL) { - // File is not Present return FALSE; } fclose(stream); @@ -280,7 +271,6 @@ int msgread_ini::msg_parse(int idx) ifstream inStream; inStream.open( name ); if (!inStream.is_open()) { - //printf("Couldn't Open Config File: %s\n", name); perror("Error unable to parse msgread.ini, check permissions!"); return FALSE; } @@ -308,7 +298,6 @@ msg_read::msg_read() gblNewScan = 0; } - /** * Message Reader Start-Up Class */ @@ -317,7 +306,6 @@ void msg_read::start(UserRec *user) thisuser = user; start_session(user); - // Check What Theme user has selected. if (msg_parse(thisuser->readertheme) == FALSE) msg_parse(); @@ -330,13 +318,11 @@ void msg_read::start(UserRec *user) */ int msg_read::change_theme(int idx) { - // Check What Theme user has selected. if (msg_parse(idx) == FALSE) return FALSE; thisuser->readertheme = idx; - // Save User Settings. UserRec usr; usr = *thisuser; users _usr; @@ -356,13 +342,11 @@ void msg_read::ansi_file(char *filename) path += filename; path += ".ans"; - char MCI[3] = {0}; // Holds MCI Codes to Parse + char MCI[3] = {0}; char sTemp[1024] = {0}; int space = 0, foundr = 0, foundl = 0; std::string buff; - - // Buffer in Ansi readinAnsi(filename, buff); // Calcuate how many messages total and left by current index. @@ -372,8 +356,6 @@ void msg_read::ansi_file(char *filename) int id1 = 0; do { - // parse justify spacing right / left passing in string before - // replacing mci code. to Properly Space Output Ansi. id1 = buff.find("%", 0); if (id1 == -1) break; @@ -382,29 +364,24 @@ void msg_read::ansi_file(char *filename) // Check if MCI Code is Justified then Process this. if (buff[id1+3] == '{') { // Left Justify - //elog("left justify: %c%c",buff[id1+4],buff[id1+5]); - MCI[0] = buff[id1+4]; // Get first Digit - MCI[1] = buff[id1+5]; // Get Second Digit + MCI[0] = buff[id1+4]; + MCI[1] = buff[id1+5]; space = atoi(MCI); foundr = FALSE; foundl = TRUE; } else if (buff[id1+3] == '}') { // Right Justify - //elog("right justify: %c%c",buff[id1+4],buff[id1+5]); - MCI[0] = buff[id1+4]; // Get first Digit - MCI[1] = buff[id1+5]; // Get Second Digit + MCI[0] = buff[id1+4]; + MCI[1] = buff[id1+5]; space = atoi(MCI); - //elog("right justify: %i",space); foundl = FALSE; foundr = TRUE; } // Now Get MCI Code - MCI[0] = buff[id1+1]; // Get first Digit - MCI[1] = buff[id1+2]; // Get Second Digit + MCI[0] = buff[id1+1]; + MCI[1] = buff[id1+2]; memset(&sTemp,0,sizeof(sTemp)); - // Insert MCI Parsing here so we can reaplace full result with propering spacing. - if (strcmp(MCI,"TI") == 0) { sprintf(sTemp,"%s", (char *)mHead.time); @@ -419,11 +396,11 @@ void msg_read::ansi_file(char *filename) } else if (strcmp(MCI,"SU") == 0) { sprintf(sTemp,"%s", (char *)mHead.subj); } else if (strcmp(MCI,"CM") == 0) { - sprintf(sTemp,"%lu", CurMsgs); // Currnet Message + sprintf(sTemp,"%lu", CurMsgs); } else if (strcmp(MCI,"HM") == 0) { - sprintf(sTemp,"%lu", TotMsgs); // Total Messages + sprintf(sTemp,"%lu", TotMsgs); } else if (strcmp(MCI,"ML") == 0) { - sprintf(sTemp,"%lu", MsgsLeft); // Messages Left + sprintf(sTemp,"%lu", MsgsLeft); } else if (strcmp(MCI,"TH") == 0) { sprintf(sTemp,"#%i. %s",thisuser->readertheme+1,sTHEME_NAME); } @@ -437,10 +414,10 @@ void msg_read::ansi_file(char *filename) //If we Parsed Justify, then Erase that MCI Code as well. (space != 0) ? - buff.replace(id1,6,sTemp): // 2 sequences - buff.replace(id1,3,sTemp); // 1 sequence + buff.replace(id1,6,sTemp): + buff.replace(id1,3,sTemp); } while (1); - //elog("Finished Parsing MCI Codes..."); + pipe2ansi((char *)buff.c_str()); } @@ -448,12 +425,12 @@ void msg_read::ansi_file(char *filename) * Message Reader - Main Readin Text Only to Buffer */ void msg_read::ReadInMsgOnly(ulong marea) -{ - // Read Data from Jam Message Area +{ if(!ReadMsgArea(marea)) { return; } - MsgSetupTxt(); // Title Scan + + MsgSetupTxt(); } /** @@ -463,50 +440,39 @@ int msg_read::ReadMsg(ulong marea, int showit, int newmsg, int private_area) { ulong lr = 0; - // Make Sure index is not greater then last message. if (current_msgidx >= msgidx_translation->size()) { return FALSE; } - // Get Last Read, If we read private messages past last read set lr = GetLastRead(thisuser->idx); - // Read Data from Jam Message Area if(!ReadMsgArea(marea)) { return FALSE; } - - // If were Scanning Messages, or Showing Them - // Populate Message Structure. if (showit) { if (private_area == TRUE && strcmp((char *)thisuser->handle,(char *)MI.To) == 0) { - MsgSetupTxt(); // Normal Message Reader + MsgSetupTxt(); } else if (private_area == TRUE && strcmp((char *)thisuser->handle,(char *)MI.To) != 0 && opscan == FALSE) { // Blank, don't populate header or message! } else if (private_area == FALSE) { - MsgSetupTxt(); // Normal Message Reader (No Email) + // Normal Message Reader (No Email) + MsgSetupTxt(); ++Views; } else { - MsgSetupTxt(); // Normal Message Reader (No Email) / Or Sysop Email Read. + // Normal Message Reader (No Email) / Or Sysop Email Read. + MsgSetupTxt(); if (opscan != TRUE) ++Views; } } else { - SetupMsgHdr(); // Title Scan + // Title Scan + SetupMsgHdr(); } - // Public NewScan - Working! if(newmsg && showit) { - - // First makesure last read pointer is not past the highest message. - // This mean all messages per current area have been read. if (lr < msgidx_translation->size()) { - // If Currnet Mesage > Message where LastRead Index is at. if (thisuser->lastmsg >= msgidx_translation->at(lr)) { - // Set last read to current index to Next Message, thats where we - // Start Reading from. if we quit and start over, or New Messages - // get Posted. SetLastRead(thisuser->idx, current_msgidx+1); } } @@ -546,7 +512,6 @@ void msg_read::JumpToMessage() { std::string AnsiString = ""; char choice[100] = {0}; - // char szTmp[3] = {0}; char szReplace[10] = {0}; std::string::size_type id1 = 0; @@ -555,9 +520,6 @@ void msg_read::JumpToMessage() AnsiString = choice; id1 = AnsiString.find("|HM",0); if (id1 != std::string::npos) { - // szTmp[0] = AnsiString[id1+1]; - // szTmp[1] = AnsiString[id1+2]; - sprintf(szReplace,"%lu",TotMsgs); AnsiString.replace(id1,3,szReplace); } @@ -569,7 +531,7 @@ void msg_read::JumpToMessage() getline(choice,len); if ((id1 = atoi(choice)) > 0); - --id1; // Move to 0 based array. + --id1; // Move to new Message if ( (signed)id1 >= 0 && id1 < msgidx_translation->size() ) { @@ -578,7 +540,6 @@ void msg_read::JumpToMessage() } else { pipe2ansi((char *)"|CR|CR|15Invalid: |07Message number. Try again! |DE |DE"); } - } /** @@ -587,11 +548,10 @@ void msg_read::JumpToMessage() void msg_read::IgnoreTheRest(ulong marea) { ulong curr_msg = 0; - curr_msg = msgidx_translation->size()-1; thisuser->lastmsg = msgidx_translation->at( msgidx_translation->size()-1 ); current_msgidx = curr_msg; - SetLastRead(thisuser->idx, curr_msg+1); // Set to greater then entire area. + SetLastRead(thisuser->idx, curr_msg+1); } /** @@ -599,7 +559,6 @@ void msg_read::IgnoreTheRest(ulong marea) */ int msg_read::DelCurMsg(ulong mbnum, ulong msgnum) { -// errlog2((char *)"DelCurMsg:"); char text[1024]= {0}; unsigned char ch; int lastReadIdx = 0; @@ -612,19 +571,14 @@ int msg_read::DelCurMsg(ulong mbnum, ulong msgnum) ch = getkey(true); putkey(ch); - if (toupper(ch) == 'Y') { if (mr.Pubpriv == PRIVATE) { // If Private let originating poster or receiver delete message. if ((strcmp((char *)thisuser->handle, mHead.from) == 0) || (strcmp((char *)thisuser->handle, mHead.to) == 0) || (isSysop == TRUE)) { - //continue; } else if (isSysop == TRUE) { - //continue; } else { - // Then user can't remove this message, add Security check - // later on for sysop / cosysop memset(&text,0,sizeof(text)); _lang.lang_get(text,21); pipe2ansi(text); @@ -633,8 +587,6 @@ int msg_read::DelCurMsg(ulong mbnum, ulong msgnum) } // Add check if real name or handle used here!! else if (strcmp((char *)thisuser->handle, mHead.from) != 0) { - // Then user can't remove this message, add Security check - // later on for sysop / cosysop memset(&text,0,sizeof(text)); _lang.lang_get(text,21); pipe2ansi(text); @@ -643,31 +595,14 @@ int msg_read::DelCurMsg(ulong mbnum, ulong msgnum) } else return FALSE; - - //std::stringstream ss; - //std::string str; - //ss << "msgnum: " << msgnum; - //str = ss.str(); - //errlog2((char *)str.c_str()); - BOOL res; res = jamapi_purgemsg(&mr, msgnum); if (res) { - //Failed -// errlog2((char *)"Failed to Purge Message"); return FALSE; } - // Reset Evenyone's Last Read Pointer if it's Greater Then message num = -1! users _usr; int iTotal = _usr.idx_count(); - - //int msg_total = msgidx_translation->size(); - - // Loop through and get currnet idx from Msg Number - // We're at / We just deleted. - // Reverse Lookup. - for (int j = msgidx_translation->size()-1; j >= 0; j--) { if (msgidx_translation->at(j) == msgnum) currReadIdx = j; @@ -675,7 +610,6 @@ int msg_read::DelCurMsg(ulong mbnum, ulong msgnum) // Should never get here. if (currReadIdx == -1) { -// errlog2((char *)"Error: Purge Message: currReadIdx == -1"); return FALSE; } @@ -685,21 +619,11 @@ int msg_read::DelCurMsg(ulong mbnum, ulong msgnum) // Only reset current person for private areas. if (mr.Pubpriv == PRIVATE) { - - // In a private area, we have a indivdual index, we need to first get current - // Index position of message deleted, then lower by one for current message. - // then reset the last read pointer by 1. if it's greater then message purged. - - // Get Last Read Pointer for Updating. lastReadIdx = GetLastRead(thisuser->idx); - - // Check Last Read if too high, we want to reset if (lastReadIdx > (signed)msgidx_translation->size()) lastReadIdx = msgidx_translation->size(); - // Last Read, > Deleted Message, decrement index to line back up - // with removed message if (lastReadIdx > currReadIdx+1) { // Don't allow Negative index's, Always start at 0 if (lastReadIdx <= 0) @@ -710,17 +634,12 @@ int msg_read::DelCurMsg(ulong mbnum, ulong msgnum) // This is a Public Area, Global Message Number(s) // Here we loop all Users and fix their lastRead. for (int iCnt = 0; iCnt != iTotal; iCnt++) { - // Get Last Read Pointer for Updating. lastReadIdx = GetLastRead(iCnt); - // Check Last Read if too high, we want to reset if (lastReadIdx > (signed)msgidx_translation->size()) lastReadIdx = msgidx_translation->size(); - // Last Read, > Deleted Message, decrement index to line back up - // with removed message if (lastReadIdx > currReadIdx+1) { - // Don't allow Negative index's, Always start at 0 if (lastReadIdx <= 0) lastReadIdx = 1; SetLastRead(iCnt, lastReadIdx-1); @@ -728,12 +647,9 @@ int msg_read::DelCurMsg(ulong mbnum, ulong msgnum) } } - // Reset current message in Reader/Title Scan now thisuser->lastmsg = msgidx_translation->at(currReadIdx); CURRENT_MSGTITLE = currReadIdx; - // Write History. - //hist_update(HIST_DELETES, thisuser); return TRUE; } @@ -744,9 +660,8 @@ int msg_read::NextAreaScan() { int total; - total = _msgf.msg_count(); // Counts total Message Areas + total = _msgf.msg_count(); - // Moe to next area to continue scan if((signed)thisuser->lastmbarea < (total-1)) { ++thisuser->lastmbarea; CURRENT_MAREA = thisuser->lastmbarea; @@ -767,26 +682,20 @@ int msg_read::verify_username(char *text, char *name) memset(&index,0,sizeof(UserIdx)); ulong usernum; - usernum = atoi(name); // Check if User Number was entered. + usernum = atoi(name); if (usernum != 0) { if (idx_read(&index,usernum-1)) { - //elog("User # found: %i, %s",usernum, index.handle); strcpy((char *)u.handle, (char *)index.handle); - - // Redisplay prompt pipe2ansi(text); - putline((char *)u.handle); // Also Ask to verify this is correct. + putline((char *)u.handle); return TRUE; } else { - //elog("User # NOT found: %i, %s",usernum, name); return FALSE; } } else if(idx_match(name)) { strcpy((char *)u.handle, name); - //elog("User Name found: %i, %s",usernum, name); return TRUE; } else { - //elog("User Name NOT found: %i, %s",usernum, name); return FALSE; } } @@ -803,7 +712,6 @@ int msg_read::read_usersig(std::string &sig) ins.open( usersig ); if (!ins.is_open()) { -// errlog((char *)"read_usersig(); None Exists."); return FALSE; } @@ -817,7 +725,6 @@ int msg_read::read_usersig(std::string &sig) } ins.close(); - // remove ending \r buff = buff.substr(0,buff.size()-1 ); return TRUE; } @@ -830,7 +737,6 @@ void msg_read::write_usersig(std::string &tmp) char usersig[1024]= {0}; sprintf(usersig,"%s%ld.sig",USRSIG, (ulong)thisuser->idx); - // Clear or Remove Sig and Return if Blank. if (tmp.size() == 0) { remove(usersig); return; @@ -842,7 +748,7 @@ void msg_read::write_usersig(std::string &tmp) return; } - ostr << tmp;// << '\r'; + ostr << tmp; ostr.close(); } @@ -856,12 +762,11 @@ int msg_read::SetupUserSig() std::string tmp; char text[1024]= {0}; - MsgHead mHLocal; // Message Header Infor to pass to FSE / Quoter. - msg_readll mLinkll; // Message Text; + MsgHead mHLocal; + msg_readll mLinkll; memset(&mHLocal,0,sizeof(MsgHead)); - // Check if Exists already in usersig folder. char usersig[1024]= {0}; sprintf(usersig,"%s%ld.sig", USRSIG, (ulong)thisuser->idx); @@ -880,7 +785,7 @@ int msg_read::SetupUserSig() while(!done) { ch = getkey(true); switch(toupper(ch)) { - case 10 : // ENTER + case 10 : done = TRUE; break; @@ -896,7 +801,7 @@ int msg_read::SetupUserSig() } buff.erase(); - msg_fse _msge(thisuser); // INIT FSE + msg_fse _msge(thisuser); strcpy(mHLocal.to,"all"); strcpy(mHLocal.from, (char *)thisuser->handle); @@ -909,7 +814,6 @@ int msg_read::SetupUserSig() strcpy(mHLocal.area,"Internal Editor"); if (exists == TRUE) { - // Send Original Message for Quoter to FSE. if(read_usersig(tmp) == TRUE) { mLinkll.PutBufferSig((char *)tmp.c_str()); } else @@ -921,14 +825,12 @@ int msg_read::SetupUserSig() save = _msge.poll_chr(FALSE, FALSE, &mHLocal); } - // Aborted. if (!save) { _lang.lang_get(text,35); pipe2ansi(text); return FALSE; } - // Get the Buffer back from FSE on Completed Message. tmp.erase(); tmp = _msge.buffer; @@ -955,7 +857,6 @@ void msg_read::get_address(XMSG *xm) xm->dest.point=0; *faddr='\0'; -// language(1113); inputfield(text,len); pipe2ansi((char *)"|CS|09Netmail |07- |15Insert Node Address below |11[|03xxx|15:|03xxx|15/|03xxx|11] |CR|08* "); pipe2ansi(text); @@ -985,7 +886,6 @@ void msg_read::get_address(XMSG *xm) */ void msg_read::DoPostEmail(int Reply) { -// struct tm *tm; time_t timet; char rep[51]= {0}, text[100]= {0}; char faddr[81]= {0}; @@ -997,11 +897,8 @@ void msg_read::DoPostEmail(int Reply) char subj[61] = {0}; UserIdx uidx; - - // Message Header Infor to pass to FSE / Quoter. MsgHead mHLocal; - // Get Current (Mesage Area) msgs _msgf; _msgf.read_mbaselist(&mr, thisuser->lastmbarea); @@ -1011,7 +908,6 @@ void msg_read::DoPostEmail(int Reply) xmsg.orig.point = mr.aka.point; time(&timet); -// tm = localtime(&timet); xmsg.date_written = *timeTToStamp(timet); xmsg.date_arrived = *timeTToStamp(timet); @@ -1029,14 +925,12 @@ void msg_read::DoPostEmail(int Reply) memset(&uidx,0,sizeof(UserIdx)); if (idx != EOF) idx_read(&uidx,idx); else { - return; // Aborted! + return; } } - // Display header. ansiPrintf((char *)"askemail"); - // Get TO: _lang.lang_get(text,47); int len = 20; inputfield(text,len); @@ -1045,7 +939,6 @@ void msg_read::DoPostEmail(int Reply) strcpy(to, (char *)uidx.handle); } pipe2ansi(to); - //getline(to,sizeof(to),to); // Get SUBJECT: _lang.lang_get(text,48); @@ -1056,7 +949,6 @@ void msg_read::DoPostEmail(int Reply) // Mesasge Reply, Data Alreadt in mHead for Current Message. if (Reply) { strcpy(subj,mHead.subj); - // Add Re: to First Replies Only! std::string sRe; if (subj != 0) { if (subj[0] != 'R' && subj[1] != 'e' && subj[2] != ':') { @@ -1089,23 +981,14 @@ void msg_read::DoPostEmail(int Reply) } *rep = '\0'; - /* - if (Reply) { - GetMsgID(rep); - strrepl(rep,50,"MSGID","REPLY"); - MakeCtrlHdr(rep); - } - else MakeCtrlHdr(rep);*/ - // Setup Mesasge Header Information - // To Pass to FSE / Message Quoter. strcpy(mHLocal.to,to); strcpy(mHLocal.from,from); strcpy(mHLocal.subj,subj); strcpy(mHLocal.area,(const char *)mr.mbdisplay); // If were in reply, send current Message text to FSE for Quoting! - msg_fse _msge(thisuser); // INIT + msg_fse _msge(thisuser); if (Reply) { // Send Original Message for Quoter and FSE. save = _msge.poll_chr(Reply, FALSE, &mHLocal, &mLink); @@ -1119,18 +1002,14 @@ void msg_read::DoPostEmail(int Reply) return; } -// errlog((char *)"1. Message Returned, check usersig."); - - // Get the Buffer back from FSE on Completed Message. - // cinfbuf = Control Header, MSGID and REPLYID etc.. buff = _msge.buffer; // Now append user signature. if exists if (read_usersig(tmp) == TRUE) { if (tmp.size() > 1) { - buff += "\r\r"; // Line Before Autosig. + buff += "\r\r"; buff += tmp; - buff += "\r"; // Line After Autosig. + buff += "\r"; } } @@ -1156,7 +1035,6 @@ void msg_read::DoPostEmail(int Reply) strcpy((char*)xmsg.to, mHLocal.to); strcpy((char*)xmsg.subj, mHLocal.subj); - SaveMsg(0,0,TRUE); _lang.lang_get(text,34); @@ -1170,9 +1048,7 @@ void msg_read::DoPostEmail(int Reply) */ void msg_read::DoPost(int mbnum, int Reply) { -// struct tm *tm; time_t timet; -// char rep[51]= {0}, char text[100]= {0}; int save; char faddr[81]= {0}; @@ -1184,7 +1060,6 @@ void msg_read::DoPost(int mbnum, int Reply) MsgHead mHLocal; - // Get Current (Mesage Area) msgs _msgf; _msgf.read_mbaselist(&mr, mbnum); @@ -1195,7 +1070,6 @@ void msg_read::DoPost(int mbnum, int Reply) xmsg.orig.point = mr.aka.point; time(&timet); -// tm = localtime(&timet); xmsg.date_written = *timeTToStamp(timet); xmsg.date_arrived = *timeTToStamp(timet); @@ -1213,16 +1087,6 @@ void msg_read::DoPost(int mbnum, int Reply) } } - /* // doing this in the api now.. mb_jam.api - *rep = '\0'; - if (Reply) { - GetMsgID(rep); - strrepl(rep,50,"MSGID","REPLY"); - MakeCtrlHdr(rep); - } - else MakeCtrlHdr(rep); - */ - // Get From: if ((mr.flags.mbrealname & 0x01) == 0) strcpy(from, (char *)thisuser->handle); @@ -1277,42 +1141,29 @@ void msg_read::DoPost(int mbnum, int Reply) buff.erase(); - // Setup Mesasge Header Information - // To Pass to FSE / Message Quoter. strcpy(mHLocal.to,to); strcpy(mHLocal.from,from); strcpy(mHLocal.subj,subj); strcpy(mHLocal.area,(const char *)mr.mbdisplay); // If were in reply, send current Message text to FSE for Quoting! - //elog ("just in message editor"); - msg_fse _msge(thisuser); // INIT + msg_fse _msge(thisuser); if (Reply) { - // Send Original Message for Quoter to FSE. + // Send Original Message to With Text Quoter to FSE. save = _msge.poll_chr(Reply, FALSE, &mHLocal, &mLink); -// errlog((char *)"** DoPost: After %i", save); } else { - // New Fresh message save = _msge.poll_chr(Reply, FALSE, &mHLocal); -// errlog((char *)"** DoPost: After %i", save); } -// errlog((char *)"** DoPost: After save"); -// errlog2((char *)"!save || == \"\" "); if (!save || _msge.buffer.size() == 0) { -// errlog((char *)"!save || == \"\" (TRUE)"); _lang.lang_get(text,35); pipe2ansi(text); - - // Clear Buffers. _msge.buffer.erase(); buff.erase(); return; } -// errlog((char *)"Read UserSig"); - // Get the Buffer back from FSE on Completed Message. // Add Control Header for MSGID and REPLYID, this was missed in rewrite!!! buff = _msge.buffer; @@ -1320,31 +1171,16 @@ void msg_read::DoPost(int mbnum, int Reply) // Process Sig if exists. if (read_usersig(tmp) == TRUE) { if (tmp.size() > 1) { - buff += "\r\r"; // Line Before Autosig. + buff += "\r\r"; buff += tmp; if (mr.Kind != LOCAL && mr.Kind != EMAIL) { } else - buff += "\r"; // Line After Autosig. - - /* - // We have echomail, add \r after sig For Orgin lines etc... - if (mr.Kind != LOCAL && mr.Kind != EMAIL) - { - tmp += "\r"; - buff += tmp; - }*/ + buff += "\r"; } } - -// if (mr.Kind != LOCAL && mr.Kind != EMAIL) -// errlog2((char *)"Echomail Test 1"); -// else -// errlog2((char *)"Echomail Test ERROR"); - - //Add System Tag && Origin Line if (mr.Kind != LOCAL && mr.Kind != EMAIL) { if (mr.aka.point != 0) { @@ -1355,13 +1191,6 @@ void msg_read::DoPost(int mbnum, int Reply) mr.aka.zone, mr.aka.net, mr.aka.node); } - -// errlog2((char *)"Echomail Test"); - ///errlog2((char *)BBSVERSION); - //errlog2((char *)OSSYSTEM); - //errlog2((char *)mr.origin_line); - //errlog2(faddr); - buff += "\r--- "; buff += BBSVERSION; buff += " "; @@ -1377,11 +1206,8 @@ void msg_read::DoPost(int mbnum, int Reply) strcpy((char*)xmsg.subj, mHLocal.subj); memset(&text,0,sizeof(text)); - -// errlog((char *)"** DoPost : (Save Message) - MI.cur_msg %lu",MI.cur_msg+1); SaveMsg(mbnum,MI.cur_msg+1,Reply); - //elog ("print saving"); _lang.lang_get(text,34); pipe2ansi(text); @@ -1410,9 +1236,7 @@ void msg_read::SetupMsgPost() */ void msg_read::DoEdit(int mbnum) { -// struct tm *tm; time_t timet; -// char rep[100] = {0}; char faddr[100] = {0}; char tag[100] = {0}; char origin[100] = {0}; @@ -1422,11 +1246,9 @@ void msg_read::DoEdit(int mbnum) unsigned char ch; - //OpenMsgArea(mbnum); if(!ReadMsgArea(mbnum)) { return; } -// CloseMsgArea(); xmsg.orig.zone = mr.aka.zone; xmsg.orig.net = mr.aka.net; @@ -1434,7 +1256,6 @@ void msg_read::DoEdit(int mbnum) xmsg.orig.point = mr.aka.point; time(&timet); -// tm = localtime(&timet); xmsg.date_written = *timeTToStamp(timet); xmsg.date_arrived = *timeTToStamp(timet); @@ -1442,16 +1263,10 @@ void msg_read::DoEdit(int mbnum) xmsg.attr |= MSGLOCAL; if(mr.Kind == NETMAIL) { - //get_address(&xmsg); Disable for Now xmsg.attr |= MSGPRIVATE; xmsg.attr |= MSGCRASH; } - /* - *rep = '\0'; - MakeCtrlHdr(rep); - */ - strcpy((char*)xmsg.from, mHead.from); strcpy((char*)xmsg.to, mHead.to); strcpy((char*)xmsg.subj, mHead.subj); @@ -1469,17 +1284,11 @@ void msg_read::DoEdit(int mbnum) sprintf(origin," * Origin: %s%s",mr.origin_line,faddr); } - buff.erase(); - mLink.cleartags(tag,origin); mLink.line_total(); - - // putline ("\nout!!!"); msg_fse _msge(thisuser); - // NEWMSG -// save = _msge.poll_chr(FALSE, TRUE, &mHead, &mLink); if (!save) { _lang.lang_get(text,35); pipe2ansi(text); @@ -1498,31 +1307,14 @@ void msg_read::DoEdit(int mbnum) } } - // Save New Message, then Kill Original, Overwrite Doesn't Work! buff = _msge.buffer; buff += "\r"; buff += tag; buff += "\r"; buff += origin; -// NEWMSG -// Dont' save message untill we rewrite deleteing the original. - // SaveMsg(mbnum,thisuser->lastmsg,TRUE); - - /* - //OpenMsgArea(mbnum); - if(!OpenMsgArea(mbnum)){ - return; - } - // NEWMSG - // MsgKillMsg(AHandle,thisuser->lastmsg); - CloseMsgArea(); - */ - _lang.lang_get(text,34); pipe2ansi(text); - - // Setup loging defaults, set users loging date time etc.. hist_update(HIST_EDITS,thisuser); } @@ -1545,9 +1337,6 @@ void msg_read::EditMessage() if (toupper(ch) == 'Y') { if (strcmp((char *)thisuser->handle,mHead.from) > 0 && strcmp((char *)thisuser->name,mHead.from) > 0) { - // User Didn't Write Original Message... - // Then user can't edit this message, add Security check - // later on for sysop / cosysop Access to users messages. memset(&text,0,sizeof(text)); _lang.lang_get(text,32); pipe2ansi(text); @@ -1559,19 +1348,15 @@ void msg_read::EditMessage() DoEdit(thisuser->lastmbarea); } - - /** * Message Reader - Title Scan Message Reader and NewScan * Handles both Public and Private Areas. */ long msg_read::title_scan(int newmsg, int multiscan, char *mString) { + unsigned long prevarea = thisuser->lastmbarea; - // Keep original Area before doing any processing. - unsigned long prevarea = thisuser->lastmbarea; - - long prevmsgcount = -1; // Check Mesasge Count has changed to reload + long prevmsgcount = -1; unsigned long msgcount = 0; // Count of Messages unsigned long newmsgcount = 0; // Count New Messages unsigned long lastread = 0; // Users Last Read @@ -1583,23 +1368,11 @@ long msg_read::title_scan(int newmsg, int multiscan, char *mString) int read_return = 0; // Hold Return Code from Reader / RET = TitleScan CURRENT_MSGTITLE = 0; // Reset Message Title to Begining for start. - - // Check if Overide on Area to Read/Scan, ie System Announcements, Email.. - // Passed from a Menu Command. - - //std::ostringstream oconvert; // Out std::stringstream iconvert(mString); // In int i = 0; - // Convert String to Int if (iconvert >> i) -// if (atoi(mString) != 0 && multiscan == FALSE) { - // Setup Current Message Area - // This is 0 Based, make sure you translaste 1 -> 0. - - //pipe2ansi((char *)"|CR|15force area |CR|PA"); - //thisuser->lastmbarea = atoi(mString); if (!multiscan) { thisuser->lastmbarea = i; CURRENT_MAREA = thisuser->lastmbarea; @@ -1613,22 +1386,10 @@ long msg_read::title_scan(int newmsg, int multiscan, char *mString) char szReplace[20] = {0}; std::string::size_type id1; - // Used for Purge a message in titlescan - //users _usr; - //int iTotal = 0; - //int cMesg = 0; - - // Title Scan Class, Dynamic Allocation for quick and clean refreshes - // On the fly for different areas. msg_title *_tlist; - - unsigned long current_msg = 0; // For Inter Loop When reading from Title Scan. - - - // List that will hold all message for passing to title scan class. + unsigned long current_msg = 0; vector < unsigned long > elist; current_msg = 0; - //ulong total_emails; int first_titlescan = TRUE; int ret = 0; @@ -1641,40 +1402,13 @@ long msg_read::title_scan(int newmsg, int multiscan, char *mString) } std::string tmp1; - - // Display Scanning Message Screen,. ansiPrintf ((char *)"mscan"); if (multiscan) pipe2ansi((char *)"|CR|09Starting Global Message NewScan ...|CR |DE"); - // Message Pre-Scan Loop. while(1) { - /* TESTING GLOBAL NEWSCAN - convert << CURRENT_MAREA; - tmp1 = convert.str(); - convert.str( std::string() ); - convert.clear(); - - pipe2ansi ((char *)"|CS CURRENT_MAREA: "); - pipe2ansi ((char *)tmp1.c_str()); - tmp1.erase(); - - convert << thisuser->lastmbarea; - tmp1 = convert.str(); - convert.str( std::string() ); - convert.clear(); - - pipe2ansi ((char *)"|CR thisuser->lastmbarea: "); - pipe2ansi ((char *)tmp1.c_str()); - - tmp1.erase(); - pipe2ansi((char *)"|CR|PA"); - */ - memset(&mr,0,sizeof(mb_list_rec)); - - // Read in current area info/flags _msgf.read_mbaselist(&mr, thisuser->lastmbarea); // Set if this is a Public/Private Message Area @@ -1688,48 +1422,23 @@ long msg_read::title_scan(int newmsg, int multiscan, char *mString) lastread = GetLastRead(thisuser->idx); } - // Get Total Number of Messages msgcount = CountMsgs(thisuser->lastmbarea, thisuser); - - // Count how many NEW unread messages newmsgcount = CountNewMsgs(thisuser->lastmbarea, thisuser); - // Don't re-read the area unless title scan is reset or message count changes. - // Also so we don't reload each time we exit from msg read back to title scan if (first_titlescan || prevmsgcount < (signed)msgcount) { - // Set the Prev Mesage Count. prevmsgcount = msgcount; - - // Clear and Start Fresh List with Updates. - // On first Run only, other runs keep elist static until exit - // from this current message area. - if (elist.size() > 0) //&& prevmsgcount == -1) - vector < unsigned long >() . swap(elist); // Clear Vector. + if (elist.size() > 0) + vector < unsigned long >() . swap(elist); current_msg = 0; - - // Build the message listings to pass to Title Scan Class - // Reads jam areas and grabs all messages into vector translation array - // Public areas are 1 -> 1, Emails can have offset 1,3,5 -> 1 - // We keep the illusion by using array index as message number. - AnsiString.erase(); - - /************** - * - * Move these Strings to the Language file!! - * - */ - if (newmsg) AnsiString.append("|CR|15|M#|07. |03|MA |15- |09Scanning |13|NM |09new out of |11|HM |09messages."); else AnsiString.append("|CR|15|M#|07. |03|MA |15- |09Scanning |11|HM |09total messages."); - - // If we have more then 1 new message, then display loading. if (newmsg && newmsgcount > 0) AnsiString.append("|CR|CR|15Loading Messages... |031 Moment|15. |DE"); @@ -1738,16 +1447,12 @@ long msg_read::title_scan(int newmsg, int multiscan, char *mString) if (!newmsg && msgcount > 0) AnsiString.append("|CR|CR|15Loading Messages... |031 Moment|15. |DE"); - // Parse Local MCI Codes from String. sprintf(outbuff,"%lu", msgcount); ParseLocalMCI(AnsiString, "|HM", outbuff); - sprintf(outbuff,"%lu", newmsgcount); ParseLocalMCI(AnsiString, "|NM", outbuff); - pipe2ansi ((char *)AnsiString.c_str()); - // If no Message in area then check if multiscan // to Skip to Next Area or exit. if (msgcount == 0) { @@ -1763,25 +1468,21 @@ long msg_read::title_scan(int newmsg, int multiscan, char *mString) AnsiString.append("|CS|CR|15NewScan Completed |07... |DE |CR|PA"); pipe2ansi ((char *)AnsiString.c_str()); - vector < unsigned long >() . swap(elist); // Clear Vector. - -// errlog2((char *)"NextAreaScan FALSE!"); - - // Before exiting system, go back to original area! + vector < unsigned long >() . swap(elist); thisuser->lastmbarea = prevarea; CURRENT_MAREA = thisuser->lastmbarea; - if (elist.size() > 0) //&& prevmsgcount == -1) - vector < unsigned long >() . swap(elist); // Clear Vector. + if (elist.size() > 0) + vector < unsigned long >() . swap(elist); return 0; } - //pipe2ansi((char *)"|DE "); + first_titlescan = TRUE; prevmsgcount = -1; continue; } // Else were done. - if (elist.size() > 0) //&& prevmsgcount == -1) - vector < unsigned long >() . swap(elist); // Clear Vector. + if (elist.size() > 0) + vector < unsigned long >() . swap(elist); pipe2ansi((char *)"|PA "); return FALSE; } @@ -1794,72 +1495,47 @@ long msg_read::title_scan(int newmsg, int multiscan, char *mString) else pipe2ansi((char *)"|CR|CR|07Sorry: |15No New messages found at this time.|CR|CR"); - // Goto Next Area or Exit. if (multiscan) { if (NextAreaScan() == FALSE) { AnsiString.erase(); AnsiString.append("|CR|CR|15NewScan Completed |07... |DE |CR|PA"); pipe2ansi ((char *)AnsiString.c_str()); - - vector < unsigned long >() . swap(elist); // Clear Vector. - - // errlog2((char *)"NextAreaScan FALSE!"); + vector < unsigned long >() . swap(elist); // Before exiting system, go back to original area! thisuser->lastmbarea = prevarea; CURRENT_MAREA = thisuser->lastmbarea; - if (elist.size() > 0) //&& prevmsgcount == -1) - vector < unsigned long >() . swap(elist); // Clear Vector. + if (elist.size() > 0) + vector < unsigned long >() . swap(elist); return 0; } - //pipe2ansi((char *)"|DE "); + first_titlescan = TRUE; prevmsgcount = -1; - if (elist.size() > 0) //&& prevmsgcount == -1) - vector < unsigned long >() . swap(elist); // Clear Vector. + if (elist.size() > 0) + vector < unsigned long >() . swap(elist); continue; } else { - if (elist.size() > 0) //&& prevmsgcount == -1) - vector < unsigned long >() . swap(elist); // Clear Vector. + if (elist.size() > 0) + vector < unsigned long >() . swap(elist); pipe2ansi((char *)"|PA "); return FALSE; } } - if (elist.size() > 0) //&& prevmsgcount == -1) - vector < unsigned long >() . swap(elist); // Clear Vector. - + if (elist.size() > 0) + vector < unsigned long >() . swap(elist); - // TESTING GLOBAL NEWSCAN - //pipe2ansi ((char*)"|CR|CRReload elist |CR|PA"); - - // Loads Entire Area into Vector List for quick reading. - // This might need to be redone lateron for currnet page. if (private_area) { elist = jamapi_build_private(&mr, thisuser); } else { elist = jamapi_build_public(&mr, thisuser); } - - // TESTING GLOBAL NEWSCAN - /* - convert << elist.size(); - tmp1 = convert.str(); - convert.str( std::string() ); - convert.clear(); - - pipe2ansi ((char *)"|CS |15elist.size(): "); - pipe2ansi ((char *)tmp1.c_str()); - tmp1.erase(); - pipe2ansi ((char *)"|CR|PA"); - */ - if ((newmsgcount > 0) || (msgcount > 0)) pipe2ansi ((char *)"|CR|CR|15Loading Messages... |03Completed|15. |DE"); - // Setup Initial Starting Position in Title Scan // If NewScan start at Users LastRead Pointer. // Otherwise start at the first message in the array / list. @@ -1868,115 +1544,83 @@ long msg_read::title_scan(int newmsg, int multiscan, char *mString) if (newmsg) { // Check if LastRead is past the end, means no new messages. if (lastread < elist.size()) { - //errlog2((char *)" #### lastread: %lu, %lu ", lastread, elist.size()); - current_msg = elist[lastread]; thisuser->lastmsg = current_msg; CURRENT_MSGTITLE = lastread; } else { - // Last Read is greater then message area bounds. - // No new messages left to read. - if (multiscan) { } else pipe2ansi((char *)"|CR|CR|07Sorry: |15No new messages found at this time.|CR|CR"); - vector < unsigned long >() . swap(elist); // Clear Vector. - - // Goto next area or exit. + vector < unsigned long >() . swap(elist); if (multiscan) { if (NextAreaScan() == FALSE) { AnsiString.erase(); AnsiString.append("|CR|CR|15NewScan Completed |07... |CR|PA"); pipe2ansi ((char *)AnsiString.c_str()); - - vector < unsigned long >() . swap(elist); // Clear Vector. - - // errlog2((char *)"NextAreaScan FALSE!"); - - // Before exiting system, go back to original area! + vector < unsigned long >() . swap(elist); thisuser->lastmbarea = prevarea; CURRENT_MAREA = thisuser->lastmbarea; - if (elist.size() > 0) //&& prevmsgcount == -1) - vector < unsigned long >() . swap(elist); // Clear Vector. + if (elist.size() > 0) + vector < unsigned long >() . swap(elist); return 0; } // Jump to next area first_titlescan = TRUE; - //pipe2ansi((char *)"|DE "); prevmsgcount = -1; - if (elist.size() > 0) //&& prevmsgcount == -1) - vector < unsigned long >() . swap(elist); // Clear Vector. + if (elist.size() > 0) + vector < unsigned long >() . swap(elist); continue; } else { - if (elist.size() > 0) //&& prevmsgcount == -1) - vector < unsigned long >() . swap(elist); // Clear Vector. + if (elist.size() > 0) + vector < unsigned long >() . swap(elist); pipe2ansi((char *)"|PA "); return 0; } } } else { - // Reading Normal Scan, Start at first Message - // Set Starting Message / Light to First Message. current_msg = elist[0]; - thisuser->lastmsg = current_msg; // Set First Message - - // Title Scan message, should be lightbarm or elist Position - // Fix this!! - CURRENT_MSGTITLE = 0; // Set First Message + thisuser->lastmsg = current_msg; + CURRENT_MSGTITLE = 0; } } } - // Setup Message Title Scan Class, for Selecting Message to Read/Scan _tlist = new msg_title; _tlist->SetupList(thisuser, private_area); // Reset Thisuser in title clas ret = _tlist->StartTitleList(newmsg, thisuser->lastmbarea, elist, CURRENT_MSGTITLE); - - // Need to keep track of this CURRENT_MSGTITLE = _tlist->CURRENT_BAR; delete _tlist; - // Done Scanning Exit! if (ret == EOF) { - // Quit Hit, If in GLobal NewScan check for next area contiue or exit. - // Goto Next Area or Exit. if (multiscan) { - - // Add to language file. - ansiPrintf ((char *)"mscan"); // Display Ansi Header First + ansiPrintf ((char *)"mscan"); pipe2ansi((char *)"|CR|09Global Message NewScan|CR|CR|15|M#|07. |03|MA |15- |09Scanning Exited."); pipe2ansi((char *)"|CR|CR|15Use: |CR|15[|11ENTER|15] |07Continue to Next Area, or |15[|11Q|15] |07to Quit Global NewScan|08: |07"); while (1) { ch = getkey(true); if ((int)ch == 10) { // ENTER - - // If ENTER, Continue to Scan next area. if (NextAreaScan() == FALSE) { AnsiString.erase(); AnsiString.append("|CR|CR|15NewScan Completed |07... |DE |CR|PA"); pipe2ansi ((char *)AnsiString.c_str()); - - vector < unsigned long >() . swap(elist); // Clear Vector. - - // Before exiting system, go back to original area! + vector < unsigned long >() . swap(elist); thisuser->lastmbarea = prevarea; CURRENT_MAREA = thisuser->lastmbarea; - if (elist.size() > 0) //&& prevmsgcount == -1) - vector < unsigned long >() . swap(elist); // Clear Vector. + if (elist.size() > 0) + vector < unsigned long >() . swap(elist); return 0; } - // Continue to Next Area Scan first_titlescan = TRUE; prevmsgcount = -1; - if (elist.size() > 0) //&& prevmsgcount == -1) - vector < unsigned long >() . swap(elist); // Clear Vector. + if (elist.size() > 0) + vector < unsigned long >() . swap(elist); break; } // If Q, Then exit Scan and return to menu. @@ -1986,8 +1630,8 @@ long msg_read::title_scan(int newmsg, int multiscan, char *mString) AnsiString.append("|CR|CR|15Exiting Title Scan |07... |DE"); pipe2ansi ((char *)AnsiString.c_str()); - if (elist.size() > 0) //&& prevmsgcount == -1) - vector < unsigned long >() . swap(elist); // Clear Vector. + if (elist.size() > 0) + vector < unsigned long >() . swap(elist); return 0; } } @@ -2004,8 +1648,8 @@ long msg_read::title_scan(int newmsg, int multiscan, char *mString) AnsiString.append("|CR|CR|15Exiting Title Scan |07... |DE"); pipe2ansi ((char *)AnsiString.c_str()); - if (elist.size() > 0) //&& prevmsgcount == -1) - vector < unsigned long >() . swap(elist); // Clear Vector. + if (elist.size() > 0) + vector < unsigned long >() . swap(elist); return 0; } // Continue to next area in newscan @@ -2020,23 +1664,19 @@ long msg_read::title_scan(int newmsg, int multiscan, char *mString) AnsiString.append("|CS|CR|15NewScan Completed |07... |CR|PA"); pipe2ansi ((char *)AnsiString.c_str()); - vector < unsigned long >() . swap(elist); // Clear Vector. - -// errlog2((char *)"NextAreaScan FALSE!"); - - // Before exiting system, go back to original area! + vector < unsigned long >() . swap(elist); thisuser->lastmbarea = prevarea; CURRENT_MAREA = thisuser->lastmbarea; - if (elist.size() > 0) //&& prevmsgcount == -1) - vector < unsigned long >() . swap(elist); // Clear Vector. + if (elist.size() > 0) + vector < unsigned long >() . swap(elist); return 0; } // Jump to next area first_titlescan = TRUE; prevmsgcount = -1; - if (elist.size() > 0) //&& prevmsgcount == -1) - vector < unsigned long >() . swap(elist); // Clear Vector. + if (elist.size() > 0) + vector < unsigned long >() . swap(elist); continue; } @@ -2059,29 +1699,24 @@ long msg_read::title_scan(int newmsg, int multiscan, char *mString) pipe2ansi((char *)"|CR|CR|15Skipping to Next Area |07... |DE"); // Received Jump to Next Area if (NextAreaScan() == FALSE) { - - // No area's left in scan, so exit. AnsiString.erase(); AnsiString.append("|CR|CR|15NewScan Completed |07... |CR|PA"); pipe2ansi ((char *)AnsiString.c_str()); - - vector < unsigned long >() . swap(elist); // Clear Vector. - - //errlog2((char *)"NextAreaScan FALSE!"); + vector < unsigned long >() . swap(elist); // Before exiting system, go back to original area! thisuser->lastmbarea = prevarea; CURRENT_MAREA = thisuser->lastmbarea; - if (elist.size() > 0) //&& prevmsgcount == -1) - vector < unsigned long >() . swap(elist); // Clear Vector. + if (elist.size() > 0) + vector < unsigned long >() . swap(elist); return 0; } // Jump to next area first_titlescan = TRUE; prevmsgcount = -1; - if (elist.size() > 0) //&& prevmsgcount == -1) - vector < unsigned long >() . swap(elist); // Clear Vector. + if (elist.size() > 0) + vector < unsigned long >() . swap(elist); continue; } continue; @@ -2094,7 +1729,7 @@ long msg_read::title_scan(int newmsg, int multiscan, char *mString) current_msg = elist.size()-1; thisuser->lastmsg = elist.at( elist.size()-1 ); CURRENT_MSGTITLE = current_msg; - SetLastRead(thisuser->idx, current_msg+1); // Set to greater then entire area. + SetLastRead(thisuser->idx, current_msg+1); pipe2ansi((char *)"|CR|CR|07FYI: |15Remaining messages ignored, marked as |03read|15.|CR|CR|PA"); @@ -2106,29 +1741,24 @@ long msg_read::title_scan(int newmsg, int multiscan, char *mString) pipe2ansi((char *)"|CR|CR|15Jumping to Next Area |07... |DE"); // Received Jump to Next Area if (NextAreaScan() == FALSE) { - - // No area's left in scan, so exit. AnsiString.erase(); AnsiString.append("|CR|CR|15NewScan Completed |07... |CR|PA"); pipe2ansi ((char *)AnsiString.c_str()); - - vector < unsigned long >() . swap(elist); // Clear Vector. - -// errlog2((char *)"NextAreaScan FALSE!"); - + vector < unsigned long >() . swap(elist); + // Before exiting system, go back to original area! thisuser->lastmbarea = prevarea; CURRENT_MAREA = thisuser->lastmbarea; - if (elist.size() > 0) //&& prevmsgcount == -1) - vector < unsigned long >() . swap(elist); // Clear Vector. + if (elist.size() > 0) + vector < unsigned long >() . swap(elist); return 0; } // Jump to next area first_titlescan = TRUE; prevmsgcount = -1; - if (elist.size() > 0) //&& prevmsgcount == -1) - vector < unsigned long >() . swap(elist); // Clear Vector. + if (elist.size() > 0) + vector < unsigned long >() . swap(elist); continue; } continue; @@ -2136,50 +1766,39 @@ long msg_read::title_scan(int newmsg, int multiscan, char *mString) case 'K': // Kill / Delete Message // Readin, then Test if User has Access to Remove Message. - -// errlog2((char *)"Kill / Delete Message"); ReadInMsgOnly(CURRENT_MAREA); // Build Index to Pass for Delete Function msgidx_translation = new vector; for (int j = 0; j < (signed)elist.size(); j++) { - // Class Global, so Readers have access to this!! - // Set message ordering for reader to parse - // correct message number msgidx_translation->push_back(elist.at(j)); } if(DelCurMsg(thisuser->lastmbarea, thisuser->lastmsg)) { pipe2ansi((char *)"|CR|CR|07FYI: |15Current Message has been deleted.|CR|CR|PA"); - //first_titlescan = TRUE; prevmsgcount = -1; - if (elist.size() > 0) //&& prevmsgcount == -1) - vector < unsigned long >() . swap(elist); // Clear Vector. + if (elist.size() > 0) + vector < unsigned long >() . swap(elist); } delete msgidx_translation; - mLink.Lines = 0; mLink.dispose(); continue; - case 'E': // Edit Message pipe2ansi((char *)"|CR|CR|07FYI: |15WIP - Not yet Implimented.|CR|CR|PA"); continue; - case 'H': // Set Pointer memset(&outbuff,0,sizeof(outbuff)); - SetLastRead(thisuser->idx, CURRENT_MSGTITLE+1); _lang.lang_get(outbuff,37); AnsiString = outbuff; id1 = AnsiString.find("|M#",0); if (id1 != std::string::npos) { - // 0 Based, att once when showing current message. sprintf(szReplace,"%d", CURRENT_MSGTITLE+1); AnsiString.replace(id1,3,szReplace); } @@ -2187,9 +1806,6 @@ long msg_read::title_scan(int newmsg, int multiscan, char *mString) continue; case 'P': // Post a New Message - // Translater current message - //DoPost(CURRENT_MAREA, FALSE); - if (mr.Pubpriv == PRIVATE) { DoPostEmail(FALSE); } else { @@ -2197,11 +1813,9 @@ long msg_read::title_scan(int newmsg, int multiscan, char *mString) } pipe2ansi((char *)"|CS"); - // Reset and Rescan Current Area - //first_titlescan = TRUE; prevmsgcount = -1; - if (elist.size() > 0) //&& prevmsgcount == -1) - vector < unsigned long >() . swap(elist); // Clear Vector. + if (elist.size() > 0) + vector < unsigned long >() . swap(elist); mLink.Lines = 0; mLink.dispose(); @@ -2217,16 +1831,12 @@ long msg_read::title_scan(int newmsg, int multiscan, char *mString) } pipe2ansi((char *)"|CS"); - // Reset and Rescan Current Area - //first_titlescan = TRUE; prevmsgcount = -1; - if (elist.size() > 0) //&& prevmsgcount == -1) - vector < unsigned long >() . swap(elist); // Clear Vector. + if (elist.size() > 0) + vector < unsigned long >() . swap(elist); - // Clear Message That was read in. mLink.Lines = 0; mLink.dispose(); - continue; default: @@ -2234,33 +1844,23 @@ long msg_read::title_scan(int newmsg, int multiscan, char *mString) } } - // Then we have area from title scan if (ret == -3) ret = CURRENT_MSGTITLE; else continue; - // Translate from Title Scan # to Real Message Number for Readin - // Now universal! - - //CURRENT_MSGTITLE = ret; // Keep Currnet Index of Vector. - current_msg = elist[ret]; // Assign Real Message From Index of Vector. + current_msg = elist[ret]; // After reading current message, jump to next message. thisuser->lastmsg = current_msg; - // Make Copy of elist into Private list // For Use in Class for Reader! msgidx_translation = new vector; for (int j = 0; j < (signed)elist.size(); j++) { - // Class Global, so Readers have access to this!! - // Set message ordering for reader to parse - // correct message number msgidx_translation->push_back(elist.at(j)); } - // Start Message Reader with messed Returned from Title Scan! read_return = StartReader(newmsg, ret); @@ -2273,29 +1873,24 @@ long msg_read::title_scan(int newmsg, int multiscan, char *mString) pipe2ansi((char *)"|CS|CR|15Jumping to Next Area |07... |DE"); // Received Jump to Next Area if (NextAreaScan() == FALSE) { - - // No area's left in scan, so exit. AnsiString.erase(); AnsiString.append("|CS|CR|15NewScan Completed |07... |CR|PA"); pipe2ansi ((char *)AnsiString.c_str()); - - vector < unsigned long >() . swap(elist); // Clear Vector. - - //errlog2((char *)"NextAreaScan FALSE!"); + vector < unsigned long >() . swap(elist); // Before exiting system, go back to original area! thisuser->lastmbarea = prevarea; CURRENT_MAREA = thisuser->lastmbarea; - if (elist.size() > 0) //&& prevmsgcount == -1) - vector < unsigned long >() . swap(elist); // Clear Vector. + if (elist.size() > 0) + vector < unsigned long >() . swap(elist); return 0; } // Jump to next area first_titlescan = TRUE; prevmsgcount = -1; - if (elist.size() > 0) //&& prevmsgcount == -1) - vector < unsigned long >() . swap(elist); // Clear Vector. + if (elist.size() > 0) + vector < unsigned long >() . swap(elist); continue; } @@ -2303,26 +1898,11 @@ long msg_read::title_scan(int newmsg, int multiscan, char *mString) if(read_return == -3) { prevmsgcount = -1; delete msgidx_translation; - if (elist.size() > 0) //&& prevmsgcount == -1) - vector < unsigned long >() . swap(elist); // Clear Vector. + if (elist.size() > 0) + vector < unsigned long >() . swap(elist); continue; - } - - /* - if (msgidx_translation->size() == elist.size()) - { - // Clear Message Listing Array,. - // And continue normal - delete msgidx_translation; - }*/ - else { - // msgidx_translation is < elist.size() from pop_back(). - - // Skip Incriments, and refresh loop, stay at current message - // Since we decremented to previous message from mesg purged. - - // Comes here when we purge a message, now we need to refresh the - // title list before we continue. + } + else { delete msgidx_translation; AnsiString.erase(); @@ -2332,12 +1912,6 @@ long msg_read::title_scan(int newmsg, int multiscan, char *mString) continue; } - - // Test if were past the last message in the current area, if we are - // Reset the message to the last message, If were in a newscan, then - // State that were at the last message and ask to move to next area - - // Make sure Message isn't past the end of translation array if (CURRENT_MSGTITLE+1 >= (signed)elist.size()) { CURRENT_MSGTITLE = elist.size()-2; @@ -2374,9 +1948,6 @@ long msg_read::title_scan(int newmsg, int multiscan, char *mString) */ int msg_read::StartReader(int newmsg, ulong msgidx) { - - //errlog2((char*)"Starting Message Reader"); - std::string AnsiString; char mString[1024] = {0}; char szReplace[100] = {0}; @@ -2403,24 +1974,15 @@ int msg_read::StartReader(int newmsg, ulong msgidx) int aCoordX; int bCoordX; - // Startup Message Reader Link List for Holding Message Lines mLink.initReader(sTEXT_COLOR, sQUOTE_COLOR, sSYS_COLOR, sORIGIN_COLOR); mLink.Top = tTop; mLink.Bot = tBot; - - // Setup Univeral User Message Index - // Passed from title scan. current_msgidx = msgidx; - - opscan = FALSE; - // History Stats. Views = 0; - - // errlog((char *)"SCAN/READ - 1st. Get # of messages in current area for Scan "); if(!ReadMsgArea(thisuser->lastmbarea)) { MI.high_msg = 0; MI.high_water = 0; @@ -2428,13 +1990,10 @@ int msg_read::StartReader(int newmsg, ulong msgidx) } sprintf(szReplace,"%lu",MI.high_msg); - - // Clear Header for fresh run. memset(&mHead,0, sizeof(MsgHead)); // Check if were doing a New Scan, or user is selecting starting # if (newmsg == TRUE) { - // Starting Current or Multi NewScan firstscan = TRUE; _lang.lang_get(text,23); AnsiString = text; @@ -2446,44 +2005,11 @@ int msg_read::StartReader(int newmsg, ulong msgidx) _lang.lang_get(text,36); AnsiString = text; pipe2ansi((char*)AnsiString.c_str()); - // return FALSE; } } - - /* - else { // Start scanning from message # user selects - firstscan = FALSE; - _lang.lang_get(text,24); - AnsiString = text; - - // No Messages Found in this Area. - if (MI.high_msg < 1) { - _lang.lang_get(text,44); - AnsiString = text; - pipe2ansi((char*)AnsiString.c_str()); - return FALSE; - } - - id1 = AnsiString.find("|HM",0); - if (id1 != -1) { - szTmp[0] = AnsiString[id1+1]; - szTmp[1] = AnsiString[id1+2]; - AnsiString.replace(id1,3,szReplace); - } - - len = strlen(szReplace)+1; // len = 3; - sprintf(choice,"%s",(char *)AnsiString.c_str()); - inputfield(choice,len); - pipe2ansi(choice); - - getline(choice,len); - thisuser->lastmsg = atoi(choice); - if (thisuser->lastmsg == 0) thisuser->lastmsg = 1; - }*/ - + // Run through Main Reader Loop until exit from user while (done == FALSE) { - memset(&mHead,0, sizeof(MsgHead)); same = TRUE; @@ -2497,13 +2023,11 @@ int msg_read::StartReader(int newmsg, ulong msgidx) cont = ReadMessages(thisuser->lastmbarea); } - // Done in Current Area, Flip to Next Area in Scan or Exit. // NOTE Next ARea done in title scan! if (cont == FALSE || thisuser->lastmsg > MI.high_msg || current_msgidx >= msgidx_translation->size() ) { - // Display End of NewScan. _msgf.read_mbaselist(&mr, thisuser->lastmbarea); _lang.lang_get(text,36); AnsiString = text; @@ -2516,45 +2040,25 @@ int msg_read::StartReader(int newmsg, ulong msgidx) break; } - //errlog2((char *)"SCAN/READ Mesasge 3.2 before init reader."); - - /// Start Message Reader Loop -------------------------------------- >>>>>>> - // Reset Message Handler if Area was Not Closed. - - // Make sure Screen is Cleared before starting to read - // Helps with Homecursor optimizations. if (firstread == TRUE) { firstread = FALSE; pipe2ansi((char *)"|CS"); } - //errlog2((char *)"SCAN/READ Mesasge 4 before init reader."); - - /// Here is the Full Screen Reader + // Here is the Full Screen Reader if (sVIEW[0] != 'S') { - // Start the entry, display of the Message inside the reader. - ansi_file(sANSI_FILE); // Display Reader Ansi - - //errlog2((char *)"box_start reader!"); + ansi_file(sANSI_FILE); mLink.box_start(thisuser->lastmbarea); } else { - /// Here is the Old School Scrolling Reader. - // figure out text range by subtracting size of message header. ansi_file(sANSI_FILE); - - // Grab from ini file. aCoordX = iTop; bCoordX = 24; pipe2ansi((char *)"|CR"); - // Get the size of the Mesage Header mLink.headerrows = aCoordX - bCoordX; ++mLink.headerrows; - - //pipe2ansi(" mLink.box_scroll_reader(); "); - //errlog2((char *)"box_scroll_reader!"); - mLink.box_scroll_reader(); /// locking up in here.. mlink + mLink.box_scroll_reader(); } // Now loop Though and Parse Extras then Start Menu Input System. @@ -2562,24 +2066,17 @@ int msg_read::StartReader(int newmsg, ulong msgidx) _output.erase(); more = FALSE; showmore = FALSE; - - // If theme changes, reset the top and bottom mLink.Top = tTop; mLink.Bot = tBot; /// full screen message reader if (sVIEW[0] != 'S') { - // Pre-Clear to leave no shadow effect. more = FALSE; showmore = FALSE; - sprintf(outBuffer,"%s%s",sMOREMSG_OFF,sMOREMSG_WORD_OFF); pipe2ansi(outBuffer); - //if (mLink.line_count() > 0) more = true; if (mLink.Page < mLink.TotPages) more = TRUE; - - // If There is only one page, we don't need to dispaly the More... if (mLink.Page == mLink.TotPages && mLink.Page != 1) { // Were on the Very Last Page of the Message sprintf(outBuffer,"%s%s",sMOREMSG_OFF,sMOREMSG_WORD_OFF); @@ -2624,20 +2121,14 @@ int msg_read::StartReader(int newmsg, ulong msgidx) _output += outBuffer; } - // Show Current/Total Pages Per Message! // Usually noit going over 99 pages,, so 2d here is good. sprintf(outBuffer,"%s%.2d",sPAGENUM,mLink.Page); _output += outBuffer; sprintf(outBuffer,"%s%.2d",sPAGETOTAL,mLink.TotPages); _output += outBuffer; - //------------------------------------------------------- pipe2ansi((char *)_output.c_str()); - // If more, Select Menu Prompt with PGDN as Default - // Otherwise Select Prompt with Next as Default! - - // Make Msgp2 Prompt Optional, Use if exists! // Also Let user Toggle on / off if (_mnuf.cmdexist(sMENU_PROMPT2,0)) { @@ -2654,24 +2145,15 @@ int msg_read::StartReader(int newmsg, ulong msgidx) } } else { - /// scrolling message menu system - //if (sVIEW[0] == 'S') { - _mnuf._premenu.clear(); // Reload Menu for Proper Lightbar PlaceMent! - //_mnuf._premenu = _mnuf._curmenu; + _mnuf._premenu.clear(); _mnuf._curmenu.clear(); _mnuf._curmenu = sMENU_PROMPT; - // Calculate Messages #'s by translation index - // This handles both offsets of normal and private message areas. _mnuf.TotMsgs = msgidx_translation->size(); _mnuf.CurMsgs = current_msgidx+1; _mnuf.MsgsLeft = _mnuf.TotMsgs - _mnuf.CurMsgs; - - /// End of. } - // Parse MEssage Reader Prompt, then get Input for Commands - //----------->>>> _mnuf.menu_readin(); _mnuf.menu_proc(mString); @@ -2681,15 +2163,10 @@ int msg_read::StartReader(int newmsg, ulong msgidx) if (mString[0] == '!') { switch (toupper(ch)) { case '+': // Next Message - - - // If next Message, less then total, switch to it. if (current_msgidx+1 < msgidx_translation->size()) { current_msgidx +=1; CURRENT_MSGTITLE +=1; thisuser->lastmsg = msgidx_translation->at(current_msgidx); - - mLink.Lines = 0; mLink.dispose(); same = FALSE; @@ -2698,16 +2175,11 @@ int msg_read::StartReader(int newmsg, ulong msgidx) current_msgidx = msgidx_translation->size()-1; thisuser->lastmsg = msgidx_translation->at(current_msgidx); CURRENT_MSGTITLE = current_msgidx; - pipe2ansi((char *)"|CS|CR|07FYI: |15You're at the highest message available.|CR|CR"); // If were in a newscan, check if we want to continue scan // or return to titlescan if (newmsg && gblNewScan) { - - // Moce to Language File - //pipe2ansi((char *)"|15Use: |CR|15[|11ENTER|15] |07Continue to Next Area, or |15[|11Q|15] |07to Quit back to the TitleScan |08: |07"); - //pipe2ansi((char *)"|DFmcont"); - Need to fix this, not cuting off full ansi name, t shows! ansiPrintf ((char *)"mcont"); // Done with NewScan, Mark Messages As Read @@ -2736,13 +2208,11 @@ int msg_read::StartReader(int newmsg, ulong msgidx) } } } else { - pipe2ansi((char *)"|PA |CS "); mLink.Lines = 0; mLink.dispose(); same = FALSE; break; - } } @@ -2750,18 +2220,14 @@ int msg_read::StartReader(int newmsg, ulong msgidx) case '-': // Previous Message mLink.Lines = 0; - - // If next Message, less then total, switch to it. if (current_msgidx > 0) { current_msgidx -= 1; CURRENT_MSGTITLE -= 1; thisuser->lastmsg = msgidx_translation->at(current_msgidx); - } else { current_msgidx =0; CURRENT_MSGTITLE = 0; thisuser->lastmsg = msgidx_translation->at(current_msgidx); - pipe2ansi((char *)"|CS|CR|07FYI: |15You're at the lowest message available.|CR|CR|PA"); pipe2ansi((char *)" |CS "); } @@ -2777,7 +2243,6 @@ int msg_read::StartReader(int newmsg, ulong msgidx) same = FALSE; if (newmsg) { - // Scan Completed _msgf.read_mbaselist(&mr, thisuser->lastmbarea); _lang.lang_get(text,36); AnsiString = text; @@ -2794,8 +2259,6 @@ int msg_read::StartReader(int newmsg, ulong msgidx) break; case 'P': // Post a New Message - //DoPost(thisuser->lastmbarea,FALSE); - if (mr.Pubpriv == PRIVATE) { DoPostEmail(FALSE); } else { @@ -2807,9 +2270,6 @@ int msg_read::StartReader(int newmsg, ulong msgidx) same = FALSE; // Refresh Message pipe2ansi((char *)"|CS"); _mnuf.choice = 0; - - // On new message, dump back to title scan - // so we refresh message count rtnval = FALSE; done = TRUE; @@ -2826,24 +2286,18 @@ int msg_read::StartReader(int newmsg, ulong msgidx) same = FALSE; // Refresh Message pipe2ansi((char *)"|CS"); _mnuf.choice = 0; - - // On new message, dump back to title scan - // so we refresh message count rtnval = FALSE; done = TRUE; break; case 'H': // Set Last Read Pointer memset(&text,0,sizeof(text)); - - //thisuser->lastmsg = msgidx_translation->at(current_msgidx); SetLastRead(thisuser->idx, current_msgidx+1); _lang.lang_get(text,37); AnsiString = text; id1 = AnsiString.find("|M#",0); if (id1 != -1) { - // 0 Based, att once when showing current message. sprintf(szReplace,"%ld", current_msgidx+1); AnsiString.replace(id1,3,szReplace); } @@ -2867,32 +2321,17 @@ int msg_read::StartReader(int newmsg, ulong msgidx) case 'I': // Ignore IgnoreTheRest(thisuser->lastmbarea); - //done = TRUE; - //thisuser->lastmbarea = CURRENT_MAREA; mLink.Lines = 0; mLink.dispose(); same = FALSE; done = TRUE; pipe2ansi((char *)"|CS|CR|07FYI: |15Remaining messages ignored, marked as read.|CR|CR|PA"); - /* - - if (new// If next Message, less then total, switch to it. - current_msgidx = msgidx_translation->size()-1; - thisuser->lastmsg = msgidx_translation->at(current_msgidx);msg) { // Scan Completed - _msgf.read_mbaselist(&mr, thisuser->lastmbarea); - _lang.lang_get(text,36); - AnsiString = text; - pipe2ansi((char*)AnsiString.c_str()); - } - pipe2ansi((char *)"|CS"); - */ _mnuf.choice = 0; // Pushes to Next Area in Global NewScan if (newmsg && gblNewScan) rtnval = -2; - break; case 'B': // Bypass The Rest (Doesn't Mark @@ -2906,34 +2345,15 @@ int msg_read::StartReader(int newmsg, ulong msgidx) same = FALSE; done = TRUE; _mnuf.choice = 0; - pipe2ansi((char *)"|CS|CR|07FYI: |15Remaining messages bypassed, not marked as read.|CR|CR|PA"); // Pushes to Next Area in Global NewScan if (newmsg && gblNewScan) rtnval = -2; - - break; - - /* - if (newmsg) { // Scan Completed - _msgf.read_mbaselist(&mr, thisuser->lastmbarea); - _lang.lang_get(text,36); - AnsiString = text; - pipe2ansi((char*)AnsiString.c_str()); - } - pipe2ansi((char *)"|CS"); break; - */ - + case 'K': // Kill Current Message - - // Then return to title Scan to refresh! - // Other then sysop, make sure only user who posts - // can kill a message. - if (DelCurMsg(thisuser->lastmbarea, thisuser->lastmsg)) { - // Use this to go to previous message before deleted. pipe2ansi((char *)"|CS|CR|07FYI: |15Current Message has been deleted.|CR|CR|PA"); mLink.Lines = 0; mLink.dispose(); @@ -2957,7 +2377,7 @@ int msg_read::StartReader(int newmsg, ulong msgidx) EditMessage(); mLink.Lines = 0; mLink.dispose(); - same = FALSE; // Refresh Message + same = FALSE; pipe2ansi((char *)"|CS"); _mnuf.choice = 0; break; @@ -2965,7 +2385,7 @@ int msg_read::StartReader(int newmsg, ulong msgidx) case 'A': // Redisplay message Again. mLink.Lines = 0; mLink.dispose(); - same = FALSE; // Refresh Message + same = FALSE; _mnuf.choice = 0; break; @@ -2995,15 +2415,11 @@ int msg_read::StartReader(int newmsg, ulong msgidx) mLink.Bot = tBot; pipe2ansi((char *)"|CS|CR|07FYI: |15You've switched Message Reader Themes.|CR|CR|PA"); _mnuf._premenu.clear(); - //_mnuf.menu_reset(); - //_mnuf.menu_readin(); // Load up new prompts for new theme. } else { // Reset Theme Back change_theme(thisuser->readertheme); pipe2ansi((char *)"|CS|CR|07FYI: |15You've hit the highest theme available. |CR|CR|PA"); _mnuf._premenu.clear(); - //_mnuf.menu_reset(); - //_mnuf.menu_readin(); // Load up new prompts for new theme. } pipe2ansi((char *)"|CS"); same = FALSE; @@ -3020,8 +2436,6 @@ int msg_read::StartReader(int newmsg, ulong msgidx) pipe2ansi((char *)"|CS|CR|07FYI: |15You've hit the lowest theme available. |CR|CR|PA"); pipe2ansi((char *)"|CS"); _mnuf._premenu.clear(); - //_mnuf.menu_reset(); - //_mnuf.menu_readin(); // Load up new prompts for new theme. same = FALSE; break; } @@ -3035,15 +2449,11 @@ int msg_read::StartReader(int newmsg, ulong msgidx) mLink.Top = tTop; mLink.Bot = tBot; pipe2ansi((char *)"|CS|CR|07FYI: |15You've switched Message Reader Themes.|CR|CR|PA"); - //_mnuf.menu_reset(); _mnuf._premenu.clear(); - //_mnuf.menu_readin(); // Load up new prompts for new theme. } else { change_theme(thisuser->readertheme); pipe2ansi((char *)"|CS|CR|07FYI: |15You've hit the lowest theme available. |CR|CR|PA"); - //_mnuf.menu_reset(); _mnuf._premenu.clear(); - //_mnuf.menu_readin(); // Load up new prompts for new theme. } pipe2ansi((char *)"|CS"); same = FALSE; @@ -3069,9 +2479,6 @@ int msg_read::StartReader(int newmsg, ulong msgidx) ch = mString[0]; switch (toupper(ch)) { case 'A': - // Scroll Up 1 Line ( forced to paeg up / down for now) - // Don't care much for single scrolling, anoying online! - // Page is much nicer and faster ;) mLink.box_pgup(); break; diff --git a/src/msg_read.h b/src/msg_read.h index ae8b213..1bf87cf 100755 --- a/src/msg_read.h +++ b/src/msg_read.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2004-2014 by Michael Griffin * + * Copyright (C) 2004-2017 by Michael Griffin * * mrmisticismo@hotmail.com * * * * Purpose: * @@ -10,12 +10,6 @@ * (at your option) any later version. * ***************************************************************************/ -// Enthral SVN: $Id: msg_read.h 1 2014-03-29 07:30:21Z mercyful $ -// Source: $HeadURL: file:///home/merc/repo/enthral/trunk/src/msg_read.h $ -// $LastChangedDate: 2014-03-29 02:30:21 -0500 (Sat, 29 Mar 2014) $ -// $LastChangedRevision: 1 $ -// $LastChangedBy: mercyful $ - # ifndef MSG_READ_H # define MSG_READ_H @@ -145,7 +139,6 @@ class msg_read : private int SetupUserSig(); void get_address(XMSG *xm); -// void get_address(struct MemMessage *xm); void DoPostEmail(int Reply); void DoPost(int mbnum, int Reply); diff --git a/src/msg_readll.cpp b/src/msg_readll.cpp index 6bc4b2e..d44581c 100755 --- a/src/msg_readll.cpp +++ b/src/msg_readll.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2004-2014 by Michael Griffin * + * Copyright (C) 2004-2017 by Michael Griffin * * mrmisticismo@hotmail.com * * * * Purpose: Link Lists used for Full Screen Reader / Quoter & Lists * @@ -12,13 +12,6 @@ * (at your option) any later version. * ***************************************************************************/ -// Enthral SVN: $Id: msg_readll.cpp 1 2014-03-29 07:30:21Z mercyful $ -// Source: $HeadURL: file:///home/merc/repo/enthral/trunk/src/msg_readll.cpp $ -// $LastChangedDate: 2014-03-29 02:30:21 -0500 (Sat, 29 Mar 2014) $ -// $LastChangedRevision: 1 $ -// $LastChangedBy: mercyful $ - - # include "struct.h" # include "menu_func.h" @@ -28,25 +21,14 @@ # include # include # include -//# include - using namespace std; - /** * Message Link List Class */ msg_readll::msg_readll() { - - // Initalize Link List Class Defaults - //head = new LineRec; - //head->data = ""; - //head->up_link = head; - //head->dn_link = head; - //current_node = head; - head = 0; current_node = 0; last = 0; @@ -75,38 +57,24 @@ msg_readll::msg_readll() msg_readll::~msg_readll() { - - //if (head) delete head; - //if (current_node) delete current_node; - //if (last) delete last; - - //head = 0; - //current_node = 0; - //last = 0; - } - /** * Message Link List - Setup Message Quoter */ void msg_readll::initQuote(char *sLow, char *sHigh, int q) { - - quote = q; // In Quote Editor for Reader. - strcpy(LoColor,sLow); // Message Text Color - strcpy(HiColor,sHigh); // Message Text HiLight Color + quote = q; // In Quote Editor for Reader. + strcpy(LoColor,sLow); // Message Text Color + strcpy(HiColor,sHigh); // Message Text HiLight Color } - /** * Message Link List - Setup Title & Area/User Lists */ void msg_readll::initList(char *sLow, int alist) { - arealist = alist; // Set if were using Area List - // Mainly for Box_Start() Proper list placement. strcpy(LoColor,sLow); // Message Text Color } @@ -115,7 +83,6 @@ void msg_readll::initList(char *sLow, int alist) */ void msg_readll::togglePageScroll(int on) { - PAGE_SCROLL = on; } @@ -124,7 +91,6 @@ void msg_readll::togglePageScroll(int on) */ void msg_readll::initReader(char *sTEXT, char *sQUOTE, char *sSYS, char *sORIGIN) { - reader = TRUE; strcpy(TEXT_COLOR,sTEXT); // Message Text Color strcpy(QUOTE_COLOR,sQUOTE); // Message Quote @@ -137,7 +103,6 @@ void msg_readll::initReader(char *sTEXT, char *sQUOTE, char *sSYS, char *sORIGIN */ void msg_readll::clearBox() { - char capture[100]= {0}; std::string _editbox; int boxsize = Bot - Top; @@ -155,7 +120,6 @@ void msg_readll::clearBox() */ void msg_readll::stripCRONLY(char *ostr) { - int id1; std::string tstr = ostr; while ((id1=tstr.find("\n",0)) != -1) tstr.erase(id1,1); @@ -170,8 +134,6 @@ void msg_readll::stripCRONLY(char *ostr) */ void msg_readll::GetBuffer(std::string &mBuf) { - - //errlog2((char *)"GetBufferSig()"); mBuf.erase(); if(head == 0) { return; @@ -193,34 +155,14 @@ void msg_readll::GetBuffer(std::string &mBuf) */ void msg_readll::GetVector(vector listb) { - - // Swap passed with Global listing.swap(listb); - //SESSION s; - - /* only a test to verify contents passed properly. - ulong max_areas = listing.size(); - for (ulong i = 0; i != max_areas; i++) { - s . errlog((char *)"GetVector str1: %s",(char *)listing[i].ansi_1.c_str()); - s . errlog((char *)"GetVector str2: %s",(char *)listing[i].ansi_2.c_str()); - s . errlog((char *)"GetVector str3: %s",(char *)listing[i].ansi_3.c_str()); - s . errlog((char *)"GetVector str4: %s",(char *)listing[i].ansi_4.c_str()); - } - - if (listb.size()>1) s . errlog((char *)"GetVector listb: %lu",listb.size()); - */ } - - /** * Copy From buffer into Link List */ void msg_readll::PutBuffer(char *mBuff, int Strip) { - - //errlog2((char *)"PutBuffer msg_readll() START LOOP!"); - std::string MsgText, Line; MsgText = mBuff; int id1, i = 0; @@ -228,7 +170,7 @@ void msg_readll::PutBuffer(char *mBuff, int Strip) while(1) { Line.erase(); - // Remove All CR/LF's if Exist for Normal Link Lists + while (1) { if (MsgText.find("\r", 0) == 0) MsgText.erase(0,1); @@ -250,35 +192,16 @@ void msg_readll::PutBuffer(char *mBuff, int Strip) else break; } } + id1 = MsgText.find("\r", 0); - // Make Sure only to Add New Lines when being used, - // First Line is already Setup! So Skip it - - //if (id1 != -1 && i != 0) add_to_list(""); - - //if (id1 != -1) add_to_list(""); if (id1 == -1) break; else { - - //errlog2((char *)"PutBuffer msg_readll() ELSE! LOOP!"); - Line = MsgText.substr(0,id1); MsgText.erase(0,id1); if (Line.size() > 0) { strcpy(TmpStrip,(char *)Line.c_str()); stripCRONLY(TmpStrip); - /* - /// Bug Fix! - // If first line already exists, use it before adding a new one!! - if (current_node != 0 && i == 0) { - current_node->data = TmpStrip; - } - else { - add_to_list(TmpStrip); - } - */ add_to_list(TmpStrip); - //current_node->data = TmpStrip; current_node->lineNum = (i+1); ++i; } @@ -286,18 +209,6 @@ void msg_readll::PutBuffer(char *mBuff, int Strip) } LineRec *tmp; - //current_node = last; - /* - current_node = head; - while (1) { // Goto LAst! - //errlog2(" $$$ box_scrolldn 2.1 LOOP X"); - if (current_node->dn_link == 0) { - //errlog2(" $$$ box_scrolldn 2.2"); - break; - } - - current_node = current_node->dn_link; - } */ Last_Line(); for (;;) { @@ -310,30 +221,19 @@ void msg_readll::PutBuffer(char *mBuff, int Strip) if (current_node->up_link == 0) break; current_node = current_node->up_link; current_node->dn_link = 0; - - //current_node->up_link = tmp->up_link; - //tmp->up_link->dn_link = current_node; - delete tmp; tmp = 0; - - /* - if (!move_up()) { - break; - } */ } else break; } current_node->dn_link = 0; } - /** * Copy From buffer into Link List (UserSig) Clean */ void msg_readll::PutBufferSig(char *mBuff, int Strip) { - int id1; std::string Line; std::string MsgText; @@ -341,8 +241,6 @@ void msg_readll::PutBufferSig(char *mBuff, int Strip) std::string buffer; - //errlog2((char *)"PutBufferSig()"); - MsgText = mBuff; while (1) { id1 = Line.find("\r", 0); @@ -351,11 +249,8 @@ void msg_readll::PutBufferSig(char *mBuff, int Strip) else break; } - //add_to_list(""); while(1) { id1 = MsgText.find("\r", 1); - //if (id1 != -1 && i != 0) add_to_list(""); - //if (id1 != -1) add_to_list(""); if (id1 == -1) break; else { Line.erase(); @@ -368,17 +263,7 @@ void msg_readll::PutBufferSig(char *mBuff, int Strip) Line.erase(id1,1); else break; } - - - /// Bug Fix! - /* - // If first line already exists, use it before adding a new one!! - if (current_node != 0 && i == 0) { - current_node->data = Line; - } - else { - add_to_list(Line); - } */ + add_to_list(Line); ++i; } @@ -386,72 +271,44 @@ void msg_readll::PutBufferSig(char *mBuff, int Strip) // Clean Bottom of Message, Leave no Blank Lines below sig. LineRec *tmp; - //current_node = last; - /* - current_node = head; - while (1) { // Goto LAst! - //errlog2(" $$$ box_scrolldn 2.1 LOOP X"); - if (current_node->dn_link == 0) { - //errlog2(" $$$ box_scrolldn 2.2"); - break; - } - - current_node = current_node->dn_link; - } */ Last_Line(); + for (;;) { if (current_node->data == "" || current_node->data.size() < 1) { if(current_node == 0) { break; } + tmp = current_node; if (current_node->up_link == 0) break; current_node = current_node->up_link; - - //current_node->up_link = tmp->up_link; - //tmp->up_link->dn_link = current_node; + delete tmp; tmp = 0; - - //if (!move_up()) { - // break; - //} } else break; } current_node->dn_link = 0; - } - /** * Remove Tag and Origin Lines from Original Message for Editing! */ void msg_readll::cleartags(char *tag, char *origin) { - LineRec *tmp; - current_node = head; //head->dn_link; + current_node = head; - //errlog2((char *)"cleartags()"); while(current_node != 0) { if (current_node->data == tag || current_node->data.substr(0,3) == "---") current_node->data.erase(); else if (current_node->data == origin) current_node->data.erase(); - //current_node = current_node->dn_link; + if (current_node->dn_link == 0) break; current_node = current_node->dn_link; } - // (Delete and Move Up) remove any blank lines from bottom going up... - // For Cleaner Message Display with no extra lines. - /* - for (;;) { - if (!move_down()) { - break; - } - }*/ - //current_node = last; // Starting at the Last, No Down, only Up! + Last_Line(); for (;;) { if (current_node->data == "" || current_node->data.size() < 1) { @@ -462,14 +319,8 @@ void msg_readll::cleartags(char *tag, char *origin) if (current_node->up_link == 0) break; current_node = current_node->up_link; - //current_node->up_link = tmp->up_link; - //tmp->up_link->dn_link = current_node; delete tmp; tmp = 0; - - //if (!move_up()) { - // break; - //} } else break; } @@ -481,24 +332,17 @@ void msg_readll::cleartags(char *tag, char *origin) */ void msg_readll::clear_all() { - - //errlog2((char *)"clear all()"); LineRec *print; if(head == 0) { return; } - //errlog2((char *)"clear all 2()"); - print = head; while(print != 0) { - //errlog2((char *)"clear all 3()"); print->flag = FALSE; if (print == last) break; print = print->dn_link; } - //errlog2((char *)"clear all 4()"); - } /** @@ -506,9 +350,7 @@ void msg_readll::clear_all() */ void msg_readll::select_all() { - LineRec *print; - //errlog2((char *)"select all()"); if(head == 0) { return; } @@ -516,50 +358,19 @@ void msg_readll::select_all() print = head; while(print != 0) { print->flag = TRUE; - //print = print->dn_link; if (print == last) break; print = print->dn_link; } - } -// Testing Only -/* -void msg_readll::display_list(void) -{ - - unsigned char c; - LineRec *print; - long int i = 0; - - if(head == 0) - { - // Empty - return; - } - - print = head; - while(print != 0) - { - printf("\n%s",print->data.c_str()); - print = print->dn_link; - ++i; - } - c = getkey(true); -} -*/ - - /** * flag Lines (Quoter) which line are to be quoted. */ void msg_readll::flag_line(int iNum) { - LineRec *print; long int i = 1; - //errlog2((char *)"flag_line()"); if(head == 0) { return; } @@ -575,66 +386,51 @@ void msg_readll::flag_line(int iNum) print = print->dn_link; ++i; } - } - /** * delete current line and Move up CTRL+Y */ void msg_readll::delete_line_up() { - LineRec *tmp; - //int Total = line_total(); - //errlog2((char *)"delete line up()"); + if(current_node == 0) { return; } - if (current_node->up_link != 0) { // At least 1 Line Above Current! + if (current_node->up_link != 0) { tmp = current_node; current_node = current_node->dn_link; current_node->up_link = tmp->up_link; tmp->up_link->dn_link = current_node; delete tmp; tmp = 0; - // No Lines Below this, move to top line - //move_up(); current_node = current_node->up_link; - //current_node->dn_link = 0; return; } - // This is the First Line, just Clear It. + current_node->data.erase(); Row = 1; Num = 1; Tot = 1; } - /** * Add Line to Link List */ void msg_readll::add_to_list(std::string add_data) { - LineRec *add = new LineRec; if (!add) { - //errlog2((char *)"unable to allocate memory readll add_to_list()"); exit (1); } - //errlog2((char *)"add_to_list readll Done 1"); - - //errlog2((char *)add_data.c_str()); add->data = add_data; add->flag = FALSE; add->lineNum = 0; - //errlog2((char *)"add_to_list readll Done 2"); if (current_node == 0) { // New Frist Add! - //errlog2((char *)"add_to_list readll Done 2.1"); add->up_link = 0; add->dn_link = 0; head = add; @@ -643,67 +439,30 @@ void msg_readll::add_to_list(std::string add_data) return; } - /// Always add after current node, then link back up. - //errlog2((char *)"add_to_list readll Done 2.2"); - //add->dn_link = 0; - //errlog2((char *)"add_to_list readll Done 2.3"); add->up_link = current_node; - - - //errlog2((char *)"add_to_list readll Done 3"); // In the Middle of list! hmmm if (current_node->dn_link != 0) { - - //errlog2((char *)"add_to_list readll Done 4"); add->dn_link = current_node->dn_link; - //add->up_link = current_node; - - //errlog2((char *)"add_to_list readll Done 5"); - // current_node->dn_link->up_link = add; current_node->dn_link = add; - - //errlog2((char *)"add_to_list readll Done 8"); - - /// SAME current_node->dn_link = add; - - //errlog2((char *)"add_to_list readll Done 9"); current_node = add; - - //errlog2((char *)"add_to_list readll Done 10"); - //last = add; - } // Current is the Last one in Lie else { - //errlog2((char *)"add_to_list readll Done 6"); add->up_link = current_node; add->dn_link = 0; - - //errlog2((char *)"add_to_list readll Done 7"); - - //errlog2((char *)"add_to_list readll Done 8"); - - /// SAME current_node->dn_link = add; - - //errlog2((char *)"add_to_list readll Done 9"); current_node = add; - - //errlog2((char *)"add_to_list readll Done 10"); last = add; } } - /** * Move up 1 from current to prev in list */ int msg_readll::move_up() { - - // Make Sure Link List Stays at current if there is none! if (current_node == 0) return FALSE; if (current_node->up_link == 0) { return FALSE; @@ -712,15 +471,11 @@ int msg_readll::move_up() return TRUE; } - - /** * move down 1 from current to next */ int msg_readll::move_down() { - - // Make Sure Link List Stays at current if there is none! if (current_node == 0) return FALSE; if (current_node->dn_link == 0) { return FALSE; @@ -729,23 +484,20 @@ int msg_readll::move_down() return TRUE; } - /** * Count how many lines in list from current all the way down */ int msg_readll::line_count() { - int count = 0; // Don't include Current LineRec *lineTmp; if(head == 0) { return 0; } - // Make Sure Link List Stays at current if there is none! + lineTmp = current_node; - // Count how many Lines from Current to Bottom while ( lineTmp->dn_link != 0 ) { lineTmp = lineTmp->dn_link; ++count; @@ -754,13 +506,11 @@ int msg_readll::line_count() return count; } - /** * Count how many lines in list from Top all the way down */ int msg_readll::line_total() { - int count = 1; // Include Current LineRec *lineTmp; // always assign temp to not affect global current_node @@ -768,91 +518,51 @@ int msg_readll::line_total() return 0; } - // Make Sure Link List Stays at current if there is none! lineTmp = head; - // Count how many Lines from Current to Bottom while ( lineTmp->dn_link != 0 ) { if (lineTmp->dn_link == 0) break; ++count; lineTmp = lineTmp->dn_link; - } Tot = count; - //errlog2("line_total msgread: %i",Tot); return count; - } - /** * Move to last line in list */ void msg_readll::Last_Line() { - - //LineRec *lineTmp; - - //is Empty? if(head == 0) { return; } - /*lineTmp = head; - lineTmp = lineTmp->up_link; - current_node = lineTmp;*/ - //current_node = last; current_node = head; while (1) { // Goto LAst! - //errlog2(" $$$ box_scrolldn 2.1 LOOP X"); if (current_node->dn_link == 0) { - //errlog2(" $$$ box_scrolldn 2.2"); break; } current_node = current_node->dn_link; } - } - /** * Remove all enteries in list */ void msg_readll::dispose() { - - //errlog2((char *)"dispose readll"); - dispose_list(); - //errlog2((char *)"dispose readll done!"); return; - - /* - int Total = line_total(); - - if (current_node == 0) return; - current_node = last; - - // Delete All the Lines - for ( ; Total != 0; Total--) { - Num = Total; - delete_line_up(); - } - //errlog2((char *)"dispose readll done!"); - */ } - /** * Wipe Out List Completely & Free Memory. */ void msg_readll::dispose_list() { - - //errlog2((char *)"dispose_list readll"); - LineRec *tmp; current_node = head; @@ -863,11 +573,8 @@ void msg_readll::dispose_list() current_node = current_node->dn_link; delete tmp; tmp = 0; - - } - //delete head; - //delete last; + current_node = 0; head = 0; last = 0; @@ -882,8 +589,6 @@ char *msg_readll::parsereadcolors(char *cap, int col, std::string data) { - - std::string tmp; tmp = data; std::string::size_type id1 = 0, id2 = 0; @@ -921,13 +626,9 @@ char *msg_readll::parsereadcolors(char *cap, } else break; } - // Quote Color - //if (tmp[0] == '>' || tmp[1] == '>' || tmp[2] == '>') id1 = tmp.find(">", 0); if (id1 != std::string::npos && id1 <= 3) { - - sprintf(cap, "\x1b[%i;%iH%s%s", row,col,QUOTE_COLOR,tmp.c_str()); return cap; @@ -948,7 +649,6 @@ char *msg_readll::parsereadcolors(char *cap, */ char *msg_readll::parseReadColorScroller(char *cap, std::string data) { - std::string tmp; tmp = data; std::string::size_type id1 = 0, id2 = 0; @@ -983,9 +683,7 @@ char *msg_readll::parseReadColorScroller(char *cap, std::string data) } else break; } - // Quote Color - //if (tmp[0] == '>' || tmp[1] == '>' || tmp[2] == '>') id1 = tmp.find(">", 0); if (id1 != std::string::npos && id1 <= 3) { sprintf(cap, "%s%s",QUOTE_COLOR,tmp.c_str()); @@ -1000,22 +698,16 @@ char *msg_readll::parseReadColorScroller(char *cap, std::string data) return cap; } -// Still used for message reader scroller i believe! -// Reader Uses old version, New Full Screen -// Interfaces use box_start_vector() - /** * Inital Fucntion for Drawing List on the Screen * And Scrolling text per page. */ void msg_readll::box_start(unsigned long CURRENT) { - std::string _editbox = LoColor, lData; char capture[200]= {0}; char lineNum[20]; Page = 1; - //pgRows = 0; // Calcuate Box Size and Total Pages int boxsize = Bot - Top; // Fist Get Box Size @@ -1042,28 +734,17 @@ void msg_readll::box_start(unsigned long CURRENT) } } - //display_list(); - //Now clear the box First for (int t = 0; t < boxsize; t++) { sprintf(capture, "\x1b[%i;%iH\x1b[K", (Top)+t, 1); _editbox += capture; } - // Now Grab as many lines as will fit in the box current_node = head; //->dn_link; for (int i = 1; i < boxsize+1; i++) { if (quote) { lData = current_node->data; - /* - lData = current_node->data.substr(0,74); - if (lData.size() < 74) - { - strcpy(capture,lData.c_str()); - rspacing(capture,74); - lData = capture; - }*/ // For Messge Quoteer only!! sprintf(lineNum,"%i",current_node->lineNum); @@ -1094,17 +775,12 @@ void msg_readll::box_start(unsigned long CURRENT) } - -// Line Reader - old school scrolling. -// Still in Use for Scroll Themes. /** * Inital Fucntion for Drawing List on the Screen * And Scrolling text per page. */ void msg_readll::box_scroll_reader() { - - //errlog2((char *)"box scroll reader"); if (head == 0) return; std::string _editbox = LoColor, lData; @@ -1114,7 +790,6 @@ void msg_readll::box_scroll_reader() pgRows = 0; int iCoordX = Top, - //iCoordY, iPause; int boxsize = TERM_HEIGHT-1; @@ -1122,7 +797,6 @@ void msg_readll::box_scroll_reader() // Now Grab as many lines as will fit in the screen up to 24 Lines! current_node = head; //->dn_link; for (int i = iCoordX; i < boxsize+1; i++) { - //current_node->data; strcpy(capture,parseReadColorScroller(capture,current_node->data.c_str())); _editbox += capture; _editbox += "|CR"; @@ -1131,10 +805,9 @@ void msg_readll::box_scroll_reader() break; } current_node = current_node->dn_link; - } - if (Page == 0) { // || Page == TotPages) { + if (Page == 0) { Page = 1; _editbox += "|CR"; pipe2ansi((char *)_editbox.c_str()); @@ -1143,7 +816,7 @@ void msg_readll::box_scroll_reader() pipe2ansi((char *)_editbox.c_str()); REDRAW: - //errlog2((char *)"box scroll reader 2"); + memset(&capture,0,sizeof(capture)); _editbox.erase(); @@ -1157,7 +830,6 @@ void msg_readll::box_scroll_reader() // Now Grab as many lines as will fit in the screen up to 24 Lines! for (int i = 1; i < boxsize+1; i++) { - //current_node->data; strcpy(capture,parseReadColorScroller(capture,current_node->data.c_str())); _editbox += capture; _editbox += "|CR"; @@ -1168,7 +840,6 @@ void msg_readll::box_scroll_reader() current_node = current_node->dn_link; } - //_editbox += "|CR"; pipe2ansi((char *)_editbox.c_str()); if (Page == TotPages) { @@ -1176,78 +847,26 @@ void msg_readll::box_scroll_reader() return; } - //errlog2((char *)"box scroll reader 5"); if (Page == 0) { Page = TotPages; pipe2ansi((char *)"|CR"); - //errlog2((char *)"box scroll reader 6"); return; } - //errlog2((char *)"box scroll reader 7"); goto REDRAW; - } -/* -void msg_readll::box_pgdn_scroll() { - - std::string _editbox = LoColor, lData; - char capture[200]={0}; -// char lineNum[5]; - int iPause; - int boxsize = 23; - -REDRAW2: - memset(&capture,0,sizeof(capture)); - _editbox.erase(); - - iPause = 0; - //pipe2ansi((char *)"ipause start"); - do { - - iPause = startpause((char *)"mreadpause.ini"); - if (toupper(iPause) == 'N' || (toupper(iPause) == 'Q')) return; - } - while(iPause == 0); - - //pipe2ansi((char *)"ipause done1"); - Page = 1; - - // Now Grab as many lines as will fit in the screen up to 24 Lines! - // current_node = current_node->dn_link; - for (int i = 0; i < boxsize; i++) { - //current_node->data; - strcpy(capture,parseReadColorScroller(capture,current_node->data.c_str())); - _editbox += capture; - _editbox += "|CR"; - if (current_node->dn_link == 0) { Page = 0; break; } - current_node = current_node->dn_link; - } - - pipe2ansi((char *)_editbox.c_str()); - - if (Page == 0) - return; - else - goto REDRAW2; -} -*/ - /** * Scroll Last Page Up from Bottom. */ void msg_readll::box_scrolldn() { - std::string _editbox = LoColor, lData; char capture[200]= {0}; char lineNum[20]; // Make sure we can go down another page.. - int boxsize = Bot - Top; // Get boxsize - - //errlog2(" $$$ box_scrolldn 1"); + int boxsize = Bot - Top; if (CLEAR_BOX == TRUE) { //Now clear the box First @@ -1257,38 +876,11 @@ void msg_readll::box_scrolldn() } } - //errlog2(" $$$ box_scrolldn 2"); - - // Jump to last line - //Last_Line(); - - //if (last == 0) { - // errlog("ERR box_scrolldn: Last was not allocated properly!"); - // return; - //} - /* - //current_node = last; - - //current_node = head; A;ready assign head! - while (1) { // Goto LAst! - //errlog2(" $$$ box_scrolldn 2.1 LOOP X"); - if (current_node->dn_link == 0) { - //errlog2(" $$$ box_scrolldn 2.2"); - break; - } - - current_node = current_node->dn_link; - } */ Last_Line(); - //errlog2(" $$$ box_scrolldn 2.3"); - // Move up As Many lines that will fit in the box for (int i = 1; i < boxsize; i++) { - //errlog2((char *)current_node->data.c_str()); - //errlog2(" $$$ box_scrolldn 2.4 LOOP X"); if (current_node->up_link == 0) { - //errlog2(" $$$ box_scrolldn 2.5"); break; } @@ -1296,20 +888,9 @@ void msg_readll::box_scrolldn() } // Now Grab as many lines as will fit in the box - //errlog2(" $$$ box_scrolldn 3"); for (int i = 1; i < boxsize+1; i++) { if (quote) { lData = current_node->data; - /* - //errlog2(" $$$ box_scrolldn 3.1"); - lData = current_node->data.substr(0,74); - if (lData.size() < 74) - { - strcpy(capture,lData.c_str()); - rspacing(capture,74); - lData = capture; - }*/ - sprintf(lineNum,"%i",current_node->lineNum); lspacing(lineNum,3); @@ -1318,40 +899,33 @@ void msg_readll::box_scrolldn() else sprintf(capture, "\x1b[%i;%iH|15%s. %s%s", Top+i-1, 1, lineNum, LoColor, lData.c_str()); } else if (reader) { - //errlog2(" $$$ box_scrolldn 3.2"); strcpy(capture,parsereadcolors(capture,Top+i-1,1, current_node->data.c_str())); } else { - //errlog2(" $$$ box_scrolldn 3.3"); pgRows = i; // Set # of Rows on Last Page. sprintf(capture, "\x1b[%i;%iH%s", Top+i-1, 1, current_node->data.c_str()); } - //errlog2(" $$$ box_scrolldn 3.4"); _editbox += capture; if (current_node->dn_link == 0) break; current_node = current_node->dn_link; } - //errlog2(" $$$ box_scrolldn 3.5"); // Display Message Page = TotPages; pipe2ansi((char *)_editbox.c_str()); - } - /** * Page Down in Link List. */ void msg_readll::box_pgdn() { - std::string _editbox = LoColor, lData; char capture[200]= {0}; char lineNum[20]= {0}; // Make sure we can go down another page.. - int boxsize = Bot - Top; // Get boxsize + int boxsize = Bot - Top; Tot = line_total(); TotPages = Tot / boxsize; @@ -1363,64 +937,37 @@ void msg_readll::box_pgdn() // Check Total Number of Pages // If On Last page Return if (Page == TotPages) { - --Page; //return; + --Page; } ++Page; - current_node = head; //->dn_link; + current_node = head; if (Page == TotPages && PAGE_SCROLL == TRUE) { box_scrolldn(); return; - }/* - else if ((Tot - boxsize) <= CURRENT_MAREA) { - errlog2(" $$$ box_pgdn 1.2"); - box_scrolldn(); - return; - - } */ + } else { - // Number of Rows if This was the Last Page Only. pgRows = 0; } if (CLEAR_BOX == TRUE) { - //Now clear the box First for (int t = 0; t < boxsize; t++) { sprintf(capture, "\x1b[%i;%iH\x1b[K", (Top)+t, 1); _editbox += capture; } } - //errlog2(" $$$ box_pgdn 3"); - // Set Current Node to First In List - - //* NOTE TESTING the +1 on i < boxsize. - - //errlog2(" $$$ box_pgdn 4"); // Now Move Down How Many Pages for (int i = 1; i < (boxsize*(Page-1))+1; i++) { - //for (int i = 1; i < (boxsize*(Page-1)); i++) { if (current_node->dn_link == 0) break; current_node = current_node->dn_link; - - //if (!move_down()) break; } - //errlog2(" $$$ box_pgdn 5"); + // Now Grab as many lines as will fit in the box for (int i = 1; i < boxsize+1; i++) { if (quote) { lData = current_node->data; - //errlog2(" $$$ box_pgdn 5.1"); - /* - lData = current_node->data.substr(0,74); - if (lData.size() < 74) - { - strcpy(capture,lData.c_str()); - rspacing(capture,74); - lData = capture; - } - */ sprintf(lineNum,"%i",current_node->lineNum); lspacing(lineNum,3); @@ -1429,19 +976,16 @@ void msg_readll::box_pgdn() else sprintf(capture, "\x1b[%i;%iH|15%s. %s%s", Top+i-1, 1, lineNum, LoColor, lData.c_str()); } else if (reader) { - //errlog2(" $$$ box_pgdn 5.2"); strcpy(capture,parsereadcolors(capture,Top+i-1,1, current_node->data.c_str())); } else { - //errlog2(" $$$ box_pgdn 5.3"); sprintf(capture, "\x1b[%i;%iH%s", Top+i-1, 1, current_node->data.c_str()); } - //errlog2(" $$$ box_pgdn 5.4"); + _editbox += capture; if (current_node->dn_link == 0) break; current_node = current_node->dn_link; } - //errlog2(" $$$ box_pgdn 5.5"); - // Display Message + pipe2ansi((char *)_editbox.c_str()); } @@ -1456,11 +1000,8 @@ void msg_readll::box_pgup() char capture[200]= {0}; char lineNum[20]; - // Number of Rows if This was the Last Page Only. pgRows = 0; - - // Make sure we can go down another page.. - int boxsize = Bot - Top; // Get boxsize + int boxsize = Bot - Top; Tot = line_total(); TotPages = Tot / boxsize; @@ -1473,13 +1014,14 @@ void msg_readll::box_pgup() // If On Last page Return if (Page == 1) return; --Page; + //Now clear the box First for (int t = 0; t < boxsize; t++) { sprintf(capture, "\x1b[%i;%iH\x1b[K", (Top)+t, 1); _editbox += capture; } // Set Current Node to First In List - current_node = head; //->dn_link; + current_node = head; if (Page > 1) { // Now Move Down How Many Pages for (int i = 1; i < (boxsize*(Page-1)+1); i++) { @@ -1491,15 +1033,6 @@ void msg_readll::box_pgup() for (int i = 1; i < boxsize+1; i++) { if (quote) { lData = current_node->data; - /* - lData = current_node->data.substr(0,74); - if (lData.size() < 74) - { - strcpy(capture,lData.c_str()); - rspacing(capture,74); - lData = capture; - }*/ - sprintf(lineNum,"%i",current_node->lineNum); lspacing(lineNum,3); @@ -1516,18 +1049,15 @@ void msg_readll::box_pgup() if (current_node->dn_link == 0) break; current_node = current_node->dn_link; } - // Display Message + pipe2ansi((char *)_editbox.c_str()); } - -// Used for Message Quoter / And Lists. /** * Refresh the Screen */ void msg_readll::box_refresh(unsigned long CURRENT) { - if (Page == 0) Page = 1; if (Page == 1) box_start(CURRENT); @@ -1537,14 +1067,11 @@ void msg_readll::box_refresh(unsigned long CURRENT) } } -// used for faster dispaly without clearing first. -// Dont think this is used anymore!! /** * Refresh the Screen */ void msg_readll::box_overdraw(unsigned long CURRENT) { - CLEAR_BOX = FALSE; if (Page == 0) Page = 1; if (Page == 1) @@ -1556,276 +1083,7 @@ void msg_readll::box_overdraw(unsigned long CURRENT) CLEAR_BOX = TRUE; } -// New Full Screen Vector Interface -// Not Used, anymore /** - * Not used anymore, box_start_vector Does it all now! - */ -void msg_readll::box_pgup_vector() -{ - -// errlog((char *)" box_pgup_vector "); - - // Faster display to throw in 1 string and send all out at 1 time - std::string _editbox = LoColor, lData; - char capture[200]= {0}; - - // Number of Rows if This was the Last Page Only. - pgRows = 0; - - // Make sure we can go down another page.. - int boxsize = Bot - Top; // Get boxsize - - Tot = line_total(); - TotPages = Tot / boxsize; - if (Tot % boxsize > 0) { - ++TotPages; - } - if (Tot <= boxsize) TotPages = 1; - - // Check Total Number of Pages - // If On Last page Return - -// if (Page == 1) return; -// --Page; - - //Now clear the box First - for (int t = 0; t < boxsize; t++) { - sprintf(capture, "\x1b[%i;%iH\x1b[K", (Top)+t, 1); - _editbox += capture; - } - - // Set to Start of Page. - int current_result = boxsize*(Page-1); - - // Now Grab as many lines as will fit in the box - for (int i = 1; i < boxsize+1; i++) { - -// errlog((char *)"%i - current_result %i, CURRENT_MAREA %i, == lsitingsize() %i", current_result, CURRENT_MAREA,i,listing.size() ); - - /// Paging up - if (listing[current_result].isnew) { - if (current_result == CURRENT_MAREA) { -// errlog((char *)" current_result == CURRENT_MAREA %i",Top+i-1); - current_selection = Top+i-1; // Get current place in box to display. - sprintf(capture, "\x1b[%i;%iH%s", Top+i-1, 1, listing[current_result].ansi_4.c_str()); - } else if (current_result < (signed)listing.size()) { -// errlog((char *)" current_result %i ",Top+i-1); - sprintf(capture, "\x1b[%i;%iH%s", Top+i-1, 1, listing[current_result].ansi_3.c_str()); - } else - break; - } else { - if (current_result == CURRENT_MAREA) { -// errlog((char *)" current_result == CURRENT_MAREA %i",Top+i-1); - current_selection = Top+i-1; // Get current place in box to display. - sprintf(capture, "\x1b[%i;%iH%s", Top+i-1, 1, listing[current_result].ansi_2.c_str()); - } else if (current_result < (signed)listing.size()) { -// errlog((char *)" current_result %i ",Top+i-1); - sprintf(capture, "\x1b[%i;%iH%s", Top+i-1, 1, listing[current_result].ansi_1.c_str()); - } else - break; - } - - ++current_result; - _editbox += capture; - if ( CURRENT_MAREA+i > (signed)listing.size() ) break; - } - // Display Message - pipe2ansi((char *)_editbox.c_str()); -} - - -// Not implimented yet - gets messy! -void msg_readll::box_scrolldn_vector() -{ - - std::string _editbox = LoColor, lData; - char capture[200]= {0}; - - // Make sure we can go down another page.. - int boxsize = Bot - Top; // Get boxsize - - //errlog2(" $$$ box_scrolldn 1"); - - if (CLEAR_BOX == TRUE) { - //Now clear the box First - for (int t = 1; t < boxsize+1; t++) { - sprintf(capture, "\x1b[%i;%iH\x1b[K", (Top)+t-1, 1); - _editbox += capture; - } - } - - //errlog2(" $$$ box_scrolldn 2"); - - // Jump to last line - //Last_Line(); - - //if (last == 0) { - // errlog("ERR box_scrolldn: Last was not allocated properly!"); - // return; - //} - /* - //current_node = last; - - //current_node = head; A;ready assign head! - while (1) { // Goto LAst! - //errlog2(" $$$ box_scrolldn 2.1 LOOP X"); - if (current_node->dn_link == 0) { - //errlog2(" $$$ box_scrolldn 2.2"); - break; - } - - current_node = current_node->dn_link; - } */ -// Last_Line(); - - //errlog2(" $$$ box_scrolldn 2.3"); - - // Move up As Many lines that will fit in the box - //for (int i = 1; i < boxsize; i++) { - //errlog2((char *)current_node->data.c_str()); - //errlog2(" $$$ box_scrolldn 2.4 LOOP X"); - //if (current_node->up_link == 0) { - //errlog2(" $$$ box_scrolldn 2.5"); - // break; - //} - - //current_node = current_node->up_link; - - //} - - // Now Grab as many lines as will fit in the box - //errlog2(" $$$ box_scrolldn 3"); - for (int i = 1; i < boxsize+1; i++) { - - - //errlog2(" $$$ box_scrolldn 3.3"); - pgRows = i; // Set # of Rows on Last Page. - if (CURRENT_MAREA) - sprintf(capture, "\x1b[%i;%iH%s", Top+i-1, 1, current_node->data.c_str()); - else - sprintf(capture, "\x1b[%i;%iH%s", Top+i-1, 1, current_node->data.c_str()); - - - - //errlog2(" $$$ box_scrolldn 3.4"); - _editbox += capture; - if (current_node->dn_link == 0) break; - current_node = current_node->dn_link; - } - - //errlog2(" $$$ box_scrolldn 3.5"); - // Display Message - Page = TotPages; - pipe2ansi((char *)_editbox.c_str()); - -} - -/* -// Used for Message Quoter / And Lists. -void msg_readll::box_refresh_vector(unsigned long CURRENT) { - - errlog((char *)" box_refresh_vector "); - if (Page == 0) Page = 1; - if (Page == 1) - box_start_vector(CurrentPage,CURRENT_MAREA); - else { - --Page; - box_pgdn_vector(); - } -} -*/ - -// Not Used! -void msg_readll::box_pgdn_vector() -{ - -// errlog((char *)" box_pgdn_vector "); - - std::string _editbox = LoColor, lData; - char capture[200]= {0}; - - // Make sure we can go down another page.. - int boxsize = Bot - Top; // Get boxsize - - Tot = listing.size(); - TotPages = Tot / boxsize; - if (Tot % boxsize > 0) { - ++TotPages; - } - if (Tot <= boxsize) TotPages = 1; - - // Check Total Number of Pages - // If On Last page Return - if (Page == TotPages) { - --Page; //return; - } - ++Page; - - - if (Page == TotPages && PAGE_SCROLL == TRUE) { - // box_scrolldn(); - // return; - } else { // Number of Rows if This was the Last Page Only. - pgRows = 0; - } - - if (CLEAR_BOX == TRUE) { - //Now clear the box First - for (int t = 0; t < boxsize; t++) { - sprintf(capture, "\x1b[%i;%iH\x1b[K", (Top)+t, 1); - _editbox += capture; - } - } - - // Move Down to Current Record for Starting Position. - int current_result = boxsize*(Page-1); - - // Now Grab as many lines as will fit in the box - for (int i = 1; i < boxsize+1; i++) { - -// errlog((char *)"%i - current_result %i, CURRENT_MAREA %i, == lsitingsize() %i", current_result, CURRENT_MAREA,i,listing.size() ); - if ( CURRENT_MAREA+i > (signed)listing.size() ) break; - - /// Paging Down - if (listing[current_result].isnew) { - if (current_result == CURRENT_MAREA) { - current_selection = Top+i-1; // Get current place in box to display. - sprintf(capture, "\x1b[%i;%iH%s", Top+i-1, 1, listing[current_result].ansi_4.c_str()); - - } else if (current_result < (signed)listing.size()) { - sprintf(capture, "\x1b[%i;%iH%s", Top+i-1, 1, listing[current_result].ansi_3.c_str()); - } else - break; - } else { - if (current_result == CURRENT_MAREA) { - current_selection = Top+i-1; // Get current place in box to display. - sprintf(capture, "\x1b[%i;%iH%s", Top+i-1, 1, listing[current_result].ansi_2.c_str()); - - } else if (current_result < (signed)listing.size()) { - sprintf(capture, "\x1b[%i;%iH%s", Top+i-1, 1, listing[current_result].ansi_1.c_str()); - } else - break; - } - - ++current_result; - _editbox += capture; - - // if (CURRENT_MAREA+(i-2) == listing.size()) break; - //if (current_node->dn_link == 0) break; - //current_node = current_node->dn_link; - } - pipe2ansi((char *)_editbox.c_str()); -} - - -// Merging all 3 Functions into a single one that takes care of listings. -// No longer need Row up or Down, universal accross all Lists. -// Previous functions are only kept for references! - -/** - * New Faster Full Screen Interface for Lightbars and Lists - * This one fucntions does all start and pageup/down * And Handles jumping to different pages. */ void msg_readll::box_start_vector(unsigned long page, unsigned long list) @@ -1860,35 +1118,21 @@ void msg_readll::box_start_vector(unsigned long page, unsigned long list) // Now Grab as many lines as will fit in the box for (int i = 1; i < boxsize+1; i++) { if (((boxsize*Page)+i)-1 >= (signed)listing.size()) break; -// errlog((char *)"ulist_start_vector list+1, %i < (boxsize*CurrentPage)+i, %i Top+i-1 %i",list+1,(boxsize*Page)+i,Top+i-1); // If Area has new message rotate output to new lightbars. if (listing[((boxsize*Page)+i)-1].isnew) { -// if (listing[current_result].isnew) { - // if (current_result == list) { if ((signed)list+1 == (boxsize*Page)+i) { -// errlog((char *)"!!! isNEW = 'Y' 4"); - // Current Area current_selection = Top+i-1; // Get current place in box to display. sprintf(capture, "\x1b[%i;%iH%s", Top+i-1, 1, (char *)listing[((boxsize*Page)+i)-1].ansi_4.c_str()); -// errlog((char *)capture); } else { -// errlog((char *)"!!! isNEW = 'Y' 3"); sprintf(capture, "\x1b[%i;%iH%s", Top+i-1, 1, (char *)listing[((boxsize*Page)+i)-1].ansi_3.c_str()); -// errlog((char *)capture); } } else { if ((signed)list+1 == (boxsize*Page)+i) { -// if (current_result == list) { -// errlog((char *)"!!! isNEW = 'N' 2"); - // Current Area current_selection = Top+i-1; // Get current place in box to display. sprintf(capture, "\x1b[%i;%iH%s", Top+i-1, 1, (char *)listing[((boxsize*Page)+i)-1].ansi_2.c_str()); -// errlog((char *)capture); } else { -// errlog((char *)"!!! isNEW = 'N' 1"); sprintf(capture, "\x1b[%i;%iH%s", Top+i-1, 1, (char *)listing[((boxsize*Page)+i)-1].ansi_1.c_str()); -// errlog((char *)capture); } } @@ -1899,5 +1143,4 @@ void msg_readll::box_start_vector(unsigned long page, unsigned long list) sprintf(capture, "\x1b[%i;%iH", Row+Top-1, 1); _editbox += capture; pipe2ansi((char *)_editbox.c_str()); - } diff --git a/src/msg_readll.h b/src/msg_readll.h index fc3fbe9..51f1f0c 100755 --- a/src/msg_readll.h +++ b/src/msg_readll.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2004-2014 by Michael Griffin * + * Copyright (C) 2004-2017 by Michael Griffin * * mrmisticismo@hotmail.com * * * * Purpose: * @@ -12,12 +12,6 @@ * (at your option) any later version. * ***************************************************************************/ -// Enthral SVN: $Id: msg_readll.h 1 2014-03-29 07:30:21Z mercyful $ -// Source: $HeadURL: file:///home/merc/repo/enthral/trunk/src/msg_readll.h $ -// $LastChangedDate: 2014-03-29 02:30:21 -0500 (Sat, 29 Mar 2014) $ -// $LastChangedRevision: 1 $ -// $LastChangedBy: mercyful $ - # ifndef MSG_READLL_H # define MSG_READLL_H @@ -31,14 +25,11 @@ using namespace std; typedef struct msg_readll : private ConsoleIO { public: - // Main List for Holding All Data LineRec *head; LineRec *current_node; LineRec *last; AreaRec *node; - - // Passing Lightbars between Interfaces std::vector listing; int Row; @@ -81,11 +72,9 @@ typedef struct msg_readll : private ConsoleIO { // Copy message from link lists to buffer void stripCRONLY(char *ostr); - //char *GetBuffer(); void GetBuffer(std::string &tbuf); void GetVector(std::vector listb); - char *PopulateQuoter(); // Copy From buffer into Link List (UserSig) Clean @@ -108,13 +97,13 @@ typedef struct msg_readll : private ConsoleIO { void Last_Line(); void dispose(); void dispose_list(); - // Line Reader - old school scrolling. + char *parseReadColorScroller(char *cap,std::string data); char *parsereadcolors(char *cap,int row, int col, std::string data); - // Line Reader - old school scrolling. + void box_scroll_reader(); void box_pgdn_scroll(); - // Normal Lightbar... + void box_start(unsigned long CURRENT); // CURRENT = ARea MAREA or ULIST etc... void box_scrolldn(); void box_pgdn(); @@ -122,16 +111,6 @@ typedef struct msg_readll : private ConsoleIO { void box_refresh(unsigned long CURRENT); void box_overdraw(unsigned long CURRENT); - // New std::vector list parsing. - // Not in use - box_start_vector replaces all 3. - void box_pgup_vector(); - void box_scrolldn_vector(); - void box_pgdn_vector(); - - // Working Up and Down, need to add Scroll Down now. - //void box_start_vector(unsigned long CURRENT); // Area Listing. - - void box_start_vector(unsigned long page, unsigned long list); } msg_readll; diff --git a/src/msg_stats.cpp b/src/msg_stats.cpp index 3928a48..d9a295f 100755 --- a/src/msg_stats.cpp +++ b/src/msg_stats.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2004-2014 by Michael Griffin * + * Copyright (C) 2004-2017 by Michael Griffin * * mrmisticismo@hotmail.com * * * * Purpose: * @@ -12,12 +12,6 @@ * (at your option) any later version. * ***************************************************************************/ -// Enthral SVN: $Id: msg_stats.cpp 1 2014-03-29 07:30:21Z mercyful $ -// Source: $HeadURL: file:///home/merc/repo/enthral/trunk/src/msg_stats.cpp $ -// $LastChangedDate: 2014-03-29 02:30:21 -0500 (Sat, 29 Mar 2014) $ -// $LastChangedRevision: 1 $ -// $LastChangedBy: mercyful $ - # include "msg_stats.h" # include "struct.h" @@ -27,7 +21,7 @@ # include # include # include -# include // gcc 4.7 +# include using namespace std; @@ -36,7 +30,6 @@ using namespace std; */ int msg_stats::hist_lockSet(int onoff, char *area) { - std::string path = LOCKPATH; path += area; path += "_stats.lck"; @@ -53,7 +46,6 @@ int msg_stats::hist_lockSet(int onoff, char *area) if(stream == NULL) { stream = fopen(path.c_str(), "wb"); if(stream == NULL) { - //elog("Error history.lck!"); return FALSE; } else { fclose(stream); @@ -70,7 +62,6 @@ int msg_stats::hist_lockSet(int onoff, char *area) */ int msg_stats::hist_write(MsgStats *stats, char *area) { - std::string path = MESGPATH; path += area; path += ".sts"; @@ -81,7 +72,6 @@ int msg_stats::hist_write(MsgStats *stats, char *area) if(stream == NULL) { stream = fopen(path.c_str(), "wb"); if(stream == NULL) { - //elog("Error hist_write!"); hist_lockSet(FALSE,area); return x; } @@ -98,7 +88,6 @@ int msg_stats::hist_write(MsgStats *stats, char *area) */ int msg_stats::hist_read(MsgStats *stats, char *area) { - std::string path = MESGPATH; path += area; path += ".sts"; @@ -109,7 +98,6 @@ int msg_stats::hist_read(MsgStats *stats, char *area) if(stream == NULL) { stream=fopen(path.c_str(), "wb"); if(stream == NULL) { - //elog("Error hist_read!"); hist_lockSet(FALSE,area); return x; } diff --git a/src/msg_stats.h b/src/msg_stats.h index 93945c3..1d9e5ae 100755 --- a/src/msg_stats.h +++ b/src/msg_stats.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2004-2014 by Michael Griffin * + * Copyright (C) 2004-2017 by Michael Griffin * * mrmisticismo@hotmail.com * * * * Purpose: * @@ -12,12 +12,6 @@ * (at your option) any later version. * ***************************************************************************/ -// Enthral SVN: $Id: msg_stats.h 1 2014-03-29 07:30:21Z mercyful $ -// Source: $HeadURL: file:///home/merc/repo/enthral/trunk/src/msg_stats.h $ -// $LastChangedDate: 2014-03-29 02:30:21 -0500 (Sat, 29 Mar 2014) $ -// $LastChangedRevision: 1 $ -// $LastChangedBy: mercyful $ - # ifndef MSG_STATS_H # define MSG_STATS_H diff --git a/src/msg_title.cpp b/src/msg_title.cpp index 2439b5a..6bf646d 100755 --- a/src/msg_title.cpp +++ b/src/msg_title.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2004-2014 by Michael Griffin * + * Copyright (C) 2004-2017 by Michael Griffin * * mrmisticismo@hotmail.com * * * * Purpose: Message Title Full Screen Listing * @@ -12,12 +12,6 @@ * (at your option) any later version. * ***************************************************************************/ -// Enthral SVN: $Id: msg_title.cpp 1 2014-03-29 07:30:21Z mercyful $ -// Source: $HeadURL: file:///home/merc/repo/enthral/trunk/src/msg_title.cpp $ -// $LastChangedDate: 2014-03-29 02:30:21 -0500 (Sat, 29 Mar 2014) $ -// $LastChangedRevision: 1 $ -// $LastChangedBy: mercyful $ - # include "struct.h" # include "users.h" # include "language.h" @@ -31,7 +25,7 @@ # include # include # include -# include // Sort and Reverse +# include # include # include @@ -89,7 +83,6 @@ bool msgtitle_ini::mtitle_exists() */ void msgtitle_ini::mtitle_create() { - std::string name = INIPATH; name += sININAME; @@ -130,7 +123,6 @@ void msgtitle_ini::mtitle_chkpar(std::string &data) */ void msgtitle_ini::mtitle_check(std::string cfgdata) { - std::string::size_type id1 = 0; std::string temp = cfgdata; if (temp[0] == '#') return; @@ -204,27 +196,21 @@ void msgtitle_ini::mtitle_check(std::string cfgdata) */ int msgtitle_ini::mtitle_parse(int idx) { - if (!mtitle_exists()) { printf("Error unable to parse msgtitle.ini, check permissions!"); } - //mtitle_create(); - char name[355] = {0}; char name2[355] = {0}; - // Set for Theme, check idx number for Themeing,. sprintf(name, "%s%s",INIPATH,sININAME); sprintf(name2,"%s%s%i.ini",INIPATH,sININAME,idx); if (idx != 0) strcpy(name,name2); - // Check if Theme Exists, if not return FALSE. FILE *stream; stream = fopen(name,"rb+"); if(stream == NULL) { - // File is not Present return FALSE; } fclose(stream); @@ -246,7 +232,6 @@ int msgtitle_ini::mtitle_parse(int idx) return TRUE; } - /** * Start of Message Title Class */ @@ -255,8 +240,6 @@ msg_title::msg_title() tTop = 1; tBot = 1; CURRENT_BAR = 0; - - //CURRENT_BAR = 0; } /** @@ -264,7 +247,6 @@ msg_title::msg_title() */ void msg_title::ParseHeader(char *filename) { - std::string temp; std::string path = ANSIPATH; path += filename; @@ -272,7 +254,7 @@ void msg_title::ParseHeader(char *filename) mb_list_rec mr; - char MCI[3] = {0}; // Holds MCI Codes to Parse + char MCI[3] = {0}; char sTemp[255] = {0}; int space = 0, foundr = 0 , foundl = 0; @@ -280,16 +262,10 @@ void msg_title::ParseHeader(char *filename) // Reads in Ansi file into Buffer Only readinAnsi(filename, buff); - - /* NOTE - MAKE THIS THE USERLIST!!! - */ read_mbaselist(&mr, CURRENT_MAREA); std::string::size_type id1 = 0; while (id1 != std::string::npos) { - // parse justify spacing right / left passing in string before - // replacing mci code. to Properly Space Output Ansi. id1 = buff.find("%", 0); if (id1 == std::string::npos) break; memset(&MCI,0,sizeof(MCI)); @@ -297,28 +273,25 @@ void msg_title::ParseHeader(char *filename) // Check if MCI Code is Justified then Process this. if (buff[id1+3] == '{') { // Left Justify - //elog("left justify: %c%c",buff[id1+4],buff[id1+5]); - MCI[0] = buff[id1+4]; // Get first Digit - MCI[1] = buff[id1+5]; // Get Second Digit + MCI[0] = buff[id1+4]; + MCI[1] = buff[id1+5]; space = atoi(MCI); foundr = FALSE; foundl = TRUE; } else if (buff[id1+3] == '}') { // Right Justify - //elog("right justify: %c%c",buff[id1+4],buff[id1+5]); - MCI[0] = buff[id1+4]; // Get first Digit - MCI[1] = buff[id1+5]; // Get Second Digit + MCI[0] = buff[id1+4]; + MCI[1] = buff[id1+5]; space = atoi(MCI); - //elog("right justify: %i",space); foundl = FALSE; foundr = TRUE; } + // Now Get MCI Code - MCI[0] = buff[id1+1]; // Get first Digit - MCI[1] = buff[id1+2]; // Get Second Digit + MCI[0] = buff[id1+1]; + MCI[1] = buff[id1+2]; memset(&sTemp,0,sizeof(sTemp)); - // Insert MCI Parsing here so we can reaplace full result with propering spacing. if (strcmp(MCI,"M#") == 0) { sprintf(sTemp,"%lu", (ulong)CURRENT_MAREA+1); @@ -340,7 +313,7 @@ void msg_title::ParseHeader(char *filename) buff.replace(id1,6,sTemp): buff.replace(id1,3,sTemp); } - //elog("Finished Parsing MCI Codes..."); + pipe2ansi((char *)buff.c_str()); } @@ -349,18 +322,13 @@ void msg_title::ParseHeader(char *filename) */ void msg_title::SetupList(UserRec *user, int isPrivate) { - - // Still WIP, Need to update .ans pull from ini file. - // Use a different theme ansi for Public vs Private Title Scans (isPrivate) ? - sprintf(sININAME,"%s",(char *)"msgtitle_private.ini"): - sprintf(sININAME,"%s",(char *)"msgtitle_public.ini"); + sprintf(sININAME,"%s",(char *)"msgtitle_private.ini"): + sprintf(sININAME,"%s",(char *)"msgtitle_public.ini"); thisuser = user; - //this->start_session(thisuser); - // Check What Theme user has selected. if (mtitle_parse(thisuser->readertheme) == FALSE) { mtitle_parse(); @@ -369,20 +337,16 @@ void msg_title::SetupList(UserRec *user, int isPrivate) tBot = iBot; } - /** * Title Scan - Change ANSI Template Theme */ int msg_title::change_theme(int idx) { - // Check What Theme user has selected. if (mtitle_parse(idx) == FALSE) { - // Theme Doesn't Exist. return FALSE; } thisuser->readertheme = idx; - // Save User Settings. UserRec usr; usr = *thisuser; users _usr; @@ -408,35 +372,24 @@ vector< list_bar > msg_title::build_titlelist(vector< unsigned long > &elist) // std::vector result; //Set the default size of the vector - //The Fill each element with defaults result.reserve( elist.size() ); result.resize( elist.size() ); - ConsoleIO s(thisuser); // Pass User Incase there are MCI Codes for User Info. - -// WIP Private vs Public Title Scan Themes!! -// Need to check here for ini file and if private area, pull ansi filename -// from ini file!! Also need to fix hardcloded titlescan lightbars. - -// s . errlog((char *)" * build_titles * "); -// strcpy(sININAME,(char *)"msgtitle.ini"); + ConsoleIO s(thisuser); int c = 0; - //std::string temp = ""; std::string path = ""; std::string temp3 = ""; FILE *inStream; long idx = 1; long i = 0; -// long lr = 0; char MCI[3]= {0}; char temp2[100]= {0}; int space = 0; int foundr = FALSE; int foundl = FALSE; -// int reset = FALSE; std::string ans = ""; std::string ans1 = ""; @@ -444,19 +397,6 @@ vector< list_bar > msg_title::build_titlelist(vector< unsigned long > &elist) // std::string ans3 = ""; std::string ans4 = ""; - // Prefetch ansi lightbar themes - // These ansi are used as the light bars to be displayed, - // We rotate between 4 ansi lightbars. - // - // 1. Unread Messages - // 2. New Messages - // 3. Current Selection of Unread - // 4. Current Selection of New - // - // We cache array with all four choices so we can - // easily switch between them in the listing. - - path = ANSIPATH; path += "mtitlemid1.ans"; if ((inStream = fopen(path.c_str(), "r+")) == NULL) { @@ -527,49 +467,29 @@ vector< list_bar > msg_title::build_titlelist(vector< unsigned long > &elist) // ulong current_msg = 0; // Read Message Number ulong max_titles = elist.size(); - - // Get Last Read, to tell which are new. - // Not used yet, if we want to compile list of only new messages - // instead of entire message area, we should use num_titles = cnt - // instead of cnt = 0 on new scans only! - ulong cnt = JamAreaGetLast(thisuser->idx, &mr); - ulong num_titles = 0; + while(num_titles < max_titles) { if (num_titles == max_titles) break; current_msg = elist[num_titles]; - -// s . errlog2((char *)"build_titlelist current %lu, num %lu, max %lu", current_msg, num_titles, max_titles); - res = jamapi_readmsg(&mr, current_msg, &mm, areakind, thisuser); + if (res) { - - // Should get here anymore, deleted and not found messages are now skipped - // over when in the readmsg function above. - // Check return value, if messaege = NO_MESSAGE, then deleted, skip to next! // And there are more messages in this area. if (res == JAM_NO_MESSAGE && current_msg <= mm.HighWater) { - //++num_titles; - //continue; // Skip and goto next message -// errlog2((char *)" *** res == JAM_NO_MESSAGE && num_titles < mm.HighWater"); - MessageDeleted(&mm); // Populated Generic Deleted Message. + MessageDeleted(&mm); } else { - //++num_titles; - //continue; // Skip and goto next message -// errlog2((char *)" *** 2. ReadMsgArea: !jamapi_readmsg(&mr, thisuser->lastmsg %lu, &mm) ",thisuser->lastmsg); - MessageNotFound(&mm); // Populated Generic Deleted Message. + MessageNotFound(&mm); } } -// errlog((char *)"2 *** ReadMsgArea: Done, Populate mm2MsgInfo(); "); mm2MsgInfo(&mm); ans = ans2; // Display HighLight None. Current Selection ans = ans1; // Dispaly Lowlight None - ans = ans4; // Dispaly HighLight (New Messages) Current Selection ans = ans3; // Dispaly LowLight (New Messages) @@ -645,8 +565,6 @@ vector< list_bar > msg_title::build_titlelist(vector< unsigned long > &elist) // foundr = FALSE; } -// errlog((char *)" ### mm.Curm CurrentMsg, cnt, num_titles %lu, %lu, %lu, %lu) ",mm.CurrMsg,current_msg, cnt, num_titles); - // New Messages Setup count if (num_titles < cnt) { tbar.isnew = FALSE; } else { @@ -714,16 +632,6 @@ vector< list_bar > msg_title::build_titlelist(vector< unsigned long > &elist) // } temp3 += temp2; - /* - // New Messages Setup count - if (cnt == 0) { // no new - tbar.isnew = FALSE; - } - else { - tbar.isnew = TRUE; - }*/ - - //temp3 += temp2; } else { temp3 += c; temp3 += MCI; @@ -731,7 +639,6 @@ vector< list_bar > msg_title::build_titlelist(vector< unsigned long > &elist) // break; case '\n' : - // temp3 += '\r'; break; default : @@ -762,36 +669,18 @@ vector< list_bar > msg_title::build_titlelist(vector< unsigned long > &elist) // temp3.erase(); - } // End of (4) Look for each string. - - // Testing only! - // s . errlog((char *)"mbar: 1 %s",tbar . ansi_1.c_str()); - // s . errlog((char *)"mbar: 2 %s",tbar . ansi_2.c_str()); - // s . errlog((char *)"mbar: 3 %s",tbar . ansi_3.c_str()); - // s . errlog((char *)"mbar: 4 %s",tbar . ansi_4.c_str()); - - -// s . pipe2ansi((char *)tbar . ansi_1.c_str()); -// s . pipe2ansi((char *)tbar . ansi_2.c_str()); -// s . pipe2ansi((char *)tbar . ansi_3.c_str()); -// s . pipe2ansi((char *)tbar . ansi_4.c_str()); - - //s . startpause(); - + } + result[num_titles] = tbar; temp3.erase(); ++num_titles; ++idx; - } -// s . errlog((char *)"build_titles Done!"); -// s . errlog((char *)"Done, import - return result vector list"); return result; } - /** * Title Scan - Start Interface */ @@ -821,9 +710,7 @@ int msg_title::StartTitleList(int newscan, // Build Title Scan into Vector List vector result; - result = build_titlelist(elist); //, qry); - - // populate list with vector class + result = build_titlelist(elist); mLink.GetVector(result); std::string _output; @@ -839,41 +726,29 @@ int msg_title::StartTitleList(int newscan, std::string tmp; std::string::size_type id1 = 0; - // Passed From Reader. - // Current_BAR is the current light bar position in the list - // It's global to the entire class untill we exit back to the msg class. CURRENT_BAR = currmsg; - // Run through Main Reader Loop until exit from user - This Loop Probably not needed anymore. do { -// errlog((char *)"* 1. Msg_title Scan - thisuser->lastmsg %lu, CURRENT_BAR %lu",thisuser->lastmsg, CURRENT_BAR); - ParseHeader(sANSI_FILE); - // Jump to Current Page boxsize = mLink.Bot - mLink.Top; CurrentPage = CURRENT_BAR / boxsize; - // Make sure we have areas. if (result.size() > 0) { mLink.box_start_vector(CurrentPage, CURRENT_BAR); } else { - // No Messages, return. return EOF; } mLink.Tot = result.size(); do { -// errlog((char *)"3. title_start msg_title() while()"); -// errlog((char *)"4. *** title_start CurrentPage %lu, CURRENT_BAR %lu",CurrentPage, CURRENT_BAR); - _output.erase(); - _output = "|16"; // Clear Color Bleeding, reset background to black. + _output = "|16"; // Clear Color Bleeding more = false; showmore = false; - //if (mLink.line_count() > 0) more = true; + if (mLink.Page+1 != mLink.TotPages) more = true; // Show Down Arrow More! @@ -912,12 +787,9 @@ int msg_title::StartTitleList(int newscan, pipe2ansi((char *)_output.c_str()); - // Blank out the previous menu so we can reload, / redraw on restart. - //memset(&_mnuf._premenu,0,sizeof(_mnuf._premenu)); - // Make Msgqp2 Prompt Optional, Use if exists! // Also Let user Toggle on / off - if (_mnuf.cmdexist(sMENU_PROMPT2,0)) { /*&& thisuser->msgp2*/ + if (_mnuf.cmdexist(sMENU_PROMPT2,0)) { if ((more == TRUE) ||(mLink.Page > 1)) { _mnuf._curmenu.clear(); _mnuf._curmenu = sMENU_PROMPT2; @@ -930,7 +802,6 @@ int msg_title::StartTitleList(int newscan, _mnuf._curmenu = sMENU_PROMPT; } - JMPINPUT1: _mnuf.menu_readin(); @@ -940,7 +811,7 @@ int msg_title::StartTitleList(int newscan, strcpy(text,sINPUT_BOX); sprintf(outBuffer,"%d",mLink.Tot); - len = strlen(outBuffer)+1; // Last Ourbuf is Message Number + len = strlen(outBuffer)+1; memset(&text,0, sizeof(text)); strcpy(text,sINPUT_BOX); @@ -950,8 +821,6 @@ int msg_title::StartTitleList(int newscan, pipe2ansi((char *)_output.c_str()); -// errlog((char *)"* 5. Msg_title Scan - thisuser->lastmsg %lu, CURRENT_BAR %lu",thisuser->lastmsg, CURRENT_BAR); - _mnuf.menu_proc(mString, CURRENT_BAR); ch = mString[1]; @@ -967,9 +836,6 @@ int msg_title::StartTitleList(int newscan, case 'U': // Page Up if (CurrentPage != 0) { --CurrentPage; - - // Reset Bar to first Listing on each Page. - // CurrentPage = CURRENT_BAR / boxsize; CURRENT_BAR = CurrentPage * boxsize; mLink.box_start_vector(CurrentPage,CURRENT_BAR); } else @@ -979,9 +845,6 @@ int msg_title::StartTitleList(int newscan, case 'D': // Page Down if (CurrentPage+1 != mLink.TotPages) { ++CurrentPage; - - // Reset Bar to first Listing on each Page. - // CurrentPage = CURRENT_BAR / boxsize; CURRENT_BAR = CurrentPage * boxsize; mLink.box_start_vector(CurrentPage,CURRENT_BAR); } else @@ -991,9 +854,7 @@ int msg_title::StartTitleList(int newscan, // hit ENTER case 'E': // Read Selected Message mLink.dispose_list(); - vector() . swap(result); // Free Vector Up. - - // -3 Means to Read CURRENT_BAR. + vector() . swap(result); return -3; case '+': // Next Message - Move Down @@ -1002,19 +863,11 @@ int msg_title::StartTitleList(int newscan, goto JMPINPUT1; ++CURRENT_BAR; - -// PreviousPage = CurrentPage; - - //Calculate if we go down, ++Current Area, are we on next page or not. - // Becasue 0 Based, need to add +1 - // Test if we moved to next page. if ((signed)CURRENT_BAR+1 < (boxsize*(CurrentPage+1))+1) { // Still on Same Page if (mLink.listing[CURRENT_BAR-1].isnew) { - // Lowlight Current, then Highlight Next. sprintf(rBuffer, "\x1b[%i;%iH|16%s", mLink.current_selection, 1, (char *)mLink.listing[CURRENT_BAR-1].ansi_3.c_str()); } else { - // Lowlight Current, then Highlight Next. sprintf(rBuffer, "\x1b[%i;%iH|16%s", mLink.current_selection, 1, (char *)mLink.listing[CURRENT_BAR-1].ansi_1.c_str()); } @@ -1029,7 +882,7 @@ int msg_title::StartTitleList(int newscan, pipe2ansi((char *)_output.c_str()); _output.erase(); - goto JMPINPUT1; //Not moving down a page. + goto JMPINPUT1; } else { // Move to next Page! @@ -1038,21 +891,13 @@ int msg_title::StartTitleList(int newscan, break; } case '-': // Previous Messasge - Move Up - // Skipping to JMPINPUT bypasses redraws, much faster! if (CURRENT_BAR > 0 && mLink.listing.size() != 0) --CURRENT_BAR; else goto JMPINPUT1; -// PreviousPage = CurrentPage; - - //Calculate if we go down, --Current Area, are we on next page or not. - // Becasue 0 Based, need to add +1 - // Test if we moved to next page. if ((signed)CURRENT_BAR+1 > (boxsize*(CurrentPage))) { - // Still on Same Page - // Lowlight Current, then Highlight Next. if (mLink.listing[CURRENT_BAR+1].isnew) { sprintf(rBuffer, "\x1b[%i;%iH|16%s", mLink.current_selection, 1, (char *)mLink.listing[CURRENT_BAR+1].ansi_3.c_str()); } else { @@ -1072,44 +917,33 @@ int msg_title::StartTitleList(int newscan, goto JMPINPUT1; //Not moving down a page. } else { - // Move to next Page! --CurrentPage; mLink.box_start_vector(CurrentPage,CURRENT_BAR); - //goto JMPINPUT1; } break; case 'Q': // Quit Received, Hard Exit. mLink.dispose_list(); - vector() . swap(result); // Free Vector Up. + vector() . swap(result); return EOF; case '?': // Help FileAreaScan ( - - ansiPrintf(sANSI_HELP); // Display Ansi Help file, + ansiPrintf(sANSI_HELP); getkey(true); - ParseHeader(sANSI_FILE); // Redisplay Display Ansi + ParseHeader(sANSI_FILE); mLink.box_start_vector(CurrentPage,CURRENT_BAR); break; - - // Pass through, any functionaly that should - // Be handeled in Reader. - // to the Message Reader. ie post ,reply, delete... + default : - mLink.dispose_list(); - vector() . swap(result); // Free Vector Up. - - // Don't exit, just return with pass through command. - //CURRENT_BAR = EOF; + vector() . swap(result); return (char)toupper(ch); } } else if (mString[0] == '#') { - // received Digit Input From Menu Prompt memset(&rBuffer,0, sizeof(rBuffer)); memset(&text,0, sizeof(text)); strcpy(text,sINPUT_BOX); - //len = 14; + inputfield(text,len); pipe2ansi(text); sprintf(sNum,"%c",ch); @@ -1119,30 +953,24 @@ int msg_title::StartTitleList(int newscan, id1 = atoi(rBuffer); if (id1 > mLink.listing.size() || id1 < 1) { - // Redraw input box memset(&text,0, sizeof(text)); strcpy(text,sINPUT_BOX); - //len = 14; inputfield(text,len); pipe2ansi(text); goto JMPINPUT1; } else { CURRENT_BAR = id1-1; - - // Jump to Current Page CurrentPage = CURRENT_BAR / boxsize; - ParseHeader(sANSI_FILE); // Display Ansi + ParseHeader(sANSI_FILE); mLink.box_start_vector(CurrentPage,CURRENT_BAR); } } else { // End [#] // For Escaped Key Input - //startpause(); // Shouldn't get here... ch = mString[0]; switch (toupper(ch)) { case 'A': if (CurrentPage != 0) { --CurrentPage; - // Reset Bar to first Listing on each Page. CURRENT_BAR = CurrentPage * boxsize; mLink.box_start_vector(CurrentPage,CURRENT_BAR); } else @@ -1152,7 +980,6 @@ int msg_title::StartTitleList(int newscan, case 'B': if (CurrentPage+1 != mLink.TotPages) { ++CurrentPage; - // Reset Bar to first Listing on each Page. CURRENT_BAR = CurrentPage * boxsize; mLink.box_start_vector(CurrentPage,CURRENT_BAR); } else @@ -1160,13 +987,12 @@ int msg_title::StartTitleList(int newscan, break; default : - // Redraw and refresh listing. - vector() . swap(result); // Free Vector Up. + vector() . swap(result); tmp.erase(); - result = build_titlelist(elist); //, qry); + result = build_titlelist(elist); mLink.GetVector(result); - ParseHeader(sANSI_FILE); // Display Ansi + ParseHeader(sANSI_FILE); mLink.box_start_vector(CurrentPage,CURRENT_BAR); break; } // Switch ch diff --git a/src/msg_title.h b/src/msg_title.h index c4e21e9..8b0d8b8 100755 --- a/src/msg_title.h +++ b/src/msg_title.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2004-2014 by Michael Griffin * + * Copyright (C) 2004-2017 by Michael Griffin * * mrmisticismo@hotmail.com * * * * Purpose: * @@ -12,26 +12,18 @@ * (at your option) any later version. * ***************************************************************************/ -// Enthral SVN: $Id: msg_title.h 1 2014-03-29 07:30:21Z mercyful $ -// Source: $HeadURL: file:///home/merc/repo/enthral/trunk/src/msg_title.h $ -// $LastChangedDate: 2014-03-29 02:30:21 -0500 (Sat, 29 Mar 2014) $ -// $LastChangedRevision: 1 $ -// $LastChangedBy: mercyful $ - # ifndef MSG_TITLE_H # define MSG_TITLE_H # include "struct.h" -# include "mb_api.h" // Mainly for SESSION and i/o functions. +# include "mb_api.h" # include "msgs.h" # include # include # include -//# define ulong unsigned long - typedef struct msgtitle_ini { char sININAME[255]; @@ -70,8 +62,6 @@ typedef struct msgtitle_ini { class msg_title : private mbapi_jam, msgtitle_ini, msgs { - - //private: UserRec *thisuser; public: @@ -84,7 +74,7 @@ class msg_title : private mbapi_jam, msgtitle_ini, msgs msg_title(); std::vector - build_titlelist(vector &elist);//, Query &qry); + build_titlelist(vector &elist); void ParseHeader(char *filename); int change_theme(int idx); diff --git a/src/msgs.cpp b/src/msgs.cpp index 3f48b1e..d2656ba 100755 --- a/src/msgs.cpp +++ b/src/msgs.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2004-2014 by Michael Griffin * + * Copyright (C) 2004-2017 by Michael Griffin * * mrmisticismo@hotmail.com * * * * Purpose: Some Basic Message I/O Fuctions * @@ -12,12 +12,6 @@ * (at your option) any later version. * ***************************************************************************/ -// Enthral SVN: $Id: msgs.cpp 1 2014-03-29 07:30:21Z mercyful $ -// Source: $HeadURL: file:///home/merc/repo/enthral/trunk/src/msgs.cpp $ -// $LastChangedDate: 2014-03-29 02:30:21 -0500 (Sat, 29 Mar 2014) $ -// $LastChangedRevision: 1 $ -// $LastChangedBy: mercyful $ - # include "struct.h" # include "mb_api.h" # include "mb_jam.h" @@ -28,71 +22,19 @@ # include "msg_area.h" # include -# include // gcc 4.3 -# include // gcc 4.3 -# include // gcc 4.7 +# include +# include +# include # include using namespace std; -/* -int msgs::read_emaillist(EmailIdx *em, int recno) -{ - - int x = 0; - std::string path = DATAPATH; - path += "email.dat"; - - FILE *fptr = fopen(path.c_str(),"rb+"); - if(fptr == NULL) - { - fptr = fopen(path.c_str(), "wb"); - if(fptr == NULL) - { - perror("Error unable to read email.dat, check permissions!"); - return x; - } - } - - if(fseek(fptr,(int)recno*sizeof(EmailIdx),SEEK_SET)==0) - x=fread(em,sizeof(EmailIdx),1,fptr); - - fclose(fptr); - return(x); -} - -int msgs::save_emaillist(EmailIdx *em, int recno) -{ - - std::string path = DATAPATH; - path += "email.dat"; - - int x = 0; - FILE *stream = fopen(path.c_str(),"rb+"); - if(stream == NULL) - { - stream = fopen(path.c_str(), "wb"); - if(stream == NULL) - { - perror("Error unable to write email.dat, check permissions!"); - return x; - } - } - if(fseek(stream,(int)recno*sizeof(EmailIdx),SEEK_SET)==0) - x = fwrite(em,sizeof(EmailIdx),1,stream); - fclose(stream); - return x; -} -*/ - /** * Message Area File - Lock File */ int msgs::mbaselist_lockSet(int onoff) { - - std::string path = LOCKPATH; path += "msgforums.lck"; @@ -101,7 +43,6 @@ int msgs::mbaselist_lockSet(int onoff) return TRUE; } - //While lock file missing, create, or loop until it disapears. FILE *stream; while(1) { stream = fopen(path.c_str(),"rb+"); @@ -149,7 +90,6 @@ int msgs::read_mbaselist(mb_list_rec *mr, int rec) return(x); } - /** * Message Area File - Temp Holder When removing */ @@ -181,7 +121,6 @@ int msgs::save_mbasetemp(mb_list_rec *mr, int rec) return(x); } - /** * Message Area File - Save Message Area */ @@ -209,13 +148,11 @@ int msgs::save_mbaselist(mb_list_rec *mr, int rec) return x; } - /** * Message Area File - Count Message Areas */ int msgs::msg_count() { - int i = 0; mb_list_rec mb; @@ -234,7 +171,6 @@ int msgs::msg_count() */ int msgs::msg_find(char *tfile) { - string temp1, temp2; mb_list_rec mb; temp1 = (tfile); @@ -253,7 +189,6 @@ int msgs::msg_find(char *tfile) */ int msgs::jlr_lockSet(int onoff) { - std::string path = LOCKPATH; path += "ljr.lck"; @@ -262,7 +197,6 @@ int msgs::jlr_lockSet(int onoff) return TRUE; } - //While lock file missing, loop untill it disapears. FILE *stream; while(1) { stream = fopen(path.c_str(),"rb+"); @@ -273,7 +207,7 @@ int msgs::jlr_lockSet(int onoff) return FALSE; } else { fclose(stream); - return TRUE; // Created Lock File + return TRUE; } } fclose(stream); @@ -286,9 +220,7 @@ int msgs::jlr_lockSet(int onoff) */ int msgs::readlr(LastRead *lr, int idx, mb_list_rec *mb) { - char path[1024]= {0}; - //printf("%s%s.jlr", mb->mbpath, mb->mbfile); sprintf(path,"%s%s.jlr2", MESGPATH, (char *)mb->mbfile); jlr_lockSet(TRUE); @@ -314,7 +246,6 @@ int msgs::readlr(LastRead *lr, int idx, mb_list_rec *mb) */ int msgs::writelr(LastRead *lr, int idx, mb_list_rec *mb) { - char path[1024]= {0}; sprintf(path,"%s%s.jlr2", MESGPATH, (char *)mb->mbfile); jlr_lockSet(TRUE); @@ -347,7 +278,6 @@ int msgs::writelr(LastRead *lr, int idx, mb_list_rec *mb) */ ulong msgs::JamAreaGetLast(long usernum, mb_list_rec *mb) { - ConsoleIO _s; LastRead lr; @@ -369,43 +299,29 @@ ulong msgs::JamAreaGetLast(long usernum, mb_list_rec *mb) // Returns 0L for Nuttin, or Message Number of Matching MsgID. unsigned long ret; ret = buildmsgid(lr.MsgID,mb); - if (ret != 0) ++ret; // When we set, we minus 1, add it back now. + if (ret != 0) ++ret; return (ret); } - /** * Set is now done by MSGID, it's universal and unique, and holds better * If not found, default checks last Message Number as a backup. - * Forget.. ?!?! :-) - */ + */ void msgs::JamAreaSetLast(long usernum, long msgnum, mb_list_rec *mb) { - // Consider this branched off seperate, - // Now we need take the currnet message_index - // then we need to get the header with the MSGID. - // we then save the msgid that will be in crc32 into lr. MsgID - LastRead lr; memset(&lr,0,sizeof(LastRead)); std::string tmp; - // Get msg id.. - // Header_S.MsgIdCRC=JAM_Crc32(buf,strlen((char *)buf)); - - lr.RepID = msgnum; //original message # (Quick Searches) + lr.RepID = msgnum; lr.MsgID = (ulong)jamapi_readmsgid(mb, msgnum, tmp); - if (!writelr(&lr,usernum,mb)) { - // _s.errlog((char *)"JamAreaSetLast: lr.RepID CRC32 (%lu) lr.MsgID CRC32 (%lu)",lr.RepID,lr.MsgID); } } - - /** * Read Area and get Count of Total Messages * use elist = jamapi_build_public(&mr, thisuser); / Private @@ -419,20 +335,16 @@ unsigned long msgs::CountMsgs(unsigned long mbnum, UserRec *usr) // Get Public/Private status of currnet area read_mbaselist(&mb, mbnum); - // This procedure uses ja->active as real true count of total - // Live messages per area. return jamapi_countmsgs(&mb, usr); } - /** * Count new message from Area passed. * (Updated to work with new system) */ unsigned long msgs::CountNewMsgs(unsigned long mbnum, UserRec *usr) { - - ConsoleIO s(usr); // Pass User Incase there are MCI Codes for User Info. + ConsoleIO s(usr); mb_list_rec mr; @@ -444,8 +356,6 @@ unsigned long msgs::CountNewMsgs(unsigned long mbnum, UserRec *usr) unsigned long lastread = JamAreaGetLast(usr->idx, &mr); -// s.errlog2((char *)"CountNewMessages() mbnum %lu, msgcnt %lu, lastread %lu ",mbnum, msgcnt, lastread); - // No New Messages if (lastread >= msgcnt || msgcnt == 0) return 0; @@ -455,17 +365,16 @@ unsigned long msgs::CountNewMsgs(unsigned long mbnum, UserRec *usr) if (lastread < msgcnt) { return (msgcnt - lastread); } + return 0; } - /** * Counts New Mesages for All Areas (Includes Email) * (Updated to work with new system) */ unsigned long msgs::CountAllNewMsgs(UserRec *usr) { - ulong counter = 1; ulong msgcnt = 0; @@ -482,7 +391,6 @@ unsigned long msgs::CountAllNewMsgs(UserRec *usr) return(msgcnt); } - /** * New User, Reset all Last Reads Pointers to 0 * (Updated to work with new system) diff --git a/src/msgs.h b/src/msgs.h index 07b24cf..7de45b6 100755 --- a/src/msgs.h +++ b/src/msgs.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2004-2014 by Michael Griffin * + * Copyright (C) 2004-2017 by Michael Griffin * * mrmisticismo@hotmail.com * * * * Purpose: * @@ -12,12 +12,6 @@ * (at your option) any later version. * ***************************************************************************/ -// Enthral SVN: $Id: msgs.h 1 2014-03-29 07:30:21Z mercyful $ -// Source: $HeadURL: file:///home/merc/repo/enthral/trunk/src/msgs.h $ -// $LastChangedDate: 2014-03-29 02:30:21 -0500 (Sat, 29 Mar 2014) $ -// $LastChangedRevision: 1 $ -// $LastChangedBy: mercyful $ - # ifndef MSGS_H # define MSGS_H @@ -27,17 +21,9 @@ typedef struct msgs { - /* - int read_emaillist(EmailIdx *em, int recno); - int save_emaillist(EmailIdx *em, int recno); - */ - int mbaselist_lockSet(int onoff); - int read_mbaselist(mb_list_rec *mr, int recno); - int save_mbasetemp(mb_list_rec *mr, int recno); - int save_mbaselist(mb_list_rec *mr, int recno); int msg_count(); diff --git a/src/node.cpp b/src/node.cpp index 7ce8bbe..d17b98b 100755 --- a/src/node.cpp +++ b/src/node.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2004-2014 by Michael Griffin * + * Copyright (C) 2004-2017 by Michael Griffin * * mrmisticismo@hotmail.com * * * * Purpose: * @@ -12,19 +12,13 @@ * (at your option) any later version. * ***************************************************************************/ -// Enthral SVN: $Id: node.cpp 1 2014-03-29 07:30:21Z mercyful $ -// Source: $HeadURL: file:///home/merc/repo/enthral/trunk/src/node.cpp $ -// $LastChangedDate: 2014-03-29 02:30:21 -0500 (Sat, 29 Mar 2014) $ -// $LastChangedRevision: 1 $ -// $LastChangedBy: mercyful $ - # include "struct.h" # include "node.h" # include "conio.h" # include # include -# include // gcc 4.7 +# include using namespace std; @@ -33,7 +27,6 @@ using namespace std; */ int node::node_lockSet(int onoff) { - std::string path = LOCKPATH; path += "node.lck"; @@ -42,7 +35,6 @@ int node::node_lockSet(int onoff) return TRUE; } - //While lock file missing, create, or loop until it disapears. FILE *stream; while(1) { stream = fopen(path.c_str(),"rb+"); @@ -73,13 +65,11 @@ int node::node_remove(int nodenum) return TRUE; } - /** * Clear Node Folder and all Drop files */ int node::node_remove_dropfiles(int nodenum) { - char path[255]= {0}; sprintf(path,"rm -Rf %snode%i/*",NODEPATH,nodenum); system(path); @@ -91,7 +81,6 @@ int node::node_remove_dropfiles(int nodenum) */ int node::node_exists(int nodenum) { - char path[255]= {0}; sprintf(path,"%snode%i.dat",NODEPATH,nodenum); @@ -111,7 +100,7 @@ int node::node_socket_exists(int nodenum) { ConsoleIO s; char path[255]= {0}; - //sprintf(path,"%snode%i.dat",NODEPATH,nodenum); + snprintf(path, sizeof path, "%s/enthral_sock%d", ENTHRALTMP, nodenum); s.pipe2ansi(path); @@ -130,7 +119,6 @@ int node::node_socket_exists(int nodenum) */ int node::node_read(UserRec *user, int nodenum) { - char path[200]= {0}; sprintf(path,"%snode%i.dat",NODEPATH,nodenum); @@ -141,7 +129,6 @@ int node::node_read(UserRec *user, int nodenum) if(stream == NULL) { stream = fopen(path, "wb"); if(stream == NULL) { - //printf("Error creating callers"); node_lockSet(FALSE); return x; } @@ -159,7 +146,6 @@ int node::node_read(UserRec *user, int nodenum) */ int node::node_write(UserRec *user, int nodenum) { - char path[200]= {0}; sprintf(path,"%snode%i.dat",NODEPATH,nodenum); @@ -181,24 +167,19 @@ int node::node_write(UserRec *user, int nodenum) return x; } - - /** * Generic List of Whois Online */ void node::whoisonline() { - UserRec user; char buffer[255]= {0}; ConsoleIO s; s.ansiPrintf((char *)"whois"); - // Add config option for how many to display! for(int i = 1; i < 6; i++) { if (node_exists(i) == TRUE) { - // If Node Exists, Check for Socket, if Found get read user info. node_read(&user,i); snprintf(buffer, sizeof buffer, " |13%02d |15%-18s |07%-15s|CR", i, user.handle, user.usernote); s.pipe2ansi(buffer); diff --git a/src/node.h b/src/node.h index efd197e..1f64ac6 100755 --- a/src/node.h +++ b/src/node.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2004-2014 by Michael Griffin * + * Copyright (C) 2004-2017 by Michael Griffin * * mrmisticismo@hotmail.com * * * * Purpose: * @@ -12,12 +12,6 @@ * (at your option) any later version. * ***************************************************************************/ -// Enthral SVN: $Id: node.h 1 2014-03-29 07:30:21Z mercyful $ -// Source: $HeadURL: file:///home/merc/repo/enthral/trunk/src/node.h $ -// $LastChangedDate: 2014-03-29 02:30:21 -0500 (Sat, 29 Mar 2014) $ -// $LastChangedRevision: 1 $ -// $LastChangedBy: mercyful $ - # ifndef NODE_H # define NODE_H @@ -35,14 +29,6 @@ typedef struct node { void whoisonline(); - /* Not used in here, this is going on in conio now, - only calling node to get who's online. - - void node_message(); - void node_global_announce(char *nmsg); - void node_global_announce_login(); - void node_global_announce_logoff(); - */ } node; # endif diff --git a/src/pyenthral.cpp b/src/pyenthral.cpp index 8f46bc7..362a0b5 100755 --- a/src/pyenthral.cpp +++ b/src/pyenthral.cpp @@ -231,14 +231,6 @@ BOOST_PYTHON_MODULE(bbs_io) def("pyStartPause" , pyStartPause); } - - -//------------------------------------------------------------------------------ -// Name: main() -// Desc: Application's main entry point. -// Note: Scripts should import gc and call gc.collect() to free memory at end. -//------------------------------------------------------------------------------ - /* * Python Interface pass script and reference to user record. */ diff --git a/src/pyenthral.h b/src/pyenthral.h index aba5d43..3940f4b 100755 --- a/src/pyenthral.h +++ b/src/pyenthral.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2004-2014 by Michael Griffin * + * Copyright (C) 2004-2017 by Michael Griffin * * mrmisticismo@hotmail.com * * * * Purpose: * @@ -12,12 +12,6 @@ * (at your option) any later version. * ***************************************************************************/ -// Enthral SVN: $Id: pyenthral.h 1 2014-03-29 07:30:21Z mercyful $ -// Source: $HeadURL: file:///home/merc/repo/enthral/trunk/src/pyenthral.h $ -// $LastChangedDate: 2014-03-29 02:30:21 -0500 (Sat, 29 Mar 2014) $ -// $LastChangedRevision: 1 $ -// $LastChangedBy: mercyful $ - #ifndef PY_ENTHRAL_H #define PY_ENTHRAL_H @@ -27,12 +21,6 @@ using namespace std; -//------------------------------------------------------------------------------ -// Name: main() -// Desc: Application's main entry point. -//------------------------------------------------------------------------------ -//void main( void ) - void pybbs_run(std::string scripts, UserRec *usr); diff --git a/src/stamp.h b/src/stamp.h index 73d1512..d4f3729 100755 --- a/src/stamp.h +++ b/src/stamp.h @@ -1,13 +1,6 @@ #ifndef __STAMP_H__ #define __STAMP_H__ -// Enthral SVN: $Id: stamp.h 1 2014-03-29 07:30:21Z mercyful $ -// Source: $HeadURL: file:///home/merc/repo/enthral/trunk/src/stamp.h $ -// $LastChangedDate: 2014-03-29 02:30:21 -0500 (Sat, 29 Mar 2014) $ -// $LastChangedRevision: 1 $ -// $LastChangedBy: mercyful $ - - typedef unsigned bits; #ifndef SASC diff --git a/src/struct.h b/src/struct.h index 2079fae..dcd4ed3 100755 --- a/src/struct.h +++ b/src/struct.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2004-2014 by Michael Griffin * + * Copyright (C) 2004-2017 by Michael Griffin * * mrmisticismo@hotmail.com * * * * Purpose: Global Data Structures * @@ -12,31 +12,21 @@ * (at your option) any later version. * ***************************************************************************/ -// Enthral SVN: $Id: struct.h 10 2014-04-03 06:52:26Z merc $ -// Source: $HeadURL: file:///home/merc/repo/enthral/trunk/src/struct.h $ -// $LastChangedDate: 2014-04-03 01:52:26 -0500 (Thu, 03 Apr 2014) $ -// $LastChangedRevision: 10 $ -// $LastChangedBy: merc $ - # ifndef STRUCT_H # define STRUCT_H #include -#include // int32_t etc type for 32/64 Bit. +#include #include using namespace std; -# define BBSVERSION "Enthral BBS v.635" +# define BBSVERSION "Enthral BBS v.700" extern char OSSYSTEM[1024]; extern int UTF8Output; extern std::string screen_buffer; -//typedef uint32_t ulong; /* must be 32 bits wide */ // in -//typedef uint16_t ushort; /* must be 16 bits wide */ -//typedef uint8_t uchar; /* must be 8 bits wide */ - # define CTLLEN 1024 # define SPACE '\x20' @@ -118,7 +108,7 @@ extern char CLIENT_TERM[255]; extern char STARTUP_SCRIPT[255]; extern char STARTUP_SCRIPT2[255]; -extern int isANSI; // Detected and useing ANSI Terminal. +extern int isANSI; // Detected ANSI Terminal. extern int isANSIMATION; extern int TOGGLE_BACKSPACE; extern int PAUSE_SCROLING; // Used to Pause Scrolling Text during Node Messages / Notifications. @@ -131,8 +121,6 @@ extern struct termios old_termios; # define BitTst(arg,posn) BOOL((arg) & (1L << (posn))) # define BitFlp(arg,posn) ((arg) ^ (1L << (posn))) -//extern int TRUE; -//extern int FALSE; #define TRUE 1 #define FALSE 0 @@ -452,17 +440,6 @@ typedef struct __attribute__((packed)) JamIndex { } JamIndex; -/* -typedef struct __attribute__((packed)) MsgStats { - - uint32_t Views; // # of times message was viewed - uint32_t Replies; // # of Replies to this message - uint32_t Date; // Date Posted. - uint32_t From[40]; // Posted From - uint8_t Subj[90]; // Message Subject - -} MsgStats; */ - typedef struct __attribute__((packed)) NewScan { uint16_t set; // TRUE / FALSE if this area is to be scanned. @@ -482,20 +459,20 @@ typedef struct DataArea { typedef struct DataRec { - uint16_t idx; // Command #, Used Internal for Input Record #. + uint16_t idx; // Command #, Used Internal for Input Record #. std::string Desc; // # Description std::string Prompt; // # Text Prompt To Display on Input Commands. - uint32_t Size; // # Max Number of Chars on Input + uint32_t Size; // # Max Number of Chars on Input std::string CKeys; // # Accepted Input Keys std::string CmdType; // # Command Type std::string MString; // # Data to be Written {UserName} std::string MciCode; // # MCI Code in ANSI For this Field std::string HiString; // # LightBar High String std::string LoString; // # LightBar Low String - uint16_t Xcoord; // # X Coord of Lightbar - uint16_t Ycoord; // # Y Coord of Lightbar - uint16_t LBarCmd; // # Is This a Lightbar Command? - uint16_t MCICmd; // # Is This a MCI Code, Skip Input and Translate. + uint16_t Xcoord; // # X Coord of Lightbar + uint16_t Ycoord; // # Y Coord of Lightbar + uint16_t LBarCmd; // # Is This a Lightbar Command? + uint16_t MCICmd; // # Is This a MCI Code, Skip Input and Translate. } DataRec; diff --git a/src/user_list.cpp b/src/user_list.cpp index 87983bc..533232b 100755 --- a/src/user_list.cpp +++ b/src/user_list.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2004-2014 by Michael Griffin * + * Copyright (C) 2004-2017 by Michael Griffin * * mrmisticismo@hotmail.com * * * * Purpose: * @@ -12,12 +12,6 @@ * (at your option) any later version. * ***************************************************************************/ -// Enthral SVN: $Id: user_list.cpp 1 2014-03-29 07:30:21Z mercyful $ -// Source: $HeadURL: file:///home/merc/repo/enthral/trunk/src/user_list.cpp $ -// $LastChangedDate: 2014-03-29 02:30:21 -0500 (Sat, 29 Mar 2014) $ -// $LastChangedRevision: 1 $ -// $LastChangedBy: mercyful $ - # include "struct.h" # include "users.h" # include "language.h" @@ -42,7 +36,6 @@ using namespace std; */ bool usrlist_ini::usrl_exists() { - iTop = 0; iBot = 0; @@ -84,7 +77,6 @@ bool usrlist_ini::usrl_exists() */ void usrlist_ini::usrl_create() { - std::string name = INIPATH; name += sININAME; @@ -105,7 +97,6 @@ void usrlist_ini::usrl_create() */ void usrlist_ini::usrl_chkpar(std::string &data) { - std::string temp1; std::string::size_type st1 = 0; std::string::size_type st2 = 0; @@ -126,7 +117,6 @@ void usrlist_ini::usrl_chkpar(std::string &data) */ void usrlist_ini::usrl_check(std::string cfgdata) { - std::string::size_type id1 = 0; std::string temp = cfgdata; if (temp[0] == '#') return; @@ -200,11 +190,9 @@ void usrlist_ini::usrl_check(std::string cfgdata) */ int usrlist_ini::usrl_parse(int idx) { - if (!usrl_exists()) { perror("Error unable to parse userlst.ini, check permissions!"); } - //usrl_create(); char name[355]= {0}; char name2[355]= {0}; @@ -217,7 +205,7 @@ int usrlist_ini::usrl_parse(int idx) // Check if Theme Exists, if not return FALSE. FILE *stream; stream = fopen(name,"rb+"); - if(stream == NULL) { // File is not Present + if(stream == NULL) { return FALSE; } fclose(stream); @@ -245,7 +233,6 @@ int usrlist_ini::usrl_parse(int idx) */ usr_list::usr_list() { - tTop = 1; tBot = 1; CURRENT_ULIST = 0; @@ -256,58 +243,44 @@ usr_list::usr_list() */ void usr_list::ParseHeader(char *filename) { - - // std::string temp; std::string path = ANSIPATH; path += filename; path += ".ans"; mb_list_rec mr; - char MCI[3] = {0}; // Holds MCI Codes to Parse + char MCI[3] = {0}; char sTemp[255] = {0}; int space = 0, foundr = 0 , foundl = 0; -// int c = 0; std::string buff; - // Reads in Ansi file into Buffer Only readinAnsi(filename, buff); int id1 = 0; while (id1 != -1) { - // parse justify spacing right / left passing in string before - // replacing mci code. to Properly Space Output Ansi. id1 = buff.find("%", 0); if (id1 == -1) break; memset(&MCI,0,sizeof(MCI)); space = 0; // Check if MCI Code is Justified then Process this. if (buff[id1+3] == '{') { // Left Justify - //elog("left justify: %c%c",buff[id1+4],buff[id1+5]); - MCI[0] = buff[id1+4]; // Get first Digit - MCI[1] = buff[id1+5]; // Get Second Digit + MCI[0] = buff[id1+4]; + MCI[1] = buff[id1+5]; space = atoi(MCI); foundr = FALSE; foundl = TRUE; } else if (buff[id1+3] == '}') { // Right Justify - //elog("right justify: %c%c",buff[id1+4],buff[id1+5]); - MCI[0] = buff[id1+4]; // Get first Digit - MCI[1] = buff[id1+5]; // Get Second Digit + MCI[0] = buff[id1+4]; + MCI[1] = buff[id1+5]; space = atoi(MCI); - //elog("right justify: %i",space); foundl = FALSE; foundr = TRUE; } // Now Get MCI Code - MCI[0] = buff[id1+1]; // Get first Digit - MCI[1] = buff[id1+2]; // Get Second Digit + MCI[0] = buff[id1+1]; + MCI[1] = buff[id1+2]; memset(&sTemp,0,sizeof(sTemp)); - // Insert MCI Parsing here so we can reaplace full result with propering spacing. - // if (strcmp(MCI,"MA") == 0) { temp += mr.mbdisplay; } - // else - // if (strcmp(MCI,"TH") == 0) { temp += sTHEME_NAME; } - if (strcmp(MCI,"MA") == 0) { sprintf(sTemp,"%s", (char *)mr.mbdisplay); @@ -315,11 +288,6 @@ void usr_list::ParseHeader(char *filename) sprintf(sTemp,"%s", (char *)sTHEME_NAME); } - /* - if (strcmp(MCI,"TH") == 0) { - sprintf(sTemp,"#%i. %s",thisuser->readertheme+1,sTHEME_NAME); } - */ - // MCI Translation . if (foundl == TRUE) { lspacing(sTemp,space); @@ -329,10 +297,10 @@ void usr_list::ParseHeader(char *filename) //If we Parsed Justify, then Erase that MCI Code as well. (space != 0) ? - buff.replace(id1,6,sTemp): - buff.replace(id1,3,sTemp); + buff.replace(id1,6,sTemp): + buff.replace(id1,3,sTemp); } - //elog("Finished Parsing MCI Codes..."); + pipe2ansi((char *)buff.c_str()); } @@ -341,13 +309,13 @@ void usr_list::ParseHeader(char *filename) */ void usr_list::SetupList(UserRec *user) { - sprintf(sININAME,"%s",(char *)"usrlist.ini"); thisuser = user; - // Check What Theme user has selected. + if (usrl_parse(thisuser->readertheme) == FALSE) { usrl_parse(); } + tTop = iTop; tBot = iBot; } @@ -357,13 +325,13 @@ void usr_list::SetupList(UserRec *user) */ void usr_list::SetupEmailList(UserRec *user) { - sprintf(sININAME,"%s",(char *)"eusrlist.ini"); thisuser = user; - // Check What Theme user has selected. + if (usrl_parse(thisuser->readertheme) == FALSE) { usrl_parse(); } + tTop = iTop; tBot = iBot; } @@ -373,15 +341,11 @@ void usr_list::SetupEmailList(UserRec *user) */ int usr_list::change_theme(int idx) { - - // Check What Theme user has selected. if (usrl_parse(idx) == FALSE) { - // Theme Doesn't Exist. return FALSE; } thisuser->readertheme = idx; - // Save User Settings. UserRec usr; usr = *thisuser; users _usr; @@ -394,20 +358,16 @@ int usr_list::change_theme(int idx) return TRUE; } - /* * UserList FullScreen - Generate List of Users into a Vector */ vector< UserRec > usr_list::read_users() { - ConsoleIO s; UserRec urecord; std::vector< UserRec > result; -// s . errlog((char *)"read_users"); - - users _usr; // Class + users _usr; ulong idx = 0; while(_usr.users_read(&urecord,idx)) { @@ -419,22 +379,17 @@ vector< UserRec > usr_list::read_users() return result; } - /* * UserList FullScreen - Builder UserList LightBar Tempaltes */ vector< list_bar > usr_list::build_userlist(UserRec *usr, std::string &temp) //, Query &qry) { { - - UserRec urecord; - + UserRec urecord; list_bar ubar; std::vector result; std::vector ulist; - ConsoleIO s(usr); // Pass User Incase there are MCI Codes for User Info. - -// s . errlog((char *)" * build_users * "); + ConsoleIO s(usr); int email = FALSE; if (strcmp(sININAME,(char *)"eusrlist.ini") == 0) { @@ -442,26 +397,18 @@ vector< list_bar > usr_list::build_userlist(UserRec *usr, std::string &temp) / } int c = 0; - //std::string temp = ""; std::string path = ""; std::string temp3 = ""; temp.erase(); - FILE *inStream; long idx = 1; -// long cnt = 0; long i = 0; - // long usernum = 0; - // long lr = 0; - char MCI[3]= {0}; char temp2[100]= {0}; int space = 0; int foundr = FALSE; int foundl = FALSE; -// int reset = FALSE; -// int dont = FALSE; std::string ans = ""; std::string ans1 = ""; @@ -532,13 +479,6 @@ vector< list_bar > usr_list::build_userlist(UserRec *usr, std::string &temp) / ulong num_users = 0; ulong max_users = ulist.size(); - - // users _usr; // Class - // UserRec urec; - - //usernum = _usr.idx_count(); - //s . errlog((char *)"build_arealist basenum %lu", basenum); -// s . errlog((char *)"build_userlist max_areas %lu", max_users); usr->lastmsg = 0; while(user_cnt < (signed)max_users) { @@ -546,21 +486,16 @@ vector< list_bar > usr_list::build_userlist(UserRec *usr, std::string &temp) / if (num_users == max_users) break; urecord = ulist[num_users]; -// s . errlog((char *)"build_userlist urecord . idx %lu", urecord.idx); - ++num_users; ++idx; ans = ans2; // Display HighLight None. ans = ans1; // Dispaly Lowlight None - ans = ans4; // Dispaly HighLight (New Messages) ans = ans3; // Dispaly LowLight (New Messages) - -// reset = FALSE; + temp3.erase(); - for (int icnt = 0; icnt < 4; icnt++) { switch (icnt) { @@ -660,16 +595,6 @@ vector< list_bar > usr_list::build_userlist(UserRec *usr, std::string &temp) / } temp3 += temp2; - /* - // New Messages Setup count - if (cnt == 0) { // no new - mbar.isnew = FALSE; - } - else { - mbar.isnew = TRUE; - }*/ - - //temp3 += temp2; } else { temp3 += c; temp3 += MCI; @@ -677,7 +602,6 @@ vector< list_bar > usr_list::build_userlist(UserRec *usr, std::string &temp) / break; case '\n' : - // temp3 += '\r'; break; default : @@ -707,46 +631,24 @@ vector< list_bar > usr_list::build_userlist(UserRec *usr, std::string &temp) / break; } - //result . push_back(mbar); - //temp += temp3; temp3.erase(); } // End of (4) Look for each string. - /* - s . errlog((char *)"mbar: 1 %s",mbar . ansi_1.c_str()); - s . errlog((char *)"mbar: 2 %s",mbar . ansi_2.c_str()); - s . errlog((char *)"mbar: 3 %s",mbar . ansi_3.c_str()); - s . errlog((char *)"mbar: 4 %s",mbar . ansi_4.c_str()); - - - s . pipe2ansi((char *)mbar . ansi_1.c_str()); - s . pipe2ansi((char *)mbar . ansi_2.c_str()); - s . pipe2ansi((char *)mbar . ansi_3.c_str()); - s . pipe2ansi((char *)mbar . ansi_4.c_str()); - */ - //s . startpause(); - result . push_back(ubar); temp3.erase(); ++user_cnt; - //s . errlog((char *)"area_cnt: %i",area_cnt); - } - // Update Clear Screen -// s . errlog((char *)"build_users Done!"); -// s . errlog((char *)"Done, import - return result vector list"); + return result; } - /* * UserList FullScreen - Startup UserList / If Sysop, Can Select and Edit Users */ BOOL usr_list::StartUserEditor(ulong usernum) { - logon _logon; users _users; @@ -757,15 +659,11 @@ BOOL usr_list::StartUserEditor(ulong usernum) return TRUE; } - /* * UserList FullScreen - Start Interface. */ int usr_list::StartList(int email) { - - /// Difference Between Area List and Users, - /// Areas is 1 Based, Users = 0 Based!. bool more = FALSE; bool showmore = FALSE; char mString[10] = {0}; @@ -773,8 +671,6 @@ int usr_list::StartList(int email) std::string _output; char outBuffer[1024]= {0}; - // Startup Friend Classes - // language _lang; menu_func _mnuf; msg_readll mLink; @@ -789,42 +685,31 @@ int usr_list::StartList(int email) char text[1024]= {0}; char sNum[3]= {0}; std::string rBuff; - std::string::size_type id1 = 0; //id2, -// int num, num2; + std::string::size_type id1 = 0; int len; std::string tmp; // For Next / Prev Message Areas int CurrentPage = 0; -// int PreviousPage = 0; int bSize = 0; int boxsize = 0; bSize = tBot - tTop; ++bSize; -// int Page; -// int Tot; -// int TotPages; - CURRENT_ULIST = 0; vector result; -// errlog((char *)"Build UserList - UserID %lu, %lu",thisuser->idx, thisuser->handle); - result = build_userlist(thisuser, tmp); //, qry); - - //Send the Original Message into list Buffer - // Draw Message Inside of Box + result = build_userlist(thisuser, tmp); mLink.GetVector(result); - // Run through Main Reader Loop until exit from user - This Loop Probably not needed anymore. while (1) { if (email == TRUE) { - ParseHeader(sANSI_FILE); // Display Ansi + ParseHeader(sANSI_FILE); } else { - ParseHeader((char *)"ulist"); // UserList + ParseHeader((char *)"ulist"); } boxsize = mLink.Bot - mLink.Top; @@ -832,16 +717,12 @@ int usr_list::StartList(int email) // Make sure we have areas. if (result.size() > 0) { - // Update Here with new user list parsing code. - // mLink.PutBuffer((char *)tmp.c_str(), FALSE); // Send the Original Message into list Buffer -// errlog((char *)"ulbox_start usr_list"); - mLink.box_start_vector(CurrentPage,CURRENT_ULIST); // Draw Message Inside of Box + mLink.box_start_vector(CurrentPage,CURRENT_ULIST); } else { return 0L; } tmp.erase(); - //UserList(tmp); mLink.Tot = result.size(); while(1) { @@ -849,7 +730,6 @@ int usr_list::StartList(int email) _output = "|16"; more = false; showmore = false; - //if (mLink.line_count() > 0) more = true; if (mLink.Page+1 != mLink.TotPages) { more = true; } @@ -888,15 +768,11 @@ int usr_list::StartList(int email) sprintf(outBuffer,"%s%d",sMAX_AREAS,mLink.Tot); _output += outBuffer; - pipe2ansi((char *)_output.c_str()); - // Blank out the previous menu so we can reload, / redraw on restart. - //memset(&_mnuf._premenu,0,sizeof(_mnuf._premenu)); - // Make Msgqp2 Prompt Optional, Use if exists! // Also Let user Toggle on / off - if (_mnuf.cmdexist(sMENU_PROMPT2,0) /*&& thisuser->msgp2*/ ) { + if (_mnuf.cmdexist(sMENU_PROMPT2,0)) { if ((more == TRUE) ||(mLink.Page > 1)) { _mnuf._curmenu.clear(); _mnuf._curmenu = sMENU_PROMPT2; @@ -909,9 +785,6 @@ int usr_list::StartList(int email) _mnuf._curmenu = sMENU_PROMPT; } - -// user list stats won't change, -// cut off here to re-display faster JMPINPUT: // Draw Input Box @@ -928,7 +801,6 @@ int usr_list::StartList(int email) _mnuf.menu_proc(mString); ch = mString[1]; - //printf("\n01. CURRENT_ULIST %i, mLink.Tot %i, mLink.Page %i, mLink.TotPages %i", CURRENT_ULIST,mLink.Tot, mLink.Page,mLink.TotPages); // For Menu CmdKey Input if (mString[0] == '!') { switch (toupper(ch)) { @@ -937,121 +809,78 @@ int usr_list::StartList(int email) if (email == FALSE && isSysop == TRUE) { mLink.dispose_list(); - vector() . swap(result); // Free Vector Up. + vector() . swap(result); StartUserEditor(CURRENT_ULIST); tmp.erase(); // Get and Redisplay UserList - result = build_userlist(thisuser, tmp); //, qry); + result = build_userlist(thisuser, tmp); mLink.GetVector(result); - ParseHeader((char *)"ulist"); // UserList + ParseHeader((char *)"ulist"); CurrentPage = CURRENT_ULIST / boxsize; mLink.box_start_vector(CurrentPage,CURRENT_ULIST); break; } mLink.dispose_list(); - vector() . swap(result); // Free Vector Up. + vector() . swap(result); return CURRENT_ULIST; case 'Q': // Quit - mLink.dispose_list(); - vector() . swap(result); // Free Vector Up. - //_mnuf.~menu_func(); - return EOF; //qBuf; + vector() . swap(result); + return EOF; break; case 'U': // Page UP - if (CurrentPage != 0) { --CurrentPage; - - // Reset Bar to first Listing on each Page. - // CurrentPage = CURRENT_MAREA / boxsize; CURRENT_ULIST = CurrentPage * boxsize; - mLink.box_start_vector(CurrentPage,CURRENT_ULIST); } else goto JMPINPUT; break; case 'D': // Page Down - if (CurrentPage != mLink.TotPages-1) { ++CurrentPage; - - // Reset Bar to first Listing on each Page. - // CurrentPage = CURRENT_MAREA / boxsize; CURRENT_ULIST = CurrentPage * boxsize; - mLink.box_start_vector(CurrentPage,CURRENT_ULIST); } else goto JMPINPUT; break; case '+': // Next Area - Move Down - -// errlog((char *)"CURRENT_ULIST+1: %i. Listing: %i ", CURRENT_ULIST+1,mLink.listing.size()); if (CURRENT_ULIST+1 == (signed)mLink.listing.size() || (signed)mLink.listing.size() == 0) goto JMPINPUT; - ++CURRENT_ULIST; - //thisuser->lastmbarea = CURRENT_ULIST; - -// errlog((char *)"CurrentPage: %i. PreviousPage: %i ", CurrentPage, PreviousPage); -// errlog((char *)"boxsize: %i. TotPages: %i. Page: %i ", boxsize, mLink.TotPages, mLink.Page); -// PreviousPage = CurrentPage; - - //Calculate if we go down, ++Current Area, are we on next page or not. - // Becasue 0 Based, need to add +1 - // Test if we moved to next page. -// errlog((char *)"CURRENT_ULIST+1 %i < (boxsize*CurrentPage+1)+1, %i",CURRENT_ULIST+1,boxsize*(CurrentPage+1)+1); - //CurrentPage = CURRENT_ULIST / boxsize; - //errlog((char *)"CURRENT_ULIST+1 %i < (boxsize*CurrentPage+1)+1, %i",CURRENT_ULIST+1,boxsize*(CurrentPage+1)+1); if (CURRENT_ULIST+1 < (boxsize*(CurrentPage+1))+1) { - // Still on Same Page - if (mLink.listing[CURRENT_ULIST-1].isnew) { -// errlog((char *)"!!! isNEW = 'Y' 3"); -// errlog((char *)"CURRENT_ULIST-1 %i < (boxsize*CurrentPage+1)+1, %i",CURRENT_ULIST-1,boxsize*(CurrentPage+1)+1); - // Lowlight Current, then Highlight Next. sprintf(rBuffer, "\x1b[%i;%iH|16%s", mLink.current_selection, 1, (char *)mLink.listing[CURRENT_ULIST-1].ansi_3.c_str()); -// errlog((char *)rBuffer); } else { -// errlog((char *)"!!! isNEW = 'N' 1"); -// errlog((char *)"CURRENT_ULIST+1 %i < (boxsize*CurrentPage+1)+1, %i",CURRENT_ULIST+1,boxsize*(CurrentPage+1)+1); - // Lowlight Current, then Highlight Next. sprintf(rBuffer, "\x1b[%i;%iH|16%s", mLink.current_selection, 1, (char *)mLink.listing[CURRENT_ULIST-1].ansi_1.c_str()); -// errlog((char *)rBuffer); } _output += rBuffer; mLink.current_selection += 1; if (mLink.listing[CURRENT_ULIST].isnew) { -// errlog((char *)"!!! isNEW = 'Y' 4"); sprintf(rBuffer, "\x1b[%i;%iH|16%s", mLink.current_selection, 1, (char *)mLink.listing[CURRENT_ULIST].ansi_4.c_str()); -// errlog((char *)rBuffer); } else { -// errlog((char *)"!!! isNEW = 'N' 2"); sprintf(rBuffer, "\x1b[%i;%iH|16%s", mLink.current_selection, 1, (char *)mLink.listing[CURRENT_ULIST].ansi_2.c_str()); -// errlog((char *)rBuffer); } _output += rBuffer; pipe2ansi((char *)_output.c_str()); _output.erase(); goto JMPINPUT; //Not moving down a page. - } else { // CURRENT_ULIST+1 < (boxsize - // Move to next Page! -// errlog((char *)"DN - CURRENT_ULIST !< Move next Page"); + } else { ++CurrentPage; mLink.box_start_vector(CurrentPage,CURRENT_ULIST); break; } break; + case '-': // Previous Area - Move Up - // Skipping to JMPINPUT bypasses redraws, much faster! if (CURRENT_ULIST != 0) --CURRENT_ULIST; @@ -1061,72 +890,42 @@ int usr_list::StartList(int email) if (mLink.listing.size() == 0) goto JMPINPUT; - //thisuser->lastmbarea = CURRENT_ULIST; - -// errlog((char *)"!!! CurrentPage: %i. PreviousPage: %i ", CurrentPage, PreviousPage); -// errlog((char *)"boxsize: %i. TotPages: %i. Page: %i ", boxsize, mLink.TotPages, mLink.Page); -// PreviousPage = CurrentPage; - -// errlog((char *)"!!! CurrentPage: %i. PreviousPage: %i ", CurrentPage, PreviousPage); - //Calculate if we go down, --Current Area, are we on next page or not. - // Becasue 0 Based, need to add +1 // Test if we moved to next page. if (CURRENT_ULIST+1 > (boxsize*(CurrentPage))) { - // Still on Same Page - -// errlog((char *)"CURRENT_ULIST+1 %i > (boxsize*CurrentPage+1)+1, %i",CURRENT_ULIST+1, ((boxsize*CurrentPage)+1) ); - // Lowlight Current, then Highlight Next. if (mLink.listing[CURRENT_ULIST+1].isnew) { -// errlog((char *)"!!! isNEW = 'Y' 1"); sprintf(rBuffer, "\x1b[%i;%iH|16%s", mLink.current_selection, 1, (char *)mLink.listing[CURRENT_ULIST+1].ansi_3.c_str()); -// errlog((char *)rBuffer); } else { -// errlog((char *)"!!! isNEW = 'N' 3"); sprintf(rBuffer, "\x1b[%i;%iH|16%s", mLink.current_selection, 1, (char *)mLink.listing[CURRENT_ULIST+1].ansi_1.c_str()); -// errlog((char *)rBuffer); } _output = rBuffer; mLink.current_selection -= 1; if (mLink.listing[CURRENT_ULIST].isnew) { -// errlog((char *)"!!! isNEW = 'Y' 4"); sprintf(rBuffer, "\x1b[%i;%iH|16%s", mLink.current_selection, 1, (char *)mLink.listing[CURRENT_ULIST].ansi_4.c_str()); -// errlog((char *)rBuffer); } else { -// errlog((char *)"!!! isNEW = 'N' 2"); sprintf(rBuffer, "\x1b[%i;%iH|16%s", mLink.current_selection, 1, (char *)mLink.listing[CURRENT_ULIST].ansi_2.c_str()); -// errlog((char *)rBuffer); } _output += rBuffer; pipe2ansi((char *)_output.c_str()); _output.erase(); -// errlog((char *)"CurrentPage: %i. PreviousPage: %i ", CurrentPage, PreviousPage); -// errlog((char *)"boxsize: %i. TotPages: %i. Page: %i ", boxsize, mLink.TotPages, mLink.Page); goto JMPINPUT; //Not moving down a page. break; } else { - // Move to next Page! -// errlog((char *)"2!!!! UP - CURRENT_MAREA !< Move prev Page"); -// errlog((char *)"First CurrentPage: %i. PreviousPage: %i ", CurrentPage, PreviousPage); --CurrentPage; -// errlog((char *)"Now CurrentPage: %i. PreviousPage: %i ", CurrentPage, PreviousPage); -// errlog((char *)"boxsize: %i. TotPages: %i. Page: %i ", boxsize, mLink.TotPages, mLink.Page); - mLink.box_start_vector(CurrentPage,CURRENT_ULIST); - //goto JMPINPUT; } break; default : - vector() . swap(result); // Free Vector Up. + vector() . swap(result); tmp.erase(); - result = build_userlist(thisuser, tmp); //, qry); + result = build_userlist(thisuser, tmp); mLink.GetVector(result); if (email == TRUE) { ParseHeader(sANSI_FILE); // Display Ansi } else { - ParseHeader((char *)"ulist"); // UserList + ParseHeader((char *)"ulist"); } CurrentPage = CURRENT_ULIST / boxsize; mLink.box_start_vector(CurrentPage,CURRENT_ULIST); @@ -1145,13 +944,10 @@ int usr_list::StartList(int email) pipe2ansi(text); sprintf(sNum,"%c",ch); getline(rBuffer,len,sNum); -// num = 0; -// num2 = 0; + // Catch any invalid input id1 = atoi(rBuffer); - if (id1 > mLink.listing.size() || id1 < 1) { -// errlog((char *)"# - Incorrect Input"); // Redraw input box memset(&text,0, sizeof(text)); strcpy(text,sINPUT_BOX); @@ -1160,23 +956,15 @@ int usr_list::StartList(int email) pipe2ansi(text); goto JMPINPUT; } else { -// errlog((char *)"# - Jump to user id1 %i",id1); - //Justjump to area, then reset to page that area is in. CURRENT_ULIST = id1-1; - //thisuser->lastmbarea = CURRENT_ULIST; - - // Jump to Current Page CurrentPage = CURRENT_ULIST / boxsize; -// errlog((char *)"# - Jump to user box_start_vector - CurrentPage %i, CURRENT_ULIST %i", CurrentPage,CURRENT_ULIST); if (email == TRUE) { - ParseHeader(sANSI_FILE); // Display Ansi + ParseHeader(sANSI_FILE); } else { - ParseHeader((char *)"ulist"); // UserList + ParseHeader((char *)"ulist"); } mLink.box_start_vector(CurrentPage,CURRENT_ULIST); - - // mLink.box_start_vector(CurrentPage); } // End of [#] } else { // For Escaped Key Input @@ -1186,7 +974,6 @@ int usr_list::StartList(int email) case 'A': if (CurrentPage != 0) { --CurrentPage; - // Reset Bar to first Listing on each Page. CURRENT_ULIST = CurrentPage * boxsize; mLink.box_start_vector(CurrentPage,CURRENT_ULIST); } else @@ -1196,7 +983,6 @@ int usr_list::StartList(int email) case 'B': if (CurrentPage+1 != mLink.TotPages) { ++CurrentPage; - // Reset Bar to first Listing on each Page. CURRENT_ULIST = CurrentPage * boxsize; mLink.box_start_vector(CurrentPage,CURRENT_ULIST); } else @@ -1205,15 +991,15 @@ int usr_list::StartList(int email) default : // Redraw and refresh listing. - vector() . swap(result); // Free Vector Up. + vector() . swap(result); tmp.erase(); - result = build_userlist(thisuser, tmp); //, qry); + result = build_userlist(thisuser, tmp); mLink.GetVector(result); if (email == TRUE) { - ParseHeader(sANSI_FILE); // Display Ansi + ParseHeader(sANSI_FILE); } else { - ParseHeader((char *)"ulist"); // UserList + ParseHeader((char *)"ulist"); } CurrentPage = CURRENT_ULIST / boxsize; mLink.box_start_vector(CurrentPage,CURRENT_ULIST); diff --git a/src/user_list.h b/src/user_list.h index 64a426e..0fd2e27 100755 --- a/src/user_list.h +++ b/src/user_list.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2004-2014 by Michael Griffin * + * Copyright (C) 2004-2017 by Michael Griffin * * mrmisticismo@hotmail.com * * * * Purpose: * @@ -12,26 +12,16 @@ * (at your option) any later version. * ***************************************************************************/ -// Enthral SVN: $Id: user_list.h 1 2014-03-29 07:30:21Z mercyful $ -// Source: $HeadURL: file:///home/merc/repo/enthral/trunk/src/user_list.h $ -// $LastChangedDate: 2014-03-29 02:30:21 -0500 (Sat, 29 Mar 2014) $ -// $LastChangedRevision: 1 $ -// $LastChangedBy: mercyful $ - # ifndef USER_LIST_H # define USER_LIST_H -//# include - # include "struct.h" -# include "mb_api.h" // Mainly for SESSION and i/o functions. +# include "mb_api.h" # include "msgs.h" # include # include -//# define ulong unsigned long - typedef struct usrlist_ini { char sININAME[255]; @@ -69,22 +59,17 @@ typedef struct usrlist_ini { class usr_list : private mbapi_jam, usrlist_ini { - - //private: UserRec *thisuser; public: int tTop; int tBot; - // This holds the current user select in the list. int CURRENT_ULIST; - usr_list(); - std::vector read_users(); - std::vector build_userlist(UserRec *usr, std::string &temp);//, Query &qry); + std::vector build_userlist(UserRec *usr, std::string &temp); void ParseHeader(char *filename); int change_theme(int idx); diff --git a/src/users.cpp b/src/users.cpp index 1d56c84..72f21da 100755 --- a/src/users.cpp +++ b/src/users.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2004-2014 by Michael Griffin * + * Copyright (C) 2004-2017 by Michael Griffin * * mrmisticismo@hotmail.com * * * * Purpose: Basic User Data I/O * @@ -12,25 +12,15 @@ * (at your option) any later version. * ***************************************************************************/ -// Enthral SVN: $Id: users.cpp 1 2014-03-29 07:30:21Z mercyful $ -// Source: $HeadURL: file:///home/merc/repo/enthral/trunk/src/users.cpp $ -// $LastChangedDate: 2014-03-29 02:30:21 -0500 (Sat, 29 Mar 2014) $ -// $LastChangedRevision: 1 $ -// $LastChangedBy: mercyful $ - # include "users.h" # include "struct.h" -# include "conio.h" // testing. elog +# include "conio.h" # include # include -# include // gcc 4.3 -//# include // gcc 4.3 transform() (Doesn't work!) -//# include -//# include - +# include # include -# include // gcc 4.7 +# include using namespace std; @@ -39,7 +29,6 @@ using namespace std; */ int users::users_lockSet(int onoff) { - std::string path = LOCKPATH; path += "users.lck"; @@ -48,7 +37,6 @@ int users::users_lockSet(int onoff) return TRUE; } - //While lock file missing, create, or loop until it disapears. FILE *stream; while(1) { stream = fopen(path.c_str(),"rb+"); @@ -72,7 +60,6 @@ int users::users_lockSet(int onoff) */ int users::uidx_lockSet(int onoff) { - std::string path = LOCKPATH; path += "uidx.lck"; @@ -81,7 +68,6 @@ int users::uidx_lockSet(int onoff) return TRUE; } - //While lock file missing, loop untill it disapears. FILE *stream; while(1) { stream = fopen(path.c_str(),"rb+"); @@ -92,7 +78,7 @@ int users::uidx_lockSet(int onoff) return FALSE; } else { fclose(stream); - return TRUE; // Created Lock File + return TRUE; } } fclose(stream); @@ -105,7 +91,6 @@ int users::uidx_lockSet(int onoff) */ int users::users_writet(UserRec *usr, int idx) { - std::string path = DATAPATH; path += "users.tmp"; @@ -129,7 +114,6 @@ int users::users_writet(UserRec *usr, int idx) */ int users::users_write(UserRec *usr, int idx) { - std::string path = DATAPATH; path += "users.dat"; @@ -156,7 +140,6 @@ int users::users_write(UserRec *usr, int idx) */ int users::users_read(UserRec *usr, int idx) { - std::string path = DATAPATH; path += "users.dat"; @@ -186,7 +169,6 @@ int users::users_read(UserRec *usr, int idx) */ int users::idx_writet(UserIdx *usr, int idx) { - std::string path = DATAPATH; path += "uidx.tmp"; @@ -210,7 +192,6 @@ int users::idx_writet(UserIdx *usr, int idx) */ int users::idx_write(UserIdx *usr, int idx) { - std::string path = DATAPATH; path += "uidx.dat"; @@ -237,7 +218,6 @@ int users::idx_write(UserIdx *usr, int idx) */ int users::idx_read(UserIdx *usr, int idx) { - std::string path = DATAPATH; path += "uidx.dat"; @@ -267,7 +247,6 @@ int users::idx_read(UserIdx *usr, int idx) */ int users::idx_count() { - UserIdx usr; int i = 0; while(idx_read(&usr,i)) { @@ -284,22 +263,18 @@ int users::idx_count() */ int users::idx_find(char *name) { - UserIdx usr; int idx = 0; std::string temp1, temp2; temp1 = (name); - //move temp1 to lower case for testing! for (std::string::size_type i = 0; i < temp1.size(); ++i ) { temp1[i] = tolower( temp1[i] ); } while(idx_read(&usr,idx)) { temp2 = (char *)(usr.handle); - // transform(temp1.begin(),temp1.end(), temp1.begin(), tolower); - // transform(temp2.begin(),temp2.end(), temp2.begin(), tolower); for (std::string::size_type i = 0; i < temp2.size(); ++i ) { temp2[i] = tolower( temp2[i] ); } @@ -315,7 +290,6 @@ int users::idx_find(char *name) */ bool users::idx_match(char *name) { - int index =- 1; index = idx_find(name); if (index == -1) return false; @@ -327,13 +301,11 @@ bool users::idx_match(char *name) */ void users::idx_new(char *name, int idx) { - UserIdx usr; memset(&usr,0,sizeof(UserIdx)); strcpy((char *)usr.handle, name); usr.num = idx; idx_write(&usr,idx); - } /** @@ -341,7 +313,6 @@ void users::idx_new(char *name, int idx) */ bool users::check_password(char *name, char *pass) { - UserRec r; memset(&r,0,sizeof(UserRec)); int idx = 0; diff --git a/src/users.h b/src/users.h index 0e2ac66..e9acc99 100755 --- a/src/users.h +++ b/src/users.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2004-2014 by Michael Griffin * + * Copyright (C) 2004-2017 by Michael Griffin * * mrmisticismo@hotmail.com * * * * Purpose: Basic User Data I/O * @@ -12,12 +12,6 @@ * (at your option) any later version. * ***************************************************************************/ -// Enthral SVN: $Id: users.h 1 2014-03-29 07:30:21Z mercyful $ -// Source: $HeadURL: file:///home/merc/repo/enthral/trunk/src/users.h $ -// $LastChangedDate: 2014-03-29 02:30:21 -0500 (Sat, 29 Mar 2014) $ -// $LastChangedRevision: 1 $ -// $LastChangedBy: mercyful $ - # ifndef USERS_H # define USERS_H