/src/mozilla-central/widget/gtk/nsCUPSShim.h
Line | Count | Source (jump to first uncovered line) |
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/. */ |
6 | | |
7 | | #ifndef nsCUPSShim_h___ |
8 | | #define nsCUPSShim_h___ |
9 | | |
10 | | |
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; |
20 | | |
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; |
29 | | |
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); |
48 | | |
49 | | struct PRLibrary; |
50 | | |
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(); |
63 | | |
64 | | /** |
65 | | * @return true if the object was initialized successfully. |
66 | | * false otherwise. |
67 | | */ |
68 | 0 | bool IsInitialized() { return nullptr != mCupsLib; } |
69 | | |
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; |
79 | | |
80 | | private: |
81 | | PRLibrary *mCupsLib; |
82 | | }; |
83 | | |
84 | | |
85 | | |
86 | | #endif /* nsCUPSShim_h___ */ |