home *** CD-ROM | disk | FTP | other *** search
/ The Devil's Doorknob BBS Capture (1996-2003) / devilsdoorknobbbscapture1996-2003.iso / W / DEVBBS.ZIP / SHRINK.C < prev    next >
C/C++ Source or Header  |  1992-07-20  |  4KB  |  211 lines

  1. /*****************************************************************************
  2.  
  3.                                 WWIV Version 4
  4.                     Copyright (C) 1988-1991 by Wayne Bell
  5.  
  6. *****************************************************************************/
  7.  
  8. #include "vars.h"
  9. #pragma hdrstop
  10. #include <process.h>
  11. #include <dir.h>
  12. #define READ(x) read(f,&(x),sizeof(x))
  13. #define WRITE(x) write(f,&(x),sizeof(x))
  14.  
  15. int restore_data(char *s)
  16. {
  17.   int f,stat;
  18.  
  19.   f=open(s,O_RDONLY | O_BINARY);
  20.   if (f<0)
  21.     return(-1);
  22.   READ(stat);
  23.   READ(oklevel);
  24.   READ(noklevel);
  25.   READ(ooneuser);
  26.   READ(no_hangup);
  27.   READ(ok_modem_stuff);
  28.   READ(topdata);
  29.   READ(last_time_c);
  30.   READ(sysop_alert);
  31.   READ(do_event);
  32.   if (stat) {
  33.     READ(andwith);
  34.     READ(usernum);
  35.     READ(chatcall);
  36.     READ(chatreason);
  37.     READ(timeon);
  38.     READ(extratimecall);
  39.     READ(curspeed);
  40.     READ(modem_speed);
  41.     READ(com_speed);
  42.     READ(modem_flag);
  43.     READ(cursub);
  44.     READ(curdir);
  45.     READ(curdloads);
  46.     READ(msgreadlogon);
  47.     READ(nscandate);
  48.     READ(mailcheck);
  49.     READ(smwcheck);
  50.     READ(use_workspace);
  51.     READ(using_modem);
  52.     READ(last_time);
  53.     READ(fsenttoday);
  54.     READ(global_xx);
  55.     READ(xtime);
  56.     READ(xdate);
  57.     READ(incom);
  58.     READ(outcom);
  59.     READ(global_handle);
  60.     READ(actsl);
  61.     if (global_handle) {
  62.       global_handle=0;
  63.       set_global_handle(1);
  64.     }
  65.     read_user(usernum,&thisuser);
  66.     useron=1;
  67.     changedsl();
  68.     topscreen();
  69.     set_baud(com_speed);
  70.     if (modem_flag & flag_fc)
  71.       flow_control = 1;
  72.   }
  73.   close(f);
  74.   unlink(s);
  75.   unlink("stat.wwv");
  76.   return(stat);
  77. }
  78.  
  79. void save_state(char *s, int state,int ctc)
  80. {
  81.   int f;
  82.  
  83.   save_status();
  84.   f=open(s,O_RDWR | O_BINARY | O_CREAT | O_TRUNC, S_IREAD | S_IWRITE);
  85.   if (f<0)
  86.     return;
  87.   WRITE(state);
  88.   WRITE(oklevel);
  89.   WRITE(noklevel);
  90.   WRITE(ooneuser);
  91.   WRITE(no_hangup);
  92.   WRITE(ok_modem_stuff);
  93.   WRITE(topdata);
  94.   WRITE(last_time_c);
  95.   WRITE(sysop_alert);
  96.   WRITE(do_event);
  97.   WRITE(andwith);
  98.   WRITE(usernum);
  99.   WRITE(chatcall);
  100.   WRITE(chatreason);
  101.   WRITE(timeon);
  102.   WRITE(extratimecall);
  103.   WRITE(curspeed);
  104.   WRITE(modem_speed);
  105.   WRITE(com_speed);
  106.   WRITE(modem_flag);
  107.   WRITE(cursub);
  108.   WRITE(curdir);
  109.   WRITE(curdloads);
  110.   WRITE(msgreadlogon);
  111.   WRITE(nscandate);
  112.   WRITE(mailcheck);
  113.   WRITE(smwcheck);
  114.   WRITE(use_workspace);
  115.   WRITE(using_modem);
  116.   WRITE(last_time);
  117.   WRITE(fsenttoday);
  118.   WRITE(global_xx);
  119.   WRITE(xtime);
  120.   WRITE(xdate);
  121.   WRITE(incom);
  122.   WRITE(outcom);
  123.   WRITE(global_handle);
  124.   WRITE(actsl);
  125.   set_global_handle(0);
  126.   close(f);
  127.   f=open("stat.wwv",O_RDWR | O_BINARY | O_CREAT | O_TRUNC, S_IREAD | S_IWRITE);
  128.   if (f<0)
  129.     return;
  130.   WRITE(incom);
  131.   WRITE(outcom);
  132.   WRITE(thisuser);
  133.   WRITE(flow_control);
  134.   WRITE(async_irq);
  135.   WRITE(com_speed);
  136.   WRITE(base);
  137.   WRITE(andwith);
  138.   WRITE(ctc);
  139.   WRITE(defscreenbottom);
  140.   WRITE(ok_modem_stuff);
  141.   close(f);
  142. }
  143.  
  144. void do_it_1(char *cl)
  145. {
  146.   int i,i1,l;
  147.   char *ss,*ss1;
  148.   char t[81];
  149.  
  150.   sl1(1,"");
  151.   ss=cl;
  152.   while ((*ss) && (*ss!=' '))
  153.     ++ss;
  154.   if (*ss==' ') {
  155.     *ss=0;
  156.     ss++;
  157.   }
  158.   ss1=(char far *) getvect(INT_SHRINK);
  159.   if (ok_modem_stuff)
  160.     closeport();
  161.   close_user();
  162.   *ss1=1;
  163.   ss1++;
  164.   strcpy(ss1,searchpath(cl));
  165.   ss1=MK_FP(FP_SEG(ss1),0x0080);
  166.   strcpy(t," ");
  167.   strcat(t,ss);
  168.   strcat(t,"\r");
  169.   *ss1=strlen(t)-1;
  170.   ++ss1;
  171.   strcpy(ss1,t);
  172.   exit(0);
  173. }
  174.  
  175. void shrink_out(char *command, int state, int intercept,int ctc,int ccc)
  176. {
  177.   char s[81],s1[10],*ss1;
  178.   int ok_shrink;
  179.  
  180.   ok_shrink=1;
  181.   ss1=(char far *) getvect(INT_SHRINK);
  182.   if (*ss1) {
  183.     ok_shrink=0;
  184.     nl();
  185.     pl("Can't shrink: No BBS.COM");
  186.     nl();
  187.   }
  188.   if (!searchpath("RETURN.EXE")) {
  189.     ok_shrink=0;
  190.     nl();
  191.     pl("Can't shrink: No RETURN.EXE");
  192.     nl();
  193.   }
  194.   if (ok_shrink) {
  195.     if (state) {
  196.       write_user(usernum,&thisuser);
  197.       if (state>1)
  198.         thisuser.sysstatus &= ~sysstatus_pause_on_page;
  199.     }
  200.     save_state("restore.wwv",state,ctc);
  201.     sprintf(s,"RETURN.EXE %d %d %s",intercept,ccc,command);
  202.     set_protect(0);
  203.     do_it_1(s);
  204.   } else {
  205.     if (intercept)
  206.       full_external(command,ctc,ccc);
  207.     else
  208.       do_remote(command,ccc);
  209.   }
  210. }
  211.