~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to libdrizzle-1.0/libdrizzle/drizzle.c

  • Committer: Olaf van der Spek
  • Date: 2011-10-17 22:46:16 UTC
  • mto: This revision was merged to the branch mainline in revision 2442.
  • Revision ID: olafvdspek@gmail.com-20111017224616-gcj9z1sjpauwsp14
Refactor

Show diffs side-by-side

added added

removed removed

Lines of Context:
39
39
 * @brief Drizzle Definitions
40
40
 */
41
41
 
42
 
#include <libdrizzle-1.0/common.h>
 
42
#include "libdrizzle/common.h"
43
43
 
44
44
/**
45
45
 * @addtogroup drizzle_static Static Drizzle Declarations
101
101
 
102
102
  if (drizzle == NULL)
103
103
  {
104
 
    drizzle= new (std::nothrow) drizzle_st;
 
104
    drizzle= malloc(sizeof(drizzle_st));
105
105
    if (drizzle == NULL)
106
106
      return NULL;
107
107
 
145
145
  if (drizzle == NULL)
146
146
    return NULL;
147
147
 
148
 
  drizzle->options|= (from->options & int(~DRIZZLE_ALLOCATED));
 
148
  drizzle->options|= (from->options & (drizzle_options_t)~DRIZZLE_ALLOCATED);
149
149
 
150
150
  for (con= from->con_list; con != NULL; con= con->next)
151
151
  {
207
207
 
208
208
drizzle_options_t drizzle_options(const drizzle_st *drizzle)
209
209
{
210
 
  return drizzle_options_t(drizzle->options);
 
210
  return drizzle->options;
211
211
}
212
212
 
213
213
void drizzle_set_options(drizzle_st *drizzle, drizzle_options_t options)
280
280
{
281
281
  if (con == NULL)
282
282
  {
283
 
    con= new (std::nothrow) drizzle_con_st;
 
283
    con= malloc(sizeof(drizzle_con_st));
284
284
    if (con == NULL)
285
285
    {
286
286
      if (drizzle != NULL)
307
307
  con->revents= 0;
308
308
  con->capabilities= DRIZZLE_CAPABILITIES_NONE;
309
309
  con->charset= 0;
310
 
  con->command= drizzle_command_t();
 
310
  con->command= 0;
311
311
  con->options|= DRIZZLE_CON_MYSQL;
312
312
  con->socket_type= DRIZZLE_CON_SOCKET_TCP;
313
313
  con->status= DRIZZLE_CON_STATUS_NONE;
356
356
    return NULL;
357
357
 
358
358
  /* Clear "operational" options such as IO status. */
359
 
  con->options|= (from->options & int(~(
 
359
  con->options|= (from->options & (drizzle_con_options_t)~(
360
360
                  DRIZZLE_CON_ALLOCATED|DRIZZLE_CON_READY|
361
361
                  DRIZZLE_CON_NO_RESULT_READ|DRIZZLE_CON_IO_READY|
362
 
                  DRIZZLE_CON_LISTEN)));
 
362
                  DRIZZLE_CON_LISTEN));
363
363
  con->backlog= from->backlog;
364
364
  strcpy(con->db, from->db);
365
365
  strcpy(con->password, from->password);
512
512
  {
513
513
    if (con->options & DRIZZLE_CON_IO_READY)
514
514
    {
515
 
      con->options&= int(~DRIZZLE_CON_IO_READY);
 
515
      con->options&= (drizzle_con_options_t)~DRIZZLE_CON_IO_READY;
516
516
      return con;
517
517
    }
518
518
  }
532
532
    if ((con->options & (DRIZZLE_CON_IO_READY | DRIZZLE_CON_LISTEN)) ==
533
533
        (DRIZZLE_CON_IO_READY | DRIZZLE_CON_LISTEN))
534
534
    {
535
 
      con->options&= int(~DRIZZLE_CON_IO_READY);
 
535
      con->options&= (drizzle_con_options_t)~DRIZZLE_CON_IO_READY;
536
536
      return con;
537
537
    }
538
538
  }
595
595
 
596
596
  drizzle_con_set_tcp(con, host, port);
597
597
  drizzle_con_set_backlog(con, backlog);
598
 
  drizzle_con_add_options(con, drizzle_con_options_t(DRIZZLE_CON_LISTEN | int(options)));
 
598
  drizzle_con_add_options(con, DRIZZLE_CON_LISTEN | options);
599
599
 
600
600
  return con;
601
601
}
611
611
 
612
612
  drizzle_con_set_uds(con, uds);
613
613
  drizzle_con_set_backlog(con, backlog);
614
 
  drizzle_con_add_options(con, drizzle_con_options_t(DRIZZLE_CON_LISTEN | int(options)));
 
614
  drizzle_con_add_options(con, DRIZZLE_CON_LISTEN | options);
615
615
 
616
616
  return con;
617
617
}
677
677
{
678
678
  size_t size;
679
679
  int written;
 
680
  char *ptr;
680
681
  char log_buffer[DRIZZLE_MAX_ERROR_SIZE];
681
682
  va_list args;
682
683
 
683
684
  size= strlen(function);
684
 
  char *ptr= (char *)memcpy(log_buffer, function, size);
 
685
  ptr= memcpy(log_buffer, function, size);
685
686
  ptr+= size;
686
687
  ptr[0]= ':';
687
688
  size++;