home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 35 Internet / 35-Internet.zip / isdnpm29.zip / toncomp.fnc < prev    next >
Text File  |  1998-01-11  |  6KB  |  179 lines

  1. /*--------------------------------------------------------------------------
  2.  
  3.                                   toncomp.fnc
  4.  
  5.  
  6.    2.5.1997 Anpassung an Version 2.8
  7.  
  8.    login compuserve via datex-j
  9.    Version 13.11.96
  10.  
  11.   --------------------------------------------------------------------------*/
  12. /***************************************************************************/
  13. call RxFuncAdd 'SysSleep','RexxUtil','SysSleep'
  14.  
  15. ARG Channel LocalIp HostIp Netmask DefaultIp user pass .
  16.  
  17. username = X2C(SUBSTR(user,1,LENGTH(user)-2))
  18. password = X2C(SUBSTR(pass,1,LENGTH(pass)-2))
  19.  
  20. cr   = '0d'x
  21. crlf = '0d0a'x
  22. remain_buffer  = ''
  23. waitfor_buffer = ''
  24. prompt_vt100='[?25h'
  25. prompt_cept='1A'x
  26. prompt_string=prompt_cept
  27. prompt_string=prompt_vt100
  28.  
  29. say 'Line       ' Channel
  30. say 'LocalIp    ' LocalIp
  31. say 'HostIp     ' HostIp
  32. say 'Netmask    ' Netmask
  33. say 'DefaultIp  ' HostIp
  34. say 'UserId     ' username
  35. say 'Password   ' password
  36.  
  37. datexj="000327278259"
  38.  
  39. say "Umgeschaltet in VT100. Anmeldung..."
  40.  
  41. call SHOWSTATUS channel,"Warte auf Anschlusskennung "
  42. call waitfor "00000" ,20
  43.  
  44. call send datexj||cr
  45.  
  46. call SHOWSTATUS channel,"Warte auf Übergabeseite"
  47. call waitfor "seite" ,20
  48. call send "11"
  49.  
  50. call SHOWSTATUS channel,"Warte auf Verbindungsaufbau"
  51. call waitfor "bindungsaufbau" ,20
  52. call send "#"
  53.  
  54. /* Handle login. */
  55.  
  56. call SHOWSTATUS channel,"Warte auf Host Name:"
  57.  
  58. call waitfor  "Host Name:" , 20
  59. call send 'CIS'||cr
  60. call SHOWSTATUS channel,"Warte auf User ID:"
  61. call waitfor  "User ID:" , 20
  62. call send username||'/NOINT/GO:PPPCONNECT'||cr
  63. call SHOWSTATUS channel,"Warte auf Password:"
  64. call waitfor  "ord:" , 20
  65. call send password||cr
  66. call SHOWSTATUS channel,"Warte auf PPPCONNECT"
  67. call waitfor  "PPPCONNECT" , 30
  68.  
  69. call SHOWSTATUS channel,"Im Internet erfolgreich angekommen"
  70.  
  71. say 'REXX DATAMODE'
  72. rc = ISDNDATAMODE(Channel)
  73. say 'REXX DATAMODE END '
  74.  
  75. call SHOWSTATUS channel,"Internet beendet"
  76.  
  77. exit 0
  78.  
  79. failure:
  80. say "Mist! Schiefgegangen!"
  81.   call ISDNDISCONNECT Channel
  82.   exit 1
  83. /*--------------------------------------------------------------------------*/
  84. /*                            send ( sendstring)                            */
  85. /*..........................................................................*/
  86. /*                                                                          */
  87. /* Routine to send a character string off to the modem.                     */
  88. /*                                                                          */
  89. /*--------------------------------------------------------------------------*/
  90.  
  91. send:
  92.  
  93.    parse arg sendstring
  94.    call ISDNWRITE channel , sendstring
  95.  
  96.    return
  97.  
  98.  
  99. /*----------------------------------------------------------------------*/
  100. /*  waitfor( waitforstring , [timeout] )                                */
  101. /*......................................................................*/
  102. /*                                                                      */
  103. /*                                                                      */
  104. /*                                                                      */
  105. /*----------------------------------------------------------------------*/
  106.  
  107. waitfor:
  108.  
  109.     parse arg waitstring , timeout
  110.     if timeout = '' then
  111.         timeout = 20        /* wait 20 sec */
  112.  
  113.     timeout = timeout * 10 ;    /* ISDNREAD returns after 1/10 Sek */
  114.  
  115.     waitfor_buffer = '' ; done = -1 ; curpos = 1
  116.     do while (( done = -1) & (timeout > 0))
  117.         if (remain_buffer \= '') then do
  118.             line = remain_buffer
  119.             remain_buffer = ''
  120.         end
  121.         else do
  122.             line = ISDNREAD(Channel)
  123.             if Substr(line,1,1)<>'00'x then do
  124.               say 'ISDNREAD-Fehler'
  125.               signal failure
  126.             end
  127.             line=Substr(line,2)
  128.         end
  129.         waitfor_buffer = waitfor_buffer || line
  130.         if waitstring>='80'x then
  131.           index=1
  132.         else
  133.           index = pos(waitstring,waitfor_buffer)
  134.         if (index > 0 ) then do
  135.             remain_buffer = substr(waitfor_buffer,index+length(waitstring))
  136.             waitfor_buffer = delstr(waitfor_buffer,index+length(waitstring))
  137.             done = 0
  138.         end
  139.         call charout,substr(waitfor_buffer,curpos)
  140.         curpos = length(waitfor_buffer)+1
  141.         timeout = timeout - 1
  142.         call SysSleep 0
  143.     end
  144.     if (timeout = 0 ) then do
  145.         say 'WAITFOR : timed out '
  146.         done = 1
  147.     end
  148.     RC = done
  149. return RC
  150. /*----------------------------------------------------------------------*/
  151. /*  flush_receive()                                                     */
  152. /*......................................................................*/
  153. /*                                                                      */
  154. /*                                                                      */
  155. /*                                                                      */
  156. /*----------------------------------------------------------------------*/
  157. flush_receive:
  158.  
  159.     parse arg echo
  160.     /* if echoing the flush - take care of waitfor remainig buffer */
  161.     if( echo \= '' ) && (length(remain_buffer) > 0 ) then do
  162.         call charout, remain_buffer
  163.     end
  164.     cx = 20
  165.     line = ''
  166.     do while (line \= '') & (cx > 0 )
  167.         line = ISDNREAD(Channel)
  168.         if Substr(line,1,1)<>'00'x then do
  169.           say 'ISDNREAD-Fehler'
  170.           signal failure
  171.         end
  172.         line=Substr(line,2)
  173.         if echo \= '' then
  174.             call charout,line
  175.         cx = cx - 1
  176.     end
  177.     return
  178.  
  179.