-static DBusHandlerResult incoming_resp(DBusConnection *connection, DBusMessage *message, struct jbus *jbus, int iserror)
+/*
+ * Parses the json-string 'msg' to create a json object stored
+ * in 'obj'. It uses the tokener of 'jbus'. This is a small
+ * improvement to avoid recreation of tokeners.
+ *
+ * Returns 1 in case of success and put the result in *'obj'.
+ * Returns 0 in case of error and put NULL in *'obj'.
+ */
+static int jparse(struct jbus *jbus, const char *msg, struct json_object **obj)
+{
+ json_tokener_reset(jbus->tokener);
+ *obj = json_tokener_parse_ex(jbus->tokener, msg, -1);
+ if (json_tokener_get_error(jbus->tokener) == json_tokener_success)
+ return 1;
+ json_object_put(*obj);
+ *obj = NULL;
+ return 0;
+}
+
+/*********************** STATIC DBUS MESSAGE HANDLING *****************/
+
+/*
+ * Handles incomming responses 'message' on 'jbus'. Response are
+ * either expected if 'iserror' == 0 or errors if 'iserror' != 0.
+ *
+ * Returns DBUS_HANDLER_RESULT_HANDLED or DBUS_HANDLER_RESULT_NOT_YET_HANDLED
+ * as defined by the dbus function 'dbus_connection_add_filter'.
+ */
+static DBusHandlerResult incoming_resp(
+ struct jbus *jbus,
+ DBusMessage * message,
+ int iserror)