return TRUE;
}
-static void cmd_dump_dbox(int argc ATTR_UNUSED, char *argv[])
+static void cmd_dump_dbox(const char *path, const char *const *args ATTR_UNUSED)
{
struct istream *input;
int fd;
unsigned int hdr_size;
bool ret;
- fd = open(argv[1], O_RDONLY);
+ fd = open(path, O_RDONLY);
if (fd < 0)
- i_fatal("open(%s) failed: %m", argv[1]);
+ i_fatal("open(%s) failed: %m", path);
input = i_stream_create_fd_autoclose(&fd, SIZE_MAX);
- i_stream_set_name(input, argv[1]);
+ i_stream_set_name(input, path);
hdr_size = dump_file_hdr(input);
do {
printf("\n");
return ret;
}
-static void cmd_dump_dcrypt_file(int argc ATTR_UNUSED, char *argv[])
+static void
+cmd_dump_dcrypt_file(const char *path, const char *const *args ATTR_UNUSED)
{
const char *error = NULL;
if (!dcrypt_initialize("openssl", NULL, &error))
i_fatal("dcrypt_initialize failed: %s", error);
- (void)dcrypt_file_dump_metadata(argv[1], TRUE);
+ (void)dcrypt_file_dump_metadata(path, TRUE);
}
struct doveadm_cmd_dump doveadm_cmd_dump_dcrypt_file = {
return ret;
}
-static void cmd_dump_dcrypt_key(int argc ATTR_UNUSED, char *argv[])
+static void
+cmd_dump_dcrypt_key(const char *path, const char *const *args ATTR_UNUSED)
{
const char *error = NULL;
if (!dcrypt_initialize("openssl", NULL, &error))
i_fatal("dcrypt_initialize: %s", error);
- (void)dcrypt_key_dump_metadata(argv[1], TRUE);
+ (void)dcrypt_key_dump_metadata(path, TRUE);
}
struct doveadm_cmd_dump doveadm_cmd_dump_dcrypt_key = {
return mail_index_alloc(NULL, ".", path);
}
-static void cmd_dump_index(int argc ATTR_UNUSED, char *argv[])
+static void
+cmd_dump_index(const char *path, const char *const *args)
{
struct mail_index *index;
struct mail_index_view *view;
struct mail_cache_view *cache_view;
unsigned int seq, uid = 0;
- index = path_open_index(argv[1]);
+ index = path_open_index(path);
if (index == NULL ||
mail_index_open(index, MAIL_INDEX_OPEN_FLAG_READONLY) <= 0)
- i_fatal("Couldn't open index %s", argv[1]);
- if (argv[2] != NULL) {
- if (str_to_uint(argv[2], &uid) < 0)
- i_fatal("Invalid uid number %s", argv[2]);
+ i_fatal("Couldn't open index %s", path);
+ if (args[0] != NULL) {
+ if (str_to_uint(args[0], &uid) < 0)
+ i_fatal("Invalid uid number %s", args[0]);
}
view = mail_index_view_open(index);
return 1;
}
-static void cmd_dump_log(int argc ATTR_UNUSED, char *argv[])
+static void cmd_dump_log(const char *path, const char *const *args ATTR_UNUSED)
{
struct istream *input;
uint64_t modseq;
unsigned int version;
int ret;
- input = i_stream_create_file(argv[1], SIZE_MAX);
+ input = i_stream_create_file(path, SIZE_MAX);
dump_hdr(input, &modseq, &version);
do {
T_BEGIN {
return 1;
}
-static void cmd_dump_mailboxlog(int argc ATTR_UNUSED, char *argv[])
+static void
+cmd_dump_mailboxlog(const char *path, const char *const *args ATTR_UNUSED)
{
int fd, ret;
- fd = open(argv[1], O_RDONLY);
+ fd = open(path, O_RDONLY);
if (fd < 0)
- i_fatal("open(%s) failed: %m", argv[1]);
+ i_fatal("open(%s) failed: %m", path);
do {
T_BEGIN {
return p - data;
}
-static void cmd_dump_thread(int argc ATTR_UNUSED, char *argv[])
+static void
+cmd_dump_thread(const char *path, const char *const *args ATTR_UNUSED)
{
unsigned int pos;
const void *map, *end;
uint32_t uid;
int fd, ret;
- fd = open(argv[1], O_RDONLY);
+ fd = open(path, O_RDONLY);
if (fd < 0)
- i_fatal("open(%s) failed: %m", argv[1]);
+ i_fatal("open(%s) failed: %m", path);
if (fstat(fd, &st) < 0)
- i_fatal("fstat(%s) failed: %m", argv[1]);
+ i_fatal("fstat(%s) failed: %m", path);
max_likely_index = (st.st_size / 8) * 2;
map = mmap(NULL, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
if (type == NULL)
printf("Detected file type: %s\n", dump->name);
}
- dump->cmd(argc, argv);
+ dump->cmd(argv[1], (const char *const *)argv+2);
}
struct doveadm_cmd doveadm_cmd_dump = {
- cmd_dump, "dump", "[-t <type>] <path>"
+ cmd_dump, "dump", "[-t <type>] <path> [<type-specific args>]"
};
-static void cmd_dump_multiplex(int argc ATTR_UNUSED, char *argv[])
+static void
+cmd_dump_multiplex(const char *path, const char *const *args ATTR_UNUSED)
{
const unsigned int channels_count = 256;
struct istream *file_input, *channels[channels_count];
size_t size;
unsigned int i;
- file_input = i_stream_create_file(argv[1], IO_BLOCK_SIZE);
+ file_input = i_stream_create_file(path, IO_BLOCK_SIZE);
/* A bit kludgy: istream-multiplex returns 0 if a wrong channel is
being read from. This causes a panic with blocking istreams.
Work around this by assuming that the file istream isn't blocking. */
struct doveadm_cmd_dump {
const char *name;
bool (*test)(const char *path);
- doveadm_command_t *cmd;
+ void (*cmd)(const char *path, const char *const *args);
};
extern struct doveadm_cmd_dump doveadm_cmd_dump_dbox;
}
#ifdef HAVE_ZLIB
-static void cmd_dump_imapzlib(int argc ATTR_UNUSED, char *argv[])
+static void
+cmd_dump_imapzlib(const char *path, const char *const *args ATTR_UNUSED)
{
struct istream *input, *input2;
const unsigned char *data;
const char *line;
int fd;
- fd = open(argv[1], O_RDONLY);
+ fd = open(path, O_RDONLY);
if (fd < 0)
- i_fatal("open(%s) failed: %m", argv[1]);
+ i_fatal("open(%s) failed: %m", path);
input = i_stream_create_fd_autoclose(&fd, 1024*32);
while ((line = i_stream_read_next_line(input)) != NULL) {
/* skip tag */
break;
i_stream_skip(input2, size);
}
- if (input2->stream_errno != 0) {
- i_error("read(%s) failed: %s",
- argv[1], i_stream_get_error(input));
- }
+ if (input2->stream_errno != 0)
+ i_error("read(%s) failed: %s", path, i_stream_get_error(input));
i_stream_unref(&input2);
fflush(stdout);
}
i_fatal("close() failed: %m");
}
#else
-static void cmd_dump_imapzlib(int argc ATTR_UNUSED, char *argv[] ATTR_UNUSED)
+static void
+cmd_dump_imapzlib(const char *path ATTR_UNUSED,
+ const char *const *args ATTR_UNUSED)
{
i_fatal("Dovecot compiled without zlib support");
}
void doveadm_fts_lucene_plugin_init(struct module *module);
void doveadm_fts_lucene_plugin_deinit(void);
-static void cmd_dump_fts_lucene(int argc ATTR_UNUSED, char *argv[])
+static void
+cmd_dump_fts_lucene(const char *path, const char *const *args ATTR_UNUSED)
{
struct lucene_index *index;
struct lucene_index_iter *iter;
bool first = TRUE;
i_zero(&prev_guid);
- index = lucene_index_init(argv[1], NULL, NULL);
+ index = lucene_index_init(path, NULL, NULL);
iter = lucene_index_iter_init(index);
while ((rec = lucene_index_iter_next(iter)) != NULL) {
if (memcmp(prev_guid, rec->mailbox_guid,
return 1;
}
-static void cmd_dump_fts_expunge_log(int argc ATTR_UNUSED, char *argv[])
+static void
+cmd_dump_fts_expunge_log(const char *path, const char *const *args ATTR_UNUSED)
{
buffer_t *buf;
int fd, ret;
- fd = open(argv[1], O_RDONLY);
+ fd = open(path, O_RDONLY);
if (fd < 0)
- i_fatal("open(%s) failed: %m", argv[1]);
+ i_fatal("open(%s) failed: %m", path);
buf = buffer_create_dynamic(default_pool, 1024);
do {