]> git.ipfire.org Git - thirdparty/cups.git/blame - scheduler/client.h
Merge pull request #1312 from weblate/weblate-cups-cups
[thirdparty/cups.git] / scheduler / client.h
CommitLineData
ef416fc2 1/*
5ec1fd3d 2 * Client definitions for the CUPS scheduler.
ef416fc2 3 *
ea5f7598 4 * Copyright © 2020-2025 by OpenPrinting.
4feb1fe2
MS
5 * Copyright © 2007-2018 by Apple Inc.
6 * Copyright © 1997-2007 by Easy Software Products, all rights reserved.
ef416fc2 7 *
4feb1fe2
MS
8 * Licensed under Apache License v2.0. See the file "LICENSE" for more
9 * information.
ef416fc2 10 */
11
f7deaa1a 12#ifdef HAVE_AUTHORIZATION_H
13# include <Security/Authorization.h>
14#endif /* HAVE_AUTHORIZATION_H */
15
b19ccc9e 16
ef416fc2 17/*
18 * HTTP client structure...
19 */
20
21struct cupsd_client_s
22{
996acce8
MS
23 int number; /* Connection number */
24 http_t *http; /* HTTP client connection */
ef416fc2 25 ipp_t *request, /* IPP request information */
26 *response; /* IPP response information */
27 cupsd_location_t *best; /* Best match for AAA */
dfd5680b 28 struct timeval start; /* Request start time */
ef416fc2 29 http_state_t operation; /* Request operation */
30 off_t bytes; /* Bytes transferred for this request */
4feb1fe2 31 int is_browser; /* Is the client a web browser? */
2fb76298 32 int type; /* AuthType for username */
3e7fe0ca
MS
33 char username[HTTP_MAX_VALUE],
34 /* Username from Authorization: line */
35 password[HTTP_MAX_VALUE],
36 /* Password from Authorization: line */
ea5f7598
MS
37 email[HTTP_MAX_VALUE],
38 /* EMail from OAuth Bearer token */
39 realname[HTTP_MAX_VALUE],
40 /* Real name from OAuth Bearer token */
41 autherror[HTTP_MAX_VALUE],
42 /* Authorization error, if any */
920047fd 43 uri[2048], /* Localized URL/URI for GET/PUT */
ef416fc2 44 *filename, /* Filename of output file */
45 *command, /* Command to run */
b86bc4cf 46 *options, /* Options for command */
47 *query_string; /* QUERY_STRING environment variable */
ef416fc2 48 int file; /* Input/output file */
49 int file_ready; /* Input ready on file/pipe? */
8dda6c2b
MS
50 int bg_pending; /* Background response pending? */
51 cupsd_printer_t *bg_printer; /* Background printer */
ef416fc2 52 int pipe_pid; /* Pipe process ID (or 0 if not a pipe) */
e200616a 53 http_status_t pipe_status; /* HTTP status from pipe process */
ef416fc2 54 int sent_header, /* Non-zero if sent HTTP header */
55 got_fields, /* Non-zero if all fields seen */
68b10830 56 header_used; /* Number of header bytes used */
9756c004 57 char header[4096]; /* Header from CGI program */
ef416fc2 58 cups_lang_t *language; /* Language to use */
ef416fc2 59 int auto_ssl; /* Automatic test for SSL/TLS */
996acce8 60 http_addr_t clientaddr; /* Client's server address */
f2534050
MS
61 char clientname[256];/* Client's server name for connection */
62 int clientport; /* Client's server port for connection */
ef416fc2 63 char servername[256];/* Server name for connection */
64 int serverport; /* Server port for connection */
f7deaa1a 65#ifdef HAVE_GSSAPI
97c9a8d7 66 int have_gss; /* Have GSS credentials? */
07ed0e9a 67 uid_t gss_uid; /* User ID for local prints */
f7deaa1a 68#endif /* HAVE_GSSAPI */
69#ifdef HAVE_AUTHORIZATION_H
70 AuthorizationRef authref; /* Authorization ref */
71#endif /* HAVE_AUTHORIZATION_H */
ef416fc2 72};
73
996acce8 74#define HTTP(con) ((con)->http)
ef416fc2 75
76
77/*
78 * HTTP listener structure...
79 */
80
81typedef struct
82{
83 int fd; /* File descriptor for this server */
84 http_addr_t address; /* Bind address of socket */
85 http_encryption_t encryption; /* To encrypt or not to encrypt... */
1166bf58 86#ifdef HAVE_ONDEMAND
441de8b2 87 int on_demand; /* Is this a socket from launchd/systemd/upstart? */
c187d9ab 88#endif /* HAVE_ONDEMAND */
ef416fc2 89} cupsd_listener_t;
90
91
92/*
93 * Globals...
94 */
95
996acce8
MS
96VAR int LastClientNumber VALUE(0),
97 /* Last client connection number */
f11a948a 98 LocalPort VALUE(631),
ef416fc2 99 /* Local port to use */
f11a948a
MS
100 RemotePort VALUE(0);
101 /* Remote port to use */
e3952d3e 102VAR http_encryption_t LocalEncryption VALUE(HTTP_ENCRYPTION_IF_REQUESTED);
ef416fc2 103 /* Local port encryption to use */
bd7854cb 104VAR cups_array_t *Listeners VALUE(NULL);
ef416fc2 105 /* Listening sockets */
76cd9e37
MS
106VAR time_t ListeningPaused VALUE(0);
107 /* Time when listening was paused */
3dfe78b3 108VAR cups_array_t *Clients VALUE(NULL),
ef416fc2 109 /* HTTP clients */
3dfe78b3
MS
110 *ActiveClients VALUE(NULL);
111 /* Active HTTP clients */
ef416fc2 112VAR char *ServerHeader VALUE(NULL);
113 /* Server header in requests */
114VAR int CGIPipes[2] VALUE2(-1,-1);
115 /* Pipes for CGI error/debug output */
116VAR cupsd_statbuf_t *CGIStatusBuffer VALUE(NULL);
117 /* Status buffer for pipes */
118
119
120/*
121 * Prototypes...
122 */
123
124extern void cupsdAcceptClient(cupsd_listener_t *lis);
125extern void cupsdCloseAllClients(void);
126extern int cupsdCloseClient(cupsd_client_t *con);
bd7854cb 127extern void cupsdDeleteAllListeners(void);
ef416fc2 128extern void cupsdPauseListening(void);
129extern int cupsdProcessIPPRequest(cupsd_client_t *con);
f7deaa1a 130extern void cupsdReadClient(cupsd_client_t *con);
ef416fc2 131extern void cupsdResumeListening(void);
132extern int cupsdSendCommand(cupsd_client_t *con, char *command,
133 char *options, int root);
f899b121 134extern int cupsdSendError(cupsd_client_t *con, http_status_t code,
135 int auth_type);
ef416fc2 136extern int cupsdSendHeader(cupsd_client_t *con, http_status_t code,
f899b121 137 char *type, int auth_type);
ef416fc2 138extern void cupsdShutdownClient(cupsd_client_t *con);
139extern void cupsdStartListening(void);
140extern void cupsdStopListening(void);
141extern void cupsdUpdateCGI(void);
f7deaa1a 142extern void cupsdWriteClient(cupsd_client_t *con);
ef416fc2 143
82cc1f9a
MS
144extern int cupsdEndTLS(cupsd_client_t *con);
145extern int cupsdStartTLS(cupsd_client_t *con);