Get a string formatted according to the 4.0 version of the MySQL protocol. @param buffer[in, out] Pointer to the user-supplied buffer to be scanned. @param max_bytes_available[in, out] Limit the bytes to scan. @param string_length[out] The number of characters scanned not including the null character. @remark If there are not enough bytes left after the cu
| 10445 | string. |
| 10446 | */ |
| 10447 | static |
| 10448 | char *get_40_protocol_string(char **buffer, |
| 10449 | size_t *max_bytes_available, |
| 10450 | size_t *string_length) |
| 10451 | { |
| 10452 | char *str; |
| 10453 | size_t len; |
| 10454 | |
| 10455 | /* No bytes to scan left, treat string as empty. */ |
| 10456 | if ((*max_bytes_available) == 0) |
| 10457 | { |
| 10458 | *string_length= 0; |
| 10459 | return empty_c_string; |
| 10460 | } |
| 10461 | |
| 10462 | str= (char *) memchr(*buffer, '\0', *max_bytes_available); |
| 10463 | |
| 10464 | /* |
| 10465 | If the string was not null terminated by the client, |
| 10466 | the remainder of the packet is the string. Otherwise, |
| 10467 | advance the buffer past the end of the null terminated |
| 10468 | string. |
| 10469 | */ |
| 10470 | if (str == NULL) |
| 10471 | len= *string_length= *max_bytes_available; |
| 10472 | else |
| 10473 | len= (*string_length= (size_t)(str - *buffer)) + 1; |
| 10474 | |
| 10475 | str= *buffer; |
| 10476 | *buffer+= len; |
| 10477 | *max_bytes_available-= len; |
| 10478 | |
| 10479 | return str; |
| 10480 | } |
| 10481 | |
| 10482 | /** |
| 10483 | Get a length encoded string from a user-supplied buffer. |
nothing calls this directly
no outgoing calls
no test coverage detected