mirror of
https://github.com/morgan9e/FreeRDP
synced 2026-04-15 00:44:19 +09:00
[c23,channels] replace NULL with nullptr
This commit is contained in:
@@ -54,7 +54,7 @@ static bool is_mac_os_sonoma_or_later(void)
|
||||
size_t size = sizeof(str);
|
||||
|
||||
errno = 0;
|
||||
int ret = sysctlbyname("kern.osrelease", str, &size, NULL, 0);
|
||||
int ret = sysctlbyname("kern.osrelease", str, &size, nullptr, 0);
|
||||
if (ret != 0)
|
||||
{
|
||||
char buffer[256] = WINPR_C_ARRAY_INIT;
|
||||
@@ -108,10 +108,10 @@ WINPR_ATTR_MALLOC(free, 1)
|
||||
static char* printer_cups_get_printjob_name(size_t id)
|
||||
{
|
||||
struct tm tres = WINPR_C_ARRAY_INIT;
|
||||
const time_t tt = time(NULL);
|
||||
const time_t tt = time(nullptr);
|
||||
const struct tm* t = localtime_r(&tt, &tres);
|
||||
|
||||
char* str = NULL;
|
||||
char* str = nullptr;
|
||||
size_t len = 0;
|
||||
const int rc =
|
||||
winpr_asprintf(&str, &len, "%s Print %04d-%02d-%02d %02d-%02d-%02d - Job %" PRIuz,
|
||||
@@ -120,7 +120,7 @@ static char* printer_cups_get_printjob_name(size_t id)
|
||||
if (rc <= 0)
|
||||
{
|
||||
free(str);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return str;
|
||||
@@ -164,7 +164,7 @@ static UINT printer_cups_write_printjob(rdpPrintJob* printjob, const BYTE* data,
|
||||
static void printer_cups_close_printjob(rdpPrintJob* printjob)
|
||||
{
|
||||
rdpCupsPrintJob* cups_printjob = (rdpCupsPrintJob*)printjob;
|
||||
rdpCupsPrinter* cups_printer = NULL;
|
||||
rdpCupsPrinter* cups_printer = nullptr;
|
||||
|
||||
WINPR_ASSERT(cups_printjob);
|
||||
|
||||
@@ -178,26 +178,26 @@ static void printer_cups_close_printjob(rdpPrintJob* printjob)
|
||||
cups_printer = (rdpCupsPrinter*)printjob->printer;
|
||||
WINPR_ASSERT(cups_printer);
|
||||
|
||||
cups_printer->printjob = NULL;
|
||||
cups_printer->printjob = nullptr;
|
||||
free(cups_printjob);
|
||||
}
|
||||
|
||||
static rdpPrintJob* printer_cups_create_printjob(rdpPrinter* printer, UINT32 id)
|
||||
{
|
||||
rdpCupsPrinter* cups_printer = (rdpCupsPrinter*)printer;
|
||||
rdpCupsPrintJob* cups_printjob = NULL;
|
||||
rdpCupsPrintJob* cups_printjob = nullptr;
|
||||
|
||||
WINPR_ASSERT(cups_printer);
|
||||
|
||||
if (cups_printer->printjob != NULL)
|
||||
if (cups_printer->printjob != nullptr)
|
||||
{
|
||||
WLog_WARN(TAG, "printjob [printer '%s'] already existing, abort!", printer->name);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
cups_printjob = (rdpCupsPrintJob*)calloc(1, sizeof(rdpCupsPrintJob));
|
||||
if (!cups_printjob)
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
cups_printjob->printjob.id = id;
|
||||
cups_printjob->printjob.printer = printer;
|
||||
@@ -206,14 +206,14 @@ static rdpPrintJob* printer_cups_create_printjob(rdpPrinter* printer, UINT32 id)
|
||||
cups_printjob->printjob.Close = printer_cups_close_printjob;
|
||||
|
||||
{
|
||||
cups_printjob->printjob_object = httpConnect2(cupsServer(), ippPort(), NULL, AF_UNSPEC,
|
||||
HTTP_ENCRYPT_IF_REQUESTED, 1, 10000, NULL);
|
||||
cups_printjob->printjob_object = httpConnect2(cupsServer(), ippPort(), nullptr, AF_UNSPEC,
|
||||
HTTP_ENCRYPT_IF_REQUESTED, 1, 10000, nullptr);
|
||||
|
||||
if (!cups_printjob->printjob_object)
|
||||
{
|
||||
WLog_WARN(TAG, "httpConnect2 failed for '%s:%d", cupsServer(), ippPort());
|
||||
free(cups_printjob);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
char* jobTitle = printer_cups_get_printjob_name(cups_printjob->printjob.id);
|
||||
@@ -221,11 +221,11 @@ static rdpPrintJob* printer_cups_create_printjob(rdpPrinter* printer, UINT32 id)
|
||||
{
|
||||
httpClose(cups_printjob->printjob_object);
|
||||
free(cups_printjob);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
cups_printjob->printjob_id =
|
||||
cupsCreateJob(cups_printjob->printjob_object, printer->name, jobTitle, 0, NULL);
|
||||
cupsCreateJob(cups_printjob->printjob_object, printer->name, jobTitle, 0, nullptr);
|
||||
|
||||
if (!cups_printjob->printjob_id)
|
||||
{
|
||||
@@ -234,7 +234,7 @@ static rdpPrintJob* printer_cups_create_printjob(rdpPrinter* printer, UINT32 id)
|
||||
httpClose(cups_printjob->printjob_object);
|
||||
free(cups_printjob);
|
||||
free(jobTitle);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
http_status_t rc =
|
||||
@@ -257,10 +257,10 @@ static rdpPrintJob* printer_cups_find_printjob(rdpPrinter* printer, UINT32 id)
|
||||
|
||||
WINPR_ASSERT(cups_printer);
|
||||
|
||||
if (cups_printer->printjob == NULL)
|
||||
return NULL;
|
||||
if (cups_printer->printjob == nullptr)
|
||||
return nullptr;
|
||||
if (cups_printer->printjob->printjob.id != id)
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
return &cups_printer->printjob->printjob;
|
||||
}
|
||||
@@ -306,11 +306,11 @@ static void printer_cups_release_ref_printer(rdpPrinter* printer)
|
||||
static rdpPrinter* printer_cups_new_printer(rdpCupsPrinterDriver* cups_driver, const char* name,
|
||||
const char* driverName, BOOL is_default)
|
||||
{
|
||||
rdpCupsPrinter* cups_printer = NULL;
|
||||
rdpCupsPrinter* cups_printer = nullptr;
|
||||
|
||||
cups_printer = (rdpCupsPrinter*)calloc(1, sizeof(rdpCupsPrinter));
|
||||
if (!cups_printer)
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
cups_printer->printer.backend = &cups_driver->driver;
|
||||
|
||||
@@ -350,14 +350,14 @@ static rdpPrinter* printer_cups_new_printer(rdpCupsPrinterDriver* cups_driver, c
|
||||
|
||||
fail:
|
||||
printer_cups_free_printer(&cups_printer->printer);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static void printer_cups_release_enum_printers(rdpPrinter** printers)
|
||||
{
|
||||
rdpPrinter** cur = printers;
|
||||
|
||||
while ((cur != NULL) && ((*cur) != NULL))
|
||||
while ((cur != nullptr) && ((*cur) != nullptr))
|
||||
{
|
||||
if ((*cur)->ReleaseRef)
|
||||
(*cur)->ReleaseRef(*cur);
|
||||
@@ -368,9 +368,9 @@ static void printer_cups_release_enum_printers(rdpPrinter** printers)
|
||||
|
||||
static rdpPrinter** printer_cups_enum_printers(rdpPrinterDriver* driver)
|
||||
{
|
||||
rdpPrinter** printers = NULL;
|
||||
rdpPrinter** printers = nullptr;
|
||||
int num_printers = 0;
|
||||
cups_dest_t* dests = NULL;
|
||||
cups_dest_t* dests = nullptr;
|
||||
BOOL haveDefault = FALSE;
|
||||
const int num_dests = cupsGetDests(&dests);
|
||||
|
||||
@@ -378,19 +378,19 @@ static rdpPrinter** printer_cups_enum_printers(rdpPrinterDriver* driver)
|
||||
if (num_dests >= 0)
|
||||
printers = (rdpPrinter**)calloc((size_t)num_dests + 1, sizeof(rdpPrinter*));
|
||||
if (!printers)
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
for (size_t i = 0; i < (size_t)num_dests; i++)
|
||||
{
|
||||
const cups_dest_t* dest = &dests[i];
|
||||
if (dest->instance == NULL)
|
||||
if (dest->instance == nullptr)
|
||||
{
|
||||
rdpPrinter* current = printer_cups_new_printer((rdpCupsPrinterDriver*)driver,
|
||||
dest->name, NULL, dest->is_default);
|
||||
dest->name, nullptr, dest->is_default);
|
||||
if (!current)
|
||||
{
|
||||
printer_cups_release_enum_printers(printers);
|
||||
printers = NULL;
|
||||
printers = nullptr;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -428,7 +428,7 @@ static void printer_cups_add_ref_driver(rdpPrinterDriver* driver)
|
||||
}
|
||||
|
||||
/* Singleton */
|
||||
static rdpCupsPrinterDriver* uniq_cups_driver = NULL;
|
||||
static rdpCupsPrinterDriver* uniq_cups_driver = nullptr;
|
||||
|
||||
static void printer_cups_release_ref_driver(rdpPrinterDriver* driver)
|
||||
{
|
||||
@@ -439,7 +439,7 @@ static void printer_cups_release_ref_driver(rdpPrinterDriver* driver)
|
||||
if (cups_driver->references <= 1)
|
||||
{
|
||||
if (uniq_cups_driver == cups_driver)
|
||||
uniq_cups_driver = NULL;
|
||||
uniq_cups_driver = nullptr;
|
||||
free(cups_driver);
|
||||
}
|
||||
else
|
||||
|
||||
@@ -85,7 +85,7 @@ static char* get_printer_hash(const WCHAR* name, size_t length)
|
||||
BYTE hash[WINPR_SHA256_DIGEST_LENGTH] = WINPR_C_ARRAY_INIT;
|
||||
|
||||
if (!winpr_Digest(WINPR_MD_SHA256, name, length, hash, sizeof(hash)))
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
return winpr_BinToHexString(hash, sizeof(hash), FALSE);
|
||||
}
|
||||
@@ -94,11 +94,11 @@ WINPR_ATTR_MALLOC(free, 1)
|
||||
WINPR_ATTR_NODISCARD
|
||||
static char* get_printer_config_path(const rdpSettings* settings, const WCHAR* name, size_t length)
|
||||
{
|
||||
char* config = NULL;
|
||||
char* config = nullptr;
|
||||
const char* path = freerdp_settings_get_string(settings, FreeRDP_ConfigPath);
|
||||
char* dir = GetCombinedPath(path, "printers");
|
||||
if (!dir)
|
||||
return NULL;
|
||||
return nullptr;
|
||||
char* bname = get_printer_hash(name, length);
|
||||
if (!bname)
|
||||
goto fail;
|
||||
@@ -106,10 +106,10 @@ static char* get_printer_config_path(const rdpSettings* settings, const WCHAR* n
|
||||
|
||||
if (config && !winpr_PathFileExists(config))
|
||||
{
|
||||
if (!winpr_PathMakePath(config, NULL))
|
||||
if (!winpr_PathMakePath(config, nullptr))
|
||||
{
|
||||
free(config);
|
||||
config = NULL;
|
||||
config = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -127,8 +127,8 @@ static BOOL printer_write_setting(const char* path, prn_conf_t type, const void*
|
||||
|
||||
DWORD written = 0;
|
||||
BOOL rc = FALSE;
|
||||
HANDLE file = NULL;
|
||||
char* base64 = NULL;
|
||||
HANDLE file = nullptr;
|
||||
char* base64 = nullptr;
|
||||
const char* name = filemap[type];
|
||||
char* abs = GetCombinedPath(path, name);
|
||||
|
||||
@@ -138,8 +138,8 @@ static BOOL printer_write_setting(const char* path, prn_conf_t type, const void*
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
file =
|
||||
winpr_CreateFile(abs, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||
file = winpr_CreateFile(abs, GENERIC_WRITE, 0, nullptr, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL,
|
||||
nullptr);
|
||||
free(abs);
|
||||
|
||||
if (file == INVALID_HANDLE_VALUE)
|
||||
@@ -155,7 +155,7 @@ static BOOL printer_write_setting(const char* path, prn_conf_t type, const void*
|
||||
/* base64 char represents 6bit -> 4*(n/3) is the length which is
|
||||
* always smaller than 2*n */
|
||||
const size_t b64len = strnlen(base64, 2 * length);
|
||||
rc = WriteFile(file, base64, (UINT32)b64len, &written, NULL);
|
||||
rc = WriteFile(file, base64, (UINT32)b64len, &written, nullptr);
|
||||
|
||||
if (b64len != written)
|
||||
rc = FALSE;
|
||||
@@ -186,7 +186,7 @@ static BOOL printer_read_setting(const char* path, prn_conf_t type, void** data,
|
||||
DWORD highSize = 0;
|
||||
DWORD read = 0;
|
||||
BOOL rc = FALSE;
|
||||
char* fdata = NULL;
|
||||
char* fdata = nullptr;
|
||||
const char* name = filemap[type];
|
||||
|
||||
switch (type)
|
||||
@@ -202,8 +202,8 @@ static BOOL printer_read_setting(const char* path, prn_conf_t type, void** data,
|
||||
if (!abs)
|
||||
return FALSE;
|
||||
|
||||
HANDLE file =
|
||||
winpr_CreateFile(abs, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||
HANDLE file = winpr_CreateFile(abs, GENERIC_READ, 0, nullptr, OPEN_EXISTING,
|
||||
FILE_ATTRIBUTE_NORMAL, nullptr);
|
||||
free(abs);
|
||||
|
||||
if (file == INVALID_HANDLE_VALUE)
|
||||
@@ -221,7 +221,7 @@ static BOOL printer_read_setting(const char* path, prn_conf_t type, void** data,
|
||||
if (!fdata)
|
||||
goto fail;
|
||||
|
||||
rc = ReadFile(file, fdata, lowSize, &read, NULL);
|
||||
rc = ReadFile(file, fdata, lowSize, &read, nullptr);
|
||||
|
||||
if (lowSize != read)
|
||||
rc = FALSE;
|
||||
@@ -246,7 +246,7 @@ fail:
|
||||
else
|
||||
{
|
||||
*length = 0;
|
||||
*data = NULL;
|
||||
*data = nullptr;
|
||||
}
|
||||
|
||||
free(fdata);
|
||||
@@ -325,15 +325,15 @@ static BOOL printer_load_from_config(const rdpSettings* settings, rdpPrinter* pr
|
||||
PRINTER_DEVICE* printer_dev)
|
||||
{
|
||||
BOOL res = FALSE;
|
||||
WCHAR* wname = NULL;
|
||||
WCHAR* wname = nullptr;
|
||||
size_t wlen = 0;
|
||||
char* path = NULL;
|
||||
char* path = nullptr;
|
||||
UINT32 flags = 0;
|
||||
void* DriverName = NULL;
|
||||
void* DriverName = nullptr;
|
||||
UINT32 DriverNameLen = 0;
|
||||
void* PnPName = NULL;
|
||||
void* PnPName = nullptr;
|
||||
UINT32 PnPNameLen = 0;
|
||||
void* CachedPrinterConfigData = NULL;
|
||||
void* CachedPrinterConfigData = nullptr;
|
||||
UINT32 CachedFieldsLen = 0;
|
||||
UINT32 PrinterNameLen = 0;
|
||||
|
||||
@@ -435,21 +435,21 @@ fail:
|
||||
static BOOL printer_save_default_config(const rdpSettings* settings, rdpPrinter* printer)
|
||||
{
|
||||
BOOL res = FALSE;
|
||||
WCHAR* wname = NULL;
|
||||
WCHAR* driver = NULL;
|
||||
WCHAR* wname = nullptr;
|
||||
WCHAR* driver = nullptr;
|
||||
size_t wlen = 0;
|
||||
size_t dlen = 0;
|
||||
char* path = NULL;
|
||||
char* path = nullptr;
|
||||
|
||||
if (!settings || !printer || !printer->name || !printer->driver)
|
||||
return FALSE;
|
||||
|
||||
wname = ConvertUtf8ToWCharAlloc(printer->name, NULL);
|
||||
wname = ConvertUtf8ToWCharAlloc(printer->name, nullptr);
|
||||
|
||||
if (!wname)
|
||||
goto fail;
|
||||
|
||||
driver = ConvertUtf8ToWCharAlloc(printer->driver, NULL);
|
||||
driver = ConvertUtf8ToWCharAlloc(printer->driver, nullptr);
|
||||
|
||||
if (!driver)
|
||||
goto fail;
|
||||
@@ -482,7 +482,7 @@ fail:
|
||||
*/
|
||||
static UINT printer_process_irp_create(PRINTER_DEVICE* printer_dev, IRP* irp)
|
||||
{
|
||||
rdpPrintJob* printjob = NULL;
|
||||
rdpPrintJob* printjob = nullptr;
|
||||
|
||||
WINPR_ASSERT(printer_dev);
|
||||
WINPR_ASSERT(irp);
|
||||
@@ -514,7 +514,7 @@ static UINT printer_process_irp_create(PRINTER_DEVICE* printer_dev, IRP* irp)
|
||||
*/
|
||||
static UINT printer_process_irp_close(PRINTER_DEVICE* printer_dev, IRP* irp)
|
||||
{
|
||||
rdpPrintJob* printjob = NULL;
|
||||
rdpPrintJob* printjob = nullptr;
|
||||
|
||||
WINPR_ASSERT(printer_dev);
|
||||
WINPR_ASSERT(irp);
|
||||
@@ -547,7 +547,7 @@ static UINT printer_process_irp_write(PRINTER_DEVICE* printer_dev, IRP* irp)
|
||||
{
|
||||
UINT32 Length = 0;
|
||||
UINT64 Offset = 0;
|
||||
rdpPrintJob* printjob = NULL;
|
||||
rdpPrintJob* printjob = nullptr;
|
||||
UINT error = CHANNEL_RC_OK;
|
||||
|
||||
WINPR_ASSERT(printer_dev);
|
||||
@@ -659,7 +659,7 @@ static UINT printer_process_irp(PRINTER_DEVICE* printer_dev, IRP* irp)
|
||||
|
||||
static DWORD WINAPI printer_thread_func(LPVOID arg)
|
||||
{
|
||||
IRP* irp = NULL;
|
||||
IRP* irp = nullptr;
|
||||
PRINTER_DEVICE* printer_dev = (PRINTER_DEVICE*)arg;
|
||||
UINT error = CHANNEL_RC_OK;
|
||||
|
||||
@@ -685,7 +685,7 @@ static DWORD WINAPI printer_thread_func(LPVOID arg)
|
||||
(void)ResetEvent(printer_dev->event);
|
||||
irp = (IRP*)InterlockedPopEntrySList(printer_dev->pIrpList);
|
||||
|
||||
if (irp == NULL)
|
||||
if (irp == nullptr)
|
||||
{
|
||||
WLog_ERR(TAG, "InterlockedPopEntrySList failed!");
|
||||
error = ERROR_INTERNAL_ERROR;
|
||||
@@ -767,10 +767,10 @@ static UINT printer_custom_component(DEVICE* device, UINT16 component, UINT16 pa
|
||||
UINT32 DriverNameLen = 0;
|
||||
UINT32 PrintNameLen = 0;
|
||||
UINT32 CacheFieldsLen = 0;
|
||||
const WCHAR* PnPName = NULL;
|
||||
const WCHAR* DriverName = NULL;
|
||||
const WCHAR* PrinterName = NULL;
|
||||
const BYTE* CachedPrinterConfigData = NULL;
|
||||
const WCHAR* PnPName = nullptr;
|
||||
const WCHAR* DriverName = nullptr;
|
||||
const WCHAR* PrinterName = nullptr;
|
||||
const BYTE* CachedPrinterConfigData = nullptr;
|
||||
|
||||
if (!Stream_CheckAndLogRequiredLength(TAG, s, 24))
|
||||
return ERROR_INVALID_DATA;
|
||||
@@ -817,8 +817,8 @@ static UINT printer_custom_component(DEVICE* device, UINT16 component, UINT16 pa
|
||||
{
|
||||
UINT32 PrinterNameLen = 0;
|
||||
UINT32 ConfigDataLen = 0;
|
||||
const WCHAR* PrinterName = NULL;
|
||||
const BYTE* ConfigData = NULL;
|
||||
const WCHAR* PrinterName = nullptr;
|
||||
const BYTE* ConfigData = nullptr;
|
||||
|
||||
if (!Stream_CheckAndLogRequiredLength(TAG, s, 8))
|
||||
return ERROR_INVALID_DATA;
|
||||
@@ -847,7 +847,7 @@ static UINT printer_custom_component(DEVICE* device, UINT16 component, UINT16 pa
|
||||
case RDPDR_DELETE_PRINTER_EVENT:
|
||||
{
|
||||
UINT32 PrinterNameLen = 0;
|
||||
const WCHAR* PrinterName = NULL;
|
||||
const WCHAR* PrinterName = nullptr;
|
||||
|
||||
if (!Stream_CheckAndLogRequiredLength(TAG, s, 4))
|
||||
return ERROR_INVALID_DATA;
|
||||
@@ -867,8 +867,8 @@ static UINT printer_custom_component(DEVICE* device, UINT16 component, UINT16 pa
|
||||
{
|
||||
UINT32 OldPrinterNameLen = 0;
|
||||
UINT32 NewPrinterNameLen = 0;
|
||||
const WCHAR* OldPrinterName = NULL;
|
||||
const WCHAR* NewPrinterName = NULL;
|
||||
const WCHAR* OldPrinterName = nullptr;
|
||||
const WCHAR* NewPrinterName = nullptr;
|
||||
|
||||
if (!Stream_CheckAndLogRequiredLength(TAG, s, 8))
|
||||
return ERROR_INVALID_DATA;
|
||||
@@ -931,7 +931,7 @@ static UINT printer_custom_component(DEVICE* device, UINT16 component, UINT16 pa
|
||||
*/
|
||||
static UINT printer_free(DEVICE* device)
|
||||
{
|
||||
IRP* irp = NULL;
|
||||
IRP* irp = nullptr;
|
||||
PRINTER_DEVICE* printer_dev = (PRINTER_DEVICE*)device;
|
||||
UINT error = 0;
|
||||
|
||||
@@ -954,7 +954,7 @@ static UINT printer_free(DEVICE* device)
|
||||
#endif
|
||||
}
|
||||
|
||||
while ((irp = (IRP*)InterlockedPopEntrySList(printer_dev->pIrpList)) != NULL)
|
||||
while ((irp = (IRP*)InterlockedPopEntrySList(printer_dev->pIrpList)) != nullptr)
|
||||
{
|
||||
WINPR_ASSERT(irp->Discard);
|
||||
irp->Discard(irp);
|
||||
@@ -984,7 +984,7 @@ static UINT printer_free(DEVICE* device)
|
||||
*/
|
||||
static UINT printer_register(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints, rdpPrinter* printer)
|
||||
{
|
||||
PRINTER_DEVICE* printer_dev = NULL;
|
||||
PRINTER_DEVICE* printer_dev = nullptr;
|
||||
UINT error = ERROR_INTERNAL_ERROR;
|
||||
|
||||
WINPR_ASSERT(pEntryPoints);
|
||||
@@ -998,7 +998,7 @@ static UINT printer_register(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints, rdpPrint
|
||||
return CHANNEL_RC_NO_MEMORY;
|
||||
}
|
||||
|
||||
printer_dev->device.data = Stream_New(NULL, 1024);
|
||||
printer_dev->device.data = Stream_New(nullptr, 1024);
|
||||
|
||||
if (!printer_dev->device.data)
|
||||
goto error_out;
|
||||
@@ -1033,7 +1033,7 @@ static UINT printer_register(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints, rdpPrint
|
||||
|
||||
InitializeSListHead(printer_dev->pIrpList);
|
||||
|
||||
printer_dev->event = CreateEvent(NULL, TRUE, FALSE, NULL);
|
||||
printer_dev->event = CreateEvent(nullptr, TRUE, FALSE, nullptr);
|
||||
if (!printer_dev->event)
|
||||
{
|
||||
WLog_ERR(TAG, "CreateEvent failed!");
|
||||
@@ -1041,7 +1041,7 @@ static UINT printer_register(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints, rdpPrint
|
||||
goto error_out;
|
||||
}
|
||||
|
||||
printer_dev->stopEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
|
||||
printer_dev->stopEvent = CreateEvent(nullptr, TRUE, FALSE, nullptr);
|
||||
if (!printer_dev->stopEvent)
|
||||
{
|
||||
WLog_ERR(TAG, "CreateEvent failed!");
|
||||
@@ -1060,7 +1060,7 @@ static UINT printer_register(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints, rdpPrint
|
||||
if (printer_dev->async)
|
||||
{
|
||||
printer_dev->thread =
|
||||
CreateThread(NULL, 0, printer_thread_func, (void*)printer_dev, 0, NULL);
|
||||
CreateThread(nullptr, 0, printer_thread_func, (void*)printer_dev, 0, nullptr);
|
||||
if (!printer_dev->thread)
|
||||
{
|
||||
WLog_ERR(TAG, "CreateThread failed!");
|
||||
@@ -1080,15 +1080,15 @@ error_out:
|
||||
static rdpPrinterDriver* printer_load_backend(const char* backend)
|
||||
{
|
||||
typedef UINT(VCAPITYPE * backend_load_t)(rdpPrinterDriver**);
|
||||
PVIRTUALCHANNELENTRY entry = freerdp_load_channel_addin_entry("printer", backend, NULL, 0);
|
||||
PVIRTUALCHANNELENTRY entry = freerdp_load_channel_addin_entry("printer", backend, nullptr, 0);
|
||||
backend_load_t func = WINPR_FUNC_PTR_CAST(entry, backend_load_t);
|
||||
if (!func)
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
rdpPrinterDriver* printer = NULL;
|
||||
rdpPrinterDriver* printer = nullptr;
|
||||
const UINT rc = func(&printer);
|
||||
if (rc != CHANNEL_RC_OK)
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
return printer;
|
||||
}
|
||||
@@ -1101,11 +1101,11 @@ static rdpPrinterDriver* printer_load_backend(const char* backend)
|
||||
FREERDP_ENTRY_POINT(
|
||||
UINT VCAPITYPE printer_DeviceServiceEntry(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints))
|
||||
{
|
||||
char* name = NULL;
|
||||
char* driver_name = NULL;
|
||||
char* name = nullptr;
|
||||
char* driver_name = nullptr;
|
||||
BOOL default_backend = TRUE;
|
||||
RDPDR_PRINTER* device = NULL;
|
||||
rdpPrinterDriver* driver = NULL;
|
||||
RDPDR_PRINTER* device = nullptr;
|
||||
rdpPrinterDriver* driver = nullptr;
|
||||
UINT error = CHANNEL_RC_OK;
|
||||
|
||||
if (!pEntryPoints || !pEntryPoints->device)
|
||||
|
||||
@@ -77,10 +77,10 @@ WINPR_ATTR_MALLOC(free, 1)
|
||||
static WCHAR* printer_win_get_printjob_name(size_t id)
|
||||
{
|
||||
struct tm tres = WINPR_C_ARRAY_INIT;
|
||||
WCHAR* str = NULL;
|
||||
WCHAR* str = nullptr;
|
||||
size_t len = 0;
|
||||
|
||||
const time_t tt = time(NULL);
|
||||
const time_t tt = time(nullptr);
|
||||
const errno_t err = localtime_s(&tres, &tt);
|
||||
|
||||
do
|
||||
@@ -89,7 +89,7 @@ static WCHAR* printer_win_get_printjob_name(size_t id)
|
||||
{
|
||||
str = calloc(len + 1, sizeof(WCHAR));
|
||||
if (!str)
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const int rc = swprintf_s(
|
||||
@@ -100,7 +100,7 @@ static WCHAR* printer_win_get_printjob_name(size_t id)
|
||||
if (rc <= 0)
|
||||
{
|
||||
free(str);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
len = WINPR_ASSERTING_INT_CAST(size_t, rc) + 1ull;
|
||||
} while (!str);
|
||||
@@ -154,7 +154,7 @@ static void printer_win_close_printjob(rdpPrintJob* printjob)
|
||||
{
|
||||
}
|
||||
|
||||
win_printer->printjob = NULL;
|
||||
win_printer->printjob = nullptr;
|
||||
|
||||
free(win_printjob->di.pDocName);
|
||||
free(win_printjob);
|
||||
@@ -165,18 +165,18 @@ static rdpPrintJob* printer_win_create_printjob(rdpPrinter* printer, UINT32 id)
|
||||
rdpWinPrinter* win_printer = (rdpWinPrinter*)printer;
|
||||
rdpWinPrintJob* win_printjob;
|
||||
|
||||
if (win_printer->printjob != NULL)
|
||||
return NULL;
|
||||
if (win_printer->printjob != nullptr)
|
||||
return nullptr;
|
||||
|
||||
win_printjob = (rdpWinPrintJob*)calloc(1, sizeof(rdpWinPrintJob));
|
||||
if (!win_printjob)
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
win_printjob->printjob.id = id;
|
||||
win_printjob->printjob.printer = printer;
|
||||
win_printjob->di.pDocName = printer_win_get_printjob_name(id);
|
||||
win_printjob->di.pDatatype = NULL;
|
||||
win_printjob->di.pOutputFile = NULL;
|
||||
win_printjob->di.pDatatype = nullptr;
|
||||
win_printjob->di.pOutputFile = nullptr;
|
||||
|
||||
win_printjob->handle = StartDocPrinter(win_printer->hPrinter, 1, (LPBYTE) & (win_printjob->di));
|
||||
|
||||
@@ -184,14 +184,14 @@ static rdpPrintJob* printer_win_create_printjob(rdpPrinter* printer, UINT32 id)
|
||||
{
|
||||
free(win_printjob->di.pDocName);
|
||||
free(win_printjob);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (!StartPagePrinter(win_printer->hPrinter))
|
||||
{
|
||||
free(win_printjob->di.pDocName);
|
||||
free(win_printjob);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
win_printjob->printjob.Write = printer_win_write_printjob;
|
||||
@@ -207,10 +207,10 @@ static rdpPrintJob* printer_win_find_printjob(rdpPrinter* printer, UINT32 id)
|
||||
rdpWinPrinter* win_printer = (rdpWinPrinter*)printer;
|
||||
|
||||
if (!win_printer->printjob)
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
if (win_printer->printjob->printjob.id != id)
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
return (rdpPrintJob*)win_printer->printjob;
|
||||
}
|
||||
@@ -254,18 +254,18 @@ static rdpPrinter* printer_win_new_printer(rdpWinPrinterDriver* win_driver, cons
|
||||
{
|
||||
rdpWinPrinter* win_printer;
|
||||
DWORD needed = 0;
|
||||
PRINTER_INFO_2* prninfo = NULL;
|
||||
PRINTER_INFO_2* prninfo = nullptr;
|
||||
|
||||
if (!name)
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
win_printer = (rdpWinPrinter*)calloc(1, sizeof(rdpWinPrinter));
|
||||
if (!win_printer)
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
win_printer->printer.backend = &win_driver->driver;
|
||||
win_printer->printer.id = win_driver->id_sequence++;
|
||||
win_printer->printer.name = ConvertWCharToUtf8Alloc(name, NULL);
|
||||
win_printer->printer.name = ConvertWCharToUtf8Alloc(name, nullptr);
|
||||
if (!win_printer->printer.name)
|
||||
goto fail;
|
||||
|
||||
@@ -278,7 +278,7 @@ static rdpPrinter* printer_win_new_printer(rdpWinPrinterDriver* win_driver, cons
|
||||
win_printer->printer.AddRef = printer_win_add_ref_printer;
|
||||
win_printer->printer.ReleaseRef = printer_win_release_ref_printer;
|
||||
|
||||
if (!OpenPrinter(WINPR_CAST_CONST_PTR_AWAY(name, WCHAR*), &(win_printer->hPrinter), NULL))
|
||||
if (!OpenPrinter(WINPR_CAST_CONST_PTR_AWAY(name, WCHAR*), &(win_printer->hPrinter), nullptr))
|
||||
goto fail;
|
||||
|
||||
/* How many memory should be allocated for printer data */
|
||||
@@ -297,9 +297,9 @@ static rdpPrinter* printer_win_new_printer(rdpWinPrinterDriver* win_driver, cons
|
||||
}
|
||||
|
||||
if (drivername)
|
||||
win_printer->printer.driver = ConvertWCharToUtf8Alloc(drivername, NULL);
|
||||
win_printer->printer.driver = ConvertWCharToUtf8Alloc(drivername, nullptr);
|
||||
else
|
||||
win_printer->printer.driver = ConvertWCharToUtf8Alloc(prninfo->pDriverName, NULL);
|
||||
win_printer->printer.driver = ConvertWCharToUtf8Alloc(prninfo->pDriverName, nullptr);
|
||||
GlobalFree(prninfo);
|
||||
if (!win_printer->printer.driver)
|
||||
goto fail;
|
||||
@@ -310,14 +310,14 @@ static rdpPrinter* printer_win_new_printer(rdpWinPrinterDriver* win_driver, cons
|
||||
|
||||
fail:
|
||||
printer_win_free_printer(&win_printer->printer);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static void printer_win_release_enum_printers(rdpPrinter** printers)
|
||||
{
|
||||
rdpPrinter** cur = printers;
|
||||
|
||||
while ((cur != NULL) && ((*cur) != NULL))
|
||||
while ((cur != nullptr) && ((*cur) != nullptr))
|
||||
{
|
||||
if ((*cur)->ReleaseRef)
|
||||
(*cur)->ReleaseRef(*cur);
|
||||
@@ -330,25 +330,25 @@ static rdpPrinter** printer_win_enum_printers(rdpPrinterDriver* driver)
|
||||
{
|
||||
rdpPrinter** printers;
|
||||
int num_printers;
|
||||
PRINTER_INFO_2* prninfo = NULL;
|
||||
PRINTER_INFO_2* prninfo = nullptr;
|
||||
DWORD needed, returned;
|
||||
BOOL haveDefault = FALSE;
|
||||
LPWSTR defaultPrinter = NULL;
|
||||
LPWSTR defaultPrinter = nullptr;
|
||||
|
||||
GetDefaultPrinter(NULL, &needed);
|
||||
GetDefaultPrinter(nullptr, &needed);
|
||||
if (needed)
|
||||
{
|
||||
defaultPrinter = (LPWSTR)calloc(needed, sizeof(WCHAR));
|
||||
|
||||
if (!defaultPrinter)
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
if (!GetDefaultPrinter(defaultPrinter, &needed))
|
||||
defaultPrinter[0] = '\0';
|
||||
}
|
||||
|
||||
/* find required size for the buffer */
|
||||
EnumPrinters(PRINTER_ENUM_LOCAL | PRINTER_ENUM_CONNECTIONS, NULL, 2, NULL, 0, &needed,
|
||||
EnumPrinters(PRINTER_ENUM_LOCAL | PRINTER_ENUM_CONNECTIONS, nullptr, 2, nullptr, 0, &needed,
|
||||
&returned);
|
||||
|
||||
/* allocate array of PRINTER_INFO structures */
|
||||
@@ -356,11 +356,11 @@ static rdpPrinter** printer_win_enum_printers(rdpPrinterDriver* driver)
|
||||
if (!prninfo)
|
||||
{
|
||||
free(defaultPrinter);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/* call again */
|
||||
if (!EnumPrinters(PRINTER_ENUM_LOCAL | PRINTER_ENUM_CONNECTIONS, NULL, 2, (LPBYTE)prninfo,
|
||||
if (!EnumPrinters(PRINTER_ENUM_LOCAL | PRINTER_ENUM_CONNECTIONS, nullptr, 2, (LPBYTE)prninfo,
|
||||
needed, &needed, &returned))
|
||||
{
|
||||
}
|
||||
@@ -370,7 +370,7 @@ static rdpPrinter** printer_win_enum_printers(rdpPrinterDriver* driver)
|
||||
{
|
||||
GlobalFree(prninfo);
|
||||
free(defaultPrinter);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
num_printers = 0;
|
||||
@@ -384,7 +384,7 @@ static rdpPrinter** printer_win_enum_printers(rdpPrinterDriver* driver)
|
||||
if (!current)
|
||||
{
|
||||
printer_win_release_enum_printers(printers);
|
||||
printers = NULL;
|
||||
printers = nullptr;
|
||||
break;
|
||||
}
|
||||
if (current->is_default)
|
||||
@@ -403,22 +403,22 @@ static rdpPrinter** printer_win_enum_printers(rdpPrinterDriver* driver)
|
||||
static rdpPrinter* printer_win_get_printer(rdpPrinterDriver* driver, const char* name,
|
||||
const char* driverName, BOOL isDefault)
|
||||
{
|
||||
WCHAR* driverNameW = NULL;
|
||||
WCHAR* nameW = NULL;
|
||||
WCHAR* driverNameW = nullptr;
|
||||
WCHAR* nameW = nullptr;
|
||||
rdpWinPrinterDriver* win_driver = (rdpWinPrinterDriver*)driver;
|
||||
rdpPrinter* myPrinter = NULL;
|
||||
rdpPrinter* myPrinter = nullptr;
|
||||
|
||||
if (name)
|
||||
{
|
||||
nameW = ConvertUtf8ToWCharAlloc(name, NULL);
|
||||
nameW = ConvertUtf8ToWCharAlloc(name, nullptr);
|
||||
if (!nameW)
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
if (driverName)
|
||||
{
|
||||
driverNameW = ConvertUtf8ToWCharAlloc(driverName, NULL);
|
||||
driverNameW = ConvertUtf8ToWCharAlloc(driverName, nullptr);
|
||||
if (!driverNameW)
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
myPrinter = printer_win_new_printer(win_driver, nameW, driverNameW, isDefault);
|
||||
@@ -436,7 +436,7 @@ static void printer_win_add_ref_driver(rdpPrinterDriver* driver)
|
||||
}
|
||||
|
||||
/* Singleton */
|
||||
static rdpWinPrinterDriver* win_driver = NULL;
|
||||
static rdpWinPrinterDriver* win_driver = nullptr;
|
||||
|
||||
static void printer_win_release_ref_driver(rdpPrinterDriver* driver)
|
||||
{
|
||||
@@ -444,7 +444,7 @@ static void printer_win_release_ref_driver(rdpPrinterDriver* driver)
|
||||
if (win->references <= 1)
|
||||
{
|
||||
free(win);
|
||||
win_driver = NULL;
|
||||
win_driver = nullptr;
|
||||
}
|
||||
else
|
||||
win->references--;
|
||||
|
||||
Reference in New Issue
Block a user