idxview.c revision 2682eeed569b446788f199e3f720616959ae6e4c
/* Copyright (c) 2007 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "array.h"
#include "str.h"
#include "hex-binary.h"
#include "file-lock.h"
#include "mail-index-private.h"
#include "mail-cache-private.h"
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
{
static char buf[64];
return buf;
}
{
unsigned int i;
printf("uid validity ............. = %u (%s)\n", hdr->uid_validity, unixdate2str(hdr->uid_validity));
if (hdr->minor_version == 0) {
} else {
}
}
{
const struct mail_index_ext *extensions;
unsigned int i, count;
if (count == 0) {
printf("no extensions\n");
return;
}
for (i = 0; i < count; i++) {
printf("-- Extension %u --\n", i);
}
}
{
const unsigned int *kw_indexes;
const char *const *keywords;
unsigned int i, count;
printf("-- Keywords --\n");
if (count == 0)
return;
for (i = 0; i < count; i++)
}
{
const char *str;
switch (type & ~MAIL_CACHE_DECISION_FORCED) {
case MAIL_CACHE_DECISION_NO:
str = "no";
break;
case MAIL_CACHE_DECISION_TEMP:
str = "tmp";
break;
case MAIL_CACHE_DECISION_YES:
str = "yes";
break;
default:
}
if ((type & MAIL_CACHE_DECISION_FORCED) != 0)
return str;
}
#define CACHE_TYPE_IS_FIXED_SIZE(type) \
((type) == MAIL_CACHE_FIELD_FIXED_SIZE || \
(type) == MAIL_CACHE_FIELD_BITMASK)
{
switch (type) {
return "fix";
return "var";
case MAIL_CACHE_FIELD_STRING:
return "str";
case MAIL_CACHE_FIELD_BITMASK:
return "bit";
case MAIL_CACHE_FIELD_HEADER:
return "hdr";
default:
}
}
{
const struct mail_cache_header *hdr;
(void)mail_cache_open_and_verify(cache);
if (MAIL_CACHE_IS_UNUSABLE(cache)) {
printf("cache is unusable\n");
return;
}
printf("field_header_offset .. = %u (0x%08x nontranslated)\n",
printf("-- Cache fields --\n");
&count);
" # Name Type Size Dec Last used\n");
for (i = 0; i < cache->file_fields_count; i++) {
else
printf(" - ");
printf("%-4s %s\n",
}
}
{
struct mail_cache_lookup_iterate_ctx iter;
const struct mail_cache_field *field;
struct mail_cache_iterate_field iter_field;
const void *data;
unsigned int size;
int ret;
printf(" - cache offset=%u size=%u, prev_offset = %u\n",
}
str_truncate(str, 0);
case MAIL_CACHE_FIELD_BITMASK:
break;
case MAIL_CACHE_FIELD_STRING:
if (size > 0)
break;
case MAIL_CACHE_FIELD_HEADER: {
int i;
for (i = 0;; i++) {
if (i == 0 && size == 0) {
/* header doesn't exist */
break;
}
size = 0;
break;
}
if (lines[i] == 0)
break;
if (i > 0)
}
if (i == 1 && size > 0 &&
size--;
if (size > 0)
break;
}
case MAIL_CACHE_FIELD_COUNT:
i_unreached();
break;
}
}
if (ret < 0)
printf(" - broken cache\n");
}
{
if ((flags & MAIL_ANSWERED) != 0)
if ((flags & MAIL_FLAGGED) != 0)
if ((flags & MAIL_DELETED) != 0)
if ((flags & MAIL_DRAFT) != 0)
return "";
}
{
const struct mail_index_record *rec;
const struct mail_index_ext *ext;
const void *data;
unsigned int i, ext_count;
bool expunged;
printf("RECORD: seq=%u, uid=%u, flags=0x%02x %s\n",
for (i = 0; i < ext_count; i++) {
continue;
str_truncate(str, 0);
}
}
}
{
struct mail_index *index;
struct mail_index_view *view;
struct mail_cache_view *cache_view;
unsigned int seq;
lib_init();
if (argc < 2)
i_fatal("Usage: idxview <index dir>");
FILE_LOCK_METHOD_FCNTL) <= 0) {
}
t_push();
t_pop();
}
return 0;
}