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