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 * Licensed under Apache License v2.0. See the file "LICENSE" for more information.
10 #ifdef HAVE_AUTHORIZATION_H
11 # include <Security/Authorization.h>
12 #endif /* HAVE_AUTHORIZATION_H */
16 * HTTP client structure...
21 int number
; /* Connection number */
22 http_t
*http
; /* HTTP client connection */
23 ipp_t
*request
, /* IPP request information */
24 *response
; /* IPP response information */
25 cupsd_location_t
*best
; /* Best match for AAA */
26 struct timeval start
; /* Request start time */
27 http_state_t operation
; /* Request operation */
28 off_t bytes
; /* Bytes transferred for this request */
29 int type
; /* AuthType for username */
30 char username
[HTTP_MAX_VALUE
],
31 /* Username from Authorization: line */
32 password
[HTTP_MAX_VALUE
],
33 /* Password from Authorization: line */
35 /* Localized URL/URI for GET/PUT */
36 *filename
, /* Filename of output file */
37 *command
, /* Command to run */
38 *options
, /* Options for command */
39 *query_string
; /* QUERY_STRING environment variable */
40 int file
; /* Input/output file */
41 int file_ready
; /* Input ready on file/pipe? */
42 int pipe_pid
; /* Pipe process ID (or 0 if not a pipe) */
43 http_status_t pipe_status
; /* HTTP status from pipe process */
44 int sent_header
, /* Non-zero if sent HTTP header */
45 got_fields
, /* Non-zero if all fields seen */
46 header_used
; /* Number of header bytes used */
47 char header
[2048]; /* Header from CGI program */
48 cups_lang_t
*language
; /* Language to use */
50 int auto_ssl
; /* Automatic test for SSL/TLS */
52 http_addr_t clientaddr
; /* Client's server address */
53 char clientname
[256];/* Client's server name for connection */
54 int clientport
; /* Client's server port for connection */
55 char servername
[256];/* Server name for connection */
56 int serverport
; /* Server port for connection */
58 int have_gss
; /* Have GSS credentials? */
59 uid_t gss_uid
; /* User ID for local prints */
60 #endif /* HAVE_GSSAPI */
61 #ifdef HAVE_AUTHORIZATION_H
62 AuthorizationRef authref
; /* Authorization ref */
63 #endif /* HAVE_AUTHORIZATION_H */
66 #define HTTP(con) ((con)->http)
70 * HTTP listener structure...
75 int fd
; /* File descriptor for this server */
76 http_addr_t address
; /* Bind address of socket */
77 http_encryption_t encryption
; /* To encrypt or not to encrypt... */
79 int on_demand
; /* Is this a socket from launchd/systemd/upstart? */
80 #endif /* HAVE_ONDEMAND */
88 VAR
int LastClientNumber
VALUE(0),
89 /* Last client connection number */
90 ListenBackLog
VALUE(SOMAXCONN
),
91 /* Max backlog of pending connections */
93 /* Local port to use */
95 /* Remote port to use */
96 VAR http_encryption_t LocalEncryption
VALUE(HTTP_ENCRYPT_IF_REQUESTED
);
97 /* Local port encryption to use */
98 VAR cups_array_t
*Listeners
VALUE(NULL
);
99 /* Listening sockets */
100 VAR
time_t ListeningPaused
VALUE(0);
101 /* Time when listening was paused */
102 VAR cups_array_t
*Clients
VALUE(NULL
),
104 *ActiveClients
VALUE(NULL
);
105 /* Active HTTP clients */
106 VAR
char *ServerHeader
VALUE(NULL
);
107 /* Server header in requests */
108 VAR
int CGIPipes
[2] VALUE2(-1,-1);
109 /* Pipes for CGI error/debug output */
110 VAR cupsd_statbuf_t
*CGIStatusBuffer
VALUE(NULL
);
111 /* Status buffer for pipes */
118 extern void cupsdAcceptClient(cupsd_listener_t
*lis
);
119 extern void cupsdCloseAllClients(void);
120 extern int cupsdCloseClient(cupsd_client_t
*con
);
121 extern void cupsdDeleteAllListeners(void);
122 extern void cupsdPauseListening(void);
123 extern int cupsdProcessIPPRequest(cupsd_client_t
*con
);
124 extern void cupsdReadClient(cupsd_client_t
*con
);
125 extern void cupsdResumeListening(void);
126 extern int cupsdSendCommand(cupsd_client_t
*con
, char *command
,
127 char *options
, int root
);
128 extern int cupsdSendError(cupsd_client_t
*con
, http_status_t code
,
130 extern int cupsdSendHeader(cupsd_client_t
*con
, http_status_t code
,
131 char *type
, int auth_type
);
132 extern void cupsdShutdownClient(cupsd_client_t
*con
);
133 extern void cupsdStartListening(void);
134 extern void cupsdStopListening(void);
135 extern void cupsdUpdateCGI(void);
136 extern void cupsdWriteClient(cupsd_client_t
*con
);
139 extern int cupsdEndTLS(cupsd_client_t
*con
);
140 extern int cupsdStartTLS(cupsd_client_t
*con
);
141 #endif /* HAVE_SSL */