ALLOBJS := $(patsubst %,%.o,$(ALLMODULES))
ALLDEPS := $(patsubst %,%.d,$(ALLMODULES))
-binaries: agedu
+BINARIES = agedu
-agedu: $(AGEDU_OBJS)
+binaries: $(BINARIES)
+
+agedu: config.h $(AGEDU_OBJS)
gcc $(LFLAGS) -o agedu $(AGEDU_OBJS)
+config.h: configure
+ ./configure
+ rm -f Makefile # we keep using _this_ Makefile
+
+configure: configure.ac
+ aclocal
+ autoconf
+ autoheader
+ automake -a --foreign
+
INTERNALFLAGS=#
$(ALLOBJS): %.o: %.c
halibut --man=$*.1 $*.but
clean:
- rm -f agedu $(ALLOBJS) $(ALLDEPS)
+ rm -f $(ALLOBJS) $(ALLDEPS) $(MANPAGES) $(BINARIES)
+
+spotless: clean
+ rm -f config.h config.h.in config.log config.status configure
+ rm -f depcomp install-sh missing stamp-h1
+ rm -f Makefile.in aclocal.m4
+ rm -rf autom4te.cache .deps
-include $(ALLDEPS)
TODO list for agedu
===================
-Future possibilities:
+ - adjust the default web server address selection.
+ + some systems (e.g. OS X) don't like us binding to random
+ localhost addresses. So if that fails, try falling back to
+ 127.0.0.1 proper (and a randomly selected port) before giving
+ up.
+ + since binding to port 80 isn't generally feasible, we should
+ adjust the default behaviour when the user specifies --addr
+ with no port: it should select port zero, and then print the
+ port number on standard output. (Possibly also print the URL
+ as usual, in that situation: translate INADDR_ANY to
+ INADDR_LOOPBACK and then do the same as when we made the
+ entire address up ourself.)
- - integrate more usefully with the output of configure. It's
- generating oodles of automatic boilerplate in config.h and I'm
- sure three quarters of it _ought_ to be usable to add
- portability, if only I had the gumption to actually pay attention
- to all those HAVE_FOO macros it's defined for me.
+ - we should munmap in all operating modes where we mmapped,
+ otherwise chaining them will run out of address space
+
+ - we could still be using more of the information coming from
+ autoconf. Our config.h is defining a whole bunch of HAVE_FOOs for
+ particular functions (e.g. HAVE_INET_NTOA, HAVE_MEMCHR,
+ HAVE_FNMATCH). We could usefully supply alternatives for some of
+ these functions (e.g. cannibalise the PuTTY wildcard matcher for
+ use in the absence of fnmatch, switch to vanilla truncate() in
+ the absence of ftruncate); where we don't have alternative code,
+ it would perhaps be polite to throw an error at configure time
+ rather than allowing the subsequent build to fail.
+ + however, I don't see anything here that looks very
+ controversial; IIRC it's all in POSIX, for one thing. So more
+ likely this should simply wait until somebody complains.
+
+ - it would be useful to support a choice of indexing strategies.
+ The current system's tradeoff of taking O(N log N) space in order
+ to be able to support any age cutoff you like is not going to be
+ ideal for everybody. A second more conventional mechanism which
+ allows the user to specify a number of fixed cutoffs and just
+ indexes each directory on those alone would undoubtedly be a
+ useful thing for large-scale users. This will require
+ considerable thought about how to make the indexers pluggable at
+ both index-generation time and query time.
- IPv6 support in the HTTP server
* of course, Linux magic auth can still work in this context; we
* Main program for agedu.
*/
-#define _GNU_SOURCE
-#include <stdio.h>
-#include <errno.h>
-#include <stdarg.h>
-#include <stdlib.h>
-#include <stdint.h>
-#include <string.h>
-#include <time.h>
-#include <assert.h>
-
-#include <unistd.h>
-#include <sys/types.h>
-#include <fcntl.h>
-#include <sys/mman.h>
-#include <termios.h>
-#include <sys/ioctl.h>
-#include <fnmatch.h>
-
#include "agedu.h"
+
#include "du.h"
#include "trie.h"
#include "index.h"
return 1;
}
- printf("Built pathname index, %d entries, %ju bytes\n", count,
- (intmax_t)st.st_size);
+ printf("Built pathname index, %d entries, %llu bytes\n", count,
+ (unsigned long long)st.st_size);
totalsize = index_compute_size(st.st_size, count);
return 1;
}
- printf("Upper bound on index file size = %ju bytes\n",
- (intmax_t)totalsize);
+ printf("Upper bound on index file size = %llu bytes\n",
+ (unsigned long long)totalsize);
mappedfile = mmap(NULL, totalsize, PROT_READ|PROT_WRITE,MAP_SHARED, fd, 0);
if (!mappedfile) {
munmap(mappedfile, totalsize);
ftruncate(fd, realsize);
close(fd);
- printf("Actual index file size = %ju bytes\n", (intmax_t)realsize);
+ printf("Actual index file size = %llu bytes\n",
+ (unsigned long long)realsize);
}
} else if (mode == TEXT) {
char *querydir = actions[action].arg;
#include "config.h"
+#ifdef HAVE_FEATURES_H
+#define _GNU_SOURCE
+#include <features.h>
+#endif
+
+#ifdef HAVE_STDIO_H
+# include <stdio.h>
+#endif
+#ifdef HAVE_ERRNO_H
+# include <errno.h>
+#endif
+#ifdef HAVE_TIME_H
+# include <time.h>
+#endif
+#ifdef HAVE_ASSERT_H
+# include <assert.h>
+#endif
+#ifdef HAVE_STRING_H
+# include <string.h>
+#endif
+#ifdef HAVE_STDLIB_H
+# include <stdlib.h>
+#endif
+#ifdef HAVE_STDARG_H
+# include <stdarg.h>
+#endif
+#ifdef HAVE_STDINT_H
+# include <stdint.h>
+#endif
+#ifdef HAVE_STDDEF_H
+# include <stddef.h>
+#endif
+#ifdef HAVE_LIMITS_H
+# include <limits.h>
+#endif
+#ifdef HAVE_CTYPE_H
+# include <ctype.h>
+#endif
+
+#ifdef HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+#ifdef HAVE_SYS_STAT_H
+# include <sys/stat.h>
+#endif
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
+#ifdef HAVE_FCNTL_H
+# include <fcntl.h>
+#endif
+#ifdef HAVE_SYS_MMAN_H
+# include <sys/mman.h>
+#endif
+#ifdef HAVE_TERMIOS_H
+# include <termios.h>
+#endif
+#ifdef HAVE_SYS_IOCTL_H
+# include <sys/ioctl.h>
+#endif
+#ifdef HAVE_FNMATCH_H
+# include <fnmatch.h>
+#endif
+#ifdef HAVE_PWD_H
+# include <pwd.h>
+#endif
+#ifdef HAVE_SYS_WAIT_H
+# include <sys/wait.h>
+#endif
+#ifdef HAVE_SYS_SOCKET_H
+# include <sys/socket.h>
+#endif
+#ifdef HAVE_ARPA_INET_H
+# include <arpa/inet.h>
+#endif
+#ifdef HAVE_NETINET_IN_H
+# include <netinet/in.h>
+#endif
+#ifdef HAVE_SYSLOG_H
+# include <syslog.h>
+#endif
+#ifdef HAVE_SYS_SELECT_H
+# include <sys/select.h>
+#endif
+
#define PNAME "agedu"
#define DUMPHDR "agedu dump file. pathsep="
* alloc.c: implementation of alloc.h
*/
-#include <stdlib.h>
-#include <string.h>
-#include <stdarg.h>
-#include <time.h>
-#include <assert.h>
-#include <stdio.h>
-
#include "agedu.h"
#include "alloc.h"
+++ /dev/null
-/*
- * config.h: stub version of the autoconf-generated config.h, to
- * stop the #include in agedu.h from failing when run from the
- * master source directory instead of from the unpacked contents
- * of the autotoolsified tarball.
- *
- * This version of config.h hardwires some parameters that match
- * the sorts of systems I tend to be building on. A nasty hack and
- * a self-centred one, but autotools is so icky that I can't quite
- * bring myself to inflict it on my main development directory,
- * and am instead keeping it at arm's length in the distribution
- * tarballs. Sorry about that.
- */
-
-#define HAVE_LSTAT64
-#define HAVE_FEATURES_H
-# autoconf input for agedu.
+# autoconf input for agedu. -*- sh -*-
AC_INIT([agedu], [6.66], [anakin@pobox.com])
AC_CONFIG_SRCDIR([agedu.c])
AC_HEADER_DIRENT
AC_HEADER_STDC
AC_HEADER_SYS_WAIT
-AC_CHECK_HEADERS([arpa/inet.h fcntl.h features.h limits.h netinet/in.h stddef.h stdint.h stdlib.h string.h sys/ioctl.h sys/socket.h syslog.h termios.h unistd.h])
+AC_CHECK_HEADERS([assert.h arpa/inet.h ctype.h errno.h fcntl.h features.h fnmatch.h limits.h netinet/in.h pwd.h stdarg.h stddef.h stdint.h stdio.h stdlib.h string.h sys/ioctl.h sys/mman.h sys/socket.h syslog.h termios.h time.h unistd.h])
# Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_FUNC_VPRINTF
AC_CHECK_FUNCS([ftruncate fdopendir inet_ntoa lstat64 memchr munmap select socket strcasecmp strchr strcspn strerror strrchr strspn strtoul strtoull])
+AC_SEARCH_LIBS(connect, socket nsl)
+# AC_SEARCH_LIBS(gethostbyname, socket nsl resolv)
+
AC_CONFIG_FILES([Makefile])
AC_OUTPUT
* du.c: implementation of du.h.
*/
-#include "agedu.h" /* for config.h */
-
-#ifdef HAVE_FEATURES_H
-#define _GNU_SOURCE
-#include <features.h>
-#endif
-
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <errno.h>
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <unistd.h>
-
+#include "agedu.h"
#include "du.h"
#include "alloc.h"
#if !defined __linux__ || defined HAVE_FDOPENDIR
+#ifdef HAVE_DIRENT_H
+# include <dirent.h>
+#endif
+#ifdef HAVE_NDIR_H
+# include <ndir.h>
+#endif
+#ifdef HAVE_SYS_DIR_H
+# include <sys/dir.h>
+#endif
+#ifdef HAVE_SYS_NDIR_H
+# include <sys/ndir.h>
+#endif
+
/*
* Wrappers around POSIX opendir, readdir and closedir, which
* permit me to replace them with different wrappers in special
* circumstances.
*/
-#include <dirent.h>
typedef DIR *dirhandle;
int open_dir(const char *path, dirhandle *dh)
*/
#define __KERNEL__
-#include <unistd.h>
-#include <fcntl.h>
#include <linux/types.h>
#include <linux/dirent.h>
#include <linux/unistd.h>
* fgetline.c: implementation of fgetline.h.
*/
-#include <stdio.h>
-#include <string.h>
-
+#include "agedu.h"
#include "alloc.h"
#include "fgetline.h"
* html.c: implementation of html.h.
*/
-#include <assert.h>
-#include <stddef.h>
-#include <string.h>
-#include <stdarg.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <limits.h>
-#include <time.h>
-
#include "agedu.h"
#include "html.h"
#include "alloc.h"
{
va_list ap2;
int size, size2;
+ char testbuf[2];
va_copy(ap2, ap);
- size = vsnprintf(NULL, 0, fmt, ap2);
+ /*
+ * Some C libraries (Solaris, I'm looking at you) don't like
+ * an output buffer size of zero in vsnprintf, but will return
+ * sensible values given any non-zero buffer size. Hence, we
+ * use testbuf to gauge the length of the string.
+ */
+ size = vsnprintf(testbuf, 1, fmt, ap2);
va_end(ap2);
if (ctx->buflen + size >= ctx->bufsize) {
* httpd.c: implementation of httpd.h.
*/
-#define _GNU_SOURCE
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <errno.h>
-#include <assert.h>
-#include <unistd.h>
-#include <pwd.h>
-#include <ctype.h>
-#include <sys/types.h>
-#include <sys/wait.h>
-#include <fcntl.h>
-#include <sys/socket.h>
-#include <arpa/inet.h>
-#include <netinet/in.h>
-#include <syslog.h>
-
#include "agedu.h"
#include "alloc.h"
#include "html.h"
*/
while (1) {
fd_set rfds, wfds;
- int i, j, maxfd, ret;
+ int i, j;
+ SELECT_TYPE_ARG1 maxfd;
+ int ret;
#define FD_SET_MAX(fd, set, max) \
do { FD_SET((fd),(set)); (max) = ((max)<=(fd)?(fd)+1:(max)); } while(0)
}
nfds = i;
- ret = select(maxfd, &rfds, &wfds, NULL, NULL);
+ ret = select(maxfd, SELECT_TYPE_ARG234 &rfds,
+ SELECT_TYPE_ARG234 &wfds, SELECT_TYPE_ARG234 NULL,
+ SELECT_TYPE_ARG5 NULL);
if (ret <= 0) {
if (ret < 0 && (errno != EINTR)) {
fprintf(stderr, "select: %s", strerror(errno));
* index.c: Implementation of index.h.
*/
-#include <assert.h>
-#include <stdio.h>
-#include <stddef.h>
-
+#include "agedu.h"
#include "trie.h"
#include "index.h"
#include "alloc.h"
* trie.c: implementation of trie.h.
*/
-#include <assert.h>
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <errno.h>
-
-#include <sys/types.h>
-#include <unistd.h>
-
#include "agedu.h"
#include "alloc.h"
#include "trie.h"