/*
- * "$Id: getputfile.c 181 2006-06-22 20:01:18Z jlovell $"
+ * "$Id: getputfile.c 6720 2007-07-25 00:40:03Z mike $"
*
* Get/put file functions for the Common UNIX Printing System (CUPS).
*
+ * Copyright 2007-2008 by Apple Inc.
* Copyright 1997-2006 by Easy Software Products.
*
* These coded instructions, statements, and computer programs are the
- * property of Easy Software Products and are protected by Federal
- * copyright law. Distribution and use rights are outlined in the file
- * "LICENSE.txt" which should have been included with this file. If this
- * file is missing or damaged please contact Easy Software Products
- * at:
- *
- * Attn: CUPS Licensing Information
- * Easy Software Products
- * 44141 Airport View Drive, Suite 204
- * Hollywood, Maryland 20636 USA
- *
- * Voice: (301) 373-9600
- * EMail: cups-info@cups.org
- * WWW: http://www.cups.org
+ * property of Apple Inc. and are protected by Federal copyright
+ * law. Distribution and use rights are outlined in the file "LICENSE.txt"
+ * which should have been included with this file. If this file is
+ * file is missing or damaged, see the license at "http://www.cups.org/".
*
* This file is subject to the Apple OS-Developed Software exception.
*
* Include necessary headers...
*/
-#include "http-private.h"
+#include "globals.h"
#include "cups.h"
#include "language.h"
-#include "string.h"
#include "debug.h"
#include <stdlib.h>
#include <ctype.h>
/*
* 'cupsGetFd()' - Get a file from the server.
*
- * This function returns HTTP_OK when the file is successfully retrieved.
+ * This function returns @code HTTP_OK@ when the file is successfully retrieved.
*
* @since CUPS 1.1.20@
*/
http_status_t /* O - HTTP status */
-cupsGetFd(http_t *http, /* I - HTTP connection to server */
+cupsGetFd(http_t *http, /* I - HTTP connection to server or @code CUPS_HTTP_DEFAULT@ */
const char *resource, /* I - Resource name */
int fd) /* I - File descriptor */
{
DEBUG_printf(("cupsGetFd(http=%p, resource=\"%s\", fd=%d)\n", http,
resource, fd));
- if (!http || !resource || fd < 0)
+ if (!resource || fd < 0)
{
if (http)
http->error = EINVAL;
return (HTTP_ERROR);
}
+ if (!http)
+ http = _cupsConnect();
+
/*
* Then send GET requests to the HTTP server...
*/
write(fd, buffer, bytes);
}
else
+ {
+ _cupsSetHTTPError(status);
httpFlush(http);
+ }
/*
* Return the request status...
/*
* 'cupsGetFile()' - Get a file from the server.
*
- * This function returns HTTP_OK when the file is successfully retrieved.
+ * This function returns @code HTTP_OK@ when the file is successfully retrieved.
*
* @since CUPS 1.1.20@
*/
http_status_t /* O - HTTP status */
-cupsGetFile(http_t *http, /* I - HTTP connection to server */
+cupsGetFile(http_t *http, /* I - HTTP connection to server or @code CUPS_HTTP_DEFAULT@ */
const char *resource, /* I - Resource name */
const char *filename) /* I - Filename */
{
/*
* 'cupsPutFd()' - Put a file on the server.
*
- * This function returns HTTP_CREATED when the file is stored successfully.
+ * This function returns @code HTTP_CREATED@ when the file is stored
+ * successfully.
*
* @since CUPS 1.1.20@
*/
http_status_t /* O - HTTP status */
-cupsPutFd(http_t *http, /* I - HTTP connection to server */
+cupsPutFd(http_t *http, /* I - HTTP connection to server or @code CUPS_HTTP_DEFAULT@ */
const char *resource, /* I - Resource name */
int fd) /* I - File descriptor */
{
DEBUG_printf(("cupsPutFd(http=%p, resource=\"%s\", fd=%d)\n", http,
resource, fd));
- if (!http || !resource || fd < 0)
+ if (!resource || fd < 0)
{
if (http)
http->error = EINVAL;
return (HTTP_ERROR);
}
+ if (!http)
+ http = _cupsConnect();
+
/*
* Then send PUT requests to the HTTP server...
*/
*/
if (status != HTTP_CREATED)
+ {
+ _cupsSetHTTPError(status);
httpFlush(http);
+ }
return (status);
}
/*
* 'cupsPutFile()' - Put a file on the server.
*
- * This function returns HTTP_CREATED when the file is stored successfully.
+ * This function returns @code HTTP_CREATED@ when the file is stored
+ * successfully.
*
* @since CUPS 1.1.20@
*/
http_status_t /* O - HTTP status */
-cupsPutFile(http_t *http, /* I - HTTP connection to server */
+cupsPutFile(http_t *http, /* I - HTTP connection to server or @code CUPS_HTTP_DEFAULT@ */
const char *resource, /* I - Resource name */
const char *filename) /* I - Filename */
{
/*
- * End of "$Id: getputfile.c 181 2006-06-22 20:01:18Z jlovell $".
+ * End of "$Id: getputfile.c 6720 2007-07-25 00:40:03Z mike $".
*/