// Name of the graph
const char* graph;
+ // Name of the object
+ const char* object;
+
// Output Format
const char* format;
// Called for each argument
case ARGP_KEY_ARG:
// Take the graph name as first argument
- if (!ctx->graph) {
+ if (!ctx->graph)
ctx->graph = arg;
- return 0;
+
+ // Take the name of the object as second argument
+ else if (!ctx->object)
+ ctx->object = arg;
// Otherwise show help
- } else {
+ else
argp_usage(state);
- }
+
break;
// Called once all arguments have been parsed
if (r < 0)
goto ERROR;
- // Append the object
- r = sd_bus_message_append(m, "s", "");
- if (r < 0)
- goto ERROR;
-
// Add an array for more configuration options
r = sd_bus_message_open_container(m, 'a', "{sv}");
if (r < 0)
goto ERROR;
+ // Pass the object
+ if (ctx->object) {
+ r = sd_bus_message_append(m, "{sv}", "object", "s", ctx->object);
+ if (r < 0)
+ goto ERROR;
+ }
+
// Is available, add the desired output format
if (ctx->format) {
r = sd_bus_message_append(m, "{sv}", "format", "s", ctx->format);
size_t length = 0;
int r;
- // Parse the arguments
- r = sd_bus_message_read(m, "s", &object);
- if (r < 0)
- goto ERROR;
-
- // If an empty string has been sent, set it to NULL
- if (object && !*object)
- object = NULL;
-
// Open the options array
r = sd_bus_message_enter_container(m, SD_BUS_TYPE_ARRAY, "{sv}");
if (r < 0)
if (r < 0)
goto ERROR;
+ // Parse "object"
+ if (td_string_equals(key, "object")) {
+ r = sd_bus_message_read(m, "v", "s", &object);
+ if (r < 0)
+ goto ERROR;
+
// Parse "format"
- if (td_string_equals(key, "format")) {
+ } else if (td_string_equals(key, "format")) {
r = sd_bus_message_read(m, "v", "s", &options.format);
if (r < 0)
goto ERROR;
SD_BUS_VTABLE_START(0),
// Operations
- SD_BUS_METHOD_WITH_ARGS("Render", SD_BUS_ARGS("s", graph, "a{sv}", options), SD_BUS_RESULT("ay", graph),
+ SD_BUS_METHOD_WITH_ARGS("Render", SD_BUS_ARGS("a{sv}", options), SD_BUS_RESULT("ay", graph),
td_graph_bus_render, SD_BUS_VTABLE_UNPRIVILEGED),
SD_BUS_VTABLE_END