~brianaker/libdrizzle/windows-support-via-mingw

« back to all changes in this revision

Viewing changes to libdrizzle/pack.cc

  • Committer: Continuous Integration
  • Date: 2013-01-05 11:52:21 UTC
  • mfrom: (79.1.5 5.1-api-fixes)
  • Revision ID: ci@drizzle.org-20130105115221-qxd0g29jljekx7q9
Merge lp:~linuxjedi/libdrizzle/5.1-api-fixes Build: jenkins-Libdrizzle-33

Show diffs side-by-side

added added

removed removed

Lines of Context:
57
57
 * Compute hash from password and scramble.
58
58
 */
59
59
static drizzle_return_t _pack_scramble_hash(drizzle_st *con,
60
 
                                            uint8_t *buffer);
 
60
                                            unsigned char *buffer);
61
61
 
62
62
/** @} */
63
63
 
65
65
 * Public definitions
66
66
 */
67
67
 
68
 
uint8_t *drizzle_pack_length(uint64_t number, uint8_t *ptr)
 
68
unsigned char *drizzle_pack_length(uint64_t number, unsigned char *ptr)
69
69
{
70
70
  if (number < 251)
71
71
  {
157
157
  return length;
158
158
}
159
159
 
160
 
uint8_t *drizzle_pack_string(char *string, uint8_t *ptr)
 
160
unsigned char *drizzle_pack_string(char *string, unsigned char *ptr)
161
161
{
162
162
  if (string == NULL)
163
163
  {
176
176
  return ptr;
177
177
}
178
178
 
179
 
uint8_t *drizzle_pack_binary(uint8_t *data, size_t len, uint8_t *ptr)
 
179
unsigned char *drizzle_pack_binary(unsigned char *data, size_t len, unsigned char *ptr)
180
180
{
181
181
  ptr= drizzle_pack_length(len, ptr);
182
182
  if (len > 0)
188
188
  return ptr;
189
189
}
190
190
 
191
 
uint8_t *drizzle_pack_time(drizzle_datetime_st *time, uint8_t *ptr)
 
191
unsigned char *drizzle_pack_time(drizzle_datetime_st *time, unsigned char *ptr)
192
192
{
193
193
  uint8_t length= 0;
194
194
 
213
213
  return ptr+length;
214
214
}
215
215
 
216
 
uint8_t *drizzle_pack_datetime(drizzle_datetime_st *datetime, uint8_t *ptr)
 
216
unsigned char *drizzle_pack_datetime(drizzle_datetime_st *datetime, unsigned char *ptr)
217
217
{
218
218
  uint8_t length= 0;
219
219
 
245
245
  return ptr + length;
246
246
}
247
247
 
248
 
void drizzle_unpack_time(drizzle_field_t field, size_t length, uint8_t *data)
 
248
void drizzle_unpack_time(drizzle_field_t field, size_t length, unsigned char *data)
249
249
{
250
250
  drizzle_datetime_st *datetime= (drizzle_datetime_st*) data;
251
251
  memset(datetime, 0, length);
266
266
  }
267
267
}
268
268
 
269
 
void drizzle_unpack_datetime(drizzle_field_t field, size_t length, uint8_t *data)
 
269
void drizzle_unpack_datetime(drizzle_field_t field, size_t length, unsigned char *data)
270
270
{
271
271
  drizzle_datetime_st *datetime= (drizzle_datetime_st*) data;
272
272
  memset(datetime, 0, length);
332
332
  return DRIZZLE_RETURN_OK;
333
333
}
334
334
 
335
 
uint8_t *drizzle_pack_auth(drizzle_st *con, uint8_t *ptr,
 
335
unsigned char *drizzle_pack_auth(drizzle_st *con, unsigned char *ptr,
336
336
                           drizzle_return_t *ret_ptr)
337
337
{
338
338
  drizzle_return_t unused_ret;
408
408
 */
409
409
 
410
410
static drizzle_return_t _pack_scramble_hash(drizzle_st *con,
411
 
                                            uint8_t *buffer)
 
411
                                            unsigned char *buffer)
412
412
{
413
413
  SHA1_CTX ctx;
414
 
  uint8_t hash_tmp1[SHA1_DIGEST_LENGTH];
415
 
  uint8_t hash_tmp2[SHA1_DIGEST_LENGTH];
 
414
  unsigned char hash_tmp1[SHA1_DIGEST_LENGTH];
 
415
  unsigned char hash_tmp2[SHA1_DIGEST_LENGTH];
416
416
 
417
417
  if (SHA1_DIGEST_LENGTH != DRIZZLE_MAX_SCRAMBLE_SIZE)
418
418
  {
431
431
 
432
432
  /* First hash the password. */
433
433
  SHA1Init(&ctx);
434
 
  SHA1Update(&ctx, (uint8_t *)(con->password), strlen(con->password));
 
434
  SHA1Update(&ctx, (unsigned char *)(con->password), strlen(con->password));
435
435
  SHA1Final(hash_tmp1, &ctx);
436
436
 
437
437
  /* Second, hash the password hash. */