Qsmtp  0.30dev
Functions | Variables
qrdata.c File Reference

send message body to remote host More...

#include <qremote/qrdata.h>
#include <fmt.h>
#include <log.h>
#include <netio.h>
#include <qremote/client.h>
#include <qremote/greeting.h>
#include <qremote/mime.h>
#include <qremote/qremote.h>
#include <version.h>
#include <assert.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <sys/mman.h>
#include <sys/types.h>
#include <syslog.h>
#include <unistd.h>

Functions

unsigned int need_recode (const char *buf, off_t len)
 
static void send_plain (const char *buf, const off_t len)
 
static void recodeheader (void)
 
static off_t wrap_line (const char *buf, off_t len)
 
static off_t send_wrapped (const char *buf, off_t pos, off_t *off, off_t *ll, const unsigned int l)
 
static void wrap_header (const char *buf, const off_t len)
 
static off_t qp_header (const char *buf, const off_t len, cstring *boundary, int *multipart, const unsigned int body_recode)
 
static void recode_qp (const char *buf, const off_t len)
 
static off_t skip_tpad (const char *buf, const off_t len)
 
static void send_qp (const char *buf, const off_t len)
 
void send_data (unsigned int recodeflag)
 

Variables

const char * successmsg [] = {NULL, " accepted ", NULL, "message", "", "", "./Remote host said: ", NULL}
 
const char * msgdata
 
off_t msgsize
 
static int lastlf = 1
 

Detailed Description

send message body to remote host

This file contains the functions to send the message body to the remote host. Both DATA and BDAT modes are supported. In DATA mode the message will be recoded to quoted-printable if necessary.

Function Documentation

unsigned int need_recode ( const char *  buf,
off_t  len 
)

check if buffer has to be recoded for SMTP transfer

Parameters
bufbuffer to scan
lenlength of buffer
Returns
logical or of:
  • 1: buffer has 8bit characters
  • 2: buffer contains line longer 998 chars
  • 4: header contains line longer 998 chars
static off_t qp_header ( const char *  buf,
const off_t  len,
cstring boundary,
int *  multipart,
const unsigned int  body_recode 
)
static

scan and recode header: fix Content-Transfer-Encoding, check for boundary

Parameters
bufbuffer to scan
lenlength of buffer
boundaryif this is a multipart message a pointer to the boundary-string is stored here
multipartwill be set to 1 if this is a multipart message
body_recodeif the body needs recoding (i.e. the CTE-header needs to be set)
Returns
offset of end of header
Warning
boundary will not be 0-terminated! Use boundary->len!
static void recode_qp ( const char *  buf,
const off_t  len 
)
static

recode buffer to quoted-printable and send it to remote host

Parameters
bufdata to send
lenlength of buffer
void send_data ( unsigned int  recodeflag)

send the message data

Parameters
recodeflagthe result of need_recode() for the input data
static void send_plain ( const char *  buf,
const off_t  len 
)
static

send message body, only fix broken line endings if present

Parameters
bufbuffer to send
lenlength of data in buffer

lastlf will be set if last 2 bytes sent were CRLF

static void send_qp ( const char *  buf,
const off_t  len 
)
static

send message body, do quoted-printable recoding where needed

Parameters
bufbuffer to encode
lenlength of buffer
static off_t skip_tpad ( const char *  buf,
const off_t  len 
)
static

skip transport padding after boundaries (trailing whitespace and [CR]LF)

Parameters
bufbuffer to encode
lenlength of buffer
Returns
number of bytes skipped
static void wrap_header ( const char *  buf,
const off_t  len 
)
static

fold long lines in header

Parameters
bufbuffer to send
lenlength of buffer
static off_t wrap_line ( const char *  buf,
off_t  len 
)
static

fold one long header line

Parameters
bufbeginning of line
lenlength of line without CR, LF or CRLF