Many fixes to the POD documentation
[awesomized/libmemcached] / lib / memcached.c
index 66a96f043325e1ba40a8707b2bc471d7a8ac088d..0bab79580661fc79781e7286d54389e224a8e3b3 100644 (file)
@@ -1,9 +1,9 @@
 /*
   Memcached library
 */
-#include <memcached.h>
+#include "common.h"
 
-memcached_st *memcached_init(memcached_st *ptr)
+memcached_st *memcached_create(memcached_st *ptr)
 {
   if (!ptr)
   {
@@ -23,89 +23,13 @@ memcached_st *memcached_init(memcached_st *ptr)
   return ptr;
 }
 
-memcached_return memcached_increment(memcached_st *ptr, char *key, size_t key_length,
-                                     unsigned int count)
+void memcached_free(memcached_st *ptr)
 {
-  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->hosts[0].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);
-}
-
-memcached_return memcached_verbosity(memcached_st *ptr, unsigned int verbosity)
-{
-  size_t send_length;
-  memcached_return rc;
-  char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE];
-
-  rc= memcached_connect(ptr);
-
-  send_length= snprintf(buffer, MEMCACHED_DEFAULT_COMMAND_SIZE, 
-                        "verbosity %u\r\n", verbosity);
-
-  if ((send(ptr->hosts[0].fd, buffer, send_length, 0) == -1))
-  {
-    fprintf(stderr, "failed verbosity\n");
-
-    return MEMCACHED_WRITE_FAILURE;
-  }
-
-  return memcached_response(ptr, buffer, MEMCACHED_DEFAULT_COMMAND_SIZE);
-}
-
-/*
-  When this is implemented you will be able to remove single hosts
-  from your current pool of hosts.
-*/
-memcached_return memcached_quit(memcached_st *ptr, char *hostname, unsigned port)
-{
-  return MEMCACHED_SUCCESS;
-}
-
-void memcached_deinit(memcached_st *ptr)
-{
-  unsigned int x;
-  memcached_host_st *host_ptr;
-
   if (ptr->hosts)
   {
-    for (x= 0; x < ptr->number_of_hosts; x++)
-    {
-      if (ptr->hosts[x].fd > 0)
-        close(ptr->hosts[x].fd);
-
-      if (ptr->hosts[x].hostname)
-        free(ptr->hosts[x].hostname);
-    }
-
-    free(ptr->hosts);
+    memcached_quit(ptr);
+    memcached_server_list_free(ptr->hosts);
+    ptr->hosts= NULL;
   }
 
   if (ptr->is_allocated == MEMCACHED_ALLOCATED)
@@ -113,46 +37,3 @@ void memcached_deinit(memcached_st *ptr)
   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";
-  };
-}