home *** CD-ROM | disk | FTP | other *** search
/ Computer Buyer 1996 May / buyer-0596.iso / wincim / scripts.lib / CSERVE.SCR < prev    next >
Text File  |  1995-12-05  |  8KB  |  344 lines

  1. !
  2. !  Copyright (c) 1995
  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.1"
  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.     send %Password & %CR;
  139.     goto Logon_Wait;
  140.  
  141. Send_XPAD:
  142.     if %X121Address = "" goto Missing_XPAD;
  143.     send %X121Address & %CR;
  144.     goto Connect_Wait;
  145.  
  146. Missing_XPAD:
  147.     define %FailureMsg = "Missing X.121 address";
  148.     define %ErrorCode = 21;
  149.     exit %Fatal;
  150.     
  151. Logon_Wait:
  152.     wait
  153.         "Account ID:"    goto Send_AccountID,
  154.         "CompuServe"    goto Return_Success,
  155.         "^[[>"        goto Return_Success,
  156.         "^F"        goto Return_Success,
  157.         "? LOG"        goto Process_Log_Msg,
  158.         "??LOG"        goto Process_Log_Msg,
  159.         "? IPX"        goto Process_IPX_Msg,
  160.         " NTW"        goto Logon_Failure,
  161.         "? ICD"        goto Process_Net_Msg,
  162.         "??ICD"        goto Process_Net_Msg,
  163.         "800 Direct Dial access " goto Process_800,
  164.         "OK^M"        goto Send_OK_Cmd,
  165.         "^[I"        goto Send_Response,
  166.         "PPP:"        goto Connect_PPP,
  167.         %mdm_Failure    goto CIS_No_Carrier
  168.     until 200;
  169.  
  170.     define %ErrorCode = 22;
  171.     goto CIS_Failure;
  172.  
  173. Connect_PPP:
  174.     if %App <> "CID" goto Logon_Wait;
  175.     define %PPP = "1";
  176.     exit %Success;
  177.         
  178.  
  179. Process_Log_Msg:
  180.     wait
  181.         "INE"    goto Bad_ID,
  182.         "ISX"    goto Bad_ID_Syntax,
  183.         "CAI"    goto Cannot_Auto_Irun,
  184.         "SIL"    goto System_Unavailable,
  185.         "SIU"    goto System_Unavailable,
  186.         "SNA"    goto System_Unavailable,
  187.         "STU"    goto Check_User_ID,
  188.         "INS"    goto Bad_ID_Syntax,
  189.         "UTL"    goto Too_Many_Users
  190.     until 50;
  191.  
  192.     goto Try_Again;
  193.  
  194. Process_IPX_Msg:
  195.     define %ErrorCode = 23;
  196.     define %FailureMsg = "InfoPlex is unavailable, try again later";
  197.     exit %Fatal;
  198.  
  199. Process_Net_Msg:
  200.     define %ErrorCode = 31;
  201.     FailStr = "PPP connection failure, please try again";
  202.  
  203.     wait
  204.         "^M"    goto Found_Error
  205.     until 10;
  206.  
  207.     goto Return_Fail_Msg;
  208.  
  209. Found_Error:
  210.     if %Scanned = "" goto Return_Fail_Msg;
  211.     FailStr = %Scanned;
  212.     goto Return_Fail_Msg;
  213.  
  214. Send_AccountID:
  215.     send %AccountID & %CR;
  216.     goto Logon_Wait;
  217.  
  218. Too_Many_Users:
  219.     if Tries = 0 goto Users_Failure;
  220.     show "Simultaneous users exceeded, retrying...";
  221.     goto Start_Connect;
  222.  
  223. Users_Failure:
  224.     define %FailureMsg = "Simultaneous users exceeded";
  225.     define %ErrorCode = 29;
  226.     exit %Fatal;
  227.  
  228. Cannot_Auto_Irun:
  229.     define %FailureMsg = "Cannot Auto Irun HMI server";
  230.     exit %Fatal;
  231.  
  232. Bad_ID:
  233.     define %ErrorCode = 24;
  234.     FailStr = "Incorrect User ID or password";
  235.     goto Try_Again;
  236.  
  237. Bad_ID_Syntax:
  238.     define %ErrorCode = 25;
  239.     FailStr = "Incorrect User ID syntax";
  240.     goto Try_Again;
  241.  
  242. System_Unavailable:
  243.     define %ErrorCode = 23;
  244.     define %FailureMsg = "The system is unavailable, try again later";
  245.     exit %Fatal;
  246.  
  247. Check_User_ID:
  248.     define %ErrorCode = 26;
  249.     define %FailureMsg = "The system is unavailable, check User ID";
  250.     exit %Fatal;
  251.  
  252. Process_800:
  253.     wait
  254.         "is not" goto No_800,
  255.         "rates" goto Access_Rates
  256.     until 20;
  257.     goto Logon_Wait;
  258.  
  259.  
  260. No_800:
  261.     define %FailureMsg = "800 Direct Dial access is not available on your account";
  262.     define %ErrorCode = 4;
  263.     exit %Fatal;
  264.  
  265. Access_Rates:
  266.     show "800 Direct Dial access rates now in effect";
  267.     goto Logon_Wait;
  268.  
  269. Try_Again:
  270.     if not FirstTry goto CIS_Fatal;
  271.     send "^C";
  272.     FirstTry = %FALSE;
  273.  
  274.     wait
  275.         "User ID"    goto Send_ID,
  276.         %mdm_Failure    goto CIS_No_Carrier
  277.     until 140;
  278.  
  279.     goto CIS_Fatal;
  280.  
  281. Logon_Failure:
  282.     define %ErrorCode = 27;
  283.     define %FailureMsg = "Remote is busy or unavailable";
  284.     exit %Fatal;
  285.  
  286. Send_OK_Cmd:
  287.     if %OKCmd = "" goto Logon_Wait;
  288.     send %OKCmd & %CR;
  289.     goto Logon_Wait;
  290.  
  291. Send_Response:
  292.     sendi %ESCIResponse;
  293.     exit %Success;
  294.  
  295. CIS_Error:
  296.     define %ErrorCode = 20;
  297. CIS_Failure:
  298.     if FailStr <> "" goto Return_Fail_Msg;
  299.     define %FailureMsg = "Unable to connect to CompuServe host";
  300.     exit %Failure;
  301.  
  302. CIS_No_Carrier:
  303.     define %ErrorCode = 28;
  304.     if FailStr <> "" goto Return_Fail_Msg;
  305.     define %FailureMsg = "Modem connection lost";
  306.     exit %Failure;
  307.  
  308. CIS_Fatal:
  309.     if FailStr <> "" goto Return_Fatal_Msg;
  310.     define %FailureMsg = "Unable to connect to CompuServe host";
  311.     exit %Fatal;
  312.  
  313. Return_Fail_Msg:
  314.     define %FailureMsg = FailStr;
  315.     exit %Failure;
  316.  
  317. Return_Fatal_Msg:
  318.     define %FailureMsg = FailStr;
  319.     exit %Fatal;
  320.  
  321. Return_Success:
  322.     exit %Success;
  323.  
  324. Return_Cancel:
  325.     exit %Cancel;
  326.  
  327.  
  328. Handle_Secure_Login:
  329.     if %MicroChallenge = "" goto Connect_Wait;
  330.  
  331.     call %Dir & "seclog.scr" () : FailCode;
  332.  
  333.     if FailCode = 0 goto Logon_Wait;
  334.     if FailCode = 1 goto Return_Cancel;
  335.     if FailCode = 3 goto CIS_No_Carrier;
  336.  
  337.     ! Failure condition.
  338.     FailStr = %SecFailTemp;
  339.     SecureTries = SecureTries - 1;
  340.     if SecureTries = 0 goto CIS_Failure;
  341.  
  342.     show %SecFailTemp & ", retrying...";
  343.     goto Start_Connect;
  344.