send.c revision 3f54fd611f536639ec30dd53c48e5ec1897cc7d9
/***********************************************************************
* *
* This software is part of the BSD package *
*Copyright (c) 1978-2011 The Regents of the University of California an*
* *
* Redistribution and use in source and binary forms, with or *
* without modification, are permitted provided that the following *
* conditions are met: *
* *
* 1. Redistributions of source code must retain the above *
* copyright notice, this list of conditions and the *
* following disclaimer. *
* *
* 2. Redistributions in binary form must reproduce the above *
* copyright notice, this list of conditions and the *
* materials provided with the distribution. *
* *
* 3. Neither the name of The Regents of the University of California*
* names of its contributors may be used to endorse or *
* promote products derived from this software without *
* specific prior written permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND *
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, *
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF *
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE *
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS *
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED *
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, *
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON *
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, *
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY *
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE *
* POSSIBILITY OF SUCH DAMAGE. *
* *
* Redistribution and use in source and binary forms, with or without *
* modification, are permitted provided that the following conditions *
* are met: *
* 1. Redistributions of source code must retain the above copyright *
* notice, this list of conditions and the following disclaimer. *
* 2. Redistributions in binary form must reproduce the above copyright *
* notice, this list of conditions and the following disclaimer in *
* distribution. *
* 3. Neither the name of the University nor the names of its *
* contributors may be used to endorse or promote products derived *
* from this software without specific prior written permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS" *
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS *
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, *
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT *
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF *
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND *
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, *
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT *
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF *
* SUCH DAMAGE. *
* *
* Kurt Shoens (UCB) *
* gsf *
* *
***********************************************************************/
#pragma prototyped
/*
* Mail -- a mail program
*
* Mail to others.
*/
#include "mailx.h"
struct letter {
};
/*
* Ouput message part to op.
*/
static int
part(register struct parse* pp, FILE* op, struct part* ap, off_t size, char* prefix, int prefixlen, int emptylen, unsigned long flags)
{
register int n = 0;
register int i;
int r = -1;
char* s;
int skip;
int line;
return -1;
mime(1) &&
goto bad;
}
mime(1) &&
return -1;
goto bad;
}
if (prefix) {
skip = 1;
line = 0;
while (size > 0) {
n = 0;
break;
}
if (!skip)
line++;
continue;
}
else
skip = 0;
#if 0
break;
#endif
if (line) {
line = 0;
}
goto bad;
}
}
else {
while (size > 0) {
break;
size -= n;
goto bad;
}
}
goto bad;
r = 0;
bad:
if (ip)
}
return r;
}
/*
* Show the message described by the passed pointer to the
* passed output buffer. Return -1 on error.
* Adjust the status: field if need be.
* If ignore is given, suppress ignored header fields.
* prefix is a string to prepend to each output line.
*/
int
{
register char* s;
register int i;
char* date;
char* head;
char* from;
int emptylen;
int prefixlen;
long n;
/*
* Compute the prefix string, without trailing whitespace
*/
if (prefix) {
}
if (flags & GREFERENCES) {
date = 0;
from = 0;
}
if (from) {
s--;
*s = 0;
}
*s = 0;
}
else {
*s++ = 0;
if (!date)
date = s;
}
}
}
}
else {
do {
return -1;
}
}
/*
* Copy out the message body
*/
n = 0;
do {
if (flags & GINTERPOLATE) {
boundary();
note(DEBUG, "interpolate boundary=%s offset=%ld size=%ld", state.part.out.boundary, (long)ap->raw.offset, (long)ap->raw.size);
return -1;
}
else if ((ap->flags & PART_body) || (flags & GMIME) && ap->count == 1 && !n && ap->next && !ap->next->lines && mime(1) && (s = mimeview(state.part.mime, NiL, NiL, ap->type, ap->opts))) {
note(DEBUG, "copy part text offset=%ld size=%ld lines=%ld", (long)ap->offset, (long)ap->size, (long)ap->lines);
return -1;
}
else
fprintf(op, "(attachment %2d %s %20s \"%s\")\n\n", ap->count, counts(1, ap->lines, ap->size), ap->type, ap->name);
}
return -1;
return 0;
}
/*
* Prepend headers in front of the collected stuff.
*/
static int
{
return -1;
return -1;
}
return -1;
}
return 0;
}
/*
* Save the outgoing mail on the passed file.
*/
static void
{
}
}
/*
* Pack ACTIVE args for execution.
*/
static int
{
return 0;
}
/*
* Determine if the passed address is a local "send to file" address.
* If any of the network metacharacters precedes any slashes, it can't
* be a filename. We cheat with .'s to allow path names like ./...
* As a final check the dir prefix must exist.
*/
static int
isfileaddr(char* name)
{
register char* cp;
register char* sp;
int r;
return 1;
sp = 0;
break;
if (*cp == '/')
}
if (!sp)
return 0;
*sp = 0;
*sp = '/';
return r;
}
/*
* For each recipient in the header name list with a /
* in the name, append the message to the end of the named file
* and remove him from the recipient list.
*
* Recipients whose name begins with | are piped through the given
* program and removed.
*/
static int
{
register char* name;
char* cmd;
int n;
goto cant;
}
/*
* Now either copy the letter to the desired file
* or give it as the standard input to the desired
* program as appropriate.
*/
if (cmd) {
goto cant;
}
if (n < 0) {
goto cant;
}
free_command(n);
}
else {
goto cant;
}
}
cant:
}
return 0;
}
/*
* Mail a message on standard input to the people indicated
* in the passed header.
*/
void
{
register char* s;
char** p;
int type;
int pid;
/*
* Collect user's mail from standard input.
* Get the result as letter.fp.
*/
return;
else
note(0, "EOT");
}
note(0, "Null message body; hope that's ok");
else
note(0, "No message, no subject; hope that's ok");
/*
* Now, take the user names from the combined
* to and cc lists and do all the alias processing.
*/
note(0, "No recipients specified");
}
}
while (s = *p++)
printf(" \"%s\"", *p);
printf("\n");
if (s)
}
else {
if (s)
/*
* Set up the temporary mail file as standard input for "mail"
* and exec with the user list we generated far above.
*/
if (!*(s += 7))
}
}
else if ((pid = start_command(s, SIG_REG_EXEC|SIG_REG_TERM, fileno(letter.fp), -1, NiL, (char*)args.argv, NiL)) < 0) {
}
else
}
}
}
/*
* Low level for fmt().
*/
typedef struct
{
int col;
int comma;
int flags;
const char* label;
} Format_t;
static int
{
register int n;
}
}
else {
}
}
}
return 0;
}
/*
* Format the given header line to not exceed MARGIN characters.
*/
static void
{
}
/*
* Dump the to, subject, cc header to fp.
*/
int
{
register struct list* x;
int comma;
int force;
int gotcha;
gotcha = 0;
gotcha = 1;
}
gotcha = 1;
else {
}
char* s;
int m;
int n;
s = hp->h_references;
if ((n = strlen(s)) > m) {
for (s += n - m; *s && !isspace(*s); s++);
for (; isspace(*s); s++);
}
}
}
}
gotcha = 1;
else
}
else
}
return 0;
}