Change in osmo-bsc[master]: ipaccess-config: improve readability of printed attribute response

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

fixeria gerrit-no-reply at lists.osmocom.org
Sat Nov 27 23:14:28 UTC 2021


fixeria has submitted this change. ( https://gerrit.osmocom.org/c/osmo-bsc/+/26149 )

Change subject: ipaccess-config: improve readability of printed attribute response
......................................................................

ipaccess-config: improve readability of printed attribute response

Change-Id: If99ec89081af4ebd65152fc0a31ebdec491f3876
---
M src/ipaccess/ipaccess-config.c
1 file changed, 18 insertions(+), 2 deletions(-)

Approvals:
  Jenkins Builder: Verified
  fixeria: Verified
  laforge: Looks good to me, but someone else must approve
  pespin: Looks good to me, approved



diff --git a/src/ipaccess/ipaccess-config.c b/src/ipaccess/ipaccess-config.c
index 2d72d0e..c06a7cc 100644
--- a/src/ipaccess/ipaccess-config.c
+++ b/src/ipaccess/ipaccess-config.c
@@ -281,6 +281,7 @@
 	char oml_ip[20] = {0};
 	uint16_t oml_port = 0;
 	char unit_id[40]  = {0};
+	unsigned int indent = 0;
 
 
 	abis_nm_tlv_parse(&tp, bts, foh->data, oh->length-sizeof(*foh));
@@ -290,8 +291,23 @@
 
 	abis_nm_tlv_attr_unit_id(&tp, unit_id,  sizeof(unit_id));
 
-	fprintf(stdout, "{ \"primary_oml_ip\": \"%s\", \"primary_oml_port\": %" PRIu16 ", \"unit_id\": \"%s\" }\n",
-		oml_ip, oml_port, unit_id);
+#define ENDL(last) \
+	fprintf(stdout, "%s\n", last ? "" : ",")
+#define print_offset(fmt, args...) \
+	fprintf(stdout, "%*s" fmt, indent * 4, "", ## args)
+#define print_field(field, fmt, args...) \
+	print_offset("\"%s\": \"" fmt "\"", field, ## args)
+
+	print_offset("{\n");
+	indent++;
+
+	print_field("primary_oml_ip", "%s", oml_ip); ENDL(false);
+	print_field("primary_oml_port", "%u", oml_port); ENDL(false);
+	print_field("unit_id", "%s", unit_id); ENDL(true);
+
+	indent--;
+	print_offset("}\n");
+
 	return 0;
 }
 

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-bsc/+/26149
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Change-Id: If99ec89081af4ebd65152fc0a31ebdec491f3876
Gerrit-Change-Number: 26149
Gerrit-PatchSet: 2
Gerrit-Owner: fixeria <vyanitskiy at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy at sysmocom.de>
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-Reviewer: neels <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: pespin <pespin at sysmocom.de>
Gerrit-Reviewer: roox <mardnh at gmx.de>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20211127/a87fec73/attachment.htm>


More information about the gerrit-log mailing list