home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 2 BBS / 02-BBS.zip / MSGDP206.SZH / MAINTMSG.C < prev    next >
Text File  |  1990-11-28  |  4KB  |  156 lines

  1. /*
  2.  
  3. Title:  Msged
  4.  
  5. File:   maintmsg.c
  6.  
  7. Author: Jim Nutt
  8.  
  9. Copr:   released into the PUBLIC DOMAIN 30 jul 1990 by jim nutt
  10.  
  11. Description:
  12.  
  13.     handles all message maintenance
  14.  
  15. */
  16.  
  17. #define TEXTLEN 80
  18.  
  19. #include "msged.h"
  20. #include "menu.h"
  21. #include "date.h"
  22.  
  23. extern int direction;
  24.  
  25. static char *formenu[] = {"Move Message","Copy Message","Forward Message",NULL};
  26.  
  27. void    _pascal deletemsg()
  28.  
  29. {
  30.     int     nto = 0;
  31.     int     nfrm = 0;
  32.     MSG    *from = NULL, *to = NULL;
  33.     int     n = arealist[area].current;
  34.  
  35.     if (message == NULL)
  36.         return;
  37.  
  38.     if (!confirm())
  39.         return;
  40.  
  41.     nto = message->replyto;
  42.     nfrm = message->replyfrom;
  43.  
  44.     if (nto)
  45.         to = msg_readheader(nto);
  46.  
  47.     if (to == NULL)
  48.         nto = 0;
  49.  
  50.     if (nfrm)
  51.         from = msg_readheader(nfrm);
  52.  
  53.     if (from == NULL)
  54.         nfrm = 0;
  55.     else
  56.         from->replyto = nto;
  57.  
  58.  
  59.     if (to != NULL)
  60.         to->replyfrom = nfrm;
  61.  
  62.     if (to) {
  63.         msg_writeheader(to);
  64.         dispose(to);
  65.         to = NULL;
  66.     }
  67.  
  68.     if (from) {
  69.         msg_writeheader(from);
  70.         dispose(from);
  71.         to = NULL;
  72.     }
  73.  
  74.     msg_delete(n);
  75.     arealist[area].messages = msg_scan(&arealist[area]);
  76.     if (direction == LEFT)
  77.         arealist[area].current = min(max(0,n-1),arealist[area].messages - 1);
  78.     else
  79.         arealist[area].current = min(n,arealist[area].messages - 1);
  80. }
  81.  
  82. void    _pascal movemsg()
  83. {
  84.     int     ch = 0;
  85.     int     to_area;
  86.     int     fr_area;
  87.     int     current = arealist[area].current;
  88.     char    sfn[TEXTLEN];
  89.     char    dfn[TEXTLEN];
  90.     time_t  now = time(NULL);
  91.  
  92.     msg_last(arealist[area]);
  93.  
  94.     for (;;) {
  95.         box((maxx/2)-9,(maxy/2)-2,(maxx/2)+8,(maxy/2)+2,1);
  96.         ch = menu((maxx/2)-8,(maxy/2)-1,(maxx/2)+7,(maxy/2)+1,
  97.               formenu,co_hilite,co_normal,0);
  98.  
  99.         switch (ch) {
  100.  
  101.             case 0: {
  102.                 int t = confirmations;
  103.                 confirmations = NO;
  104.                 deletemsg();
  105.                 confirmations = t;
  106.                 }
  107.             case 1:
  108.                 fr_area = area;
  109.                 area = to_area = selectarea();
  110.                 arealist[area].messages = msg_scan((&arealist[area]));
  111.                 arealist[area].new = 1;
  112.                 message->msgnum =  arealist[area].last + 1;
  113.                 message->new = 1;
  114.                 writemsg(message);
  115.                 area = fr_area;
  116.                 arealist[area].messages = msg_scan((&arealist[area]));
  117.                 arealist[to_area].new = 1;
  118.                 arealist[area].current =
  119.                     (current < arealist[area].messages)?current:arealist[area].current;
  120.                 return;
  121.  
  122.             case 2:
  123.                 message->msgnum = arealist[area].last + 1;
  124.                 message->attrib.sent = 0;
  125.                 message->attrib.recvd = 0;
  126.                 message->text = insline(message->text);
  127.                 message->text->text = strdup("\n");
  128.  
  129.                 sprintf(sfn," * Original to %s @ %s in %s\n",message->isto,
  130.                         (show_address(message->to))?show_address(message->to):show_address(thisnode),
  131.                         (arealist[area].echomail)?arealist[area].tag:"netmail");
  132.                 sprintf(dfn," * Forwarded %s by %s @ %s\n",atime(now),username,show_address(thisnode));
  133.  
  134.                 message->text = insline(message->text);
  135.                 message->text->text = strdup(dfn);
  136.  
  137.                 message->text = insline(message->text);
  138.                 message->text->text = strdup(sfn);
  139.  
  140.                 strset(message->isto,0);
  141.                 message->to.notfound = 1;
  142.  
  143.                 if ((editheader() == ABORT) && (confirm()))
  144.                     return;
  145.                 save(message);
  146.                 arealist[area].messages = msg_scan((&arealist[area]));
  147.                 arealist[area].current = current;
  148.                 return;
  149.  
  150.             case -1:    /* Escape */
  151.                 return;
  152.  
  153.         }
  154.     }
  155. }
  156.