Also changed this parameter to an enum.
char *encoded_data = malloc((data_length * 2) + 100);
if (encoded_data) {
sprintf(encoded_data, "Content-type: text/plain; charset=UTF-8\nContent-transfer-encoding: base64\n\n");
- CtdlEncodeBase64(&encoded_data[strlen(encoded_data)], unencoded_data, data_length, 1);
+ CtdlEncodeBase64(&encoded_data[strlen(encoded_data)], unencoded_data, data_length, BASE64_YES_LINEBREAKS);
char userconfigroomname[ROOMNAMELEN];
struct ctdluser usbuf;
char *encoded_data = malloc((data_length * 2) + 100);
if (encoded_data) {
sprintf(encoded_data, "Content-type: %s\nContent-transfer-encoding: base64\n\n", mimetype);
- CtdlEncodeBase64(&encoded_data[strlen(encoded_data)], unencoded_data, data_length, 1);
+ CtdlEncodeBase64(&encoded_data[strlen(encoded_data)], unencoded_data, data_length, BASE64_YES_LINEBREAKS);
long new_msgnum = quickie_message("Citadel", NULL, NULL, SYSCONFIGROOM, encoded_data, FMT_RFC822, "Image uploaded by admin user");
if (CtdlGetRoomLock(&CC->room, CC->room.QRname) == 0) {
char *encoded_data = malloc((data_length * 2) + 100);
if (encoded_data) {
sprintf(encoded_data, "Content-type: %s\nContent-transfer-encoding: base64\n\n", mimetype);
- CtdlEncodeBase64(&encoded_data[strlen(encoded_data)], unencoded_data, data_length, 1);
+ CtdlEncodeBase64(&encoded_data[strlen(encoded_data)], unencoded_data, data_length, BASE64_YES_LINEBREAKS);
long new_msgnum = quickie_message("Citadel", NULL, NULL, userconfigroomname, encoded_data, FMT_RFC822, "Photo uploaded by user");
if (CtdlGetUserLock(&usbuf, username) == 0) { // lock it this time
char *encoded_data = malloc((data_length * 2) + 100);
if (encoded_data) {
sprintf(encoded_data, "Content-type: %s\nContent-transfer-encoding: base64\n\n", GuessMimeByFilename(path, strlen(path)));
- CtdlEncodeBase64(&encoded_data[strlen(encoded_data)], unencoded_data, data_length, 1);
+ CtdlEncodeBase64(&encoded_data[strlen(encoded_data)], unencoded_data, data_length, BASE64_YES_LINEBREAKS);
char userconfigroomname[ROOMNAMELEN];
struct ctdluser usbuf;
}
if (!strcasecmp(Params[2].Key, "LOGIN")) {
- size_t len = CtdlEncodeBase64(UsrBuf, "Username:", 9, 0);
+ size_t len = CtdlEncodeBase64(UsrBuf, "Username:", 9, BASE64_NO_LINEBREAKS);
if (UsrBuf[len - 1] == '\n') {
UsrBuf[len - 1] = '\0';
}
}
if (!strcasecmp(Params[2].Key, "PLAIN")) {
- // size_t len = CtdlEncodeBase64(UsrBuf, "Username:", 9, 0);
+ // size_t len = CtdlEncodeBase64(UsrBuf, "Username:", 9, BASE64_NO_LINEBREAKS);
// if (UsrBuf[len - 1] == '\n') {
// UsrBuf[len - 1] = '\0';
// }
case imap_as_expecting_username:
StrBufDecodeBase64(Imap->Cmd.CmdBuf);
CtdlLoginExistingUser(ChrPtr(Imap->Cmd.CmdBuf));
- size_t len = CtdlEncodeBase64(PWBuf, "Password:", 9, 0);
+ size_t len = CtdlEncodeBase64(PWBuf, "Password:", 9, BASE64_NO_LINEBREAKS);
if (PWBuf[len - 1] == '\n') {
PWBuf[len - 1] = '\0';
}
}
else {
// Once we do the encoding we know the exact size
- encoded_len = CtdlEncodeBase64(encoded_msg, (char *)smr.ser, smr.len, 1);
+ encoded_len = CtdlEncodeBase64(encoded_msg, (char *)smr.ser, smr.len, BASE64_YES_LINEBREAKS);
// Careful now. If the message is gargantuan, trying to write multiple gigamegs in one
// big write operation can make our transport unhappy. So we'll chunk it up 10 KB at a time.
StrBufDecodeBase64(UserName);
if (CtdlLoginExistingUser(ChrPtr(UserName)) == login_ok) {
- size_t len = CtdlEncodeBase64(buf, "Password:", 9, 0);
+ size_t len = CtdlEncodeBase64(buf, "Password:", 9, BASE64_NO_LINEBREAKS);
if (buf[len - 1] == '\n') {
buf[len - 1] = '\0';
smtp_get_user(11);
}
else {
- size_t len = CtdlEncodeBase64(username_prompt, "Username:", 9, 0);
+ size_t len = CtdlEncodeBase64(username_prompt, "Username:", 9, BASE64_NO_LINEBREAKS);
if (username_prompt[len - 1] == '\n') {
username_prompt[len - 1] = '\0';
}
encoded_data = malloc((data_length * 2) + 100);
if (encoded_data) {
sprintf(encoded_data, "Content-type: text/plain\nContent-transfer-encoding: base64\n\n");
- CtdlEncodeBase64(&encoded_data[strlen(encoded_data)], unencoded_data, data_length, 1);
+ CtdlEncodeBase64(&encoded_data[strlen(encoded_data)], unencoded_data, data_length, BASE64_YES_LINEBREAKS);
snprintf(subject, sizeof subject, "Imported room banner for %s", roomname);
info_msgnum = quickie_message("Citadel", NULL, NULL, SYSCONFIGROOM, encoded_data, FMT_RFC822, subject);
free(encoded_data);
encoded_data = malloc((data_length * 2) + 100);
if (encoded_data) {
sprintf(encoded_data, "Content-type: image/gif\nContent-transfer-encoding: base64\n\n");
- CtdlEncodeBase64(&encoded_data[strlen(encoded_data)], unencoded_data, data_length, 1);
+ CtdlEncodeBase64(&encoded_data[strlen(encoded_data)], unencoded_data, data_length, BASE64_YES_LINEBREAKS);
snprintf(subject, sizeof subject, "Imported room icon for %s", roomname);
pic_msgnum = quickie_message("Citadel", NULL, NULL, SYSCONFIGROOM, encoded_data, FMT_RFC822, subject);
free(encoded_data);
CC->user.fullname,
CtdlGetConfigStr("c_nodename"));
- memolen = CtdlEncodeBase64(encoded_memo, memo, memolen, 0);
+ memolen = CtdlEncodeBase64(encoded_memo, memo, memolen, BASE64_YES_LINEBREAKS);
StrBufAppendBufPlain(NewMsgText, HKEY("--"), 0);
StrBufAppendBufPlain(NewMsgText, boundary, -1, 0);
enc = malloc(len * 2);
if (enc) {
- enc_len = CtdlEncodeBase64(enc, raw_netconfig, len, 0);
+ enc_len = CtdlEncodeBase64(enc, raw_netconfig, len, BASE64_NO_LINEBREAKS);
if ((enc_len > 1) && (enc[enc_len-2] == 13)) enc[enc_len-2] = 0;
if ((enc_len > 0) && (enc[enc_len-1] == 10)) enc[enc_len-1] = 0;
enc[enc_len] = 0;
bytes_output += 4;
}
if ( ((bytes_processed % 57) == 0) || (bytes_processed >= sourcelen) ) {
- sprintf(&dest[bytes_output], "\r\n");
- bytes_output += 2;
+ if (linebreaks) {
+ sprintf(&dest[bytes_output], "\r\n");
+ bytes_output += 2;
+ }
}
}
unsigned long extract_unsigned_long(const char *source, int parmnum);
void CtdlInitBase64Table(void);
size_t CtdlEncodeBase64(char *dest, const char *source, size_t sourcelen, int linebreaks);
+enum {
+ BASE64_NO_LINEBREAKS = 0,
+ BASE64_YES_LINEBREAKS = 1
+};
size_t CtdlDecodeBase64(char *dest, const char *source, size_t length);
unsigned int decode_hex(char *Source);
int CtdlDecodeQuotedPrintable(char *decoded, char *encoded, int sourcelen);
result = (char*) malloc(sizeof(UTF8_HEADER) + 4 + length * 2);
strncpy (result, UTF8_HEADER, strlen (UTF8_HEADER));
- CtdlEncodeBase64(result + strlen(UTF8_HEADER), line, length, 0);
+ CtdlEncodeBase64(result + strlen(UTF8_HEADER), line, length, BASE64_NO_LINEBREAKS);
end = strlen (result);
result[end]='?';
result[end+1]='=';
if ((strcasecmp(hostbuf, host))
|| (strcasecmp(portbuf, port))) {
snprintf(buf, sizeof buf, "%s|%s|%s|%s|", hostbuf, portbuf, ubuf, pbuf);
- CtdlEncodeBase64(buf64, buf, strlen(buf), 0);
+ CtdlEncodeBase64(buf64, buf, strlen(buf), BASE64_NO_LINEBREAKS);
fprintf(fp, "%s\n", buf64);
}
}
if (!IsEmptyStr(username)) {
snprintf(buf, sizeof buf, "%s|%s|%s|%s|", host, port, username, password);
- CtdlEncodeBase64(buf64, buf, strlen(buf), 0);
+ CtdlEncodeBase64(buf64, buf, strlen(buf), BASE64_NO_LINEBREAKS);
fprintf(fp, "%s\n", buf64);
}
fclose(oldfp);
extract_token(password, h->request_body, 1, '|', sizeof password);
snprintf(buf, sizeof buf, "%s:%s", username, password);
- CtdlEncodeBase64(auth, buf, strlen(buf), 0);
+ CtdlEncodeBase64(auth, buf, strlen(buf), BASE64_NO_LINEBREAKS);
syslog(LOG_DEBUG, "try_login(username='%s',password=(%d bytes))", username, (int) strlen(password));
// Re-encode the auth string so it contains the properly formatted username
char new_auth_string[1024];
snprintf(new_auth_string, sizeof(new_auth_string), "%s:%s", c->whoami, supplied_password);
- CtdlEncodeBase64(c->auth, new_auth_string, strlen(new_auth_string), 0);
+ CtdlEncodeBase64(c->auth, new_auth_string, strlen(new_auth_string), BASE64_NO_LINEBREAKS);
return(0);
}
break;
}
syslog(LOG_DEBUG, "Attachment: raw len %d", StrLength(att->Data));
- encoded_strlen = CtdlEncodeBase64(encoded, ChrPtr(att->Data), StrLength(att->Data), 1);
+ encoded_strlen = CtdlEncodeBase64(encoded, ChrPtr(att->Data), StrLength(att->Data), BASE64_YES_LINEBREAKS);
syslog(LOG_DEBUG, "Attachment: encoded len %d", encoded_strlen);
serv_printf("--%s", top_boundary);
redirect, automsg, final
);
- size_t len = CtdlEncodeBase64(encoded_rule, rule, strlen(rule)+1, 0);
+ size_t len = CtdlEncodeBase64(encoded_rule, rule, strlen(rule)+1, BASE64_NO_LINEBREAKS);
if (encoded_rule[len - 1] == '\n') {
encoded_rule[len - 1] = '\0';
}