2 * Client definitions for the CUPS scheduler.
4 * Copyright © 2007-2018 by Apple Inc.
5 * Copyright © 1997-2007 by Easy Software Products, all rights reserved.
7 * Licensed under Apache License v2.0. See the file "LICENSE" for more
11 #ifdef HAVE_AUTHORIZATION_H
12 # include <Security/Authorization.h>
13 #endif /* HAVE_AUTHORIZATION_H */
17 * HTTP client structure...
22 int number
; /* Connection number */
23 http_t
*http
; /* HTTP client connection */
24 ipp_t
*request
, /* IPP request information */
25 *response
; /* IPP response information */
26 cupsd_location_t
*best
; /* Best match for AAA */
27 struct timeval start
; /* Request start time */
28 http_state_t operation
; /* Request operation */
29 off_t bytes
; /* Bytes transferred for this request */
30 int is_browser
; /* Is the client a web browser? */
31 int type
; /* AuthType for username */
32 char username
[HTTP_MAX_VALUE
],
33 /* Username from Authorization: line */
34 password
[HTTP_MAX_VALUE
],
35 /* Password from Authorization: line */
37 /* Localized URL/URI for GET/PUT */
38 *filename
, /* Filename of output file */
39 *command
, /* Command to run */
40 *options
, /* Options for command */
41 *query_string
; /* QUERY_STRING environment variable */
42 int file
; /* Input/output file */
43 int file_ready
; /* Input ready on file/pipe? */
44 int pipe_pid
; /* Pipe process ID (or 0 if not a pipe) */
45 http_status_t pipe_status
; /* HTTP status from pipe process */
46 int sent_header
, /* Non-zero if sent HTTP header */
47 got_fields
, /* Non-zero if all fields seen */
48 header_used
; /* Number of header bytes used */
49 char header
[2048]; /* Header from CGI program */
50 cups_lang_t
*language
; /* Language to use */
52 int auto_ssl
; /* Automatic test for SSL/TLS */
54 http_addr_t clientaddr
; /* Client's server address */
55 char clientname
[256];/* Client's server name for connection */
56 int clientport
; /* Client's server port for connection */
57 char servername
[256];/* Server name for connection */
58 int serverport
; /* Server port for connection */
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 */
68 #define HTTP(con) ((con)->http)
72 * HTTP listener structure...
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... */
81 int on_demand
; /* Is this a socket from launchd/systemd/upstart? */
82 #endif /* HAVE_ONDEMAND */
90 VAR
int LastClientNumber
VALUE(0),
91 /* Last client connection number */
92 ListenBackLog
VALUE(SOMAXCONN
),
93 /* Max backlog of pending connections */
95 /* Local port to use */
97 /* Remote port to use */
98 VAR http_encryption_t LocalEncryption
VALUE(HTTP_ENCRYPT_IF_REQUESTED
);
99 /* Local port encryption to use */
100 VAR cups_array_t
*Listeners
VALUE(NULL
);
101 /* Listening sockets */
102 VAR
time_t ListeningPaused
VALUE(0);
103 /* Time when listening was paused */
104 VAR cups_array_t
*Clients
VALUE(NULL
),
106 *ActiveClients
VALUE(NULL
);
107 /* Active HTTP clients */
108 VAR
char *ServerHeader
VALUE(NULL
);
109 /* Server header in requests */
110 VAR
int CGIPipes
[2] VALUE2(-1,-1);
111 /* Pipes for CGI error/debug output */
112 VAR cupsd_statbuf_t
*CGIStatusBuffer
VALUE(NULL
);
113 /* Status buffer for pipes */
120 extern void cupsdAcceptClient(cupsd_listener_t
*lis
);
121 extern void cupsdCloseAllClients(void);
122 extern int cupsdCloseClient(cupsd_client_t
*con
);
123 extern void cupsdDeleteAllListeners(void);
124 extern void cupsdPauseListening(void);
125 extern int cupsdProcessIPPRequest(cupsd_client_t
*con
);
126 extern void cupsdReadClient(cupsd_client_t
*con
);
127 extern void cupsdResumeListening(void);
128 extern int cupsdSendCommand(cupsd_client_t
*con
, char *command
,
129 char *options
, int root
);
130 extern int cupsdSendError(cupsd_client_t
*con
, http_status_t code
,
132 extern int cupsdSendHeader(cupsd_client_t
*con
, http_status_t code
,
133 char *type
, int auth_type
);
134 extern void cupsdShutdownClient(cupsd_client_t
*con
);
135 extern void cupsdStartListening(void);
136 extern void cupsdStopListening(void);
137 extern void cupsdUpdateCGI(void);
138 extern void cupsdWriteClient(cupsd_client_t
*con
);
141 extern int cupsdEndTLS(cupsd_client_t
*con
);
142 extern int cupsdStartTLS(cupsd_client_t
*con
);
143 #endif /* HAVE_SSL */