FreeRDP
printer_main.c File Reference
#include <freerdp/config.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <winpr/crt.h>
#include <winpr/assert.h>
#include <winpr/string.h>
#include <winpr/synch.h>
#include <winpr/thread.h>
#include <winpr/stream.h>
#include <winpr/interlocked.h>
#include <winpr/path.h>
#include <freerdp/channels/rdpdr.h>
#include <freerdp/crypto/crypto.h>
#include <freerdp/freerdp.h>
#include "../printer.h"
#include <freerdp/client/printer.h>
#include <freerdp/channels/log.h>

Macros

#define TAG   CHANNELS_TAG("printer.client")
 

Enumerations

enum  prn_conf_t { PRN_CONF_PORT = 0 , PRN_CONF_PNP = 1 , PRN_CONF_DRIVER = 2 , PRN_CONF_DATA = 3 }
 

Functions

static char * get_printer_config_path (const rdpSettings *settings, const WCHAR *name, size_t length)
 
static BOOL printer_write_setting (const char *path, prn_conf_t type, const void *data, size_t length)
 
static BOOL printer_config_valid (const char *path)
 
static BOOL printer_read_setting (const char *path, prn_conf_t type, void **data, UINT32 *length)
 
static BOOL printer_save_to_config (const rdpSettings *settings, const char *PortDosName, size_t PortDosNameLen, const WCHAR *PnPName, size_t PnPNameLen, const WCHAR *DriverName, size_t DriverNameLen, const WCHAR *PrinterName, size_t PrintNameLen, const BYTE *CachedPrinterConfigData, size_t CacheFieldsLen)
 
static BOOL printer_update_to_config (const rdpSettings *settings, const WCHAR *name, size_t length, const BYTE *data, size_t datalen)
 
static BOOL printer_remove_config (const rdpSettings *settings, const WCHAR *name, size_t length)
 
static BOOL printer_move_config (const rdpSettings *settings, const WCHAR *oldName, size_t oldLength, const WCHAR *newName, size_t newLength)
 
static BOOL printer_load_from_config (const rdpSettings *settings, rdpPrinter *printer, PRINTER_DEVICE *printer_dev)
 
static BOOL printer_save_default_config (const rdpSettings *settings, rdpPrinter *printer)
 
static UINT printer_process_irp_create (PRINTER_DEVICE *printer_dev, IRP *irp)
 
static UINT printer_process_irp_close (PRINTER_DEVICE *printer_dev, IRP *irp)
 
static UINT printer_process_irp_write (PRINTER_DEVICE *printer_dev, IRP *irp)
 
static UINT printer_process_irp_device_control (PRINTER_DEVICE *printer_dev, IRP *irp)
 
static UINT printer_process_irp (PRINTER_DEVICE *printer_dev, IRP *irp)
 
static DWORD WINAPI printer_thread_func (LPVOID arg)
 
static UINT printer_irp_request (DEVICE *device, IRP *irp)
 
static UINT printer_custom_component (DEVICE *device, UINT16 component, UINT16 packetId, wStream *s)
 
static UINT printer_free (DEVICE *device)
 
static UINT printer_register (PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints, rdpPrinter *printer)
 
static rdpPrinterDriver * printer_load_backend (const char *backend)
 
 if (!pEntryPoints||!pEntryPoints->device) return ERROR_INVALID_PARAMETER
 
 if (driver_name)
 
 if (!driver &&default_backend)
 
 if (!driver)
 
 if (name &&name[0])
 
 if (printers)
 
 WINPR_ASSERT (driver->ReleaseEnumPrinters)
 
driver ReleaseEnumPrinters (printers)
 
 if (driver)
 

Variables

static const char * filemap []
 
char * driver_name = NULL
 
BOOL default_backend = TRUE
 
RDPDR_PRINTERdevice = NULL
 
rdpPrinterDriver * driver = NULL
 
UINT error = CHANNEL_RC_OK
 
 name = device->device.Name
 
 else
 
rdpPrinter ** printers = driver->EnumPrinters(driver)
 
fail __pad0__
 

Macro Definition Documentation

◆ TAG

#define TAG   CHANNELS_TAG("printer.client")

FreeRDP: A Remote Desktop Protocol Implementation Print Virtual Channel

Copyright 2010-2011 Vic Lee Copyright 2015 Thincast Technologies GmbH Copyright 2015 DI (FH) Martin Haimberger marti.nosp@m.n.ha.nosp@m.imber.nosp@m.ger@.nosp@m.thinc.nosp@m.ast..nosp@m.com Copyright 2016 Armin Novak armin.nosp@m..nov.nosp@m.ak@gm.nosp@m.ail..nosp@m.com Copyright 2016 David PHAM-VAN d.pha.nosp@m.mvan.nosp@m.@inuv.nosp@m.ika..nosp@m.com

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Enumeration Type Documentation

◆ prn_conf_t

enum prn_conf_t
Enumerator
PRN_CONF_PORT 
PRN_CONF_PNP 
PRN_CONF_DRIVER 
PRN_CONF_DATA 

Function Documentation

◆ get_printer_config_path()

