int DeviceServiceEntry(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints) { int i; char* name; char* driver_name; rdpPrinter* printer; rdpPrinter** printers; RDPDR_PRINTER* device; rdpPrinterDriver* driver = NULL; #ifdef WITH_CUPS driver = printer_cups_get_driver(); #endif #ifdef WIN32 driver = printer_win_get_driver(); #endif if (driver == NULL) { DEBUG_WARN("no driver"); return 1; } device = (RDPDR_PRINTER*) pEntryPoints->device; name = device->Name; driver_name = device->DriverName; if (name && name[0]) { printer = driver->GetPrinter(driver, name); if (printer == NULL) { DEBUG_WARN("printer %s not found.", name); return 1; } if (driver_name && driver_name[0]) printer->driver = driver_name; printer_register(pEntryPoints, printer); } else { printers = driver->EnumPrinters(driver); for (i = 0; printers[i]; i++) { printer = printers[i]; printer_register(pEntryPoints, printer); } free(printers); } return 0; }
/** * Function description * * @return 0 on success, otherwise a Win32 error code */ UINT DeviceServiceEntry(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints) { int i; char* name; char* driver_name; rdpPrinter* printer; rdpPrinter** printers; RDPDR_PRINTER* device; rdpPrinterDriver* driver = NULL; UINT error; #ifdef WITH_CUPS driver = printer_cups_get_driver(); #endif #if defined(_WIN32) && !defined(_UWP) driver = printer_win_get_driver(); #endif if (!driver) { WLog_ERR(TAG, "Could not get a printer driver!"); return CHANNEL_RC_INITIALIZATION_ERROR; } device = (RDPDR_PRINTER*) pEntryPoints->device; name = device->Name; driver_name = device->DriverName; if (name && name[0]) { printer = driver->GetPrinter(driver, name, driver_name); if (!printer) { WLog_ERR(TAG, "Could not get printer %s!", name); return CHANNEL_RC_INITIALIZATION_ERROR; } if ((error = printer_register(pEntryPoints, printer))) { WLog_ERR(TAG, "printer_register failed with error %lu!", error); return error; } } else { printers = driver->EnumPrinters(driver); for (i = 0; printers[i]; i++) { printer = printers[i]; if ((error = printer_register(pEntryPoints, printer))) { WLog_ERR(TAG, "printer_register failed with error %lu!", error); free(printers); return error; } } free(printers); } return CHANNEL_RC_OK; }