2 * Client definitions for the CUPS scheduler.
4 * Copyright 2007-2016 by Apple Inc.
5 * Copyright 1997-2007 by Easy Software Products, all rights reserved.
7 * These coded instructions, statements, and computer programs are the
8 * property of Apple Inc. and are protected by Federal copyright
9 * law. Distribution and use rights are outlined in the file "LICENSE.txt"
10 * which should have been included with this file. If this file is
11 * file is missing or damaged, see the license at "http://www.cups.org/".
14 #ifdef HAVE_AUTHORIZATION_H
15 # include <Security/Authorization.h>
16 #endif /* HAVE_AUTHORIZATION_H */
20 * HTTP client structure...
25 int number
; /* Connection number */
26 http_t
*http
; /* HTTP client connection */
27 ipp_t
*request
, /* IPP request information */
28 *response
; /* IPP response information */
29 cupsd_location_t
*best
; /* Best match for AAA */
30 struct timeval start
; /* Request start time */
31 http_state_t operation
; /* Request operation */
32 off_t bytes
; /* Bytes transferred for this request */
33 int type
; /* AuthType for username */
34 char username
[HTTP_MAX_VALUE
],
35 /* Username from Authorization: line */
36 password
[HTTP_MAX_VALUE
],
37 /* Password from Authorization: line */
39 /* Localized URL/URI for GET/PUT */
40 *filename
, /* Filename of output file */
41 *command
, /* Command to run */
42 *options
, /* Options for command */
43 *query_string
; /* QUERY_STRING environment variable */
44 int file
; /* Input/output file */
45 int file_ready
; /* Input ready on file/pipe? */
46 int pipe_pid
; /* Pipe process ID (or 0 if not a pipe) */
47 http_status_t pipe_status
; /* HTTP status from pipe process */
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 */
54 int auto_ssl
; /* Automatic test for SSL/TLS */
56 http_addr_t clientaddr
; /* Client's server address */
57 char clientname
[256];/* Client's server name for connection */
58 int clientport
; /* Client's server port for connection */
59 char servername
[256];/* Server name for connection */
60 int serverport
; /* Server port for connection */
62 int have_gss
; /* Have GSS credentials? */
63 uid_t gss_uid
; /* User ID for local prints */
64 #endif /* HAVE_GSSAPI */
65 #ifdef HAVE_AUTHORIZATION_H
66 AuthorizationRef authref
; /* Authorization ref */
67 #endif /* HAVE_AUTHORIZATION_H */
70 #define HTTP(con) ((con)->http)
74 * HTTP listener structure...
79 int fd
; /* File descriptor for this server */
80 http_addr_t address
; /* Bind address of socket */
81 http_encryption_t encryption
; /* To encrypt or not to encrypt... */
83 int on_demand
; /* Is this a socket from launchd/systemd/upstart? */
84 #endif /* HAVE_ONDEMAND */
92 VAR
int LastClientNumber
VALUE(0),
93 /* Last client connection number */
94 ListenBackLog
VALUE(SOMAXCONN
),
95 /* Max backlog of pending connections */
97 /* Local port to use */
99 /* Remote port to use */
100 VAR http_encryption_t LocalEncryption
VALUE(HTTP_ENCRYPT_IF_REQUESTED
);
101 /* Local port encryption to use */
102 VAR cups_array_t
*Listeners
VALUE(NULL
);
103 /* Listening sockets */
104 VAR
time_t ListeningPaused
VALUE(0);
105 /* Time when listening was paused */
106 VAR cups_array_t
*Clients
VALUE(NULL
),
108 *ActiveClients
VALUE(NULL
);
109 /* Active HTTP clients */
110 VAR
char *ServerHeader
VALUE(NULL
);
111 /* Server header in requests */
112 VAR
int CGIPipes
[2] VALUE2(-1,-1);
113 /* Pipes for CGI error/debug output */
114 VAR cupsd_statbuf_t
*CGIStatusBuffer
VALUE(NULL
);
115 /* Status buffer for pipes */
122 extern void cupsdAcceptClient(cupsd_listener_t
*lis
);
123 extern void cupsdCloseAllClients(void);
124 extern int cupsdCloseClient(cupsd_client_t
*con
);
125 extern void cupsdDeleteAllListeners(void);
126 extern void cupsdPauseListening(void);
127 extern int cupsdProcessIPPRequest(cupsd_client_t
*con
);
128 extern void cupsdReadClient(cupsd_client_t
*con
);
129 extern void cupsdResumeListening(void);
130 extern int cupsdSendCommand(cupsd_client_t
*con
, char *command
,
131 char *options
, int root
);
132 extern int cupsdSendError(cupsd_client_t
*con
, http_status_t code
,
134 extern int cupsdSendHeader(cupsd_client_t
*con
, http_status_t code
,
135 char *type
, int auth_type
);
136 extern void cupsdShutdownClient(cupsd_client_t
*con
);
137 extern void cupsdStartListening(void);
138 extern void cupsdStopListening(void);
139 extern void cupsdUpdateCGI(void);
140 extern void cupsdWriteClient(cupsd_client_t
*con
);
143 extern int cupsdEndTLS(cupsd_client_t
*con
);
144 extern int cupsdStartTLS(cupsd_client_t
*con
);
145 #endif /* HAVE_SSL */