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
Sun Nov 7 19:35:39 UTC 2021


fixeria has uploaded this change for review. ( 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, 16 insertions(+), 2 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-bsc refs/changes/49/26149/1

diff --git a/src/ipaccess/ipaccess-config.c b/src/ipaccess/ipaccess-config.c
index 2d72d0e..b10959c 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,21 @@
 
 	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 print_offset(fmt, args...) \
+	fprintf(stdout, "%*s" fmt, indent * 4, "", ## args)
+#define print_field(field, fmt, args...) \
+	print_offset("\"%s\": \"" fmt "\",\n", field, ## args)
+
+	print_offset("{\n");
+	indent++;
+
+	print_field("primary_oml_ip", "%s", oml_ip);
+	print_field("primary_oml_port", "%u", oml_port);
+	print_field("unit_id", "%s", unit_id);
+
+	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: 1
Gerrit-Owner: fixeria <vyanitskiy at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20211107/5397257e/attachment.htm>


More information about the gerrit-log mailing list