Blame scheduler/client.h

Packit 2fc92b
/*
Packit 2fc92b
 * Client definitions for the CUPS scheduler.
Packit 2fc92b
 *
Packit 2fc92b
 * Copyright 2007-2016 by Apple Inc.
Packit 2fc92b
 * Copyright 1997-2007 by Easy Software Products, all rights reserved.
Packit 2fc92b
 *
Packit 2fc92b
 * These coded instructions, statements, and computer programs are the
Packit 2fc92b
 * property of Apple Inc. and are protected by Federal copyright
Packit 2fc92b
 * law.  Distribution and use rights are outlined in the file "LICENSE.txt"
Packit 2fc92b
 * which should have been included with this file.  If this file is
Packit 2fc92b
 * missing or damaged, see the license at "http://www.cups.org/".
Packit 2fc92b
 */
Packit 2fc92b
Packit 2fc92b
#ifdef HAVE_AUTHORIZATION_H
Packit 2fc92b
#  include <Security/Authorization.h>
Packit 2fc92b
#endif /* HAVE_AUTHORIZATION_H */
Packit 2fc92b
Packit 2fc92b
Packit 2fc92b
/*
Packit 2fc92b
 * HTTP client structure...
Packit 2fc92b
 */
Packit 2fc92b
Packit 2fc92b
struct cupsd_client_s
Packit 2fc92b
{
Packit 2fc92b
  int			number;		/* Connection number */
Packit 2fc92b
  http_t		*http;		/* HTTP client connection */
Packit 2fc92b
  ipp_t			*request,	/* IPP request information */
Packit 2fc92b
			*response;	/* IPP response information */
Packit 2fc92b
  cupsd_location_t	*best;		/* Best match for AAA */
Packit 2fc92b
  struct timeval	start;		/* Request start time */
Packit 2fc92b
  http_state_t		operation;	/* Request operation */
Packit 2fc92b
  off_t			bytes;		/* Bytes transferred for this request */
Packit 2fc92b
  int			type;		/* AuthType for username */
Packit 2fc92b
  char			username[HTTP_MAX_VALUE],
Packit 2fc92b
					/* Username from Authorization: line */
Packit 2fc92b
			password[HTTP_MAX_VALUE],
Packit 2fc92b
					/* Password from Authorization: line */
Packit 2fc92b
			uri[HTTP_MAX_URI],
Packit 2fc92b
					/* Localized URL/URI for GET/PUT */
Packit 2fc92b
			*filename,	/* Filename of output file */
Packit 2fc92b
			*command,	/* Command to run */
Packit 2fc92b
			*options,	/* Options for command */
Packit 2fc92b
			*query_string;	/* QUERY_STRING environment variable */
Packit 2fc92b
  int			file;		/* Input/output file */
Packit 2fc92b
  int			file_ready;	/* Input ready on file/pipe? */
Packit 2fc92b
  int			pipe_pid;	/* Pipe process ID (or 0 if not a pipe) */
Packit 2fc92b
  http_status_t		pipe_status;	/* HTTP status from pipe process */
Packit 2fc92b
  int			sent_header,	/* Non-zero if sent HTTP header */
Packit 2fc92b
			got_fields,	/* Non-zero if all fields seen */
Packit 2fc92b
			header_used;	/* Number of header bytes used */
Packit 2fc92b
  char			header[2048];	/* Header from CGI program */
Packit 2fc92b
  cups_lang_t		*language;	/* Language to use */
Packit 2fc92b
#ifdef HAVE_SSL
Packit 2fc92b
  int			auto_ssl;	/* Automatic test for SSL/TLS */
Packit 2fc92b
#endif /* HAVE_SSL */
Packit 2fc92b
  http_addr_t		clientaddr;	/* Client's server address */
Packit 2fc92b
  char			clientname[256];/* Client's server name for connection */
Packit 2fc92b
  int			clientport;	/* Client's server port for connection */
Packit 2fc92b
  char			servername[256];/* Server name for connection */
Packit 2fc92b
  int			serverport;	/* Server port for connection */
Packit 2fc92b
#ifdef HAVE_GSSAPI
Packit 2fc92b
  int			have_gss;	/* Have GSS credentials? */
Packit 2fc92b
  uid_t			gss_uid;	/* User ID for local prints */
Packit 2fc92b
#endif /* HAVE_GSSAPI */
Packit 2fc92b
#ifdef HAVE_AUTHORIZATION_H
Packit 2fc92b
  AuthorizationRef	authref;	/* Authorization ref */
Packit 2fc92b
#endif /* HAVE_AUTHORIZATION_H */
Packit 2fc92b
};
Packit 2fc92b
Packit 2fc92b
#define HTTP(con) ((con)->http)
Packit 2fc92b
Packit 2fc92b
Packit 2fc92b
/*
Packit 2fc92b
 * HTTP listener structure...
Packit 2fc92b
 */
