]> git.ipfire.org Git - thirdparty/cups.git/blobdiff - scheduler/printers.h
Strip trailing slash from regex paths to prevent sandboxing issues.
[thirdparty/cups.git] / scheduler / printers.h
index bc2f637c58671d7b6bbdc980db287eccbe6af09d..a5ced9f21c5b18c3977ff4492b014ef9dc03e1c2 100644 (file)
@@ -1,48 +1,66 @@
 /*
- * "$Id: printers.h,v 1.22.2.8 2003/01/29 20:08:28 mike Exp $"
+ * "$Id$"
  *
- *   Printer definitions for the Common UNIX Printing System (CUPS) scheduler.
+ *   Printer definitions for the CUPS scheduler.
  *
- *   Copyright 1997-2003 by Easy Software Products, all rights reserved.
+ *   Copyright 2007-2012 by Apple Inc.
+ *   Copyright 1997-2007 by Easy Software Products, all rights reserved.
  *
  *   These coded instructions, statements, and computer programs are the
- *   property of Easy Software Products and are protected by Federal
- *   copyright law.  Distribution and use rights are outlined in the file
- *   "LICENSE.txt" which should have been included with this file.  If this
- *   file is missing or damaged please contact Easy Software Products
- *   at:
- *
- *       Attn: CUPS Licensing Information
- *       Easy Software Products
- *       44141 Airport View Drive, Suite 204
- *       Hollywood, Maryland 20636-3111 USA
- *
- *       Voice: (301) 373-9603
- *       EMail: cups-info@cups.org
- *         WWW: http://www.cups.org
+ *   property of Apple Inc. and are protected by Federal copyright
+ *   law.  Distribution and use rights are outlined in the file "LICENSE.txt"
+ *   which should have been included with this file.  If this file is
+ *   file is missing or damaged, see the license at "http://www.cups.org/".
  */
 
+#ifdef HAVE_DNSSD
+#  include <dns_sd.h>
+#elif defined(HAVE_AVAHI)
+#  include <avahi-client/client.h>
+#  include <avahi-client/publish.h>
+#  include <avahi-common/error.h>
+#  include <avahi-common/thread-watch.h>
+#endif /* HAVE_DNSSD */
+#include <cups/pwg-private.h>
+
+
 /*
  * Quota data...
  */
 
 typedef struct
 {
-  char         username[33];   /* User data */
-  time_t       next_update;    /* Next update time */
-  int          page_count,     /* Count of pages */
-               k_count;        /* Count of kilobytes */
-} quota_t;
+  char         username[33];           /* User data */
+  time_t       next_update;            /* Next update time */
+  int          page_count,             /* Count of pages */
+               k_count;                /* Count of kilobytes */
+} cupsd_quota_t;
+
+
+/*
+ * DNS-SD types to make the code cleaner/clearer...
+ */
+
+#ifdef HAVE_DNSSD
+typedef DNSServiceRef cupsd_srv_t;     /* Service reference */
+typedef TXTRecordRef cupsd_txt_t;      /* TXT record */
+
+#elif defined(HAVE_AVAHI)
+typedef AvahiEntryGroup *cupsd_srv_t;  /* Service reference */
+typedef AvahiStringList *cupsd_txt_t;  /* TXT record */
+#endif /* HAVE_DNSSD */
 
 
 /*
  * Printer/class information structure...
  */
 
