home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World Interactive 1997 February / pcwfeb97.zip / pcwfeb97 / COMPSERV / SCRIPTS.LIB / CSERVE.SCR < prev    next >
Text File  |  1996-01-29  |  8KB  |  352 lines

  1. !
  2. !  Copyright (c) 1996
  3. !  by CompuServe Incorporated, Columbus, Ohio
  4. !
  5. !  The information in this software is subject to change without
  6. !  notice and should not be construed as a commitment by CompuServe.
  7. !
  8. !  CSERVE:
  9. !    Connect to CIS.
  10. !    First argument is %TRUE if direct connect and %FALSE otherwise
  11. !    Success:  returns %Success
  12. !    Failure:  saves error msg in %FailureMsg and returns %Failure
  13. !        or %Fatal (depending on severity).
  14. !
  15. !+V
  16. ! "3.8.2"
  17. !-V
  18.  
  19. DirectConnect = Arg1;
  20. Internet = 25;
  21. ifndef %HostName = "CPS";
  22. Plus = "+";
  23. Wait_Time = 80;
  24. ifndef %Scanned = "";
  25. Msg = "Connecting to CompuServe Network";
  26. if %Network <> Internet goto NotInternet;
  27. Msg = "Logging onto CompuServe .    ";
  28. define %HostName = "CISAGREE";
  29. Wait_Time = 30;
  30.  
  31. NotInternet:
  32. show Msg;
  33. Tries = 7;
  34. SecureTries = 3;
  35. FirstTry = %TRUE;
  36. FailStr = "";
  37. Sent_Host_Name = %FALSE;
  38. ifndef %X121Address = "";
  39. ifndef %OKCmd = "";
  40. ifndef %StopAtHost = "";
  41. ifndef %AccountID = "";
  42. ifndef %BreakChar = "#";
  43. ifndef %MicroChallenge = "";
  44. ifndef %App = "";
  45. on cancel goto Return_Cancel;
  46.  
  47. Start_Connect:
  48.     if Tries = 0 goto CIS_Error;
  49.     Tries = Tries - 1;
  50.  
  51. Connect_Wait:
  52.     wait
  53.         "UIC:"        goto Send_ETX,
  54.         "Host Name:"    goto Send_Host_Name,
  55.         "User ID:"    goto Send_ID,
  56.         "Password:"    goto Send_Password,
  57.         "XPAD:"        goto Send_XPAD,
  58.         "ITI:"        goto Send_XPAD,
  59.         "? LOG"        goto Process_Log_Msg,
  60.         "??LOG"        goto Process_Log_Msg,
  61.         "% IPN"        goto Process_IPX_Msg,
  62.         "? IPX"        goto Process_IPX_Msg,
  63.         "? ICD"        goto Process_Net_Msg,
  64.         "??ICD"        goto Process_Net_Msg,
  65.         "RA:"        goto Handle_Secure_Login,
  66.         "0, OFF):"    goto Send_Baud_Rate,
  67.         %mdm_Failure    goto CIS_No_Carrier
  68.     until Wait_Time;
  69.  
  70.     if %Network <> Internet goto Send_Break;
  71.     Wait_Time = 200;
  72.     if not Sent_Host_Name goto Send_CR;
  73.     goto Start_Connect;
  74.  
  75. Send_Break:
  76.     if not DirectConnect goto Send_CR;
  77.     sendm %BreakChar;
  78.     sendm %BreakChar;
  79.     sendm %BreakChar;
  80.  
  81. Send_CR:
  82.     send %CR;
  83.     goto Start_Connect;
  84.  
  85. Send_Baud_Rate:
  86.     send %BaudRate;
  87.     send "^M";
  88.     goto Connect_Wait;
  89.  
  90. Send_ETX:
  91.     send "^C";
  92.     goto Connect_Wait;
  93.  
  94. Send_Host_Name:
  95.     if Arg2 goto No_Wait;
  96.     wait until 10;
  97. No_Wait:
  98.     if Sent_Host_Name goto Reset_Host_Name;
  99.     Sent_Host_Name = %TRUE;
  100.  
  101.     Wait_Time = 200;
  102.     if %StopAtHost = "1" goto Return_Success;
  103.     send %HostName & "^M";
  104.     if %StopAtHost = "" goto Connect_Wait;
  105.     goto Return_Success;
  106.  
  107. !
  108. ! Only send Host Name response on 1st, 3rd, & 5th attempts
  109. ! to guard against unintended double host name prompts resulting
  110. ! from sending "^M".  On even attempts, eat the Host Name: prompt.
  111. !
  112. Reset_Host_Name:
  113.     Sent_Host_Name = %FALSE;
  114.     Tries = Tries - 1;
  115.     goto Connect_Wait;
  116.  
  117. Send_ID:
  118.     if %StopAtHost = "1" goto GetHost;
  119.     define %ErrorCode = 0;
  120.     if %App = "CID" goto No_Msg1;
  121.     show "Logging onto CompuServe . .  ";
  122. No_Msg1:
  123.     if %MicroChallenge = "" goto No_Secure_Login;
  124.  
  125.     send Plus & %UserID & %LogonParams & "/INT:60 /secure:1^M";
  126.     Plus = "";
  127.     goto Connect_Wait;
  128.  
  129. No_Secure_Login:
  130.     send %UserID & %LogonParams & "/INT:60^M";
  131.     goto Connect_Wait;
  132.  
  133. GetHost:
  134.     send "/HOST^M";
  135.     exit %Success;
  136.  
  137. Send_Password:
  138.     if %MicroChallenge <> "" goto Secure_Failure;
  139.     send %Password & %CR;
  140.     goto Logon_Wait;
  141.  
  142. Secure_Failure:
  143.     define %FailureMsg = "Secure login failure, non-secure connect aborted";
  144.     define %ErrorCode = 37;
  145.     exit %Fatal;
  146.     
  147. Send_XPAD:
  148.     if %X121Address = "" goto Missing_XPAD;
  149.     send %X121Address & %CR;
  150.     goto Connect_Wait;
  151.  
  152. Missing_XPAD:
  153.     define %FailureMsg = "Missing X.121 address";
  154.     define %ErrorCode = 21;
  155.     exit %Fatal;
  156.     
  157. Logon_Wait:
  158.     wait
  159.         "Account ID:"    goto Send_AccountID,
  160.         "CompuServe"    goto Return_Success,
  161.         "^[[>"        goto Return_Success,
  162.         "^F"        goto Return_Success,
  163.         "? LOG"        goto Process_Log_Msg,
  164.         "??LOG"        goto Process_Log_Msg,
  165.         "? IPX"        goto Process_IPX_Msg,
  166.         " NTW"        goto Logon_Failure,
  167.         "? ICD"        goto Process_Net_Msg,
  168.         "??ICD"        goto Process_Net_Msg,
  169.         "800 Direct Dial access " goto Process_800,
  170.         "OK^M"        goto Send_OK_Cmd,
  171.         "^[I"        goto Send_Response,
  172.         "PPP:"        goto Connect_PPP,
  173.         %mdm_Failure    goto CIS_No_Carrier
  174.     until 200;
  175.  
  176.     define %ErrorCode = 22;
  177.     goto CIS_Failure;
  178.  
  179. Connect_PPP:
  180.     if %App <> "CID" goto Logon_Wait;
  181.     define %PPP = "1";
  182.     exit %Success;
  183.         
  184.  
  185. Process_Log_Msg:
  186.     wait
  187.         "INE"    goto Bad_ID,
  188.         "ISX"    goto Bad_ID_Syntax,
  189.         "CAI"    goto Cannot_Auto_Irun,
  190.         "SIL"    goto System_Unavailable,
  191.         "SIU"    goto System_Unavailable,
  192.         "SNA"    goto System_Unavailable,
  193.         "STU"    goto Check_User_ID,
  194.         "INS"    goto Bad_ID_Syntax,
  195.         "UTL"    goto Too_Many_Users
  196.     until 50;
  197.  
  198.     FailStr = "Unable to connect to CompuServe host";
  199.     goto Scan_Error;
  200.  
  201. Process_IPX_Msg:
  202.     define %ErrorCode = 23;
  203.     FailStr = "InfoPlex is unavailable, try again later";
  204.     goto Scan_Error;
  205.  
  206. Process_Net_Msg:
  207.     define %ErrorCode = 31;
  208.     FailStr = "PPP connection failure, please try again";
  209.  
  210. Scan_Error:
  211.     wait
  212.         "^M"    goto Found_Error
  213.     until 15;
  214.  
  215.     goto Return_Fatal_Msg;
  216.  
  217. Found_Error:
  218.     if %Scanned = "" goto Return_Fatal_Msg;
  219.     FailStr = %Scanned;
  220.     goto Return_Fatal_Msg;
  221.  
  222. Send_AccountID:
  223.     send %AccountID & %CR;
  224.     goto Logon_Wait;
  225.  
  226. Too_Many_Users:
  227.     if Tries = 0 goto Users_Failure;
  228.     show "Simultaneous users exceeded, retrying...";
  229.     goto Start_Connect;
  230.  
  231. Users_Failure:
  232.     define %FailureMsg = "Simultaneous users exceeded";
  233.     define %ErrorCode = 29;
  234.     exit %Fatal;
  235.  
  236. Cannot_Auto_Irun:
  237.     define %FailureMsg = "Cannot Auto Irun HMI server";
  238.     exit %Fatal;
  239.  
  240. Bad_ID:
  241.     define %ErrorCode = 24;
  242.     FailStr = "Incorrect User ID or password";
  243.     goto Try_Again;
  244.  
  245. Bad_ID_Syntax:
  246.     define %ErrorCode = 25;
  247.     FailStr = "Incorrect User ID syntax";
  248.     goto Try_Again;
  249.  
  250. System_Unavailable:
  251.     define %ErrorCode = 23;
  252.     FailStr = "The system is unavailable, try again later";
  253.     goto Scan_Error;
  254.  
  255. Check_User_ID:
  256.     define %ErrorCode = 26;
  257.     define %FailureMsg = "The system is unavailable, check User ID";
  258.     exit %Fatal;
  259.  
  260. Process_800:
  261.     wait
  262.         "is not" goto No_800,
  263.         "rates" goto Access_Rates
  264.     until 25;
  265.     goto Logon_Wait;
  266.  
  267.  
  268. No_800:
  269.     define %FailureMsg = "800 Direct Dial access is not available on your account";
  270.     define %ErrorCode = 4;
  271.     exit %Fatal;
  272.  
  273. Access_Rates:
  274.     show "800 Direct Dial access rates now in effect";
  275.     goto Logon_Wait;
  276.  
  277. Try_Again:
  278.     if not FirstTry goto CIS_Fatal;
  279.     send "^C";
  280.     FirstTry = %FALSE;
  281.  
  282.     wait
  283.         "User ID"    goto Send_ID,
  284.         %mdm_Failure    goto CIS_No_Carrier
  285.     until 140;
  286.  
  287.     goto CIS_Fatal;
  288.  
  289. Logon_Failure:
  290.     define %ErrorCode = 27;
  291.     FailStr = "Remote is busy or unavailable";
  292.     goto Scan_Error;
  293.  
  294. Send_OK_Cmd:
  295.     if %OKCmd = "" goto Logon_Wait;
  296.     send %OKCmd & %CR;
  297.     goto Logon_Wait;
  298.  
  299. Send_Response:
  300.     sendi %ESCIResponse;
  301.     exit %Success;
  302.  
  303. CIS_Error:
  304.     define %ErrorCode = 20;
  305. CIS_Failure:
  306.     if FailStr <> "" goto Return_Fail_Msg;
  307.     define %FailureMsg = "Unable to connect to CompuServe host";
  308.     exit %Failure;
  309.  
  310. CIS_No_Carrier:
  311.     define %ErrorCode = 28;
  312.     if FailStr <> "" goto Return_Fail_Msg;
  313.     define %FailureMsg = "Modem connection lost";
  314.     exit %Failure;
  315.  
  316. CIS_Fatal:
  317.     if FailStr <> "" goto Return_Fatal_Msg;
  318.     define %FailureMsg = "Unable to connect to CompuServe host";
  319.     exit %Fatal;
  320.  
  321. Return_Fail_Msg:
  322.     define %FailureMsg = FailStr;
  323.     exit %Failure;
  324.  
  325. Return_Fatal_Msg:
  326.     define %FailureMsg = FailStr;
  327.     exit %Fatal;
  328.  
  329. Return_Success:
  330.     exit %Success;
  331.  
  332. Return_Cancel:
  333.     exit %Cancel;
  334.  
  335.  
  336. Handle_Secure_Login:
  337.     if %MicroChallenge = "" goto Connect_Wait;
  338.  
  339.     call %Dir & "seclog.scr" () : FailCode;
  340.  
  341.     if FailCode = 0 goto Logon_Wait;
  342.     if FailCode = 1 goto Return_Cancel;
  343.     if FailCode = 3 goto CIS_No_Carrier;
  344.  
  345.     ! Failure condition.
  346.     FailStr = %SecFailTemp;
  347.     SecureTries = SecureTries - 1;
  348.     if SecureTries = 0 goto CIS_Failure;
  349.  
  350.     show %SecFailTemp & ", retrying...";
  351.     goto Start_Connect;
  352.