Mercurial > dovecot > core-2.2
view src/lib-mail/message-part.c @ 18137:3009a1a6f6d5
global: freshen copyright
Robomatically:
git ls-files | xargs perl -p -i -e 's/(\d+)-201[0-4]/$1-2015/g;s/ (201[0-4]) Dovecot/ $1-2015 Dovecot/'
Happy 2015 everyone!
Signed-off-by: Phil Carmody <phil@dovecot.fi>
author | Phil Carmody <phil@dovecot.fi> |
---|---|
date | Mon, 05 Jan 2015 22:20:10 +0200 |
parents | 7c12201decaf |
children | 012a355f9f8a |
line wrap: on
line source
/* Copyright (c) 2014-2015 Dovecot authors, see the included COPYING file */ #include "lib.h" #include "message-part.h" unsigned int message_part_to_idx(const struct message_part *part) { const struct message_part *p; unsigned int n; if (part->parent == NULL) { /* root */ return 0; } for (n = 0, p = part->parent->children; p != part; p = p->next, n++) ; return n + 1 + message_part_to_idx(part->parent); } static struct message_part * message_sub_part_by_idx(struct message_part *parts, unsigned int idx) { struct message_part *part = parts; for (; part != NULL && idx > 0; part = part->next) { if (part->children_count >= idx) return message_sub_part_by_idx(part->children, idx-1); idx -= part->children_count + 1; } return part; } struct message_part * message_part_by_idx(struct message_part *parts, unsigned int idx) { i_assert(parts->parent == NULL); return message_sub_part_by_idx(parts, idx); }