#include <tr_idp.h>
#include <tr_config.h>
#include <tr_debug.h>
+#include <tr_json_util.h>
static char *tr_aaa_server_to_str(TALLOC_CTX *mem_ctx, TR_AAA_SERVER *aaa)
{
}
-/* helper for below */
-#define OBJECT_SET_OR_FAIL(jobj, key, val) \
-do { \
- if (val) \
- json_object_set_new((jobj),(key),(val)); \
- else \
- goto cleanup; \
-} while (0)
-
-#define ARRAY_APPEND_OR_FAIL(jary, val) \
-do { \
- if (val) \
- json_array_append_new((jary),(val)); \
- else \
- goto cleanup; \
-} while (0)
-
static json_t *tr_apcs_to_json(TR_APC *apcs)
{
json_t *jarray = json_array();
if ((jarray == NULL) || (iter == NULL))
goto cleanup;
- apc = tr_apc_iter_first(iter, apcs);
- while (apc) {
+ for (apc = tr_apc_iter_first(iter, apcs);
+ apc != NULL;
+ apc = tr_apc_iter_next(iter)) {
ARRAY_APPEND_OR_FAIL(jarray, tr_name_to_json_string(tr_apc_get_id(apc)));
- apc = tr_apc_iter_next(iter);
}
/* success */
if ((jarray == NULL) || (iter == NULL))
goto cleanup;
- aaa = tr_aaa_server_iter_first(iter, aaas);
- while (aaa) {
+ for (aaa = tr_aaa_server_iter_first(iter, aaas);
+ aaa != NULL;
+ aaa = tr_aaa_server_iter_next(iter)) {
ARRAY_APPEND_OR_FAIL(jarray, tr_aaa_server_to_json(aaa));
- aaa = tr_aaa_server_iter_next(iter);
}
/* success */