diff options
| author | Daniel Stenberg <daniel@haxx.se> | 2002-04-12 07:21:11 +0000 | 
|---|---|---|
| committer | Daniel Stenberg <daniel@haxx.se> | 2002-04-12 07:21:11 +0000 | 
| commit | 3f6133be2735936631c4bfe5aedd28ae9b084f3f (patch) | |
| tree | c77945364d0d160199188bd96d6a23725d394a62 /lib/sendf.c | |
| parent | c3bfb355c56178d23a5fc2d8706a1da472800da4 (diff) | |
Jean-Philippe Barrette-LaPierre provided his patch that introduces
CURLOPT_DEBUGFUNCTION and CURLOPT_DEBUGDATA.
Diffstat (limited to 'lib/sendf.c')
| -rw-r--r-- | lib/sendf.c | 32 | 
1 files changed, 27 insertions, 5 deletions
diff --git a/lib/sendf.c b/lib/sendf.c index 721db36a8..6d4ab1fb7 100644 --- a/lib/sendf.c +++ b/lib/sendf.c @@ -135,10 +135,11 @@ void Curl_infof(struct SessionHandle *data, const char *fmt, ...)  {    va_list ap;    if(data->set.verbose) { +    char print_buffer[1024 + 1];      va_start(ap, fmt); -    fputs("* ", data->set.err); -    vfprintf(data->set.err, fmt, ap); +    vsnprintf(print_buffer, 1024, fmt, ap);      va_end(ap); +    Curl_debug(data, CURLINFO_TEXT, print_buffer, strlen(print_buffer));    }  } @@ -174,9 +175,6 @@ CURLcode Curl_sendf(int sockfd, struct connectdata *conn,    if(!s)      return CURLE_OUT_OF_MEMORY; /* failure */ -  if(data->set.verbose) -    fprintf(data->set.err, "> %s", s); -    bytes_written=0;    write_len = strlen(s);    sptr = s; @@ -188,6 +186,9 @@ CURLcode Curl_sendf(int sockfd, struct connectdata *conn,      if(CURLE_OK != res)        break; +    if(data->set.verbose) +      Curl_debug(data, CURLINFO_DATA_OUT, sptr, bytes_written); +      if(bytes_written != write_len) {        /* if not all was written at once, we must advance the pointer, decrease           the size left and try again! */ @@ -380,6 +381,27 @@ int Curl_read(struct connectdata *conn,    return CURLE_OK;  } +/* return 0 on success */ +int Curl_debug(struct SessionHandle *data, curl_infotype type, +               char *ptr, size_t size) +{ +  static const char * const s_infotype[CURLINFO_END] = { +    "* ", "< ", "> ", "{ ", "} " }; + +  if(data->set.fdebug) +    return (*data->set.fdebug)(data, type, ptr, size, +                               data->set.debugdata); + +  if(type >= CURLINFO_DATA_IN) +    /* don't do the data parts now */ +    return 0; + +  fwrite(s_infotype[type], 2, 1, data->set.err); +  fwrite(ptr, size, 1, data->set.err); + +  return 0; +} +  /*   * local variables:  | 
