92
92
for (next_ptr= string_ptr; isdigit(*string_ptr); string_ptr++) {};
93
result->item_flags= (uint32_t) strtoul(next_ptr, &string_ptr, 10);
93
result->impl()->item_flags= (uint32_t) strtoul(next_ptr, &string_ptr, 10);
95
95
if (end_ptr == string_ptr)
133
133
/* We add two bytes so that we can walk the \r\n */
134
if (memcached_failed(memcached_string_check(&result->value, value_length +2)))
134
if (memcached_failed(memcached_string_check(&result->impl()->value, value_length +2)))
136
136
return memcached_set_error(*instance, MEMCACHED_MEMORY_ALLOCATION_FAILURE, MEMCACHED_AT);
140
char *value_ptr= memcached_string_value_mutable(&result->value);
140
char *value_ptr= memcached_string_value_mutable(&result->impl()->value);
142
142
We read the \r\n into the string since not doing so is more
143
143
cycles then the waster of memory to do so.
166
166
/* This next bit blows the API, but this is internal....*/
169
char_ptr= memcached_string_value_mutable(&result->value);;
169
char_ptr= memcached_string_value_mutable(&result->impl()->value);
170
170
char_ptr[value_length]= 0;
171
171
char_ptr[value_length +1]= 0;
172
memcached_string_set_length(&result->value, value_length);
172
memcached_string_set_length(&result->impl()->value, value_length);
175
175
if (memcached_is_encrypted(instance->root) and memcached_result_length(result))
447
447
if (auto_return_value == ULLONG_MAX and errno == ERANGE)
449
result->numeric_value= UINT64_MAX;
449
result->impl()->numeric_value= UINT64_MAX;
450
450
return memcached_set_error(*instance, MEMCACHED_UNKNOWN_READ_FAILURE, MEMCACHED_AT,
451
451
memcached_literal_param("Numeric response was out of range"));
453
453
else if (errno == EINVAL)
455
result->numeric_value= UINT64_MAX;
455
result->impl()->numeric_value= UINT64_MAX;
456
456
return memcached_set_error(*instance, MEMCACHED_UNKNOWN_READ_FAILURE, MEMCACHED_AT,
457
457
memcached_literal_param("Numeric response was out of range"));
460
result->numeric_value= uint64_t(auto_return_value);
460
result->impl()->numeric_value= uint64_t(auto_return_value);
462
462
WATCHPOINT_STRING(buffer);
463
463
return MEMCACHED_SUCCESS;
524
524
uint16_t keylen= header.response.keylen;
525
525
memcached_result_reset(result);
526
result->item_cas= header.response.cas;
526
result->impl()->item_cas= header.response.cas;
528
if ((rc= memcached_safe_read(instance, &result->item_flags, sizeof (result->item_flags))) != MEMCACHED_SUCCESS)
528
if ((rc= memcached_safe_read(instance, &result->impl()->item_flags, sizeof (result->impl()->item_flags))) != MEMCACHED_SUCCESS)
530
530
WATCHPOINT_ERROR(rc);
531
531
return MEMCACHED_UNKNOWN_READ_FAILURE;
534
result->item_flags= ntohl(result->item_flags);
534
result->impl()->item_flags= ntohl(result->impl()->item_flags);
535
535
bodylen -= header.response.extlen;
537
result->key_length= keylen;
538
if (memcached_failed(rc= memcached_safe_read(instance, result->item_key, keylen)))
537
result->impl()->key_length= keylen;
538
if (memcached_failed(rc= memcached_safe_read(instance, result->impl()->item_key, keylen)))
540
540
WATCHPOINT_ERROR(rc);
541
541
return MEMCACHED_UNKNOWN_READ_FAILURE;
544
544
// Only bother with doing this if key_length > 0
545
if (result->key_length)
545
if (result->impl()->key_length)
547
if (memcached_array_size(instance->root->_namespace) and memcached_array_size(instance->root->_namespace) >= result->key_length)
547
if (memcached_array_size(instance->root->_namespace) and memcached_array_size(instance->root->_namespace) >= result->impl()->key_length)
549
549
return memcached_set_error(*instance, MEMCACHED_UNKNOWN_READ_FAILURE, MEMCACHED_AT);
552
552
if (memcached_array_size(instance->root->_namespace))
554
result->key_length-= memcached_array_size(instance->root->_namespace);
555
memmove(result->item_key, result->item_key +memcached_array_size(instance->root->_namespace), result->key_length);
554
result->impl()->key_length-= memcached_array_size(instance->root->_namespace);
555
memmove(result->impl()->item_key, result->impl()->item_key +memcached_array_size(instance->root->_namespace), result->impl()->key_length);
559
559
bodylen -= keylen;
560
if (memcached_failed(memcached_string_check(&result->value, bodylen)))
560
if (memcached_failed(memcached_string_check(&result->impl()->value, bodylen)))
562
562
return MEMCACHED_MEMORY_ALLOCATION_FAILURE;
565
char *vptr= memcached_string_value_mutable(&result->value);
565
char *vptr= memcached_string_value_mutable(&result->impl()->value);
566
566
if (memcached_failed(rc= memcached_safe_read(instance, vptr, bodylen)))
568
568
WATCHPOINT_ERROR(rc);
569
569
return MEMCACHED_UNKNOWN_READ_FAILURE;
572
memcached_string_set_length(&result->value, bodylen);
572
memcached_string_set_length(&result->impl()->value, bodylen);
579
579
if (bodylen != sizeof(uint64_t))
581
result->numeric_value= UINT64_MAX;
581
result->impl()->numeric_value= UINT64_MAX;
582
582
return memcached_set_error(*instance, MEMCACHED_UNKNOWN_READ_FAILURE, MEMCACHED_AT);
586
586
if ((rc= memcached_safe_read(instance, &val, sizeof(val))) != MEMCACHED_SUCCESS)
588
result->numeric_value= UINT64_MAX;
588
result->impl()->numeric_value= UINT64_MAX;
589
589
return MEMCACHED_UNKNOWN_READ_FAILURE;
592
result->numeric_value= memcached_ntohll(val);
592
result->impl()->numeric_value= memcached_ntohll(val);
697
697
case PROTOCOL_BINARY_CMD_SASL_STEP:
699
699
memcached_result_reset(result);
700
result->item_cas= header.response.cas;
700
result->impl()->item_cas= header.response.cas;
702
if (memcached_string_check(&result->value,
702
if (memcached_string_check(&result->impl()->value,
703
703
bodylen) != MEMCACHED_SUCCESS)
704
704
return MEMCACHED_MEMORY_ALLOCATION_FAILURE;
706
char *vptr= memcached_string_value_mutable(&result->value);
706
char *vptr= memcached_string_value_mutable(&result->impl()->value);
707
707
if ((rc= memcached_safe_read(instance, vptr, bodylen)) != MEMCACHED_SUCCESS)
709
709
WATCHPOINT_ERROR(rc);
710
710
return MEMCACHED_UNKNOWN_READ_FAILURE;
713
memcached_string_set_length(&result->value, bodylen);
713
memcached_string_set_length(&result->impl()->value, bodylen);