home *** CD-ROM | disk | FTP | other *** search
/ The Devil's Doorknob BBS Capture (1996-2003) / devilsdoorknobbbscapture1996-2003.iso / W / WWIVSOR.ZIP / BBSOVL1.C < prev    next >
Text File  |  1995-04-25  |  29KB  |  1,205 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. #include "vars.h"
  16.  
  17. #pragma hdrstop
  18.  
  19. #include "subxtr.h"
  20.  
  21. #include "ripint.h"
  22.  
  23. #define FRAME 7
  24.  
  25. /****************************************************************************/
  26.  
  27. /*
  28.  * Makes various (local-only) sounds based upon input params. The params are:
  29.  *     sf = starting frequency, in hertz
  30.  *     ef = ending frequency, in hertz
  31.  *     uf = frequency change, in hertz, for each step
  32.  *   dly1 = delay, in milliseconds, between each step, when going from sf
  33.  *             to ef
  34.  *   dly2 = delay, in milliseconds, between each repetition of the sound
  35.  *             sequence
  36.  *     rp = number of times to play the whole sound sequence
  37.  */
  38.  
  39. #ifdef __OS2__
  40. #define sound(freq) setbeep(freq)
  41. #define nosound() setbeep(0)
  42. #endif
  43.  
  44. void chatsound(int sf, int ef, int uf, int dly1, int dly2, int rp)
  45. {
  46.   int i,i1;
  47.  
  48.   for (i1=0; i1<rp; i1++) {
  49.     if (sf < ef) {
  50.       for (i=sf; i<ef; i+=uf) {
  51.         sound(i);
  52.         delay(dly1);
  53.       }
  54.     } else {
  55.       for (i=ef; i>sf; i-=uf) {
  56.         sound(i);
  57.         delay(dly1);
  58.       }
  59.     }
  60.     delay(dly2);
  61.   }
  62.   nosound();
  63. }
  64.  
  65. /****************************************************************************/
  66.  
  67. /*
  68.  * Function called when user requests chat w/sysop.
  69.  */
  70.  
  71. void reqchat(void)
  72. {
  73.   int ok;
  74.   char s[81];
  75.  
  76.   nln(2);
  77.   ok=sysop2();
  78.   if (restrict_chat & thisuser.restrict)
  79.     ok=0;
  80.   if (ok) {
  81.     if (chatcall) {
  82.       chatcall=0;
  83.       pl(get_string(597));
  84.       topscreen();
  85.     } else {
  86.       prt(2,get_string(598));
  87.       inputl(s,70);
  88.       if (s[0]) {
  89.         if (sysinfo.flags & OP_FLAGS_NEW_CHATSOUND) {
  90.           if (!play_sdf("CHAT",0))
  91.             chatsound(100, 800, 10, 10, 25, 5);
  92.         }
  93.         chatcall=1;
  94.         sprintf(chatreason,"%s: %s",get_stringx(1,33), s);
  95.         nl();
  96.         sysoplog(chatreason);
  97.         for (ok=strlen(chatreason); ok<80; ok++)
  98.           chatreason[ok]=32;
  99.         chatreason[80]=0;
  100.         topscreen();
  101.         pl(get_string(599));
  102.         nl();
  103.       }
  104.     }
  105.   } else {
  106.     pl(get_string(600));
  107.     nl();
  108.     pl(get_string(601));
  109.     strcpy(irt,get_stringx(1,34));
  110.     irt_name[0]=0;
  111.     imail(1,0);
  112.   }
  113. }
  114.  
  115. /****************************************************************************/
  116.  
  117. /*
  118.  * Displays some basic user statistics for the current user.
  119.  */
  120.  
  121. void yourinfo(void)
  122. {
  123.  
  124.   if (menu_on()) {
  125.     rip_yourinfo();
  126.     return;
  127.   }
  128.  
  129.   outchr(12);
  130.   ansic_x(1); outstr(get_string(602));
  131.   ansic_x(2); pl(nam(&thisuser,usernum));
  132.   ansic_x(1); outstr(get_string(603));
  133.   ansic_x(2); pl(thisuser.phone);
  134.   if (thisuser.waiting) {
  135.     ansic_x(1); outstr(get_string(1001));
  136.     ansic_x(2); npr("%d\r\n",thisuser.waiting);
  137.   }
  138.   ansic_x(1); outstr(get_string(604));
  139.   ansic_x(2); npr("%d",thisuser.sl);
  140.  
  141.   if (actsl!=thisuser.sl) {
  142.     ansic_x(1); outstr(get_string(605));
  143.     ansic_x(2); npr("%d",actsl);
  144.     pl(")");
  145.   } else
  146.     nl();
  147.   ansic_x(1); outstr(get_string(606));
  148.   ansic_x(2); pln(thisuser.dsl);
  149.   ansic_x(1); outstr(get_string(1004));
  150.   ansic_x(2); pl(thisuser.laston);
  151.   ansic_x(1); outstr(get_string(607));
  152.   ansic_x(2); pln(thisuser.logons);
  153.   ansic_x(1); outstr(get_string(608));
  154.   ansic_x(2); pln(thisuser.ontoday);
  155.   ansic_x(1); outstr(get_string(609));
  156.   ansic_x(2); pln(thisuser.msgpost);
  157.   ansic_x(1); outstr(get_string(610));
  158.   ansic_x(2); pln((thisuser.emailsent+thisuser.feedbacksent+thisuser.emailnet));
  159.   ansic_x(1); outstr(get_string(611));
  160.   ansic_x(2); npr("%ld",(long)((thisuser.timeon+timer()-timeon)/60.0));
  161.   pl(get_string(612));
  162.  
  163. }
  164.  
  165. /****************************************************************************/
  166.  
  167. /*
  168.  * Allows user to upload a post.
  169.  */
  170.  
  171. void upload_post(void)
  172. {
  173.   char s[81],ch;
  174.   int i,maxli,f;
  175.   long l,l1;
  176.  
  177.   if (actsl<=syscfg.newusersl)
  178.     maxli=60;
  179.   else if (cs())
  180.     maxli=120;
  181.   else
  182.     maxli=80;
  183.  
  184.   sprintf(s,"%sINPUT.MSG",syscfgovr.tempdir);
  185.   l1=250*(long)maxli;
  186.  
  187.   nl();
  188.   outstr(get_string(613));
  189.   npr("%ld\r\n",l1);
  190.   nl();
  191.   receive_file(s,&i,&ch, "INPUT.MSG", -1);
  192.   f=sh_open1(s,O_RDWR | O_BINARY);
  193.   if (f>0) {
  194.     l=filelength(f);
  195.     if (l>l1) {
  196.       nl();
  197.       pl(get_string(614));
  198.       nl();
  199.       sh_close(f);
  200.       unlink(s);
  201.     } else {
  202.       sh_close(f);
  203.       use_workspace=1;
  204.       nl();
  205.       pl(get_string(615));
  206.       nl();
  207.     }
  208.   } else {
  209.     nl();
  210.     pl(get_string(452));
  211.     nl();
  212.   }
  213. }
  214.  
  215. /****************************************************************************/
  216.  
  217. /*
  218.  * Copies a file (filename=*input) to another destination (filename=*output).
  219.  */
  220.  
  221. void copy_file(char *input, char *output)
  222. {
  223.   int f1, f2, i;
  224.   char *b;
  225.   struct ftime ft;
  226.  
  227.   if ((strcmp(input, output) != 0) && (exist(input)) && (!exist(output))) {
  228.     if ((b = malloca(16400)) == NULL)
  229.       return;
  230.     f1 = sh_open1(input, O_RDONLY | O_BINARY);
  231.     getftime(f1, &ft);
  232.     f2 = sh_open(output, O_RDWR | O_BINARY | O_CREAT | O_TRUNC, S_IREAD | S_IWRITE);
  233.     i = read(f1, (void *) b, 16384);
  234.     while (i > 0) {
  235.       write(f2, (void *) b, i);
  236.       i = read(f1, (void *) b, 16384);
  237.     }
  238.     f1=sh_close(f1);
  239.     setftime(f2, &ft);
  240.     f2=sh_close(f2);
  241.     bbsfree(b);
  242.   }
  243. #ifdef LAZY_WRITES
  244.   wait1(LAZY_WRITES);
  245. #endif
  246. }
  247.  
  248. /****************************************************************************/
  249.  
  250. /*
  251.  * Handles reading short messages. This is also where PackScan file requests
  252.  * plug in, if such are used.
  253.  */
  254.  
  255. void rsm(int un, userrec *u, int mode)
  256. {
  257.   shortmsgrec sm;
  258.   int i,i1,f,handled,any, all;
  259.   char s1[81];
  260.  
  261.   any=0;
  262.   all=1;
  263.   if ((u->sysstatus) & sysstatus_smw) {
  264.     sprintf(s1,"%sSMW.DAT",syscfg.datadir);
  265.     f=sh_open(s1,O_RDWR | O_BINARY | O_CREAT, S_IREAD | S_IWRITE);
  266.     if (f<0)
  267.       return;
  268.     i=(int) (filelength(f) / sizeof(shortmsgrec));
  269.     for (i1=0; i1<i; i1++) {
  270.       sh_lseek(f,((long) (i1)) * sizeof(shortmsgrec),SEEK_SET);
  271.       sh_read(f,(void *)&sm,sizeof(shortmsgrec));
  272.       if ((sm.touser==un) && (sm.tosys==0)) {
  273.         pl(sm.message);
  274.         handled=0;
  275.         any=1;
  276.         if ((!so()) || (!mode)) {
  277.           handled=1;
  278.         } else {
  279.           if (sysinfo.flags & OP_FLAGS_PACKSCAN_FREQ) {
  280.             if ( (strstr(sm.message,"UPL"))
  281.               || (strstr(sm.message,"upload "))
  282.               || (strstr(sm.message,"U/L"))) {
  283.               handled=mode;
  284.               handled=remoteupload(sm.message);
  285.             }
  286.           } else {
  287.             handled=mode;
  288.             handled=0;
  289.           }
  290.  
  291.           if (sysinfo.flags & OP_FLAGS_CAN_SAVE_SSM) {
  292.             if ((handled==0) && (mode)) {
  293.               npr(get_string(1044));
  294.               handled=!yn();
  295.             }
  296.           } else {
  297.             handled=1;
  298.           }
  299.  
  300.         }
  301.         if (handled==1) {
  302.           sm.touser=0;
  303.           sm.tosys=0;
  304.           sm.message[0]=0;
  305.           sh_lseek(f,((long) (i1)) * sizeof(shortmsgrec),SEEK_SET);
  306.           sh_write(f,(void *)&sm,sizeof(shortmsgrec));
  307.         } else {
  308.           all=0;
  309.         }
  310.       }
  311.     }
  312.     sh_close(f);
  313.     smwcheck=1;
  314.   }
  315.   if (any)
  316.     nl();
  317.   if (all)
  318.     u->sysstatus &= ~sysstatus_smw;
  319. }
  320.  
  321. /****************************************************************************/
  322.  
  323. void show_chains(int *mapp, int *map)
  324. {
  325.   int abort=0,i,i1;
  326.   char s[121],s1[121];
  327.   userrec u;
  328.  
  329.   if ((sysinfo.flags & OP_FLAGS_CHAIN_REG) && chains_reg) {
  330.     abort=0;
  331.     nl();
  332.     strcpy(s,get_string(1045));
  333.     sprintf(s1,"%-42.42s2",get_string(1046));
  334.     strcat(s,s1);
  335.     sprintf(s1,"%-22.22s1",get_string(1047));
  336.     strcat(s,s1);
  337.     sprintf(s1,"%-5.5s",get_string(1048));
  338.     strcat(s,s1);
  339.     pla(s,&abort);
  340.  
  341.     if (okansi())
  342.       sprintf(s,"%d %s",FRAME,get_string(1049));
  343.     else
  344.       sprintf(s,get_string(1050));
  345.     pla(s,&abort);
  346.     for (i=0; (i<*mapp) && (!abort) && (!hangup); i++) {
  347.       strcat(s,". ");
  348.       if (okansi()) {
  349.         read_user(chains_reg[map[i]].regby[0],&u);
  350.         sprintf(s," %d║5%3d%d║1%-41s%d║%d%-21s%d║1%5d%d║",
  351.           FRAME, i+1, FRAME, chains[map[i]].description,
  352.           FRAME, (chains_reg[map[i]].regby[0])?2:3,
  353.           (chains_reg[map[i]].regby[0]) ? u.name : get_string(315),
  354.           FRAME, chains_reg[map[i]].usage, FRAME );
  355.         pla(s,&abort);
  356.         if (chains_reg[map[i]].regby[0]!=0) {
  357.           for(i1=1;i1<5;i1++) {
  358.             if (chains_reg[map[i]].regby[i1]!=0) {
  359.               read_user(chains_reg[map[i]].regby[i1],&u);
  360.               sprintf(s," %d║   ║%-41s║2%-21s%d║%5.5s║",
  361.                 FRAME, " ", u.name, FRAME, " ");
  362.               pla(s,&abort);
  363.             }
  364.           }
  365.         }
  366.       } else {
  367.         read_user(chains_reg[map[i]].regby[0],&u);
  368.         sprintf(s," |%3d|%-41.41s|%-21.21s|%5d|",
  369.           i+1,chains[map[i]].description,
  370.           (chains_reg[map[i]].regby[0]) ? u.name : get_string(315),
  371.           chains_reg[map[i]].usage);
  372.         pla(s,&abort);
  373.         if (chains_reg[map[i]].regby[0]!=0) {
  374.           for(i1=1;i1<5;i1++) {
  375.             if (chains_reg[map[i]].regby[i1]!=0) {
  376.               read_user(chains_reg[map[i]].regby[i1],&u);
  377.               sprintf(s," |%3.3s|%-41.41s|%-21.21s|%5.5s|",
  378.                 " "," ",(chains_reg[map[i]].regby[i1]) ?
  379.                 u.name : get_string(315)," ");
  380.               pla(s,&abort);
  381.             }
  382.           }
  383.         }
  384.       }
  385.     }
  386.     if (okansi())
  387.       sprintf(s,"%d %s",FRAME,get_string(1051));
  388.     else
  389.       sprintf(s,get_string(1052));
  390.     pla(s,&abort);
  391.  
  392.   } else {
  393.  
  394.     abort=0;
  395.     nl();
  396.     for (i=0; (i<*mapp) && (!abort) && (!hangup); i++) {
  397.       sprintf(s,"%d. %s",i+1, chains[map[i]].description);
  398.       pla(s,&abort);
  399.     }
  400.     nl();
  401.   }
  402. }
  403.  
  404. /****************************************************************************/
  405.  
  406. /*
  407.  * Executes a "chain", index number cn.
  408.  */
  409.  
  410. void run_chain(int cn)
  411. {
  412.   char s[255],s1[81],s2[81],s3[81];
  413.   int oc,inst,f;
  414.   unsigned short fl;
  415.  
  416.   inst=(inst_ok(INST_LOC_CHAINS, cn+1));
  417.   if (inst!=0) {
  418.     strcpy(s,get_string(1053));
  419.     strcat(s,chains[cn].description);
  420.     strcat(s,get_string(1054));
  421.     sprintf(s1,"%d.  ",inst);
  422.     strcat(s,s1);
  423.     if (!(chains[cn].ansir & ansir_multi_user)) {
  424.       strcat(s,get_string(1055));
  425.       pl(s);
  426.       return;
  427.     } else {
  428.       strcat(s,get_string(1056));
  429.       outstr(s);
  430.       if (!(yn()))
  431.         return;
  432.     }
  433.   }
  434.  
  435.   write_inst(INST_LOC_CHAINS, cn+1, INST_FLAGS_NONE);
  436.   if ((sysinfo.flags & OP_FLAGS_CHAIN_REG) && chains_reg) {
  437.     chains_reg[cn].usage++;
  438.     sprintf(s,"%s%s",syscfg.datadir,get_string(1057));
  439.     f=sh_open(s,O_RDWR | O_BINARY | O_CREAT | O_TRUNC, S_IREAD | S_IWRITE);
  440.     if (f) {
  441.       sh_write(f,(void *)chains_reg, numchain * sizeof(chainregrec));
  442.       f=sh_close(f);
  443.     }
  444.   }
  445.   itoa(com_speed, s1, 10);
  446.   if ((com_speed==1) || (com_speed==49664))
  447.     strcpy(s1,"115200");
  448.   itoa(syscfgovr.primaryport,s2,10);
  449.   itoa(modem_speed, s3, 10);
  450.   stuff_in(s,chains[cn].filename,create_chain_file(),s1,s2,s3,"");
  451.   sprintf(s2,get_stringx(1,35),chains[cn].description);
  452.   sysoplog(s2);
  453.   oc=chatcall;
  454.   chatcall=0;
  455.   thisuser.chainsrun++;
  456.   fl=0;
  457.   if (!(chains[cn].ansir & ansir_no_DOS))
  458.     fl |= EFLAG_COMIO;
  459.   if (chains[cn].ansir & ansir_shrink)
  460.     fl |= EFLAG_SHRINK|EFLAG_FILES;
  461.   if (chains[cn].ansir & ansir_no_pause)
  462.     fl |= EFLAG_NOPAUSE;
  463.  
  464.   extern_prog(s, fl);
  465.  
  466.   chatcall=oc;
  467.   topscreen();
  468. }
  469.  
  470. /****************************************************************************/
  471.  
  472. /*
  473.  * Main high-level function for chain access and execution.
  474.  */
  475.  
  476. void do_chains(void)
  477. {
  478.   int *map,mapp,i,ok,done,start=0;
  479.   char *ss,s[67];
  480.   chainfilerec c;
  481.   chainregrec r;
  482.  
  483.   if (menu_on()) {
  484.     rip_cls();
  485.   }
  486.  
  487.   map=(int *)malloca(sysinfo.max_chains * sizeof(int));
  488.   if (!map)
  489.     return;
  490.  
  491.   tleft(1);
  492.   mapp=0;
  493.   memset(odc, 0, sizeof(odc));
  494.   /* memset(otc, 0, sizeof(otc)); */
  495.   for (i=0; i<numchain; i++) {
  496.     ok=1;
  497.     c=chains[i];
  498.     if ((c.ansir & ansir_ansi) && (!okansi()))
  499.       ok=0;
  500.     if ((c.ansir & ansir_rip_only) && (!rip_on()))
  501.       ok=0;
  502.     if ((c.ansir & ansir_no_300) && (modem_speed==300) && incom)
  503.       ok=0;
  504.     if ((c.ansir & ansir_local_only) && (using_modem))
  505.       ok=0;
  506.     if (c.sl>actsl)
  507.       ok=0;
  508.     if (c.ar)
  509.       if ((c.ar & thisuser.ar)==0)
  510.         ok=0;
  511.     if ((sysinfo.flags & OP_FLAGS_CHAIN_REG) && chains_reg && (actsl<255)) {
  512.       r=chains_reg[i];
  513.       if (r.maxage) {
  514.         if ((r.minage>thisuser.age) || (r.maxage < thisuser.age))
  515.           ok=0;
  516.       }
  517.     }
  518.     if (ok) {
  519.       map[mapp++]=i;
  520.       if (mapp<100) {
  521.         if ((mapp % 10) ==0)
  522.           odc[mapp/10 -1]='0'+(mapp/10);
  523.       } else {
  524.         /* if ((mapp%100)==0)
  525.           otc[mapp/100 -1] = '0' + (mapp/100); */
  526.       }
  527.     }
  528.   }
  529.   if (mapp==0) {
  530.     nln(2);
  531.     pl(get_string(620));
  532.     nl();
  533.     bbsfree(map);
  534.     return;
  535.   }
  536. #ifdef AUTO_START
  537.   if (mapp==1) {
  538.     run_chain(map[0]);
  539.     bbsfree(map);
  540.     return;
  541.   }
  542. #endif
  543.   if ((menu_on() == 0) || rip_subset)
  544.     show_chains(&mapp,map);
  545.  
  546.   done=0;
  547.   curdloads=0;
  548.   do {
  549.     tleft(1);
  550.  
  551.     if (menu_on() && (rip_subset==0))
  552.       rip_show_chains(&mapp,map,start);
  553.     nl();
  554.     outstr(get_string(1058));
  555.     npr("%d",mapp);
  556.     outstr(get_string(1059));
  557.  
  558.     if (mapp<100) {
  559.       ss=mmkey(2);
  560.       i=atoi(ss);
  561.     } else {
  562.       input(s,3);
  563.       i=atoi(s);
  564.     }
  565.     if ((i>0) && (i<=mapp)) {
  566.       done=1;
  567.       curdloads=2;
  568.  
  569.       if (menu_on()) {
  570.         rip_cls();
  571.         sprintf(s,"%sdoor%d.rip",languagedir,map[i-1]+1);
  572.         if (exist(s)) {
  573.           ripcode = 1;
  574.           maybeprint(s,2);
  575.           ripcode=0;
  576.         }
  577.       }
  578. #ifdef RIPDRIVE
  579.       if (rd_on())
  580.         localrip_deactivate();
  581. #endif
  582.       run_chain(map[i-1]);
  583. #ifdef RIPDRIVE
  584.       if (rd_on())
  585.         localrip_activate(sysinfo.ripdir, sysinfo.ripdir);
  586. #endif
  587.       rip_cls();
  588.     } else
  589.       if (strcmp(ss,"Q")==0)
  590.         done=1;
  591.       else if (strcmp(ss,"?")==0)
  592.           show_chains(&mapp,map);
  593.       else if (strcmp(ss,"P")==0) {
  594.         if (start > 0)
  595.           start -= 14;
  596.         if (start < 0)
  597.           start = 0;
  598.       } else if (strcmp(ss,"N")==0) {
  599.         if (start+14 < mapp)
  600.           start += 14;
  601.       }
  602.   } while ((!hangup) && (!done));
  603.   if (menu_on()) {
  604.     nl();
  605.     rip_cls();
  606.     cleared = -1;
  607.     rmenu = 300;                  /* Menu bar stuff */
  608.   }
  609.  
  610.   bbsfree(map);
  611. }
  612.  
  613. /****************************************************************************/
  614.  
  615. /*
  616.  * Compresses file *fn to directory *dir.
  617.  */
  618.  
  619. void compress_file(char *fn, char *dir)
  620. {
  621.   char s1[161],s2[81],s3[81],s4[81],s5[81], *ss;
  622.  
  623.   outstr(get_string(1196));
  624.   pl(fn);
  625.   if (strchr(fn,'.')==NULL)
  626.     strcat(fn,".MSG");
  627.   strcpy(s1,fn);
  628.   strcpy(s2, fn);
  629.   ss=strchr(s2,'.');
  630.   if (ss) ss[1]=0;
  631.   strcat(s2,syscfg.arcs[0].extension);
  632.   strcpy(s5,syscfg.arcs[0].arca);
  633.   strcpy(s3,dir);
  634.   strcat(s3,s2);
  635.   strcpy(s4,dir);
  636.   strcat(s4,s1);
  637.   stuff_in(s1,s5,s3,s4,"","","");
  638.   extern_prog(s1, sysinfo.spawn_opts[11]);
  639.   unlink(s4);
  640.   topscreen();
  641. }
  642.  
  643. /****************************************************************************/
  644.  
  645. /*
  646.  * Allows extracting a message into a file area, directly.
  647.  */
  648.  
  649. void extract_mod(char *b, long len)
  650. {
  651.   char s1[81],s2[81],s4[81],ch=26,ch1,*ss1;
  652.   int i,i1,exists,quit,mod_dir;
  653.  
  654.   tmp_disable_conf(1);
  655.   do {
  656.     prt(2,get_string(1198));
  657.     ss1=mmkey(1);
  658.     if (ss1[0]=='?')
  659.       dirlist();
  660.   } while ((!hangup) && (ss1[0]=='?'));
  661.  
  662.   mod_dir=-1;
  663.   for (i1=0; (i1<num_dirs) && (udir[i1].subnum!=-1); i1++)
  664.     if (strcmp(udir[i1].keys,ss1)==0)
  665.       mod_dir=i1;
  666.  
  667.   if (mod_dir==-1) {
  668.     goto go_away;
  669.   }
  670.  
  671.   strcpy(s1,directories[udir[mod_dir].subnum].path);
  672.   do {
  673.     exists=quit=0;
  674.     prt(2,get_string(1199));
  675.     input(s2,12);
  676.     if (!s2[0]) {
  677.       goto go_away;
  678.     }
  679.     if (strchr(s2,'.')==NULL)
  680.       strcat(s2,".MOD");
  681.     sprintf(s4,"%s%s",s1,s2);
  682.     if (exist(s4)) {
  683.       exists=1;
  684.       sprintf(s4,"%s%s",s2,get_string(1200));
  685.       nl();
  686.       pl(s4);
  687.       nl();
  688.     }
  689.     if (exists==1) {
  690.       prt(2,get_string(1201));
  691.       ch1=onek("QN");
  692.       switch(ch1) {
  693.         case 'Q':
  694.           quit=1;
  695.           break;
  696.         case 'N':
  697.           s2[0]=0;
  698.           break;
  699.       }
  700.       nl();
  701.     }
  702.   } while ((!hangup) && (s2[0]==0) && (!quit));
  703.  
  704.   if ((quit!=1) && (!hangup)) {
  705.     i=sh_open(s4,O_RDWR | O_BINARY | O_CREAT, S_IREAD | S_IWRITE);
  706.     sh_lseek(i,0L,SEEK_END);
  707.     sh_write(i,(void *)b,len);
  708.     sh_write(i,&ch,1);
  709.     sh_close(i);
  710.     npr("%s%s\r\n",get_string(1202),s4);
  711.     compress_file(s2,s1);
  712.     nln(2);
  713.     prt(2,get_string(1203));
  714.     if (yn()) {
  715.       prt(5,get_string(1204));
  716.       quit=uploadall(mod_dir);
  717.     }
  718.   }
  719. go_away:
  720.   tmp_disable_conf(0);
  721. }
  722.  
  723. void extract_out(char *b, long len, char *title)
  724. {
  725.   char s1[81],s2[81],s3[81],ch=26,ch1;
  726.   int i,done;
  727.  
  728.   if (sysinfo.flags & OP_FLAGS_NEW_EXTRACT) {
  729.     do {
  730.       s1[0]=0; s2[0]=0; s3[0]=0;
  731.       done=1;
  732.       if (menu_on()) {
  733.         rip_saveall();
  734.         printmenu(18);
  735.       } else
  736.         prt(5,get_string(1197));
  737.       ch1=onek("Q1234?");
  738.       if (menu_on())
  739.         rip_restoreall();
  740.       switch(ch1) {
  741.         case '1':
  742.           extract_mod(b,len);
  743.           break;
  744.         case '2':
  745.           strcpy(s2,syscfg.gfilesdir);
  746.           break;
  747.         case '3':
  748.           strcpy(s2,syscfg.datadir);
  749.           break;
  750.         case '4':
  751.           strcpy(s2,syscfgovr.tempdir);
  752.           break;
  753.         case '?':
  754.           printmenu(18);
  755.           done=0;
  756.           break;
  757.       }
  758.     } while ((!done) && (!hangup));
  759.  
  760.     if (s2[0]) {
  761.       do {
  762.         prt(2,get_string(674));
  763.         input(s1,50);
  764.         if (s1[0]) {
  765.           if (strchr(s1,':') || strchr(s1,'\\'))
  766.             strcpy(s3,s1);
  767.           else
  768.             sprintf(s3,"%s%s",s2,s1);
  769.           if (exist(s3)) {
  770.             nl();
  771.             pl(get_string(675));
  772.             nl();
  773.             outstr(get_string(676));
  774.             ch1=onek("QOAN");
  775.             switch(ch1) {
  776.               case 'Q':
  777.                 s3[0]=1;
  778.                 s1[0]=0;
  779.                 break;
  780.               case 'N':
  781.                 s3[0]=0;
  782.                 break;
  783.               case 'A':
  784.                 break;
  785.               case 'O':
  786.                 unlink(s3);
  787.                 break;
  788.             }
  789.             nl();
  790.           }
  791.         } else
  792.           s3[0]=1;
  793.       } while ((!hangup) && (s3[0]==0));
  794.       if ((s3[0]) && (!hangup)) {
  795.         if (s3[0]!=1) {
  796.           i=sh_open(s3,O_RDWR | O_BINARY | O_CREAT , S_IREAD | S_IWRITE);
  797.           if (i<=0) {
  798.             pl(get_string(933));
  799.           } else {
  800.             if (filelength(i)) {
  801.               sh_lseek(i, -1L, SEEK_END);
  802.               sh_read(i, ((void *)&ch1), 1);
  803.               if (ch1 == 26)
  804.                 sh_lseek(i, -1L, SEEK_END);
  805.             }
  806.             sh_write(i,title,strlen(title));
  807.             sh_write(i,"\r\n",2);
  808.             sh_write(i,(void *)b,len);
  809.             sh_write(i,&ch,1);
  810.             sh_close(i);
  811.             outstr(get_string(677));
  812.             pl(s3);
  813.           }
  814.         }
  815.       }
  816.     }
  817.   } else {
  818.     do {
  819.       prt(2,get_string(674));
  820.       input(s1,50);
  821.       if (s1[0]) {
  822.         if (strchr(s1,':') || strchr(s1,'\\'))
  823.           strcpy(s2,s1);
  824.         else
  825.           sprintf(s2,"%s%s",syscfg.gfilesdir,s1);
  826.         if (exist(s2)) {
  827.           nl();
  828.           pl(get_string(675));
  829.           nl();
  830.           outstr(get_string(676));
  831.           ch1=onek("QOAN");
  832.           switch(ch1) {
  833.             case 'Q':
  834.               s2[0]=0;
  835.               s1[0]=0;
  836.               break;
  837.             case 'N':
  838.               s1[0]=0;
  839.               break;
  840.             case 'A':
  841.               break;
  842.             case 'O':
  843.               unlink(s2);
  844.               break;
  845.           }
  846.           nl();
  847.         }
  848.       } else
  849.         s2[0]=0;
  850.     } while ((!hangup) && (s2[0]!=0) && (s1[0]==0));
  851.     if ((s1[0]) && (!hangup)) {
  852.       i=sh_open(s2,O_RDWR | O_BINARY | O_CREAT , S_IREAD | S_IWRITE);
  853.       if (i<=0) {
  854.         pl(get_string(933));
  855.       } else {
  856.         if (filelength(i)) {
  857.           sh_lseek(i, -1L, SEEK_END);
  858.           sh_read(i, ((void *)&ch1), 1);
  859.           if (ch1 == 26)
  860.             sh_lseek(i, -1L, SEEK_END);
  861.         }
  862.         sh_write(i,title,strlen(title));
  863.         sh_write(i,"\r\n",2);
  864.         sh_write(i,(void *)b,len);
  865.         sh_write(i,&ch,1);
  866.         sh_close(i);
  867.         outstr(get_string(677));
  868.         pl(s2);
  869.       }
  870.     }
  871.   }
  872.   bbsfree(b);
  873. }
  874.  
  875. /****************************************************************************/
  876.  
  877. /*
  878.  * High-level function for sending email.
  879.  */
  880.  
  881. void send_email(void)
  882. {
  883.   char s1[81];
  884.   unsigned short sy,un;
  885.  
  886.   write_inst(INST_LOC_EMAIL,0,INST_FLAGS_NONE);
  887.   nln(2);
  888.   pl(get_string(15));
  889.   helpl=14;
  890.   outstr(":");
  891.   input(s1,75);
  892.   helpl=0;
  893.   irt[0]=0;
  894.   irt_name[0]=0;
  895.   parse_email_info(s1,&un,&sy);
  896.   grab_quotes(NULL, NULL);
  897.   if (un || sy)
  898.     email(un,sy,0,0);
  899. }
  900.  
  901. /****************************************************************************/
  902.  
  903. /*
  904.  * High-level function for selecting conference type to edit.
  905.  */
  906.  
  907. void edit_confs(void)
  908. {
  909.   char ch;
  910.  
  911.   if (!checkpw())
  912.     return;
  913.  
  914.   nln(2);
  915.   pl(get_string(1023));
  916.   nl();
  917.   pl(get_string(1024));
  918.   pl(get_string(1025));
  919.   nl();
  920.   outstr(get_string(1026));
  921.   ch=onek("Q12");
  922.   switch (ch) {
  923.     case '1':
  924.       conf_edit(CONF_SUBS);
  925.       break;
  926.     case '2':
  927.       conf_edit(CONF_DIRS);
  928.       break;
  929.     default:
  930.       break;
  931.   }
  932. }
  933.  
  934. /****************************************************************************/
  935.  
  936. /*
  937.  * If nuf>0 then this is newuser feedback, else it is "normal" feedback.
  938.  * Shows users with usernum<10 who are sysops, so user can select which
  939.  * sysop to leave feedback to.
  940.  */
  941.  
  942. void feedback(int nuf)
  943. {
  944.   int i,i1,nu;
  945.   char onek_str[20],ch;
  946.   userrec u;
  947.  
  948.   irt_name[0]=0;
  949.   grab_quotes(NULL, NULL);
  950.  
  951.   if (nuf) {
  952.     read_status();
  953.     sprintf(irt,get_stringx(1,30),syscfg.maxusers-status.users);
  954.     email(1,0,1,0);
  955.     return;
  956.   }
  957.  
  958.   strcpy(irt,get_stringx(1,14));
  959.   nu=number_userrecs();
  960.   i1=0;
  961.  
  962.   for (i=2; (i<10) && (i<nu); i++) {
  963.     read_user(i,&u);
  964.     if (((u.sl==255) || (syscfg.sl[u.sl].ability & ability_cosysop)) &&
  965.        ((u.inact & inact_deleted)==0)) {
  966.       i1++;
  967.     }
  968.   }
  969.  
  970.   if (!i1) {
  971.     i=1;
  972.   } else {
  973.     onek_str[0]=0;
  974.     i1=0;
  975.     nl();
  976.     for (i=1;((i<10) && (i<nu));i++) {
  977.       read_user(i,&u);
  978.       if (((u.sl==255) || (syscfg.sl[u.sl].ability & ability_cosysop)) &&
  979.          ((u.inact & inact_deleted)==0)) {
  980.         ansic(2); npr("%d",i);
  981.         ansic(7); npr(")");
  982.         ansic(1); npr(" %s",nam(&u,i));
  983.         nl();
  984.         onek_str[i1++]='0'+i;
  985.       }
  986.     }
  987.     onek_str[i1++]=*str_quit;
  988.     onek_str[i1]=0;
  989.     nl();
  990.     ansic(1); npr("%s (%s): ",get_string(1003), onek_str);
  991.     mpl(1);
  992.     ch=onek(onek_str);
  993.     if (ch==*str_quit)
  994.       return;
  995.     nl();
  996.     i=ch-'0';
  997.   }
  998.   email(i,0,0,0);
  999. }
  1000.  
  1001. /****************************************************************************/
  1002.  
  1003. /*
  1004.  * Lists the available subs for the current user.
  1005.  */
  1006.  
  1007. void sublist(void)
  1008. {
  1009.   int i,i1,abort,oc,os,sn,en;
  1010.   char s[80],s1[80],*ss,ch;
  1011.  
  1012.   oc=curconfsub; os=usub[cursub].subnum;
  1013.  
  1014.   abort=0;
  1015.   sn=0;
  1016.   en=subconfnum-1;
  1017.   if (okconf(&thisuser)) {
  1018.     if (uconfsub[1].confnum!=-1) {
  1019.       nl();
  1020.       prt(2,get_string(1019));
  1021.       ch=onek("Q A");
  1022.       nl();
  1023.       switch (ch) {
  1024.         case ' ':
  1025.           sn=curconfsub;
  1026.           en=curconfsub;
  1027.           break;
  1028.         case 'Q':
  1029.           return;
  1030.       }
  1031.     }
  1032.   } else
  1033.     oc=-1;
  1034.  
  1035.   nl();
  1036.   ansic_x(1);
  1037.   pla(get_string(617),&abort);
  1038.   nl();
  1039.   i=sn;
  1040.   while ((i<=en) && (uconfsub[i].confnum!=-1) && (!abort)) {
  1041.     if ((uconfsub[1].confnum!=-1) && (okconf(&thisuser))) {
  1042.       setuconf(CONF_SUBS, i, -1);
  1043.       sprintf(s,"1%s %c0:2 %s",get_string(1021),
  1044.         subconfs[uconfsub[i].confnum].designator,
  1045.         stripcolors(subconfs[uconfsub[i].confnum].name));
  1046.       if (E_C) {
  1047.         pla(s,&abort);
  1048.       } else {
  1049.         pla(stripcolors(s),&abort);
  1050.       }
  1051.     }
  1052.     i1=0;
  1053.     while ((i1<num_subs) && (usub[i1].subnum!=-1) && (!abort)) {
  1054.       sprintf(s,"  5%4.4s2",usub[i1].keys);
  1055.       if (qsc_q[usub[i1].subnum/32]&(1L<<(usub[i1].subnum%32)))
  1056.         strcat(s,get_string(3));
  1057.       else
  1058.         strcat(s,get_string(4));
  1059.       if (net_sysnum || (net_num_max>1)) {
  1060.         if (xsubs[usub[i1].subnum].num_nets) {
  1061.           if (xsubs[usub[i1].subnum].num_nets>1)
  1062.             ss=get_string(1022);
  1063.           else
  1064.             ss=stripcolors(net_networks[xsubs[usub[i1].subnum].nets[0].net_num].name);
  1065.           if (subboards[usub[i1].subnum].anony & anony_val_net)
  1066.             sprintf(s1,"4[%-8.8s]9 ",ss);
  1067.           else
  1068.             sprintf(s1,"4<%-8.8s>9 ",ss);
  1069.           strcat(s,s1);
  1070.         } else
  1071.           strcat(s,charstr(11,' '));
  1072.           strcat(s,"9");
  1073.       }
  1074.       strcat(s,stripcolors(subboards[usub[i1].subnum].name));
  1075.       if (E_C) {
  1076.         pla(s,&abort);
  1077.       } else {
  1078.         pla(stripcolors(s),&abort);
  1079.       }
  1080.       i1++;
  1081.     }
  1082.     i++;
  1083.     nl();
  1084.     if (!okconf(&thisuser))
  1085.       break;
  1086.   }
  1087.   if (i==0) {
  1088.     ansic(6);
  1089.     pla(get_string(5),&abort);
  1090.     nl();
  1091.   }
  1092.  
  1093.   if (okconf(&thisuser))
  1094.     setuconf(CONF_SUBS, oc, os);
  1095. }
  1096.  
  1097. /****************************************************************************/
  1098.  
  1099. /*
  1100.  * Displays the available file areas for the current user.
  1101.  */
  1102.  
  1103. void dirlist(void)
  1104. {
  1105.   int i,i1,oc,os,abort,sn,en;
  1106.   char s[80],ch;
  1107.  
  1108.   oc=curconfdir; os=udir[curdir].subnum;
  1109.  
  1110.   abort=0;
  1111.   sn=0;
  1112.   en=dirconfnum-1;
  1113.   if (okconf(&thisuser)) {
  1114.     if (uconfdir[1].confnum!=-1) {
  1115.       nl();
  1116.       prt(2,get_string(1019));
  1117.       ch=onek("Q A");
  1118.       nl();
  1119.       switch (ch) {
  1120.         case ' ':
  1121.           sn=curconfdir;
  1122.           en=curconfdir;
  1123.           break;
  1124.         case 'Q':
  1125.           return;
  1126.       }
  1127.     }
  1128.   } else
  1129.     oc=-1;
  1130.  
  1131.  
  1132.   nl();
  1133.   ansic_x(1);
  1134.   pla(get_string(6),&abort);
  1135.   nl();
  1136.   i=sn;
  1137.   while ((i<=en) && (uconfdir[i].confnum!=-1) && (!abort)) {
  1138.     if ((uconfdir[1].confnum!=-1) && (okconf(&thisuser))) {
  1139.       setuconf(CONF_DIRS, i, -1);
  1140.       sprintf(s,"1%s %c0:2 %s",get_string(1021),
  1141.         dirconfs[uconfdir[i].confnum].designator,
  1142.         stripcolors(dirconfs[uconfdir[i].confnum].name));
  1143.       if (E_C) {
  1144.         pla(s,&abort);
  1145.       } else {
  1146.         pla(stripcolors(s),&abort);
  1147.       }
  1148.     }
  1149.     i1=0;
  1150.     while ((i1<num_dirs) && (udir[i1].subnum!=-1) && (!abort)) {
  1151.       sprintf(s,"  5%4.4s2 - 9%s",udir[i1].keys,
  1152.         stripcolors(directories[udir[i1].subnum].name));
  1153.       if (E_C) {
  1154.         pla(s,&abort);
  1155.       } else {
  1156.         pla(stripcolors(s),&abort);
  1157.       }
  1158.       i1++;
  1159.     }
  1160.     nl();
  1161.     i++;
  1162.     if (!okconf(&thisuser))
  1163.       break;
  1164.   }
  1165.   if (i==0) {
  1166.     ansic(6);
  1167.     pla(get_string(5),&abort);
  1168.     nl();
  1169.   }
  1170.   setuconf(CONF_DIRS, oc, os);
  1171. }
  1172.  
  1173. /****************************************************************************/
  1174.  
  1175. /*
  1176.  * Allows editing of ASCII textfiles. Must have an external editor defined,
  1177.  * and toggled for use in defaults.
  1178.  */
  1179.  
  1180. void text_edit(void)
  1181. {
  1182.   char s[81],s1[81];
  1183.  
  1184.   nl();
  1185.   prt(2,get_string(44));
  1186.   mpl(12);
  1187.   input(s,12);
  1188.   if (strstr(s,".LOG")!=NULL)
  1189.     s[0]=0;
  1190.   if (!okfn(s))
  1191.     s[0]=0;
  1192.   if (s[0]) {
  1193.     sprintf(s1,get_stringx(1,1),s);
  1194.     sysoplog(s1);
  1195.     if (okfsed())
  1196.       external_edit(s,syscfg.gfilesdir,thisuser.defed-1,500,syscfg.gfilesdir,s,1);
  1197.     else {
  1198.       sprintf(s1,"%s%s",syscfg.gfilesdir, s);
  1199.       tedit(s1);
  1200.     }
  1201.   }
  1202. }
  1203.  
  1204. /****************************************************************************/
  1205.