Packit 2fc92b
Packit 2fc92b
typedef struct
Packit 2fc92b
{
Packit 2fc92b
  int			fd;		/* File descriptor for this server */
Packit 2fc92b
  http_addr_t		address;	/* Bind address of socket */
Packit 2fc92b
  http_encryption_t	encryption;	/* To encrypt or not to encrypt... */
Packit 2fc92b
#ifdef HAVE_ONDEMAND
Packit 2fc92b
  int			on_demand;	/* Is this a socket from launchd/systemd/upstart? */
Packit 2fc92b
#endif /* HAVE_ONDEMAND */
Packit 2fc92b
} cupsd_listener_t;
Packit 2fc92b
Packit 2fc92b
Packit 2fc92b
/*
Packit 2fc92b
 * Globals...
Packit 2fc92b
 */
Packit 2fc92b
Packit 2fc92b
VAR int			LastClientNumber VALUE(0),
Packit 2fc92b
					/* Last client connection number */
Packit 2fc92b
			ListenBackLog	VALUE(SOMAXCONN),
Packit 2fc92b
					/* Max backlog of pending connections */
Packit 2fc92b
			LocalPort	VALUE(631),
Packit 2fc92b
					/* Local port to use */
Packit 2fc92b
			RemotePort	VALUE(0);
Packit 2fc92b
					/* Remote port to use */
Packit 2fc92b
VAR http_encryption_t	LocalEncryption	VALUE(HTTP_ENCRYPT_IF_REQUESTED);
Packit 2fc92b
					/* Local port encryption to use */
Packit 2fc92b
VAR cups_array_t	*Listeners	VALUE(NULL);
Packit 2fc92b
					/* Listening sockets */
Packit 2fc92b
VAR time_t		ListeningPaused	VALUE(0);
Packit 2fc92b
					/* Time when listening was paused */
Packit 2fc92b
VAR cups_array_t	*Clients	VALUE(NULL),
Packit 2fc92b
					/* HTTP clients */
Packit 2fc92b
			*ActiveClients	VALUE(NULL);
Packit 2fc92b
					/* Active HTTP clients */
Packit 2fc92b
VAR char		*ServerHeader	VALUE(NULL);
Packit 2fc92b
					/* Server header in requests */
Packit 2fc92b
VAR int			CGIPipes[2]	VALUE2(-1,-1);
Packit 2fc92b
					/* Pipes for CGI error/debug output */
Packit 2fc92b
VAR cupsd_statbuf_t	*CGIStatusBuffer VALUE(NULL);
Packit 2fc92b
					/* Status buffer for pipes */
Packit 2fc92b
Packit 2fc92b
Packit 2fc92b
/*
Packit 2fc92b
 * Prototypes...
Packit 2fc92b
 */
Packit 2fc92b
Packit 2fc92b
extern void	cupsdAcceptClient(cupsd_listener_t *lis);
Packit 2fc92b
extern void	cupsdCloseAllClients(void);
Packit 2fc92b
extern int	cupsdCloseClient(cupsd_client_t *con);
Packit 2fc92b
extern void	cupsdDeleteAllListeners(void);
Packit 2fc92b
extern void	cupsdPauseListening(void);
Packit 2fc92b
extern int	cupsdProcessIPPRequest(cupsd_client_t *con);
Packit 2fc92b
extern void	cupsdReadClient(cupsd_client_t *con);
Packit 2fc92b
extern void	cupsdResumeListening(void);
Packit 2fc92b
extern int	cupsdSendCommand(cupsd_client_t *con, char *command,
Packit 2fc92b
		                 char *options, int root);
Packit 2fc92b
extern int	cupsdSendError(cupsd_client_t *con, http_status_t code,
Packit 2fc92b
		               int auth_type);
Packit 2fc92b
extern int	cupsdSendHeader(cupsd_client_t *con, http_status_t code,
Packit 2fc92b
		                char *type, int auth_type);
Packit 2fc92b
extern void	cupsdShutdownClient(cupsd_client_t *con);
Packit 2fc92b
extern void	cupsdStartListening(void);
Packit 2fc92b
extern void	cupsdStopListening(void);
Packit 2fc92b
extern void	cupsdUpdateCGI(void);
Packit 2fc92b
extern void	cupsdWriteClient(cupsd_client_t *con);
Packit 2fc92b
Packit 2fc92b
#ifdef HAVE_SSL
Packit 2fc92b
extern int	cupsdEndTLS(cupsd_client_t *con);
Packit 2fc92b
extern int	cupsdStartTLS(cupsd_client_t *con);
Packit 2fc92b
#endif /* HAVE_SSL */