home *** CD-ROM | disk | FTP | other *** search
/ PC Online 1997 January / PCO0197.ISO / filesbbs / os2 / isdnpm27.arj / TONCOMP.FNC < prev    next >
Encoding:
Text File  |  1996-11-17  |  5.1 KB  |  168 lines

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