diff --git a/src/sbbs3/con_hi.cpp b/src/sbbs3/con_hi.cpp index b51959f904a1343790689adb8f9d00f7dcd0640f..fb19c17af129b1d988f1659e68177b5468f6b6aa 100644 --- a/src/sbbs3/con_hi.cpp +++ b/src/sbbs3/con_hi.cpp @@ -37,65 +37,6 @@ #include "sbbs.h" -/****************************************************************************/ -/* Returns 1 if a is a valid ctrl-a code, 0 if it isn't. */ -/****************************************************************************/ -bool sbbs_t::validattr(char a) -{ - - switch(toupper(a)) { - case '-': /* clear */ - case '_': /* clear */ - case 'B': /* blue fg */ - case 'C': /* cyan fg */ - case 'G': /* green fg */ - case 'H': /* high fg */ - case 'I': /* blink */ - case 'K': /* black fg */ - case 'L': /* cls */ - case 'M': /* magenta fg */ - case 'N': /* normal */ - case 'P': /* pause */ - case 'R': /* red fg */ - case 'W': /* white fg */ - case 'Y': /* yellow fg */ - case '0': /* black bg */ - case '1': /* red bg */ - case '2': /* green bg */ - case '3': /* brown bg */ - case '4': /* blue bg */ - case '5': /* magenta bg */ - case '6': /* cyan bg */ - case '7': /* white bg */ - return(true); } - return(false); -} - -/****************************************************************************/ -/* Strips invalid Ctrl-Ax sequences from str */ -/* Returns number of ^A's in line */ -/****************************************************************************/ -int sbbs_t::stripattr(char *strin) -{ - char str[256]; - uint a,c,d,e; - - e=strlen(strin); - for(a=c=d=0;c<e && d<sizeof(str)-1;c++) { - if(strin[c]==CTRL_A && strin[c+1]!=0) { - a++; - if(!validattr(strin[c+1])) { - c++; - continue; - } - } - str[d++]=strin[c]; - } - str[d]=0; - strcpy(strin,str); - return(a); -} - /****************************************************************************/ /* Redraws str using i as current cursor position and l as length */ /****************************************************************************/ diff --git a/src/sbbs3/sbbs.h b/src/sbbs3/sbbs.h index 00a869b74d4180d87139aeb3ef366b97c5c785bb..0f713ca7178a88483d1abf33b288e91db4c96d11 100644 --- a/src/sbbs3/sbbs.h +++ b/src/sbbs3/sbbs.h @@ -482,8 +482,6 @@ public: uint uselect_total, uselect_num[500]; void riosync(char abortable); - bool validattr(char a); - int stripattr(char *str); void redrwstr(char *strin, int i, int l, long mode); void attr(int atr); /* Change local and remote text attributes */ void ctrl_a(char x); /* Peforms the Ctrl-Ax attribute changes */ @@ -777,6 +775,9 @@ extern "C" { DLLEXPORT char * DLLCALL strip_ctrl(char *str); DLLEXPORT char * DLLCALL net_addr(net_t* net); DLLEXPORT ushort DLLCALL crc16(char *str); + DLLEXPORT BOOL DLLCALL validattr(char a); + DLLEXPORT size_t DLLCALL strip_invalid_attr(char *str); + /* date_str.c */ DLLEXPORT char * DLLCALL zonestr(short zone); diff --git a/src/sbbs3/str_util.c b/src/sbbs3/str_util.c index 3d82379f30381976c67f0222aa10cbec2c2f8d59..2eb16ed4897771783b9eb672681ec1799772568e 100644 --- a/src/sbbs3/str_util.c +++ b/src/sbbs3/str_util.c @@ -390,3 +390,61 @@ ushort DLLCALL crc16(char *str) return(crc); } +/****************************************************************************/ +/* Returns 1 if a is a valid ctrl-a code, 0 if it isn't. */ +/****************************************************************************/ +BOOL validattr(char a) +{ + + switch(toupper(a)) { + case '-': /* clear */ + case '_': /* clear */ + case 'B': /* blue fg */ + case 'C': /* cyan fg */ + case 'G': /* green fg */ + case 'H': /* high fg */ + case 'I': /* blink */ + case 'K': /* black fg */ + case 'L': /* cls */ + case 'M': /* magenta fg */ + case 'N': /* normal */ + case 'P': /* pause */ + case 'R': /* red fg */ + case 'W': /* white fg */ + case 'Y': /* yellow fg */ + case '0': /* black bg */ + case '1': /* red bg */ + case '2': /* green bg */ + case '3': /* brown bg */ + case '4': /* blue bg */ + case '5': /* magenta bg */ + case '6': /* cyan bg */ + case '7': /* white bg */ + return(TRUE); + } + return(FALSE); +} + +/****************************************************************************/ +/* Strips invalid Ctrl-Ax sequences from str */ +/* Returns number of ^A's in line */ +/****************************************************************************/ +size_t strip_invalid_attr(char *strin) +{ + char str[1024]; + size_t a,c,d; + + for(a=c=d=0;strin[c] && d<sizeof(str)-1;c++) { + if(strin[c]==CTRL_A && strin[c+1]!=0) { + a++; + if(!validattr(strin[c+1])) { + c++; + continue; + } + } + str[d++]=strin[c]; + } + str[d]=0; + strcpy(strin,str); + return(a); +}