]>
Commit | Line | Data |
---|---|---|
ef416fc2 | 1 | /* |
f2d18633 | 2 | * "$Id$" |
ef416fc2 | 3 | * |
7d644288 | 4 | * Printer definitions for the CUPS scheduler. |
ef416fc2 | 5 | * |
7d644288 MS |
6 | * Copyright 2007-2013 by Apple Inc. |
7 | * Copyright 1997-2007 by Easy Software Products, all rights reserved. | |
ef416fc2 | 8 | * |
7d644288 MS |
9 | * These coded instructions, statements, and computer programs are the |
10 | * property of Apple Inc. and are protected by Federal copyright | |
11 | * law. Distribution and use rights are outlined in the file "LICENSE.txt" | |
12 | * which should have been included with this file. If this file is | |
13 | * file is missing or damaged, see the license at "http://www.cups.org/". | |
ef416fc2 | 14 | */ |
15 | ||
f7deaa1a | 16 | #ifdef HAVE_DNSSD |
17 | # include <dns_sd.h> | |
f3c17241 MS |
18 | #elif defined(HAVE_AVAHI) |
19 | # include <avahi-client/client.h> | |
20 | # include <avahi-client/publish.h> | |
21 | # include <avahi-common/error.h> | |
22 | # include <avahi-common/thread-watch.h> | |
f7deaa1a | 23 | #endif /* HAVE_DNSSD */ |
54afec33 MS |
24 | #include <cups/pwg-private.h> |
25 | ||
f7deaa1a | 26 | |
ef416fc2 | 27 | /* |
28 | * Quota data... | |
29 | */ | |
30 | ||
31 | typedef struct | |
32 | { | |
33 | char username[33]; /* User data */ | |
34 | time_t next_update; /* Next update time */ | |
35 | int page_count, /* Count of pages */ | |
36 | k_count; /* Count of kilobytes */ | |
37 | } cupsd_quota_t; | |
38 | ||
39 | ||
f3c17241 MS |
40 | /* |
41 | * DNS-SD types to make the code cleaner/clearer... | |
42 | */ | |
43 | ||
44 | #ifdef HAVE_DNSSD | |
45 | typedef DNSServiceRef cupsd_srv_t; /* Service reference */ | |
46 | typedef TXTRecordRef cupsd_txt_t; /* TXT record */ | |
47 | ||
48 | #elif defined(HAVE_AVAHI) | |
49 | typedef AvahiEntryGroup *cupsd_srv_t; /* Service reference */ | |
50 | typedef AvahiStringList *cupsd_txt_t; /* TXT record */ | |
51 | #endif /* HAVE_DNSSD */ | |
52 | ||
53 | ||
ef416fc2 | 54 | /* |
55 | * Printer/class information structure... | |
56 | */ | |
57 | ||
f11a948a MS |
58 | typedef struct cupsd_job_s cupsd_job_t; |
59 | ||
10d09e33 | 60 | struct cupsd_printer_s |
ef416fc2 | 61 | { |
62 | char *uri, /* Printer URI */ | |
82f97232 | 63 | *uuid, /* Printer UUID */ |
ef416fc2 | 64 | *hostname, /* Host printer resides on */ |
65 | *name, /* Printer name */ | |
9b4bd602 MS |
66 | *location, /* Location string */ |
67 | *geo_location, /* Geographic location URI */ | |
ef416fc2 | 68 | *make_model, /* Make and model */ |
69 | *info, /* Description */ | |
9b4bd602 MS |
70 | *organization, /* Organization name */ |
71 | *organizational_unit, /* Organizational unit (department, etc.) */ | |
ef416fc2 | 72 | *op_policy, /* Operation policy name */ |
73 | *error_policy; /* Error policy */ | |
74 | cupsd_policy_t *op_policy_ptr; /* Pointer to operation policy */ | |
75 | int shared; /* Shared? */ | |
76 | int accepting; /* Accepting jobs? */ | |
61cf44e2 | 77 | int holding_new_jobs; /* Holding new jobs for printing? */ |
ef416fc2 | 78 | int in_implicit_class; /* In an implicit class? */ |
79 | ipp_pstate_t state; /* Printer state */ | |
80 | char state_message[1024]; /* Printer state message */ | |
81 | int num_reasons; /* Number of printer-state-reasons */ | |
d1c13e16 | 82 | char *reasons[64]; /* printer-state-reasons strings */ |
9b4bd602 MS |
83 | time_t config_time, /* Time at this configuration */ |
84 | state_time; /* Time at this state */ | |
ef416fc2 | 85 | char *job_sheets[2]; /* Banners/job sheets */ |
09a101d6 | 86 | cups_ptype_t type; /* Printer type (color, small, etc.) */ |
ef416fc2 | 87 | char *device_uri; /* Device URI */ |
0af14961 | 88 | char *sanitized_device_uri; /* Sanitized device URI */ |
ef416fc2 | 89 | char *port_monitor; /* Port monitor */ |
90 | int raw; /* Raw queue? */ | |
d09495fa | 91 | int remote; /* Remote queue? */ |
f7deaa1a | 92 | mime_type_t *filetype, /* Pseudo-filetype for printer */ |
93 | *prefiltertype; /* Pseudo-filetype for pre-filters */ | |
f14324a7 MS |
94 | cups_array_t *filetypes, /* Supported file types */ |
95 | *dest_types; /* Destination types for queue */ | |
f11a948a | 96 | cupsd_job_t *job; /* Current job in queue */ |
61cf44e2 MS |
97 | ipp_t *attrs, /* Attributes supported by this printer */ |
98 | *ppd_attrs; /* Attributes based on the PPD */ | |
ef416fc2 | 99 | int num_printers, /* Number of printers in class */ |
100 | last_printer; /* Last printer job was sent to */ | |
101 | struct cupsd_printer_s **printers; /* Printers in class */ | |
102 | int quota_period, /* Period for quotas */ | |
103 | page_limit, /* Maximum number of pages */ | |
fa73b229 | 104 | k_limit; /* Maximum number of kilobytes */ |
105 | cups_array_t *quotas; /* Quota records */ | |
10d09e33 MS |
106 | int deny_users; /* 1 = deny, 0 = allow */ |
107 | cups_array_t *users; /* Allowed/denied users */ | |
ef416fc2 | 108 | int sequence_number; /* Increasing sequence number */ |
b423cd4c | 109 | int num_options; /* Number of default options */ |
110 | cups_option_t *options; /* Default options */ | |
f7deaa1a | 111 | int num_auth_info_required; /* Number of required auth fields */ |
112 | const char *auth_info_required[4]; /* Required authentication fields */ | |
323c5de1 | 113 | char *alert, /* PSX printer-alert value */ |
114 | *alert_description; /* PSX printer-alert-description value */ | |
5a738aea | 115 | time_t marker_time; /* Last time marker attributes were updated */ |
f14324a7 | 116 | _ppd_cache_t *pc; /* PPD cache and mapping data */ |
f7deaa1a | 117 | |
f3c17241 | 118 | #if defined(HAVE_DNSSD) || defined(HAVE_AVAHI) |
f7deaa1a | 119 | char *reg_name, /* Name used for service registration */ |
f3c17241 MS |
120 | *pdl; /* pdl value for TXT record */ |
121 | cupsd_srv_t ipp_srv; /* IPP service(s) */ | |
122 | # ifdef HAVE_DNSSD | |
123 | # ifdef HAVE_SSL | |
124 | cupsd_srv_t ipps_srv; /* IPPS service(s) */ | |
125 | # endif /* HAVE_SSL */ | |
126 | cupsd_srv_t printer_srv; /* LPD service */ | |
127 | # endif /* HAVE_DNSSD */ | |
128 | #endif /* HAVE_DNSSD || HAVE_AVAHI */ | |
10d09e33 | 129 | }; |
ef416fc2 | 130 | |
131 | ||
132 | /* | |
133 | * Globals... | |
134 | */ | |
135 | ||
136 | VAR ipp_t *CommonData VALUE(NULL); | |
137 | /* Common printer object attrs */ | |
f7deaa1a | 138 | VAR cups_array_t *CommonDefaults VALUE(NULL); |
139 | /* Common -default option names */ | |
a2326b5b | 140 | VAR cups_array_t *Printers VALUE(NULL); |
ef416fc2 | 141 | /* Printer list */ |
ef416fc2 | 142 | VAR cupsd_printer_t *DefaultPrinter VALUE(NULL); |
143 | /* Default printer */ | |
144 | VAR char *DefaultPolicy VALUE(NULL); | |
145 | /* Default policy name */ | |
146 | VAR cupsd_policy_t *DefaultPolicyPtr | |
147 | VALUE(NULL); | |
148 | /* Pointer to default policy */ | |
149 | ||
150 | ||
151 | /* | |
152 | * Prototypes... | |
153 | */ | |
154 | ||
155 | extern cupsd_printer_t *cupsdAddPrinter(const char *name); | |
ef416fc2 | 156 | extern void cupsdCreateCommonData(void); |
157 | extern void cupsdDeleteAllPrinters(void); | |
f8b3a85b | 158 | extern int cupsdDeletePrinter(cupsd_printer_t *p, int update); |
ef416fc2 | 159 | extern cupsd_printer_t *cupsdFindDest(const char *name); |
160 | extern cupsd_printer_t *cupsdFindPrinter(const char *name); | |
3d8365b8 | 161 | extern cupsd_quota_t *cupsdFindQuota(cupsd_printer_t *p, |
162 | const char *username); | |
ef416fc2 | 163 | extern void cupsdFreeQuotas(cupsd_printer_t *p); |
164 | extern void cupsdLoadAllPrinters(void); | |
f7deaa1a | 165 | extern void cupsdRenamePrinter(cupsd_printer_t *p, |
166 | const char *name); | |
ef416fc2 | 167 | extern void cupsdSaveAllPrinters(void); |
f7deaa1a | 168 | extern int cupsdSetAuthInfoRequired(cupsd_printer_t *p, |
169 | const char *values, | |
170 | ipp_attribute_t *attr); | |
0af14961 | 171 | extern void cupsdSetDeviceURI(cupsd_printer_t *p, const char *uri); |
5a738aea | 172 | extern void cupsdSetPrinterAttr(cupsd_printer_t *p, |
7d644288 MS |
173 | const char *name, |
174 | const char *value); | |
ef416fc2 | 175 | extern void cupsdSetPrinterAttrs(cupsd_printer_t *p); |
e07d4801 | 176 | extern int cupsdSetPrinterReasons(cupsd_printer_t *p, |
f7deaa1a | 177 | const char *s); |
178 | extern void cupsdSetPrinterState(cupsd_printer_t *p, ipp_pstate_t s, | |
179 | int update); | |
a29fd7dd MS |
180 | #define cupsdStartPrinter(p,u) cupsdSetPrinterState((p), \ |
181 | IPP_PRINTER_IDLE, (u)) | |
ef416fc2 | 182 | extern void cupsdStopPrinter(cupsd_printer_t *p, int update); |
c9fc04c6 MS |
183 | extern int cupsdUpdatePrinterPPD(cupsd_printer_t *p, |
184 | int num_keywords, | |
185 | cups_option_t *keywords); | |
ef416fc2 | 186 | extern void cupsdUpdatePrinters(void); |
f7deaa1a | 187 | extern cupsd_quota_t *cupsdUpdateQuota(cupsd_printer_t *p, |
188 | const char *username, int pages, | |
189 | int k); | |
190 | extern const char *cupsdValidateDest(const char *uri, | |
ef416fc2 | 191 | cups_ptype_t *dtype, |
192 | cupsd_printer_t **printer); | |
193 | extern void cupsdWritePrintcap(void); | |
194 | ||
ef416fc2 | 195 | |
196 | /* | |
f2d18633 | 197 | * End of "$Id$". |
ef416fc2 | 198 | */ |