Guest User

Untitled

a guest
Jun 27th, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
mIRC 1.37 KB | None | 0 0
  1. on 1:sockread:mR_*:
  2.   ;check for errors, if so, echo out then stop processing
  3.   if ($sockerr) {  echo -s Sockread error from: $sockname | return }
  4.  
  5.   ;if the sockmark isn't set lets get it to "GetHeader" which
  6.   ;tells the script to, well, get the header
  7.   if (!$sock($sockname).mark) { sockmark $sockname GetHeader }
  8.  
  9.   ;setup so we can loop back
  10.   :loop
  11.  
  12.   ;read all data in the receive buffer into &tmp
  13.   sockread $sock($sockname).rq &tmp
  14.  
  15.   ;if no data was read, stop processing
  16.   if (!$sockbr) { return }
  17.  
  18.   ;if the header is "GetHeader" lets do some processing
  19.   if ($sock($sockname).mark == GetHeader) {
  20.  
  21.     ;set %n to the data saved from socket, plus the data we just read
  22.     var %n = $($+(%,$sockname),2) $+ $bvar(&tmp,1-).text
  23.  
  24.     ;if Get *crlfcrlf* is wildcard matched in %n, the header has been read:
  25.     if (GET * $+ $str($crlf,2) $+ * iswm %n) {
  26.  
  27.       ;set %head to the entire header
  28.       var %head = $regsubex(%n,/(\r\n\r\n.*)/s,$Null)
  29.  
  30.       ;change the sockets mark to GotHeader so we stop looking for the head
  31.       sockmark $sockname GotHeader
  32.  
  33.      ;HEY, I GOT THAT DOUBLE CRLFCRLF I WAS LOOKING FOR, lets do some stuff
  34.      echo -s %head
  35.  
  36.     }
  37.     ;if Get *crlfcrlf* isn't matched in %n, lets save it, to look at on the next read
  38.     else { set $+(%,$sockname) %n }
  39.   }
  40.  
  41.   ;loop back so we can try to read more data
  42.   goto loop
  43. }
Advertisement
Add Comment
Please, Sign In to add comment