require glib 2.12. check for timegm().
authorDan Winship <danw@src.gnome.org>
Sat, 17 Mar 2007 17:55:30 +0000 (17:55 +0000)
committerDan Winship <danw@src.gnome.org>
Sat, 17 Mar 2007 17:55:30 +0000 (17:55 +0000)
* configure.in: require glib 2.12. check for timegm().

* libsoup/soup-date.c (soup_mktime_utc): Use timegm if available.
(soup_date_iso8601_parse): use g_time_val_from_iso8601. #337010,
patch from Emmanuele Bassi.

* libsoup/soup-types.h: remove local copy of
G_GNUC_NULL_TERMINATED since we now depend on a new-enough copy of
glib.

* libsoup/soup-misc.c (soup_base64_encode_close)
(soup_base64_encode_step, soup_base64_encode)
(soup_base64_decode_step): Make these just be wrappers around the
glib base64 methods. (For now; eventually they'll just go away.)

* libsoup/soup-auth-basic.c (authenticate):
* libsoup/soup-auth-digest.c (authenticate):
* libsoup/soup-connection-ntlm.c (soup_ntlm_parse_challenge)
(soup_ntlm_response):
* libsoup/soup-server-auth.c (soup_server_auth_new):
* libsoup/soup-soap-message.c (soup_soap_message_write_base64):
* libsoup/soup-xmlrpc-message.c
(soup_xmlrpc_message_write_base64):
* libsoup/soup-xmlrpc-response.c (soup_xmlrpc_value_get_base64):
Use glib base64 methods

svn path=/trunk/; revision=921

13 files changed:
ChangeLog
configure.in
libsoup/soup-auth-basic.c
libsoup/soup-auth-digest.c
libsoup/soup-connection-ntlm.c
libsoup/soup-date.c
libsoup/soup-misc.c
libsoup/soup-misc.h
libsoup/soup-server-auth.c
libsoup/soup-soap-message.c
libsoup/soup-types.h
libsoup/soup-xmlrpc-message.c
libsoup/soup-xmlrpc-response.c

index 736ab62..ea03272 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,31 @@
+2007-03-17  Dan Winship  <danw@novell.com>
+
+       * configure.in: require glib 2.12. check for timegm().
+
+       * libsoup/soup-date.c (soup_mktime_utc): Use timegm if available.
+       (soup_date_iso8601_parse): use g_time_val_from_iso8601. #337010,
+       patch from Emmanuele Bassi.
+
+       * libsoup/soup-types.h: remove local copy of
+       G_GNUC_NULL_TERMINATED since we now depend on a new-enough copy of
+       glib.
+
+       * libsoup/soup-misc.c (soup_base64_encode_close)
+       (soup_base64_encode_step, soup_base64_encode)
+       (soup_base64_decode_step): Make these just be wrappers around the
+       glib base64 methods. (For now; eventually they'll just go away.)
+
+       * libsoup/soup-auth-basic.c (authenticate): 
+       * libsoup/soup-auth-digest.c (authenticate):
+       * libsoup/soup-connection-ntlm.c (soup_ntlm_parse_challenge)
+       (soup_ntlm_response): 
+       * libsoup/soup-server-auth.c (soup_server_auth_new): 
+       * libsoup/soup-soap-message.c (soup_soap_message_write_base64): 
+       * libsoup/soup-xmlrpc-message.c
+       (soup_xmlrpc_message_write_base64): 
+       * libsoup/soup-xmlrpc-response.c (soup_xmlrpc_value_get_base64):
+       Use glib base64 methods
+
 2007-03-16  Dan Winship  <danw@novell.com>
 
        * libsoup/soup-message.c (soup_message_get_response_encoding):
index c4fe298..61f336d 100644 (file)
@@ -73,7 +73,7 @@ dnl ***********************
 dnl *** Checks for glib ***
 dnl ***********************
 
-AM_PATH_GLIB_2_0(2.6.0,,,gobject gthread)
+AM_PATH_GLIB_2_0(2.12.0,,,gobject gthread)
 
 PKG_CHECK_MODULES(XML, libxml-2.0)
 AC_SUBST(XML_CFLAGS)
@@ -106,6 +106,7 @@ dnl *******************
 dnl *** Misc checks ***
 dnl *******************
 AC_CHECK_FUNCS(gmtime_r)
+AC_CHECK_FUNCS(timegm)
 
 dnl *********************************
 dnl *** Networking library checks ***
index f91acd0..235b7f3 100644 (file)
@@ -118,7 +118,7 @@ authenticate (SoupAuth *auth, const char *username, const char *password)
        user_pass = g_strdup_printf ("%s:%s", username, password);
        len = strlen (user_pass);
 
-       priv->token = soup_base64_encode (user_pass, len);
+       priv->token = g_base64_encode ((guchar *)user_pass, len);
 
        memset (user_pass, 0, len);
        g_free (user_pass);
index bf54d0d..6b91147 100644 (file)
@@ -1,4 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-digest-offset: 8 -*- */
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
 /*
  * soup-auth-digest.c: HTTP Digest Authentication
  *
@@ -258,7 +258,7 @@ authenticate (SoupAuth *auth, const char *username, const char *password)
                                auth,
                                (unsigned long) getpid (),
                                (unsigned long) time (0));
-       priv->cnonce = soup_base64_encode (bgen, strlen (bgen));
+       priv->cnonce = g_base64_encode ((guchar *)bgen, strlen (bgen));
        g_free (bgen);
 
        priv->user = g_strdup (username);
index 7fe1270..0550922 100644 (file)
@@ -328,25 +328,14 @@ soup_ntlm_parse_challenge (const char *challenge,
                           char      **nonce,
                           char      **default_domain)
 {
-       int clen, decodelen;
+       gsize clen;
        NTLMString domain;
        guchar *chall;
-       int state;
-       unsigned int save;
 
        if (strncmp (challenge, "NTLM ", 5) != 0)
                return FALSE;
 
-       decodelen = strlen (challenge) - 5;
-       chall = g_malloc (decodelen);
-
-       state = save = 0;
-       clen = soup_base64_decode_step ((const guchar *) challenge + 5, 
-                                       decodelen,
-                                       chall, 
-                                       &state, 
-                                       &save);
-
+       chall = g_base64_decode (challenge + 5, &clen);
        if (clen < NTLM_CHALLENGE_DOMAIN_STRING_OFFSET ||
            clen < NTLM_CHALLENGE_NONCE_OFFSET + NTLM_CHALLENGE_NONCE_LENGTH) {
                g_free (chall);
@@ -385,7 +374,7 @@ soup_ntlm_response (const char *nonce,
        int hlen, dlen, ulen, offset;
        guchar hash[21], lm_resp[24], nt_resp[24];
        NTLMResponse resp;
-       guchar *out, *p;
+       char *out, *p;
        int state, save;
 
        nt_hash (password, hash);
@@ -411,51 +400,27 @@ soup_ntlm_response (const char *nonce,
        ntlm_set_string (&resp.nt_resp, &offset, sizeof (nt_resp));
 
        out = g_malloc (((offset + 3) * 4) / 3 + 6);
-       strncpy ((char *)out, "NTLM ", 5);
+       strncpy (out, "NTLM ", 5);
        p = out + 5;
 
        state = save = 0;
 
-       p += soup_base64_encode_step ((guchar *) &resp, 
-                                     sizeof (resp), 
-                                     FALSE, 
-                                     p, 
-                                     &state, 
-                                     &save);
-       p += soup_base64_encode_step ((const guchar *) domain, 
-                                     dlen, 
-                                     FALSE, 
-                                     p, 
-                                     &state, 
-                                     &save);
-       p += soup_base64_encode_step ((const guchar *) user, 
-                                     ulen, 
-                                     FALSE, 
-                                     p, 
-                                     &state, 
-                                     &save);
-       p += soup_base64_encode_step ((const guchar *) host, 
-                                     hlen, 
-                                     FALSE, 
-                                     p,
-                                     &state, 
-                                     &save);
-       p += soup_base64_encode_step (lm_resp, 
-                                     sizeof (lm_resp), 
-                                     FALSE, 
-                                     p, 
-                                     &state, 
-                                     &save);
-
-       p += soup_base64_encode_close (nt_resp, 
-                                      sizeof (nt_resp), 
-                                      FALSE, 
-                                      p, 
-                                      &state, 
-                                      &save);
+       p += g_base64_encode_step ((const guchar *) &resp, sizeof (resp), 
+                                  FALSE, p, &state, &save);
+       p += g_base64_encode_step ((const guchar *) domain, dlen, 
+                                  FALSE, p, &state, &save);
+       p += g_base64_encode_step ((const guchar *) user, ulen, 
+                                  FALSE, p, &state, &save);
+       p += g_base64_encode_step ((const guchar *) host, hlen, 
+                                  FALSE, p, &state, &save);
+       p += g_base64_encode_step (lm_resp, sizeof (lm_resp), 
+                                  FALSE, p, &state, &save);
+       p += g_base64_encode_step (nt_resp, sizeof (nt_resp), 
+                                  FALSE, p, &state, &save);
+       p += g_base64_encode_close (FALSE, p, &state, &save);
        *p = '\0';
 
-       return (char *)out;
+       return out;
 }
 
 /* DES utils */
index 90c37d8..e085366 100644 (file)
@@ -26,10 +26,6 @@ static const char *days[] = {
        "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
 };
 
-static const int days_before[] = {
-       0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334
-};
-
 static int
 parse_month (const char *month)
 {
@@ -54,12 +50,18 @@ parse_month (const char *month)
 time_t
 soup_mktime_utc (struct tm *tm)
 {
+#if HAVE_TIMEGM
+       return timegm (tm);
+#else
        time_t tt;
+       static const int days_before[] = {
+               0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334
+       };
 
        /* We check the month because (a) if we don't, the
         * days_before[] part below may access random memory, and (b)
         * soup_date_parse() doesn't check the return value of
-        * parse_month(). The caller is responsible for ensure the
+        * parse_month(). The caller is responsible for ensuring the
         * sanity of everything else.
         */
        if (tm->tm_mon < 0 || tm->tm_mon > 11)
@@ -71,7 +73,9 @@ soup_mktime_utc (struct tm *tm)
        if (tm->tm_year % 4 == 0 && tm->tm_mon < 2)
                tt--;
        tt = ((((tt * 24) + tm->tm_hour) * 60) + tm->tm_min) * 60 + tm->tm_sec;
+       
        return tt;
+#endif
 }
 
 /**
@@ -185,6 +189,7 @@ char *
 soup_date_generate (time_t when)
 {
        struct tm tm;
+
        soup_gmtime (&when, &tm);
 
        /* RFC1123 format, eg, "Sun, 06 Nov 1994 08:49:37 GMT" */
@@ -206,59 +211,10 @@ soup_date_generate (time_t when)
 time_t
 soup_date_iso8601_parse (const char *timestamp)
 {
-       struct tm tm;
-       long val;
-       time_t tt;
-
-       val = strtoul (timestamp, (char **)&timestamp, 10);
-       if (*timestamp == '-') {
-               // YYYY-MM-DD
-               tm.tm_year = val - 1900;
-               timestamp++;
-               tm.tm_mon = strtoul (timestamp, (char **)&timestamp, 10) - 1;
-               if (*timestamp++ != '-')
-                       return -1;
-               tm.tm_mday = strtoul (timestamp, (char **)&timestamp, 10);
-       } else {
-               // YYYYMMDD
-               tm.tm_mday = val % 100;
-               tm.tm_mon = (val % 10000) / 100 - 1;
-               tm.tm_year = val / 10000 - 1900;
-       }
-
-       if (*timestamp++ != 'T')
-               return -1;
-
-       val = strtoul (timestamp, (char **)&timestamp, 10);
-       if (*timestamp == ':') {
-               // hh:mm:ss
-               tm.tm_hour = val;
-               timestamp++;
-               tm.tm_min = strtoul (timestamp, (char **)&timestamp, 10);
-               if (*timestamp++ != ':')
-                       return -1;
-               tm.tm_sec = strtoul (timestamp, (char **)&timestamp, 10);
-       } else {
-               // hhmmss
-               tm.tm_sec = val % 100;
-               tm.tm_min = (val % 10000) / 100;
-               tm.tm_hour = val / 10000;
-       }
+       GTimeVal timeval;
 
-       tt = soup_mktime_utc (&tm);
+       if (!g_time_val_from_iso8601 (timestamp, &timeval))
+               return (time_t) -1;
 
-       if (*timestamp == '.')
-               strtoul (timestamp + 1, (char **)&timestamp, 10);
-
-       if (*timestamp == '+' || *timestamp == '-') {
-               int sign = (*timestamp == '+') ? -1 : 1;
-               val = strtoul (timestamp + 1, (char **)&timestamp, 10);
-               if (*timestamp == ':')
-                       val = 60 * val + strtoul (timestamp + 1, NULL, 10);
-               else
-                       val = 60 * (val / 100) + (val % 100);
-               tt += sign * val;
-       }
-
-       return tt;
+       return (time_t) timeval.tv_sec;
 }
index d98ff4a..252596d 100644 (file)
@@ -50,16 +50,6 @@ soup_str_case_equal (gconstpointer v1,
        return g_ascii_strcasecmp (string1, string2) == 0;
 }
 
-/* Base64 utils (straight from camel-mime-utils.c) */
-#define d(x)
-
-static const char *base64_alphabet =
-       "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
-
-/* 
- * call this when finished encoding everything, to
- * flush off the last little bit 
- */
 int
 soup_base64_encode_close (const guchar  *in, 
                          int            inlen, 
@@ -68,53 +58,19 @@ soup_base64_encode_close (const guchar  *in,
                          int           *state, 
                          int           *save)
 {
-       int c1, c2;
-       unsigned char *outptr = out;
-
-       if (inlen > 0)
-               outptr += soup_base64_encode_step (in, 
-                                                  inlen, 
-                                                  break_lines, 
-                                                  outptr, 
-                                                  state, 
-                                                  save);
-
-       c1 = ((unsigned char *) save) [1];
-       c2 = ((unsigned char *) save) [2];
-       
-       d(printf("mode = %d\nc1 = %c\nc2 = %c\n",
-                (int)((char *) save) [0],
-                (int)((char *) save) [1],
-                (int)((char *) save) [2]));
-
-       switch (((char *) save) [0]) {
-       case 2:
-               outptr [2] = base64_alphabet[ ( (c2 &0x0f) << 2 ) ];
-               g_assert (outptr [2] != 0);
-               goto skip;
-       case 1:
-               outptr[2] = '=';
-       skip:
-               outptr [0] = base64_alphabet [ c1 >> 2 ];
-               outptr [1] = base64_alphabet [ c2 >> 4 | ( (c1&0x3) << 4 )];
-               outptr [3] = '=';
-               outptr += 4;
-               break;
+       if (inlen > 0) {
+               out += soup_base64_encode_step (in, 
+                                               inlen, 
+                                               break_lines, 
+                                               out, 
+                                               state, 
+                                               save);
        }
-       if (break_lines)
-               *outptr++ = '\n';
 
-       *save = 0;
-       *state = 0;
-
-       return outptr-out;
+       return (int)g_base64_encode_close (break_lines, (char *) out,
+                                          state, save);
 }
 
-/*
- * performs an 'encode step', only encodes blocks of 3 characters to the
- * output at a time, saves left-over state in state and save (initialise to
- * 0 on first invocation).
- */
 int
 soup_base64_encode_step (const guchar  *in, 
                         int            len, 
@@ -123,142 +79,16 @@ soup_base64_encode_step (const guchar  *in,
                         int           *state, 
                         int           *save)
 {
-       register guchar *outptr;
-       register const guchar *inptr;
-
-       if (len <= 0)
-               return 0;
-
-       inptr = in;
-       outptr = out;
-
-       d (printf ("we have %d chars, and %d saved chars\n", 
-                  len, 
-                  ((char *) save) [0]));
-
-       if (len + ((char *) save) [0] > 2) {
-               const guchar *inend = in+len-2;
-               register int c1, c2, c3;
-               register int already;
-
-               already = *state;
-
-               switch (((char *) save) [0]) {
-               case 1: c1 = ((unsigned char *) save) [1]; goto skip1;
-               case 2: c1 = ((unsigned char *) save) [1];
-                       c2 = ((unsigned char *) save) [2]; goto skip2;
-               }
-               
-               /* 
-                * yes, we jump into the loop, no i'm not going to change it, 
-                * it's beautiful! 
-                */
-               while (inptr < inend) {
-                       c1 = *inptr++;
-               skip1:
-                       c2 = *inptr++;
-               skip2:
-                       c3 = *inptr++;
-                       *outptr++ = base64_alphabet [ c1 >> 2 ];
-                       *outptr++ = base64_alphabet [ c2 >> 4 | 
-                                                     ((c1&0x3) << 4) ];
-                       *outptr++ = base64_alphabet [ ((c2 &0x0f) << 2) | 
-                                                     (c3 >> 6) ];
-                       *outptr++ = base64_alphabet [ c3 & 0x3f ];
-                       /* this is a bit ugly ... */
-                       if (break_lines && (++already)>=19) {
-                               *outptr++='\n';
-                               already = 0;
-                       }
-               }
-
-               ((char *)save)[0] = 0;
-               len = 2-(inptr-inend);
-               *state = already;
-       }
-
-       d(printf("state = %d, len = %d\n",
-                (int)((char *)save)[0],
-                len));
-
-       if (len>0) {
-               register char *saveout;
-
-               /* points to the slot for the next char to save */
-               saveout = & (((char *)save)[1]) + ((char *)save)[0];
-
-               /* len can only be 0 1 or 2 */
-               switch(len) {
-               case 2: *saveout++ = *inptr++;
-               case 1: *saveout++ = *inptr++;
-               }
-               ((char *)save)[0]+=len;
-       }
-
-       d(printf("mode = %d\nc1 = %c\nc2 = %c\n",
-                (int)((char *)save)[0],
-                (int)((char *)save)[1],
-                (int)((char *)save)[2]));
-
-       return outptr-out;
+       return (int)g_base64_encode_step (in, len, break_lines,
+                                         (char *)out, state, save);
 }
 
-/**
- * soup_base64_encode:
- * @text: the binary data to encode.
- * @len: the length of @text.
- *
- * Encode a sequence of binary data into it's Base-64 stringified
- * representation.
- *
- * Return value: The Base-64 encoded string representing @text.
- */
 char *
 soup_base64_encode (const char *text, int len)
 {
-        unsigned char *out;
-        int state = 0, outlen,  save = 0;
-        
-        out = g_malloc (len * 4 / 3 + 5);
-        outlen = soup_base64_encode_close ((const guchar *)text,
-                                          len, 
-                                          FALSE,
-                                          out, 
-                                          &state, 
-                                          &save);
-        out[outlen] = '\0';
-        return (char *) out;
+       return g_base64_encode ((const guchar *)text, len);
 }
 
-static unsigned char camel_mime_base64_rank[256] = {
-       255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
-       255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
-       255,255,255,255,255,255,255,255,255,255,255, 62,255,255,255, 63,
-        52, 53, 54, 55, 56, 57, 58, 59, 60, 61,255,255,255,  0,255,255,
-       255,  0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14,
-        15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,255,255,255,255,255,
-       255, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
-        41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51,255,255,255,255,255,
-       255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
-       255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
-       255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
-       255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
-       255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
-       255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
-       255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
-       255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
-};
-
-/**
- * base64_decode_step: decode a chunk of base64 encoded data
- * @in: input stream
- * @len: max length of data to decode
- * @out: output stream
- * @state: holds the number of bits that are stored in @save
- * @save: leftover bits that have not yet been decoded
- *
- * Decodes a chunk of base64 encoded data
- **/
 int
 soup_base64_decode_step (const guchar  *in, 
                         int            len, 
@@ -266,68 +96,20 @@ soup_base64_decode_step (const guchar  *in,
                         int           *state, 
                         guint         *save)
 {
-       register const guchar *inptr;
-       register guchar *outptr;
-       const guchar *inend;
-       guchar c;
-       register unsigned int v;
-       int i;
-
-       inend = in+len;
-       outptr = out;
-
-       /* convert 4 base64 bytes to 3 normal bytes */
-       v=*save;
-       i=*state;
-       inptr = in;
-       while (inptr < inend) {
-               c = camel_mime_base64_rank [*inptr++];
-               if (c != 0xff) {
-                       v = (v<<6) | c;
-                       i++;
-                       if (i==4) {
-                               *outptr++ = v>>16;
-                               *outptr++ = v>>8;
-                               *outptr++ = v;
-                               i=0;
-                       }
-               }
-       }
-
-       *save = v;
-       *state = i;
-
-       /* quick scan back for '=' on the end somewhere */
-       /* fortunately we can drop 1 output char for each trailing = (upto 2) */
-       i=2;
-       while (inptr > in && i) {
-               inptr--;
-               if (camel_mime_base64_rank [*inptr] != 0xff) {
-                       if (*inptr == '=')
-                               outptr--;
-                       i--;
-               }
-       }
-
-       /* if i!= 0 then there is a truncation error! */
-       return outptr - out;
+       return (int) g_base64_decode_step ((const char *)in, len,
+                                          out, state, save);
 }
 
 char *
 soup_base64_decode (const char   *text,
                    int          *out_len)
 {
-       guchar *ret;
-       int inlen, state = 0;
-       unsigned int save = 0;
-
-       inlen = strlen (text);
-       ret = g_malloc0 (inlen);
-
-       *out_len = soup_base64_decode_step ((const guchar *)text, inlen,
-                                           ret, &state, &save);
+       char *ret;
+       gsize out_len_tmp;
 
-       return (char *)ret; 
+       ret = (char *) g_base64_decode (text, &out_len_tmp);
+       *out_len = out_len_tmp;
+       return ret;
 }
 
 typedef struct {
index 2d739e3..a25cdf9 100644 (file)
@@ -9,7 +9,8 @@
 #include <glib-object.h>
 #include <libxml/tree.h>
 
-/* Base64 encoding/decoding */
+#ifndef LIBSOUP_DISABLE_DEPRECATED
+/* Base64 encoding/decoding. DEPRECATED: use <glib/base64.h> */
 
 char              *soup_base64_encode        (const char   *text,
                                              int           len);
@@ -36,6 +37,7 @@ int                soup_base64_decode_step   (const guchar *in,
                                              guchar       *out, 
                                              int          *state, 
                                              guint        *save);
+#endif /* LIBSOUP_DISABLE_DEPRECATED */
 
 /* Non-default-GMainContext operations */
 GSource           *soup_add_io_watch         (GMainContext *async_context,
index ee5cf54..e2c5138 100644 (file)
@@ -352,23 +352,24 @@ soup_server_auth_new (SoupServerAuthContext *auth_ctx,
        switch (type) {
        case SOUP_AUTH_TYPE_BASIC:
                {
-                       gchar *userpass, *colon;
-                       gint len;
+                       guchar *userpass, *colon;
+                       gsize len;
 
-                       userpass = soup_base64_decode (header, &len);
+                       userpass = g_base64_decode (header, &len);
                        if (!userpass)
                                break;
 
-                       colon = strchr (userpass, ':');
+                       colon = memchr (userpass, ':', len);
                        if (!colon) {
                                g_free (userpass);
                                break;
                        }
 
                        ret->basic.type = SOUP_AUTH_TYPE_BASIC;
-                       ret->basic.user = g_strndup (userpass, 
+                       ret->basic.user = g_strndup ((char *)userpass, 
                                                     colon - userpass);
-                       ret->basic.passwd = g_strdup (colon + 1);
+                       ret->basic.passwd = g_strndup ((char *)colon + 1,
+                                                      len - (colon + 1 - userpass));
 
                        g_free (userpass);
 
index 364a7b1..0c50c72 100644 (file)
@@ -513,7 +513,7 @@ soup_soap_message_write_double (SoupSoapMessage *msg, double d)
 void
 soup_soap_message_write_base64 (SoupSoapMessage *msg, const char *string, int len)
 {
-        gchar *str = soup_base64_encode (string, len);
+        gchar *str = g_base64_encode ((const guchar *)string, len);
         soup_soap_message_write_string (msg, str);
         g_free (str);
 }
index 1370583..ecd7282 100644 (file)
@@ -49,13 +49,4 @@ GType type_name##_get_type(void)\
        return type;                                    \
 }
 
-/* Compat for glib 2.6.x */
-#ifndef G_GNUC_NULL_TERMINATED
-#  if __GNUC__ >= 4
-#  define G_GNUC_NULL_TERMINATED __attribute__((__sentinel__))
-#  else
-#  define G_GNUC_NULL_TERMINATED
-#  endif
-#endif
-
 #endif
index 05100ef..b2954b9 100644 (file)
@@ -226,7 +226,7 @@ soup_xmlrpc_message_write_base64 (SoupXmlrpcMessage *msg, gconstpointer buf, int
        g_return_if_fail (SOUP_IS_XMLRPC_MESSAGE (msg));
        priv = SOUP_XMLRPC_MESSAGE_GET_PRIVATE (msg);
 
-       str = soup_base64_encode (buf, len);
+       str = g_base64_encode (buf, len);
 
        priv->last_node = xmlNewChild (priv->last_node, NULL, (const xmlChar *)"value", NULL);
        xmlNewTextChild (priv->last_node, NULL, (const xmlChar *)"base64", (xmlChar *)str);
index 84dabf0..ab0f82c 100644 (file)
@@ -361,8 +361,8 @@ soup_xmlrpc_value_get_base64 (SoupXmlrpcValue *value, GByteArray **data)
 {
        xmlNode *xml;
        xmlChar *content;
-       char *decoded;
-       int len;
+       guchar *decoded;
+       gsize len;
 
        xml = (xmlNode *) value;
        if (strcmp ((const char *)xml->name, "value"))
@@ -372,11 +372,11 @@ soup_xmlrpc_value_get_base64 (SoupXmlrpcValue *value, GByteArray **data)
                return FALSE;
 
        content = xmlNodeGetContent (xml);
-       decoded = soup_base64_decode ((const char *)content, &len);
+       decoded = g_base64_decode ((const char *)content, &len);
        xmlFree (content);
 
        *data = g_byte_array_new ();
-       g_byte_array_append (*data, (guchar *)decoded, len);
+       g_byte_array_append (*data, decoded, len);
        g_free (decoded);
 
        return TRUE;