zxid
view release on metacpan or search on metacpan
smimemime.c view on Meta::CPAN
}
nparts++;
if (*p == '\015') p++; /* Skip CRLF */
if (*p == '\012') p++; /* This is really mandatory */
start = p;
}
return nparts;
/* Called by: */
err:
if (parts) {
/* free what we have allocated so far */
for (sep_len = 0; sep_len < nparts; sep_len++)
if (parts[sep_len])
OPENSSL_free(parts[sep_len]);
}
return -1;
}
/* Called by: main */
char*
mime_raw_entity(const char* text, const char* type)
{
char* b;
if (!(b = strdup("Content-type: "))) GOTO_ERR("no memory?");
if (!(b = concat(b, type))) goto err;
if (!(b = concat(b, CRLF CRLF))) goto err;
if (!(b = concat(b, text))) goto err;
return b;
err:
return NULL;
}
/* Called by: main x3 */
char*
mime_base64_entity(const char* data, int len, const char* type)
{
/*int n;*/
char* b64;
char* b;
if (!(b = strdup("Content-type: "))) GOTO_ERR("no memory?");
if (!(b = concat(b, type))) goto err;
if (!(b = concat(b, CRLF CRLF))) goto err;
/*n =*/ smime_base64(1, data, len, &b64);
if (!b64) GOTO_ERR("no memory?");
if (!(b = concat(b, b64))) goto err;
return b;
err:
return NULL;
}
/* Canonicalization involves converting LF->CRLF (Unix) and CR->CRLF (Mac).
* Canonicalization is of prime importance when signing data because
* verification assumes canonicalized form. This canonicalization is really
* not mime specific at all so you can use it for fixing PEM blobs
* on Mac (becaue OpenSSL does not understand lone CR as line termination). */
/* Called by: clear_sign, extract_certificate, extract_request, main, open_private_key, sign */
char*
mime_canon(const char* s)
{
char* d;
char* p;
int len;
len = strlen(s);
p = d = (char*)OPENSSL_malloc(len + len); /* Reserve spaces for CR's to be inserted. */
if (!d) GOTO_ERR("no memory?");
/* Scan and copy */
for (; *s; s++) {
if (s[0] != '\015' && s[0] != '\012')
*(p++) = *s; /* pass thru */
else {
if (s[0] == '\015' && s[1] == '\012') s++; /* already CRLF */
*(p++) = '\015'; *(p++) = '\012';
}
}
*(p++) = '\0';
/* Shrink the buffer back to actual size (not very likely to fail) */
return (char*)OPENSSL_realloc(d, (p-d));
err:
return NULL;
}
/* EOF - smimemime.c */
( run in 0.487 second using v1.01-cache-2.11-cpan-600a1bdf6e4 )