michael@0: /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ michael@0: /* ex: set tabstop=8 softtabstop=4 shiftwidth=4 expandtab: */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef nsCUPSShim_h___ michael@0: #define nsCUPSShim_h___ michael@0: michael@0: michael@0: /* Various CUPS data types. We don't #include cups headers to avoid michael@0: * requiring CUPS to be installed on the build host (and to avoid having michael@0: * to test for CUPS in configure). michael@0: */ michael@0: typedef struct /**** Printer Options ****/ michael@0: { michael@0: char *name; /* Name of option */ michael@0: char *value; /* Value of option */ michael@0: } cups_option_t; michael@0: michael@0: typedef struct /**** Destination ****/ michael@0: { michael@0: char *name, /* Printer or class name */ michael@0: *instance; /* Local instance name or nullptr */ michael@0: int is_default; /* Is this printer the default? */ michael@0: int num_options; /* Number of options */ michael@0: cups_option_t *options; /* Options */ michael@0: } cups_dest_t; michael@0: michael@0: typedef cups_dest_t* (*CupsGetDestType)(const char *printer, michael@0: const char *instance, michael@0: int num_dests, michael@0: cups_dest_t *dests); michael@0: typedef int (*CupsGetDestsType)(cups_dest_t **dests); michael@0: typedef int (*CupsFreeDestsType)(int num_dests, michael@0: cups_dest_t *dests); michael@0: typedef int (*CupsPrintFileType)(const char *printer, michael@0: const char *filename, michael@0: const char *title, michael@0: int num_options, michael@0: cups_option_t *options); michael@0: typedef int (*CupsTempFdType)(char *filename, michael@0: int length); michael@0: typedef int (*CupsAddOptionType)(const char *name, michael@0: const char *value, michael@0: int num_options, michael@0: cups_option_t **options); michael@0: michael@0: struct PRLibrary; michael@0: michael@0: /* Note: this class relies on static initialization. */ michael@0: class nsCUPSShim { michael@0: public: michael@0: /** michael@0: * Initialize this object. Attempt to load the CUPS shared michael@0: * library and find function pointers for the supported michael@0: * functions (see below). michael@0: * @return false if the shared library could not be loaded, or if michael@0: * any of the functions could not be found. michael@0: * true for successful initialization. michael@0: */ michael@0: bool Init(); michael@0: michael@0: /** michael@0: * @return true if the object was initialized successfully. michael@0: * false otherwise. michael@0: */ michael@0: bool IsInitialized() { return nullptr != mCupsLib; } michael@0: michael@0: /* Function pointers for supported functions. These are only michael@0: * valid after successful initialization. michael@0: */ michael@0: CupsAddOptionType mCupsAddOption; michael@0: CupsFreeDestsType mCupsFreeDests; michael@0: CupsGetDestType mCupsGetDest; michael@0: CupsGetDestsType mCupsGetDests; michael@0: CupsPrintFileType mCupsPrintFile; michael@0: CupsTempFdType mCupsTempFd; michael@0: michael@0: private: michael@0: PRLibrary *mCupsLib; michael@0: }; michael@0: michael@0: michael@0: michael@0: #endif /* nsCUPSShim_h___ */