diff -Nur -x '*.orig' -x '*~' bluez-4.48/cups/main.c bluez-4.48.new/cups/main.c --- bluez-4.48/cups/main.c 2009-08-16 20:43:34.000000000 +0200 +++ bluez-4.48.new/cups/main.c 2009-08-26 19:05:31.000000000 +0200 @@ -185,6 +185,27 @@ return id; } +static void print_printer_details(const char *name, const char *bdaddr, const char *id) +{ + char *uri, *escaped; + + escaped = g_strdelimit(g_strdup(name), "\"", '\''); + uri = g_strdup_printf("bluetooth://%c%c%c%c%c%c%c%c%c%c%c%c", + bdaddr[0], bdaddr[1], + bdaddr[3], bdaddr[4], + bdaddr[6], bdaddr[7], + bdaddr[9], bdaddr[10], + bdaddr[12], bdaddr[13], + bdaddr[15], bdaddr[16]); + printf("direct %s \"%s\" \"%s (Bluetooth)\"", uri, escaped, escaped); + if (id != NULL) + printf(" \"%s\"\n", id); + else + printf("\n"); + g_free(escaped); + g_free(uri); +} + static void add_device_to_list(const char *name, const char *bdaddr, const char *id) { struct cups_device *device; @@ -212,27 +233,7 @@ device->id = g_strdup(id); device_list = g_slist_prepend(device_list, device); -} - -static void print_printer_details(const char *name, const char *bdaddr, const char *id) -{ - char *uri, *escaped; - - escaped = g_strdelimit(g_strdup(name), "\"", '\''); - uri = g_strdup_printf("bluetooth://%c%c%c%c%c%c%c%c%c%c%c%c", - bdaddr[0], bdaddr[1], - bdaddr[3], bdaddr[4], - bdaddr[6], bdaddr[7], - bdaddr[9], bdaddr[10], - bdaddr[12], bdaddr[13], - bdaddr[15], bdaddr[16]); - printf("direct %s \"%s\" \"%s (Bluetooth)\"", uri, escaped, escaped); - if (id != NULL) - printf(" \"%s\"\n", id); - else - printf("\n"); - g_free(escaped); - g_free(uri); + print_printer_details(device->name, device->bdaddr, device->id); } static gboolean parse_device_properties(DBusMessageIter *reply_iter, char **name, char **bdaddr) @@ -384,23 +385,6 @@ static void discovery_completed(void) { - GSList *l; - - for (l = device_list; l != NULL; l = l->next) { - struct cups_device *device = (struct cups_device *) l->data; - - if (device->name == NULL) - device->name = g_strdelimit(g_strdup(device->bdaddr), ":", '-'); - /* Give another try to getting an ID for the device */ - if (device->id == NULL) - remote_device_found(NULL, device->bdaddr, device->name); - print_printer_details(device->name, device->bdaddr, device->id); - g_free(device->name); - g_free(device->bdaddr); - g_free(device->id); - g_free(device); - } - g_slist_free(device_list); device_list = NULL; @@ -638,6 +622,9 @@ /* Make sure status messages are not buffered */ setbuf(stderr, NULL); + /* Make sure output is not buffered */ + setbuf(stdout, NULL); + /* Ignore SIGPIPE signals */ #ifdef HAVE_SIGSET sigset(SIGPIPE, SIG_IGN);