1 /*****************************************************************************
3 * Project ___| | | | _ \| |
5 * | (__| |_| | _ <| |___
6 * \___|\___/|_| \_\_____|
8 * The contents of this file are subject to the Mozilla Public License
9 * Version 1.0 (the "License"); you may not use this file except in
10 * compliance with the License. You may obtain a copy of the License at
11 * http://www.mozilla.org/MPL/
13 * Software distributed under the License is distributed on an "AS IS"
14 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
15 * License for the specific language governing rights and limitations
18 * The Original Code is Curl.
20 * The Initial Developer of the Original Code is Daniel Stenberg.
22 * Portions created by the Initial Developer are Copyright (C) 1998.
23 * All Rights Reserved.
25 * ------------------------------------------------------------
27 * - Daniel Stenberg <Daniel.Stenberg@haxx.nu>
31 * $Source: /cvsroot/curl/curl/lib/sendf.c,v $
33 * $Date: 1999-12-29 14:21:35 $
38 * ------------------------------------------------------------
39 ****************************************************************************/
50 #if defined(WIN32) && !defined(__GNUC__) || defined(__MINGW32__)
54 #include <curl/curl.h>
57 #include <curl/mprintf.h>
59 /* infof() is for info message along the way */
61 void infof(struct UrlData
*data
, char *fmt
, ...)
64 if(data
->conf
& CONF_VERBOSE
) {
66 fputs("* ", data
->err
);
67 vfprintf(data
->err
, fmt
, ap
);
72 /* failf() is for messages stating why we failed, the LAST one will be
73 returned for the user (if requested) */
75 void failf(struct UrlData
*data
, char *fmt
, ...)
80 vsprintf(data
->errorbuffer
, fmt
, ap
);
81 else /* no errorbuffer receives this, write to data->err instead */
82 vfprintf(data
->err
, fmt
, ap
);
86 /* sendf() sends the formated data to the server */
88 int sendf(int fd
, struct UrlData
*data
, char *fmt
, ...)
94 s
= mvaprintf(fmt
, ap
);
97 return 0; /* failure */
98 if(data
->conf
& CONF_VERBOSE
)
99 fprintf(data
->err
, "> %s", s
);
101 bytes_written
= swrite(fd
, s
, strlen(s
));
104 bytes_written
= SSL_write(data
->ssl
, s
, strlen(s
));
106 bytes_written
= swrite(fd
, s
, strlen(s
));
108 #endif /* USE_SSLEAY */
109 free(s
); /* free the output string */
110 return(bytes_written
);