~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to libdrizzle-1.0/handshake.cc

Fix merge issues with 1.0 CC fix.

Show diffs side-by-side

added added

removed removed

Lines of Context:
142
142
  }
143
143
 
144
144
  /* Look for null-terminated server version string. */
145
 
  ptr= memchr(con->buffer_ptr, 0, con->buffer_size - 1);
 
145
  ptr= (uint8_t*)memchr(con->buffer_ptr, 0, con->buffer_size - 1);
146
146
  if (ptr == NULL)
147
147
  {
148
148
    drizzle_set_error(con->drizzle, "drizzle_state_handshake_server_read",
188
188
  con->charset= con->buffer_ptr[0];
189
189
  con->buffer_ptr+= 1;
190
190
 
191
 
  con->status= drizzle_get_byte2(con->buffer_ptr);
 
191
  con->status= drizzle_con_status_t(drizzle_get_byte2(con->buffer_ptr));
192
192
  /* Skip status and filler. */
193
193
  con->buffer_ptr+= 15;
194
194
 
325
325
drizzle_return_t drizzle_state_handshake_client_read(drizzle_con_st *con)
326
326
{
327
327
  size_t real_size;
328
 
  uint8_t *ptr;
329
328
  uint8_t scramble_size;
330
329
 
331
330
  drizzle_log_debug(con->drizzle, "drizzle_state_handshake_client_read");
368
367
  con->buffer_ptr+= 23;
369
368
 
370
369
  /* Look for null-terminated user string. */
371
 
  ptr= memchr(con->buffer_ptr, 0, con->buffer_size - 32);
 
370
  uint8_t *ptr= (uint8_t*)memchr(con->buffer_ptr, 0, con->buffer_size - 32);
372
371
  if (ptr == NULL)
373
372
  {
374
373
    drizzle_set_error(con->drizzle, "drizzle_state_handshake_client_read",
401
400
  con->buffer_ptr+= 1;
402
401
 
403
402
  if (scramble_size == 0)
 
403
  {
404
404
    con->scramble= NULL;
 
405
  }
405
406
  else
406
407
  {
407
408
    if (scramble_size != DRIZZLE_MAX_SCRAMBLE_SIZE)
420
421
 
421
422
  /* Look for null-terminated db string. */
422
423
  if ((34 + strlen(con->user) + scramble_size) == con->packet_size)
 
424
  {
423
425
    con->db[0]= 0;
 
426
  }
424
427
  else
425
428
  {
426
 
    ptr= memchr(con->buffer_ptr, 0, con->buffer_size -
 
429
    ptr= (uint8_t*)memchr(con->buffer_ptr, 0, con->buffer_size -
427
430
                                    (34 + strlen(con->user) + scramble_size));
428
431
    if (ptr == NULL)
429
432
    {
470
473
drizzle_return_t drizzle_state_handshake_client_write(drizzle_con_st *con)
471
474
{
472
475
  uint8_t *ptr;
473
 
  drizzle_capabilities_t capabilities;
 
476
  int capabilities;
474
477
  drizzle_return_t ret;
475
478
 
476
479
  drizzle_log_debug(con->drizzle, "drizzle_state_handshake_client_write");
503
506
  if (con->options & DRIZZLE_CON_MYSQL)
504
507
    con->capabilities|= DRIZZLE_CAPABILITIES_PROTOCOL_41;
505
508
 
506
 
  capabilities= con->capabilities & DRIZZLE_CAPABILITIES_CLIENT;
 
509
  capabilities= con->capabilities & int(DRIZZLE_CAPABILITIES_CLIENT);
507
510
  if (!(con->options & DRIZZLE_CON_FOUND_ROWS))
508
 
    capabilities&= ~DRIZZLE_CAPABILITIES_FOUND_ROWS;
 
511
    capabilities&= ~int(DRIZZLE_CAPABILITIES_FOUND_ROWS);
509
512
 
510
513
  if (con->options & DRIZZLE_CON_INTERACTIVE)
511
514
  {
512
 
    capabilities|= DRIZZLE_CAPABILITIES_INTERACTIVE;
 
515
    capabilities|= int(DRIZZLE_CAPABILITIES_INTERACTIVE);
513
516
  }
514
517
 
515
518
  if (con->options & DRIZZLE_CON_MULTI_STATEMENTS)
516
519
  {
517
 
    capabilities|= DRIZZLE_CAPABILITIES_MULTI_STATEMENTS;
 
520
    capabilities|= int(DRIZZLE_CAPABILITIES_MULTI_STATEMENTS);
518
521
  }
519
522
 
520
523
  if (con->options & DRIZZLE_CON_AUTH_PLUGIN)
521
524
  {
522
 
    capabilities|= DRIZZLE_CAPABILITIES_PLUGIN_AUTH;
 
525
    capabilities|= int(DRIZZLE_CAPABILITIES_PLUGIN_AUTH);
523
526
  }
524
527
 
525
 
  capabilities&= ~(DRIZZLE_CAPABILITIES_COMPRESS | DRIZZLE_CAPABILITIES_SSL);
 
528
  capabilities&= ~(int(DRIZZLE_CAPABILITIES_COMPRESS) | int(DRIZZLE_CAPABILITIES_SSL));
526
529
  if (con->db[0] == 0)
527
 
    capabilities&= ~DRIZZLE_CAPABILITIES_CONNECT_WITH_DB;
 
530
    capabilities&= ~int(DRIZZLE_CAPABILITIES_CONNECT_WITH_DB);
528
531
 
529
532
  drizzle_set_byte4(ptr, capabilities);
530
533
  ptr+= 4;