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