~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to libdrizzle-1.0/conn.cc

  • Committer: Brian Aker
  • Date: 2011-11-30 17:23:18 UTC
  • mto: This revision was merged to the branch mainline in revision 2466.
  • Revision ID: brian@tangent.org-20111130172318-3lfw8f73h0uycpda
Fix compiling issues for 1.0, and cleanup header files.

Show diffs side-by-side

added added

removed removed

Lines of Context:
89
89
  (void)closesocket(con->fd);
90
90
  con->fd= -1;
91
91
 
92
 
  con->options&= (drizzle_con_options_t)~DRIZZLE_CON_READY;
 
92
  con->options&= int(~DRIZZLE_CON_READY);
93
93
  con->packet_number= 0;
94
94
  con->buffer_ptr= con->buffer;
95
95
  con->buffer_size= 0;
179
179
 
180
180
drizzle_con_options_t drizzle_con_options(const drizzle_con_st *con)
181
181
{
182
 
  return con->options;
 
182
  return drizzle_con_options_t(con->options);
183
183
}
184
184
 
185
185
void drizzle_con_set_options(drizzle_con_st *con,
196
196
  /* If asking for the experimental Drizzle protocol, clean the MySQL flag. */
197
197
  if (con->options & DRIZZLE_CON_EXPERIMENTAL)
198
198
  {
199
 
    con->options&= (drizzle_con_options_t)~DRIZZLE_CON_MYSQL;
 
199
    con->options&= int(~DRIZZLE_CON_MYSQL);
200
200
  }
201
201
}
202
202
 
356
356
 
357
357
drizzle_capabilities_t drizzle_con_capabilities(const drizzle_con_st *con)
358
358
{
359
 
  return con->capabilities;
 
359
  return drizzle_capabilities_t(con->capabilities);
360
360
}
361
361
 
362
362
drizzle_charset_t drizzle_con_charset(const drizzle_con_st *con)
654
654
  drizzle_con_set_server_version(con, from->server_version);
655
655
  drizzle_con_set_thread_id(con, from->thread_id);
656
656
  drizzle_con_set_scramble(con, from->scramble);
657
 
  drizzle_con_set_capabilities(con, from->capabilities);
 
657
  drizzle_con_set_capabilities(con, drizzle_capabilities_t(from->capabilities));
658
658
  drizzle_con_set_charset(con, from->charset);
659
659
  drizzle_con_set_status(con, from->status);
660
660
  drizzle_con_set_max_packet_size(con, from->max_packet_size);
692
692
                                 drizzle_command_t *command, size_t *total,
693
693
                                 drizzle_return_t *ret_ptr)
694
694
{
695
 
  uint8_t *command_data;
696
695
  size_t offset= 0;
697
696
  size_t size= 0;
698
697
 
699
 
  command_data= drizzle_con_command_read(con, command, &offset, &size, total, ret_ptr);
 
698
  char *command_data= (char *)drizzle_con_command_read(con, command, &offset, &size, total, ret_ptr);
700
699
  if (*ret_ptr != DRIZZLE_RETURN_OK)
701
700
    return NULL;
702
701
 
708
707
 
709
708
  if (con->command_buffer == NULL)
710
709
  {
711
 
    con->command_buffer= malloc((*total) + 1);
 
710
    con->command_buffer= (uint8_t*)malloc((*total) + 1);
712
711
    if (con->command_buffer == NULL)
713
712
    {
714
713
      drizzle_set_error(con->drizzle, "drizzle_command_buffer", "malloc");
721
720
 
722
721
  while ((offset + size) != (*total))
723
722
  {
724
 
    command_data= drizzle_con_command_read(con, command, &offset, &size, total,
725
 
                                           ret_ptr);
 
723
    command_data= (char *)drizzle_con_command_read(con, command, &offset, &size, total, ret_ptr);
726
724
    if (*ret_ptr != DRIZZLE_RETURN_OK)
727
725
      return NULL;
728
726
 
729
727
    memcpy(con->command_buffer + offset, command_data, size);
730
728
  }
731
729
 
732
 
  command_data= con->command_buffer;
 
730
  command_data= (char *)con->command_buffer;
733
731
  con->command_buffer= NULL;
734
732
  command_data[*total]= 0;
735
733
 
1219
1217
{
1220
1218
  char host[NI_MAXHOST];
1221
1219
  char port[NI_MAXSERV];
1222
 
  int ret;
1223
1220
  int fd;
1224
1221
  int opt;
1225
1222
  drizzle_con_st *new_con;
1227
1224
  for (; con->addrinfo_next != NULL;
1228
1225
       con->addrinfo_next= con->addrinfo_next->ai_next)
1229
1226
  {
1230
 
    ret= getnameinfo(con->addrinfo_next->ai_addr,
1231
 
                     con->addrinfo_next->ai_addrlen, host, NI_MAXHOST, port,
1232
 
                     NI_MAXSERV, NI_NUMERICHOST | NI_NUMERICSERV);
 
1227
    int ret= getnameinfo(con->addrinfo_next->ai_addr,
 
1228
                         con->addrinfo_next->ai_addrlen, host, NI_MAXHOST, port,
 
1229
                         NI_MAXSERV, NI_NUMERICHOST | NI_NUMERICSERV);
1233
1230
    if (ret != 0)
1234
1231
    {
1235
 
      drizzle_set_error(con->drizzle, "drizzle_state_listen", "getnameinfo:%s",
1236
 
                        gai_strerror(ret));
 
1232
      drizzle_set_error(con->drizzle, "drizzle_state_listen", "getnameinfo:%s", gai_strerror(ret));
1237
1233
      return DRIZZLE_RETURN_GETADDRINFO;
1238
1234
    }
1239
1235
 
1307
1303
    }
1308
1304
 
1309
1305
    /* Wait for read events on the listening socket. */
1310
 
    ret= drizzle_con_set_events(new_con, POLLIN);
1311
 
    if (ret != DRIZZLE_RETURN_OK)
 
1306
    drizzle_return_t local_ret= drizzle_con_set_events(new_con, POLLIN);
 
1307
    if (local_ret != DRIZZLE_RETURN_OK)
1312
1308
    {
1313
1309
      drizzle_con_free(new_con);
1314
 
      return ret;
 
1310
      return local_ret;
1315
1311
    }
1316
1312
 
1317
1313
    drizzle_log_info(con->drizzle, "listening on %s:%s", host, port);