memcache_test.c
author Tero Marttila <terom@fixme.fi>
Thu, 28 Aug 2008 01:34:14 +0300
changeset 44 03a7e064f833
parent 38 9894df13b779
child 46 8a832c0e01ee
permissions -rw-r--r--
stub functions and documentation

#include <event2/event.h>
#include <event2/event_compat.h>
#include <event2/event_struct.h>

#include "memcache.h"
#include "config.h"
#include "common.h"

static struct memcache *mc;
static struct config_endpoint server_endpoint;

int _memcache_cb (struct memcache_req *req, void *arg) {
    return 0;
}

void begin_test () {
    if ((mc = memcache_alloc(&_memcache_cb)) == NULL)
        ERROR("memcache_alloc");
    
    // fix up the endpoint
    endpoint_init(&server_endpoint, 11211);
    
    if (endpoint_parse(&server_endpoint, "localhost"))
        ERROR("config_endpoint_parse");
    
    // add the server
    if (memcache_add_server(mc, &server_endpoint, 1))
        ERROR("memcache_add_server");
   
    // add a request or two
    
    

error:
    return;
}

int main (int argc, char **argv) {
    // libevent init
    struct event_base *ev_base = event_init();

    if (!ev_base)
        FATAL("event_init");
    
    begin_test();

    // run the libevent mainloop
    if (event_base_dispatch(ev_base))
        WARNING("event_dispatch");

    INFO("SHUTDOWN");
    
    // clean up
    event_base_free(ev_base);
    
    // successfull exit
    return 0;
}