Reuse, not rework

License Awareness

Highly Reusable Software

By activity
Professions, Sciences, Humanities, Business, ...

User Interface
Text-based, GUI, Audio, Video, Keyboards, Mouse, Images,...

Text Strings
Conversions, tests, processing, manipulation,...

Integer, Floating point, Matrix, Statistics, Boolean, ...

Algorithms, Memory, Process control, Debugging, ...

Stored Data
Data storage, Integrity, Encryption, Compression, ...

Networks, protocols, Interprocess, Remote, Client Server, ...

Hard World
Timing, Calendar and Clock, Audio, Video, Printer, Controls...

File System
Management, Filtering, File & Directory access, Viewers, ...


librock_base64decN - Decodes N bytes of MIME Base64 data.
#License - #Source code - #Example Use -


#include <librock/parse.h>

    const char *wptr.  /* Input buffer */
    int amt,     /* Bytes at input buffer.  Must be a multiple of 4 */
    char *optr;  /* Output buffer */


Decodes the amt bytes at wptr, encoded as MIME Base 64. The input and output buffer pointers can be equal. The amt must be a multiple of 4.

Returns the number of characters stored at optr, which is normally 3, but may be less than 3 at the end of the encoded block if there was padding.

Typical use is

#ifdef librock_TYPICAL_USE_base64decN
    #include <stdio.h>
    char *wptr = "U29tZSBlbmNvZGVkIHN0cmluZw==";
    char *optr = wptr;
    if (strlen(wptr) % 4) {
        fprintf(stderr,"%s","bad input.  base64 encodings are always a multiple of 4\n");
    } else {
        char *result = wptr; /* In place */
        optr += librock_base64decN(wptr,strlen(wptr),optr);
        *optr = '\0';


  // No external calls


  Copyright 1998-2002 Forrest J. Cavalier III,
  Licensed under BSD-ish license, NO WARRANTY. Copies must retain this block.
  License text in <librock/license/librock.txt> librock_LIDESC_HC=12440211096131f5976d36be0cddca4cd9152e45

Source Code

./comm/person/email/base64.c (implementation, plus source of this manual page)

This software is part of Librock

Rapid reuse, without rework. Details
This page copyright (C) 2002-2003 Forrest J. Cavalier III, d-b-a Mib Software, Saylorsburg PA 18353, USA

Verbatim copying and distribution of this generated page is permitted in any medium provided that no changes are made.
(The source of this manual page may be covered by a more permissive license which allows modifications.)

Want to help? We welcome comments, patches. -- Need help? Request paid support.