From b1d38e7ab3402e66bedc43dfd9d2fb7e41074511 Mon Sep 17 00:00:00 2001 From: Daniel Golle Date: Sun, 15 Aug 2021 02:14:20 +0100 Subject: [PATCH] auc: update to version 0.2.0 * support for ASU server post commit aparcar/asu@bac6de18 Signed-off-by: Daniel Golle --- utils/auc/Makefile | 2 +- utils/auc/src/auc.c | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/utils/auc/Makefile b/utils/auc/Makefile index c7badf71f..c8f1d9187 100644 --- a/utils/auc/Makefile +++ b/utils/auc/Makefile @@ -5,7 +5,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=auc -PKG_VERSION:=0.1.9 +PKG_VERSION:=0.2.0 PKG_RELEASE:=$(AUTORELEASE) PKG_LICENSE:=GPL-3.0 diff --git a/utils/auc/src/auc.c b/utils/auc/src/auc.c index 00d813b05..8e8ac14f0 100644 --- a/utils/auc/src/auc.c +++ b/utils/auc/src/auc.c @@ -1202,6 +1202,7 @@ static int request_branches(bool only_active) struct blob_attr *tb[__REPLY_MAX]; int rem; char url[256]; + struct blob_attr *data; blobmsg_buf_init(&brbuf); snprintf(url, sizeof(url), "%s/%s/%s%s", serverurl, API_JSON, @@ -1214,10 +1215,16 @@ static int request_branches(bool only_active) blobmsg_parse(reply_policy, __REPLY_MAX, tb, blob_data(brbuf.head), blob_len(brbuf.head)); - if (!tb[REPLY_ARRAY]) + /* newer server API replies OBJECT, older API replies ARRAY... */ + if ((!tb[REPLY_ARRAY] && !tb[REPLY_OBJECT])) return -ENODATA; - blobmsg_for_each_attr(cur, tb[REPLY_ARRAY], rem) + if (tb[REPLY_OBJECT]) + data = tb[REPLY_OBJECT]; + else + data = tb[REPLY_ARRAY]; + + blobmsg_for_each_attr(cur, data, rem) process_branch(cur, only_active); blob_buf_free(&brbuf);