~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to libdrizzle/libdrizzle.c

Merged in Jay's tree.

Show diffs side-by-side

added added

removed removed

Lines of Context:
63
63
#undef net_buffer_length
64
64
#undef max_allowed_packet
65
65
 
66
 
ulong           net_buffer_length=8192;
67
 
ulong           max_allowed_packet= 1024L*1024L*1024L;
 
66
uint32_t                net_buffer_length= 8192;
 
67
uint32_t                max_allowed_packet= 1024L*1024L*1024L;
68
68
 
69
69
#include <errno.h>
70
70
#define SOCKET_ERROR -1
323
323
 
324
324
int cli_read_change_user_result(MYSQL *mysql, char *buff, const char *passwd)
325
325
{
326
 
  NET *net= &mysql->net;
327
326
  ulong pkt_length;
328
327
 
329
328
  pkt_length= cli_safe_read(mysql);
331
330
  if (pkt_length == packet_error)
332
331
    return 1;
333
332
 
334
 
  if (pkt_length == 1 && net->read_pos[0] == 254 &&
335
 
      mysql->server_capabilities & CLIENT_SECURE_CONNECTION)
336
 
  {
337
 
    /*
338
 
      By sending this very specific reply server asks us to send scrambled
339
 
      password in old format. The reply contains scramble_323.
340
 
    */
341
 
    scramble_323(buff, mysql->scramble, passwd);
342
 
    if (my_net_write(net, (uchar*) buff, SCRAMBLE_LENGTH_323 + 1) ||
343
 
        net_flush(net))
344
 
    {
345
 
      set_mysql_error(mysql, CR_SERVER_LOST, unknown_sqlstate);
346
 
      return 1;
347
 
    }
348
 
    /* Read what server thinks about out new auth message report */
349
 
    if (cli_safe_read(mysql) == packet_error)
350
 
      return 1;
351
 
  }
352
333
  return 0;
353
334
}
354
335
 
367
348
  if (mysql_init_character_set(mysql))
368
349
  {
369
350
    mysql->charset= saved_cs;
370
 
    DBUG_RETURN(TRUE);
 
351
    DBUG_RETURN(true);
371
352
  }
372
353
 
373
354
  /* Use an empty string instead of NULL. */
383
364
  /* write scrambled password according to server capabilities */
384
365
  if (passwd[0])
385
366
  {
386
 
    if (mysql->server_capabilities & CLIENT_SECURE_CONNECTION)
387
367
    {
388
368
      *end++= SCRAMBLE_LENGTH;
389
369
      scramble(end, mysql->scramble, passwd);
390
370
      end+= SCRAMBLE_LENGTH;
391
371
    }
392
 
    else
393
 
    {
394
 
      scramble_323(end, mysql->scramble, passwd);
395
 
      end+= SCRAMBLE_LENGTH_323 + 1;
396
 
    }
397
372
  }
398
373
  else
399
374
    *end++= '\0';                               /* empty password */
409
384
  }
410
385
 
411
386
  /* Write authentication package */
412
 
  simple_command(mysql,COM_CHANGE_USER, (uchar*) buff, (ulong) (end-buff), 1);
 
387
  (void)simple_command(mysql,COM_CHANGE_USER, (uchar*) buff, (ulong) (end-buff), 1);
413
388
 
414
389
  rc= (*mysql->methods->read_change_user_result)(mysql, buff, passwd);
415
390
 
931
906
}
932
907
 
933
908
 
934
 
int STDCALL
935
 
mysql_kill(MYSQL *mysql,ulong pid)
 
909
int32_t STDCALL
 
910
mysql_kill(MYSQL *mysql, uint32_t pid)
936
911
{
937
912
  uchar buff[4];
938
913
  DBUG_ENTER("mysql_kill");
1019
994
  return (char*) MYSQL_SERVER_VERSION;
1020
995
}
1021
996
 
1022
 
ulong STDCALL mysql_get_client_version(void)
 
997
uint32_t STDCALL mysql_get_client_version(void)
1023
998
{
1024
999
  return MYSQL_VERSION_ID;
1025
1000
}
1071
1046
  return mysql ? mysql->net.sqlstate : cant_connect_sqlstate;
1072
1047
}
1073
1048
 
1074
 
uint STDCALL mysql_warning_count(MYSQL *mysql)
 
1049
uint32_t STDCALL mysql_warning_count(MYSQL *mysql)
1075
1050
{
1076
1051
  return mysql->warning_count;
1077
1052
}
1081
1056
  return mysql->info;
1082
1057
}
1083
1058
 
1084
 
ulong STDCALL mysql_thread_id(MYSQL *mysql)
 
1059
uint32_t STDCALL mysql_thread_id(MYSQL *mysql)
1085
1060
{
1086
1061
  return (mysql)->thread_id;
1087
1062
}
1159
1134
  trailing '. The caller must supply whichever of those is desired.
1160
1135
*/
1161
1136
 
1162
 
ulong STDCALL
1163
 
mysql_hex_string(char *to, const char *from, ulong length)
 
1137
uint32_t STDCALL
 
1138
mysql_hex_string(char *to, const char *from, uint32_t length)
1164
1139
{
1165
1140
  char *to0= to;
1166
1141
  const char *end;
1171
1146
    *to++= _dig_vec_upper[((unsigned char) *from) & 0x0F];
1172
1147
  }
1173
1148
  *to= '\0';
1174
 
  return (ulong) (to-to0);
 
1149
  return (uint32_t) (to-to0);
1175
1150
}
1176
1151
 
1177
1152
/*
1180
1155
  Returns the length of the to string
1181
1156
*/
1182
1157
 
1183
 
ulong STDCALL
1184
 
mysql_escape_string(char *to,const char *from,ulong length)
 
1158
uint32_t STDCALL
 
1159
mysql_escape_string(char *to,const char *from, uint32_t length)
1185
1160
{
1186
1161
  return escape_string_for_mysql(default_charset_info, to, 0, from, length);
1187
1162
}
1188
1163
 
1189
 
ulong STDCALL
 
1164
uint32_t STDCALL
1190
1165
mysql_real_escape_string(MYSQL *mysql, char *to,const char *from,
1191
 
                         ulong length)
 
1166
                         uint32_t length)
1192
1167
{
1193
1168
  if (mysql->server_status & SERVER_STATUS_NO_BACKSLASH_ESCAPES)
1194
1169
    return escape_quotes_for_mysql(mysql->charset, to, 0, from, length);