home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / cpm / bye3 / bye339.lbr / CALLME.PQS / CALLME.PAS
Pascal/Delphi Source File  |  1985-12-02  |  5KB  |  155 lines

  1. {---------------------------------------------------------------------------}
  2. {                                                                           }
  3. {  This program will (when running under Bye337 or newer), hang up the      }
  4. {  phone, and dial a specified number.  This is useful if the Sysop wants   }
  5. {  to access his/her computer from a remote place without running up a long }
  6. {  phone bill.  This program was somewhat inspired by Dave Hardy's          }
  7. {  PMMISTAT program which did the same sort of thing.                       }
  8. {  This is a good demonstration of the features of Bye337.                  }
  9. {                                                                           }
  10. {  This is for the Courrier 2400 or Hayes compatible modems only.           }
  11. {                                                                           }
  12. {---------------------------------------------------------------------------}
  13. { Copyright (c) 1985 by Paul Traina - all commercial rights reserved        }
  14. { This program may be distributed under the following circumstances:        }
  15. {    1) This software is to be distributed with the Bye3 series of programs }
  16. {       and no "spinoffs."                                                  }
  17. {    2) This software is not sold or marketed for commercial gain.          }
  18. {    3) The author's copyright notice is not disturbed.                     }
  19. {---------------------------------------------------------------------------}
  20. {                                                                           }
  21. {  Note: A small change will have to be made to Bye337 to have this program }
  22. {        work properly:  You must change part of the modem initialization   }
  23. {        string.  Change "S2=128" to "S2=1  " .. this changes the attention }
  24. {        character to ^A which is virtually impossible to get the system to }
  25. {        echo so you should be safe from crashes.                           }
  26. {                                                                           }
  27. {---------------------------------------------------------------------------}
  28.  
  29. program Call_Me(input,output);
  30.  
  31. const
  32.   password = 'CHICKEN';     { Password needed }
  33.  
  34.   outsta   = 62;            { modem output status }
  35.   outchr   = 63;            { modem output char }
  36.   carsta   = 65;            { modem carrier status }
  37.   wrtloc   = 76;            { write-lock }
  38.   mdmoff   = 77;            { modem-ignore }
  39.   gettime  = 79;            { get rtc buffer }
  40.   getcalr  = 80;            { get caller buffer }
  41.  
  42. type
  43.   string20            = string[20];
  44.   string80            = string[80];
  45.  
  46. var
  47.   num                 : string20;
  48.   pass                : string20;
  49.   wait                : integer;
  50.   dummy               : integer;
  51.  
  52. { return true if we have carrier }
  53.  
  54. function carrier:boolean;
  55. begin
  56.   carrier := Bdos(carsta)>0
  57. end;
  58.  
  59. { Hangup the phone the universal way }
  60.  
  61. procedure disconnect;
  62. begin
  63.   while carrier do
  64.     begin
  65.       delay(1500);              { pad 50% over minimum }
  66.       write(usr,^A,^A,^A);
  67.       delay(1500);
  68.       write(usr,^M,'ATH',^M);
  69.       delay(300);               { wait a bit for modem to hangup }
  70.     end;
  71. end;
  72.  
  73. { Send a character to the modem }
  74.  
  75. procedure putchar(ch:char);
  76. var dummy : byte;
  77. begin
  78.   repeat until Bdos(outsta)>0;
  79.   dummy := Bdos(outchr,ord(ch));
  80.   delay(100)    { 100ms mini-delay }
  81. end;
  82.  
  83. begin
  84.   UsrOutPtr := addr(putchar);             { tie in our output routine }
  85.  
  86.   if Bdos(32,241) <> 77 then
  87.   begin
  88.     writeln('Bye337 or newer not running.');
  89.     halt
  90.   end;
  91.  
  92.   writeln('Call me back...');
  93.   write('Phone number? ');
  94.   readln(num);
  95.   write('Password? ');
  96.   readln(pass);
  97.  
  98.   mem[0] := $CD;                      { from now on, bump him if bad }
  99.  
  100.   if pass<>password then
  101.   begin
  102.     writeln('Invalid password.');
  103.     halt
  104.   end;
  105.  
  106.   writeln;
  107.   writeln('Calling you back... bye bye');
  108.   writeln;
  109.  
  110.   dummy := Bdos(mdmoff,255);      { turn on modem-ignore flag }
  111.   dummy := Bdos(wrtloc,255);      { turn on write-loc if we have it }
  112.  
  113.   disconnect;
  114.   delay(1000);
  115.  
  116.   write(usr,^M,'ATDTR',num,^M);   { tell modem to dial number (answer mode )}
  117.  
  118.   wait := 0;                      { wait for carrier or timeout }
  119.   repeat
  120.     delay(1000);                  { wait one second }
  121.     wait := wait + 1;
  122.   until carrier or (wait > 60);
  123.  
  124.   if wait > 60 then
  125.   begin
  126.     disconnect;                   { we have an error, try to recover }
  127.     delay(1000);                  { turn on all bye's error checking }
  128.     dummy := Bdos(mdmoff,0);
  129.     dummy := Bdos(wrtloc,0);
  130.     halt;
  131.   end;
  132.  
  133.   { we have connect }
  134.  
  135.   delay(1000);
  136.   dummy := Bdos(mdmoff,0);              { re-enable bye's checking }
  137.   dummy := Bdos(wrtloc,0);
  138.  
  139.   writeln;
  140.   write('Enter sync string---> ');
  141.   readln(pass);
  142.   write('Enter password?');
  143.   readln(pass);
  144.  
  145.   if password<>pass then
  146.   begin
  147.     writeln('Invalid password.');
  148.     halt
  149.   end;
  150.  
  151.   { All done...whew... return to CP/M }
  152.  
  153.   mem[0] := $C3;                       { let us go to cp/m without death }
  154. end.
  155.