/*
Copyright 2015 IoT.bzh
+ author: José Bollo <jose.bollo@iot.bzh>
+
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
return 0;
-error3:
- free(srv->method);
error2:
free(srv);
error:
return 0;
case DBUS_REQUEST_NAME_REPLY_EXISTS:
case DBUS_REQUEST_NAME_REPLY_IN_QUEUE:
+ default:
errno = EADDRINUSE;
return -1;
}
}
+int jbus_read_write_dispatch(struct jbus *jbus, int toms)
+{
+ if (dbus_connection_read_write_dispatch(jbus->connection, toms));
+ return 0;
+ errno = EPIPE;
+ return -1;
+}
+
int jbus_callj(struct jbus *jbus, const char *method, const char *query, void (*onresp)(int status, struct json_object *response, void *data), void *data)
{
- int rc;
DBusMessage *msg;
struct jrespw *resp;
int s2 = jbus_add_service(jbus, "incr", incr);
int s3 = jbus_start_serving(jbus);
printf("started %d %d %d\n", s1, s2, s3);
- while (dbus_connection_read_write_dispatch (jbus->connection, -1))
+ while (!jbus_read_write_dispatch (jbus, -1))
;
}
#endif
while(i--) {
jbus_callj(jbus, "ping", "{\"toto\":[1,2,3,4,true,\"toto\"]}", onresp, "ping");
jbus_callj(jbus, "incr", "{\"doit\":\"for-me\"}", onresp, "incr");
- dbus_connection_read_write_dispatch (jbus->connection, 1);
+ jbus_read_write_dispatch (jbus, 1);
}
- while (dbus_connection_read_write_dispatch (jbus->connection, -1))
+ while (!jbus_read_write_dispatch (jbus, -1))
;
}
#endif