diff --git a/AUTHORS b/AUTHORS new file mode 100644 index 0000000000..fc95232f5f --- /dev/null +++ b/AUTHORS @@ -0,0 +1,2 @@ +Anatoly Vorobey +Brad Fitzpatrick diff --git a/ChangeLog b/ChangeLog new file mode 100644 index 0000000000..a0767f7b71 --- /dev/null +++ b/ChangeLog @@ -0,0 +1,7 @@ +Fri, 13 Jun 2003 10:05:51 -0700 Evan Martin + + * configure.ac, autogen.sh, Makefile.am: Use autotools. + * items.c, memcached.c: #include for time(), + printf time_t as %lu (is this correct?), + minor warnings fixes. + diff --git a/Makefile b/Makefile deleted file mode 100644 index 61767dc8b5..0000000000 --- a/Makefile +++ /dev/null @@ -1,10 +0,0 @@ -all: memcached - -memcached: memcached.c slabs.c items.c memcached.h - $(CC) -I. -L. -static -o memcached memcached.c slabs.c items.c -levent -lJudy - -memcached-debug: memcached.c slabs.c items.c memcached.h - $(CC) -g -I. -L. -static -o memcached-debug memcached.c slabs.c items.c -levent -lJudy - -clean: - rm memcached memcached-debug diff --git a/Makefile.am b/Makefile.am new file mode 100644 index 0000000000..a2483b1d7a --- /dev/null +++ b/Makefile.am @@ -0,0 +1,4 @@ +bin_PROGRAMS = memcached + +memcached_SOURCES = memcached.c slabs.c items.c memcached.h + diff --git a/README b/README index 49adb5fbe5..783e53592c 100644 --- a/README +++ b/README @@ -1,7 +1,7 @@ Dependencies: - -- Judy, http://judy.sf.net/ - -- libevent, http://www.monkey.org/~provos/libevent/ + -- Judy, http://judy.sf.net/ (Debian package libjudy-dev) + -- libevent, http://www.monkey.org/~provos/libevent/ (libevent-dev) If using Linux, you need a kernel with epoll. Sure, libevent will work with normal select, but it sucks. diff --git a/autogen.sh b/autogen.sh new file mode 100755 index 0000000000..f83c8872e1 --- /dev/null +++ b/autogen.sh @@ -0,0 +1,18 @@ +#!/bin/sh + +echo "aclocal..." +ACLOCAL=${ACLOCAL:-aclocal-1.7} +$ACLOCAL || exit 1 + +echo "autoheader..." +AUTOHEADER=${AUTOHEADER:-autoheader} +$AUTOHEADER || exit 1 + +echo "automake..." +AUTOMAKE=${AUTOMAKE:-automake-1.7} +$AUTOMAKE --gnu --add-missing || exit 1 + +echo "autoconf..." +AUTOCONF=${AUTOCONF:-autoconf} +$AUTOCONF || exit 1 + diff --git a/configure.ac b/configure.ac new file mode 100644 index 0000000000..8c244249dc --- /dev/null +++ b/configure.ac @@ -0,0 +1,32 @@ +AC_PREREQ(2.52) +AC_INIT(memcached, 1.0.1, XXXzilla) +AC_CONFIG_SRCDIR(memcached.c) +AM_INIT_AUTOMAKE([dist-bzip2]) +AM_CONFIG_HEADER(config.h) + +AC_PROG_CC +AC_PROG_INSTALL + +dnl Default to building a static executable. +AC_ARG_ENABLE(static, + AC_HELP_STRING([--disable-static],[build a dynamically linked executable]), + , enable_static=yes) +AC_MSG_CHECKING(whether to build a static executable) +if test "$enable_static" = "no"; then + STATIC= + AC_MSG_RESULT(no) +else + CFLAGS="$CFLAGS -static" + AC_MSG_RESULT(yes) +fi + +JUDY_URL=http://judy.sf.net +AC_CHECK_HEADERS(Judy.h, , [AC_MSG_ERROR(libJudy is required. You can get it from $JUDY_URL.)]) +AC_CHECK_LIB(Judy, Judy1Test, , [AC_MSG_ERROR(libJudy is required. You can get it from $JUDY_URL.)]) + +LIBEVENT_URL=http://www.monkey.org/~provos/libevent/ +AC_CHECK_LIB(event, event_set, , + [AC_MSG_ERROR(libevent is required. You can get it from $LIBEVENT_URL)]) + +AC_CONFIG_FILES(Makefile) +AC_OUTPUT diff --git a/items.c b/items.c index 6cd35b94eb..77712eb1e5 100644 --- a/items.c +++ b/items.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -190,7 +191,7 @@ char *item_cachedump(unsigned int slabs_clsid, unsigned int limit, unsigned int break; if (!it) break; - sprintf(temp, "ITEM %s [%u b; %u s]\r\n", it->key, it->nbytes - 2, it->time); + sprintf(temp, "ITEM %s [%u b; %lu s]\r\n", it->key, it->nbytes - 2, it->time); len = strlen(temp); if (bufcurr + len +5 > memlimit) /* 5 is END\r\n */ break; @@ -219,7 +220,7 @@ void item_stats(char *buffer, int buflen) { for (i=0; itime); } strcpy(bufcurr, "END"); @@ -237,7 +238,6 @@ char* item_stats_sizes(int *bytes) { if (histogram) free(histogram); if (buf) free(buf); return 0; - return; } /* build the histogram */ diff --git a/memcached.c b/memcached.c index 62e361c67b..8b9aa275ca 100644 --- a/memcached.c +++ b/memcached.c @@ -15,6 +15,7 @@ * $Id$ */ +#include "config.h" #include #include #include @@ -28,7 +29,9 @@ #include #include #include +#include #include +#include #include #include #include @@ -293,7 +296,7 @@ void process_stat(conn *c, char *command) { char *pos = temp; pos += sprintf(pos, "STAT pid %u\r\n", pid); - pos += sprintf(pos, "STAT uptime %u\r\n", now - stats.started); + pos += sprintf(pos, "STAT uptime %lu\r\n", now - stats.started); pos += sprintf(pos, "STAT curr_items %u\r\n", stats.curr_items); pos += sprintf(pos, "STAT total_items %u\r\n", stats.total_items); pos += sprintf(pos, "STAT bytes %llu\r\n", stats.curr_bytes); @@ -306,7 +309,7 @@ void process_stat(conn *c, char *command) { pos += sprintf(pos, "STAT get_misses %u\r\n", stats.get_misses); pos += sprintf(pos, "STAT bytes_read %llu\r\n", stats.bytes_read); pos += sprintf(pos, "STAT bytes_written %llu\r\n", stats.bytes_written); - pos += sprintf(pos, "STAT limit_maxbytes %u\r\n", settings.maxbytes); + pos += sprintf(pos, "STAT limit_maxbytes %llu\r\n", settings.maxbytes); pos += sprintf(pos, "STAT limit_maxitems %u\r\n", settings.maxitems); pos += sprintf(pos, "END"); out_string(c, temp); @@ -447,7 +450,7 @@ void process_command(conn *c, char *command) { int len, res; item *it; - res = sscanf(command, "%s %s %u %u %d\n", s_comm, key, &flags, &expire, &len); + res = sscanf(command, "%s %s %u %lu %d\n", s_comm, key, &flags, &expire, &len); if (res!=5 || strlen(key)==0 ) { out_string(c, "CLIENT_ERROR bad command line format"); return; @@ -693,7 +696,7 @@ int try_read_network(conn *c) { int update_event(conn *c, int new_flags) { if (c->ev_flags == new_flags) - return; + return 0; if (event_del(&c->event) == -1) return 0; event_set(&c->event, c->sfd, new_flags, event_handler, (void *)c); c->ev_flags = new_flags; @@ -1061,6 +1064,7 @@ void delete_handler(int fd, short which, void *arg) { } void usage(void) { + printf(PACKAGE " " VERSION ".\n"); printf("-p port number to listen on\n"); printf("-l interface to listen on, default is INDRR_ANY\n"); printf("-s maximum number of items to store, default is unlimited\n"); @@ -1126,7 +1130,7 @@ int main (int argc, char **argv) { } } - /* initialize other stuff stuff */ + /* initialize other stuff */ item_init(); event_init(); stats_init(); @@ -1139,7 +1143,7 @@ int main (int argc, char **argv) { int res; res = daemon(0, 0); if (res == -1) { - fprintf(stderr, "failed to fork() in order to daemonize\n"); + fprintf(stderr, "failed to daemon() in order to daemonize\n"); return 1; } } @@ -1170,6 +1174,6 @@ int main (int argc, char **argv) { /* enter the loop */ event_loop(0); - return; + return 0; }