<commit_before>/* Copyright (c) 2010-2014 Dovecot authors, see the included COPYING file */

#include "lib.h"
#include "mail-storage.h"
#include "doveadm-print.h"
#include "doveadm-mailbox-list-iter.h"
#include "doveadm-mail-iter.h"
#include "doveadm-mail.h"

#include <stdio.h>

static int
cmd_search_box(struct doveadm_mail_cmd_context *ctx,
	       const struct mailbox_info *info)
{
	struct doveadm_mail_iter *iter;
	struct mailbox *box;
	struct mail *mail;
	struct mailbox_metadata metadata;
	const char *guid_str;
	int ret = 0;

	if (doveadm_mail_iter_init(ctx, info, ctx->search_args, 0, NULL,
				   &iter) < 0)
		return -1;
	box = doveadm_mail_iter_get_mailbox(iter);

	if (mailbox_get_metadata(box, MAILBOX_METADATA_GUID, &metadata) < 0) {
		ret = -1;
		doveadm_mail_failed_mailbox(ctx, box);
	} else {
		guid_str = guid_128_to_string(metadata.guid);
		while (doveadm_mail_iter_next(iter, &mail)) {
			doveadm_print(guid_str);
			T_BEGIN {
				doveadm_print(dec2str(mail->uid));
			} T_END;
		}
	}
	if (doveadm_mail_iter_deinit(&iter) < 0)<commit_msg>doveadm search: If mailbox GUID lookup fails, print an error.<commit_after>/* Copyright (c) 2010-2014 Dovecot authors, see the included COPYING file */

#include "lib.h"
#include "mail-storage.h"
#include "doveadm-print.h"
#include "doveadm-mailbox-list-iter.h"
#include "doveadm-mail-iter.h"
#include "doveadm-mail.h"

#include <stdio.h>

static int
cmd_search_box(struct doveadm_mail_cmd_context *ctx,
	       const struct mailbox_info *info)
{
	struct doveadm_mail_iter *iter;
	struct mailbox *box;
	struct mail *mail;
	struct mailbox_metadata metadata;
	const char *guid_str;
	int ret = 0;

	if (doveadm_mail_iter_init(ctx, info, ctx->search_args, 0, NULL,
				   &iter) < 0)
		return -1;
	box = doveadm_mail_iter_get_mailbox(iter);

	if (mailbox_get_metadata(box, MAILBOX_METADATA_GUID, &metadata) < 0) {
		i_error("Couldn't get mailbox '%s' GUID: %s",
			mailbox_get_vname(box),
			mailbox_get_last_error(box, NULL));
		ret = -1;
		doveadm_mail_failed_mailbox(ctx, box);
	} else {
		guid_str = guid_128_to_string(metadata.guid);
		while (doveadm_mail_iter_next(iter, &mail)) {
			doveadm_print(guid_str);
			T_BEGIN {
				doveadm_print(dec2str(mail->uid));
			} T_END;
		}
	}
	if (doveadm_mail_iter_deinit(&iter) < 0)
{'fraction_non_alphanumeric': 0.1265323992994746, 'fraction_numerical': 0.016637478108581436, 'mean_word_length': 4.829081632653061, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2211322', 'n_tokens_mistral': 1023, 'n_tokens_neox': 910, 'n_words': 189}