Skip to content

Commit

Permalink
libfreerdp-utils: remove deprecated calls to xnew() macro
Browse files Browse the repository at this point in the history
  • Loading branch information
awakecoding committed Nov 22, 2012
1 parent b2c3ca8 commit 2a16183
Show file tree
Hide file tree
Showing 39 changed files with 278 additions and 176 deletions.
6 changes: 4 additions & 2 deletions channels/audin/client/audin_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,8 @@ static int audin_on_new_channel_connection(IWTSListenerCallback* pListenerCallba

DEBUG_DVC("");

callback = xnew(AUDIN_CHANNEL_CALLBACK);
callback = (AUDIN_CHANNEL_CALLBACK*) malloc(sizeof(AUDIN_CHANNEL_CALLBACK));
ZeroMemory(callback, sizeof(AUDIN_CHANNEL_CALLBACK));

callback->iface.OnDataReceived = audin_on_data_received;
callback->iface.OnClose = audin_on_close;
Expand All @@ -399,7 +400,8 @@ static int audin_plugin_initialize(IWTSPlugin* pPlugin, IWTSVirtualChannelManage

DEBUG_DVC("");

audin->listener_callback = xnew(AUDIN_LISTENER_CALLBACK);
audin->listener_callback = (AUDIN_LISTENER_CALLBACK*) malloc(sizeof(AUDIN_LISTENER_CALLBACK));
ZeroMemory(audin->listener_callback, sizeof(AUDIN_LISTENER_CALLBACK));

audin->listener_callback->iface.OnNewChannelConnection = audin_on_new_channel_connection;
audin->listener_callback->plugin = pPlugin;
Expand Down
6 changes: 4 additions & 2 deletions channels/client/channels.c
Original file line number Diff line number Diff line change
Expand Up @@ -930,7 +930,8 @@ rdpChannels* freerdp_channels_new(void)
rdpChannels* channels;
rdpChannelsList* channels_list;

channels = xnew(rdpChannels);
channels = (rdpChannels*) malloc(sizeof(rdpChannels));
ZeroMemory(channels, sizeof(rdpChannels));

channels->pSyncDataList = (PSLIST_HEADER) _aligned_malloc(sizeof(SLIST_HEADER), MEMORY_ALLOCATION_ALIGNMENT);
InitializeSListHead(channels->pSyncDataList);
Expand All @@ -939,7 +940,8 @@ rdpChannels* freerdp_channels_new(void)
channels->signal = wait_obj_new();

/* Add it to the global list */
channels_list = xnew(rdpChannelsList);
channels_list = (rdpChannelsList*) malloc(sizeof(rdpChannelsList));
ZeroMemory(channels_list, sizeof(rdpChannelsList));
channels_list->channels = channels;

WaitForSingleObject(g_mutex_list, INFINITE);
Expand Down
15 changes: 11 additions & 4 deletions channels/drdynvc/client/dvcman.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,16 @@ static int dvcman_create_listener(IWTSVirtualChannelManager* pChannelMgr,
const char* pszChannelName, UINT32 ulFlags,
IWTSListenerCallback* pListenerCallback, IWTSListener** ppListener)
{
DVCMAN* dvcman = (DVCMAN*)pChannelMgr;
DVCMAN* dvcman = (DVCMAN*) pChannelMgr;
DVCMAN_LISTENER* listener;

if (dvcman->num_listeners < MAX_PLUGINS)
{
DEBUG_DVC("%d.%s.", dvcman->num_listeners, pszChannelName);
listener = xnew(DVCMAN_LISTENER);

listener = (DVCMAN_LISTENER*) malloc(sizeof(DVCMAN_LISTENER));
ZeroMemory(listener, sizeof(DVCMAN_LISTENER));

listener->iface.GetConfiguration = dvcman_get_configuration;
listener->dvcman = dvcman;
listener->channel_name = _strdup(pszChannelName);
Expand Down Expand Up @@ -213,7 +216,9 @@ IWTSVirtualChannelManager* dvcman_new(drdynvcPlugin* plugin)
{
DVCMAN* dvcman;

dvcman = xnew(DVCMAN);
dvcman = (DVCMAN*) malloc(sizeof(DVCMAN));
ZeroMemory(dvcman, sizeof(DVCMAN));

dvcman->iface.CreateListener = dvcman_create_listener;
dvcman->iface.PushEvent = dvcman_push_event;
dvcman->iface.FindChannelById = dvcman_find_channel_by_id;
Expand Down Expand Up @@ -345,7 +350,9 @@ int dvcman_create_channel(IWTSVirtualChannelManager* pChannelMgr, UINT32 Channel

if (strcmp(listener->channel_name, ChannelName) == 0)
{
channel = xnew(DVCMAN_CHANNEL);
channel = (DVCMAN_CHANNEL*) malloc(sizeof(DVCMAN_CHANNEL));
ZeroMemory(channel, sizeof(DVCMAN_CHANNEL));

channel->iface.Write = dvcman_write_channel;
channel->iface.Close = dvcman_close_channel_iface;
channel->dvcman = dvcman;
Expand Down
4 changes: 3 additions & 1 deletion channels/drive/client/drive_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,9 @@ DRIVE_FILE* drive_file_new(const char* base_path, const char* path, UINT32 id,
{
DRIVE_FILE* file;

file = xnew(DRIVE_FILE);
file = (DRIVE_FILE*) malloc(sizeof(DRIVE_FILE));
ZeroMemory(file, sizeof(DRIVE_FILE));

file->id = id;
file->basepath = (char*) base_path;
drive_file_set_fullpath(file, drive_file_combine_fullpath(base_path, path));
Expand Down
3 changes: 2 additions & 1 deletion channels/parallel/client/parallel_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,8 @@ int DeviceServiceEntry(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints)

if (name[0] && path[0])
{
parallel = xnew(PARALLEL_DEVICE);
parallel = (PARALLEL_DEVICE*) malloc(sizeof(PARALLEL_DEVICE));
ZeroMemory(parallel, sizeof(PARALLEL_DEVICE));

parallel->device.type = RDPDR_DTYP_PARALLEL;
parallel->device.name = name;
Expand Down
58 changes: 34 additions & 24 deletions channels/printer/client/printer_cups.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,72 +79,78 @@ static void printer_cups_get_printjob_name(char* buf, int size)

static void printer_cups_write_printjob(rdpPrintJob* printjob, BYTE* data, int size)
{
rdpCupsPrintJob* cups_printjob = (rdpCupsPrintJob*)printjob;
rdpCupsPrintJob* cups_printjob = (rdpCupsPrintJob*) printjob;

#ifndef _CUPS_API_1_4

{
FILE* fp;

fp = fopen((const char*)cups_printjob->printjob_object, "a+b");
fp = fopen((const char*) cups_printjob->printjob_object, "a+b");

if (fp == NULL)
{
DEBUG_WARN("failed to open file %s", (char*)cups_printjob->printjob_object);
DEBUG_WARN("failed to open file %s", (char*) cups_printjob->printjob_object);
return;
}

if (fwrite(data, 1, size, fp) < size)
{
DEBUG_WARN("failed to write file %s", (char*)cups_printjob->printjob_object);
DEBUG_WARN("failed to write file %s", (char*) cups_printjob->printjob_object);
}

fclose(fp);
}

#else

cupsWriteRequestData((http_t*)cups_printjob->printjob_object, (const char*)data, size);
cupsWriteRequestData((http_t*) cups_printjob->printjob_object, (const char*) data, size);

#endif
}

static void printer_cups_close_printjob(rdpPrintJob* printjob)
{
rdpCupsPrintJob* cups_printjob = (rdpCupsPrintJob*)printjob;
rdpCupsPrintJob* cups_printjob = (rdpCupsPrintJob*) printjob;

#ifndef _CUPS_API_1_4

{
char buf[100];

printer_cups_get_printjob_name(buf, sizeof(buf));
if (cupsPrintFile(printjob->printer->name, (const char *)cups_printjob->printjob_object, buf, 0, NULL) == 0)

if (cupsPrintFile(printjob->printer->name, (const char*) cups_printjob->printjob_object, buf, 0, NULL) == 0)
{
DEBUG_WARN("cupsPrintFile: %s", cupsLastErrorString());
}

unlink(cups_printjob->printjob_object);
free(cups_printjob->printjob_object);
}

#else

cupsFinishDocument((http_t*)cups_printjob->printjob_object, printjob->printer->name);
cupsFinishDocument((http_t*) cups_printjob->printjob_object, printjob->printer->name);
cups_printjob->printjob_id = 0;
httpClose((http_t*)cups_printjob->printjob_object);
httpClose((http_t*) cups_printjob->printjob_object);

#endif

((rdpCupsPrinter*)printjob->printer)->printjob = NULL;
((rdpCupsPrinter*) printjob->printer)->printjob = NULL;
free(cups_printjob) ;
}

static rdpPrintJob* printer_cups_create_printjob(rdpPrinter* printer, UINT32 id)
{
rdpCupsPrinter* cups_printer = (rdpCupsPrinter*)printer;
rdpCupsPrinter* cups_printer = (rdpCupsPrinter*) printer;
rdpCupsPrintJob* cups_printjob;

if (cups_printer->printjob != NULL)
return NULL;

cups_printjob = xnew(rdpCupsPrintJob);
cups_printjob = (rdpCupsPrintJob*) malloc(sizeof(rdpCupsPrintJob));
ZeroMemory(cups_printjob, sizeof(rdpCupsPrintJob));

cups_printjob->printjob.id = id;
cups_printjob->printjob.printer = printer;
Expand All @@ -161,6 +167,7 @@ static rdpPrintJob* printer_cups_create_printjob(rdpPrinter* printer, UINT32 id)
char buf[100];

cups_printjob->printjob_object = httpConnectEncrypt(cupsServer(), ippPort(), HTTP_ENCRYPT_IF_REQUESTED);

if (cups_printjob->printjob_object == NULL)
{
DEBUG_WARN("httpConnectEncrypt: %s", cupsLastErrorString());
Expand All @@ -169,19 +176,19 @@ static rdpPrintJob* printer_cups_create_printjob(rdpPrinter* printer, UINT32 id)
}

printer_cups_get_printjob_name(buf, sizeof(buf));
cups_printjob->printjob_id = cupsCreateJob((http_t*)cups_printjob->printjob_object,
cups_printjob->printjob_id = cupsCreateJob((http_t*) cups_printjob->printjob_object,
printer->name, buf, 0, NULL);

if (cups_printjob->printjob_id == 0)
{
DEBUG_WARN("cupsCreateJob: %s", cupsLastErrorString());
httpClose((http_t*)cups_printjob->printjob_object);
httpClose((http_t*) cups_printjob->printjob_object);
free(cups_printjob);
return NULL;
}
cupsStartDocument((http_t*)cups_printjob->printjob_object,
printer->name, cups_printjob->printjob_id, buf,
CUPS_FORMAT_AUTO, 1);

cupsStartDocument((http_t*) cups_printjob->printjob_object,
printer->name, cups_printjob->printjob_id, buf, CUPS_FORMAT_AUTO, 1);
}

#endif
Expand All @@ -205,10 +212,11 @@ static rdpPrintJob* printer_cups_find_printjob(rdpPrinter* printer, UINT32 id)

static void printer_cups_free_printer(rdpPrinter* printer)
{
rdpCupsPrinter* cups_printer = (rdpCupsPrinter*)printer;
rdpCupsPrinter* cups_printer = (rdpCupsPrinter*) printer;

if (cups_printer->printjob)
cups_printer->printjob->printjob.Close((rdpPrintJob*)cups_printer->printjob);
cups_printer->printjob->printjob.Close((rdpPrintJob*) cups_printer->printjob);

free(printer->name);
free(printer);
}
Expand All @@ -217,7 +225,8 @@ static rdpPrinter* printer_cups_new_printer(rdpCupsPrinterDriver* cups_driver, c
{
rdpCupsPrinter* cups_printer;

cups_printer = xnew(rdpCupsPrinter);
cups_printer = (rdpCupsPrinter*) malloc(sizeof(rdpCupsPrinter));
ZeroMemory(cups_printer, sizeof(rdpCupsPrinter));

cups_printer->printer.id = cups_driver->id_sequence++;
cups_printer->printer.name = _strdup(name);
Expand All @@ -229,7 +238,7 @@ static rdpPrinter* printer_cups_new_printer(rdpCupsPrinterDriver* cups_driver, c
cups_printer->printer.FindPrintJob = printer_cups_find_printjob;
cups_printer->printer.Free = printer_cups_free_printer;

return (rdpPrinter*)cups_printer;
return (rdpPrinter*) cups_printer;
}

static rdpPrinter** printer_cups_enum_printers(rdpPrinterDriver* driver)
Expand Down Expand Up @@ -262,7 +271,7 @@ static rdpPrinter** printer_cups_enum_printers(rdpPrinterDriver* driver)

static rdpPrinter* printer_cups_get_printer(rdpPrinterDriver* driver, const char* name)
{
rdpCupsPrinterDriver* cups_driver = (rdpCupsPrinterDriver*)driver;
rdpCupsPrinterDriver* cups_driver = (rdpCupsPrinterDriver*) driver;

return printer_cups_new_printer(cups_driver, name, cups_driver->id_sequence == 1 ? TRUE : FALSE);
}
Expand All @@ -273,7 +282,8 @@ rdpPrinterDriver* printer_cups_get_driver(void)
{
if (cups_driver == NULL)
{
cups_driver = xnew(rdpCupsPrinterDriver);
cups_driver = (rdpCupsPrinterDriver*) malloc(sizeof(rdpCupsPrinterDriver));
ZeroMemory(cups_driver, sizeof(rdpCupsPrinterDriver));

cups_driver->driver.EnumPrinters = printer_cups_enum_printers;
cups_driver->driver.GetPrinter = printer_cups_get_printer;
Expand All @@ -287,6 +297,6 @@ rdpPrinterDriver* printer_cups_get_driver(void)
#endif
}

return (rdpPrinterDriver*)cups_driver;
return (rdpPrinterDriver*) cups_driver;
}

3 changes: 2 additions & 1 deletion channels/printer/client/printer_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,8 @@ void printer_register(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints, rdpPrinter* pri
port = malloc(10);
snprintf(port, 10, "PRN%d", printer->id);

printer_dev = xnew(PRINTER_DEVICE);
printer_dev = (PRINTER_DEVICE*) malloc(sizeof(PRINTER_DEVICE));
ZeroMemory(printer_dev, sizeof(PRINTER_DEVICE));

printer_dev->device.type = RDPDR_DTYP_PRINT;
printer_dev->device.name = port;
Expand Down
33 changes: 15 additions & 18 deletions channels/printer/client/printer_win.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,33 +121,34 @@ static rdpPrintJob* printer_win_create_printjob(rdpPrinter* printer, UINT32 id)
if (win_printer->printjob != NULL)
return NULL;

win_printjob = xnew(rdpWinPrintJob);
win_printjob = (rdpWinPrintJob*) malloc(sizeof(rdpWinPrintJob));
ZeroMemory(win_printjob, sizeof(rdpWinPrintJob));

win_printjob->printjob.id = id;
win_printjob->printjob.printer = printer;
win_printjob->di.pDocName = L"FREERDPjob";
win_printjob->di.pDatatype= NULL;
win_printjob->di.pOutputFile = NULL;

win_printjob->handle = StartDocPrinter(win_printer->hPrinter, 1, (LPBYTE)&(win_printjob->di) );
if(! win_printjob->handle) DEBUG_WINPR("StartDocPrinter failed");
if ( ! StartPagePrinter(win_printer->hPrinter) )
DEBUG_WINPR("ClosePrinter failed");
win_printjob->handle = StartDocPrinter(win_printer->hPrinter, 1, (LPBYTE) &(win_printjob->di));

if (!win_printjob->handle)
DEBUG_WINPR("StartDocPrinter failed");

if (!StartPagePrinter(win_printer->hPrinter))
DEBUG_WINPR("ClosePrinter failed");

win_printjob->printjob.Write = printer_win_write_printjob;
win_printjob->printjob.Close = printer_win_close_printjob;



win_printer->printjob = win_printjob;

return (rdpPrintJob*) win_printjob;
}

static rdpPrintJob* printer_win_find_printjob(rdpPrinter* printer, UINT32 id)
{
rdpWinPrinter* win_printer = (rdpWinPrinter*)printer;
rdpWinPrinter* win_printer = (rdpWinPrinter*) printer;

DEBUG_WINPR("");

Expand All @@ -162,7 +163,7 @@ static rdpPrintJob* printer_win_find_printjob(rdpPrinter* printer, UINT32 id)

static void printer_win_free_printer(rdpPrinter* printer)
{
rdpWinPrinter* win_printer = (rdpWinPrinter*)printer;
rdpWinPrinter* win_printer = (rdpWinPrinter*) printer;

DEBUG_WINPR("");

Expand All @@ -182,7 +183,8 @@ static rdpPrinter* printer_win_new_printer(rdpWinPrinterDriver* win_driver, cons
size_t charsConverted;
DEBUG_WINPR("");

win_printer = xnew(rdpWinPrinter);
win_printer = (rdpWinPrinter*) malloc(sizeof(rdpWinPrinter));
ZeroMemory(win_printer, sizeof(rdpWinPrinter));

win_printer->printer.id = win_driver->id_sequence++;
win_printer->printer.name = _strdup(name);
Expand Down Expand Up @@ -269,20 +271,15 @@ rdpPrinterDriver* printer_win_get_driver(void)

if (win_driver == NULL)
{
win_driver = xnew(rdpWinPrinterDriver);
win_driver = (rdpWinPrinterDriver*) malloc(sizeof(rdpWinPrinterDriver));
ZeroMemory(win_driver, sizeof(rdpWinPrinterDriver));

win_driver->driver.EnumPrinters = printer_win_enum_printers;
win_driver->driver.GetPrinter = printer_win_get_printer;

win_driver->id_sequence = 1;

//#ifdef _win_API_1_4
// DEBUG_SVC("using win API 1.4");
//#else
// DEBUG_SVC("using win API 1.2");
//#endif
}

return (rdpPrinterDriver*)win_driver;
return (rdpPrinterDriver*) win_driver;
}

Loading

0 comments on commit 2a16183

Please sign in to comment.