#include #include "log.h" #include "queuefn.h" #include "fmt.h" #define AUTOSPLIT 23 /* the compiler should optimize this away */ inline unsigned int ilog10(const unsigned int v) { unsigned int i = 1; unsigned int j; for (j = v; j > 10; j /= 10) i++; return i; } size_t queuefn(char *buf, const size_t buflen, const char *dir, const unsigned int inode) { size_t pos = strlen(dir); if (pos + 4 + ilog10(AUTOSPLIT) >= buflen) return 0; memcpy(buf, dir, pos); buf[pos++] = '/'; ultostr(inode % AUTOSPLIT, buf + pos); pos += ilog10(AUTOSPLIT); buf[pos++] = '/'; // FIXME: length check ultostr(inode, buf + pos); return strlen(buf); }