{
memset(ptr, 0, sizeof(memcached_st));
}
- ptr->fd= -1;
return ptr;
}
-memcached_return memcached_increment(memcached_st *ptr, char *key, size_t key_length,
- unsigned int count)
-{
- return MEMCACHED_SUCCESS;
-}
-
-memcached_return memcached_decrement(memcached_st *ptr, char *key, size_t key_length,
- unsigned int count)
-{
- return MEMCACHED_SUCCESS;
-}
-
-memcached_return memcached_flush(memcached_st *ptr, time_t expiration)
-{
- size_t send_length;
- memcached_return rc;
- char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE];
-
- rc= memcached_connect(ptr);
-
- if (expiration)
- send_length= snprintf(buffer, MEMCACHED_DEFAULT_COMMAND_SIZE,
- "flush_all %u\r\n", expiration);
- else
- send_length= snprintf(buffer, MEMCACHED_DEFAULT_COMMAND_SIZE,
- "flush_all\r\n");
- if ((send(ptr->fd, buffer, send_length, 0) == -1))
- {
- fprintf(stderr, "failed flush_all TCP\n");
-
- return MEMCACHED_WRITE_FAILURE;
- }
-
- return memcached_response(ptr, buffer, MEMCACHED_DEFAULT_COMMAND_SIZE);
-}
-
-char *memcached_version(memcached_st *ptr, memcached_return *error)
-{
- return MEMCACHED_SUCCESS;
-}
-
-memcached_return memcached_verbosity(memcached_st *ptr, unsigned int verbosity)
-{
- return MEMCACHED_SUCCESS;
-}
-
-memcached_return memcached_quit(memcached_st *ptr)
-{
- return MEMCACHED_SUCCESS;
-}
-
void memcached_deinit(memcached_st *ptr)
{
- memcached_host_st *host_ptr;
-
- if (ptr->fd > 0)
- close(ptr->fd);
+ unsigned int x;
- for (host_ptr= ptr->hosts; host_ptr;)
+ if (ptr->hosts)
{
- memcached_host_st *temp;
+ for (x= 0; x < ptr->number_of_hosts; x++)
+ {
+ if (ptr->hosts[x].fd > 0)
+ close(ptr->hosts[x].fd);
- temp= host_ptr;
- host_ptr= host_ptr->next;
- if (temp->hostname)
- free(temp->hostname);
- free(temp);
+ free(ptr->hosts[x].hostname);
+ }
+
+ free(ptr->hosts);
}
if (ptr->is_allocated == MEMCACHED_ALLOCATED)
else
memset(ptr, 0, sizeof(memcached_st));
}
-
-char *memcached_strerror(memcached_st *ptr, memcached_return rc)
-{
- switch (rc)
- {
- case MEMCACHED_SUCCESS:
- return "SUCCESS";
- case MEMCACHED_FAILURE:
- return "FAILURE";
- case MEMCACHED_HOST_LOCKUP_FAILURE:
- return "HOSTNAME LOOKUP FAILURE";
- case MEMCACHED_CONNECTION_FAILURE:
- return "CONNECTION FAILURE";
- case MEMCACHED_CONNECTION_BIND_FAILURE:
- return "CONNECTION BIND FAILURE";
- case MEMCACHED_READ_FAILURE:
- return "READ FAILURE";
- case MEMCACHED_UNKNOWN_READ_FAILURE:
- return "UNKNOWN READ FAILURE";
- case MEMCACHED_PROTOCOL_ERROR:
- return "PROTOCOL ERROR";
- case MEMCACHED_CLIENT_ERROR:
- return "CLIENT ERROR";
- case MEMCACHED_SERVER_ERROR:
- return "SERVER ERROR";
- case MEMCACHED_WRITE_FAILURE:
- return "WRITE FAILURE";
- case MEMCACHED_CONNECTION_SOCKET_CREATE_FAILURE:
- return "CONNECTION SOCKET CREATE FAILURE";
- case MEMCACHED_DATA_EXISTS:
- return "CONNECTION DATA EXISTS";
- case MEMCACHED_DATA_DOES_NOT_EXIST:
- return "CONNECTION DATA DOES NOT EXIST";
- case MEMCACHED_NOTSTORED:
- return "NOT STORED";
- case MEMCACHED_NOTFOUND:
- return "NOT FOUND";
- case MEMCACHED_MEMORY_ALLOCATION_FAILURE:
- return "MEMORY ALLOCATION FAILURE";
- case MEMCACHED_PARTIAL_READ:
- return "PARTIAL READ";
- };
-}