#include <sys/types.h>
#include <unistd.h>
+#include "agedu.h"
#include "malloc.h"
#include "trie.h"
#define alignof(typ) ( offsetof(struct { char c; typ t; }, t) )
-extern char pathsep;
-
/*
* Compare functions for pathnames. Returns the relative order of
* the names, like strcmp; also passes back the offset of the
{
tb->offset = off;
if (lseek(tb->fd, off, SEEK_SET) < 0) {
- fprintf(stderr, "agedu: lseek: %s\n", strerror(errno));
+ fprintf(stderr, PNAME ": lseek: %s\n", strerror(errno));
exit(1);
}
}
while (len > 0) {
int ret = write(tb->fd, buf, len);
if (ret < 0) {
- fprintf(stderr, "agedu: write: %s\n", strerror(errno));
+ fprintf(stderr, PNAME ": write: %s\n", strerror(errno));
exit(1);
}
len -= ret;
{
return ((const struct trie_header *)t)->indexroot;
}
+
+void make_successor(char *pathbuf)
+{
+ int len = strlen(pathbuf);
+ if (len > 0 && pathbuf[len-1] == pathsep)
+ len--;
+ pathbuf[len] = '\001';
+ pathbuf[len+1] = '\0';
+}