home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / comm / autogap1.zip / AUTOGAP.SLT < prev    next >
Text File  |  1993-01-06  |  13KB  |  432 lines

  1. //      AUTOGAP.slt
  2. //      Automatic up/download for GAP using Zmodem
  3. //
  4. //      CS AUTOGAP to compile to .slc
  5. //      TELIX SAUTOGAP to execute from command line or event
  6. //
  7. // ...............     ..............................................
  8.  
  9. str first_name[] = "Tony",                      // user's first name
  10.     last_name[]  = "vanRoon",                   // user's last name
  11.     line_num[]   = "3",                         // line # in Telix Dialdir
  12.     bbs_id[]     = "SCOTTS",                    // BBS identification
  13.     graphics[]   = "y",                         // "n" = graphics
  14.     up_default[] = "n",                         // "y" = upload is default
  15.     copy_bak[]   = "y",                         // "y" = copy to .BAK
  16.     modem_spkr[] = "y";                         // "y" = modem-speaker is ON
  17. int nsec         = 10,                          // countdown in seconds
  18.     busy_pause   = 15;                          // pause between busy's
  19.  
  20. // ...............     user configured parameters   .................
  21.  
  22. str down_file[64];                              // download path + filename
  23. str up_file[64];                                // upload path + filename
  24. str cap_file [12];                              // capture filename
  25. str rep[12];                                    // upload filename
  26. str ns[64], qmail[16], s[64], sw[5];
  27. str logoff_sw[3];
  28. int t, to10, pt, psl;
  29. int t1, t2, t3, t4, t5, t6;
  30. int t7, t8, t9, t10, t11, t12, stat;
  31. int c, c1, c2, cb, ct;                          // values of colors
  32. main()
  33. {
  34.     clear_scr();
  35.     if (t == 0)
  36.         hi();
  37.     _add_lf = 0;                                // line feed added
  38.     _local_echo = 1;                            // local echo ON
  39.     _dial_pause = busy_pause;
  40.     strupper(bbs_id);
  41.     down_file = _down_dir;
  42.     strcat(down_file, bbs_id);
  43.     strcat(down_file, ".QWK");
  44.     up_file = _up_dir;
  45.     strcat(up_file, bbs_id);
  46.     strcat(up_file, ".REP");
  47.     cap_file = bbs_id;
  48.     strcat(cap_file, ".CAP");
  49.     rep = bbs_id;
  50.     strcat(rep, ".REP");
  51.     ns = "";
  52.     upper(first_name);
  53.     upper(last_name);
  54.     strcat(ns, first_name);
  55.     strcat(ns, " ");
  56.     strcat(ns, last_name);
  57.     sw = "start";                               // sw = upload switch
  58.     if (graphics == "y")
  59.     {
  60.        _back_color = 7;
  61.        _fore_color = 0;
  62.        c = 112;                                 // black on grey
  63.        c1 = 14;                                 // yellow on black
  64.        c2 = 113;                                // blue on grey
  65.        cb = 116;
  66.        ct = 112;
  67.     }                       
  68.     else
  69.     {
  70.        c = 7;                                   // light grey
  71.        c1 = 112;
  72.        c2 = 2;
  73.        cb = 116;
  74.        ct = 4;
  75.     }
  76.     if (up_default == "y" && filefind(up_file) == 0)
  77.     {
  78.         tone(40, 50);
  79.         s = up_file;
  80.         strcat(s, " was not found - NO UPLOAD!");
  81.         status_wind(s, 40);
  82.         up_default = "n";
  83.     }
  84.     s = " Do you wish to UPLOAD also ";
  85.     if (up_default == "y")
  86.     {
  87.         sw = "yes";
  88.         strcat(s, "(Y/n)? ");
  89.         keyset(13, 0, "y");
  90.     }
  91.     else
  92.     {
  93.         sw = "no";
  94.         strcat(s, "(y/N)? ");
  95.         keyset(13, 0, "n");
  96.     }
  97.     heading(c, c2, sw, rep);
  98.     pstraxy(s, 22, 15, c1);
  99.     to10 = nsec;
  100.     pt = nsec;
  101.     nsec = nsec * 10 + 1;                       // assure that 0 is displayed
  102.     itos(pt, s);
  103.     psl = strlen(s);
  104.     cursor_onoff(0);                            // cursor OFF
  105.     flushbuf();
  106.     t1 = track("h", 0);                         // h(i)
  107.     t2 = track("n", 0);                         // n(o)
  108.     t3 = track("y", 0);                         // y(es)
  109.     t = timer_start(nsec);
  110.     while (!time_up(t))
  111.     {
  112.         stat = track_hit(0);
  113.         if (stat == t1)
  114.             hi();
  115.         if (stat == t2)
  116.         {
  117.             sw = "no";
  118.             break;
  119.         }
  120.         if (stat == t3)
  121.         {
  122.             if (filefind(up_file) > 0)
  123.             {
  124.                 sw = "yes";
  125.                 break;
  126.             }
  127.             else
  128.             {
  129.                 up_default = "y";
  130.                 nsec = to10;
  131.                 main();
  132.             }
  133.         }
  134.         countdown(t, to10, pt, psl, cb, ct);
  135.     }
  136.     heading(c, c2, sw, rep);
  137.     s = " Do you wish automatic LOG OFF after download (Y/n)? ";
  138.     pstraxy(s, 13, 15, c1);
  139.     nsec = to10;
  140.     pt = nsec;
  141.     nsec = nsec * 10 + 1;
  142.     itos(pt, s);
  143.     psl = strlen(s);
  144.     t = timer_start(nsec);
  145.     keyset(13, 0, "y");
  146.     s = "LOG OFF at Main Board";
  147.     logoff_sw = "yes";
  148.     flushbuf();
  149.     while (!time_up(t))
  150.     {
  151.         stat = track_hit(0);
  152.         if (stat == t2)                         // no
  153.         {
  154.             s = "WAIT FOR INPUT at Main Board";
  155.             logoff_sw = "no";
  156.             break;
  157.         }
  158.         if (stat == t3)                         // yes, log off
  159.             break;
  160.         countdown(t, to10, pt, psl, cb, ct);
  161.     }
  162.     track_free(0);
  163.     keyset(13, 0, "");
  164.     _add_lf = 1;
  165.     cursor_onoff(1);
  166.     heading(c, c2, sw, rep);
  167.     strcat(s, " after download.");
  168.     pstraxy(s, 19, 5, c);
  169.     gotoxy(0, 7);
  170.     if (modem_spkr != "y")
  171.     {
  172.         status_wind("AUDIO is OFF", 20);
  173.         cputs("at m0 ^m");                      // speaker OFF
  174.         _sound_on = 0;                          // false, alarms OFF
  175.     }
  176.     dial(line_num, 0, 1);                       // dial # of entry in dir.
  177.                                                 // (1 does not link script)
  178.     if (_entry_enum < 1)
  179.         abort();                                // if Esc
  180.     if ((timer_total(t)) > 300)
  181.     {
  182.         alarm(1);
  183.         delay(10);
  184.         alarm(1);
  185.     }
  186.     capture("trouble.cap");                     // begin LOGIN <-----------
  187.     status_wind("TROUBLE.CAP is ON", 20);
  188.     t2 = track("Ansi Color? (Y/N/Help) [Enter] =", 1);
  189.     t3 = track("First Name ", 1);
  190.     t4 = track("Last Name ", 1);
  191.     t5 = track("correct? ", 1);                 // 0 = case is significant
  192.     t6 = track("Password ", 1);
  193.     t7 = track("[Any Key] To Continue", 0);
  194.     t8 = track("No New Messages To Export", 1);
  195.     t9 = track("QWK Packet Successfully Exported", 1);
  196.     t10 = track("Main Board Command ", 0);
  197.     t11 = track("Forum Command ", 0);           // remembered forum?
  198.     t12 = track("NO CARRIER", 1);
  199.     timer_free(t);
  200.     t = timer_start(900);
  201.     while (not time_up(t))                      // loop  90 seconds
  202.     {
  203.         terminal();                             // read input, any BBS function
  204.         stat = track_hit(0);                    // see if any matches
  205.         if (stat == t2)
  206.         {
  207.             cputs(graphics);                    // graphics (y/n)
  208.             cputs("^M");
  209.         }
  210.         if (stat == t3)
  211.         {
  212.             cputs(first_name);                  // send first name
  213.             cputs("^M");
  214.         }
  215.         if (stat == t4)
  216.         {
  217.             cputs(last_name);                   // send last name
  218.             cputs("^M");
  219.         }
  220.         if (stat == t5)
  221.             cputs("^M");                        // answer correct
  222.         if (stat == t6)
  223.         {
  224.             cputs(_entry_pass);                 // send password
  225.             cputs("^M");
  226.         }
  227.         if (stat == t7)                         // any key to continue
  228.             cputs("^M");
  229.         if (stat == t10)                        // Main Board prompt  <----
  230.         {
  231.             cputs("qwk^M");                     // invoke QWK module  <----
  232.             break;
  233.         }
  234.         if (stat == t11)                        // abandon forum
  235.             cputs("a^M");
  236.         if (stat == t12)                        // BBS trouble
  237.             abort();
  238.     }
  239.     if (time_up(t))                             // timed out
  240.     {
  241.         status_wind("TIMED OUT", 30);
  242.         prints("TIMED OUT");
  243.         abort();
  244.     }
  245.     clear_scr();
  246.     capture("*CLOSE*");
  247.     if (copy_bak == "y")
  248.     {
  249.         status_wind("Copy TROUBLE.CAP to TROUBLE.BAK", 20);
  250.         dos("copy trouble.cap trouble.bak", 0);
  251.     }
  252.     status_wind("Delete TROUBLE.CAP", 20);      // if no trouble
  253.     fdelete("trouble.cap");
  254.     capture(cap_file);                          // bbs_id.cap on
  255.     s = cap_file;
  256.     strcat(s, " is ON.");
  257.     status_wind(s, 30);
  258.     prints("");
  259.     date(curtime(), s);                         // stamp date
  260.     printsc(s);
  261.     printsc("  ");
  262.     time(curtime(), s);                         // stamp time
  263.     printsc(s);
  264.     printsc("   ");
  265.     printsc(bbs_id);
  266.     printsc("   ");
  267.     prints(ns);
  268.     if (sw == "yes")                            // u(pload)           <----
  269.     {
  270.         waitfor("[Q]uit, [H]elp :", 1800);      // QWK command line
  271.         cputs("u^M");
  272.         prints("Upload messages.");
  273.         waitfor("Zmodem Upload", 1800);
  274.         send('Z', up_file);
  275.         s = "Delete ";
  276.         strcat(s, up_file);
  277.         status_wind(s, 40);
  278.         fdelete(up_file);
  279.         prints("");
  280.         prints(s);
  281.         waitfor("[Any Key] To Continue", 1800);
  282.         cputs("^M");
  283.     }
  284.     else
  285.         prints("NO UPLOAD.");
  286.     //                                          // d(ownload)         <----
  287.     _zmod_rcrash = 0;                           // crash recovery OFF
  288.     waitfor("[Q]uit, [H]elp :", 1800);
  289.     cputs("d^M");
  290.     while (1)
  291.     {
  292.         terminal();
  293.         stat = track_hit(0);
  294.         if (stat == t8)                         // no new messages
  295.             break;
  296.         if (stat == t9)                         // messages found
  297.         {
  298.             sw = "found";
  299.             break;
  300.         }
  301.     }
  302.     if (waitfor("[Any Key] To Continue", 10))   // output randomly in
  303.         cputs("^M");                            // (2) versions of GAP
  304.     waitfor("[Q]uit, [H]elp :", 1800);
  305.     cputs("q^M");                               // quit to BBS
  306.     waitfor("Main Board Command", 1800);
  307.     if (logoff_sw == "yes")
  308.         cputs("g^M");
  309.     while (1)
  310.     {
  311.         terminal();
  312.         stat = track_hit(0);
  313.         if (stat == t12)                        // NO CARRIER        <-----
  314.             break;
  315.     }
  316.     if (sw == "found")
  317.         prints("PACKET DOWNLOADED");
  318.     else
  319.         prints("NO MESSAGES FOUND");
  320.     capture("*CLOSE*");                         // .cap OFF
  321.     if (modem_spkr != "y")
  322.     {
  323.         cputs("at m1 ^m");                      // speaker ON
  324.         _sound_on = -1;                         // true, alarms ON
  325.     }
  326.     exittelix(0, 1);                            // return to DOS
  327. }
  328.  
  329.  
  330. ////////////////////////////// functions //////////////////////////////
  331.  
  332. countdown(int t, int to10, int pt, int psl, int cb, int ct)
  333. {
  334.     int i, tt;
  335.     str sec[4];
  336.     tt = timer_total(t);
  337.     tt = to10 - tt / 10;
  338.     itos(tt, sec);
  339.     box(36, 8, 39+strlen(sec), 10, 2, 1, cb);
  340.     pstraxy(sec, 38, 9, ct);                    // prints all tenth's
  341.     pstra(" ", ct);
  342.     gotoxy(0, 17);
  343.     if (tt < pt)                                // if a whole second
  344.     {
  345.         pt = tt;                                // previous time
  346.         tone(650, 5);                           // "tick"
  347.         if (strlen(sec) < psl)                  // if shorter string
  348.         {
  349.             psl = strlen(sec);                  // previous string length
  350.             box(36, 8, 39+strlen(sec)+1, 10, 0, 1, cb);
  351.             box(36, 8, 39+strlen(sec), 10, 2, 1, cb);    // smaller box
  352.         }
  353.     }
  354.     gotoxy(0, 17);
  355. }
  356. ///////////////////////////////////////////////////////////////////////
  357.  
  358. hi()
  359. {
  360.     int i, t, ldit, ldah;
  361.     t=500; ldit=8; ldah=3*ldit;                 // length of dit and dah
  362.     tone(0, ldit);                              // why delay needed?
  363.     for (i=0; i<4; i=i+1)
  364.     {
  365.     tone(t, ldit);
  366.     tone(0, ldit);
  367.     }
  368.     tone(0, ldit);
  369.     tone(0, ldit);
  370.     for (i=0; i<2; i=i+1)
  371.     {
  372.     tone(t, ldit);
  373.     tone(0, ldit);
  374.     }
  375. }
  376. ///////////////////////////////////////////////////////////////////////
  377.  
  378. heading(int c, int c2, str sw, str rep)
  379. {
  380.     str s[6];
  381.     clear_scr();
  382.     pstraxy(bbs_id, 19, 2, c);
  383.     pstraxy(ns, 60-strlen(ns), 2, c);
  384.     if (sw == "start")
  385.     {
  386.         pstraxy("If an upload,", 18, 4, c);
  387.         pstraxy(rep, 32, 4, c);
  388.         pstraxy("will be deleted.", 45, 4, c);
  389.     }
  390.     else if (sw == "yes")
  391.     {
  392.         s = "UPLOAD";
  393.         pstraxy(s, 19, 4, 206);                 // blinking
  394.         pstraxy("---", 27, 4, c);
  395.         pstraxy(rep, 32, 4, c);
  396.         pstraxy("will be deleted.", 45, 4, c);
  397.     }
  398.     else
  399.         pstraxy("NO UPLOAD", 19, 4, c);
  400.     box(14, 1, 64, 6, 3, 1, c2);
  401.     gotoxy(0, 17);
  402. }
  403. ////////////////////////////////////////////////////////////////////////
  404.  
  405. upper(str s)
  406. {
  407.     str f[64];
  408.     int n;
  409.     n = subchr(s, 0);
  410.     n = toupper(n);
  411.     f = n;
  412.     delchrs(s, 0, 1);
  413.     strcat(f, s);
  414.     s = f;
  415. }
  416. ////////////////////////////////////////////////////////////////////////
  417.  
  418. abort()
  419. {
  420.     clear_scr();
  421.     hangup();
  422.     status_wind("ABORT - Return to DOS", 20);
  423.     if (modem_spkr != "y")
  424.     {
  425.         cputs("at m1 ^m");
  426.         _sound_on = -1;
  427.     }
  428.     exittelix(0, 1);
  429. }
  430.  
  431. /////////////////////////////////  end  ///////////////////////////////
  432.