Exemple #1
0
/*---------------------------------------------------------------------------*/
char *b64buffer(const char *s, bool f)
{
    int     l = (int)strlen(s);                  // String size to encode or decode.

    if  (!l)                                // If the string size is 0...
        return  0;                       // ...return 0.

    return (char *)calloc((f ? b64blocks(l) : b64octets(l)),sizeof(char));
}
Exemple #2
0
char *b64buffer(char *s, bool f)
{
    int     l = strlen(s);                  // String size to encode or decode.
    char   *b;                              // String pointers.

    if  (!l)                                // If the string size is 0...
        return  NULL;                       // ...return null.

   if (!(b = (char *) calloc((f ? b64blocks(l) : b64octets(l)),
               sizeof(char))))
        printf("Insufficient real memory to %s \"%s\".\n",
              (f ? "encode" : "decode"), s);
    return  b;                              // Return the pointer or null.
}