]> git.ipfire.org Git - thirdparty/cups.git/blob - scheduler/printers.h
Use cupsArray*() API to manage sorted list of printers and classes.
[thirdparty/cups.git] / scheduler / printers.h
1 /*
2 * "$Id$"
3 *
4 * Printer definitions for the Common UNIX Printing System (CUPS) scheduler.
5 *
6 * Copyright 1997-2005 by Easy Software Products, all rights reserved.
7 *
8 * These coded instructions, statements, and computer programs are the
9 * property of Easy Software Products and are protected by Federal
10 * copyright law. Distribution and use rights are outlined in the file
11 * "LICENSE.txt" which should have been included with this file. If this
12 * file is missing or damaged please contact Easy Software Products
13 * at:
14 *
15 * Attn: CUPS Licensing Information
16 * Easy Software Products
17 * 44141 Airport View Drive, Suite 204
18 * Hollywood, Maryland 20636 USA
19 *
20 * Voice: (301) 373-9600
21 * EMail: cups-info@cups.org
22 * WWW: http://www.cups.org
23 */
24
25 /*
26 * Quota data...
27 */
28
29 typedef struct
30 {
31 char username[33]; /* User data */
32 time_t next_update; /* Next update time */
33 int page_count, /* Count of pages */
34 k_count; /* Count of kilobytes */
35 } quota_t;
36
37
38 /*
39 * Printer/class information structure...
40 */
41
42 typedef struct printer_str
43 {
44 char *uri, /* Printer URI */
45 *hostname, /* Host printer resides on */
46 *name, /* Printer name */
47 *location, /* Location code */
48 *make_model, /* Make and model */
49 *info, /* Description */
50 *op_policy, /* Operation policy name */
51 *error_policy; /* Error policy */
52 cupsd_policy_t *op_policy_ptr; /* Pointer to operation policy */
53 int shared; /* Shared? */
54 int accepting; /* Accepting jobs? */
55 ipp_pstate_t state; /* Printer state */
56 char state_message[1024]; /* Printer state message */
57 int num_reasons; /* Number of printer-state-reasons */
58 char *reasons[16]; /* printer-state-reasons strings */
59 time_t state_time; /* Time at this state */
60 char *job_sheets[2]; /* Banners/job sheets */
61 cups_ptype_t type; /* Printer type (color, small, etc.) */
62 time_t browse_time; /* Last time update was sent/received */
63 char *device_uri; /* Device URI */
64 char *port_monitor; /* Port monitor */
65 int raw; /* Raw queue? */
66 mime_type_t *filetype; /* Pseudo-filetype for printer */
67 void *job; /* Current job in queue */
68 ipp_t *attrs; /* Attributes supported by this printer */
69 int num_printers, /* Number of printers in class */
70 last_printer; /* Last printer job was sent to */
71 struct printer_str **printers; /* Printers in class */
72 int quota_period, /* Period for quotas */
73 page_limit, /* Maximum number of pages */
74 k_limit, /* Maximum number of kilobytes */
75 num_quotas; /* Number of quota records */
76 quota_t *quotas; /* Quota records */
77 int deny_users, /* 1 = deny, 0 = allow */
78 num_users; /* Number of allowed/denied users */
79 const char **users; /* Allowed/denied users */
80 int num_history; /* Number of history collections */
81 ipp_t **history; /* History data */
82 int sequence_number; /* Increasing sequence number */
83 } printer_t;
84
85
86 /*
87 * Globals...
88 */
89
90 VAR ipp_t *CommonData VALUE(NULL);
91 /* Common printer object attrs */
92 VAR cups_array_t *Printers VALUE(NULL);
93 /* Printer list */
94 VAR printer_t *DefaultPrinter VALUE(NULL);
95 /* Default printer */
96 VAR char *DefaultPolicy VALUE(NULL);
97 /* Default policy name */
98 VAR cupsd_policy_t *DefaultPolicyPtr
99 VALUE(NULL);
100 /* Pointer to default policy */
101
102
103 /*
104 * Prototypes...
105 */
106
107 extern printer_t *AddPrinter(const char *name);
108 extern void AddPrinterFilter(printer_t *p, const char *filter);
109 extern void AddPrinterHistory(printer_t *p);
110 extern void AddPrinterUser(printer_t *p, const char *username);
111 extern quota_t *AddQuota(printer_t *p, const char *username);
112 extern void CreateCommonData(void);
113 extern void DeleteAllPrinters(void);
114 extern void DeletePrinter(printer_t *p, int update);
115 extern void DeletePrinterFilters(printer_t *p);
116 extern printer_t *FindDest(const char *name);
117 extern printer_t *FindPrinter(const char *name);
118 extern quota_t *FindQuota(printer_t *p, const char *username);
119 extern void FreePrinterUsers(printer_t *p);
120 extern void FreeQuotas(printer_t *p);
121 extern void LoadAllPrinters(void);
122 extern void SaveAllPrinters(void);
123 extern void SetPrinterAttrs(printer_t *p);
124 extern void SetPrinterReasons(printer_t *p, const char *s);
125 extern void SetPrinterState(printer_t *p, ipp_pstate_t s, int update);
126 #define StartPrinter(p,u) SetPrinterState((p), IPP_PRINTER_IDLE, (u))
127 extern void StopPrinter(printer_t *p, int update);
128 extern quota_t *UpdateQuota(printer_t *p, const char *username,
129 int pages, int k);
130 extern const char *ValidateDest(const char *hostname,
131 const char *resource,
132 cups_ptype_t *dtype,
133 printer_t **printer);
134 extern void WritePrintcap(void);
135
136 extern char *cupsdSanitizeURI(const char *uri, char *buffer,
137 int buflen);
138
139
140 /*
141 * End of "$Id$".
142 */