/***********************************************************************
* *
* This software is part of the BSD package *
*Copyright (c) 1978-2012 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.
*
* Termination processing.
*/
#include "mailx.h"
/*
* Give names to all the temporary files that we will need.
*/
void
tempinit(void)
{
register char* cp;
if (!(state.tmp.dir = tempnam(NiL, NiL)) || !*state.tmp.dir || !(cp = strrchr(state.tmp.dir, '/')) && !(cp = strrchr(state.tmp.dir, '\\')))
else {
*++cp = 0;
}
}
/*
* The "quit" command.
*/
int
cmdquit(void)
{
/*
* If we are sourcing, then return 1 so execute() can handle it.
* Otherwise, return -1 to abort command loop.
*/
}
/*
* Terminate an editing session by attempting to write out the user's
* file from the temporary. Save any new stuff appended to the file.
*/
static void
edstop(void)
{
register int gotcha;
register int c;
int update;
char* s;
char* temp;
char* move;
return;
holdsigs();
gotcha++;
}
}
if (news) {
goto done;
}
if (!gotcha)
goto done;
if (!state.incorporating)
else {
relsesigs();
reset(0);
}
}
}
}
}
if (!state.incorporating)
note(0, "complete");
}
else {
ibuf = 0;
relsesigs();
reset(0);
}
relsesigs();
reset(0);
}
relsesigs();
reset(0);
}
}
if (!state.incorporating)
relsesigs();
reset(0);
}
c = 0;
c = 1;
relsesigs();
reset(0);
}
}
if (ibuf) {
}
relsesigs();
reset(0);
}
if (!state.incorporating) {
if (gotcha) {
note(0, "removed");
}
else
note(0, "complete");
}
}
done:
relsesigs();
}
/*
* Preserve all the appropriate messages back in the system
* mailbox, and print a nice message indicated how many were
* saved. On any error, just return -1. Else return 0.
* Incorporate the any new mail that we found.
*/
static int
{
register int p;
p = 0;
return -1;
#if !APPEND_MAILBOX
if (res)
#endif
p++;
return -1;
}
}
#if APPEND_MAILBOX
return -1;
}
#endif
return -1;
}
if (res)
return 0;
}
/*
* Save all of the undetermined messages at the top of "mbox"
* Save all untouched messages back in the system mailbox.
* Remove the system mailbox, if none saved there.
*/
void
quit(void)
{
register int c;
char* mbox;
char* s;
char* xbox;
int anystat;
int holdbit;
int mcount;
int modify;
int nohold;
int p;
int x;
int set;
int clr;
/*
* If we are read only, we can't do anything,
* so just return quickly.
*/
return;
/*
* If editing (not reading system mail box), then do the work
* in edstop()
*/
edstop();
return;
}
/*
* See if there any messages to save in mbox. If no, we
* can save copying mbox to /tmp and back.
*
* Check also to see if any files need to be preserved.
* Delete all untouched messages to keep them out of mbox.
* If all the messages are to be preserved, just exit with
* a message.
*
* NOTE: filelock() requires open for r/w
*/
goto newmail;
rbuf = 0;
note(0, "New mail has arrived");
goto newmail;
#if APPEND_MAILBOX
#else
goto newmail;
#endif
goto newmail;
}
}
else
fbuf = 0;
/*
* Adjust the message flags in each message.
*/
anystat = 0;
}
anystat++;
}
modify = 0;
x++;
}
c++;
p++;
modify++;
}
if (news)
if (fbuf)
return;
}
xbuf = 0;
if (x && (!state.var.spamlog || !*state.var.spamlog || !(xbuf = fileopen(xbox = expand(state.var.spamlog, 1), "a"))))
x = 0;
x--;
}
}
}
if (xbuf) {
if (x)
}
}
imap_quit();
return;
}
if (!c && !x) {
if (p) {
return;
}
goto cream;
}
/*
* Create another temporary file and copy user's mbox file
* darin. If there is no mbox, copy nothing.
* If he has specified "append" don't copy his mailbox,
* just copy saveable entries at the end.
*/
mcount = c;
return;
}
}
else {
return;
}
return;
}
return;
}
}
return;
}
return;
}
}
return;
}
}
x--;
}
}
}
if (xbuf) {
if (x)
}
/*
* Copy the user's old mbox contents back
* to the end of the stuff we just saved.
* If we are appending, this is unnecessary.
*/
}
return;
}
if (mcount)
/*
* Now we are ready to copy back preserved files to
* the system mailbox, if any were requested.
*/
if (p) {
return;
}
/*
* If new mail has arrived, copy it back.
*/
if (rbuf) {
goto newmail;
return;
}
demail();
if (fbuf)
return;
note(0, "Thou hast new mail");
if (fbuf)
}