]> git.ipfire.org Git - thirdparty/cups.git/blob - scheduler/client.h
Merge changes from CUPS 1.6svn-r10310.
[thirdparty/cups.git] / scheduler / client.h
1 /*
2 * "$Id: client.h 7935 2008-09-11 01:54:11Z mike $"
3 *
4 * Client definitions for the CUPS scheduler.
5 *
6 * Copyright 2007-2011 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_AUTHORIZATION_H
17 # include <Security/Authorization.h>
18 #endif /* HAVE_AUTHORIZATION_H */
19
20
21 /*
22 * HTTP client structure...
23 */
24
25 struct cupsd_client_s
26 {
27 http_t http; /* HTTP client connection */
28 ipp_t *request, /* IPP request information */
29 *response; /* IPP response information */
30 cupsd_location_t *best; /* Best match for AAA */
31 struct timeval start; /* Request start time */
32 http_state_t operation; /* Request operation */
33 off_t bytes; /* Bytes transferred for this request */
34 int type; /* AuthType for username */
35 char username[HTTP_MAX_VALUE],
36 /* Username from Authorization: line */
37 password[HTTP_MAX_VALUE],
38 /* Password from Authorization: line */
39 uri[HTTP_MAX_URI],
40 /* Localized URL/URI for GET/PUT */
41 *filename, /* Filename of output file */
42 *command, /* Command to run */
43 *options, /* Options for command */
44 *query_string; /* QUERY_STRING environment variable */
45 int file; /* Input/output file */
46 int file_ready; /* Input ready on file/pipe? */
47 int pipe_pid; /* Pipe process ID (or 0 if not a pipe) */
48 int sent_header, /* Non-zero if sent HTTP header */
49 got_fields, /* Non-zero if all fields seen */
50 header_used; /* Number of header bytes used */
51 char header[2048]; /* Header from CGI program */
52 cups_lang_t *language; /* Language to use */
53 #ifdef HAVE_SSL
54 int auto_ssl; /* Automatic test for SSL/TLS */
55 #endif /* HAVE_SSL */
56 http_addr_t clientaddr; /* Client address */
57 char servername[256];/* Server name for connection */
58 int serverport; /* Server port for connection */
59 #ifdef HAVE_GSSAPI
60 int have_gss; /* Have GSS credentials? */
61 uid_t gss_uid; /* User ID for local prints */
62 #endif /* HAVE_GSSAPI */
63 #ifdef HAVE_AUTHORIZATION_H
64 AuthorizationRef authref; /* Authorization ref */
65 #endif /* HAVE_AUTHORIZATION_H */
66 };
67
68 #define HTTP(con) &((con)->http)
69
70
71 /*
72 * HTTP listener structure...
73 */
74
75 typedef struct
76 {
77 int fd; /* File descriptor for this server */
78 http_addr_t address; /* Bind address of socket */
79 http_encryption_t encryption; /* To encrypt or not to encrypt... */
80 } cupsd_listener_t;
81
82
83 /*
84 * Globals...
85 */
86
87 VAR int ListenBackLog VALUE(SOMAXCONN),
88 /* Max backlog of pending connections */
89 LocalPort VALUE(631),
90 /* Local port to use */
91 RemotePort VALUE(0);
92 /* Remote port to use */
93 VAR http_encryption_t LocalEncryption VALUE(HTTP_ENCRYPT_IF_REQUESTED);
94 /* Local port encryption to use */
95 VAR cups_array_t *Listeners VALUE(NULL);
96 /* Listening sockets */
97 VAR time_t ListeningPaused VALUE(0);
98 /* Time when listening was paused */
99 VAR cups_array_t *Clients VALUE(NULL),
100 /* HTTP clients */
101 *ActiveClients VALUE(NULL);
102 /* Active HTTP clients */
103 VAR char *ServerHeader VALUE(NULL);
104 /* Server header in requests */
105 VAR int CGIPipes[2] VALUE2(-1,-1);
106 /* Pipes for CGI error/debug output */
107 VAR cupsd_statbuf_t *CGIStatusBuffer VALUE(NULL);
108 /* Status buffer for pipes */
109
110
111 /*
112 * Prototypes...
113 */
114
115 extern void cupsdAcceptClient(cupsd_listener_t *lis);
116 extern void cupsdCloseAllClients(void);
117 extern int cupsdCloseClient(cupsd_client_t *con);
118 extern void cupsdDeleteAllListeners(void);
119 extern int cupsdFlushHeader(cupsd_client_t *con);
120 extern void cupsdPauseListening(void);
121 extern int cupsdProcessIPPRequest(cupsd_client_t *con);
122 extern void cupsdReadClient(cupsd_client_t *con);
123 extern void cupsdResumeListening(void);
124 extern int cupsdSendCommand(cupsd_client_t *con, char *command,
125 char *options, int root);
126 extern int cupsdSendError(cupsd_client_t *con, http_status_t code,
127 int auth_type);
128 extern int cupsdSendHeader(cupsd_client_t *con, http_status_t code,
129 char *type, int auth_type);
130 extern void cupsdShutdownClient(cupsd_client_t *con);
131 extern void cupsdStartListening(void);
132 extern void cupsdStopListening(void);
133 extern void cupsdUpdateCGI(void);
134 extern void cupsdWriteClient(cupsd_client_t *con);
135
136
137 /*
138 * End of "$Id: client.h 7935 2008-09-11 01:54:11Z mike $".
139 */