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 <[email protected]>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <[email protected]>
Gerrit-Reviewer: laforge <[email protected]>
Gerrit-Reviewer: neels <[email protected]>
Gerrit-Reviewer: pespin <[email protected]>
Gerrit-Reviewer: roox <[email protected]>
Gerrit-MessageType: merged

Reply via email to