if (fgets (buf, sizeof (buf) - 1, ctx->fp) == NULL)
break;
+ if (SigInt == 1)
+ break;
+
if (mutt_strcmp (buf, MMDF_SEP) == 0)
{
loc = ftello (ctx->fp);
if (ctx->msgcount > oldmsgcount)
mx_update_context (ctx, ctx->msgcount - oldmsgcount);
- return (0);
+ if (SigInt == 1)
+ {
+ SigInt = 0;
+ return -2;
+ }
+
+ return 0;
}
/* Note that this function is also called when new mail is appended to the
}
loc = ftello (ctx->fp);
- while (fgets (buf, sizeof (buf), ctx->fp) != NULL)
+ while ((fgets (buf, sizeof (buf), ctx->fp) != NULL) && (SigInt != 0))
{
if (is_from (buf, return_path, sizeof (return_path), &t))
{
mx_update_context (ctx, count);
}
- return (0);
+ if (SigInt == 1)
+ {
+ SigInt = 0;
+ return -2;
+ }
+
+ return 0;
}
#undef PREV
}
}
-static void read_mesgs_query(CONTEXT *ctx, notmuch_query_t *q, int dedup)
+static bool read_mesgs_query(CONTEXT *ctx, notmuch_query_t *q, int dedup)
{
struct nm_ctxdata *data = get_ctxdata(ctx);
int limit;
notmuch_messages_t *msgs;
if (!data)
- return;
+ return false;
limit = get_limit(data);
#if LIBNOTMUCH_CHECK_VERSION(4,3,0)
if (notmuch_query_search_messages_st(q, &msgs) != NOTMUCH_STATUS_SUCCESS)
- return;
+ return false;
#else
msgs = notmuch_query_search_messages(q);
#endif
for (; notmuch_messages_valid(msgs) && ((limit == 0) || (ctx->msgcount < limit));
notmuch_messages_move_to_next(msgs))
{
+ if (SigInt == 1)
+ {
+ SigInt = 0;
+ return false;
+ }
notmuch_message_t *m = notmuch_messages_get(msgs);
append_message(ctx, q, m, dedup);
notmuch_message_destroy(m);
}
+ return true;
}
-static void read_threads_query(CONTEXT *ctx, notmuch_query_t *q, int dedup,
+static bool read_threads_query(CONTEXT *ctx, notmuch_query_t *q, int dedup,
int limit)
{
struct nm_ctxdata *data = get_ctxdata(ctx);
notmuch_threads_t *threads;
if (!data)
- return;
+ return false;
#if LIBNOTMUCH_CHECK_VERSION(4,3,0)
if (notmuch_query_search_threads_st(q, &threads) != NOTMUCH_STATUS_SUCCESS)
- return;
+ return false;
#else
threads = notmuch_query_search_threads(q);
#endif
((limit == 0) || (ctx->msgcount < limit));
notmuch_threads_move_to_next(threads))
{
+ if (SigInt == 1)
+ {
+ SigInt = 0;
+ return false;
+ }
notmuch_thread_t *thread = notmuch_threads_get(threads);
append_thread(ctx, q, thread, dedup);
notmuch_thread_destroy(thread);
}
+ return true;
}
static notmuch_message_t *get_nm_message(notmuch_database_t *db, HEADER *hdr)
q = get_query(data, false);
if (q)
{
+ rc = 0;
switch (get_query_type(data))
{
case NM_QUERY_TYPE_MESGS:
- read_mesgs_query(ctx, q, 0);
+ if (!read_mesgs_query(ctx, q, 0))
+ rc = -2;
break;
case NM_QUERY_TYPE_THREADS:
- read_threads_query(ctx, q, 0, get_limit(data));
+ if (!read_threads_query(ctx, q, 0, get_limit(data)))
+ rc = -2;
break;
}
notmuch_query_destroy(q);
- rc = 0;
}
if (!is_longrun(data))