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

  1. /***************************************************************************/
  2. call RxFuncAdd 'SysSleep','RexxUtil','SysSleep'
  3.  
  4. ARG Channel LocalIp HostIp Netmask DefaultIp user pass .
  5.  
  6. username = X2C(SUBSTR(user,1,LENGTH(user)-2))
  7. password = X2C(SUBSTR(pass,1,LENGTH(pass)-2))
  8.  
  9. cr   = '0d'x
  10. crlf = '0d0a'x
  11. remain_buffer  = ''
  12. waitfor_buffer = ''
  13.  
  14. say 'Line       ' Channel
  15. say 'LocalIp    ' LocalIp
  16. say 'HostIp     ' HostIp
  17. say 'Netmask    ' Netmask
  18. say 'DefaultIp  ' HostIp
  19.  
  20.  
  21. rc = ISDNWRITE(Channel,cr)
  22. call waitfor ">" , 5
  23. rc = ISDNWRITE(Channel,'login'||cr)
  24. call waitfor  "id" , 5
  25. rc = ISDNWRITE(Channel,username||cr)
  26. call waitfor  "ord" , 5
  27. rc = ISDNWRITE(Channel,password||cr)
  28. call waitfor ">" , 5
  29. rc = ISDNWRITE(Channel,'slip'||cr)
  30.  
  31. call flush_receive "echo"
  32. call flush_receive "echo"
  33.  
  34. /* must not be changed ! */
  35.  
  36. say 'REXX DATAMODE'
  37. rc = ISDNDATAMODE(Channel)
  38. say 'REXX DATAMODE END '
  39.  
  40.  
  41. exit 0
  42.  
  43. /*----------------------------------------------------------------------*/
  44. /*  waitfor( waitforstring , [timeout] )                                */
  45. /*......................................................................*/
  46. /*                                                                      */
  47. /*                                                                      */
  48. /*                                                                      */
  49. /*----------------------------------------------------------------------*/
  50.  
  51. waitfor:
  52.  
  53.     parse arg waitstring , timeout
  54.     if timeout = '' then
  55.         timeout = 20        /* wait 20 sec */
  56.     waitfor_buffer = '' ; done = -1 ; curpos = 1
  57.     do while (( done = -1) & (timeout > 0))
  58.         if (remain_buffer \= '') then do
  59.             line = remain_buffer
  60.             remain_buffer = ''
  61.         end
  62.         else do
  63.             line = ISDNREAD(Channel)
  64.             if Substr(line,1,1)<>'00'x then do
  65.               say 'ISDNREAD-Fehler'
  66.               signal failure
  67.             end
  68.             line=Substr(line,2)
  69.         end
  70.         waitfor_buffer = waitfor_buffer || line
  71.         index = pos(waitstring,waitfor_buffer)
  72.         if (index > 0 ) then do
  73.             remain_buffer = substr(waitfor_buffer,index+length(waitstring))
  74.             waitfor_buffer = delstr(waitfor_buffer,index+length(waitstring))
  75.             done = 0
  76.         end
  77.         call charout,substr(waitfor_buffer,curpos)
  78.         curpos = length(waitfor_buffer)+1
  79.         timeout = timeout - 1
  80.         call SysSleep 1
  81.     end
  82.     if (timeout = 0 ) then do
  83.         say 'WAITFOR : timed out '
  84.     end
  85.     RC = done
  86. return RC
  87. /*----------------------------------------------------------------------*/
  88. /*  flush_receive()                                                     */
  89. /*......................................................................*/
  90. /*                                                                      */
  91. /*                                                                      */
  92. /*                                                                      */
  93. /*----------------------------------------------------------------------*/
  94. flush_receive:
  95.  
  96.     parse arg echo
  97.     /* if echoing the flush - take care of waitfor remainig buffer */
  98.     if( echo \= '' ) && (length(remain_buffer) > 0 ) then do
  99.         call charout, remain_buffer
  100.     end
  101.     cx = 20
  102.     line = ''
  103.     do while (line \= '') & (cx > 0 )
  104.         line = ISDNREAD(Channel)
  105.         if Substr(line,1,1)<>'00'x then do
  106.           say 'ISDNREAD-Fehler'
  107.           signal failure
  108.         end
  109.         line=Substr(line,2)
  110.         if echo \= '' then
  111.             call charout,line
  112.         cx = cx - 1
  113.     end
  114.     return
  115.