static char* get_printer_config_path ( const rdpSettings *  settings,
const WCHAR *  name,
size_t  length 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ if() [1/7]

if ( !driver &&  default_backend)
Here is the call graph for this function:

◆ if() [2/7]

if ( driver)

◆ if() [3/7]

if ( !pEntryPoints||!pEntryPoints->  device)

◆ if() [4/7]

if ( driver  )
Here is the call graph for this function:

◆ if() [5/7]

if ( driver_name  )
Here is the call graph for this function:

◆ if() [6/7]

if ( name &&  name[0])
Here is the call graph for this function:

◆ if() [7/7]

if ( printers  )
Here is the call graph for this function:

◆ printer_config_valid()

static BOOL printer_config_valid ( const char *  path)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ printer_custom_component()

static UINT printer_custom_component ( DEVICE *  device,
UINT16  component,
UINT16  packetId,
wStream s 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ printer_free()

static UINT printer_free ( DEVICE *  device)
static

Function description

Returns
0 on success, otherwise a Win32 error code
Here is the call graph for this function:
Here is the caller graph for this function:

◆ printer_irp_request()

static UINT printer_irp_request ( DEVICE *  device,
IRP *  irp 
)
static

Function description

Returns
0 on success, otherwise a Win32 error code
Here is the call graph for this function:
Here is the caller graph for this function:

◆ printer_load_backend()

static rdpPrinterDriver* printer_load_backend ( const char *  backend)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ printer_load_from_config()

static BOOL printer_load_from_config ( const rdpSettings *  settings,
rdpPrinter *  printer,
PRINTER_DEVICE *  printer_dev 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ printer_move_config()

static BOOL printer_move_config ( const rdpSettings *  settings,
const WCHAR *  oldName,
size_t  oldLength,
const WCHAR *  newName,
size_t  newLength 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ printer_process_irp()

static UINT printer_process_irp ( PRINTER_DEVICE *  printer_dev,
IRP *  irp 
)
static

Function description

Returns
0 on success, otherwise a Win32 error code
Here is the call graph for this function:
Here is the caller graph for this function:

◆ printer_process_irp_close()

static UINT printer_process_irp_close ( PRINTER_DEVICE *  printer_dev,
IRP *  irp 
)
static

Function description

Returns
0 on success, otherwise a Win32 error code
Here is the call graph for this function:
Here is the caller graph for this function:

◆ printer_process_irp_create()

static UINT printer_process_irp_create ( PRINTER_DEVICE *  printer_dev,
IRP *  irp 
)
static

Function description

Returns
0 on success, otherwise a Win32 error code
Here is the call graph for this function:
Here is the caller graph for this function:

◆ printer_process_irp_device_control()

static UINT printer_process_irp_device_control ( PRINTER_DEVICE *  printer_dev,
IRP *  irp 
)
static

Function description

Returns
0 on success, otherwise a Win32 error code
Here is the call graph for this function:
Here is the caller graph for this function:

◆ printer_process_irp_write()

static UINT printer_process_irp_write ( PRINTER_DEVICE *  printer_dev,
IRP *  irp 
)
static

Function description

Returns
0 on success, otherwise a Win32 error code
Here is the call graph for this function:
Here is the caller graph for this function:

◆ printer_read_setting()

static BOOL printer_read_setting ( const char *  path,
prn_conf_t  type,
void **  data,
UINT32 *  length 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ printer_register()

static UINT printer_register ( PDEVICE_SERVICE_ENTRY_POINTS  pEntryPoints,
rdpPrinter *  printer 
)
static

Function description

Returns
0 on success, otherwise a Win32 error code
Here is the call graph for this function:
Here is the caller graph for this function:

◆ printer_remove_config()

static BOOL printer_remove_config ( const rdpSettings *  settings,
const WCHAR *  name,
size_t  length 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ printer_save_default_config()

static BOOL printer_save_default_config ( const rdpSettings *  settings,
rdpPrinter *  printer 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ printer_save_to_config()

static BOOL printer_save_to_config ( const rdpSettings *  settings,
const char *  PortDosName,
size_t  PortDosNameLen,
const WCHAR *  PnPName,
size_t  PnPNameLen,
const WCHAR *  DriverName,
size_t  DriverNameLen,
const WCHAR *  PrinterName,
size_t  PrintNameLen,
const BYTE CachedPrinterConfigData,
size_t  CacheFieldsLen 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ printer_thread_func()

static DWORD WINAPI printer_thread_func ( LPVOID  arg)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ printer_update_to_config()

static BOOL printer_update_to_config ( const rdpSettings *  settings,
const WCHAR *  name,
size_t  length,
const BYTE data,
size_t  datalen 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ printer_write_setting()

static BOOL printer_write_setting ( const char *  path,
prn_conf_t  type,
const void *  data,
size_t  length 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ReleaseEnumPrinters()

driver ReleaseEnumPrinters ( printers  )

◆ WINPR_ASSERT()

WINPR_ASSERT ( driver->  ReleaseEnumPrinters)
Here is the caller graph for this function:

Variable Documentation

◆ __pad0__

fail __pad0__

◆ default_backend

BOOL default_backend = TRUE

◆ device

device = NULL

◆ driver

rdpPrinterDriver* driver = NULL

◆ driver_name

driver_name = NULL

Function description

Returns
0 on success, otherwise a Win32 error code

◆ else

else
Initial value:
{
WINPR_ASSERT(driver->EnumPrinters)
WINPR_ASSERT(driver->ReleaseEnumPrinters)
rdpPrinterDriver * driver
Definition: printer_main.c:1079

◆ error

◆ filemap

const char* filemap[]
static
Initial value:
= { "PortDosName", "PnPName", "DriverName",
"CachedPrinterConfigData" }

◆ name

name = device->device.Name

◆ printers

rdpPrinter** printers = driver->EnumPrinters(driver)