|
|
1.1 root 1: /* putmsg.cpp */
2:
3: /* Synchronet message/menu display routine */
4:
1.1.1.2 ! root 5: /* $Id: putmsg.cpp,v 1.11 2004/10/27 22:02:08 rswindell Exp $ */
1.1 root 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: * *
1.1.1.2 ! root 11: * Copyright 2003 Rob Swindell - http://www.synchro.net/copyright.html *
1.1 root 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 HUGE16 *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:
1.1.1.2 ! root 57: attr_sp=0; /* clear any saved attributes */
1.1 root 58: tmpatr=curatr; /* was lclatr(-1) */
59: if(!(mode&P_SAVEATR))
60: attr(LIGHTGRAY);
1.1.1.2 ! root 61: if(mode&P_NOPAUSE)
! 62: sys_status|=SS_PAUSEOFF;
! 63: if(mode&P_HTML)
! 64: putcom("\x02\x02");
1.1 root 65: while(str[l] && (mode&P_NOABORT || !msgabort()) && online) {
1.1.1.2 ! root 66: if(str[l]==CTRL_A && str[l+1]!=0) {
1.1 root 67: if(str[l+1]=='"' && !(sys_status&SS_NEST_PF)) { /* Quote a file */
68: l+=2;
69: i=0;
70: while(i<12 && isprint(str[l]) && str[l]!='\\' && str[l]!='/')
71: tmp2[i++]=str[l++];
72: tmp2[i]=0;
73: sys_status|=SS_NEST_PF; /* keep it only one message deep! */
74: sprintf(tmp3,"%s%s",cfg.text_dir,tmp2);
75: printfile(tmp3,0);
1.1.1.2 ! root 76: sys_status&=~SS_NEST_PF;
! 77: }
1.1 root 78: else if(toupper(str[l+1])=='Z') /* Ctrl-AZ==EOF */
79: break;
80: else {
81: ctrl_a(str[l+1]);
1.1.1.2 ! root 82: l+=2;
! 83: }
! 84: }
1.1 root 85: else if((str[l]=='`' || str[l]=='�') && str[l+1]=='[') {
86: outchar(ESC); /* Convert `[ and �[ to ESC[ */
1.1.1.2 ! root 87: l++;
! 88: }
1.1 root 89: else if(cfg.sys_misc&SM_PCBOARD && str[l]=='@' && str[l+1]=='X'
90: && isxdigit(str[l+2]) && isxdigit(str[l+3])) {
91: sprintf(tmp2,"%.2s",str+l+2);
92: attr(ahtoul(tmp2));
93: exatr=1;
1.1.1.2 ! root 94: l+=4;
! 95: }
1.1 root 96: else if(cfg.sys_misc&SM_WILDCAT && str[l]=='@' && str[l+3]=='@'
97: && isxdigit(str[l+1]) && isxdigit(str[l+2])) {
98: sprintf(tmp2,"%.2s",str+l+1);
99: attr(ahtoul(tmp2));
100: // exatr=1;
1.1.1.2 ! root 101: l+=4;
! 102: }
1.1 root 103: else if(cfg.sys_misc&SM_RENEGADE && str[l]=='|' && isdigit(str[l+1])
104: && !(useron.misc&(RIP|WIP))) {
105: sprintf(tmp2,"%.2s",str+l+1);
106: i=atoi(tmp2);
1.1.1.2 ! root 107: if(i>=16) { /* setting background */
1.1 root 108: i-=16;
109: i<<=4;
1.1.1.2 ! root 110: i|=(curatr&0x0f); /* leave foreground alone */
! 111: }
1.1 root 112: else
113: i|=(curatr&0xf0); /* leave background alone */
114: attr(i);
115: exatr=1;
116: l+=2; /* Skip |x */
117: if(isdigit(str[l]))
1.1.1.2 ! root 118: l++; /* Skip second digit if it exists */
! 119: }
1.1 root 120: else if(cfg.sys_misc&SM_CELERITY && str[l]=='|' && isalpha(str[l+1])
121: && !(useron.misc&(RIP|WIP))) {
122: switch(str[l+1]) {
123: case 'k':
124: attr((curatr&0xf0)|BLACK);
125: break;
126: case 'b':
127: attr((curatr&0xf0)|BLUE);
128: break;
129: case 'g':
130: attr((curatr&0xf0)|GREEN);
131: break;
132: case 'c':
133: attr((curatr&0xf0)|CYAN);
134: break;
135: case 'r':
136: attr((curatr&0xf0)|RED);
137: break;
138: case 'm':
139: attr((curatr&0xf0)|MAGENTA);
140: break;
141: case 'y':
142: attr((curatr&0xf0)|YELLOW);
143: break;
144: case 'w':
145: attr((curatr&0xf0)|LIGHTGRAY);
146: break;
147: case 'd':
148: attr((curatr&0xf0)|BLACK|HIGH);
149: break;
150: case 'B':
151: attr((curatr&0xf0)|BLUE|HIGH);
152: break;
153: case 'G':
154: attr((curatr&0xf0)|GREEN|HIGH);
155: break;
156: case 'C':
157: attr((curatr&0xf0)|CYAN|HIGH);
158: break;
159: case 'R':
160: attr((curatr&0xf0)|RED|HIGH);
161: break;
162: case 'M':
163: attr((curatr&0xf0)|MAGENTA|HIGH);
164: break;
165: case 'Y': /* Yellow */
166: attr((curatr&0xf0)|YELLOW|HIGH);
167: break;
168: case 'W':
169: attr((curatr&0xf0)|LIGHTGRAY|HIGH);
170: break;
171: case 'S': /* swap foreground and background */
172: attr((curatr&0x07)<<4);
1.1.1.2 ! root 173: break;
! 174: }
1.1 root 175: exatr=1;
176: l+=2; /* Skip |x */
1.1.1.2 ! root 177: } /* Skip second digit if it exists */
! 178: else if(cfg.sys_misc&SM_WWIV && str[l]==CTRL_C && isdigit(str[l+1])) {
1.1 root 179: exatr=1;
180: switch(str[l+1]) {
181: default:
182: attr(LIGHTGRAY);
183: break;
184: case '1':
185: attr(CYAN|HIGH);
186: break;
187: case '2':
188: attr(BROWN|HIGH);
189: break;
190: case '3':
191: attr(MAGENTA);
192: break;
193: case '4':
1.1.1.2 ! root 194: attr(LIGHTGRAY|HIGH|BG_BLUE);
1.1 root 195: break;
196: case '5':
197: attr(GREEN);
198: break;
199: case '6':
200: attr(RED|HIGH|BLINK);
201: break;
202: case '7':
203: attr(BLUE|HIGH);
204: break;
205: case '8':
206: attr(BLUE);
207: break;
208: case '9':
209: attr(CYAN);
1.1.1.2 ! root 210: break;
! 211: }
! 212: l+=2;
! 213: }
1.1 root 214: else {
1.1.1.2 ! root 215: if(str[l]=='\n') {
1.1 root 216: if(exatr) /* clear at newline for extra attr codes */
217: attr(LIGHTGRAY);
1.1.1.2 ! root 218: if(l==0 || str[l-1]!='\r') /* expand sole LF to CR/LF */
! 219: outchar('\r');
1.1 root 220: }
221:
222: /* ansi escape sequence */
223: if(outchar_esc) {
224: if(str[l]=='A' || str[l]=='B' || str[l]=='H' || str[l]=='J'
225: || str[l]=='f' || str[l]=='u') /* ANSI anim */
226: lncntr=0; /* so defeat pause */
227: if(str[l]=='"') {
228: l++; /* don't pass on keyboard reassignment */
1.1.1.2 ! root 229: continue;
! 230: }
! 231: }
1.1 root 232: if(str[l]=='!' && str[l+1]=='|' && useron.misc&(RIP|WIP)) /* RIP */
233: lncntr=0; /* so defeat pause */
234: if(str[l]==ESC && str[l+1]=='$') /* WIP command */
235: lncntr=0;
236: if(str[l]=='@' && !(mode&P_NOATCODES)) {
1.1.1.2 ! root 237: i=show_atcode((char *)str+l); /* returns 0 if not valid @ code */
1.1 root 238: l+=i; /* i is length of code string */
239: if(i) /* if valid string, go to top */
1.1.1.2 ! root 240: continue;
! 241: }
! 242: if(str[l]!=CTRL_Z)
1.1 root 243: outchar(str[l]);
1.1.1.2 ! root 244: l++;
! 245: }
! 246: }
1.1 root 247: if(!(mode&P_SAVEATR)) {
248: console=orgcon;
1.1.1.2 ! root 249: attr(tmpatr);
! 250: }
! 251: if(mode&P_HTML)
! 252: putcom("\x02");
1.1 root 253:
1.1.1.2 ! root 254: attr_sp=0; /* clear any saved attributes */
1.1 root 255: /* Restore original settings of Forced Pause On/Off */
256: sys_status&=~(SS_PAUSEOFF|SS_PAUSEON);
257: sys_status|=(sys_status_sav&(SS_PAUSEOFF|SS_PAUSEON));
258: return(str[l]);
259: }
260:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.