home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 2 BBS / 02-BBS.zip / msq31004.zip / MISC.C < prev    next >
C/C++ Source or Header  |  1995-07-13  |  4KB  |  222 lines

  1. /* misc.c
  2. **
  3. ** released into the PUBLIC DOMAIN 30 jul 1990 by jim nutt
  4. ** Changes released into the PUBLIC DOMAIN 10 jul 1994 by John Dennis
  5. **
  6. ** Miscilaneous extra functions & stuff tacked on :-)
  7. */
  8.  
  9. #define TEXTLEN 80
  10.  
  11. #include "msged.h"
  12. #include "menu.h"
  13. #include "date.h"
  14. #include "main.h"
  15. #include "dialogs.h"
  16. #include "help.h"
  17. #include "nshow.h"
  18.  
  19. void  change_curr_addr()
  20. {
  21.     int  ch  = 0;
  22.     int  num = 0;
  23.     int  x1, y1, x2, y2;
  24.     char line[TEXTLEN];
  25.     char **addrch = NULL;
  26.  
  27.     if (SW->aliascount < 2)
  28.     {
  29.         return;
  30.     }
  31.  
  32.     if ((addrch = calloc(SW->aliascount + 2, sizeof(char *))) == NULL)
  33.     {
  34.         return;
  35.     }
  36.  
  37.     for (; num < SW->aliascount; num++)
  38.     {
  39.         sprintf(line, "%-20.20s", show_address(&alias[num]));
  40.         if ((addrch[num] = strdup(line)) == NULL) {
  41.             break;
  42.         }
  43.     }
  44.  
  45.     addrch[num] = NULL;
  46.  
  47.     x1 = (maxx/2)-11;
  48.     x2 = (maxx/2)+11;
  49.     y1 = 8;
  50.     y2 = (num > maxy - 1) ? maxy - 1 : y1 + num + 1;
  51.  
  52.     ch = DoMenu(x1+1, y1+1, x2-1, y2-1, addrch, 0);
  53.  
  54.     switch (ch)
  55.     {
  56.         case -1 : break;
  57.         default :
  58.             CurArea.addr = alias[ch];
  59.             ShowNewArea();
  60.             ShowMsgHeader(message);
  61.             break;
  62.     }
  63.  
  64.     for (num = 0; num < SW->aliascount; num++)
  65.     {
  66.          free(addrch[num]);
  67.     }
  68.     free(addrch);
  69.     return;
  70. }
  71.  
  72. void  change_nodelist(void)
  73. {
  74.     int  ch  = 0;
  75.     int  num = 0;
  76.     int  x1, y1, x2, y2;
  77.     char line[TEXTLEN];
  78.     char **nodls = NULL;
  79.  
  80.     if (SW->nodelists < 2)
  81.     {
  82.         return;
  83.     }
  84.  
  85.     if ((nodls = calloc(SW->nodelists + 2, sizeof(char *))) == NULL)
  86.     {
  87.         return;
  88.     }
  89.  
  90.     for (; num < SW->nodelists; num++)
  91.     {
  92.         sprintf(line, "%-20.20s", node_lists[num].name);
  93.         if ((nodls[num] = strdup(line)) == NULL) {
  94.             break;
  95.         }
  96.     }
  97.  
  98.     nodls[num] = NULL;
  99.  
  100.     x1 = (maxx/2)-11;
  101.     x2 = (maxx/2)+11;
  102.     y1 = 8;
  103.     y2 = (num > maxy - 1) ? maxy - 1 : y1 + num + 1;
  104.  
  105.     ch = DoMenu(x1+1, y1+1, x2-1, y2-1, nodls, 0);
  106.  
  107.     switch (ch)
  108.     {
  109.         case -1 :
  110.             break;
  111.         default :
  112.             ST->nodebase = node_lists[ch].base_name;
  113.             ST->sysop    = node_lists[ch].sysop;
  114.             break;
  115.     }
  116.  
  117.     for (num = 0; num < SW->nodelists; num++)
  118.     {
  119.          free(nodls[num]);
  120.     }
  121.     free(nodls);
  122.     return;
  123. }
  124.  
  125. void  change_username(void)
  126. {
  127.     int x1, y1, x2, y2, len = 0;
  128.     int i, j, ch;
  129.     char *list[11];
  130.  
  131.     if (user_list[1].name == NULL)
  132.         return;
  133.  
  134.     for (i = 0; i < 11; i++)
  135.     {
  136.         if (user_list[i].name == NULL)
  137.             break;
  138.  
  139.         list[i] = strdup(user_list[i].name);
  140.  
  141.         if ((j = strlen(list[i])) >= len)
  142.         {
  143.             len = j;
  144.         }
  145.  
  146.         if (j >= maxx - 2)
  147.             *(list[i] + maxx - 4) = '\0';
  148.     }
  149.  
  150.     list[i] = NULL;
  151.  
  152.     if (len >= maxx - 2)
  153.         len = maxx - 4;
  154.  
  155.     x1 = (maxx/2) - (len/2) - 1;
  156.     x2 = (maxx/2) + (len/2) + 1;
  157.     y1 = 7;
  158.     y2 = y1 + i + 1;
  159.  
  160.     ch = DoMenu(x1+1, y1+1, x2-1, y2-1, list, 0);
  161.  
  162.     switch (ch)
  163.     {
  164.         case -1 : break;
  165.         default :
  166.             release(ST->username);
  167.             ST->username = strdup(user_list[ch].name);
  168.  
  169.             release(ST->lastread);
  170.             if (user_list[ch].lastread != NULL)
  171.             {
  172.                 ST->lastread = strdup(user_list[ch].lastread);
  173.             }
  174.             else
  175.                 ST->lastread = strdup(user_list[0].lastread);
  176.  
  177.             SW->useroffset = user_list[ch].offset;
  178.             break;
  179.     }
  180.     i = 0;
  181.     while (list[i])
  182.     {
  183.         free(list[i++]);
  184.     }
  185. }
  186.  
  187. void  set_switch(void)
  188. {
  189.     WND *hCurr, *hWnd;
  190.     int ret;
  191.  
  192.     ReadSettings();
  193.  
  194.     hCurr = Wtop();
  195. //    hWnd  = WPopUp(52, 16, INSBDR|SHADOW, cm[DL_BTXT], cm[DL_WTXT]);
  196.     hWnd  = WPopUp(52, 17, INSBDR|SHADOW, cm[DL_BTXT], cm[DL_WTXT]);
  197.  
  198.     if (!hWnd)
  199.         return;
  200.  
  201.     ret = DoDialog(&settings, 1);
  202.  
  203.     WClose(hWnd);
  204.     WCurr(hCurr);
  205.  
  206.     if (ret == ID_OK)
  207.     {
  208.         WriteSettings();
  209.         ShowNewArea();
  210.         ShowMsgHeader(message);
  211.         message = KillMsg(message);
  212.     }
  213. }
  214.  
  215. void  show_help(void)
  216. {
  217.     if (ST->helpfile != NULL)
  218.         DoHelp(0);
  219. }
  220.  
  221. /*--- end ---*/
  222.