/* Copyright (c) 2002-2018 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "ioloop.h"
#include "time-util.h"
#include "hostpid.h"
#include "maildir-storage.h"
#include "maildir-filename.h"
const char *maildir_filename_generate(void)
{
/* use secs + usecs to guarantee uniqueness within this process. */
tv = ioloop_timeval;
else {
}
}
return t_strdup_printf("%s.M%sP%s.%s",
}
{
fname += 3;
break;
}
}
if (*fname == '\0')
return FALSE;
fname++;
}
if (*fname != MAILDIR_INFO_SEP &&
*fname != MAILDIR_EXTRA_SEP &&
*fname != '\0')
return FALSE;
return TRUE;
}
/* a char* hash function from ASU -- from glib */
unsigned int maildir_filename_base_hash(const char *s)
{
unsigned int g, h = 0;
while (*s != MAILDIR_INFO_SEP && *s != '\0') {
i_assert(*s != '/');
h = (h << 4) + *s;
if ((g = h & 0xf0000000UL) != 0) {
h = h ^ (g >> 24);
h = h ^ g;
}
s++;
}
return h;
}
{
*fname1 != '\0') {
}
return 0;
}
{
int usecs = 0;
/* Assume we already read the timestamp. Next up is
".<uniqueness>.<host>". Find usecs inside the uniqueness. */
if (*fname != '.')
return FALSE;
fname++;
if (*fname++ == 'M') {
fname++;
}
return TRUE;
}
}
return FALSE;
}
{
/* sort primarily by the timestamp in file name */
if (ret == 0) {
/* sort secondarily by microseconds, if they exist */
if (ret == 0) {
/* fallback to comparing the base file name */
}
}
return ret;
}