#include <tr_gss_names.h>
#include <tr_rp_client.h>
-
-/* 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)
+#include <tr_json_util.h>
static json_t *tr_rp_client_to_json(TR_RP_CLIENT *rp_client)
{
if ((jarray == NULL) || (iter == NULL))
goto cleanup;
- rp_client = tr_rp_client_iter_first(iter, rp_clients);
- while (rp_client) {
+ for (rp_client = tr_rp_client_iter_first(iter, rp_clients);
+ rp_client != NULL;
+ rp_client = tr_rp_client_iter_next(iter)) {
ARRAY_APPEND_OR_FAIL(jarray, tr_rp_client_to_json(rp_client));
- rp_client = tr_rp_client_iter_next(iter);
}
/* succeeded - set the return value and increment the reference count */