home *** CD-ROM | disk | FTP | other *** search
/ The Devil's Doorknob BBS Capture (1996-2003) / devilsdoorknobbbscapture1996-2003.iso / W / WWIVSOR.ZIP / QWK1.C < prev    next >
Text File  |  1995-05-27  |  38KB  |  1,868 lines

  1. /*****************************************************************************
  2.  
  3.                 WWIV Version 4
  4.                     Copyright (C) 1988-1995 by Wayne Bell
  5.  
  6. Distribution of the source code for WWIV, in any form, modified or unmodified,
  7. without PRIOR, WRITTEN APPROVAL by the author, is expressly prohibited.
  8. Distribution of compiled versions of WWIV is limited to copies compiled BY
  9. THE AUTHOR.  Distribution of any copies of WWIV not compiled by the author
  10. is expressly prohibited.
  11.  
  12.  
  13. *****************************************************************************/
  14.  
  15.  
  16.  
  17. #include "vars.h"
  18.  
  19. #pragma hdrstop
  20.  
  21.  
  22. #include "subxtr.h"
  23. #include "vardec1.h"
  24.  
  25. #include <conio.h>
  26. #include <ctype.h>
  27.  
  28.  
  29. #ifdef STATS
  30. #include <sys\timeb.h>
  31. #endif
  32.  
  33.  
  34. #define SET_BLOCK(file, pos, size) sh_lseek(file, (long)pos * (long)size, SEEK_SET)
  35.  
  36.  
  37. #define qwk_iscan(x)         (iscan1(usub[x].subnum, 1))
  38. #define qwk_iscan_literal(x) (iscan1(x, 1))
  39.  
  40. #define MAXMAIL 255
  41. #define EMAIL_STORAGE 2
  42.  
  43. extern char *QWKFrom;
  44. extern int qwk_percent;
  45. extern int qwk_bi_mode;
  46.  
  47. extern int numlock;
  48.  
  49.  
  50. void qwk_remove_email(void)
  51. {
  52.   int i,f,mw,mfl,curmail,done;
  53.     mailrec m;
  54.     tmpmailrec *mloc;
  55.  
  56.     emchg=0;
  57.  
  58.     mloc=(tmpmailrec *)malloca(MAXMAIL*sizeof(tmpmailrec));
  59.     if (!mloc)
  60.     {
  61.         pl(get_string(1272));
  62.         return;
  63.     }
  64.  
  65.   f=open_email(1);
  66.  
  67.     if (f<0)
  68.     {
  69.         farfree(mloc);
  70.         return;
  71.     }
  72.     mfl=filelength(f)/sizeof(mailrec);
  73.     mw=0;
  74.  
  75.   for (i=0; (i<mfl) && (mw<MAXMAIL); i++)
  76.     {
  77.         sh_lseek(f,((long) (i)) * (sizeof(mailrec)), SEEK_SET);
  78.         sh_read(f,(void *)(&m),sizeof(mailrec));
  79.         if ((m.tosys==0) && (m.touser==usernum))
  80.         {
  81.             mloc[mw].index=i;
  82.             mloc[mw].fromsys=m.fromsys;
  83.             mloc[mw].fromuser=m.fromuser;
  84.             mloc[mw].daten=m.daten;
  85.             mloc[mw].msg=m.msg;
  86.             mw++;
  87.         }
  88.     }
  89.     thisuser.waiting=mw;
  90.  
  91.     if (usernum==1)
  92.         fwaiting=mw;
  93.  
  94.  
  95.     if (mw==0)
  96.     {
  97.         farfree(mloc);
  98.                 f=sh_close(f);
  99.         return;
  100.     }
  101.  
  102.     if (mw==1)
  103.         curmail=0;
  104.  
  105.     curmail=0;
  106.     done=0;
  107.  
  108.  
  109.         do {
  110.           delmail(f, mloc[curmail].index);
  111.  
  112.           ++curmail;
  113.           if (curmail>=mw)
  114.             done=1;
  115.  
  116.         } while ((!hangup) && (!done));
  117.  
  118.         f=sh_close(f);
  119. }
  120.  
  121.   
  122.  
  123. void qwk_gather_email(struct qwk_junk *qwk_info)
  124. {
  125.   int i,f,mw,mfl,curmail,done,tp,nn;
  126.     char filename[201];
  127.     mailrec m;
  128.   postrec junk;
  129.     slrec ss;
  130.     tmpmailrec *mloc;
  131.  
  132.     emchg=0;
  133.  
  134.     mloc=(tmpmailrec *)malloca(MAXMAIL*sizeof(tmpmailrec));
  135.     if (!mloc)
  136.     {
  137.         pl(get_string(1272));
  138.         return;
  139.     }
  140.  
  141.     ss=syscfg.sl[actsl];
  142.     f=open_email(0);
  143.     if (f<0)
  144.     {
  145.                 nln(2);
  146.         pl(get_string(702));
  147.         nl();
  148.         farfree(mloc);
  149.         return;
  150.     }
  151.     mfl=filelength(f)/sizeof(mailrec);
  152.     mw=0;
  153.     for (i=0; (i<mfl) && (mw<MAXMAIL); i++)
  154.     {
  155.         sh_lseek(f,((long) (i)) * (sizeof(mailrec)), SEEK_SET);
  156.         sh_read(f,(void *)(&m),sizeof(mailrec));
  157.         if ((m.tosys==0) && (m.touser==usernum))
  158.         {
  159.             mloc[mw].index=i;
  160.             mloc[mw].fromsys=m.fromsys;
  161.             mloc[mw].fromuser=m.fromuser;
  162.             mloc[mw].daten=m.daten;
  163.             mloc[mw].msg=m.msg;
  164.             mw++;
  165.         }
  166.     }
  167.     f=sh_close(f);
  168.     thisuser.waiting=mw;
  169.  
  170.     if (usernum==1)
  171.         fwaiting=mw;
  172.  
  173.  
  174.     if (mw==0)
  175.     {
  176.         nl();
  177.         pl(get_string(27));
  178.         nl();
  179.         farfree(mloc);
  180.         return;
  181.     }
  182.   
  183.   ansic(7);
  184.   pl(get_string(1559));
  185.  
  186.     if (mw==1)
  187.         curmail=0;
  188.  
  189.     curmail=0;
  190.     done=0;
  191.  
  192.  
  193.     qwk_info->in_email=1;
  194.  
  195.   sprintf(filename, "%sPERSONAL.NDX", QWK_DIRECTORY);
  196.   qwk_info->personal=sh_open1(filename, O_RDWR | O_APPEND | O_BINARY | O_CREAT);
  197.   sprintf(filename, "%s000.NDX", QWK_DIRECTORY);
  198.     qwk_info->zero=sh_open1(filename, O_RDWR | O_APPEND | O_BINARY | O_CREAT);
  199.  
  200.     do
  201.     {
  202.     read_same_email(mloc, mw, curmail, &m, 0, 0);
  203.  
  204.         strupr(m.title);
  205.         strncpy(qwk_info->email_title,m.title, 25);
  206.  
  207.  
  208.         i=((ability_read_email_anony & ss.ability)!=0);
  209.  
  210.         if ((m.fromsys) && (!m.fromuser))
  211.       grab_user_name(&(m.msg),"EMAIL");
  212.         else
  213.             net_email_name[0]=0;
  214.         tp=80;
  215.  
  216.         if (m.status & status_new_net)
  217.         {
  218.             tp -= 1;
  219.             if (strlen(m.title)<=tp)
  220.                 nn=m.title[tp+1];
  221.             else
  222.                 nn=0;
  223.         }
  224.         else
  225.             nn=0;
  226.  
  227.  
  228.         set_net_num(nn);
  229. //    if (nn==255)
  230. //      setorigin(0,0);
  231. //    else
  232. //      setorigin(m.fromsys, m.fromuser);
  233.  
  234.  
  235.  
  236.     // Hope this isn't killed in the future
  237.     strcpy(junk.title, m.title);
  238.     junk.anony=m.anony;
  239.     junk.status=m.status;
  240.     junk.ownersys=m.fromsys;
  241.     junk.owneruser=m.fromuser;
  242.     junk.daten=m.daten;
  243.     junk.msg=m.msg;
  244.  
  245.  
  246.     put_in_qwk(&junk, "EMAIL", curmail, qwk_info);
  247.  
  248.  
  249.     ++curmail;
  250.         if (curmail>=mw)
  251.             done=1;
  252.  
  253.   } while ((!hangup) && (!done));
  254.  
  255.     qwk_info->in_email=0;
  256.     farfree(mloc);
  257. }
  258.  
  259.  
  260.  
  261. int select_qwk_archiver(struct qwk_junk *qwk_info, int ask)
  262. {
  263.   int x;
  264.   int archiver;
  265.   char temp[101];
  266.   char allowed[20];
  267.  
  268.   strcpy(allowed, "Q\r");
  269.  
  270.   nl();
  271.   pl(get_string(1560));
  272.   nl();
  273.   if(ask)
  274.     pl(get_string(1561));
  275.   for(x=0;x<4;++x)
  276.   {
  277.     strcpy(temp,syscfg.arcs[x].extension);
  278.     trimstr1(temp);
  279.  
  280.     if(temp[0])
  281.     {
  282.       sprintf(temp, "%d", x+1);
  283.       strcat(allowed, temp);
  284.       npr("1%d) 3%s", x+1, syscfg.arcs[x].extension);
  285.       nl();
  286.     }
  287.   }
  288.   nl();
  289.   outstr(get_string(1562));
  290.  
  291.   if(ask)
  292.     strcat(allowed, "0");
  293.  
  294.   archiver=onek(allowed);
  295.  
  296.   if(archiver=='\r')
  297.     archiver='1';
  298.  
  299.   if(archiver=='Q')
  300.   {
  301.     qwk_info->abort=1;
  302.     return 0;
  303.   }
  304.   archiver=archiver-'0';
  305.   return(archiver);
  306.  
  307. }
  308.  
  309. void qwk_which_zip(char *thiszip)
  310. {
  311.   if(thisuser.qwk_archive>4)
  312.     thisuser.qwk_archive=0;
  313.  
  314.   if(syscfg.arcs[thisuser.qwk_archive-1].extension[0]==0)
  315.     thisuser.qwk_archive=0;
  316.  
  317.   if(thisuser.qwk_archive==0)
  318.     strcpy(thiszip, "ASK");
  319.   else
  320.     strcpy(thiszip, syscfg.arcs[thisuser.qwk_archive-1].extension);
  321. }
  322.  
  323. void qwk_which_protocol(char *thisprotocol)
  324. {
  325.   if(thisuser.qwk_protocol==1)
  326.     thisuser.qwk_protocol=0;
  327.  
  328.   if(thisuser.qwk_protocol==0)
  329.     strcpy(thisprotocol, "ASK");
  330.   else {
  331.     strncpy(thisprotocol, prot_name(thisuser.qwk_protocol), 22);
  332.     thisprotocol[22]=0;
  333.   }
  334. }
  335. void upload_reply_packet(void)
  336. {
  337.   char name[21], namepath[101];
  338.   int rec=1, save_conf=0, save_sub, do_it;
  339.   struct qwk_config qwk_cfg;
  340.  
  341.  
  342.   read_qwk_cfg(&qwk_cfg);
  343.  
  344.   if(!qwk_cfg.fu)
  345.     qwk_cfg.fu=time(NULL);
  346.  
  347.   ++qwk_cfg.timesu;
  348.   write_qwk_cfg(&qwk_cfg);
  349.   close_qwk_cfg(&qwk_cfg);
  350.  
  351.  
  352.  
  353.   save_sub=cursub;
  354.   if ((uconfsub[1].confnum!=-1) && (okconf(&thisuser)))
  355.   {
  356.     save_conf=1;
  357.     tmp_disable_conf(1);
  358.   }
  359.  
  360.   qwk_system_name(name);
  361.     strcat(name, ".REP");
  362.  
  363.   npr("%s%s%s", get_string(1563), name, get_string(1564));
  364.  
  365.   sprintf(namepath, "%s%s", QWK_DIRECTORY, name);
  366.  
  367.   if(!qwk_bi_mode)
  368.     do_it=yn();
  369.   else
  370.     do_it=1;
  371.  
  372.   if(do_it)
  373.   {
  374.     char ch;
  375.  
  376.     if(!qwk_bi_mode && incom)
  377.     {
  378.       qwk_receive_file(namepath, &rec, &ch, thisuser.qwk_protocol);
  379.       wait_sec_or_hit(1);
  380.     }
  381.  
  382.     if(rec)
  383.     {
  384.       ready_reply_packet(namepath);
  385.  
  386.       qwk_system_name(name);
  387.       strcat(name, ".MSG");
  388.       sprintf(namepath, "%s%s", QWK_DIRECTORY, name);
  389.       process_reply_dat(namepath);
  390.     }
  391.     else
  392.     {
  393.       sysoplog(get_stringx(1,119));
  394.       nl();
  395.       npr("%s%s", get_string(1565), name);
  396.       nl();
  397.     }
  398.   }
  399.   if(save_conf)
  400.     tmp_disable_conf(0);
  401.  
  402.   cursub=save_sub;
  403. }
  404.  
  405.  
  406.  
  407. void ready_reply_packet(char *name)
  408. {
  409.   char command[161];
  410.   int archiver;
  411.  
  412.   archiver=match_archiver(name);
  413.   stuff_in(command, syscfg.arcs[archiver].arce, name, QWK_DIRECTORY, "", "", "");
  414.  
  415.   extern_prog(command, EFLAG_NOPAUSE | EFLAG_SHRINK);
  416. }
  417.  
  418.  
  419. // Takes reply packet and converts '227' (π) to '13'
  420. void make_text_ready(char *text, long len)
  421. {
  422.   int pos=0;
  423.  
  424.   while(pos<len && !hangup)
  425.   {
  426.     if((unsigned char)text[pos]==227)
  427.       text[pos]=13;
  428.  
  429.     ++pos;
  430.   }
  431. }
  432.  
  433.  
  434. char * make_text_file(int filenumber, long *size, int curpos, int blocks)
  435. {
  436.   struct qwk_junk *qwk;
  437.   char *temp;
  438.  
  439.  
  440.   *size=0;
  441.  
  442.   // This memory has to be freed later, after text is 'emailed' or 'posted'
  443.     // Enough memory is allocated for all blocks, plus 2k extra for other
  444.   // 'addline' stuff
  445.   qwk=(struct qwk_junk *) malloca((blocks * sizeof(struct qwk_junk))+2048);
  446.   if(!qwk)
  447.     return NULL;
  448.  
  449.  
  450.   SET_BLOCK(filenumber, curpos, sizeof(struct qwk_record));
  451.  
  452.   sh_read(filenumber, (void *)qwk, sizeof(struct qwk_record) * blocks);
  453.   make_text_ready((char *)qwk, sizeof(struct qwk_record)*blocks);
  454.  
  455.   *size=sizeof(struct qwk_record) * blocks;
  456.  
  457.   // Remove trailing spaces
  458.   temp=(char *)qwk;
  459.   while(isspace(temp[*size-1]) && *size && !hangup)
  460.     --*size;
  461.  
  462.   return(temp);
  463. }
  464.  
  465.  
  466.  
  467.  
  468.  
  469. void qwk_email_text(char *text, long size, char *title, char *to)
  470. {
  471.   unsigned short sy,un;
  472.   long thetime;
  473. //  char qwk_address[201];
  474.   char *st;
  475.  
  476.   strupr(to);
  477.  
  478.   // Remove text name from address, if it doesn't contain " AT " in it
  479.   st=strstr(to, " AT ");
  480.   if(!st)
  481.   {
  482.     st=strchr(to, '#');
  483.     if(st)
  484.       strcpy(to, st+1);
  485.   }
  486.   else  // Also try and strip off name of a gated user
  487.   {
  488.     st=strstr(to, "``");
  489.     if(st)
  490.     {
  491.       st=strstr(st+1, "``");
  492.       if(st)
  493.         strcpy(to, st+2);
  494.     }
  495.   }
  496.  
  497.  
  498.  
  499.   helpl=0;
  500.   irt[0]=0;
  501.   irt_name[0]=0;
  502.   parse_email_info(to,&un,&sy);
  503.   grab_quotes(NULL, NULL);
  504.  
  505.  
  506.   if (un || sy)
  507.   {
  508. //    int i;
  509.     messagerec msg;
  510.     char s2[81];
  511.     userrec ur;
  512.     net_system_list_rec *csne;
  513.  
  514.  
  515.     if (freek1(syscfg.msgsdir)<10.0) {
  516.       nl();
  517.       pl(get_string(332));
  518.       nl();
  519.       pausescr();
  520.       return;
  521.     }
  522.  
  523.     if(forwardm(&un,&sy))
  524.     {
  525.       nl();
  526.       pl(get_string(651));
  527.       nl();
  528.       if ((un==0) && (sy==0))
  529.       {
  530.         pl(get_string(652));
  531.         pausescr();
  532.         return;
  533.       }
  534.     }
  535.  
  536.     if (!un && !sy)
  537.       return;
  538.  
  539.     if (sy)
  540.       csne=next_system(sy);
  541.  
  542.     if (sy==0)
  543.     {
  544.       set_net_num(0);
  545.       read_user(un,&ur);
  546.       strcpy(s2,nam(&ur,un));
  547.     }
  548.     else
  549.     {
  550.       if (net_num_max>1)
  551.       {
  552.         if (un==0)
  553.           sprintf(s2,"%s %s @%u",net_name, net_email_name,sy);
  554.         else
  555.           sprintf(s2,"%s %u @%u",net_name, un,sy);
  556.       }
  557.       else
  558.       {
  559.         if (un==0)
  560.           sprintf(s2,"%s @%u",net_email_name,sy);
  561.         else
  562.           sprintf(s2,"%u @%u",un,sy);
  563.       }
  564.     }
  565.  
  566.     if (sy!=0)
  567.     {
  568. //      i=0;
  569.       nl();
  570.       outstr(get_string(654));
  571.       pl(csne -> name);
  572.       outstr(get_string(655));
  573.       pln(csne->numhops);
  574.       nl();
  575.     }
  576.  
  577.     CLS();
  578.     ansic(2);
  579.     npr("%s 3%s", get_string(1632), s2);
  580.     nl();
  581.     ansic(2);
  582.     npr("%s 3%s", get_string(1633), title);
  583.     nln(2);
  584.     ansic(5);
  585.     outstr(get_string(1566));
  586.  
  587.  
  588.     if(!yn())
  589.       return;
  590.  
  591.     
  592.  
  593. //    if(i)
  594. //    {
  595. //      ansic(1);
  596. //      outstr(get_string(485));
  597. //      i=yn();
  598. //    }
  599.  
  600.  
  601.     msg.storage_type=EMAIL_STORAGE;
  602.  
  603.     time(&thetime);
  604.  
  605.  
  606.     qwk_inmsg(text, size, &msg,"EMAIL", nam1(&thisuser,usernum,net_sysnum), thetime);
  607.  
  608.     if(msg.stored_as==0xffffffff)
  609.       return;
  610.  
  611.     ansic(8);
  612.     sendout_email(title, &msg, 0, un, sy, 1, usernum, net_sysnum, 0,net_num);
  613.   }
  614. }
  615.  
  616. void qwk_inmsg(char *text, long size, messagerec *m1, char *aux, char *name, long thetime)
  617. {
  618.   char s[181];
  619.   int oiia;
  620.   char *t;
  621.  
  622.     messagerec m;
  623.   long pos;
  624.  
  625.     oiia=iia;
  626.     setiia(0);
  627.  
  628.     m=*m1;
  629.  
  630.  
  631.   t=(char *)malloca(size+2048);
  632.  
  633.   pos=0;
  634.   addline(t, name, &pos);
  635.  
  636.   strcpy(s,ctime(&thetime));
  637.   s[strlen(s)-1]=0;
  638.   addline(t,s,&pos);
  639.  
  640.   memmove(t+pos, text, size);
  641.   pos+=size;
  642.  
  643.   if (t[pos-1]!=26)
  644.     t[pos++]=26;
  645.   savefile(t,pos,&m,aux);
  646.  
  647.  
  648.   *m1=m;
  649.  
  650.   charbufferpointer=0;
  651.   charbuffer[0]=0;
  652.   setiia(oiia);
  653. }
  654.  
  655.  
  656.  
  657. void process_reply_dat(char *name)
  658. {
  659.   struct qwk_record qwk;
  660.   char *text;
  661.   long size;
  662.     int repfile;
  663.   int curpos=0;
  664.   int done=0;
  665.   int to_email=0;
  666.   
  667.   repfile=sh_open1(name, O_RDONLY | O_BINARY);
  668.  
  669.   if(repfile<0)
  670.   {
  671.     nl();
  672.     ansic(3);
  673.     pl(get_string(1567));
  674.     pausescr();
  675.     return;
  676.   }
  677.  
  678.   SET_BLOCK(repfile, curpos, sizeof(struct qwk_record));
  679.   sh_read(repfile, &qwk, sizeof(struct qwk_record));
  680.  
  681.   // Should check to makesure first block contains our bbs id
  682.  
  683.  
  684.   ++curpos;
  685.  
  686.   CLS();
  687.  
  688.   while(!done && !hangup)
  689.   {
  690.     to_email=0;
  691.  
  692.     SET_BLOCK(repfile, curpos, sizeof(struct qwk_record));
  693.     ++curpos;
  694.  
  695.     if(sh_read(repfile, (void *)&qwk, sizeof(struct qwk_record))<1)
  696.             done=1;
  697.     else
  698.     {
  699.       char blocks[7];
  700.       char to[201];
  701.       char title[26];
  702.       char tosub[7];
  703.  
  704.  
  705.  
  706.       strncpy(blocks, qwk.amount_blocks, 6);
  707.       blocks[6]=0;
  708.  
  709.       strncpy(tosub, qwk.msgnum, 7);
  710.       tosub[7]=0;
  711.       
  712.       strncpy(title, qwk.subject, 25);
  713.       title[25]=0;
  714.  
  715.       strncpy(to, qwk.to, 25);
  716.       to[25]=0;
  717.       strupr(to);
  718.       trimstr1(to);
  719.  
  720.       
  721.       // If in sub 0 or not public, possibly route into email
  722.       if(atoi(tosub)==0)
  723.         to_email=1;
  724.       else if(qwk.status!=' ' && qwk.status !='-') // if not public
  725.       {
  726.         CLS();
  727.         ansic(1);
  728.         npr("Message '2%s1' is marked 3PRIVATE", title);
  729.         nl();
  730.         ansic(1);
  731.         npr("It is addressed to 2%s", to);
  732.         nln(2);
  733.         ansic(7);
  734.         outstr(get_string(1568));
  735.         if(ny())
  736.           to_email=1;
  737.       }
  738.  
  739.  
  740.       text = make_text_file(repfile, &size, curpos, atoi(blocks)-1);
  741.       if(!text)
  742.       {
  743.         curpos+=atoi(blocks)-1;
  744.         continue;
  745.       }
  746.  
  747.  
  748.       if(to_email)
  749.       {
  750.         char *temp;
  751.  
  752.         if((temp=strstr(text, QWKFrom+2)) != NULL)
  753.         {
  754.           char *s;
  755.  
  756.           temp+=strlen(QWKFrom+2);  // Get past 'QWKFrom:'
  757.           s=strchr(temp, '\r');
  758.  
  759.           if(s)
  760.           {
  761.             int x;
  762.  
  763.             s[0]=0;
  764.  
  765.             trimstr1(temp);
  766.             strupr(temp);
  767.  
  768.             if(strlen(s) != strlen(temp))
  769.             {
  770.               nl();
  771.               ansic(3);
  772.               npr("1) %s", to);
  773.               nl();
  774.               ansic(3);
  775.               npr("2) %s", temp);
  776.               nln(2);
  777.  
  778.               outstr(get_string(1569));
  779.               mpl(1);
  780.  
  781.               x=onek("12");
  782.  
  783.               if(x=='2')
  784.                 strcpy(to, temp);
  785.             }
  786.           }
  787.         }
  788.       }
  789.  
  790.       
  791.         
  792.          
  793.  
  794.       if(to_email)
  795.         qwk_email_text(text, size, title, to);
  796.       else if (freek1(syscfg.msgsdir)<10.0)
  797.       {       // Not enough disk space
  798.         nl();
  799.         pl(get_string(332));
  800.         pausescr();
  801.       }
  802.       else
  803.         qwk_post_text(text, size, title, atoi(tosub)-1);
  804.  
  805.             free(text);
  806.  
  807.             curpos+=atoi(blocks)-1;
  808.         }
  809.     }
  810.  
  811.     repfile=sh_close(repfile);
  812. }
  813.  
  814.  
  815.  
  816.  
  817. void qwk_post_text(char *text, long size, char *title, int sub)
  818. {
  819.   messagerec m;
  820.   postrec p;
  821.  
  822.   int i,dm,a,f, done=0, pass=0;
  823.   slrec ss;
  824.   long thetime;
  825.   char user_name[101];
  826.  
  827.  
  828.   while(!done)
  829.   {
  830.     if(pass>0)
  831.     {
  832.       int done5=0;
  833.       char substr[5];
  834.  
  835.       while(!done5)
  836.       {
  837.         nl();
  838.         outstr(get_string(1570));
  839.         input(substr, 3);
  840.  
  841.         trimstr1(substr);
  842.         sub=usub[atoi(substr)-1].subnum;
  843.  
  844.         if(substr[0] == 'Q')
  845.           return;
  846.         else if(substr[0] == '?')
  847.           sublist();
  848.         else
  849.           done5=1;
  850.       }
  851.     }
  852.  
  853.  
  854.     if(sub >= num_subs || sub < 0)
  855.     {
  856.       ansic(5);
  857.       pl(get_string(1571));
  858.  
  859.       ++pass;
  860.       continue;
  861.     }
  862.     cursub=sub;
  863.  
  864.     // Busy files... allow to retry
  865.     while(1)
  866.     {
  867.       if (!qwk_iscan_literal(cursub))
  868.       {
  869.         nl();
  870.         outstr(get_string(1572));
  871.         if(!ny())
  872.         {
  873.           ++pass;
  874.           continue;
  875.         }
  876.       }
  877.       else
  878.         break;
  879.     }
  880.  
  881.     if(curlsub < 0)
  882.     {
  883.       ansic(5);
  884.       pl(get_string(1571));
  885.  
  886.       ++pass;
  887.       continue;
  888.     }
  889.  
  890.  
  891.     ss=syscfg.sl[actsl];
  892.  
  893.  
  894.     // User is restricked from posting
  895.     if ((restrict_post & thisuser.restrict) || (thisuser.posttoday>=ss.posts))
  896.     {
  897.       nl();
  898.       pl(get_string(669));
  899.       nl();
  900.  
  901.       ++pass;
  902.       continue;
  903.     }
  904.  
  905.     // User doesn't have enough sl to post on sub
  906.     if (actsl<subboards[curlsub].postsl)
  907.     {
  908.       nl();
  909.       pl(get_string(670));
  910.       nl();
  911.       ++pass;
  912.       continue;
  913.     }
  914.  
  915.     m.storage_type=subboards[curlsub].storage_type;
  916.  
  917.     a=0;
  918.  
  919.     if(xsubs[curlsub].num_nets)
  920.     {
  921.       a &= (anony_real_name);
  922.  
  923.       if (thisuser.restrict & restrict_net)
  924.       {
  925.         nl();
  926.         pl(get_string(671));
  927.         nl();
  928.         ++pass;
  929.         continue;
  930.       }
  931.     }
  932.  
  933.     CLS();
  934.     ansic(2);
  935.     outstr(get_string(1573));
  936.     ansic(3);
  937.     pl(title);
  938.  
  939.     ansic(2);
  940.     outstr(get_string(1574));
  941.     ansic(3);
  942.     pl(stripcolors(subboards[curlsub].name));
  943.  
  944.     if(xsubs[curlsub].nets)
  945.     {
  946.       ansic(2);
  947.       outstr(get_string(1575));
  948.       ansic(3);
  949.       pl(net_networks[xsubs[curlsub].nets[xsubs[curlsub].num_nets].net_num].name);
  950.     }
  951.  
  952.     nl();
  953.     ansic(5);
  954.     outstr(get_string(1566));
  955.  
  956.     if(ny())
  957.       done=1;
  958.     else
  959.       ++pass;
  960.   }
  961.  
  962.  
  963.  
  964.  
  965.  
  966.   if(subboards[curlsub].anony & anony_real_name)
  967.   {
  968.     strcpy(user_name, thisuser.realname);
  969.     properize(user_name);
  970.   }
  971.   else
  972.     strcpy(user_name, nam1(&thisuser,usernum,net_sysnum));
  973.  
  974.  
  975.   time(&thetime);
  976.   qwk_inmsg(text, size, &m, subboards[curlsub].filename, user_name, thetime);
  977.  
  978.   if (m.stored_as!=0xffffffff)
  979.   {
  980.     char s[201];
  981.  
  982.     while(1)
  983.     {
  984.       f=qwk_iscan_literal(curlsub);
  985.  
  986.       if (f==-1)
  987.       {
  988.         nl();
  989.         outstr(get_string(1572));
  990.         if(!ny())
  991.           return;
  992.       }
  993.       else
  994.         break;
  995.  
  996.     }
  997.  
  998.     // Anonymous
  999.     if(a)
  1000.     {
  1001.       ansic(1);
  1002.       outstr(get_string(485));
  1003.       a=yn();
  1004.     }
  1005.     nl();
  1006.  
  1007.     strcpy(p.title, title);
  1008.     p.anony=a;
  1009.     p.msg=m;
  1010.     p.ownersys=0;
  1011.     p.owneruser=usernum;
  1012.     lock_status();
  1013.     p.qscan=status.qscanptr++;
  1014.     save_status();
  1015.     time((long *)(&p.daten));
  1016.     if (thisuser.restrict & restrict_validate)
  1017.       p.status=status_unvalidated;
  1018.     else
  1019.       p.status=0;
  1020.  
  1021.     open_sub(1);
  1022.  
  1023.     if ((xsubs[curlsub].num_nets) &&
  1024.             (subboards[curlsub].anony & anony_val_net) && (!lcs() || irt[0]))
  1025.     {
  1026.       p.status |= status_pending_net;
  1027.       dm=1;
  1028.  
  1029.       for (i=nummsgs; (i>=1) && (i>(nummsgs-28)); i--)
  1030.       {
  1031.         if (get_post(i)->status & status_pending_net) {
  1032.           dm=0;
  1033.           break;
  1034.         }
  1035.       }
  1036.       if (dm)
  1037.       {
  1038.         sprintf(s,get_stringx(1,37),subboards[curlsub].name);
  1039.         ssm(1,0,s);
  1040.       }
  1041.     }
  1042.  
  1043.     if (nummsgs>=subboards[curlsub].maxmsgs)
  1044.     {
  1045.       i=1;
  1046.       dm=0;
  1047.       while ((dm==0) && (i<=nummsgs) && !hangup)
  1048.       {
  1049.         if((get_post(i)->status & status_no_delete)==0)
  1050.           dm=i;
  1051.         ++i;
  1052.       }
  1053.       if (dm==0)
  1054.         dm=1;
  1055.       delete(dm);
  1056.     }
  1057.  
  1058.     add_post(&p);
  1059.  
  1060.     ++thisuser.msgpost;
  1061.     ++thisuser.posttoday;
  1062.     lock_status();
  1063.     ++status.msgposttoday;
  1064.     ++status.localposts;
  1065.  
  1066.     save_status();
  1067.  
  1068.     close_sub();
  1069.  
  1070.     sprintf(s,get_stringx(1,38),p.title,subboards[curlsub].name);
  1071.     sysoplog(s);
  1072.  
  1073.     if (xsubs[curlsub].num_nets)
  1074.     {
  1075.       ++thisuser.postnet;
  1076.       if (!(p.status & status_pending_net))
  1077.         send_net_post(&p, subboards[curlsub].filename, curlsub);
  1078.     }
  1079.   }
  1080. }
  1081.  
  1082.  
  1083.  
  1084. int find_qwk_sub(struct qwk_sub_conf *subs, int amount, int fromsub, char *title)
  1085. {
  1086.   int x=0;
  1087.  
  1088.   if(title==title)
  1089.     title=title;
  1090.  
  1091.   while(x<amount && !hangup)
  1092.   {
  1093.     if(subs[x].import_num==fromsub)
  1094.       return subs[x].to_num;
  1095.  
  1096.     ++x;
  1097.   }
  1098.   return -1;
  1099. }
  1100. /* Start DAW */
  1101. void qwk_receive_file(char *fn, int *received, char *ft, int i)
  1102. {
  1103.   if ((i<=1) || (i == 5))
  1104.     i=get_protocol(xf_up_temp);
  1105.  
  1106.   switch(i) {
  1107.     case -1:
  1108.     case 0:
  1109.     case 1:
  1110.     case 5:
  1111.       *received=0;
  1112.       break;
  1113.     case 2:
  1114.     case 3:
  1115.     case 4:
  1116.       maybe_internal(fn, received, NULL, 0, ft, 0, i);
  1117.       break;
  1118.     default:
  1119.       if (incom) {
  1120.         extern_prot(i-6,fn,0);
  1121.         *received=exist(fn);
  1122.       }
  1123.       break;
  1124.   }
  1125. }
  1126. /* End DAW */
  1127.  
  1128. void qwk_sysop(void)
  1129. {
  1130.   struct qwk_config qwk_cfg;
  1131.   char temp[10];
  1132.   char sn[10];
  1133.   int done=0;
  1134.   int x;
  1135.  
  1136.   if(!so())
  1137.     return;
  1138.  
  1139.   read_qwk_cfg(&qwk_cfg);
  1140.  
  1141.   while(!done && !hangup)
  1142.   {
  1143.     qwk_system_name(sn);
  1144.     CLS();
  1145.     npr("%s %s", get_string(1576), qwk_cfg.hello);
  1146.     nl();
  1147.     npr("%s %s", get_string(1577), qwk_cfg.news);
  1148.     nl();
  1149.     npr("%s %s", get_string(1578), qwk_cfg.bye);
  1150.     nl();
  1151.     npr("%s %s", get_string(1579), sn);
  1152.     nl();
  1153.     npr("%s %d", get_string(1580), qwk_cfg.max_msgs);
  1154.     nl();
  1155.     npr("%s %d", get_string(1581), qwk_cfg.amount_blts);
  1156.     nln(2);
  1157.     npr(get_string(1582));
  1158.  
  1159.     x=onek("Q123456\r\n");
  1160.     if(x=='1' || x=='2' || x=='3')
  1161.     {
  1162.       nl();
  1163.       ansic(1);  
  1164.       outstr(get_string(1583));
  1165.       mpl(12);
  1166.     }
  1167.  
  1168.     switch(x)
  1169.     {
  1170.       case '1':
  1171.         input(qwk_cfg.hello, 12);
  1172.         break;
  1173.       case '2':
  1174.         input(qwk_cfg.news, 12);
  1175.         break;
  1176.       case '3':
  1177.         input(qwk_cfg.bye, 12);
  1178.         break;
  1179.  
  1180.       case '4':
  1181.         write_qwk_cfg(&qwk_cfg);
  1182.         qwk_system_name(sn);
  1183.         nl();
  1184.         ansic(1);
  1185.         npr("Current name : %s", sn);
  1186.         nl();
  1187.         outstr(get_string(1584));
  1188.         input(sn, 8);
  1189.         if(sn[0])
  1190.           strcpy(qwk_cfg.packet_name, sn);
  1191.  
  1192.         write_qwk_cfg(&qwk_cfg);
  1193.         break;
  1194.  
  1195.       case '5':
  1196.         ansic(1);
  1197.         outstr(get_string(1585));
  1198.         mpl(5);
  1199.         input(temp, 5);
  1200.         qwk_cfg.max_msgs=atoi(temp);
  1201.         break;
  1202.       case '6':
  1203.         modify_bulletins(&qwk_cfg);
  1204.         break;
  1205.       default:
  1206.         done=1;
  1207.     }
  1208.   }
  1209.  
  1210.   write_qwk_cfg(&qwk_cfg);
  1211.   close_qwk_cfg(&qwk_cfg);
  1212. }
  1213.  
  1214. void modify_bulletins(struct qwk_config *qwk_cfg)
  1215. {
  1216.   int x, abort=0, key, done=0;
  1217.   char s[101], t[101];
  1218.  
  1219.   while(!done)
  1220.   {
  1221.     nl();
  1222.     outstr(get_string(1586));
  1223.     mpl(1);
  1224.  
  1225.     key=onek("Q\rAD?");
  1226.  
  1227.     switch(key)
  1228.     {
  1229.       case 'Q':
  1230.       case '\r':
  1231.         return;
  1232.  
  1233.       case 'D':
  1234.         nl();
  1235.         outstr(get_string(1587));
  1236.         mpl(2);
  1237.  
  1238.         input(s, 2);
  1239.         x=atoi(s);
  1240.  
  1241.         if(x<=qwk_cfg->amount_blts)
  1242.         {
  1243.           strcpy(qwk_cfg->blt[x], qwk_cfg->blt[qwk_cfg->amount_blts-1]);
  1244.           strcpy(qwk_cfg->bltname[x], qwk_cfg->bltname[qwk_cfg->amount_blts-1]);
  1245.  
  1246.           bbsfree(qwk_cfg->blt[qwk_cfg->amount_blts-1]);
  1247.           bbsfree(qwk_cfg->bltname[qwk_cfg->amount_blts-1]);
  1248.  
  1249.           --qwk_cfg->amount_blts;
  1250.         }
  1251.         break;
  1252.  
  1253.       case 'A':
  1254.         nl();
  1255.         pl(get_string(1588));
  1256.         input(s, 80);
  1257.  
  1258.         if(!exist(s))
  1259.         {
  1260.           outstr(get_string(1589));
  1261.           if(!yn())
  1262.             break;
  1263.         }
  1264.  
  1265.         pl(get_string(1590));
  1266.         input(t, BNAME_SIZE);
  1267.  
  1268.         if(strncmpi(t, "BLT-", 4) != 0)
  1269.         {
  1270.           pl(get_string(1591));
  1271.           break;
  1272.         }
  1273.  
  1274.         qwk_cfg->blt[qwk_cfg->amount_blts]=(char *)calloc(BULL_SIZE, sizeof(char));
  1275.         qwk_cfg->bltname[qwk_cfg->amount_blts]=(char *)calloc(BNAME_SIZE, sizeof(char));
  1276.  
  1277.         strcpy(qwk_cfg->blt[qwk_cfg->amount_blts], s);
  1278.         strcpy(qwk_cfg->bltname[qwk_cfg->amount_blts], t);
  1279.         ++qwk_cfg->amount_blts;
  1280.         break;
  1281.  
  1282.  
  1283.       case '?':
  1284.         abort=0;
  1285.         x=0;
  1286.         while(x<qwk_cfg->amount_blts && !abort)
  1287.         {
  1288.           npr("[%d] %s %s", x+1, qwk_cfg->bltname[x], get_string(1592));
  1289.           nl();
  1290.           repeat_char(' ', 5);
  1291.           outstr(qwk_cfg->blt[x]);
  1292.           nl();
  1293.  
  1294.           checka(&abort, &abort);
  1295.  
  1296.           ++x;
  1297.         }
  1298.         break;
  1299.     }
  1300.   }
  1301. }
  1302. void config_qwk_bw(void)
  1303. {
  1304.   char text[101];
  1305.   int done=0, key;
  1306.  
  1307.  
  1308.   while(!done)
  1309.   {
  1310.     npr(get_string(1593));
  1311.     npr(qwk_current_text(0, text));
  1312.     nl();
  1313.     npr(get_string(1594));
  1314.     npr(qwk_current_text(1, text));
  1315.     nl();
  1316.     npr(get_string(1595));
  1317.     npr(qwk_current_text(2, text));
  1318.     nl();
  1319.     npr(get_string(1596));
  1320.     npr(qwk_current_text(3, text));
  1321.     nl();
  1322.     npr(get_string(1597));
  1323.     npr(qwk_current_text(4, text));
  1324.     nl();
  1325.     npr(get_string(1598));
  1326.     npr(qwk_current_text(5, text));
  1327.     nl();
  1328.     npr(get_string(1599));
  1329.     npr(qwk_current_text(6, text));
  1330.     nl();
  1331.     npr(get_string(1600));
  1332.     npr(qwk_current_text(7, text));
  1333.     nl();
  1334.     npr(get_string(1601));
  1335.     npr(qwk_current_text(8, text));
  1336.     nl();
  1337.     npr(get_string(1602));
  1338.     npr(qwk_current_text(9, text));
  1339.     nl();
  1340.     npr(get_string(1603));
  1341.     npr(qwk_current_text(10, text));
  1342.     nl();
  1343.     pl(get_string(1604));
  1344.  
  1345.     key=onek("QABCDEFGHIJK");
  1346.  
  1347.     if(key=='Q')
  1348.       done=1;
  1349.  
  1350.     key=key-'A';
  1351.  
  1352.     switch(key)
  1353.     {
  1354.       case 0:
  1355.         thisuser.qwk_dont_scan_mail=!thisuser.qwk_dont_scan_mail;
  1356.         break;
  1357.       case 1:
  1358.         thisuser.qwk_delete_mail=!thisuser.qwk_delete_mail;
  1359.         break;
  1360.       case 2:
  1361.         thisuser.qwk_dontsetnscan=!thisuser.qwk_dontsetnscan;
  1362.         break;
  1363.       case 3:
  1364.         thisuser.qwk_remove_color=!thisuser.qwk_remove_color;
  1365.         break;
  1366.       case 4:
  1367.         thisuser.qwk_convert_color=!thisuser.qwk_convert_color;
  1368.         break;
  1369.       case 5:
  1370.         thisuser.qwk_leave_bulletin=!thisuser.qwk_leave_bulletin;
  1371.         break;
  1372.       case 6:
  1373.         thisuser.qwk_dontscanfiles=!thisuser.qwk_dontscanfiles;
  1374.         break;
  1375.       case 7:
  1376.         thisuser.qwk_keep_routing=!thisuser.qwk_keep_routing;
  1377.         break;
  1378.  
  1379.       case 8:
  1380.       {
  1381.         struct qwk_junk qj;
  1382.         int a;
  1383.  
  1384.         memset(&qj, 0, sizeof(struct qwk_junk));
  1385.         CLS();
  1386.  
  1387.         a=select_qwk_archiver(&qj, 1);
  1388.         if(!qj.abort)
  1389.           thisuser.qwk_archive=a;
  1390.  
  1391.         break;
  1392.       }
  1393.  
  1394.       case 9:
  1395.       {
  1396.         struct qwk_junk qj;
  1397.         int a;
  1398.  
  1399.         memset(&qj, 0, sizeof(struct qwk_junk));
  1400.         CLS();
  1401.  
  1402.         a=select_qwk_protocol(&qj);
  1403.         if(!qj.abort)
  1404.           thisuser.qwk_protocol=a;
  1405.  
  1406.         break;
  1407.       }
  1408.  
  1409.       case 10:
  1410.       {
  1411.         unsigned int max_msgs, max_per_sub;
  1412.  
  1413.         if(get_qwk_max_msgs(&max_msgs, &max_per_sub))
  1414.         {
  1415.           thisuser.qwk_max_msgs=max_msgs;
  1416.           thisuser.qwk_max_msgs_per_sub=max_per_sub;
  1417.         }
  1418.         break;
  1419.       }
  1420.  
  1421.     }
  1422.   }
  1423. }
  1424. void config_qwk_rip(void)
  1425. {
  1426.   char text[101];
  1427.   int done=0, key;
  1428.  
  1429.  
  1430.   while(!done)
  1431.   {
  1432.     printmenu(367);
  1433.  
  1434.     if (strcmp(qwk_current_text(0, text), "YES") == 0)
  1435.       comstr("\r!|@2S34X");
  1436.     if (strcmp(qwk_current_text(1, text), "YES") == 0)
  1437.       comstr("\r!|@2S3SX");
  1438.     if (strcmp(qwk_current_text(2, text), "YES") == 0)
  1439.       comstr("\r!|@2S54X");
  1440.     if (strcmp(qwk_current_text(3, text), "YES") == 0)
  1441.       comstr("\r!|@2S6GX");
  1442.     if (strcmp(qwk_current_text(4, text), "YES") == 0)
  1443.       comstr("\r!|@2S74X");
  1444.     if (strcmp(qwk_current_text(5, text), "YES") == 0)
  1445.       comstr("\r!|@9G34X");
  1446.     if (strcmp(qwk_current_text(6, text), "YES") == 0)
  1447.       comstr("\r!|@9G3SX");
  1448.     if (strcmp(qwk_current_text(7, text), "YES") == 0)
  1449.       comstr("\r!|@9G4GX");
  1450.     comstr("\r!|@BW5Z\\");
  1451.     comstr(qwk_current_text(8, text));
  1452.     comstr("\r!|@BW6O\\");
  1453.     comstr(qwk_current_text(9, text));
  1454.     comstr("\r!|Y02000400|@BW7A\\");
  1455.     comstr(qwk_current_text(10, text));
  1456.     comstr("\r");
  1457.  
  1458.     key=onek("QSDMECBFRAPX");
  1459.  
  1460.     if(key=='Q')
  1461.       done=1;
  1462.  
  1463.     switch(toupper(key))
  1464.     {
  1465.       case 'S':
  1466.             thisuser.qwk_dont_scan_mail=!thisuser.qwk_dont_scan_mail;
  1467.             break;
  1468.       case 'D':
  1469.             thisuser.qwk_delete_mail=!thisuser.qwk_delete_mail;
  1470.             break;
  1471.       case 'M':
  1472.             thisuser.qwk_dontsetnscan=!thisuser.qwk_dontsetnscan;
  1473.             break;
  1474.       case 'E':
  1475.             thisuser.qwk_remove_color=!thisuser.qwk_remove_color;
  1476.             break;
  1477.       case 'C':
  1478.             thisuser.qwk_convert_color=!thisuser.qwk_convert_color;
  1479.             break;
  1480.       case 'B':
  1481.             thisuser.qwk_leave_bulletin=!thisuser.qwk_leave_bulletin;
  1482.             break;
  1483.       case 'F':
  1484.             thisuser.qwk_dontscanfiles=!thisuser.qwk_dontscanfiles;
  1485.             break;
  1486.       case 'R':
  1487.             thisuser.qwk_keep_routing=!thisuser.qwk_keep_routing;
  1488.             break;
  1489.  
  1490.       case 'A':
  1491.       {
  1492.             struct qwk_junk qj;
  1493.             int a;
  1494.  
  1495.             memset(&qj, 0, sizeof(struct qwk_junk));
  1496.             CLS();
  1497.  
  1498.             a=select_qwk_archiver(&qj, 1);
  1499.             if(!qj.abort)
  1500.               thisuser.qwk_archive=a;
  1501.  
  1502.             break;
  1503.       }
  1504.  
  1505.       case 'P':
  1506.       {
  1507.             struct qwk_junk qj;
  1508.             int a;
  1509.  
  1510.             memset(&qj, 0, sizeof(struct qwk_junk));
  1511.             CLS();
  1512.  
  1513.             a=select_qwk_protocol(&qj);
  1514.             if(!qj.abort)
  1515.               thisuser.qwk_protocol=a;
  1516.  
  1517.             break;
  1518.       }
  1519.  
  1520.       case 'X':
  1521.       {
  1522.             unsigned int max_msgs, max_per_sub;
  1523.  
  1524.             if(get_qwk_max_msgs(&max_msgs, &max_per_sub))
  1525.             {
  1526.               thisuser.qwk_max_msgs=max_msgs;
  1527.               thisuser.qwk_max_msgs_per_sub=max_per_sub;
  1528.             }
  1529.             break;
  1530.       }
  1531.  
  1532.     }
  1533.   }
  1534. }
  1535. void config_qwk(void)
  1536. {
  1537.   int done=0, save_num=numlock, x;
  1538.   char temp[51];
  1539.   inputeditrec max_subs, max_packet;
  1540.   radiobuttonrec color_convert, archiver;
  1541.   checkboxrec options;
  1542.   showtextrec protocol, quit_save, abort;
  1543.   unsigned int options_bitfield=0, color_bitfield=0;
  1544.  
  1545.  
  1546.   varimenurec *menu=NULL, newmenu;
  1547.  
  1548.   varimenuinfo info={YELLOW+(BLUE<<4), YELLOW+(BLUE<<4),
  1549.                      YELLOW+(BLUE<<4), YELLOW+(BLUE<<4), DARKGRAY+(CYAN<<4),
  1550.                      COMMON_FULL, 0, 0, 0, 0, 0};
  1551.  
  1552.   /* Start DAW */
  1553.   if (!((thisuser.sysstatus & sysstatus_ansi) && (thisuser.sysstatus & sysstatus_color)))
  1554.   /* End DAW */
  1555.   {
  1556.     config_qwk_bw();
  1557.     return;
  1558.   }
  1559.  
  1560.   if (rip_on()) {
  1561.     config_qwk_rip();
  1562.     return;
  1563.   }
  1564.   numlock=NUMBERS;
  1565.  
  1566.  
  1567.   if(!thisuser.qwk_dont_scan_mail)
  1568.     options_bitfield = BitSet(options_bitfield, 0);
  1569.   if(thisuser.qwk_delete_mail)
  1570.     options_bitfield = BitSet(options_bitfield, 1);
  1571.   if(!thisuser.qwk_dontsetnscan)
  1572.     options_bitfield = BitSet(options_bitfield, 2);
  1573.   if(!thisuser.qwk_leave_bulletin)
  1574.     options_bitfield = BitSet(options_bitfield, 3);
  1575.   if(!thisuser.qwk_dontscanfiles)
  1576.     options_bitfield = BitSet(options_bitfield, 4);
  1577.   if(!thisuser.qwk_keep_routing)
  1578.     options_bitfield = BitSet(options_bitfield, 5);
  1579.  
  1580.   build_checkboxrec(&options, 28, 4, 6, 0, options_bitfield, 'X', ' ');
  1581.   fillvarimenurec(&newmenu, &options, CHECK_BOX_TYPE, 0, 0, COMMON_ACTIVE);
  1582.   menu=addvarimenu(menu, &newmenu);
  1583.  
  1584.   if(thisuser.qwk_remove_color)
  1585.     color_bitfield=1;
  1586.   else if(thisuser.qwk_convert_color)
  1587.     color_bitfield=2;
  1588.   else
  1589.     color_bitfield=0;
  1590.  
  1591.   build_radiobuttonrec(&color_convert, 28, 11, 3, color_bitfield, '*', ' ');
  1592.   fillvarimenurec(&newmenu, &color_convert, RADIO_BUTTON_TYPE, 0, QWK_SELECT, COMMON_ACTIVE);
  1593.   menu=addvarimenu(menu, &newmenu);
  1594.  
  1595.  
  1596.   build_radiobuttonrec(&archiver, 34, 5, 5, thisuser.qwk_archive, '*', ' ');
  1597.   fillvarimenurec(&newmenu, &archiver, RADIO_BUTTON_TYPE, 0, QWK_ARCHIVER, COMMON_ACTIVE);
  1598.   menu=addvarimenu(menu, &newmenu);
  1599.  
  1600.   build_inputrec(&max_packet, 5, 64, 5, 5, 0, IE_UPPER);
  1601.   fillvarimenurec(&newmenu, &max_packet, INPUT_EDIT_TYPE, 0, QWK_MAX_PACKET, COMMON_ACTIVE);
  1602.   menu=addvarimenu(menu, &newmenu);
  1603.   sprintf(max_packet.text, "%u", thisuser.qwk_max_msgs);
  1604.   max_packet.curlen=strlen(max_packet.text);
  1605.  
  1606.   build_inputrec(&max_subs, 5, 64, 6, 5, 0, IE_UPPER);
  1607.   fillvarimenurec(&newmenu, &max_subs, INPUT_EDIT_TYPE, 0, QWK_MAX_SUB, COMMON_ACTIVE);
  1608.   menu=addvarimenu(menu, &newmenu);
  1609.   sprintf(max_subs.text, "%u", thisuser.qwk_max_msgs_per_sub);
  1610.   max_subs.curlen=strlen(max_subs.text);
  1611.  
  1612.   build_showtextrec(&protocol, 39, 13, 0, "", JUSTIFY_CENTER, ' ');
  1613.   fillvarimenurec(&newmenu, &protocol, SHOW_TEXT_TYPE, 0, QWK_SELECT_PROTOCOL, COMMON_ACTIVE);
  1614.   menu=addvarimenu(menu, &newmenu);
  1615.  
  1616.   build_showtextrec(&quit_save, 56, 13, 0, "", JUSTIFY_CENTER, ' ');
  1617.   fillvarimenurec(&newmenu, &quit_save, SHOW_TEXT_TYPE, EXECUTE, QWK_QUIT_SAVE, COMMON_ACTIVE);
  1618.   menu=addvarimenu(menu, &newmenu);
  1619.  
  1620.   build_showtextrec(&abort, 69, 13, 0, "", JUSTIFY_CENTER, ' ');
  1621.   fillvarimenurec(&newmenu, &abort, SHOW_TEXT_TYPE, GET_OUT, QWK_ABORT, COMMON_ACTIVE);
  1622.   menu=addvarimenu(menu, &newmenu);
  1623.  
  1624.  
  1625.   printfile("QWKCFG");
  1626.   GOTO_XY(67,2);
  1627.   setc(LIGHTBLUE+(BLACK<<4));
  1628.   outstr(numlock==NUMBERS ? get_string(1605) : get_string(1606));
  1629.  
  1630.   setc(RED+(LIGHTGRAY<<4));
  1631.   for(x=0;x<4;++x)
  1632.   {
  1633.     GOTO_XY(37, 6+x);
  1634.     outstr(syscfg.arcs[x].extension);
  1635.   }
  1636.  
  1637.   GOTO_XY(52, 11);
  1638.   qwk_which_protocol(temp);
  1639.   outstr(temp);
  1640.   ansic(0);
  1641.  
  1642.  
  1643.   done=0;
  1644.   while(!done && !hangup)
  1645.   {
  1646.     varimenu(menu, &info);
  1647.     if(do_sysop_command(info.event))
  1648.     {
  1649.       info.last=0;
  1650.       info.redraw=COMMON_FULL;
  1651.  
  1652.       CLS();
  1653.       printfile("QWKCFG");
  1654.  
  1655.       GOTO_XY(67,2);
  1656.       setc(LIGHTBLUE+(BLACK<<4));
  1657.       outstr(numlock==NUMBERS ? get_string(1605) : get_string(1606));
  1658.  
  1659.       setc(RED+(LIGHTGRAY<<4));
  1660.       for(x=0;x<4;++x)
  1661.       {
  1662.         GOTO_XY(37, 6+x);
  1663.         outstr(syscfg.arcs[x].extension);
  1664.       }
  1665.  
  1666.       GOTO_XY(52, 11);
  1667.       qwk_which_protocol(temp);
  1668.       outstr(temp);
  1669.  
  1670.       info.redraw=COMMON_FULL;
  1671.       ansic(0);
  1672.     }
  1673.  
  1674.     switch(info.event)
  1675.     {
  1676.       case EXECUTE:
  1677.         switch(info.returnvalue)
  1678.         {
  1679.           case QWK_SELECT_PROTOCOL:
  1680.             CLS();
  1681.  
  1682.             x=get_protocol(xf_down_temp);
  1683.             if(x>=0)
  1684.               thisuser.qwk_protocol=x;
  1685.  
  1686.             CLS();
  1687.             printfile("QWKCFG");
  1688.  
  1689.             GOTO_XY(67,2);
  1690.             setc(LIGHTBLUE+(BLACK<<4));
  1691.             outstr(numlock==NUMBERS ? get_string(1605) : get_string(1606));
  1692.  
  1693.             setc(RED+(LIGHTGRAY<<4));
  1694.             for(x=0;x<4;++x)
  1695.             {
  1696.               GOTO_XY(37, 6+x);
  1697.               outstr(syscfg.arcs[x].extension);
  1698.             }
  1699.  
  1700.             GOTO_XY(52, 11);
  1701.             qwk_which_protocol(temp);
  1702.             outstr(temp);
  1703.  
  1704.             info.redraw=COMMON_FULL;
  1705.             ansic(0);
  1706.  
  1707.             break;
  1708.  
  1709.           case QWK_ABORT:
  1710.             done=1;
  1711.             break;
  1712.  
  1713.  
  1714.           case QWK_QUIT_SAVE:
  1715.           default:
  1716.             thisuser.qwk_dont_scan_mail = !options.bi.i.one;
  1717.             thisuser.qwk_delete_mail    = options.bi.i.two;
  1718.             thisuser.qwk_dontsetnscan   = !options.bi.i.three;
  1719.             thisuser.qwk_leave_bulletin = !options.bi.i.four;
  1720.             thisuser.qwk_dontscanfiles  = !options.bi.i.five;
  1721.             thisuser.qwk_keep_routing   = !options.bi.i.six;
  1722.  
  1723.             switch(color_convert.pos)
  1724.             {
  1725.               case 0:
  1726.                 thisuser.qwk_remove_color=0;
  1727.                 thisuser.qwk_convert_color=0;
  1728.                 break;
  1729.               case 1:
  1730.                 thisuser.qwk_remove_color=1;
  1731.                 thisuser.qwk_convert_color=0;
  1732.                 break;
  1733.               case 2:
  1734.                 thisuser.qwk_remove_color=0;
  1735.                 thisuser.qwk_convert_color=1;
  1736.                 break;
  1737.             }
  1738.  
  1739.             thisuser.qwk_archive=archiver.pos;
  1740.             thisuser.qwk_max_msgs=atoi(max_packet.text);
  1741.             thisuser.qwk_max_msgs_per_sub=atoi(max_subs.text);
  1742.  
  1743.  
  1744.             done=1;
  1745.             break;
  1746.  
  1747.         }
  1748.         break;
  1749.  
  1750.       case CN:  // Toggle the numlock key, should it act on the numbers or arrows?
  1751.         numlock=!numlock;
  1752.         if(numlock==NUMBERS)
  1753.         {
  1754.           int save_c=curatr;
  1755.           GOTO_XY(67,2)
  1756.           setc(LIGHTBLUE);
  1757.           outstr(get_string(1605));
  1758.           setc(save_c);
  1759.         }
  1760.         else
  1761.         {
  1762.           int save_c=curatr;
  1763.           GOTO_XY(67,2);
  1764.           setc(LIGHTBLUE);
  1765.           outstr(get_string(1606));
  1766.           setc(save_c);
  1767.         }
  1768.         break;
  1769.  
  1770.  
  1771.  
  1772.       case GET_OUT:
  1773.         done=1;
  1774.         break;
  1775.     }
  1776.   }
  1777.  
  1778.   ansic(0);
  1779.   killvarimenu(menu);
  1780.   numlock=save_num;
  1781. }
  1782.  
  1783. char *qwk_current_text(int pos, char *text)
  1784. {
  1785.   char *yesorno[]={"YES", "NO"};
  1786.  
  1787.   switch(pos)
  1788.   {
  1789.     case 0:
  1790.       if(thisuser.qwk_dont_scan_mail)
  1791.         return(yesorno[1]);
  1792.       else
  1793.         return(yesorno[0]);
  1794.     case 1:
  1795.       if(thisuser.qwk_delete_mail)
  1796.         return(yesorno[0]);
  1797.       else
  1798.        return(yesorno[1]);
  1799.     case 2:
  1800.       if(thisuser.qwk_dontsetnscan)
  1801.         return(yesorno[1]);
  1802.       else
  1803.         return(yesorno[0]);
  1804.     case 3:
  1805.       if(thisuser.qwk_remove_color)
  1806.         return(yesorno[0]);
  1807.       else
  1808.         return(yesorno[1]);
  1809.     case 4:
  1810.       if(thisuser.qwk_convert_color)
  1811.         return(yesorno[0]);
  1812.       else
  1813.         return(yesorno[1]);
  1814.  
  1815.     case 5:
  1816.       if(thisuser.qwk_leave_bulletin)
  1817.         return(yesorno[1]);
  1818.       else
  1819.         return(yesorno[0]);
  1820.  
  1821.     case 6:
  1822.       if(thisuser.qwk_dontscanfiles)
  1823.         return(yesorno[1]);
  1824.       else
  1825.         return(yesorno[0]);
  1826.  
  1827.     case 7:
  1828.       if(thisuser.qwk_keep_routing)
  1829.         return(yesorno[1]);
  1830.       else
  1831.         return(yesorno[0]);
  1832.  
  1833.     case 8:
  1834.       qwk_which_zip(text);
  1835.       return(text);
  1836.     
  1837.     case 9:
  1838.       qwk_which_protocol(text);
  1839.       return(text);
  1840.  
  1841.     case 10:
  1842.       if(!thisuser.qwk_max_msgs_per_sub && !thisuser.qwk_max_msgs)
  1843.         return(get_string(1607));
  1844.       else if(!thisuser.qwk_max_msgs_per_sub)
  1845.       {
  1846.         sprintf(text, "%s/%u", get_string(1634), thisuser.qwk_max_msgs);
  1847.         return(text);
  1848.       }
  1849.       else if(!thisuser.qwk_max_msgs)
  1850.       {
  1851.         sprintf(text, "%u/%s", thisuser.qwk_max_msgs_per_sub, get_string(1634));
  1852.         return(text);
  1853.       }
  1854.       else
  1855.       {
  1856.         sprintf(text, "%u/%u", thisuser.qwk_max_msgs, thisuser.qwk_max_msgs_per_sub);
  1857.         return(text);
  1858.       }
  1859.  
  1860.     case 11:
  1861.       strcpy(text, get_string(1635));
  1862.       return(text);
  1863.   }
  1864.  
  1865.   return(NULL);
  1866. }
  1867.  
  1868.