mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Oct 2005
Posts: 827
P
pouncer Offline OP
Hoopy frood
OP Offline
Hoopy frood
P
Joined: Oct 2005
Posts: 827
Code:
on *:sockread:creds.*: {
  sockread &data

  if ($bfind(&data, 1, BinarySecurityToken Id="PPToken1">t=)) {
    var %start = $calc($ifmatch + 34), %end = $bfind(&data, %start,  </wsse:BinarySecurityToken>), $&
      %str = $bvar(&data, $+(%start, -, %end)).text)
  }
}


problem here is that the string im trying to capture is

BinarySecurityToken Id="PPToken1">t=blahblah</wsse:BinarySecurityToken>

but in the sockread its coming through in chunks like

BinarySecurityToken Id="PPToken1">t=blahblahfgfdgfdgf
fgdgfdgfdgfdgfdg</wsse:BinarySecurityToken>

how can i change the code so it waits until the &data var has been fully filled up before doing the $bfind ?

Joined: Jul 2007
Posts: 1,129
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,129
Ummm...is there a particular reason why you have to use binary variables? You can do something like this with regex to get the string you want:
Code:
on *:sockread:creds.*: {
  var %data
  sockread %data
  if ($regex(%data,/BinarySecurityToken Id="PPToken1">t=(.+)</wsse:BinarySecurityToken>/)) {
then use $regml(1) to reference to the string.

Joined: Oct 2005
Posts: 827
P
pouncer Offline OP
Hoopy frood
OP Offline
Hoopy frood
P
Joined: Oct 2005
Posts: 827
it needs to be binvars because the server sends back 1 huge xml response.. its 1 huge string..

Joined: Dec 2002
Posts: 5,169
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2002
Posts: 5,169
It would not be practical for mIRC to wait until the entire file or data had been sent before triggering a sockread and then allowing you to /sockread all of the data at once - what if the incoming file or data was one gigabyte in size?

You will need to read the data from the socket as each packet comes in and /bwrite it to a file (or store it in a hash file as a binary value). Once the server has finished sending data and closes the socket connection, you can then process the contents of your file.

Joined: Sep 2005
Posts: 2,881
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
Try this:

Code:
on *:sockread:creds.*: {
  sockread &data
  while ($sockbr) {
    sockread &data2
    bcopy &data $calc($bvar(&data,0) + 1) &data2 1 -1
  }
  if ($bfind(&data, 1, BinarySecurityToken Id="PPToken1">t=)) {
    var %start = $calc($ifmatch + 34), %end = $bfind(&data, %start,  </wsse:BinarySecurityToken>), $&
      %str = $bvar(&data, $+(%start, -, %end)).text)
  }
}


I haven't tested it but I think it should work. If it doesn't, try changing 1 -1 to 0 -1 in the /bcopy command.. I can't remember whether or not the position starts at 0!

Joined: Oct 2005
Posts: 827
P
pouncer Offline OP
Hoopy frood
OP Offline
Hoopy frood
P
Joined: Oct 2005
Posts: 827
thanks hixxy, i get some errors though

* /bcopy: invalid parameters

tried with both 1 -1 and 0 -1

Last edited by pouncer; 30/05/10 11:50 AM.
Joined: Nov 2008
Posts: 22
F
Ameglian cow
Offline
Ameglian cow
F
Joined: Nov 2008
Posts: 22
Try looping until you get the end.
i.e.
Code:
on *:sockread:creds.*: {
 sockread &data
 if ($bfind(&data, 1, BinarySecurityToken Id="PPToken1">t=)) {
  ;...append original line
  while (!$bfind(&data, %start,  </wsse:BinarySecurityToken>)) {
   ;...append data
   sockread &data
  }
  ;...There'll be some data at the end, append it too.
 }
}

One problem is the length by which the loop may run maybe freezing up mIRC, make sure you don't let it run forever.
Sorry if that's bad psuedocode =(

Last edited by Firstmate; 03/06/10 04:33 AM.

Link Copied to Clipboard