/** * Makes a message type specifically for gpg encryption and * signing. Specific MIME message descriptions are needed * when signing/encrypting a file before it is actuall signed * or encrypted. This function takes care of that. **/ static int makeGpgMessage(dstrbuf *in, dstrbuf *out, const char *border) { dstrbuf *qp=NULL; assert(in != NULL); assert(out != NULL); assert(border != NULL); if (Mopts.attach) { dsbPrintf(out, "Content-Type: multipart/mixed; " "boundary=\"%s\"\r\n\r\n", border); dsbPrintf(out, "\r\n--%s\r\n", border); } if (Mopts.html) { dsbPrintf(out, "Content-Type: text/html\r\n"); } else { dsbPrintf(out, "Content-Type: text/plain\r\n"); } dsbPrintf(out, "Content-Transfer-Encoding: quoted-printable\r\n\r\n"); qp = mimeQpEncodeString((u_char *)in->str, true); dsbnCat(out, qp->str, qp->len); dsbDestroy(qp); if (Mopts.attach) { attachFiles(border, out); dsbPrintf(out, "\r\n--%s--\r\n", border); } return 0; }
static dstrbuf * getMimeType(const char *str) { dstrbuf *ret = DSB_NEW; while (*str != ' ' && *str != '\t' && *str != '\0') { dsbnCat(ret, str, 1); str++; } return ret; }
/** * Makes a message type specifically for gpg encryption and * signing. Specific MIME message descriptions are needed * when signing/encrypting a file before it is actuall signed * or encrypted. This function takes care of that. **/ static int makeGpgMessage(dstrbuf *in, dstrbuf *out, const char *border) { char *ptr=NULL; dstrbuf *qp=NULL; assert(in != NULL); assert(out != NULL); assert(border != NULL); if (Mopts.attach) { dsbPrintf(out, "Content-Type: multipart/mixed; " "boundary=\"%s\"\r\n\r\n", border); dsbPrintf(out, "\r\n--%s\r\n", border); } if (Mopts.html) { dsbPrintf(out, "Content-Type: text/html\r\n"); } else { dsbPrintf(out, "Content-Type: text/plain\r\n"); } dsbPrintf(out, "Content-Transfer-Encoding: quoted-printable\r\n\r\n"); qp = mimeQpEncodeString((u_char *)in->str, true); /* Fix single dot on it's on line so we don't terminate the message prematurely. */ dstrbuf *formatted = DSB_NEW; char previous='\0'; for (ptr = qp->str; ptr && *ptr != '\0'; previous=*ptr, ptr++) { dsbCatChar(formatted, *ptr); /* If we have a dot starting on a newline. */ if ((previous == '\n' || previous == '\r') && *ptr == '.') { dsbCatChar(formatted, '.'); } } dsbDestroy(qp); dsbnCat(out, formatted->str, formatted->len); dsbDestroy(formatted); if (Mopts.attach) { attachFiles(border, out); dsbPrintf(out, "\r\n--%s--\r\n", border); } return 0; }