widget/gtk/nsCUPSShim.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
     2 /* ex: set tabstop=8 softtabstop=4 shiftwidth=4 expandtab: */
     3 /* This Source Code Form is subject to the terms of the Mozilla Public
     4  * License, v. 2.0. If a copy of the MPL was not distributed with this
     5  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     7 #ifndef nsCUPSShim_h___
     8 #define nsCUPSShim_h___
    11 /* Various CUPS data types. We don't #include cups headers to avoid
    12  * requiring CUPS to be installed on the build host (and to avoid having
    13  * to test for CUPS in configure).
    14  */
    15 typedef struct                          /**** Printer Options ****/
    16 {
    17     char          *name;                  /* Name of option */
    18     char          *value;                 /* Value of option */
    19 } cups_option_t;
    21 typedef struct               /**** Destination ****/
    22 {
    23     char          *name,       /* Printer or class name */
    24                   *instance;   /* Local instance name or nullptr */
    25     int           is_default;  /* Is this printer the default? */
    26     int           num_options; /* Number of options */
    27     cups_option_t *options;    /* Options */
    28 } cups_dest_t;
    30 typedef cups_dest_t* (*CupsGetDestType)(const char *printer,
    31                                         const char *instance,
    32                                         int num_dests,
    33                                         cups_dest_t *dests);
    34 typedef int (*CupsGetDestsType)(cups_dest_t **dests);
    35 typedef int (*CupsFreeDestsType)(int         num_dests,
    36                                  cups_dest_t *dests);
    37 typedef int (*CupsPrintFileType)(const char    *printer,
    38                                  const char    *filename,
    39                                  const char    *title,
    40                                  int           num_options,
    41                                  cups_option_t *options);
    42 typedef int (*CupsTempFdType)(char *filename,
    43                               int   length);
    44 typedef int (*CupsAddOptionType)(const char    *name,
    45                                  const char    *value,
    46                                  int           num_options,
    47                                  cups_option_t **options);
    49 struct PRLibrary;
    51 /* Note: this class relies on static initialization. */
    52 class nsCUPSShim {
    53     public:
    54         /**
    55          * Initialize this object. Attempt to load the CUPS shared
    56          * library and find function pointers for the supported
    57          * functions (see below).
    58          * @return false if the shared library could not be loaded, or if
    59          *                  any of the functions could not be found.
    60          *         true  for successful initialization.
    61          */
    62         bool Init();
    64         /**
    65          * @return true  if the object was initialized successfully.
    66          *         false otherwise.
    67          */
    68         bool IsInitialized() { return nullptr != mCupsLib; }
    70         /* Function pointers for supported functions. These are only
    71          * valid after successful initialization.
    72          */
    73         CupsAddOptionType   mCupsAddOption;
    74         CupsFreeDestsType   mCupsFreeDests;
    75         CupsGetDestType     mCupsGetDest;
    76         CupsGetDestsType    mCupsGetDests;
    77         CupsPrintFileType   mCupsPrintFile;
    78         CupsTempFdType      mCupsTempFd;
    80     private:
    81         PRLibrary *mCupsLib;
    82 };
    86 #endif /* nsCUPSShim_h___ */

mercurial