Branch: Tag:

2015-03-31

2015-03-31 03:10:30 by Martin Nilsson <nilsson@opera.com>

Change alert_buffer to an Stdio.Buffer object. Improved internal documentation and types.

697:    return size;   }    - protected int handle_alert(string s) + // @returns + // @int + // @elem value -1 + // A Fatal error occurred and processing should stop. + // @elem value 0 + // Processing can continue. + // @elem value 1 + // Connection should close. + // @endint + protected int(-1..1) handle_alert(string s)   {    // sizeof(s)==2, checked at caller.    int level = s[0];
861:   }      Stdio.Buffer handshake_buffer = Stdio.Buffer(); // Error mode 0. - string(8bit) alert_buffer = ""; + Stdio.Buffer alert_buffer = Stdio.Buffer();      //! Main receive handler.   //!
944:    COND_FATAL(!sizeof(packet->fragment), ALERT_unexpected_message,    "Zero length Alert fragments not allowed.\n");    -  int i; +     int err = 0; -  alert_buffer += packet->fragment; -  for (i = 0; -  !err && ((sizeof(alert_buffer) - i) >= 2); -  i+= 2) -  err = handle_alert(alert_buffer[i..i+1]); +  alert_buffer->add( packet->fragment ); +  while(!err && sizeof(alert_buffer)>1) +  err = handle_alert(alert_buffer->read(2));    -  alert_buffer = alert_buffer[i..]; +     if (err)    if (err > 0 && sizeof (res))    // If we get a close then we return the data we got so far.