home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 35 Internet / 35-Internet.zip / isdnpm29.zip / loginc.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. CompId = username
  21. CompPw = password
  22.  
  23.  
  24. call SysSleep 2
  25. rc = ISDNWRITE(Channel,cr)
  26. call waitfor  "Host Name:" , 10
  27. rc = ISDNWRITE(Channel,'CIS'||cr)
  28. call waitfor  "User ID:" , 10
  29. rc = ISDNWRITE(Channel,CompId||'/GO:PPPCONNECT'||cr)
  30. call waitfor  "ord:" , 10
  31. rc = ISDNWRITE(Channel,CompPw||cr)
  32. call waitfor  "moment" , 10
  33. rc = ISDNWRITE(Channel,cr)
  34.  
  35. /* must not be changed ! */
  36.  
  37. say 'REXX DATAMODE'
  38. rc = ISDNDATAMODE(Channel)
  39. say 'REXX DATAMODE END '
  40.  
  41.  
  42. exit 0
  43.  
  44. /*----------------------------------------------------------------------*/
  45. /*  waitfor( waitforstring , [timeout] )                                */
  46. /*......................................................................*/
  47. /*                                                                      */
  48. /*                                                                      */
  49. /*                                                                      */
  50. /*----------------------------------------------------------------------*/
  51.  
  52. waitfor:
  53.  
  54.     parse arg waitstring , timeout
  55.     if timeout = '' then
  56.         timeout = 20        /* wait 20 sec */
  57.  
  58.     timeout = timeout * 10 ;    /* ISDNREAD returns after 1/10 Sek */
  59.  
  60.     waitfor_buffer = '' ; done = -1 ; curpos = 1
  61.     do while (( done = -1) & (timeout > 0))
  62.         if (remain_buffer \= '') then do
  63.             line = remain_buffer
  64.             remain_buffer = ''
  65.         end
  66.         else do
  67.             line = ISDNREAD(Channel)
  68.             if Substr(line,1,1)<>'00'x then do
  69.               say 'ISDNREAD-Fehler'
  70.               signal failure
  71.             end
  72.             line=Substr(line,2)
  73.         end
  74.         waitfor_buffer = waitfor_buffer || line
  75.         index = pos(waitstring,waitfor_buffer)
  76.         if (index > 0 ) then do
  77.             remain_buffer = substr(waitfor_buffer,index+length(waitstring))
  78.             waitfor_buffer = delstr(waitfor_buffer,index+length(waitstring))
  79.             done = 0
  80.         end
  81.         call charout,substr(waitfor_buffer,curpos)
  82.         curpos = length(waitfor_buffer)+1
  83.         timeout = timeout - 1
  84.     end
  85.     if (timeout = 0 ) then do
  86.         say 'WAITFOR : timed out '
  87.         done = 1
  88.     end
  89.     RC = done
  90. return RC
  91.  
  92. /*----------------------------------------------------------------------*/
  93. /*  flush_receive()                                                     */
  94. /*......................................................................*/
  95. /*                                                                      */
  96. /*                                                                      */
  97. /*                                                                      */
  98. /*----------------------------------------------------------------------*/
  99. flush_receive:
  100.  
  101.     parse arg echo
  102.     /* if echoing the flush - take care of waitfor remainig buffer */
  103.     if( echo \= '' ) && (length(remain_buffer) > 0 ) then do
  104.         call charout, remain_buffer
  105.     end
  106.     cx = 20
  107.     line = ''
  108.     do while (line \= '') & (cx > 0 )
  109.         line = ISDNREAD(Channel)
  110.         if echo \= '' then
  111.             call charout,line
  112.         cx = cx - 1
  113.     end
  114.     return
  115.