-typedef struct printer_str
+typedef struct cupsd_job_s cupsd_job_t;
+
+struct cupsd_printer_s
 {
-  struct printer_str *next;            /* Next printer in list */
   char         *uri,                   /* Printer URI */
+               *uuid,                  /* Printer UUID */
                *hostname,              /* Host printer resides on */
                *name,                  /* Printer name */
                *location,              /* Location code */
@@ -50,74 +68,126 @@ typedef struct printer_str
                *info,                  /* Description */
                *op_policy,             /* Operation policy name */
                *error_policy;          /* Error policy */
-  policy_t     *op_policy_ptr;         /* Pointer to operation policy */
+  cupsd_policy_t *op_policy_ptr;       /* Pointer to operation policy */
+  int          shared;                 /* Shared? */
   int          accepting;              /* Accepting jobs? */
+  int          holding_new_jobs;       /* Holding new jobs for printing? */
+  int          in_implicit_class;      /* In an implicit class? */
   ipp_pstate_t state;                  /* Printer state */
   char         state_message[1024];    /* Printer state message */
-  ipp_attribute_t *state_reasons;      /* Printer state reasons */
+  int          num_reasons;            /* Number of printer-state-reasons */
+  char         *reasons[64];           /* printer-state-reasons strings */
   time_t       state_time;             /* Time at this state */
   char         *job_sheets[2];         /* Banners/job sheets */
   cups_ptype_t type;                   /* Printer type (color, small, etc.) */
-  time_t       browse_time;            /* Last time update was sent/received */
-  char         *device_uri,            /* Device URI */
-               *backend;               /* Backend to use */
+  char         *device_uri;            /* Device URI */
+  char         *sanitized_device_uri;  /* Sanitized device URI */
+  char         *port_monitor;          /* Port monitor */
   int          raw;                    /* Raw queue? */
-  mime_type_t  *filetype;              /* Pseudo-filetype for printer */
-  void         *job;                   /* Current job in queue */
-  ipp_t                *attrs;                 /* Attributes supported by this printer */
+  int          remote;                 /* Remote queue? */
+  mime_type_t  *filetype,              /* Pseudo-filetype for printer */
+               *prefiltertype;         /* Pseudo-filetype for pre-filters */
+  cups_array_t *filetypes,             /* Supported file types */
+               *dest_types;            /* Destination types for queue */
+  cupsd_job_t  *job;                   /* Current job in queue */
+  ipp_t                *attrs,                 /* Attributes supported by this printer */
+               *ppd_attrs;             /* Attributes based on the PPD */
   int          num_printers,           /* Number of printers in class */
                last_printer;           /* Last printer job was sent to */
-  struct printer_str **printers;       /* Printers in class */
+  struct cupsd_printer_s **printers;   /* Printers in class */
   int          quota_period,           /* Period for quotas */
                page_limit,             /* Maximum number of pages */
-               k_limit,                /* Maximum number of kilobytes */
-               num_quotas;             /* Number of quota records */
-  quota_t      *quotas;                /* Quota records */
-  int          deny_users,             /* 1 = deny, 0 = allow */
-               num_users;              /* Number of allowed/denied users */
-  const char   **users;                /* Allowed/denied users */
-} printer_t;
+               k_limit;                /* Maximum number of kilobytes */
+  cups_array_t *quotas;                /* Quota records */
+  int          deny_users;             /* 1 = deny, 0 = allow */
+  cups_array_t *users;                 /* Allowed/denied users */
+  int          sequence_number;        /* Increasing sequence number */
+  int          num_options;            /* Number of default options */
+  cups_option_t        *options;               /* Default options */
+  int          num_auth_info_required; /* Number of required auth fields */
+  const char   *auth_info_required[4]; /* Required authentication fields */
+  char         *alert,                 /* PSX printer-alert value */
+               *alert_description;     /* PSX printer-alert-description value */
+  time_t       marker_time;            /* Last time marker attributes were updated */
+  _ppd_cache_t *pc;                    /* PPD cache and mapping data */
+
+#if defined(HAVE_DNSSD) || defined(HAVE_AVAHI)
+  char         *reg_name,              /* Name used for service registration */
+               *pdl;                   /* pdl value for TXT record */
+  cupsd_srv_t  ipp_srv;                /* IPP service(s) */
+#  ifdef HAVE_DNSSD
+#    ifdef HAVE_SSL
+  cupsd_srv_t  ipps_srv;               /* IPPS service(s) */
+#    endif /* HAVE_SSL */
+  cupsd_srv_t  printer_srv;            /* LPD service */
+#  endif /* HAVE_DNSSD */
+#endif /* HAVE_DNSSD || HAVE_AVAHI */
+};
 
 
 /*
  * Globals...
  */
 
-VAR printer_t          *Printers VALUE(NULL);  /* Printer list */
-VAR printer_t          *DefaultPrinter VALUE(NULL);
-                                               /* Default printer */
+VAR ipp_t              *CommonData     VALUE(NULL);
+                                       /* Common printer object attrs */
+VAR cups_array_t       *CommonDefaults VALUE(NULL);
+                                       /* Common -default option names */
+VAR cups_array_t       *Printers       VALUE(NULL);
+                                       /* Printer list */
+VAR cupsd_printer_t    *DefaultPrinter VALUE(NULL);
+                                       /* Default printer */
+VAR char               *DefaultPolicy  VALUE(NULL);
+                                       /* Default policy name */
+VAR cupsd_policy_t     *DefaultPolicyPtr
+                                       VALUE(NULL);
+                                       /* Pointer to default policy */
+
 
 /*
  * Prototypes...
  */
 
