~ubuntu-branches/ubuntu/natty/curl/natty

« back to all changes in this revision

Viewing changes to lib/easy.c

  • Committer: Bazaar Package Importer
  • Author(s): Bhavani Shankar
  • Date: 2010-06-20 13:56:28 UTC
  • mfrom: (3.4.7 sid)
  • Revision ID: james.westby@ubuntu.com-20100620135628-e30tp9jldq6hq985
Tags: 7.21.0-1ubuntu1
* Merge from debian unstable.  Remaining changes: LP: #596334
  - Keep build deps in main:
    - Drop build dependencies: stunnel, libssh2-1-dev
    - Add build-dependency on openssh-server
    - Drop libssh2-1-dev from libcurl4-openssl-dev's Depends.

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
 *                            | (__| |_| |  _ <| |___
6
6
 *                             \___|\___/|_| \_\_____|
7
7
 *
8
 
 * Copyright (C) 1998 - 2009, Daniel Stenberg, <daniel@haxx.se>, et al.
 
8
 * Copyright (C) 1998 - 2010, Daniel Stenberg, <daniel@haxx.se>, et al.
9
9
 *
10
10
 * This software is licensed as described in the file COPYING, which
11
11
 * you should have received as part of this distribution. The terms
18
18
 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19
19
 * KIND, either express or implied.
20
20
 *
21
 
 * $Id: easy.c,v 1.145 2009-10-27 16:38:42 yangtse Exp $
22
21
 ***************************************************************************/
23
22
 
24
23
#include "setup.h"
288
287
  }
289
288
#endif
290
289
 
 
290
#if defined(USE_LIBSSH2) && defined(HAVE_LIBSSH2_INIT)
 
291
  if(libssh2_init(0)) {
 
292
    DEBUGF(fprintf(stderr, "Error: libssh2_init failed\n"));
 
293
    return CURLE_FAILED_INIT;
 
294
  }
 
295
#endif
 
296
 
291
297
  init_flags  = flags;
292
298
 
293
299
  /* Preset pseudo-random number sequence. */
356
362
  amiga_cleanup();
357
363
#endif
358
364
 
 
365
#if defined(USE_LIBSSH2) && defined(HAVE_LIBSSH2_EXIT)
 
366
  (void)libssh2_exit();
 
367
#endif
 
368
 
359
369
  init_flags  = 0;
360
370
}
361
371
 
619
629
  bool fail = TRUE;
620
630
  struct SessionHandle *data=(struct SessionHandle *)incurl;
621
631
 
622
 
  struct SessionHandle *outcurl = calloc(sizeof(struct SessionHandle), 1);
 
632
  struct SessionHandle *outcurl = calloc(1, sizeof(struct SessionHandle));
623
633
 
624
634
  if(NULL == outcurl)
625
635
    return NULL; /* failure */
882
892
    rc = data->set.convtonetwork(buffer, length);
883
893
    if(rc != CURLE_OK) {
884
894
      failf(data,
885
 
            "CURLOPT_CONV_TO_NETWORK_FUNCTION callback returned %i: %s",
886
 
            rc, curl_easy_strerror(rc));
 
895
            "CURLOPT_CONV_TO_NETWORK_FUNCTION callback returned %d: %s",
 
896
            (int)rc, curl_easy_strerror(rc));
887
897
    }
888
898
    return(rc);
889
 
  } else {
 
899
  }
 
900
  else {
890
901
#ifdef HAVE_ICONV
891
902
    /* do the translation ourselves */
892
903
    char *input_ptr, *output_ptr;
942
953
    rc = data->set.convfromnetwork(buffer, length);
943
954
    if(rc != CURLE_OK) {
944
955
      failf(data,
945
 
            "CURLOPT_CONV_FROM_NETWORK_FUNCTION callback returned %i: %s",
946
 
            rc, curl_easy_strerror(rc));
 
956
            "CURLOPT_CONV_FROM_NETWORK_FUNCTION callback returned %d: %s",
 
957
            (int)rc, curl_easy_strerror(rc));
947
958
    }
948
959
    return(rc);
949
960
  }
1003
1014
    rc = data->set.convfromutf8(buffer, length);
1004
1015
    if(rc != CURLE_OK) {
1005
1016
      failf(data,
1006
 
            "CURLOPT_CONV_FROM_UTF8_FUNCTION callback returned %i: %s",
1007
 
            rc, curl_easy_strerror(rc));
 
1017
            "CURLOPT_CONV_FROM_UTF8_FUNCTION callback returned %d: %s",
 
1018
            (int)rc, curl_easy_strerror(rc));
1008
1019
    }
1009
1020
    return(rc);
1010
 
  } else {
 
1021
  }
 
1022
  else {
1011
1023
#ifdef HAVE_ICONV
1012
1024
    /* do the translation ourselves */
1013
1025
    const char *input_ptr;
1096
1108
{
1097
1109
  curl_socket_t sfd;
1098
1110
  CURLcode ret;
1099
 
  int ret1;
1100
1111
  ssize_t n1;
1101
1112
  struct connectdata *c;
1102
1113
  struct SessionHandle *data = (struct SessionHandle *)curl;
1106
1117
    return ret;
1107
1118
 
1108
1119
  *n = 0;
1109
 
  ret1 = Curl_read(c, sfd, buffer, buflen, &n1);
1110
 
 
1111
 
  if(ret1 == -1)
1112
 
    return CURLE_AGAIN;
1113
 
 
1114
 
  if(ret1 != CURLE_OK)
1115
 
    return (CURLcode)ret1;
 
1120
  ret = Curl_read(c, sfd, buffer, buflen, &n1);
 
1121
 
 
1122
  if(ret != CURLE_OK)
 
1123
    return ret;
1116
1124
 
1117
1125
  *n = (size_t)n1;
1118
1126