2 * "$Id: client.c,v 1.5 1999/02/26 15:11:11 mike Exp $"
4 * Client routines for the Common UNIX Printing System (CUPS) scheduler.
6 * Copyright 1997-1999 by Easy Software Products, all rights reserved.
8 * These coded instructions, statements, and computer programs are the
9 * property of Easy Software Products and are protected by Federal
10 * copyright law. Distribution and use rights are outlined in the file
11 * "LICENSE.txt" which should have been included with this file. If this
12 * file is missing or damaged please contact Easy Software Products
15 * Attn: CUPS Licensing Information
16 * Easy Software Products
17 * 44145 Airport View Drive, Suite 204
18 * Hollywood, Maryland 20636-3111 USA
20 * Voice: (301) 373-9603
21 * EMail: cups-info@cups.org
22 * WWW: http://www.cups.org
26 * AcceptClient() - Accept a new client.
27 * CloseAllClients() - Close all remote clients immediately.
28 * CloseClient() - Close a remote client.
29 * ReadClient() - Read data from a client.
30 * SendCommand() - Send output from a command via HTTP.
31 * SendError() - Send an error message via HTTP.
32 * SendFile() - Send a file via HTTP.
33 * SendHeader() - Send an HTTP request.
34 * StartListening() - Create all listening sockets...
35 * StopListening() - Close all listening sockets...
36 * WriteClient() - Write data to a client as needed.
37 * check_if_modified() - Decode an "If-Modified-Since" line.
38 * decode_basic_auth() - Decode a Basic authorization string.
39 * get_file() - Get a filename and state info.
40 * pipe_command() - Pipe the output of a command to the remote client.
41 * process_ipp_request() - Process an incoming IPP request...
42 * send_ipp_error() - Send an error status back to the IPP client.
43 * sigpipe_handler() - Handle 'broken pipe' signals from lost network
48 * Include necessary headers...
52 #include <cups/debug.h>
59 static int check_if_modified(client_t
*con
, struct stat
*filestats
);
60 static void decode_basic_auth(client_t
*con
);
61 static char *get_file(client_t
*con
, struct stat
*filestats
);
62 static int pipe_command(client_t
*con
, int infile
, int *outfile
, char *command
, char *options
);
63 static void process_ipp_request(client_t
*con
);
64 static void send_ipp_error(client_t
*con
, ipp_status_t status
);
65 static void sigpipe_handler(int sig
);
68 static char *get_extension(char *filename
);
69 static char *get_type(char *extension
);
73 * 'AcceptClient()' - Accept a new client.
77 AcceptClient(listener_t
*lis
) /* I - Listener socket */
79 int i
; /* Looping var */
80 int val
; /* Parameter value */
81 client_t
*con
; /* New client pointer */
82 unsigned address
;/* Address of client */
83 struct hostent
*host
; /* Host entry for address */
87 * Get a pointer to the next available client...
90 con
= Clients
+ NumClients
;
92 memset(con
, 0, sizeof(client_t
));
93 con
->http
.activity
= time(NULL
);
96 * Accept the client and get the remote address...
99 val
= sizeof(struct sockaddr_in
);
101 if ((con
->http
.fd
= accept(lis
->fd
, (struct sockaddr
*)&(con
->http
.hostaddr
), &val
)) < 0)
103 LogMessage(LOG_ERROR
, "accept() failed - %s.", strerror(errno
));
108 * Get the hostname or format the IP address as needed...
111 address
= ntohl(con
->http
.hostaddr
.sin_addr
.s_addr
);
114 host
= gethostbyaddr(&address
, sizeof(address
), AF_INET
);
119 sprintf(con
->http
.hostname
, "%d.%d.%d.%d", (address
>> 24) & 255,
120 (address
>> 16) & 255, (address
>> 8) & 255, address
& 255);
122 strncpy(con
->http
.hostname
, host
->h_name
, sizeof(con
->http
.hostname
) - 1);
124 LogMessage(LOG_INFO
, "accept() %d from %s.", con
->http
.fd
, con
->http
.hostname
);
127 * Add the socket to the select() input mask.
130 fcntl(con
->http
.fd
, F_SETFD
, fcntl(con
->http
.fd
, F_GETFD
) | FD_CLOEXEC
);
132 FD_SET(con
->http
.fd
, &InputSet
);
137 * Temporarily suspend accept()'s until we lose a client...
140 if (NumClients
== MAX_CLIENTS
)
141 for (i
= 0; i
< NumListeners
; i
++)
142 FD_CLR(Listeners
[i
].fd
, &InputSet
);
147 * 'CloseAllClients()' - Close all remote clients immediately.
151 CloseAllClients(void)
153 while (NumClients
> 0)
154 CloseClient(Clients
);
159 * 'CloseClient()' - Close a remote client.
163 CloseClient(client_t
*con
) /* I - Client to close */
165 int i
; /* Looping var */
166 int status
; /* Exit status of pipe command */
169 LogMessage(LOG_INFO
, "CloseClient() %d", con
->http
.fd
);
172 * Close the socket and clear the file from the input set for select()...
175 #if defined(WIN32) || defined(__EMX__)
177 * Microsoft Windows and IBM OS/2 don't have a unified IO system...
180 closesocket(con
->http
.fd
);
187 #endif /* WIN32 || __EMX__ */
189 for (i
= 0; i
< NumListeners
; i
++)
190 FD_SET(Listeners
[i
].fd
, &InputSet
);
192 FD_CLR(con
->http
.fd
, &InputSet
);
193 if (con
->pipe_pid
!= 0)
194 FD_CLR(con
->file
, &InputSet
);
195 FD_CLR(con
->http
.fd
, &OutputSet
);
198 * If we have a data file open, close it...
205 kill(con
->pipe_pid
, SIGKILL
);
206 waitpid(con
->pipe_pid
, &status
, WNOHANG
);
213 * Compact the list of clients as necessary...
218 if (con
< (Clients
+ NumClients
))
219 memcpy(con
, con
+ 1, (Clients
+ NumClients
- con
) * sizeof(client_t
));
224 * 'ReadClient()' - Read data from a client.
227 int /* O - 1 on success, 0 on error */
228 ReadClient(client_t
*con
) /* I - Client to read from */
230 char line
[8192], /* Line from client... */
231 operation
[64], /* Operation code from socket */
232 version
[64]; /* HTTP version number string */
233 int major
, minor
; /* HTTP version numbers */
234 http_status_t status
; /* Transfer status */
235 int bytes
; /* Number of bytes to POST */
236 char *filename
, /* Name of file for GET/HEAD */
237 *extension
, /* Extension of file */
238 *type
; /* MIME type */
239 struct stat filestats
; /* File information */
240 char command
[1024], /* Command to run */
241 *options
; /* Options/CGI data */
244 status
= HTTP_CONTINUE
;
246 switch (con
->http
.state
)
250 * See if we've received a request line...
253 if (httpGets(line
, sizeof(line
) - 1, HTTP(con
)) == NULL
)
260 * Ignore blank request lines...
267 * Clear other state variables...
270 httpClearFields(HTTP(con
));
272 con
->http
.activity
= time(NULL
);
273 con
->http
.version
= HTTP_1_0
;
274 con
->http
.keep_alive
= HTTP_KEEPALIVE_OFF
;
275 con
->http
.data_encoding
= HTTP_ENCODE_LENGTH
;
276 con
->http
.data_remaining
= 0;
277 con
->operation
= HTTP_WAITING
;
281 con
->username
[0] = '\0';
282 con
->password
[0] = '\0';
285 if (con
->language
!= NULL
)
287 cupsLangFree(con
->language
);
288 con
->language
= NULL
;
292 * Grab the request line...
295 switch (sscanf(line
, "%63s%1023s%s", operation
, con
->uri
, version
))
298 SendError(con
, HTTP_BAD_REQUEST
);
302 con
->http
.version
= HTTP_0_9
;
305 if (sscanf(version
, "HTTP/%d.%d", &major
, &minor
) != 2)
307 SendError(con
, HTTP_BAD_REQUEST
);
314 con
->http
.version
= (http_version_t
)(major
* 100 + minor
);
315 if (con
->http
.version
== HTTP_1_1
)
316 con
->http
.keep_alive
= HTTP_KEEPALIVE_ON
;
318 con
->http
.keep_alive
= HTTP_KEEPALIVE_OFF
;
322 SendError(con
, HTTP_NOT_SUPPORTED
);
330 * Process the request...
333 if (strcmp(operation
, "GET") == 0)
334 con
->http
.state
= HTTP_GET
;
335 else if (strcmp(operation
, "PUT") == 0)
336 con
->http
.state
= HTTP_PUT
;
337 else if (strcmp(operation
, "POST") == 0)
338 con
->http
.state
= HTTP_POST
;
339 else if (strcmp(operation
, "DELETE") == 0)
340 con
->http
.state
= HTTP_DELETE
;
341 else if (strcmp(operation
, "TRACE") == 0)
342 con
->http
.state
= HTTP_TRACE
;
343 else if (strcmp(operation
, "CLOSE") == 0)
344 con
->http
.state
= HTTP_CLOSE
;
345 else if (strcmp(operation
, "OPTIONS") == 0)
346 con
->http
.state
= HTTP_OPTIONS
;
347 else if (strcmp(operation
, "HEAD") == 0)
348 con
->http
.state
= HTTP_HEAD
;
351 SendError(con
, HTTP_BAD_REQUEST
);
356 con
->start
= time(NULL
);
357 con
->operation
= con
->http
.state
;
359 LogMessage(LOG_INFO
, "ReadClient() %d %s %s HTTP/%d.%d", con
->http
.fd
,
361 con
->http
.version
/ 100, con
->http
.version
% 100);
363 con
->http
.status
= HTTP_OK
;
374 * Parse incoming parameters until the status changes...
377 status
= httpUpdate(HTTP(con
));
379 if (status
!= HTTP_OK
&& status
!= HTTP_CONTINUE
)
381 SendError(con
, HTTP_BAD_REQUEST
);
389 * Handle new transfers...
392 if (status
== HTTP_OK
)
394 con
->language
= cupsLangGet(con
->http
.fields
[HTTP_FIELD_ACCEPT_LANGUAGE
]);
396 decode_basic_auth(con
);
398 if (con
->http
.fields
[HTTP_FIELD_HOST
][0] == '\0' &&
399 con
->http
.version
>= HTTP_1_0
)
401 if (!SendError(con
, HTTP_BAD_REQUEST
))
407 else if (strncmp(con
->uri
, "..", 2) == 0)
410 * Protect against malicious users!
413 if (!SendError(con
, HTTP_FORBIDDEN
))
419 else if (con
->uri
[0] != '/')
422 * Don't allow proxying (yet)...
425 if (!SendError(con
, HTTP_METHOD_NOT_ALLOWED
))
431 else if ((status
= IsAuthorized(con
)) != HTTP_OK
)
433 if (!SendError(con
, status
))
439 else switch (con
->http
.state
)
442 if (strncmp(con
->uri
, "/printers", 9) == 0 ||
443 strncmp(con
->uri
, "/classes", 8) == 0 ||
444 strncmp(con
->uri
, "/jobs", 5) == 0)
450 if (strncmp(con
->uri
, "/printers", 9) == 0)
452 sprintf(command
, "%s/cgi-bin/printers", ServerRoot
);
453 options
= con
->uri
+ 9;
455 else if (strncmp(con
->uri
, "/classes", 8) == 0)
457 sprintf(command
, "%s/cgi-bin/classes", ServerRoot
);
458 options
= con
->uri
+ 8;
462 sprintf(command
, "%s/cgi-bin/jobs", ServerRoot
);
463 options
= con
->uri
+ 5;
469 if (!SendCommand(con
, command
, options
))
471 if (!SendError(con
, HTTP_NOT_FOUND
))
478 LogRequest(con
, HTTP_OK
);
480 if (con
->http
.version
<= HTTP_1_0
)
481 con
->http
.keep_alive
= HTTP_KEEPALIVE_OFF
;
489 if ((filename
= get_file(con
, &filestats
)) == NULL
)
491 if (!SendError(con
, HTTP_NOT_FOUND
))
497 else if (!check_if_modified(con
, &filestats
))
499 if (!SendError(con
, HTTP_NOT_MODIFIED
))
507 extension
= get_extension(filename
);
508 type
= get_type(extension
);
510 if (!SendFile(con
, HTTP_OK
, filename
, type
, &filestats
))
519 case HTTP_POST_RECV
:
521 * See what kind of POST request this is; for IPP requests the
522 * content-type field will be "application/ipp"...
525 httpGetLength(&(con
->http
));
527 if (strcmp(con
->http
.fields
[HTTP_FIELD_CONTENT_TYPE
], "application/ipp") == 0)
528 con
->request
= ippNew();
529 else if (strcmp(con
->http
.fields
[HTTP_FIELD_CONTENT_TYPE
], "application/ipp") == 0 &&
530 (strncmp(con
->uri
, "/printers", 9) == 0 ||
531 strncmp(con
->uri
, "/classes", 8) == 0 ||
532 strncmp(con
->uri
, "/jobs", 5) == 0))
538 if (strncmp(con
->uri
, "/printers", 9) == 0)
540 sprintf(command
, "%s/cgi-bin/printers", ServerRoot
);
541 options
= con
->uri
+ 9;
543 else if (strncmp(con
->uri
, "/classes", 8) == 0)
545 sprintf(command
, "%s/cgi-bin/classes", ServerRoot
);
546 options
= con
->uri
+ 8;
550 sprintf(command
, "%s/cgi-bin/jobs", ServerRoot
);
551 options
= con
->uri
+ 5;
557 if (!SendCommand(con
, command
, options
))
559 if (!SendError(con
, HTTP_NOT_FOUND
))
566 LogRequest(con
, HTTP_OK
);
568 if (con
->http
.version
<= HTTP_1_0
)
569 con
->http
.keep_alive
= HTTP_KEEPALIVE_OFF
;
571 else if (!SendError(con
, HTTP_UNAUTHORIZED
))
581 SendError(con
, HTTP_NOT_IMPLEMENTED
);
588 if (strncmp(con
->uri
, "/printers/", 10) == 0 ||
589 strncmp(con
->uri
, "/classes/", 9) == 0 ||
590 strncmp(con
->uri
, "/jobs/", 6) == 0)
596 if (!SendHeader(con
, HTTP_OK
, "text/html"))
602 if (httpPrintf(HTTP(con
), "\r\n") < 0)
608 LogRequest(con
, HTTP_OK
);
610 else if ((filename
= get_file(con
, &filestats
)) == NULL
)
612 if (!SendHeader(con
, HTTP_NOT_FOUND
, "text/html"))
618 LogRequest(con
, HTTP_NOT_FOUND
);
620 else if (!check_if_modified(con
, &filestats
))
622 if (!SendError(con
, HTTP_NOT_MODIFIED
))
628 LogRequest(con
, HTTP_NOT_MODIFIED
);
636 extension
= get_extension(filename
);
637 type
= get_type(extension
);
639 if (!SendHeader(con
, HTTP_OK
, type
))
645 if (httpPrintf(HTTP(con
), "Last-Modified: %s\r\n",
646 httpGetDateString(filestats
.st_mtime
)) < 0)
652 if (httpPrintf(HTTP(con
), "Content-Length: %d\r\n",
653 filestats
.st_size
) < 0)
659 LogRequest(con
, HTTP_OK
);
662 if (send(con
->http
.fd
, "\r\n", 2, 0) < 0)
668 con
->http
.state
= HTTP_WAITING
;
674 * Handle any incoming data...
677 switch (con
->http
.state
)
682 case HTTP_POST_RECV
:
683 LogMessage(LOG_DEBUG
, "ReadClient() %d con->data_encoding = %s con->data_remaining = %d\n",
685 con
->http
.data_encoding
== HTTP_ENCODE_CHUNKED
? "chunked" : "length",
686 con
->http
.data_remaining
);
688 if (con
->request
!= NULL
)
691 * Grab any request data from the connection...
694 if (ippRead(&(con
->http
), con
->request
) != IPP_DATA
)
698 * Then create a file as needed for the request data...
701 if (con
->file
== 0 &&
702 (con
->http
.data_remaining
> 0 ||
703 con
->http
.data_encoding
== HTTP_ENCODE_CHUNKED
))
705 sprintf(con
->filename
, "%s/requests/XXXXXX", ServerRoot
);
706 con
->file
= mkstemp(con
->filename
);
708 LogMessage(LOG_INFO
, "ReadClient() %d REQUEST %s", con
->http
.fd
,
713 if (!SendError(con
, HTTP_REQUEST_TOO_LARGE
))
722 if ((bytes
= httpRead(HTTP(con
), line
, sizeof(line
))) < 0)
731 LogMessage(LOG_DEBUG
, "ReadClient() %d writing %d bytes", bytes
);
733 if (write(con
->file
, line
, bytes
) < bytes
)
736 unlink(con
->filename
);
738 if (!SendError(con
, HTTP_REQUEST_TOO_LARGE
))
746 if (con
->http
.state
== HTTP_POST_SEND
)
751 process_ipp_request(con
);
756 if (!con
->http
.keep_alive
&& con
->http
.state
== HTTP_WAITING
)
767 * 'SendCommand()' - Send output from a command via HTTP.
771 SendCommand(client_t
*con
,
775 con
->pipe_pid
= pipe_command(con
, 0, &(con
->file
), command
, options
);
777 LogMessage(LOG_DEBUG
, "SendCommand() %d command=\"%s\" file=%d pipe_pid=%d",
778 con
->http
.fd
, command
, con
->file
, con
->pipe_pid
);
780 if (con
->pipe_pid
== 0)
783 fcntl(con
->file
, F_SETFD
, fcntl(con
->file
, F_GETFD
) | FD_CLOEXEC
);
785 FD_SET(con
->file
, &InputSet
);
786 FD_SET(con
->http
.fd
, &OutputSet
);
788 if (!SendHeader(con
, HTTP_OK
, "text/html"))
791 if (con
->http
.version
== HTTP_1_1
)
793 con
->http
.data_encoding
= HTTP_ENCODE_CHUNKED
;
795 if (httpPrintf(HTTP(con
), "Transfer-Encoding: chunked\r\n") < 0)
799 if (httpPrintf(HTTP(con
), "\r\n") < 0)
807 * 'SendError()' - Send an error message via HTTP.
810 int /* O - 1 if successful, 0 otherwise */
811 SendError(client_t
*con
, /* I - Connection */
812 http_status_t code
) /* I - Error code */
814 char message
[1024]; /* Text version of error code */
818 * Put the request in the access_log file...
821 LogRequest(con
, code
);
824 * To work around bugs in some proxies, don't use Keep-Alive for some
828 if (code
>= HTTP_BAD_REQUEST
)
829 con
->http
.keep_alive
= HTTP_KEEPALIVE_OFF
;
832 * Send an error message back to the client. If the error code is a
833 * 400 or 500 series, make sure the message contains some text, too!
836 if (!SendHeader(con
, code
, NULL
))
839 if (code
== HTTP_UNAUTHORIZED
)
841 if (httpPrintf(HTTP(con
), "WWW-Authenticate: Basic realm=\"CUPS\"\r\n") < 0)
845 if (con
->http
.version
>= HTTP_1_1
&& !con
->http
.keep_alive
)
847 if (httpPrintf(HTTP(con
), "Connection: close\r\n") < 0)
851 if (code
>= HTTP_BAD_REQUEST
)
854 * Send a human-readable error message.
857 sprintf(message
, "<HTML><HEAD><TITLE>%d %s</TITLE></HEAD>"
858 "<BODY><H1>%s</H1>%s</BODY></HTML>\n",
859 code
, httpStatus(code
), httpStatus(code
),
860 con
->language
? (char *)con
->language
->messages
[code
] : httpStatus(code
));
862 if (httpPrintf(HTTP(con
), "Content-Type: text/html\r\n") < 0)
864 if (httpPrintf(HTTP(con
), "Content-Length: %d\r\n", strlen(message
)) < 0)
866 if (httpPrintf(HTTP(con
), "\r\n") < 0)
868 if (send(con
->http
.fd
, message
, strlen(message
), 0) < 0)
871 else if (httpPrintf(HTTP(con
), "\r\n") < 0)
874 con
->http
.state
= HTTP_WAITING
;
881 * 'SendFile()' - Send a file via HTTP.
885 SendFile(client_t
*con
,
889 struct stat
*filestats
)
891 con
->file
= open(filename
, O_RDONLY
);
893 LogMessage(LOG_DEBUG
, "SendFile() %d file=%d", con
->http
.fd
, con
->file
);
898 fcntl(con
->file
, F_SETFD
, fcntl(con
->file
, F_GETFD
) | FD_CLOEXEC
);
902 if (!SendHeader(con
, code
, type
))
905 if (httpPrintf(HTTP(con
), "Last-Modified: %s\r\n", httpGetDateString(filestats
->st_mtime
)) < 0)
907 if (httpPrintf(HTTP(con
), "Content-Length: %d\r\n", filestats
->st_size
) < 0)
909 if (httpPrintf(HTTP(con
), "\r\n") < 0)
912 FD_SET(con
->http
.fd
, &OutputSet
);
919 * 'SendHeader()' - Send an HTTP request.
922 int /* O - 1 on success, 0 on failure */
923 SendHeader(client_t
*con
, /* I - Client to send to */
924 http_status_t code
, /* I - HTTP status code */
925 char *type
) /* I - MIME type of document */
927 if (httpPrintf(HTTP(con
), "HTTP/%d.%d %d %s\r\n", con
->http
.version
/ 100,
928 con
->http
.version
% 100, code
, httpStatus(code
)) < 0)
930 if (httpPrintf(HTTP(con
), "Date: %s\r\n", httpGetDateString(time(NULL
))) < 0)
932 if (httpPrintf(HTTP(con
), "Server: CUPS/1.0\r\n") < 0)
934 if (con
->http
.keep_alive
&& con
->http
.version
>= HTTP_1_0
)
936 if (httpPrintf(HTTP(con
), "Connection: Keep-Alive\r\n") < 0)
938 if (httpPrintf(HTTP(con
), "Keep-Alive: timeout=%d\r\n", KeepAliveTimeout
) < 0)
941 if (con
->language
!= NULL
)
943 if (httpPrintf(HTTP(con
), "Content-Language: %s\r\n",
944 con
->language
->language
) < 0)
948 if (httpPrintf(HTTP(con
), "Content-Type: %s; charset=%s\r\n", type
,
949 cupsLangEncoding(con
->language
)) < 0)
952 else if (type
!= NULL
)
953 if (httpPrintf(HTTP(con
), "Content-Type: %s\r\n", type
) < 0)
961 * 'StartListening()' - Create all listening sockets...
967 int i
, /* Looping var */
968 val
; /* Parameter value */
969 listener_t
*lis
; /* Current listening socket */
972 #if defined(WIN32) || defined(__EMX__)
974 * Initialize Windows sockets... This handles loading the DLL, etc. since
975 * Windows doesn't have built-in support for sockets like UNIX...
978 WSADATA wsadata
; /* Socket data for application from DLL */
979 static int initialized
= 0;/* Whether or not we've initialized things */
986 if (WSAStartup(MAKEWORD(1,1), &wsadata
) != 0)
991 * Setup a 'broken pipe' signal handler for lost clients.
994 sigset(SIGPIPE
, sigpipe_handler
);
998 * Setup socket listeners...
1001 for (i
= NumListeners
, lis
= Listeners
; i
> 0; i
--, lis
++)
1003 LogMessage(LOG_INFO
, "StartListening() address=%08x port=%d",
1004 ntohl(lis
->address
.sin_addr
.s_addr
),
1005 ntohs(lis
->address
.sin_port
));
1007 if ((lis
->fd
= socket(AF_INET
, SOCK_STREAM
, PF_UNSPEC
)) == -1)
1009 LogMessage(LOG_ERROR
, "StartListening() Unable to open listen socket - %s.",
1014 fcntl(lis
->fd
, F_SETFD
, fcntl(lis
->fd
, F_GETFD
) | FD_CLOEXEC
);
1017 * Set things up to reuse the local address for this port.
1021 setsockopt(lis
->fd
, SOL_SOCKET
, SO_REUSEADDR
, &val
, sizeof(val
));
1024 * Bind to the port we found...
1027 if (bind(lis
->fd
, (struct sockaddr
*)&(lis
->address
), sizeof(lis
->address
)) < 0)
1029 LogMessage(LOG_ERROR
, "StartListening() Unable to bind socket - %s.", strerror(errno
));
1034 * Listen for new clients.
1037 if (listen(lis
->fd
, SOMAXCONN
) < 0)
1039 LogMessage(LOG_ERROR
, "StartListening() Unable to listen for clients - %s.",
1045 * Setup the select() input mask to contain the listening socket we have.
1048 FD_SET(lis
->fd
, &InputSet
);
1051 LogMessage(LOG_INFO
, "StartListening() NumListeners=%d", NumListeners
);
1056 * 'StopListening()' - Close all listening sockets...
1062 int i
; /* Looping var */
1063 listener_t
*lis
; /* Current listening socket */
1066 for (i
= NumListeners
, lis
= Listeners
; i
> 0; i
--, lis
++)
1068 #if defined(WIN32) || defined(__EMX__)
1069 closesocket(lis
->fd
);
1072 #endif /* WIN32 || __EMX__ */
1074 FD_CLR(lis
->fd
, &InputSet
);
1077 LogMessage(LOG_INFO
, "StopListening()");
1082 * 'WriteClient()' - Write data to a client as needed.
1086 WriteClient(client_t
*con
)
1090 char buf
[HTTP_MAX_BUFFER
];
1093 if (con
->http
.state
!= HTTP_GET_SEND
&&
1094 con
->http
.state
!= HTTP_POST_SEND
)
1097 if (con
->response
!= NULL
)
1098 bytes
= ippWrite(&(con
->http
), con
->response
) != IPP_DATA
;
1099 else if ((bytes
= read(con
->file
, buf
, sizeof(buf
))) > 0)
1101 if (httpWrite(HTTP(con
), buf
, bytes
) < 0)
1107 con
->bytes
+= bytes
;
1112 LogRequest(con
, HTTP_OK
);
1114 if (con
->http
.data_encoding
== HTTP_ENCODE_CHUNKED
)
1116 if (httpPrintf(HTTP(con
), "0\r\n\r\n") < 0)
1123 FD_CLR(con
->http
.fd
, &OutputSet
);
1124 FD_CLR(con
->file
, &InputSet
);
1128 kill(con
->pipe_pid
, SIGKILL
);
1129 waitpid(con
->pipe_pid
, &status
, WNOHANG
);
1134 if (!con
->http
.keep_alive
)
1140 con
->http
.state
= HTTP_WAITING
;
1144 if (con
->request
!= NULL
)
1146 ippDelete(con
->request
);
1147 con
->request
= NULL
;
1150 if (con
->response
!= NULL
)
1152 ippDelete(con
->response
);
1153 con
->response
= NULL
;
1157 LogMessage(LOG_DEBUG
, "WriteClient() %d %d bytes", con
->http
.fd
, bytes
);
1159 con
->http
.activity
= time(NULL
);
1166 * 'check_if_modified()' - Decode an "If-Modified-Since" line.
1169 static int /* O - 1 if modified since */
1170 check_if_modified(client_t
*con
, /* I - Client connection */
1171 struct stat
*filestats
) /* I - File information */
1173 char *ptr
; /* Pointer into field */
1174 time_t date
; /* Time/date value */
1175 int size
; /* Size/length value */
1180 ptr
= con
->http
.fields
[HTTP_FIELD_IF_MODIFIED_SINCE
];
1185 LogMessage(LOG_DEBUG
, "check_if_modified() %d If-Modified-Since=\"%s\"",
1188 while (*ptr
!= '\0')
1190 while (isspace(*ptr
) || *ptr
== ';')
1193 if (strncasecmp(ptr
, "length=", 7) == 0)
1198 while (isdigit(*ptr
))
1201 else if (isalpha(*ptr
))
1203 date
= httpGetDateTime(ptr
);
1204 while (*ptr
!= '\0' && *ptr
!= ';')
1209 LogMessage(LOG_DEBUG
, "check_if_modified() %d sizes=%d,%d dates=%d,%d",
1210 con
->http
.fd
, size
, filestats
->st_size
, date
, filestats
->st_mtime
);
1212 return ((size
!= filestats
->st_size
&& size
!= 0) ||
1213 (date
< filestats
->st_mtime
&& date
!= 0) ||
1214 (size
== 0 && date
== 0));
1219 * 'decode_basic_auth()' - Decode a Basic authorization string.
1223 decode_basic_auth(client_t
*con
) /* I - Client to decode to */
1225 char value
[1024]; /* Value string */
1229 * Decode the string and pull the username and password out...
1232 httpDecode64(value
, con
->http
.fields
[HTTP_FIELD_AUTHORIZATION
]);
1234 LogMessage(LOG_DEBUG
, "decode_basic_auth() %d Authorization=\"%s\"",
1235 con
->http
.fd
, value
);
1237 sscanf(value
, "%[^:]:%[^\n]", con
->username
, con
->password
);
1242 * 'pipe_command()' - Pipe the output of a command to the remote client.
1245 static int /* O - Process ID */
1246 pipe_command(client_t
*con
, /* I - Client connection */
1247 int infile
, /* I - Standard input for command */
1248 int *outfile
, /* O - Standard output for command */
1249 char *command
, /* I - Command to run */
1250 char *options
) /* I - Options for command */
1252 int pid
; /* Process ID */
1253 char *commptr
; /* Command string pointer */
1254 int fds
[2]; /* Pipe FDs */
1255 int argc
; /* Number of arguments */
1256 char argbuf
[1024], /* Argument buffer */
1257 *argv
[100], /* Argument strings */
1258 *envp
[100]; /* Environment variables */
1259 static char lang
[1024]; /* LANG env variable */
1260 static char content_length
[1024]; /* CONTENT_LENGTH env variable */
1261 static char content_type
[1024]; /* CONTENT_TYPE env variable */
1262 static char server_port
[1024]; /* Default listen port */
1263 static char remote_host
[1024]; /* REMOTE_HOST env variable */
1264 static char remote_user
[1024]; /* REMOTE_HOST env variable */
1268 * Copy the command string...
1271 strncpy(argbuf
, options
, sizeof(argbuf
) - 1);
1272 argbuf
[sizeof(argbuf
) - 1] = '\0';
1275 * Parse the string; arguments can be separated by spaces or by ? or +...
1280 for (commptr
= argbuf
, argc
= 1; *commptr
!= '\0'; commptr
++)
1281 if (*commptr
== ' ' || *commptr
== '?' || *commptr
== '+')
1285 while (*commptr
== ' ')
1288 if (*commptr
!= '\0')
1290 argv
[argc
] = commptr
;
1296 else if (*commptr
== '%')
1298 if (commptr
[1] >= '0' && commptr
[1] <= '9')
1299 *commptr
= (commptr
[1] - '0') << 4;
1301 *commptr
= (tolower(commptr
[1]) - 'a' + 10) << 4;
1303 if (commptr
[2] >= '0' && commptr
[2] <= '9')
1304 *commptr
|= commptr
[2] - '0';
1306 *commptr
|= tolower(commptr
[2]) - 'a' + 10;
1308 strcpy(commptr
+ 1, commptr
+ 3);
1313 if (argv
[1][0] == '\0')
1314 argv
[1] = strrchr(command
, '/') + 1;
1317 * Setup the environment variables as needed...
1320 sprintf(lang
, "LANG=%s", con
->language
? con
->language
->language
: "C");
1321 sprintf(server_port
, "SERVER_PORT=%d", ntohs(con
->http
.hostaddr
.sin_port
));
1322 sprintf(remote_host
, "REMOTE_HOST=%s", con
->http
.hostname
);
1323 sprintf(remote_user
, "REMOTE_USER=%s", con
->username
);
1325 envp
[0] = "PATH=/bin:/usr/bin";
1326 envp
[1] = "SERVER_SOFTWARE=CUPS/1.0";
1327 envp
[2] = "SERVER_NAME=localhost"; /* This isn't 100% correct... */
1328 envp
[3] = "GATEWAY_INTERFACE=CGI/1.1";
1329 envp
[4] = "SERVER_PROTOCOL=HTTP/1.1";
1330 envp
[5] = server_port
;
1331 envp
[6] = remote_host
;
1332 envp
[7] = remote_user
;
1336 if (con
->operation
== HTTP_GET
)
1338 envp
[10] = "REQUEST_METHOD=GET";
1343 sprintf(content_length
, "CONTENT_LENGTH=%d", con
->http
.data_remaining
);
1344 sprintf(content_type
, "CONTENT_TYPE=%s",
1345 con
->http
.fields
[HTTP_FIELD_CONTENT_TYPE
]);
1347 envp
[10] = "REQUEST_METHOD=POST";
1348 envp
[11] = content_length
;
1349 envp
[12] = content_type
;
1354 * Create a pipe for the output...
1361 * Then execute the pipe command...
1364 if ((pid
= fork()) == 0)
1367 * Child comes here... Close stdin if necessary and dup the pipe to stdout.
1386 * Execute the pipe program; if an error occurs, exit with status 1...
1389 execve(command
, argv
, envp
);
1396 * Error - can't fork!
1406 * Fork successful - return the PID...
1418 * 'process_ipp_request()' - Process an incoming IPP request...
1422 process_ipp_request(client_t
*con
) /* I - Client connection */
1424 ipp_tag_t group
; /* Current group tag */
1425 ipp_attribute_t
*attr
; /* Current attribute */
1426 ipp_attribute_t
*charset
; /* Character set attribute */
1427 ipp_attribute_t
*language
; /* Language attribute */
1428 ipp_attribute_t
*uri
; /* Printer URI attribute */
1429 char *dest
; /* Destination */
1430 cups_ptype_t dtype
; /* Destination type (printer or class) */
1431 int priority
; /* Job priority */
1432 job_t
*job
; /* Current job */
1433 char job_uri
[HTTP_MAX_URI
],
1435 method
[HTTP_MAX_URI
],
1436 /* Method portion of URI */
1437 username
[HTTP_MAX_URI
],
1438 /* Username portion of URI */
1440 /* Host portion of URI */
1441 resource
[HTTP_MAX_URI
];
1442 /* Resource portion of URI */
1443 int port
; /* Port portion of URI */
1446 DEBUG_printf(("process_ipp_request(%08x)\n", con
));
1447 DEBUG_printf(("process_ipp_request: operation_id = %04x\n",
1448 con
->request
->request
.op
.operation_id
));
1451 * First build an empty response message for this request...
1454 con
->response
= ippNew();
1456 con
->response
->request
.status
.version
[0] = 1;
1457 con
->response
->request
.status
.version
[1] = 0;
1458 con
->response
->request
.status
.request_id
= con
->request
->request
.op
.request_id
;
1461 * Then validate the request header and required attributes...
1464 if (con
->request
->request
.any
.version
[0] != 1)
1467 * Return an error, since we only support IPP 1.x.
1470 send_ipp_error(con
, IPP_VERSION_NOT_SUPPORTED
);
1476 * Make sure that the attributes are provided in the correct order and
1477 * don't repeat groups...
1480 for (attr
= con
->request
->attrs
, group
= attr
->group_tag
;
1483 if (attr
->group_tag
< group
)
1486 * Out of order; return an error...
1489 DEBUG_puts("process_ipp_request: attribute groups are out of order!");
1490 send_ipp_error(con
, IPP_BAD_REQUEST
);
1494 group
= attr
->group_tag
;
1497 * Then make sure that the first three attributes are:
1499 * attributes-charset
1500 * attributes-natural-language
1504 attr
= con
->request
->attrs
;
1505 if (attr
!= NULL
&& strcmp(attr
->name
, "attributes-charset") == 0)
1511 if (attr
!= NULL
&& strcmp(attr
->name
, "attributes-natural-language") == 0)
1517 if (attr
!= NULL
&& strcmp(attr
->name
, "printer-uri") == 0)
1519 else if (attr
!= NULL
&& strcmp(attr
->name
, "job-uri") == 0)
1524 if (charset
== NULL
|| language
== NULL
|| uri
== NULL
)
1527 * Return an error, since attributes-charset,
1528 * attributes-natural-language, and printer-uri/job-uri are required
1529 * for all operations.
1532 DEBUG_printf(("process_ipp_request: missing attributes (%08x, %08x, %08x)!\n",
1533 charset
, language
, uri
));
1534 send_ipp_error(con
, IPP_BAD_REQUEST
);
1538 attr
= ippAddString(con
->response
, IPP_TAG_OPERATION
, "attributes-charset",
1539 charset
->values
[0].string
);
1540 attr
->value_tag
= IPP_TAG_CHARSET
;
1542 attr
= ippAddString(con
->response
, IPP_TAG_OPERATION
,
1543 "attributes-natural-language", language
->values
[0].string
);
1544 attr
->value_tag
= IPP_TAG_LANGUAGE
;
1546 httpSeparate(uri
->values
[0].string
, method
, username
, host
, &port
, resource
);
1549 * OK, all the checks pass so far; try processing the operation...
1552 switch (con
->request
->request
.op
.operation_id
)
1554 case IPP_PRINT_JOB
:
1556 * OK, see if the client is sending the document compressed - CUPS
1557 * doesn't support compression yet...
1560 if ((attr
= ippFindAttribute(con
->request
, "compression")) != NULL
)
1562 DEBUG_puts("process_ipp_request: Unsupported compression attribute!");
1563 send_ipp_error(con
, IPP_ATTRIBUTES
);
1564 attr
= ippAddString(con
->response
, IPP_TAG_UNSUPPORTED
,
1565 "compression", attr
->values
[0].string
);
1566 attr
->value_tag
= IPP_TAG_KEYWORD
;
1572 * Do we have a file to print?
1575 if (con
->filename
[0] == '\0')
1577 DEBUG_puts("process_ipp_request: No filename!?!");
1578 send_ipp_error(con
, IPP_BAD_REQUEST
);
1583 * Is the destination valid?
1586 if (strncmp(resource
, "/classes/", 9) == 0)
1589 * Print to a class...
1592 dest
= resource
+ 9;
1593 dtype
= CUPS_PRINTER_CLASS
;
1595 if (FindClass(dest
) == NULL
)
1597 send_ipp_error(con
, IPP_NOT_FOUND
);
1601 else if (strncmp(resource
, "/printers/", 10) == 0)
1604 * Print to a specific printer...
1607 dest
= resource
+ 10;
1608 dtype
= (cups_ptype_t
)0;
1610 if (FindPrinter(dest
) == NULL
&& FindClass(dest
) == NULL
)
1612 send_ipp_error(con
, IPP_NOT_FOUND
);
1622 DEBUG_printf(("process_ipp_request: resource name \'%s\' no good!\n",
1624 send_ipp_error(con
, IPP_BAD_REQUEST
);
1629 * Create the job and set things up...
1632 if ((attr
= ippFindAttribute(con
->request
, "job-priority")) != NULL
)
1633 priority
= attr
->values
[0].integer
;
1637 if ((job
= AddJob(priority
, dest
)) == NULL
)
1639 send_ipp_error(con
, IPP_INTERNAL_ERROR
);
1645 job
->attrs
= con
->request
;
1646 con
->request
= NULL
;
1648 strcpy(con
->filename
, job
->filename
);
1649 con
->filename
[0] = '\0';
1651 job
->state
= IPP_JOB_PENDING
;
1654 * Start the job if possible...
1660 * Fill in the response info...
1663 sprintf(job_uri
, "http://%s:%d/jobs/%d", ServerName
,
1664 ntohs(con
->http
.hostaddr
.sin_port
), job
->id
);
1665 attr
= ippAddString(con
->response
, IPP_TAG_JOB
, "job-uri", job_uri
);
1666 attr
->value_tag
= IPP_TAG_URI
;
1668 attr
= ippAddInteger(con
->response
, IPP_TAG_JOB
, "job-id", job
->id
);
1669 attr
->value_tag
= IPP_TAG_INTEGER
;
1671 attr
= ippAddInteger(con
->response
, IPP_TAG_JOB
, "job-state", job
->state
);
1672 attr
->value_tag
= IPP_TAG_ENUM
;
1674 con
->response
->request
.status
.status_code
= IPP_OK
;
1677 case IPP_VALIDATE_JOB
:
1678 send_ipp_error(con
, IPP_OPERATION_NOT_SUPPORTED
);
1681 case IPP_CANCEL_JOB
:
1682 send_ipp_error(con
, IPP_OPERATION_NOT_SUPPORTED
);
1685 case IPP_GET_JOB_ATTRIBUTES
:
1686 send_ipp_error(con
, IPP_OPERATION_NOT_SUPPORTED
);
1690 send_ipp_error(con
, IPP_OPERATION_NOT_SUPPORTED
);
1693 case IPP_GET_PRINTER_ATTRIBUTES
:
1694 send_ipp_error(con
, IPP_OPERATION_NOT_SUPPORTED
);
1697 case CUPS_GET_DEFAULT
:
1698 send_ipp_error(con
, IPP_OPERATION_NOT_SUPPORTED
);
1701 case CUPS_GET_PRINTERS
:
1702 send_ipp_error(con
, IPP_OPERATION_NOT_SUPPORTED
);
1705 case CUPS_ADD_PRINTER
:
1706 send_ipp_error(con
, IPP_OPERATION_NOT_SUPPORTED
);
1709 case CUPS_DELETE_PRINTER
:
1710 send_ipp_error(con
, IPP_OPERATION_NOT_SUPPORTED
);
1713 case CUPS_GET_CLASSES
:
1714 send_ipp_error(con
, IPP_OPERATION_NOT_SUPPORTED
);
1717 case CUPS_ADD_CLASS
:
1718 send_ipp_error(con
, IPP_OPERATION_NOT_SUPPORTED
);
1721 case CUPS_DELETE_CLASS
:
1722 send_ipp_error(con
, IPP_OPERATION_NOT_SUPPORTED
);
1726 send_ipp_error(con
, IPP_OPERATION_NOT_SUPPORTED
);
1730 FD_SET(con
->http
.fd
, &OutputSet
);
1735 * 'send_ipp_error()' - Send an error status back to the IPP client.
1739 send_ipp_error(client_t
*con
, /* I - Client connection */
1740 ipp_status_t status
) /* I - IPP status code */
1742 ipp_attribute_t
*attr
; /* Current attribute */
1745 if (con
->filename
[0])
1746 unlink(con
->filename
);
1748 con
->response
->request
.status
.status_code
= status
;
1750 attr
= ippAddString(con
->response
, IPP_TAG_OPERATION
, "attributes-charset",
1752 attr
->value_tag
= IPP_TAG_CHARSET
;
1754 attr
= ippAddString(con
->response
, IPP_TAG_OPERATION
,
1755 "attributes-natural-language", DefaultLanguage
);
1756 attr
->value_tag
= IPP_TAG_LANGUAGE
;
1758 FD_SET(con
->http
.fd
, &OutputSet
);
1763 * 'sigpipe_handler()' - Handle 'broken pipe' signals from lost network
1768 sigpipe_handler(int sig
) /* I - Signal number */
1777 /**** OBSOLETE ****/
1780 * 'get_extension()' - Get the extension for a filename.
1783 static char * /* O - Pointer to extension */
1784 get_extension(char *filename
) /* I - Filename or URI */
1786 char *ext
; /* Pointer to extension */
1789 ext
= filename
+ strlen(filename
) - 1;
1791 while (ext
> filename
&& *ext
!= '/')
1802 * 'get_file()' - Get a filename and state info.
1805 static char * /* O - Real filename */
1806 get_file(client_t
*con
, /* I - Client connection */
1807 struct stat
*filestats
)/* O - File information */
1809 int status
; /* Status of filesystem calls */
1810 char *params
; /* Pointer to parameters in URI */
1811 static char filename
[1024]; /* Filename buffer */
1815 * Need to add DocumentRoot global...
1818 if (con
->language
!= NULL
)
1819 sprintf(filename
, "%s/%s%s", DocumentRoot
, con
->language
->language
,
1822 sprintf(filename
, "%s%s", DocumentRoot
, con
->uri
);
1824 if ((params
= strchr(filename
, '?')) != NULL
)
1828 * Grab the status for this language; if there isn't a language-specific file
1829 * then fallback to the default one...
1832 if ((status
= stat(filename
, filestats
)) != 0 && con
->language
!= NULL
)
1835 * Drop the language prefix and try the current directory...
1838 sprintf(filename
, "%s%s", DocumentRoot
, con
->uri
);
1840 status
= stat(filename
, filestats
);
1844 * If we're found a directory, get the index.html file instead...
1847 if (!status
&& S_ISDIR(filestats
->st_mode
))
1849 if (filename
[strlen(filename
) - 1] == '/')
1850 strcat(filename
, "index.html");
1852 strcat(filename
, "/index.html");
1854 status
= stat(filename
, filestats
);
1857 LogMessage(LOG_DEBUG
, "get_filename() %d filename=%s size=%d",
1858 con
->http
.fd
, filename
, filestats
->st_size
);
1868 * 'get_type()' - Get MIME type from the given extension.
1872 get_type(char *extension
)
1874 if (strcmp(extension
, "html") == 0 || strcmp(extension
, "htm") == 0)
1875 return ("text/html");
1876 else if (strcmp(extension
, "txt") == 0)
1877 return ("text/plain");
1878 else if (strcmp(extension
, "gif") == 0)
1879 return ("image/gif");
1880 else if (strcmp(extension
, "jpg") == 0)
1881 return ("image/jpg");
1882 else if (strcmp(extension
, "png") == 0)
1883 return ("image/png");
1884 else if (strcmp(extension
, "ps") == 0)
1885 return ("application/postscript");
1886 else if (strcmp(extension
, "pdf") == 0)
1887 return ("application/pdf");
1888 else if (strcmp(extension
, "gz") == 0)
1889 return ("application/gzip");
1891 return ("application/unknown");
1896 * 'show_printer_status()' - Show the current printer status.
1900 show_printer_status(client_t
*con
)
1903 char buffer
[HTTP_MAX_BUFFER
];
1904 static char *states
[] =
1906 "", "", "", "Idle", "Processing", "Stopped"
1911 if (con
->uri
[10] != '\0')
1912 if ((p
= FindPrinter(con
->uri
+ 10)) == NULL
)
1915 if (!SendHeader(con
, HTTP_OK
, "text/html"))
1918 if (con
->http
.version
== HTTP_1_1
)
1920 con
->http
.data_encoding
= HTTP_ENCODE_CHUNKED
;
1922 if (httpPrintf(HTTP(con
), "Transfer-Encoding: chunked\r\n") < 0)
1926 if (httpPrintf(HTTP(con
), "\r\n") < 0)
1932 * Send printer information...
1935 sprintf(buffer
, "<HTML>\n"
1937 "\t<TITLE>Printer Status for %s</TITLE>\n"
1938 "\t<META HTTP-EQUIV=\"Refresh\" CONTENT=\"10\">\n"
1940 "<BODY BGCOLOR=#ffffff>\n"
1941 "<TABLE WIDTH=100%%><TR>\n"
1942 "\t<TD ALIGN=LEFTV ALIGN=MIDDLE><IMG SRC=\"/images/cups-small.gif\"></TD>\n"
1943 "\t<TD ALIGN=CENTER VALIGN=MIDDLE><H1>Printer Status for %s</H1></TD>\n"
1944 "\t<TD ALIGN=RIGHT VALIGN=MIDDLE><IMG SRC=\"/images/vendor.gif\"></TD>\n"
1946 "<CENTER><TABLE BORDER=1 WIDTH=80%%>\n"
1947 "<TR><TH>Name</TH><TH>Value</TH></TR>\n"
1948 "<TR><TD>Info</TD><TD>%s</TD></TR>\n"
1949 "<TR><TD>MoreInfo</TD><TD>%s</TD></TR>\n"
1950 "<TR><TD>Location</TD><TD>%s</TD></TR>\n"
1951 "<TR><TD>Device URI</TD><TD>%s</TD></TR>\n"
1952 "<TR><TD>PPDFile</TD><TD>%s</TD></TR>\n",
1953 p
->name
, p
->name
, p
->info
, p
->more_info
,
1954 p
->location
, p
->device_uri
, p
->ppd
);
1956 con
->bytes
+= httpWrite(HTTP(con
), buffer
, strlen(buffer
));
1960 strcpy(buffer
, "<HTML>\n"
1962 "\t<TITLE>Available Printers</TITLE>\n"
1963 "\t<META HTTP-EQUIV=\"Refresh\" CONTENT=\"10\">\n"
1965 "<BODY BGCOLOR=#ffffff>\n"
1966 "<TABLE WIDTH=100%%><TR>\n"
1967 "\t<TD ALIGN=LEFT VALIGN=MIDDLE><IMG SRC=\"/images/cups-small.gif\"></TD>\n"
1968 "\t<TD ALIGN=CENTER VALIGN=MIDDLE><H1>Available Printers</H1></TD>\n"
1969 "\t<TD ALIGN=RIGHT VALIGN=MIDDLE><IMG SRC=\"/images/vendor.gif\"></TD>\n"
1971 "<CENTER><TABLE BORDER=1 WIDTH=80%%>\n"
1972 "<TR><TH>Name</TH><TH>State</TH><TH>Info</TH></TR>\n");
1974 con
->bytes
+= httpWrite(HTTP(con
), buffer
, strlen(buffer
));
1976 for (p
= Printers
; p
!= NULL
; p
= p
->next
)
1978 sprintf(buffer
, "<TR><TD><A HREF=/printers/%s>%s</A></TD><TD>%s</TD><TD>%s</TD></TR>\n",
1979 p
->name
, p
->name
, states
[p
->state
], p
->info
);
1980 con
->bytes
+= httpWrite(HTTP(con
), buffer
, strlen(buffer
));
1984 strcpy(buffer
, "</TABLE></CENTER>\n"
1986 "CUPS Copyright 1997-1999 by Easy Software Products, "
1987 "All Rights Reserved. CUPS and the CUPS logo are the "
1988 "trademark property of Easy Software Products.\n"
1991 con
->bytes
+= httpWrite(HTTP(con
), buffer
, strlen(buffer
));
1992 httpWrite(HTTP(con
), buffer
, 0);
1999 * End of "$Id: client.c,v 1.5 1999/02/26 15:11:11 mike Exp $".