From ed9cbaf412227e03cdc841d34082b44f513d85bd Mon Sep 17 00:00:00 2001 From: Stanislav Kinsbursky Date: Tue, 14 Aug 2012 14:47:03 +0400 Subject: [PATCH] protobuf: field showing routine split Will be usefull later with "pretty" show support. Signed-off-by: Stanislav Kinsbursky Signed-off-by: Pavel Emelyanov --- protobuf.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/protobuf.c b/protobuf.c index f8567180c..a48c5d1c7 100644 --- a/protobuf.c +++ b/protobuf.c @@ -296,20 +296,11 @@ static pb_pr_show_t get_pb_show_function(int type) return pb_msg_unk; } -static void pb_show_field(const ProtobufCFieldDescriptor *fd, - unsigned long nr_fields, pb_pr_ctl_t *ctl) +static void pb_show_repeated(pb_pr_ctl_t *ctl, int nr_fields, pb_pr_show_t show, + size_t fsize) { - pb_pr_show_t show; pb_pr_field_t *field = &ctl->cur; unsigned long counter; - size_t fsize; - - print_tabs(ctl); - - pr_msg("%s: ", fd->name); - - fsize = pb_show_prepare_field_context(fd, ctl); - show = get_pb_show_function(fd->type); show(field->data, ctl); field->data += fsize; @@ -318,6 +309,19 @@ static void pb_show_field(const ProtobufCFieldDescriptor *fd, pr_msg(":"); show(field->data, ctl); } +} + +static void pb_show_field(const ProtobufCFieldDescriptor *fd, + int nr_fields, pb_pr_ctl_t *ctl) +{ + pb_pr_show_t show; + + print_tabs(ctl); + pr_msg("%s: ", fd->name); + + show = get_pb_show_function(fd->type); + + pb_show_repeated(ctl, nr_fields, show, pb_show_prepare_field_context(fd, ctl)); if (ctl->single_entry) pr_msg("\n");