-extern printer_t       *AddPrinter(const char *name);
-extern void            AddPrinterFilter(printer_t *p, const char *filter);
-extern void            AddPrinterUser(printer_t *p, const char *username);
-extern quota_t         *AddQuota(printer_t *p, const char *username);
-extern void            DeleteAllPrinters(void);
-extern void            DeletePrinter(printer_t *p);
-extern void            DeletePrinterFilters(printer_t *p);
-extern printer_t       *FindDest(const char *name);
-extern printer_t       *FindPrinter(const char *name);
-extern quota_t         *FindQuota(printer_t *p, const char *username);
-extern void            FreePrinterUsers(printer_t *p);
-extern void            FreeQuotas(printer_t *p);
-extern void            LoadAllPrinters(void);
-extern void            SaveAllPrinters(void);
-extern void            SetPrinterAttrs(printer_t *p);
-extern void            SetPrinterState(printer_t *p, ipp_pstate_t s);
-extern void            SortPrinters(void);
-#define                        StartPrinter(p) SetPrinterState((p), IPP_PRINTER_IDLE)
-extern void            StopPrinter(printer_t *p);
-extern quota_t         *UpdateQuota(printer_t *p, const char *username,
-                                    int pages, int k);
-extern const char      *ValidateDest(const char *hostname,
-                                     const char *resource,
-                                     cups_ptype_t *dtype);
-extern void            WritePrintcap(void);
+extern cupsd_printer_t *cupsdAddPrinter(const char *name);
+extern void            cupsdCreateCommonData(void);
+extern void            cupsdDeleteAllPrinters(void);
+extern int             cupsdDeletePrinter(cupsd_printer_t *p, int update);
+extern cupsd_printer_t *cupsdFindDest(const char *name);
+extern cupsd_printer_t *cupsdFindPrinter(const char *name);
+extern cupsd_quota_t   *cupsdFindQuota(cupsd_printer_t *p,
+                                       const char *username);
+extern void            cupsdFreeQuotas(cupsd_printer_t *p);
+extern void            cupsdLoadAllPrinters(void);
+extern void            cupsdRenamePrinter(cupsd_printer_t *p,
+                                          const char *name);
+extern void            cupsdSaveAllPrinters(void);
+extern int             cupsdSetAuthInfoRequired(cupsd_printer_t *p,
+                                                const char *values,
+                                                ipp_attribute_t *attr);
+extern void            cupsdSetDeviceURI(cupsd_printer_t *p, const char *uri);
+extern void            cupsdSetPrinterAttr(cupsd_printer_t *p,
+                                           const char *name, char *value);
+extern void            cupsdSetPrinterAttrs(cupsd_printer_t *p);
+extern int             cupsdSetPrinterReasons(cupsd_printer_t *p,
+                                              const char *s);
+extern void            cupsdSetPrinterState(cupsd_printer_t *p, ipp_pstate_t s,
+                                            int update);
+#define                        cupsdStartPrinter(p,u) cupsdSetPrinterState((p), \
+                                                  IPP_PRINTER_IDLE, (u))
+extern void            cupsdStopPrinter(cupsd_printer_t *p, int update);
+extern int             cupsdUpdatePrinterPPD(cupsd_printer_t *p,
+                                             int num_keywords,
+                                             cups_option_t *keywords);
+extern void            cupsdUpdatePrinters(void);
+extern cupsd_quota_t   *cupsdUpdateQuota(cupsd_printer_t *p,
+                                         const char *username, int pages,
+                                         int k);
+extern const char      *cupsdValidateDest(const char *uri,
+                                          cups_ptype_t *dtype,
+                                          cupsd_printer_t **printer);
+extern void            cupsdWritePrintcap(void);
 
 
 /*
- * End of "$Id: printers.h,v 1.22.2.8 2003/01/29 20:08:28 mike Exp $".
+ * End of "$Id$".
  */