vector <string> method_call_wait_reply (const gchar * bus_name, const gchar * object, const gchar * interface, const gchar * method, bool silent) // This equals: dbus-send --print-reply --dest=bus_name object interface.method // It calls the method, and returns the reply. { // Assemble the method call. DBusMessage *dbus_message; dbus_message = dbus_message_new_method_call(bus_name, object, interface, method); dbus_message_set_auto_start(dbus_message, TRUE); // Send dbus_message and handle the reply. DBusError error; dbus_error_init(&error); int timeout = 10; // Timeout in milliseconds. DBusMessage *dbus_reply; dbus_reply = dbus_connection_send_with_reply_and_block(con, dbus_message, timeout, &error); if (dbus_error_is_set(&error) && !silent) { string err(error.name); err.append(": "); err.append(error.message); printf ("%s\n", err.c_str()); fflush (stdout); } if (dbus_reply) { retrieve_message(dbus_reply); dbus_message_unref(dbus_reply); } // Free the message. dbus_message_unref(dbus_message); // Return reply. vector <string> method_reply (string_reply); string_reply.clear(); return method_reply; }
int main(int argc, char **argv) { FILE *fp; char *s; int header_index=0; if((fp = fopen(argv[1], "r"))==NULL) { printf("Error while attempting to open:\n\n\t"); printf("%s\n", argv[1]); return 1; } if(skip_header(fp, &header_index)) return 1; s = retrieve_message(fp); display_message(s); free(s); fclose(fp); return 0; }