libdrizzle Developer Documentation

state.c
Go to the documentation of this file.
1 /*
2  * Drizzle Client & Protocol Library
3  *
4  * Copyright (C) 2008 Eric Day (eday@oddments.org)
5  * All rights reserved.
6  *
7  * Use and distribution licensed under the BSD license. See
8  * the COPYING file in this directory for full text.
9  */
10 
16 #include "common.h"
17 
19 {
20  drizzle_return_t ret;
21 
22  while (!drizzle_state_none(con))
23  {
24  ret= con->state_stack[con->state_current - 1](con);
25  if (ret != DRIZZLE_RETURN_OK)
26  {
27  if (ret != DRIZZLE_RETURN_IO_WAIT && ret != DRIZZLE_RETURN_PAUSE &&
29  {
30  drizzle_con_close(con);
31  }
32 
33  return ret;
34  }
35  }
36 
37  return DRIZZLE_RETURN_OK;
38 }
39 
41 {
42  drizzle_log_debug(con->drizzle, "drizzle_state_packet_read");
43 
44  if (con->buffer_size < 4)
45  {
47  return DRIZZLE_RETURN_OK;
48  }
49 
51 
52  if (con->packet_number != con->buffer_ptr[3])
53  {
54  drizzle_set_error(con->drizzle, "drizzle_state_packet_read",
55  "bad packet number:%u:%u", con->packet_number,
56  con->buffer_ptr[3]);
58  }
59 
60  drizzle_log_debug(con->drizzle, "packet_size= %zu, packet_number= %u",
61  con->packet_size, con->packet_number);
62 
63  con->packet_number++;
64 
65  con->buffer_ptr+= 4;
66  con->buffer_size-= 4;
67 
68  drizzle_state_pop(con);
69  return DRIZZLE_RETURN_OK;
70 }