2
* Drizzle Client & Protocol Library
4
* Copyright (C) 2008 Eric Day (eday@oddments.org)
7
* Use and distribution licensed under the BSD license. See
8
* the COPYING file in this directory for full text.
13
* @brief State machine definitions
18
drizzle_return_t drizzle_state_loop(drizzle_con_st *con)
22
while (!drizzle_state_none(con))
24
ret= con->state_stack[con->state_current - 1](con);
25
if (ret != DRIZZLE_RETURN_OK)
27
if (ret != DRIZZLE_RETURN_IO_WAIT && ret != DRIZZLE_RETURN_PAUSE &&
28
ret != DRIZZLE_RETURN_ERROR_CODE)
30
drizzle_con_close(con);
37
return DRIZZLE_RETURN_OK;
40
drizzle_return_t drizzle_state_packet_read(drizzle_con_st *con)
42
drizzle_log_debug(con->drizzle, "drizzle_state_packet_read");
44
if (con->buffer_size < 4)
46
drizzle_state_push(con, drizzle_state_read);
47
return DRIZZLE_RETURN_OK;
50
con->packet_size= drizzle_get_byte3(con->buffer_ptr);
52
if (con->packet_number != con->buffer_ptr[3])
54
drizzle_set_error(con->drizzle, "drizzle_state_packet_read",
55
"bad packet number:%u:%u", con->packet_number,
57
return DRIZZLE_RETURN_BAD_PACKET_NUMBER;
60
drizzle_log_debug(con->drizzle, "packet_size= %zu, packet_number= %u",
61
con->packet_size, con->packet_number);
68
drizzle_state_pop(con);
69
return DRIZZLE_RETURN_OK;