~ubuntu-branches/debian/sid/glib2.0/sid

« back to all changes in this revision

Viewing changes to glib/gbase64.c

  • Committer: Package Import Robot
  • Author(s): Martin Pitt
  • Date: 2013-05-08 06:25:57 UTC
  • mfrom: (1.27.14) (3.1.181 experimental)
  • Revision ID: package-import@ubuntu.com-20130508062557-i7gbku66mls70gi2
Tags: 2.36.1-2
Merge experimental branch, upload to unstable.

Show diffs side-by-side

added added

removed removed

Lines of Context:
344
344
  /* convert 4 base64 bytes to 3 normal bytes */
345
345
  v=*save;
346
346
  i=*state;
 
347
 
 
348
  last[0] = last[1] = 0;
 
349
 
 
350
  /* we use the sign in the state to determine if we got a padding character
 
351
     in the previous sequence */
 
352
  if (i < 0)
 
353
    {
 
354
      i = -i;
 
355
      last[0] = '=';
 
356
    }
 
357
 
347
358
  inptr = (const guchar *)in;
348
 
  last[0] = last[1] = 0;
349
359
  while (inptr < inend)
350
360
    {
351
361
      c = *inptr++;
369
379
    }
370
380
 
371
381
  *save = v;
372
 
  *state = i;
 
382
  *state = last[0] == '=' ? -i : i;
373
383
 
374
384
  return outptr - out;
375
385
}
379
389
 * @text: zero-terminated string with base64 text to decode
380
390
 * @out_len: (out): The length of the decoded data is written here
381
391
 *
382
 
 * Decode a sequence of Base-64 encoded text into binary data
 
392
 * Decode a sequence of Base-64 encoded text into binary data.  Note
 
393
 * that the returned binary data is not necessarily zero-terminated,
 
394
 * so it should not be used as a character string.
383
395
 *
384
396
 * Return value: (transfer full) (array length=out_len) (element-type guint8):
385
397
 *               newly allocated buffer containing the binary data