|
|
1.1 ! root 1: /* putmsg.cpp */ ! 2: ! 3: /* Synchronet message/menu display routine */ ! 4: ! 5: /* $Id: putmsg.cpp,v 1.17 2006/02/08 00:47:11 rswindell Exp $ */ ! 6: ! 7: /**************************************************************************** ! 8: * @format.tab-size 4 (Plain Text/Source Code File Header) * ! 9: * @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) * ! 10: * * ! 11: * Copyright 2006 Rob Swindell - http://www.synchro.net/copyright.html * ! 12: * * ! 13: * This program is free software; you can redistribute it and/or * ! 14: * modify it under the terms of the GNU General Public License * ! 15: * as published by the Free Software Foundation; either version 2 * ! 16: * of the License, or (at your option) any later version. * ! 17: * See the GNU General Public License for more details: gpl.txt or * ! 18: * http://www.fsf.org/copyleft/gpl.html * ! 19: * * ! 20: * Anonymous FTP access to the most recent released source is available at * ! 21: * ftp://vert.synchro.net, ftp://cvs.synchro.net and ftp://ftp.synchro.net * ! 22: * * ! 23: * Anonymous CVS access to the development source and modification history * ! 24: * is available at cvs.synchro.net:/cvsroot/sbbs, example: * ! 25: * cvs -d :pserver:[email protected]:/cvsroot/sbbs login * ! 26: * (just hit return, no password is necessary) * ! 27: * cvs -d :pserver:[email protected]:/cvsroot/sbbs checkout src * ! 28: * * ! 29: * For Synchronet coding style and modification guidelines, see * ! 30: * http://www.synchro.net/source.html * ! 31: * * ! 32: * You are encouraged to submit any modifications (preferably in Unix diff * ! 33: * format) via e-mail to [email protected] * ! 34: * * ! 35: * Note: If this box doesn't appear square, then you need to fix your tabs. * ! 36: ****************************************************************************/ ! 37: ! 38: #include "sbbs.h" ! 39: ! 40: /****************************************************************************/ ! 41: /* Outputs a NULL terminated string locally and remotely (if applicable) */ ! 42: /* checking for message aborts, pauses, ANSI escape and ^A sequences. */ ! 43: /* Changes local text attributes if necessary. Max length of str is 4 gig */ ! 44: /* Returns the last char of the buffer access.. 0 if not aborted. */ ! 45: /* If P_SAVEATR bit is set in mode, the attributes set by the message */ ! 46: /* will be the current attributes after the message is displayed, otherwise */ ! 47: /* the attributes prior to diplaying the message are always restored. */ ! 48: /* Ignores Ctrl-Z's */ ! 49: /****************************************************************************/ ! 50: char sbbs_t::putmsg(char *str, long mode) ! 51: { ! 52: char tmpatr,tmp2[256],tmp3[128]; ! 53: uchar exatr=0; ! 54: int orgcon=console,i; ! 55: ulong l=0,sys_status_sav=sys_status; ! 56: long col=0; ! 57: ! 58: attr_sp=0; /* clear any saved attributes */ ! 59: tmpatr=curatr; /* was lclatr(-1) */ ! 60: if(!(mode&P_SAVEATR)) ! 61: attr(LIGHTGRAY); ! 62: if(mode&P_NOPAUSE) ! 63: sys_status|=SS_PAUSEOFF; ! 64: if(mode&P_HTML) ! 65: putcom("\x02\x02"); ! 66: while(str[l] && (mode&P_NOABORT || !msgabort()) && online) { ! 67: if(str[l]==CTRL_A && str[l+1]!=0) { ! 68: if(str[l+1]=='"' && !(sys_status&SS_NEST_PF)) { /* Quote a file */ ! 69: l+=2; ! 70: i=0; ! 71: while(i<12 && isprint(str[l]) && str[l]!='\\' && str[l]!='/') ! 72: tmp2[i++]=str[l++]; ! 73: tmp2[i]=0; ! 74: sys_status|=SS_NEST_PF; /* keep it only one message deep! */ ! 75: sprintf(tmp3,"%s%s",cfg.text_dir,tmp2); ! 76: printfile(tmp3,0); ! 77: sys_status&=~SS_NEST_PF; ! 78: } ! 79: else if(toupper(str[l+1])=='Z') /* Ctrl-AZ==EOF */ ! 80: break; ! 81: else { ! 82: ctrl_a(str[l+1]); ! 83: l+=2; ! 84: } ! 85: } ! 86: else if((str[l]=='`' || str[l]=='�') && str[l+1]=='[') { ! 87: outchar(ESC); /* Convert `[ and �[ to ESC[ */ ! 88: l++; ! 89: } ! 90: else if(cfg.sys_misc&SM_PCBOARD && str[l]=='@' && str[l+1]=='X' ! 91: && isxdigit(str[l+2]) && isxdigit(str[l+3])) { ! 92: sprintf(tmp2,"%.2s",str+l+2); ! 93: attr(ahtoul(tmp2)); ! 94: exatr=1; ! 95: l+=4; ! 96: } ! 97: else if(cfg.sys_misc&SM_WILDCAT && str[l]=='@' && str[l+3]=='@' ! 98: && isxdigit(str[l+1]) && isxdigit(str[l+2])) { ! 99: sprintf(tmp2,"%.2s",str+l+1); ! 100: attr(ahtoul(tmp2)); ! 101: // exatr=1; ! 102: l+=4; ! 103: } ! 104: else if(cfg.sys_misc&SM_RENEGADE && str[l]=='|' && isdigit(str[l+1]) ! 105: && isdigit(str[l+2]) && !(useron.misc&(RIP|WIP))) { ! 106: sprintf(tmp2,"%.2s",str+l+1); ! 107: i=atoi(tmp2); ! 108: if(i>=16) { /* setting background */ ! 109: i-=16; ! 110: i<<=4; ! 111: i|=(curatr&0x0f); /* leave foreground alone */ ! 112: } ! 113: else ! 114: i|=(curatr&0xf0); /* leave background alone */ ! 115: attr(i); ! 116: exatr=1; ! 117: l+=3; /* Skip |xx */ ! 118: } ! 119: else if(cfg.sys_misc&SM_CELERITY && str[l]=='|' && isalpha(str[l+1]) ! 120: && !(useron.misc&(RIP|WIP))) { ! 121: switch(str[l+1]) { ! 122: case 'k': ! 123: attr((curatr&0xf0)|BLACK); ! 124: break; ! 125: case 'b': ! 126: attr((curatr&0xf0)|BLUE); ! 127: break; ! 128: case 'g': ! 129: attr((curatr&0xf0)|GREEN); ! 130: break; ! 131: case 'c': ! 132: attr((curatr&0xf0)|CYAN); ! 133: break; ! 134: case 'r': ! 135: attr((curatr&0xf0)|RED); ! 136: break; ! 137: case 'm': ! 138: attr((curatr&0xf0)|MAGENTA); ! 139: break; ! 140: case 'y': ! 141: attr((curatr&0xf0)|YELLOW); ! 142: break; ! 143: case 'w': ! 144: attr((curatr&0xf0)|LIGHTGRAY); ! 145: break; ! 146: case 'd': ! 147: attr((curatr&0xf0)|BLACK|HIGH); ! 148: break; ! 149: case 'B': ! 150: attr((curatr&0xf0)|BLUE|HIGH); ! 151: break; ! 152: case 'G': ! 153: attr((curatr&0xf0)|GREEN|HIGH); ! 154: break; ! 155: case 'C': ! 156: attr((curatr&0xf0)|CYAN|HIGH); ! 157: break; ! 158: case 'R': ! 159: attr((curatr&0xf0)|RED|HIGH); ! 160: break; ! 161: case 'M': ! 162: attr((curatr&0xf0)|MAGENTA|HIGH); ! 163: break; ! 164: case 'Y': /* Yellow */ ! 165: attr((curatr&0xf0)|YELLOW|HIGH); ! 166: break; ! 167: case 'W': ! 168: attr((curatr&0xf0)|LIGHTGRAY|HIGH); ! 169: break; ! 170: case 'S': /* swap foreground and background */ ! 171: attr((curatr&0x07)<<4); ! 172: break; ! 173: } ! 174: exatr=1; ! 175: l+=2; /* Skip |x */ ! 176: } /* Skip second digit if it exists */ ! 177: else if(cfg.sys_misc&SM_WWIV && str[l]==CTRL_C && isdigit(str[l+1])) { ! 178: exatr=1; ! 179: switch(str[l+1]) { ! 180: default: ! 181: attr(LIGHTGRAY); ! 182: break; ! 183: case '1': ! 184: attr(CYAN|HIGH); ! 185: break; ! 186: case '2': ! 187: attr(BROWN|HIGH); ! 188: break; ! 189: case '3': ! 190: attr(MAGENTA); ! 191: break; ! 192: case '4': ! 193: attr(LIGHTGRAY|HIGH|BG_BLUE); ! 194: break; ! 195: case '5': ! 196: attr(GREEN); ! 197: break; ! 198: case '6': ! 199: attr(RED|HIGH|BLINK); ! 200: break; ! 201: case '7': ! 202: attr(BLUE|HIGH); ! 203: break; ! 204: case '8': ! 205: attr(BLUE); ! 206: break; ! 207: case '9': ! 208: attr(CYAN); ! 209: break; ! 210: } ! 211: l+=2; ! 212: } ! 213: else { ! 214: if(str[l]=='\n') { ! 215: if(exatr) /* clear at newline for extra attr codes */ ! 216: attr(LIGHTGRAY); ! 217: if(l==0 || str[l-1]!='\r') /* expand sole LF to CR/LF */ ! 218: outchar('\r'); ! 219: } ! 220: ! 221: /* ansi escape sequence */ ! 222: if(outchar_esc) { ! 223: if(str[l]=='A' || str[l]=='B' || str[l]=='H' || str[l]=='J' ! 224: || str[l]=='f' || str[l]=='u') /* ANSI anim */ ! 225: lncntr=0; /* so defeat pause */ ! 226: if(str[l]=='"') { ! 227: l++; /* don't pass on keyboard reassignment */ ! 228: continue; ! 229: } ! 230: } ! 231: if(str[l]=='!' && str[l+1]=='|' && useron.misc&(RIP|WIP)) /* RIP */ ! 232: lncntr=0; /* so defeat pause */ ! 233: if(str[l]==ESC && str[l+1]=='$') /* WIP command */ ! 234: lncntr=0; ! 235: if(str[l]=='@' && !(mode&P_NOATCODES)) { ! 236: i=show_atcode((char *)str+l); /* returns 0 if not valid @ code */ ! 237: l+=i; /* i is length of code string */ ! 238: if(i) /* if valid string, go to top */ ! 239: continue; ! 240: } ! 241: if(str[l]!=CTRL_Z) { ! 242: outchar(str[l]); ! 243: if(!exatr && !outchar_esc && lncntr && lbuflen && cols && ++col==cols) ! 244: lncntr++; ! 245: else ! 246: col=0; ! 247: } ! 248: l++; ! 249: } ! 250: } ! 251: if(!(mode&P_SAVEATR)) { ! 252: console=orgcon; ! 253: attr(tmpatr); ! 254: } ! 255: if(mode&P_HTML) ! 256: putcom("\x02"); ! 257: ! 258: attr_sp=0; /* clear any saved attributes */ ! 259: /* Restore original settings of Forced Pause On/Off */ ! 260: sys_status&=~(SS_PAUSEOFF|SS_PAUSEON); ! 261: sys_status|=(sys_status_sav&(SS_PAUSEOFF|SS_PAUSEON)); ! 262: return(str[l]); ! 263: } ! 264:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.