home *** CD-ROM | disk | FTP | other *** search
/ The Devil's Doorknob BBS Capture (1996-2003) / devilsdoorknobbbscapture1996-2003.iso / Dloads / WWIVMODS / MODSUNKN.ZIP / MSGQUOTE.MOD < prev    next >
Text File  |  1990-07-28  |  15KB  |  352 lines

  1. 91/100: Enhanced Message Quote Mod - Final Version
  2. Name: Goose #1 @7312
  3. Date: Sat Jul 21 09:48:50 1990
  4. From: The Twilight Zone [703-369-5225]
  5.  
  6.                       Enhanced Message Quoting Mod              (MSGQUOTE.MOD)
  7.                        by Goose, 1@7312 (WWIVnet)
  8.  
  9. This is *hopefully* the final version of this mod.  I've incorporated every
  10. change/fix that has been sent to me, so I think there's been enough testing.
  11. If you already have this mod installed, the only changes from the latest
  12. version I sent out are in void quote_message - so just replace the existing
  13. code with the one from here.  If you're starting from scratch, this file
  14. should be all you need.
  15.  
  16. =============================================================================
  17.  
  18. Many BBS software programs these days offer a "quoting" feature when replying
  19. messages, which provides a "> " at the beginning of each quoted line, plus
  20. provides the quoted text after it.  For example, you would see a message like:
  21.  
  22. ------------------------------------------------------------------------------
  23.  
  24. > How can I get rid of the DGROUP error in WWIV?  I've been modding my board
  25. > and now I get that whenever I recompile.
  26.  
  27. A DGROUP error means that you've run of out variable space in the board.....
  28.  
  29. ------------------------------------------------------------------------------
  30.  
  31. If you didn't already know what I was talking about, you should get the idea
  32. by now.  What happens when you quote is the old message is read in, a "> " is
  33. added to the beginning of each line, and you are put into the editor at the
  34. bottom of the current message.  There has been at least one other mod that has
  35. been released that is similar, but not quite as flexible as this one (it
  36. doesn't use the quote ">" indicator, which makes the message a little
  37. confusing, and it doesn't work with the internal editor).
  38.  
  39. OK, now for the first part of the mod.  Load up FCNS.H and make the following
  40. one line addition (- indicates existing code, + indicates new/modified code):
  41.  
  42. - void grab_user_name(messagerec *m, char *fn);
  43. - void quote_message(messagerec *m1, char *aux);             /* mod - add */
  44. - void scan(int msgnum, int optype, int *nextsub);
  45. - void qscan(int bn, int *ns);
  46.  
  47. Now, go into MSGBASE1.C and find the void scan(....), and read in the following
  48. code right before it.
  49.  
  50. + void quote_message(messagerec *m1, char *aux)     /* mod - add entire void */
  51. + {
  52. +   char *b,*c,s1[81];
  53. +   int cc,dq,lc,f,ok,mc;
  54. +   long l,l1,l2;
  55. +   messagerec m;
  56. +
  57. +   sprintf(s1,"%sINPUT.MSG",syscfg.tempdir);
  58. +   if (exist(s1))
  59. +     return;
  60. +   nl();
  61. +   prt(2,"Quote from message? ");
  62. +   if (!yn())
  63. +     return;
  64. +   m=*m1;
  65. +   b=readfile(&m,aux,&l);
  66. +   if ((c=malloca(l+1000))==NULL) {
  67. +     farfree(b);
  68. +     return;
  69. +   }
  70. +   lc=0; l1=0; l2=0; ok=1;
  71. +   do {
  72. +     if (b[l1]==10)
  73. +       lc++;
  74. +     l1++;
  75. +   } while (lc<2);
  76. +   lc=0; dq=1; cc=48;
  77. +   do {
  78. +     if (lc==0) {
  79. +       for (f=0; f<dq; f++) {
  80. +         c[l2++]='>'; lc++;
  81. +       }
  82. +       if (dq==1) {
  83. +         c[l2++]=' '; lc++;
  84. +       }
  85. +       if (cc!=48) {
  86. +         c[l2++]=3;
  87. +         c[l2++]=cc;
  88. +       }
  89. +     }
  90. +     switch(b[l1]) {
  91. +       case 3:
  92. +         l1++;
  93. +         cc=b[l1++];
  94. +         c[l2++]=3;
  95. +         c[l2++]=cc;
  96. +         break;
  97. +       case 1:
  98. +         if (b[l1-1]!=32)
  99. +           c[l2++]=' ';
  100. +         l1+=3;
  101. +         dq=1;
  102. +         break;
  103. +       case 13:
  104. +         lc=0;
  105. +         l1+=2;
  106. +         dq=1;
  107. +         while (b[l1]=='>') {
  108. +           dq++; l1++;
  109. +         }
  110. +         if (dq>=6)
  111. +           ok=0;
  112. +         if (dq==1) {
  113. +           cc=48;
  114. +           c[l2++]=3;
  115. +           c[l2++]=48;
  116. +         }
  117. +         c[l2++]=13;
  118. +         c[l2++]=10;
  119. +         break;
  120. +       default:
  121. +         c[l2++]=b[l1++];
  122. +         lc++;
  123. +         break;
  124. +     }
  125. +     if (dq==1)
  126. +       mc=72;
  127. +     else
  128. +       mc=78;
  129. +     if (lc>=mc) {
  130. +       while ((b[l1]!=32) && (lc>0)) {
  131. +         --l1; --l2; --lc;
  132. +         if (b[l1]==3) {
  133. +           lc+=2;
  134. +           l2++;
  135. +         }
  136. +         if (b[l1]==1) {
  137. +           l2+=3;
  138. +           lc+=3;
  139. +         }
  140. +       }
  141. +       if (lc==0) {
  142. +         l1+=mc;
  143. +         l2+=mc;
  144. +       } else {
  145. +         lc=0;
  146. +         l1++;
  147. +       }
  148. +       c[l2++]=13;
  149. +       c[l2++]=10;
  150. +     }
  151. +   } while (l1<l);
  152. +   c[l2++]=13;
  153. +   c[l2++]=10;
  154. +   if (ok) {
  155. +     sprintf(s1,"%sQUOTE.MSG",syscfg.tempdir);
  156. +     f=open(s1,O_RDWR | O_BINARY | O_CREAT | O_TRUNC, S_IREAD | S_IWRITE);
  157. +     write(f,(void *)c,l2);
  158. +     close(f);
  159. +     farfree(b);
  160. +     farfree(c);
  161. +     load_workspace(s1,0);
  162. +     unlink(s1);
  163. +   }
  164. + }
  165.  
  166. Now, in void scan(...), make the following changes:
  167.  
  168. -               case 'R':
  169. -                 optype=2;
  170. -                 break;
  171. -               case 'A':
  172. +                 quote_message(&(msgs[msgnum].msg),           /* mod - add */
  173. +                   (subboards[curlsub].filename));            /* mod - add */
  174. -                 if ((msgs[msgnum].ownersys) && (!msgs[msgnum].owneruser))
  175.  
  176. and a little farther down:
  177.  
  178. -               case 'W':
  179. +                 if (s[0]!='P')                               /* mod - add */
  180. +                   quote_message(&(msgs[msgnum].msg),         /* mod - add */
  181. +                     (subboards[curlsub].filename));          /* mod - add */
  182. -                 deleted_flag=0;
  183. -                 post();
  184. -                 if (deleted_flag && (deleted_flag<=msgnum))
  185.  
  186. Then, find void readmail(), and make the following changes:
  187.  
  188. -         case 'A':
  189. -         case 'S':
  190. -           if (!okmail)
  191. -             break;
  192. -           close(f);
  193. +           quote_message(&(m.msg),"EMAIL");                  /* mod - add */
  194. -           num_mail=((long) thisuser.feedbacksent) +
  195. -                    ((long) thisuser.emailsent) +
  196.  
  197. That's it for the quote itself.  It will work fine as long as the user has
  198. selected a full screen editor.  Unfortunately, many don't like to do this and
  199. instead stick with the internal editor in WWIV.  The next part of this mod
  200. allows the user to delete lines using the internal editor (which is necessary
  201. to be able to really use the quote feature), and allows the internal editor to
  202. be loaded from an external file.  Load up MSGBASE.C and find void
  203. load_workspace(...), then make the following change to allow editing of
  204. messages when using the internal editor:
  205.  
  206. -   strcat(s,"INPUT.MSG");
  207. -   i5=open(s,O_RDWR | O_CREAT | O_BINARY,S_IREAD | S_IWRITE);
  208. -   write(i5, (void *)b,l);
  209. -   close(i5);
  210. -   farfree(b);
  211. +   if (no_edit)                                             /* mod - change */
  212. -     use_workspace=1;
  213. -   else
  214. -     use_workspace=0;
  215.  
  216. Then go down to void inmsg(...), and add the variable declarations as shown.
  217. You can include them on the line with the other int variables if you want, I
  218. just figured it would be easier this way.
  219.  
  220. + int  i6,i7;                                                /* mod - add */
  221.  
  222. And if you haven't defined it in another mod, you'll have to add l2 as well:
  223.  
  224. + long l2;                                                   /* mod - add */
  225.  
  226. Then, go down a few lines and make the following change to correctly set the
  227. flag only if an external editor is selected:
  228.  
  229. -   strcat(fnx,"INPUT.MSG");
  230. -   if (fsed)
  231. -     fsed=1;
  232. +   if ((use_workspace) && (okfsed)) {                       /* mod - change */
  233. -     if (!exist(fnx))
  234.  
  235. And a few lines farther down, add the following code to read in the input file
  236. for the internal editor:
  237.  
  238. -     for (i=0; i<maxli; i++)
  239. -       lin[i*LEN]=0;
  240. -     ro[0]=0;
  241. +     if (exist(fnx)) {                                      /* mod - add */
  242. +       f=open(fnx,O_RDONLY | O_BINARY);                     /* mod - add */
  243. +       l1=filelength(f);                                    /* mod - add */
  244. +       if ((b=malloca(l1))!=NULL) {                         /* mod - add */
  245. +         read(f,(void *)b,l1);                              /* mod - add */
  246. +         i7=0; l2=0;                                        /* mod - add */
  247. +         do {                                               /* mod - add */
  248. +           if (b[l2]==13) {                                 /* mod - add */
  249. +             s[i7]=0;                                       /* mod - add */
  250. +             strcpy(&(lin[(curli++)*LEN]),s);               /* mod - add */
  251. +             ++l2;                                          /* mod - add */
  252. +             i7=0;                                          /* mod - add */
  253. +           } else                                           /* mod - add */
  254. +           if ((b[l2]!=10) && (b[l2]!=26)) {                /* mod - add */
  255. +             s[i7]=b[l2];                                   /* mod - add */
  256. +             ++i7;                                          /* mod - add */
  257. +           }                                                /* mod - add */
  258. +           ++l2;                                            /* mod - add */
  259. +         } while ((l2<l1) && (curli<maxli));                /* mod - add */
  260. +         farfree(b);                                        /* mod - add */
  261. +       }                                                    /* mod - add */
  262. +       close(f);                                            /* mod - add */
  263. +       unlink(fnx);                                         /* mod - add */
  264. +     }                                                      /* mod - add */
  265. -   }
  266. -
  267. -   nl();
  268. -   helpl=6;
  269.  
  270. And right before the loop to start inputting text (right after the title has
  271. been entered), add the following code to print out the quoted part of the
  272. message so the user knows what he's working with:
  273.  
  274. -     s[thisuser.screenchars]=0;
  275. -     pl(s);
  276. +     if (curli!=0) {                                            /* mod - add */
  277. +       i1=0; i2=0; i3=thisuser.screenchars;                     /* mod - add */
  278. +       for (i=0; (i<curli) && (!i2); i++) {                     /* mod - add */
  279. +         strcpy(s1,&(lin[i*LEN]));                              /* mod - add */
  280. +         if (s1[0]==2) {                                        /* mod - add */
  281. +           strcpy(s1,&(s1[1]));                                 /* mod - add */
  282. +           i7=0;                                                /* mod - add */
  283. +           for(i4=0; i4<strlen(s1); i4++)                       /* mod - add */
  284. +             if ((s1[i4]==8) || (s1[i4]==3))                    /* mod - add */
  285. +               --i7;                                            /* mod - add */
  286. +             else                                               /* mod - add */
  287. +               ++i7;                                            /* mod - add */
  288. +           for (i4=0; (i4<(i3-i7)/2) && (!i2); i4++)            /* mod - add */
  289. +             osan(" ",&i2,&i1);                                 /* mod - add */
  290. +         }                                                      /* mod - add */
  291. +         pla(s1,&i2);                                           /* mod - add */
  292. +       }                                                        /* mod - add */
  293. +       pl("Use /D to delete extra lines, or begin entering.."); /* mod - add */
  294. +     }                                                          /* mod - add */
  295. -
  296. -     while (!done) {
  297. -       helpl=27;
  298.  
  299. Then, about 150 lines down, add the following code to add the /D (delete)
  300. command for editing of the message:
  301.  
  302. -             pl("Replace:");
  303. -           } else {
  304. -             pl("Nothing to replace.");
  305. -           }
  306. -         }
  307. +         if ((stricmp(s,"/D")==0) && (curli>1)) {           /* mod - add */
  308. +           savel=0;                                         /* mod - add */
  309. +           sprintf(s1,"Delete from line 1-%d?",curli-1);    /* mod - add */
  310. +           prt(5,s1);                                       /* mod - add */
  311. +           input(s1,2);                                     /* mod - add */
  312. +           i7=atoi(s1);                                     /* mod - add */
  313. +           if (i7==curli-1)                                 /* mod - add */
  314. +             i6=i7;                                         /* mod - add */
  315. +           else {                                           /* mod - add */
  316. +             sprintf(s1,"through line %d-%d?",i7,curli-1);  /* mod - add */
  317. +             prt(5,s1);                                     /* mod - add */
  318. +             input(s1,2);                                   /* mod - add */
  319. +             i6=atoi(s1);                                   /* mod - add */
  320. +           }                                                /* mod - add */
  321. +           if ((i7>0) && (i6>=i7) && (i6<=curli-1)) {       /* mod - add */
  322. +             memmove(&lin[(i7-1)*LEN],&lin[(i6)*LEN],       /* mod - add */
  323. +               LEN*(curli-i6+1));                           /* mod - add */
  324. +             curli+=i7-i6-1;                                /* mod - add */
  325. +             pl("Line(s) deleted.  Continue entering...");  /* mod - add */
  326. +           } else                                           /* mod - add */
  327. +             pl("Nothing deleted.");                        /* mod - add */
  328. +         }                                                  /* mod - add */
  329. -         if (stricmp(s,"/TI")==0) {
  330. -           savel=0;
  331. -           helpl=26;
  332.  
  333. Update the menus to reflect the changes, and recompile the entire board (since
  334. FCNS.H has changed).  One thing about this mod...  since it removes the "soft
  335. returns" that allow messages to flow correctly if the user is set for 80
  336. columns, the quoted part of the message may look a little strange for these
  337. users.  Unfortunately, there was no easy way to accomplish this without forcing
  338. everyone to use this mod, so I guess some will just have to live with that.
  339. However, since most user do have 80 columns, it really shouldn't be much of a
  340. problem, but you might want to consider your user base before you decide to
  341. install this mod.  Also, if a message contains real ANSI codes it probably will
  342. come out strange looking if it is quoted.  The normal WWIV colors should be
  343. handled with no problems.
  344.  
  345. Tony "Goose" Geisler                   The Twilight Zone BBS
  346. 703-369-5225                           WWIVnet node @7312
  347. 300/1200/2400/9600/19.2K baud          USR HST modem (MNP level 5)
  348. An Official WWIV Support Board         WWIV Sysop Autovalidation
  349.  
  350.  
  351.  
  352.