2001-08-17 05:46:24 +00:00
|
|
|
/*****************************************************************************
|
|
|
|
*
|
2001-11-09 13:53:19 +00:00
|
|
|
* $Id$
|
2001-08-17 05:46:24 +00:00
|
|
|
* Purpose ...............: Message reading and writing.
|
|
|
|
* Todo ..................: Implement message groups.
|
|
|
|
*
|
|
|
|
*****************************************************************************
|
2005-08-14 09:38:06 +00:00
|
|
|
* Copyright (C) 1997-2005
|
2001-08-17 05:46:24 +00:00
|
|
|
*
|
|
|
|
* Michiel Broek FIDO: 2:280/2802
|
|
|
|
* Beekmansbos 10
|
|
|
|
* 1971 BV IJmuiden
|
|
|
|
* the Netherlands
|
|
|
|
*
|
|
|
|
* This file is part of MBSE BBS.
|
|
|
|
*
|
|
|
|
* This BBS is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License as published by the
|
|
|
|
* Free Software Foundation; either version 2, or (at your option) any
|
|
|
|
* later version.
|
|
|
|
*
|
|
|
|
* MBSE BBS is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with MBSE BBS; see the file COPYING. If not, write to the Free
|
2003-08-15 20:05:34 +00:00
|
|
|
* Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
2001-08-17 05:46:24 +00:00
|
|
|
*****************************************************************************
|
|
|
|
*
|
|
|
|
* JAM(mbp) - Copyright 1993 Joaquim Homrighausen, Andrew Milner,
|
|
|
|
* Mats Birch, Mats Wallin.
|
|
|
|
* ALL RIGHTS RESERVED.
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
|
|
|
|
2002-06-30 12:48:44 +00:00
|
|
|
#include "../config.h"
|
2004-02-21 17:22:00 +00:00
|
|
|
#include "../lib/mbselib.h"
|
2001-08-17 05:46:24 +00:00
|
|
|
#include "../lib/mbse.h"
|
2002-01-07 19:16:03 +00:00
|
|
|
#include "../lib/users.h"
|
2002-12-28 17:29:06 +00:00
|
|
|
#include "../lib/nodelist.h"
|
2001-08-17 05:46:24 +00:00
|
|
|
#include "../lib/msgtext.h"
|
|
|
|
#include "../lib/msg.h"
|
|
|
|
#include "mail.h"
|
|
|
|
#include "funcs.h"
|
2001-11-10 17:14:16 +00:00
|
|
|
#include "input.h"
|
2001-08-17 05:46:24 +00:00
|
|
|
#include "language.h"
|
|
|
|
#include "misc.h"
|
|
|
|
#include "timeout.h"
|
|
|
|
#include "oneline.h"
|
|
|
|
#include "exitinfo.h"
|
|
|
|
#include "lineedit.h"
|
|
|
|
#include "fsedit.h"
|
|
|
|
#include "filesub.h"
|
|
|
|
#include "msgutil.h"
|
|
|
|
#include "pop3.h"
|
|
|
|
#include "email.h"
|
2002-03-05 21:32:52 +00:00
|
|
|
#include "door.h"
|
2001-11-10 17:14:16 +00:00
|
|
|
#include "whoson.h"
|
2004-10-27 11:08:09 +00:00
|
|
|
#include "term.h"
|
2004-11-03 20:48:45 +00:00
|
|
|
#include "ttyio.h"
|
|
|
|
#include "openport.h"
|
|
|
|
|
2001-08-17 05:46:24 +00:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Global variables
|
|
|
|
*/
|
|
|
|
unsigned long LastNum; /* Last read message number */
|
|
|
|
int Kludges = FALSE; /* Show kludges or not */
|
|
|
|
int Line = 1; /* Line counter in editor */
|
|
|
|
char *Message[TEXTBUFSIZE +1];/* Message compose text buffer */
|
|
|
|
FILE *qf; /* Quote file */
|
|
|
|
extern int do_mailout;
|
2001-11-02 22:08:33 +00:00
|
|
|
extern int LC_Wrote; /* Lastcaller info write message */
|
2001-08-17 05:46:24 +00:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Internal prototypes
|
|
|
|
*/
|
2005-01-14 19:52:12 +00:00
|
|
|
void ShowMsgHdr(int Conv); /* Show message header */
|
2001-08-17 05:46:24 +00:00
|
|
|
int Read_a_Msg(unsigned long Num, int);/* Read a message */
|
|
|
|
int Export_a_Msg(unsigned long Num);/* Export message to homedir */
|
|
|
|
int ReadPanel(void); /* Read panel bar */
|
|
|
|
int Save_Msg(int, faddr *); /* Save a message */
|
2003-11-15 16:36:51 +00:00
|
|
|
int Save_CC(int, char *); /* Save carbon copy */
|
2001-08-17 05:46:24 +00:00
|
|
|
void Reply_Msg(int); /* Reply to message */
|
|
|
|
void Delete_MsgNum(unsigned long); /* Delete specified message */
|
|
|
|
int CheckUser(char *); /* Check if user exists */
|
|
|
|
int IsMe(char *); /* Test if this is my userrecord */
|
|
|
|
|
|
|
|
|
|
|
|
/****************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* More prompt, returns 1 if user decides not to look any further.
|
|
|
|
*/
|
|
|
|
int LC(int Lines)
|
|
|
|
{
|
2003-02-20 21:06:46 +00:00
|
|
|
int z;
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-02-20 21:06:46 +00:00
|
|
|
iLineCount += Lines;
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-02-20 21:06:46 +00:00
|
|
|
if (iLineCount >= exitinfo.iScreenLen && iLineCount < 1000) {
|
|
|
|
iLineCount = 1;
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-02-20 21:06:46 +00:00
|
|
|
pout(CFG.MoreF, CFG.MoreB, (char *) Language(61));
|
|
|
|
alarm_on();
|
2004-11-03 20:48:45 +00:00
|
|
|
z = toupper(Readkey());
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-02-20 21:06:46 +00:00
|
|
|
if (z == Keystroke(61, 1)) {
|
2004-11-03 20:48:45 +00:00
|
|
|
Enter(1);
|
2003-02-20 21:06:46 +00:00
|
|
|
return(1);
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-02-20 21:06:46 +00:00
|
|
|
if (z == Keystroke(61, 2))
|
|
|
|
iLineCount = 50000;
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-02-20 21:06:46 +00:00
|
|
|
Blanker(strlen(Language(61)));
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-02-20 21:06:46 +00:00
|
|
|
return(0);
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Check if posting is allowed
|
|
|
|
*/
|
|
|
|
int Post_Allowed(void);
|
|
|
|
int Post_Allowed(void)
|
|
|
|
{
|
2003-02-20 21:06:46 +00:00
|
|
|
if (msgs.MsgKinds == RONLY) {
|
|
|
|
/* Message area is Readonly */
|
|
|
|
pout(LIGHTRED, BLACK, (char *) Language(437));
|
|
|
|
sleep(3);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
return TRUE;
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2001-11-09 13:53:19 +00:00
|
|
|
/*
|
|
|
|
* Check if Alias is allowed, and if so if the user
|
|
|
|
* wants to use this in the From: field.
|
|
|
|
*/
|
|
|
|
int Alias_Option(void);
|
|
|
|
int Alias_Option(void)
|
|
|
|
{
|
|
|
|
int rc = TRUE;
|
|
|
|
|
|
|
|
if (!msgs.Aliases)
|
|
|
|
return FALSE;
|
|
|
|
if (strlen(exitinfo.sHandle) == 0)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
/* Use your alias ( */
|
|
|
|
pout(CYAN, BLACK, (char *)Language(477));
|
|
|
|
pout(CYAN, BLACK, exitinfo.sHandle);
|
|
|
|
/* YN|) to post this message [Y/n]: */
|
|
|
|
pout(CYAN, BLACK, (char *)Language(478));
|
|
|
|
colour(CFG.MsgInputColourF, CFG.MsgInputColourB);
|
|
|
|
alarm_on();
|
2004-11-03 20:48:45 +00:00
|
|
|
if (toupper(Readkey()) == Keystroke(478, 1)) {
|
2001-11-09 13:53:19 +00:00
|
|
|
rc = FALSE;
|
2004-11-03 20:48:45 +00:00
|
|
|
PUTCHAR(Keystroke(478, 1));
|
2001-11-09 13:53:19 +00:00
|
|
|
} else {
|
2004-11-03 20:48:45 +00:00
|
|
|
PUTCHAR(Keystroke(478, 0));
|
2001-11-09 13:53:19 +00:00
|
|
|
}
|
|
|
|
Enter(2);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2001-08-17 05:46:24 +00:00
|
|
|
/*
|
|
|
|
* Check if netmail may be send crash or immediate.
|
|
|
|
*/
|
|
|
|
int Crash_Option(faddr *);
|
|
|
|
int Crash_Option(faddr *Dest)
|
|
|
|
{
|
2002-12-30 22:13:33 +00:00
|
|
|
node *Nlent;
|
|
|
|
int rc = 0;
|
|
|
|
unsigned short point;
|
|
|
|
|
|
|
|
if (exitinfo.Security.level < CFG.iCrashLevel)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
point = Dest->point;
|
|
|
|
Dest->point = 0;
|
|
|
|
|
|
|
|
if (((Nlent = getnlent(Dest)) != NULL) && (Nlent->addr.zone)) {
|
2004-06-18 19:54:13 +00:00
|
|
|
if ((Nlent->can_pots && Nlent->is_cm) || (Nlent->can_ip && Nlent->is_icm)) {
|
2002-12-30 22:13:33 +00:00
|
|
|
/* Crash [y/N]: */
|
|
|
|
pout(CYAN, BLACK, (char *)Language(461));
|
|
|
|
colour(CFG.MsgInputColourF, CFG.MsgInputColourB);
|
|
|
|
alarm_on();
|
2004-11-03 20:48:45 +00:00
|
|
|
if (toupper(Readkey()) == Keystroke(461, 0)) {
|
2002-12-30 22:13:33 +00:00
|
|
|
rc = 1;
|
2004-11-03 20:48:45 +00:00
|
|
|
PUTCHAR(Keystroke(461, 0));
|
2002-12-30 22:13:33 +00:00
|
|
|
} else
|
2004-11-03 20:48:45 +00:00
|
|
|
PUTCHAR(Keystroke(461, 1));
|
2002-12-30 22:13:33 +00:00
|
|
|
} else {
|
|
|
|
/* Warning: node is not CM, send Immediate [y/N]: */
|
|
|
|
pout(CYAN, BLACK, (char *)Language(462));
|
|
|
|
colour(CFG.MsgInputColourF, CFG.MsgInputColourB);
|
|
|
|
alarm_on();
|
2004-11-03 20:48:45 +00:00
|
|
|
if (toupper(Readkey()) == Keystroke(462, 0)) {
|
2002-12-30 22:13:33 +00:00
|
|
|
rc = 2;
|
2004-11-03 20:48:45 +00:00
|
|
|
PUTCHAR(Keystroke(462, 0));
|
2002-12-30 22:13:33 +00:00
|
|
|
} else
|
2004-11-03 20:48:45 +00:00
|
|
|
PUTCHAR(Keystroke(462, 1));
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
2003-12-16 21:50:32 +00:00
|
|
|
|
|
|
|
if (Nlent->addr.domain)
|
|
|
|
free(Nlent->addr.domain);
|
|
|
|
Nlent->addr.domain = NULL;
|
|
|
|
if (Nlent->url)
|
|
|
|
free(Nlent->url);
|
|
|
|
Nlent->url = NULL;
|
2004-08-07 14:52:57 +00:00
|
|
|
} else {
|
|
|
|
Syslog('+', "Node %s not found", ascfnode(Dest, 0x1f));
|
|
|
|
rc = -1;
|
2002-12-30 22:13:33 +00:00
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2002-12-30 22:13:33 +00:00
|
|
|
Dest->point = point;
|
|
|
|
return rc;
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Ask if message must be private, only allowed in areas which allow
|
|
|
|
* both public and private. Private areas are forced to private.
|
|
|
|
*/
|
|
|
|
int IsPrivate(void);
|
|
|
|
int IsPrivate(void)
|
|
|
|
{
|
2003-02-20 21:06:46 +00:00
|
|
|
int rc = FALSE;
|
|
|
|
|
|
|
|
if (msgs.MsgKinds == BOTH) {
|
2004-11-05 19:38:24 +00:00
|
|
|
Enter(1);
|
2003-02-20 21:06:46 +00:00
|
|
|
/* Private [y/N]: */
|
|
|
|
pout(CYAN, BLACK, (char *) Language(163));
|
|
|
|
alarm_on();
|
2004-11-03 20:48:45 +00:00
|
|
|
if (toupper(Readkey()) == Keystroke(163, 0)) {
|
2003-02-20 21:06:46 +00:00
|
|
|
rc = TRUE;
|
2004-11-03 20:48:45 +00:00
|
|
|
PUTCHAR(Keystroke(163, 0));
|
2003-02-20 21:06:46 +00:00
|
|
|
} else {
|
2004-11-03 20:48:45 +00:00
|
|
|
PUTCHAR(Keystroke(163, 1));
|
2003-02-20 21:06:46 +00:00
|
|
|
}
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-02-20 21:06:46 +00:00
|
|
|
/*
|
|
|
|
* Allways set the private flag in Private areas.
|
|
|
|
*/
|
|
|
|
if (msgs.MsgKinds == PRIVATE)
|
|
|
|
rc = TRUE;
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-02-20 21:06:46 +00:00
|
|
|
return rc;
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Check_Attach(void);
|
|
|
|
void Check_Attach(void)
|
|
|
|
{
|
2004-11-03 20:48:45 +00:00
|
|
|
char *Attach, *dospath, msg[81];
|
|
|
|
struct stat sb;
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
/*
|
|
|
|
* This is a dangerous option! Every file on the system to which the
|
|
|
|
* bbs has read access and is in the range of paths translatable by
|
|
|
|
* Unix to DOS can be attached to the netmail.
|
|
|
|
*/
|
|
|
|
if ((msgs.Type == NETMAIL) && (exitinfo.Security.level >= CFG.iAttachLevel)) {
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
Attach = calloc(PATH_MAX, sizeof(char));
|
|
|
|
while (TRUE) {
|
|
|
|
Enter(1);
|
|
|
|
/* Attach file [y/N]: */
|
|
|
|
pout(CYAN, BLACK, (char *)Language(463));
|
|
|
|
alarm_on();
|
|
|
|
if (toupper(Readkey()) == Keystroke(463, 0)) {
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
PUTCHAR(Keystroke(463, 0));
|
|
|
|
Enter(1);
|
|
|
|
/* Please enter filename: */
|
|
|
|
pout(YELLOW, BLACK, (char *)Language(245));
|
|
|
|
colour(CFG.MsgInputColourF, CFG.MsgInputColourB);
|
|
|
|
alarm_on();
|
2005-08-29 11:15:54 +00:00
|
|
|
snprintf(Attach, PATH_MAX, "%s/", CFG.uxpath);
|
2004-11-03 20:48:45 +00:00
|
|
|
PUTSTR(Attach);
|
|
|
|
GetstrP(Attach, 71, strlen(Attach));
|
|
|
|
if (strcmp(Attach, "") == 0)
|
|
|
|
break;
|
|
|
|
|
|
|
|
if ((stat(Attach, &sb) == 0) && (S_ISREG(sb.st_mode))) {
|
|
|
|
dospath = xstrcpy(Unix2Dos(Attach));
|
|
|
|
if (strncasecmp(Attach, CFG.uxpath, strlen(CFG.uxpath)) == 0) {
|
|
|
|
Syslog('+', "FileAttach \"%s\"", Attach);
|
|
|
|
if (strlen(CFG.dospath))
|
|
|
|
strcpy(Msg.Subject, dospath);
|
|
|
|
else
|
2005-08-29 11:15:54 +00:00
|
|
|
snprintf(Msg.Subject, 101, "%s", Attach);
|
2004-11-03 20:48:45 +00:00
|
|
|
Msg.FileAttach = TRUE;
|
|
|
|
Enter(1);
|
|
|
|
/* File */ /* will be attached */
|
2005-08-29 11:15:54 +00:00
|
|
|
snprintf(msg, 81, "%s %s %s", (char *)Language(464), Msg.Subject, Language(465));
|
2004-11-03 20:48:45 +00:00
|
|
|
pout(LIGHTCYAN, BLACK, msg);
|
|
|
|
Enter(1);
|
|
|
|
sleep(2);
|
|
|
|
break;
|
|
|
|
} else {
|
|
|
|
Enter(1);
|
|
|
|
/* File not within */
|
2005-08-29 11:15:54 +00:00
|
|
|
snprintf(msg, 81, "%s \"%s\"", Language(466), CFG.uxpath);
|
2004-11-03 20:48:45 +00:00
|
|
|
pout(LIGHTGREEN, BLACK, msg);
|
|
|
|
Enter(1);
|
|
|
|
Pause();
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
Enter(1);
|
|
|
|
/* File does not exist, please try again ... */
|
|
|
|
pout(LIGHTGREEN, BLACK, (char *)Language(296));
|
|
|
|
Enter(1);
|
|
|
|
Pause();
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
break;
|
|
|
|
} /* if attach */
|
|
|
|
} /* while true */
|
|
|
|
free(Attach);
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Comment to sysop
|
|
|
|
*/
|
|
|
|
void SysopComment(char *Cmt)
|
|
|
|
{
|
2003-11-15 16:36:51 +00:00
|
|
|
unsigned long tmp;
|
|
|
|
char *temp;
|
|
|
|
FILE *fp;
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-11-15 16:36:51 +00:00
|
|
|
tmp = iMsgAreaNumber;
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-11-15 16:36:51 +00:00
|
|
|
/*
|
|
|
|
* Make sure that the .quote file is empty.
|
|
|
|
*/
|
|
|
|
temp = calloc(PATH_MAX, sizeof(char));
|
2005-08-29 11:15:54 +00:00
|
|
|
snprintf(temp, PATH_MAX, "%s/%s/.quote", CFG.bbs_usersdir, exitinfo.Name);
|
2003-11-15 16:36:51 +00:00
|
|
|
if ((fp = fopen(temp, "w")) != NULL)
|
|
|
|
fclose(fp);
|
|
|
|
free(temp);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-11-15 16:36:51 +00:00
|
|
|
SetMsgArea(CFG.iSysopArea -1);
|
2005-08-29 11:15:54 +00:00
|
|
|
snprintf(Msg.From, 101, "%s", CFG.sysop_name);
|
|
|
|
snprintf(Msg.Subject, 101, "%s", Cmt);
|
2003-11-15 16:36:51 +00:00
|
|
|
Reply_Msg(FALSE);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-11-15 16:36:51 +00:00
|
|
|
SetMsgArea(tmp);
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Edit a message. Call the users preffered editor.
|
|
|
|
*/
|
|
|
|
int Edit_Msg()
|
|
|
|
{
|
2002-03-05 21:32:52 +00:00
|
|
|
switch (exitinfo.MsgEditor) {
|
|
|
|
case LINEEDIT: return Line_Edit();
|
|
|
|
case FSEDIT: return Fs_Edit();
|
|
|
|
case EXTEDIT: return Ext_Edit();
|
|
|
|
}
|
|
|
|
return 0;
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Post a message, called from the menu or ReadPanel().
|
|
|
|
*/
|
|
|
|
void Post_Msg()
|
|
|
|
{
|
2003-11-15 16:36:51 +00:00
|
|
|
int i, x, cc;
|
2004-11-03 20:48:45 +00:00
|
|
|
char *FidoNode, msg[81];
|
2003-07-11 20:28:36 +00:00
|
|
|
faddr *Dest = NULL;
|
2003-12-16 21:50:32 +00:00
|
|
|
node *Nlent = NULL;
|
2003-07-11 20:28:36 +00:00
|
|
|
unsigned short point;
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-07-11 20:28:36 +00:00
|
|
|
Line = 1;
|
2003-10-11 21:22:16 +00:00
|
|
|
WhosDoingWhat(READ_POST, NULL);
|
2003-07-11 20:28:36 +00:00
|
|
|
SetMsgArea(iMsgAreaNumber);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-07-11 20:28:36 +00:00
|
|
|
clear();
|
|
|
|
if (!Post_Allowed())
|
|
|
|
return;
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-07-11 20:28:36 +00:00
|
|
|
for (i = 0; i < (TEXTBUFSIZE + 1); i++)
|
2003-09-02 20:25:42 +00:00
|
|
|
Message[i] = (char *) calloc(MAX_LINE_LENGTH +1, sizeof(char));
|
2003-07-11 20:28:36 +00:00
|
|
|
Line = 1;
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-07-11 20:28:36 +00:00
|
|
|
Msg_New();
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
Enter(1);
|
2003-07-11 20:28:36 +00:00
|
|
|
/* Posting message in area: */
|
2005-08-29 11:15:54 +00:00
|
|
|
snprintf(msg, 81, "%s\"%s\"", (char *) Language(156), sMsgAreaDesc);
|
2004-11-03 20:48:45 +00:00
|
|
|
pout(LIGHTBLUE, BLACK, msg);
|
|
|
|
Enter(1);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-07-11 20:28:36 +00:00
|
|
|
if (Alias_Option()) {
|
|
|
|
/*
|
|
|
|
* Set Handle
|
|
|
|
*/
|
|
|
|
strcpy(Msg.From, exitinfo.sHandle);
|
|
|
|
tlcap(Msg.From); // Do we want this???
|
|
|
|
/* From : */
|
|
|
|
pout(YELLOW, BLACK, (char *) Language(157));
|
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* Normal from address, no alias
|
|
|
|
*/
|
|
|
|
/* From : */
|
|
|
|
pout(YELLOW, BLACK, (char *) Language(157));
|
|
|
|
if (msgs.Type == NEWS) {
|
|
|
|
if (CFG.EmailMode != E_PRMISP) {
|
|
|
|
/*
|
|
|
|
* If no internet mail domain, use fidonet addressing.
|
|
|
|
*/
|
|
|
|
Dest = fido2faddr(CFG.EmailFidoAka);
|
2001-08-17 05:46:24 +00:00
|
|
|
strcpy(Msg.From, exitinfo.sUserName);
|
|
|
|
tlcap(Msg.From);
|
2003-07-11 20:28:36 +00:00
|
|
|
} else {
|
2005-08-29 11:15:54 +00:00
|
|
|
snprintf(Msg.From, 101, "%s@%s (%s)", exitinfo.Name, CFG.sysdomain, exitinfo.sUserName);
|
2001-11-09 13:53:19 +00:00
|
|
|
}
|
2003-07-11 20:28:36 +00:00
|
|
|
} else {
|
|
|
|
strcpy(Msg.From, exitinfo.sUserName);
|
|
|
|
tlcap(Msg.From);
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
2003-07-11 20:28:36 +00:00
|
|
|
}
|
2001-11-09 13:53:19 +00:00
|
|
|
|
2003-07-11 20:28:36 +00:00
|
|
|
pout(CFG.MsgInputColourF, CFG.MsgInputColourB, Msg.From);
|
|
|
|
Syslog('b', "Setting From: %s", Msg.From);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-07-11 20:28:36 +00:00
|
|
|
if ((msgs.Type == NEWS) || (msgs.Type == LIST)) {
|
|
|
|
/*
|
|
|
|
* Newsmode or maillist mode, automatic addressing to All.
|
|
|
|
* */
|
|
|
|
strcpy(Msg.To, "All");
|
|
|
|
} else {
|
|
|
|
while (TRUE) {
|
|
|
|
Enter(1);
|
|
|
|
/* To : */
|
|
|
|
pout(YELLOW, BLACK, (char *) Language(158));
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-07-11 20:28:36 +00:00
|
|
|
colour(CFG.MsgInputColourF, CFG.MsgInputColourB);
|
|
|
|
Getname(Msg.To, 35);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-07-11 20:28:36 +00:00
|
|
|
if ((strcmp(Msg.To, "")) == 0) {
|
|
|
|
for(i = 0; i < (TEXTBUFSIZE + 1); i++)
|
|
|
|
free(Message[i]);
|
|
|
|
return;
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-07-11 20:28:36 +00:00
|
|
|
if ((strcasecmp(Msg.To, "sysop")) == 0)
|
|
|
|
strcpy(Msg.To, CFG.sysop_name);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-07-11 20:28:36 +00:00
|
|
|
/*
|
|
|
|
* Localmail and Echomail may be addressed to All
|
|
|
|
*/
|
|
|
|
if ((msgs.Type == LOCALMAIL) || (msgs.Type == ECHOMAIL) || (msgs.Type == LIST)) {
|
|
|
|
if (strcasecmp(Msg.To, "all") == 0)
|
|
|
|
x = TRUE;
|
|
|
|
else {
|
|
|
|
/*
|
|
|
|
* Local users must exist in the userbase.
|
|
|
|
*/
|
|
|
|
if (msgs.Type == LOCALMAIL) {
|
|
|
|
/* Verifying user ... */
|
|
|
|
pout(CYAN, BLACK, (char *) Language(159));
|
|
|
|
x = CheckUser(Msg.To);
|
|
|
|
} else
|
|
|
|
x = TRUE;
|
|
|
|
}
|
|
|
|
} else if (msgs.Type == NETMAIL) {
|
|
|
|
x = FALSE;
|
2004-11-05 19:38:24 +00:00
|
|
|
Enter(1);
|
2003-07-11 20:28:36 +00:00
|
|
|
pout(YELLOW, BLACK, (char *)"Address : ");
|
|
|
|
FidoNode = calloc(61, sizeof(char));
|
|
|
|
colour(CFG.MsgInputColourF, CFG.MsgInputColourB);
|
|
|
|
GetstrC(FidoNode, 60);
|
|
|
|
|
|
|
|
if ((Dest = parsefnode(FidoNode)) != NULL) {
|
|
|
|
point = Dest->point;
|
|
|
|
Dest->point = 0;
|
|
|
|
if (((Nlent = getnlent(Dest)) != NULL) && (Nlent->addr.zone)) {
|
2003-12-16 21:50:32 +00:00
|
|
|
if (Nlent->url)
|
|
|
|
free(Nlent->url);
|
|
|
|
Nlent->url = NULL;
|
|
|
|
if (Nlent->addr.domain)
|
|
|
|
free(Nlent->addr.domain);
|
|
|
|
Nlent->addr.domain = NULL;
|
|
|
|
|
2003-07-11 20:28:36 +00:00
|
|
|
colour(YELLOW, BLACK);
|
|
|
|
if (point)
|
2004-11-03 20:48:45 +00:00
|
|
|
PUTSTR((char *)"Boss : ");
|
2003-07-11 20:28:36 +00:00
|
|
|
else
|
2004-11-03 20:48:45 +00:00
|
|
|
PUTSTR((char *)"Node : ");
|
2003-07-11 20:28:36 +00:00
|
|
|
Dest->point = point;
|
2005-08-29 11:15:54 +00:00
|
|
|
snprintf(msg, 81, "%s in %s", Nlent->name, Nlent->location);
|
2004-11-03 20:48:45 +00:00
|
|
|
pout(CFG.MsgInputColourF, CFG.MsgInputColourB, msg);
|
2003-11-15 16:36:51 +00:00
|
|
|
/* " Is this correct [y/N]: " */
|
|
|
|
pout(YELLOW, BLACK, (char *)Language(21));
|
2003-07-11 20:28:36 +00:00
|
|
|
colour(CFG.MsgInputColourF, CFG.MsgInputColourB);
|
|
|
|
alarm_on();
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
if (toupper(Readkey()) == Keystroke(21, 0)) {
|
2003-07-11 20:28:36 +00:00
|
|
|
Enter(1);
|
2005-08-29 11:15:54 +00:00
|
|
|
snprintf(Msg.ToAddress, 101, "%s", ascfnode(Dest, 0x1f));
|
2003-07-11 20:28:36 +00:00
|
|
|
x = TRUE;
|
|
|
|
switch (Crash_Option(Dest)) {
|
|
|
|
case 1: Msg.Crash = TRUE;
|
|
|
|
break;
|
|
|
|
case 2: Msg.Immediate = TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
Dest->point = point;
|
2004-11-05 19:38:24 +00:00
|
|
|
Enter(1);
|
2003-11-15 16:36:51 +00:00
|
|
|
/* Node not known, continue anayway [y/N]: */
|
2003-07-11 20:28:36 +00:00
|
|
|
pout(CYAN, BLACK, (char *) Language(241));
|
|
|
|
alarm_on();
|
2004-11-03 20:48:45 +00:00
|
|
|
if (toupper(Readkey()) == Keystroke(241, 0)) {
|
2003-07-11 20:28:36 +00:00
|
|
|
x = TRUE;
|
|
|
|
Syslog('+', "Node %s not found, forced continue", FidoNode);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
Syslog('m', "Can't parse address %s", FidoNode);
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
2003-07-11 20:28:36 +00:00
|
|
|
free(FidoNode);
|
|
|
|
} else {
|
|
|
|
x = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!x) {
|
2004-11-03 20:48:45 +00:00
|
|
|
PUTCHAR('\r');
|
2003-07-11 20:28:36 +00:00
|
|
|
/* User not found. Try again, or (Enter) to quit */
|
|
|
|
pout(CYAN, BLACK, (char *) Language(160));
|
|
|
|
} else
|
|
|
|
break;
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
2003-07-11 20:28:36 +00:00
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-07-11 20:28:36 +00:00
|
|
|
Enter(1);
|
|
|
|
/* Subject : */
|
|
|
|
pout(YELLOW, BLACK, (char *) Language(161));
|
|
|
|
colour(CFG.MsgInputColourF, CFG.MsgInputColourB);
|
|
|
|
alarm_on();
|
|
|
|
GetstrP(Msg.Subject, 65, 0);
|
2005-08-10 15:32:42 +00:00
|
|
|
mbse_CleanSubject(Msg.Subject);
|
2003-07-11 20:28:36 +00:00
|
|
|
|
|
|
|
if ((strcmp(Msg.Subject, "")) == 0) {
|
2001-08-17 05:46:24 +00:00
|
|
|
Enter(1);
|
2003-07-11 20:28:36 +00:00
|
|
|
/* Abort Message [y/N] ?: */
|
|
|
|
pout(CYAN, BLACK, (char *) Language(162));
|
2001-08-17 05:46:24 +00:00
|
|
|
alarm_on();
|
2003-07-11 20:28:36 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
if (toupper(Readkey()) == Keystroke(162, 0)) {
|
2003-07-11 20:28:36 +00:00
|
|
|
for(i = 0; i < (TEXTBUFSIZE + 1); i++)
|
|
|
|
free(Message[i]);
|
2003-12-16 21:50:32 +00:00
|
|
|
tidy_faddr(Dest);
|
2003-07-11 20:28:36 +00:00
|
|
|
return;
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
2003-07-11 20:28:36 +00:00
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-07-11 20:28:36 +00:00
|
|
|
/*
|
|
|
|
* If not addressed to "all" and the area is Private/Public we
|
|
|
|
* ask the user for the private flag.
|
|
|
|
*/
|
|
|
|
if ((strcasecmp(Msg.To, "all")) != 0)
|
|
|
|
Msg.Private = IsPrivate();
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-07-11 20:28:36 +00:00
|
|
|
Check_Attach();
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-11-15 16:36:51 +00:00
|
|
|
if (Edit_Msg()) {
|
2004-11-03 20:48:45 +00:00
|
|
|
Enter(1);
|
2003-11-15 16:36:51 +00:00
|
|
|
if (msgs.Type == NETMAIL) {
|
|
|
|
/*
|
|
|
|
* Check for Carbon Copy lines, process them if present.
|
|
|
|
*/
|
|
|
|
cc = 0;
|
|
|
|
for (i = 1; i <= Line; i++) {
|
|
|
|
if (strncasecmp(Message[i], "cc: ", 4)) {
|
|
|
|
break;
|
|
|
|
} else {
|
|
|
|
cc++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Syslog('b', "CC: detected %d", cc);
|
|
|
|
if (cc) {
|
|
|
|
/*
|
|
|
|
* Carbon copies, modify the text to show the presence of CCs.
|
|
|
|
*/
|
|
|
|
for (i = Line; i; i--) {
|
|
|
|
Syslog('b', "%02d: \"%s\"", i, printable(Message[i], 0));
|
2005-08-29 11:15:54 +00:00
|
|
|
snprintf(Message[i + 1], TEXTBUFSIZE +1, Message[i]);
|
2003-11-15 16:36:51 +00:00
|
|
|
}
|
|
|
|
Line++;
|
2005-08-29 11:15:54 +00:00
|
|
|
snprintf(Message[1], TEXTBUFSIZE +1, " +: Original message to %s", ascfnode(Dest, 0x4f));
|
2003-11-15 16:36:51 +00:00
|
|
|
for (i = 1; i <= Line; i++) {
|
|
|
|
Syslog('b', "%02d: \"%s\"", i, printable(Message[i], 0));
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* First sent to original destination
|
|
|
|
*/
|
|
|
|
Save_Msg(FALSE, Dest);
|
|
|
|
/*
|
|
|
|
* Now sent copies
|
|
|
|
*/
|
|
|
|
for (i = 0; i < cc; i++) {
|
|
|
|
Save_CC(FALSE, Message[i+2]);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
Save_Msg(FALSE, Dest);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
Save_Msg(FALSE, Dest);
|
|
|
|
}
|
2004-11-03 20:48:45 +00:00
|
|
|
Enter(1);
|
2004-11-05 19:38:24 +00:00
|
|
|
sleep(2);
|
2003-11-15 16:36:51 +00:00
|
|
|
}
|
|
|
|
|
2003-07-11 20:28:36 +00:00
|
|
|
for (i = 0; i < (TEXTBUFSIZE + 1); i++)
|
|
|
|
free(Message[i]);
|
2003-12-16 21:50:32 +00:00
|
|
|
tidy_faddr(Dest);
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2003-11-15 16:36:51 +00:00
|
|
|
/*
|
|
|
|
* Save a Carbon Copy
|
|
|
|
* The ccline should have the format "cc: Firstname Lastname z:n/n.p"
|
|
|
|
*/
|
|
|
|
int Save_CC(int IsReply, char *ccline)
|
|
|
|
{
|
|
|
|
faddr *Dest = NULL;
|
|
|
|
int i, j, x, rc = FALSE;
|
2004-11-03 20:48:45 +00:00
|
|
|
char *p, *username, msg[81];
|
2003-11-15 16:36:51 +00:00
|
|
|
unsigned short point;
|
|
|
|
node *Nlent;
|
|
|
|
|
|
|
|
Syslog('b', "Save_CC(%s, %s)", IsReply ?"TRUE":"FALSE", ccline);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Reformat the line and extract username and node
|
|
|
|
*/
|
|
|
|
i = 4;
|
|
|
|
j = strlen(ccline);
|
|
|
|
while (ccline[i] == ' ')
|
|
|
|
i++;
|
|
|
|
while (ccline[j] != ' ')
|
|
|
|
j--;
|
|
|
|
Syslog('b', "i=%d, j=%d", i, j);
|
|
|
|
if (j <= i) {
|
|
|
|
Syslog('+', "Could not parse %s", printable(ccline, 0));
|
|
|
|
/* Could not parse */
|
2005-08-29 11:15:54 +00:00
|
|
|
snprintf(msg, 81, "%s \"%s\"", Language(22), printable(ccline, 0));
|
2004-11-03 20:48:45 +00:00
|
|
|
pout(LIGHTRED, BLACK, msg);
|
|
|
|
Enter(1);
|
2003-11-15 16:36:51 +00:00
|
|
|
Pause();
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
username = calloc(j - i + 1, sizeof(char));
|
|
|
|
strncpy(username, ccline+i, j - i);
|
|
|
|
Syslog('b', "Username: \"%s\"", printable(username, 0));
|
|
|
|
while (*(p = username + strlen(username) -1) == ' ')
|
|
|
|
*p = '\0';
|
|
|
|
Syslog('b', "Username: \"%s\"", tlcap(printable(username, 0)));
|
|
|
|
|
|
|
|
if (strlen(username) == 0) {
|
|
|
|
Syslog('+', "Could not extract username from %s", printable(ccline, 0));
|
|
|
|
/* Could not parse */
|
2005-08-29 11:15:54 +00:00
|
|
|
snprintf(msg, 81, "%s \"%s\"", Language(22), printable(ccline, 0));
|
2004-11-03 20:48:45 +00:00
|
|
|
pout(LIGHTRED, BLACK, msg);
|
|
|
|
Enter(1);
|
2003-11-15 16:36:51 +00:00
|
|
|
Pause();
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((Dest = parsefnode(ccline + j)) == NULL) {
|
|
|
|
Syslog('+', "Could not extract address from %s", printable(ccline, 0));
|
|
|
|
/* Could not parse */
|
2005-08-29 11:15:54 +00:00
|
|
|
snprintf(msg, 81, "%s \"%s\"", Language(22), printable(ccline, 0));
|
2004-11-03 20:48:45 +00:00
|
|
|
pout(LIGHTRED, BLACK, msg);
|
|
|
|
Enter(1);
|
2003-11-15 16:36:51 +00:00
|
|
|
Pause();
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
Dest->name = tlcap(printable(username, 0));
|
|
|
|
Syslog('b', "Dest %s", ascfnode(Dest, 0xff));
|
2004-11-03 20:48:45 +00:00
|
|
|
Enter(1);
|
2005-08-29 11:15:54 +00:00
|
|
|
snprintf(msg, 81, "Confirm CC to %s", ascfnode(Dest, 0xff));
|
2004-11-03 20:48:45 +00:00
|
|
|
pout(LIGHTMAGENTA, BLACK, msg);
|
|
|
|
Enter(1);
|
2003-11-15 16:36:51 +00:00
|
|
|
|
|
|
|
x = FALSE;
|
|
|
|
point = Dest->point;
|
|
|
|
Dest->point = 0;
|
|
|
|
if (((Nlent = getnlent(Dest)) != NULL) && (Nlent->addr.zone)) {
|
|
|
|
colour(YELLOW, BLACK);
|
|
|
|
if (point)
|
2004-11-03 20:48:45 +00:00
|
|
|
PUTSTR((char *)"Boss : ");
|
2003-11-15 16:36:51 +00:00
|
|
|
else
|
2004-11-03 20:48:45 +00:00
|
|
|
PUTSTR((char *)"Node : ");
|
2003-11-15 16:36:51 +00:00
|
|
|
Dest->point = point;
|
2005-08-29 11:15:54 +00:00
|
|
|
snprintf(msg, 81, "%s in %s", Nlent->name, Nlent->location);
|
2004-11-03 20:48:45 +00:00
|
|
|
pout(CFG.MsgInputColourF, CFG.MsgInputColourB, msg);
|
2003-11-15 16:36:51 +00:00
|
|
|
/* " Is this correct [y/N]: " */
|
|
|
|
pout(YELLOW, BLACK, (char *)Language(21));
|
|
|
|
colour(CFG.MsgInputColourF, CFG.MsgInputColourB);
|
|
|
|
alarm_on();
|
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
if (toupper(Readkey()) == Keystroke(21, 0)) {
|
2003-11-15 16:36:51 +00:00
|
|
|
Enter(1);
|
2005-08-29 11:15:54 +00:00
|
|
|
snprintf(Msg.ToAddress, 101, "%s", ascfnode(Dest, 0x1f));
|
2003-11-15 16:36:51 +00:00
|
|
|
x = TRUE;
|
|
|
|
switch (Crash_Option(Dest)) {
|
|
|
|
case 1: Msg.Crash = TRUE;
|
|
|
|
break;
|
|
|
|
case 2: Msg.Immediate = TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
Dest->point = point;
|
2004-11-03 20:48:45 +00:00
|
|
|
Enter(1);
|
2003-11-15 16:36:51 +00:00
|
|
|
/* Node not known, continue anayway [y/N]: */
|
|
|
|
pout(CYAN, BLACK, (char *) Language(241));
|
|
|
|
alarm_on();
|
2004-11-03 20:48:45 +00:00
|
|
|
if (toupper(Readkey()) == Keystroke(241, 0)) {
|
2003-11-15 16:36:51 +00:00
|
|
|
x = TRUE;
|
|
|
|
Syslog('+', "Node %s not found, forced continue", ascfnode(Dest, 0x0f));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (x) {
|
2004-11-03 20:48:45 +00:00
|
|
|
Enter(1);
|
2003-11-15 16:36:51 +00:00
|
|
|
rc = Save_Msg(IsReply, Dest);
|
|
|
|
}
|
|
|
|
|
|
|
|
tidy_faddr(Dest);
|
|
|
|
free(username);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2001-08-17 05:46:24 +00:00
|
|
|
/*
|
|
|
|
* Save the message to disk.
|
|
|
|
*/
|
|
|
|
int Save_Msg(int IsReply, faddr *Dest)
|
|
|
|
{
|
2003-05-10 11:51:43 +00:00
|
|
|
int i;
|
|
|
|
char *temp;
|
|
|
|
FILE *fp;
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-12-08 18:01:25 +00:00
|
|
|
Syslog('b', "Entering Save_Msg() Line=%d, Dest=%s", Line, (Dest == NULL)?"NULL":"valid");
|
|
|
|
|
|
|
|
if (Line < 2)
|
2003-05-10 11:51:43 +00:00
|
|
|
return TRUE;
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-05 19:38:24 +00:00
|
|
|
/* Saving message to disk */
|
|
|
|
pout(CFG.HiliteF, CFG.HiliteB, (char *) Language(202));
|
|
|
|
|
2003-12-08 18:01:25 +00:00
|
|
|
if (!Open_Msgbase(msgs.Base, 'w')) {
|
|
|
|
WriteError("Failed to open msgbase \"%s\"", msgs.Base);
|
2003-05-10 11:51:43 +00:00
|
|
|
return FALSE;
|
2003-12-08 18:01:25 +00:00
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-05-10 11:51:43 +00:00
|
|
|
Msg.Written = Msg.Arrived = time(NULL) - (gmt_offset((time_t)0) * 60);
|
|
|
|
Msg.Local = TRUE;
|
|
|
|
temp = calloc(PATH_MAX, sizeof(char));
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-05-10 11:51:43 +00:00
|
|
|
if (strlen(Msg.ReplyTo) && (msgs.Type == NETMAIL)) {
|
2001-08-17 05:46:24 +00:00
|
|
|
/*
|
2003-05-10 11:51:43 +00:00
|
|
|
* Send message to internet gateway.
|
2001-08-17 05:46:24 +00:00
|
|
|
*/
|
2003-05-10 11:51:43 +00:00
|
|
|
Syslog('m', "UUCP message to %s", Msg.ReplyAddr);
|
2005-08-29 11:15:54 +00:00
|
|
|
snprintf(Msg.To, 101, "UUCP");
|
2003-05-10 11:51:43 +00:00
|
|
|
Add_Headkludges(Dest, IsReply);
|
2005-08-29 11:15:54 +00:00
|
|
|
snprintf(temp, 101, "To: %s", Msg.ReplyAddr);
|
2003-05-10 11:51:43 +00:00
|
|
|
MsgText_Add2(temp);
|
|
|
|
MsgText_Add2((char *)"");
|
|
|
|
} else {
|
|
|
|
Add_Headkludges(Dest, IsReply);
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-05-10 11:51:43 +00:00
|
|
|
/*
|
|
|
|
* Add message text
|
|
|
|
*/
|
|
|
|
for (i = 1; i <= Line; i++)
|
|
|
|
MsgText_Add2(Message[i]);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-05-10 11:51:43 +00:00
|
|
|
Add_Footkludges(TRUE, NULL, FALSE);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-05-10 11:51:43 +00:00
|
|
|
/*
|
|
|
|
* Save if to disk
|
|
|
|
*/
|
|
|
|
Msg_AddMsg();
|
|
|
|
Msg_UnLock();
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2005-08-29 11:15:54 +00:00
|
|
|
snprintf(temp, 81, " (%ld)", Msg.Id);
|
2004-11-05 19:38:24 +00:00
|
|
|
PUTSTR(temp);
|
|
|
|
Enter(1);
|
|
|
|
|
2003-05-10 11:51:43 +00:00
|
|
|
ReadExitinfo();
|
|
|
|
exitinfo.iPosted++;
|
|
|
|
WriteExitinfo();
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-05-10 11:51:43 +00:00
|
|
|
LC_Wrote = TRUE;
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-05-10 11:51:43 +00:00
|
|
|
Syslog('+', "Msg (%ld) to \"%s\", \"%s\", in %ld", Msg.Id, Msg.To, Msg.Subject, iMsgAreaNumber + 1);
|
|
|
|
|
|
|
|
msgs.LastPosted = time(NULL);
|
|
|
|
msgs.Posted.total++;
|
|
|
|
msgs.Posted.tweek++;
|
|
|
|
msgs.Posted.tdow[Diw]++;
|
|
|
|
msgs.Posted.month[Miy]++;
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2005-08-29 11:15:54 +00:00
|
|
|
snprintf(temp, PATH_MAX, "%s/etc/mareas.data", getenv("MBSE_ROOT"));
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-05-10 11:51:43 +00:00
|
|
|
if ((fp = fopen(temp, "r+")) != NULL) {
|
|
|
|
fseek(fp, msgshdr.hdrsize + (iMsgAreaNumber * (msgshdr.recsize + msgshdr.syssize)), SEEK_SET);
|
|
|
|
fwrite(&msgs, msgshdr.recsize, 1, fp);
|
|
|
|
fclose(fp);
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-05-11 13:23:31 +00:00
|
|
|
if (strlen(msgs.Group)) {
|
2005-08-29 11:15:54 +00:00
|
|
|
snprintf(temp, PATH_MAX, "%s/etc/mgroups.data", getenv("MBSE_ROOT"));
|
2004-05-11 13:23:31 +00:00
|
|
|
if ((fp = fopen(temp, "r+")) != NULL) {
|
|
|
|
fread(&mgrouphdr, sizeof(mgrouphdr), 1, fp);
|
|
|
|
while ((fread(&mgroup, mgrouphdr.recsize, 1, fp)) == 1) {
|
|
|
|
if (!strcmp(msgs.Group, mgroup.Name)) {
|
|
|
|
mgroup.LastDate = time(NULL);
|
|
|
|
mgroup.MsgsSent.total++;
|
|
|
|
mgroup.MsgsSent.tweek++;
|
|
|
|
mgroup.MsgsSent.tdow[l_date->tm_wday]++;
|
|
|
|
mgroup.MsgsSent.month[l_date->tm_mon]++;
|
|
|
|
fseek(fp, - mgrouphdr.recsize, SEEK_CUR);
|
|
|
|
fwrite(&mgroup, mgrouphdr.recsize, 1, fp);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fclose(fp);
|
|
|
|
} else {
|
|
|
|
WriteError("$Save_Msg(): Can't open %s", temp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-05-10 11:51:43 +00:00
|
|
|
/*
|
|
|
|
* Add quick mailscan info
|
|
|
|
*/
|
|
|
|
if (msgs.Type != LOCALMAIL) {
|
|
|
|
do_mailout = TRUE;
|
2005-08-29 11:15:54 +00:00
|
|
|
snprintf(temp, PATH_MAX, "%s/tmp/%smail.jam", getenv("MBSE_ROOT"),
|
|
|
|
((msgs.Type == ECHOMAIL) || (msgs.Type == LIST))? "echo" : "net");
|
2003-05-10 11:51:43 +00:00
|
|
|
if ((fp = fopen(temp, "a")) != NULL) {
|
|
|
|
fprintf(fp, "%s %lu\n", msgs.Base, Msg.Id);
|
|
|
|
fclose(fp);
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
2003-05-10 11:51:43 +00:00
|
|
|
}
|
|
|
|
free(temp);
|
2003-09-14 12:24:18 +00:00
|
|
|
Close_Msgbase(msgs.Base);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-05-10 11:51:43 +00:00
|
|
|
SetMsgArea(iMsgAreaNumber);
|
|
|
|
return TRUE;
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Show message header screen top for reading messages.
|
|
|
|
*/
|
2005-01-14 19:52:12 +00:00
|
|
|
void ShowMsgHdr(int Conv)
|
2001-08-17 05:46:24 +00:00
|
|
|
{
|
2004-11-03 20:48:45 +00:00
|
|
|
static char Buf1[35], Buf2[35], Buf3[81];
|
|
|
|
char msg[81];
|
|
|
|
struct tm *tm;
|
|
|
|
time_t now;
|
2005-01-14 19:52:12 +00:00
|
|
|
int color, i;
|
2004-11-03 20:48:45 +00:00
|
|
|
|
|
|
|
Buf1[0] = '\0';
|
|
|
|
Buf2[0] = '\0';
|
|
|
|
Buf3[0] = '\0';
|
|
|
|
|
|
|
|
clear();
|
2005-08-29 11:15:54 +00:00
|
|
|
snprintf(msg, 81, " %-70s", sMsgAreaDesc);
|
2004-11-03 20:48:45 +00:00
|
|
|
pout(BLUE, LIGHTGRAY, msg);
|
|
|
|
|
2005-08-29 11:15:54 +00:00
|
|
|
snprintf(msg, 81,"#%-5lu", Msg.Id);
|
2004-11-03 20:48:45 +00:00
|
|
|
pout(RED, LIGHTGRAY, msg);
|
|
|
|
Enter(1);
|
|
|
|
|
|
|
|
/* Date : */
|
|
|
|
pout(YELLOW, BLACK, (char *) Language(206));
|
|
|
|
colour(GREEN, BLACK);
|
|
|
|
/* Use intermediate variable to prevent SIGBUS on Sparc's */
|
|
|
|
now = Msg.Written;
|
|
|
|
tm = gmtime(&now);
|
2005-08-29 11:15:54 +00:00
|
|
|
snprintf(msg, 81, "%02d-%02d-%d %02d:%02d:%02d", tm->tm_mday, tm->tm_mon+1,
|
2001-08-17 05:46:24 +00:00
|
|
|
tm->tm_year+1900, tm->tm_hour, tm->tm_min, tm->tm_sec);
|
2004-11-03 20:48:45 +00:00
|
|
|
PUTSTR(msg);
|
|
|
|
|
|
|
|
colour(LIGHTRED, BLACK);
|
|
|
|
if (Msg.Local) PUTSTR((char *)" Local");
|
|
|
|
if (Msg.Intransit) PUTSTR((char *)" Transit");
|
|
|
|
if (Msg.Private) PUTSTR((char *)" Priv.");
|
|
|
|
if (Msg.Received) PUTSTR((char *)" Rcvd");
|
|
|
|
if (Msg.Sent) PUTSTR((char *)" Sent");
|
|
|
|
if (Msg.KillSent) PUTSTR((char *)" KillSent");
|
|
|
|
if (Msg.ArchiveSent) PUTSTR((char *)" ArchiveSent");
|
|
|
|
if (Msg.Hold) PUTSTR((char *)" Hold");
|
|
|
|
if (Msg.Crash) PUTSTR((char *)" Crash");
|
|
|
|
if (Msg.Immediate) PUTSTR((char *)" Imm.");
|
|
|
|
if (Msg.Direct) PUTSTR((char *)" Dir");
|
|
|
|
if (Msg.Gate) PUTSTR((char *)" Gate");
|
|
|
|
if (Msg.FileRequest) PUTSTR((char *)" Freq");
|
|
|
|
if (Msg.FileAttach) PUTSTR((char *)" File");
|
|
|
|
if (Msg.TruncFile) PUTSTR((char *)" TruncFile");
|
|
|
|
if (Msg.KillFile) PUTSTR((char *)" KillFile");
|
|
|
|
if (Msg.ReceiptRequest) PUTSTR((char *)" RRQ");
|
|
|
|
if (Msg.ConfirmRequest) PUTSTR((char *)" CRQ");
|
|
|
|
if (Msg.Orphan) PUTSTR((char *)" Orphan");
|
|
|
|
if (Msg.Encrypt) PUTSTR((char *)" Crypt");
|
|
|
|
if (Msg.Compressed) PUTSTR((char *)" Comp");
|
|
|
|
if (Msg.Escaped) PUTSTR((char *)" 7bit");
|
|
|
|
if (Msg.ForcePU) PUTSTR((char *)" FPU");
|
|
|
|
if (Msg.Localmail) PUTSTR((char *)" Localmail");
|
|
|
|
if (Msg.Netmail) PUTSTR((char *)" Netmail");
|
|
|
|
if (Msg.Echomail) PUTSTR((char *)" Echomail");
|
|
|
|
if (Msg.News) PUTSTR((char *)" News");
|
|
|
|
if (Msg.Email) PUTSTR((char *)" E-mail");
|
|
|
|
if (Msg.Nodisplay) PUTSTR((char *)" Nodisp");
|
|
|
|
if (Msg.Locked) PUTSTR((char *)" LCK");
|
|
|
|
if (Msg.Deleted) PUTSTR((char *)" Del");
|
|
|
|
Enter(1);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
/* From : */
|
|
|
|
pout(YELLOW, BLACK, (char *) Language(209));
|
|
|
|
if (IsMe(Msg.From))
|
|
|
|
color = LIGHTGREEN;
|
|
|
|
else
|
|
|
|
color = GREEN;
|
|
|
|
colour(color++, BLACK);
|
|
|
|
PUTSTR(Msg.From);
|
|
|
|
if (iMsgAreaType != LOCALMAIL) {
|
2005-08-29 11:15:54 +00:00
|
|
|
snprintf(msg, 81, " (%s)", Msg.FromAddress);
|
2004-11-03 20:48:45 +00:00
|
|
|
pout(color, BLACK, msg);
|
|
|
|
}
|
|
|
|
Enter(1);
|
|
|
|
|
|
|
|
/* To : */
|
|
|
|
pout(YELLOW, BLACK, (char *) Language(208));
|
|
|
|
if (IsMe(Msg.To))
|
|
|
|
color = LIGHTGREEN;
|
|
|
|
else
|
|
|
|
color = GREEN;
|
|
|
|
colour(color++, BLACK);
|
|
|
|
PUTSTR(Msg.To);
|
|
|
|
if (iMsgAreaType == NETMAIL) {
|
2005-08-29 11:15:54 +00:00
|
|
|
snprintf(msg, 81, " (%s)", Msg.ToAddress);
|
2004-11-03 20:48:45 +00:00
|
|
|
pout(color, BLACK, msg);
|
|
|
|
}
|
|
|
|
Enter(1);
|
|
|
|
|
|
|
|
/* Subject : */
|
|
|
|
pout(YELLOW, BLACK, (char *) Language(210));
|
2005-01-14 19:52:12 +00:00
|
|
|
colour(GREEN, BLACK);
|
|
|
|
|
|
|
|
if (Conv) {
|
|
|
|
/*
|
|
|
|
* Try to translate character sets
|
|
|
|
*/
|
|
|
|
for (i = 0; i < strlen(Msg.Subject); i++) {
|
|
|
|
PUTSTR(charset_map_c(Msg.Subject[i], FALSE));
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
PUTSTR(Msg.Subject);
|
|
|
|
}
|
2004-11-03 20:48:45 +00:00
|
|
|
Enter(1);
|
|
|
|
|
|
|
|
colour(CFG.HiliteF, CFG.HiliteB);
|
|
|
|
colour(YELLOW, BLUE);
|
|
|
|
if (Msg.Reply)
|
2005-08-29 11:15:54 +00:00
|
|
|
snprintf(Buf1, 35, "\"+\" %s %lu", (char *)Language(211), Msg.Reply);
|
2004-11-03 20:48:45 +00:00
|
|
|
if (Msg.Original)
|
2005-08-29 11:15:54 +00:00
|
|
|
snprintf(Buf2, 35, " \"-\" %s %lu", (char *)Language(212), Msg.Original);
|
|
|
|
snprintf(Buf3, 35, "%s%s ", Buf1, Buf2);
|
|
|
|
snprintf(msg, 81, "%77s ", Buf3);
|
2004-11-03 20:48:45 +00:00
|
|
|
pout(YELLOW, BLUE, msg);
|
|
|
|
Enter(1);
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2003-02-03 20:20:23 +00:00
|
|
|
* Export a message to file in the users home directory or to the rules directory.
|
2001-08-17 05:46:24 +00:00
|
|
|
*/
|
|
|
|
int Export_a_Msg(unsigned long Num)
|
|
|
|
{
|
2004-11-03 20:48:45 +00:00
|
|
|
char *p, msg[81];
|
2003-02-03 20:20:23 +00:00
|
|
|
int ShowMsg = TRUE, z, homedir = TRUE;
|
|
|
|
|
|
|
|
LastNum = Num;
|
|
|
|
iLineCount = 7;
|
2003-10-11 21:22:16 +00:00
|
|
|
WhosDoingWhat(READ_POST, NULL);
|
2003-02-03 20:20:23 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* The sysop has a choice to export to the rules directory.
|
|
|
|
*/
|
|
|
|
if ((exitinfo.Security.level >= CFG.sysop_access) && strlen(msgs.Tag)) {
|
|
|
|
while (TRUE) {
|
|
|
|
Enter(2);
|
|
|
|
/* Export to (H)ome or (R)ules directory: */
|
|
|
|
pout(WHITE, RED, (char *) Language(11));
|
|
|
|
colour(CFG.MsgInputColourF, CFG.MsgInputColourB);
|
|
|
|
alarm_on();
|
2004-11-03 20:48:45 +00:00
|
|
|
z = toupper(Readkey());
|
2003-02-03 20:20:23 +00:00
|
|
|
if (z == Keystroke(11, 0)) {
|
2004-11-03 20:48:45 +00:00
|
|
|
PUTCHAR(Keystroke(478, 0));
|
2003-02-03 20:20:23 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (z == Keystroke(11, 1)) {
|
2004-11-03 20:48:45 +00:00
|
|
|
PUTCHAR(Keystroke(478, 1));
|
2003-02-03 20:20:23 +00:00
|
|
|
homedir = FALSE;
|
|
|
|
break;
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
2003-02-03 20:20:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Syslog('+', "Export msg %d in area #%d (%s) to %s directory", Num, iMsgAreaNumber + 1, sMsgAreaDesc, homedir?"Home":"Rules");
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The area data is already set, so we can do the next things
|
|
|
|
*/
|
|
|
|
if (MsgBase.Total == 0) {
|
2004-11-03 20:48:45 +00:00
|
|
|
Enter(1);
|
2003-02-03 20:20:23 +00:00
|
|
|
/* There are no messages in this area */
|
2004-11-03 20:48:45 +00:00
|
|
|
pout(WHITE, BLACK, (char *) Language(205));
|
|
|
|
Enter(2);
|
2003-02-03 20:20:23 +00:00
|
|
|
Syslog('+', "No messages in area");
|
|
|
|
sleep(3);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-02-03 20:20:23 +00:00
|
|
|
if (!Msg_Open(sMsgAreaBase)) {
|
|
|
|
WriteError("Error open JAM base %s", sMsgAreaBase);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-02-03 20:20:23 +00:00
|
|
|
if (!Msg_ReadHeader(Num)) {
|
2004-11-03 20:48:45 +00:00
|
|
|
Enter(1);
|
2003-02-03 20:20:23 +00:00
|
|
|
/* Message doesn't exist */
|
2004-11-03 20:48:45 +00:00
|
|
|
pout(WHITE, BLACK, (char *)Language(77));
|
|
|
|
Enter(2);
|
2003-02-03 20:20:23 +00:00
|
|
|
Msg_Close();
|
|
|
|
sleep(3);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-02-03 20:20:23 +00:00
|
|
|
if (Msg.Private) {
|
|
|
|
ShowMsg = FALSE;
|
|
|
|
if ((strcasecmp(exitinfo.sUserName, Msg.From) == 0) || (strcasecmp(exitinfo.sUserName, Msg.To) == 0))
|
|
|
|
ShowMsg = TRUE;
|
|
|
|
if (exitinfo.Security.level >= msgs.SYSec.level)
|
|
|
|
ShowMsg = TRUE;
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-02-03 20:20:23 +00:00
|
|
|
if (!ShowMsg) {
|
2004-11-03 20:48:45 +00:00
|
|
|
Enter(1);
|
2003-02-03 20:20:23 +00:00
|
|
|
/* Private message, not owner */
|
2004-11-03 20:48:45 +00:00
|
|
|
pout(WHITE, BLACK, (char *) Language(82));
|
|
|
|
Enter(2);
|
2003-02-03 20:20:23 +00:00
|
|
|
Msg_Close();
|
|
|
|
sleep(3);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-02-03 20:20:23 +00:00
|
|
|
/*
|
|
|
|
* Export the message text to the file in the users home/wrk directory
|
|
|
|
* or to the rules directory.
|
|
|
|
* Create the filename as <areanum>_<msgnum>.msg if exported to the
|
|
|
|
* home directory, if exported to a rule directory the name is the area tag.
|
|
|
|
* The message is written in M$DOS <cr/lf> format.
|
|
|
|
*/
|
|
|
|
p = calloc(PATH_MAX, sizeof(char));
|
|
|
|
if (homedir)
|
2005-08-29 11:15:54 +00:00
|
|
|
snprintf(p, PATH_MAX, "%s/%s/wrk/%d_%lu.msg", CFG.bbs_usersdir, exitinfo.Name, iMsgAreaNumber + 1, Num);
|
2003-02-03 20:20:23 +00:00
|
|
|
else
|
2005-08-29 11:15:54 +00:00
|
|
|
snprintf(p, PATH_MAX, "%s/%s", CFG.rulesdir, msgs.Tag);
|
2003-02-03 20:20:23 +00:00
|
|
|
|
|
|
|
if ((qf = fopen(p, "w")) != NULL) {
|
|
|
|
free(p);
|
|
|
|
p = NULL;
|
|
|
|
if (Msg_Read(Num, 80)) {
|
|
|
|
if ((p = (char *)MsgText_First()) != NULL) {
|
|
|
|
do {
|
|
|
|
if ((p[0] == '\001') || (!strncmp(p, "SEEN-BY:", 8)) || (!strncmp(p, "AREA:", 5))) {
|
|
|
|
if (Kludges && homedir) {
|
|
|
|
if (p[0] == '\001') {
|
|
|
|
p[0] = 'a';
|
|
|
|
fprintf(qf, "^%s\r\n", p);
|
|
|
|
} else {
|
|
|
|
fprintf(qf, "%s\r\n", p);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (homedir || (strncmp(p, "--- ", 4) && strncmp(p, " * Origin", 9))) {
|
|
|
|
/*
|
|
|
|
* In rules directory, don't write tearline and Origin line.
|
|
|
|
*/
|
|
|
|
fprintf(qf, "%s\r\n", p);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} while ((p = (char *)MsgText_Next()) != NULL);
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
2003-02-03 20:20:23 +00:00
|
|
|
fclose(qf);
|
|
|
|
} else {
|
|
|
|
WriteError("$Can't open %s", p);
|
|
|
|
}
|
|
|
|
Msg_Close();
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Report the result.
|
|
|
|
*/
|
2004-11-03 20:48:45 +00:00
|
|
|
Enter(2);
|
2003-02-03 20:20:23 +00:00
|
|
|
if (homedir) {
|
|
|
|
/* Message exported to your private directory as: */
|
2004-11-03 20:48:45 +00:00
|
|
|
pout(CFG.TextColourF, CFG.TextColourB, (char *) Language(46));
|
2005-08-29 11:15:54 +00:00
|
|
|
snprintf(msg, 81, "%d_%lu.msg", iMsgAreaNumber + 1, Num);
|
2004-11-03 20:48:45 +00:00
|
|
|
pout(CFG.HiliteF, CFG.HiliteB, msg);
|
2003-02-03 20:20:23 +00:00
|
|
|
} else {
|
|
|
|
/* Message exported to rules directory as */
|
2004-11-03 20:48:45 +00:00
|
|
|
pout(CFG.TextColourF, CFG.TextColourB, (char *) Language(12));
|
|
|
|
pout(CFG.HiliteF, CFG.HiliteB, msgs.Tag);
|
2003-02-03 20:20:23 +00:00
|
|
|
}
|
2004-11-03 20:48:45 +00:00
|
|
|
Enter(2);
|
2003-02-03 20:20:23 +00:00
|
|
|
Pause();
|
|
|
|
return TRUE;
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Read a message on screen. Update the lastread pointers,
|
|
|
|
* except while scanning and reading new mail at logon.
|
|
|
|
*/
|
|
|
|
int Read_a_Msg(unsigned long Num, int UpdateLR)
|
|
|
|
{
|
2004-02-26 20:16:10 +00:00
|
|
|
char *p = NULL, *fn, *charset = NULL, *charsin = NULL, *charsout = NULL;
|
2004-02-28 19:49:54 +00:00
|
|
|
int i, ShowMsg = TRUE, UseIconv = FALSE;
|
2004-02-26 20:16:10 +00:00
|
|
|
lastread LR;
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-02-26 20:16:10 +00:00
|
|
|
LastNum = Num;
|
|
|
|
iLineCount = 7;
|
|
|
|
WhosDoingWhat(READ_POST, NULL);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-02-26 20:16:10 +00:00
|
|
|
/*
|
|
|
|
* The area data is already set, so we can do the next things
|
|
|
|
*/
|
|
|
|
if (MsgBase.Total == 0) {
|
2004-11-03 20:48:45 +00:00
|
|
|
Enter(1);
|
2004-02-26 20:16:10 +00:00
|
|
|
/* There are no messages in this area */
|
2004-11-03 20:48:45 +00:00
|
|
|
pout(WHITE, BLACK, (char *) Language(205));
|
|
|
|
Enter(2);
|
2004-02-26 20:16:10 +00:00
|
|
|
sleep(3);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-02-26 20:16:10 +00:00
|
|
|
if (!Msg_Open(sMsgAreaBase)) {
|
|
|
|
WriteError("Error open JAM base %s", sMsgAreaBase);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-02-26 20:16:10 +00:00
|
|
|
if (!Msg_ReadHeader(Num)) {
|
2004-11-03 20:48:45 +00:00
|
|
|
Enter(1);
|
|
|
|
pout(WHITE, BLACK, (char *)Language(77));
|
|
|
|
Enter(2);
|
2004-02-26 20:16:10 +00:00
|
|
|
Msg_Close();
|
|
|
|
sleep(3);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Msg.Private) {
|
|
|
|
ShowMsg = FALSE;
|
|
|
|
if ((strcasecmp(exitinfo.sUserName, Msg.From) == 0) || (strcasecmp(exitinfo.sUserName, Msg.To) == 0))
|
|
|
|
ShowMsg = TRUE;
|
|
|
|
if (exitinfo.Security.level >= msgs.SYSec.level)
|
|
|
|
ShowMsg = TRUE;
|
|
|
|
}
|
|
|
|
if (!ShowMsg) {
|
2004-11-03 20:48:45 +00:00
|
|
|
Enter(1);
|
|
|
|
pout(WHITE, BLACK, (char *) Language(82));
|
|
|
|
Enter(2);
|
2004-02-26 20:16:10 +00:00
|
|
|
Msg_Close();
|
|
|
|
sleep(3);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Fill Quote file in case the user wants to reply. Note that line
|
|
|
|
* wrapping is set lower then normal message read, to create room
|
|
|
|
* for the Quote> strings at the start of each line.
|
|
|
|
*/
|
2005-08-29 11:15:54 +00:00
|
|
|
fn = calloc(PATH_MAX, sizeof(char));
|
|
|
|
snprintf(fn, PATH_MAX, "%s/%s/.quote", CFG.bbs_usersdir, exitinfo.Name);
|
2004-02-26 20:16:10 +00:00
|
|
|
if ((qf = fopen(fn, "w")) != NULL) {
|
|
|
|
if (Msg_Read(Num, 75)) {
|
|
|
|
if ((p = (char *)MsgText_First()) != NULL)
|
|
|
|
do {
|
|
|
|
if ((p[0] == '\001') || (!strncmp(p, "SEEN-BY:", 8)) || (!strncmp(p, "AREA:", 5))) {
|
|
|
|
/*
|
|
|
|
* While we are here, check for the ^aCHRS: kludge and set the used charset.
|
|
|
|
*/
|
|
|
|
if (strncmp(p, "\001CHRS: ", 7) == 0) {
|
|
|
|
charset = xstrcpy(p + 7);
|
|
|
|
}
|
|
|
|
if (strncmp(p, "\001CHARSET: ", 10) == 0) {
|
|
|
|
charset = xstrcpy(p + 10);
|
|
|
|
}
|
|
|
|
if (Kludges) {
|
|
|
|
if (p[0] == '\001') {
|
|
|
|
p[0] = 'a';
|
|
|
|
fprintf(qf, "^%s\n", p);
|
|
|
|
} else
|
|
|
|
fprintf(qf, "%s\n", p);
|
|
|
|
}
|
|
|
|
} else
|
|
|
|
fprintf(qf, "%s\n", p);
|
|
|
|
} while ((p = (char *)MsgText_Next()) != NULL);
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
2004-02-26 20:16:10 +00:00
|
|
|
fclose(qf);
|
|
|
|
} else {
|
|
|
|
WriteError("$Can't open %s", p);
|
|
|
|
}
|
|
|
|
free(fn);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-02-26 20:16:10 +00:00
|
|
|
if ((charset == NULL) && (msgs.Charset != FTNC_NONE)) {
|
2001-08-17 05:46:24 +00:00
|
|
|
/*
|
2004-02-26 20:16:10 +00:00
|
|
|
* No charset marked in the message, use the area charset
|
2001-08-17 05:46:24 +00:00
|
|
|
*/
|
2005-08-14 09:38:06 +00:00
|
|
|
charset = xstrcpy(getftnchrs(msgs.Charset));
|
2004-02-26 20:16:10 +00:00
|
|
|
}
|
2004-02-28 19:49:54 +00:00
|
|
|
charsin = xstrcpy(charset);
|
2005-08-14 09:38:06 +00:00
|
|
|
charsout = xstrcpy(getftnchrs(exitinfo.Charset));
|
2004-02-26 20:16:10 +00:00
|
|
|
|
|
|
|
/*
|
2004-02-28 19:49:54 +00:00
|
|
|
* Try to setup charset mapping if the charactersets are different.
|
2004-02-26 20:16:10 +00:00
|
|
|
*/
|
|
|
|
if (charsin && charsout && strcmp(charsout, charsin)) {
|
2004-02-28 19:49:54 +00:00
|
|
|
UseIconv = charset_set_in_out(charsin, charsout);
|
2004-02-26 20:16:10 +00:00
|
|
|
}
|
2005-01-14 19:52:12 +00:00
|
|
|
/*
|
|
|
|
* Show message header with charset mapping if needed.
|
|
|
|
*/
|
|
|
|
ShowMsgHdr(UseIconv);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-02-26 20:16:10 +00:00
|
|
|
/*
|
|
|
|
* Show message text
|
|
|
|
*/
|
|
|
|
colour(CFG.TextColourF, CFG.TextColourB);
|
2004-09-12 12:59:38 +00:00
|
|
|
if (Msg_Read(Num, 79)) {
|
2004-02-26 20:16:10 +00:00
|
|
|
if ((p = (char *)MsgText_First()) != NULL) {
|
|
|
|
do {
|
|
|
|
if ((p[0] == '\001') || (!strncmp(p, "SEEN-BY:", 8)) || (!strncmp(p, "AREA:", 5))) {
|
|
|
|
if (Kludges) {
|
2004-11-03 20:48:45 +00:00
|
|
|
pout(LIGHTGRAY, BLACK, p);
|
|
|
|
Enter(1);
|
2005-01-14 19:52:12 +00:00
|
|
|
if (CheckLine(CFG.TextColourF, CFG.TextColourB, FALSE, UseIconv))
|
2004-02-26 20:16:10 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
colour(CFG.TextColourF, CFG.TextColourB);
|
|
|
|
if (strchr(p, '>') != NULL)
|
|
|
|
if ((strlen(p) - strlen(strchr(p, '>'))) < 10)
|
|
|
|
colour(CFG.HiliteF, CFG.HiliteB);
|
|
|
|
if (UseIconv) {
|
|
|
|
/*
|
2004-02-28 19:49:54 +00:00
|
|
|
* Try to translate character sets
|
2004-02-26 20:16:10 +00:00
|
|
|
*/
|
2004-02-28 19:49:54 +00:00
|
|
|
for (i = 0; i < strlen(p); i++) {
|
2004-11-03 20:48:45 +00:00
|
|
|
PUTSTR(charset_map_c(p[i], FALSE));
|
2004-02-26 20:16:10 +00:00
|
|
|
}
|
2004-11-03 20:48:45 +00:00
|
|
|
Enter(1);
|
2004-02-26 20:16:10 +00:00
|
|
|
} else {
|
2004-11-03 20:48:45 +00:00
|
|
|
PUTSTR(p);
|
|
|
|
Enter(1);
|
2004-02-26 20:16:10 +00:00
|
|
|
}
|
2004-02-28 19:49:54 +00:00
|
|
|
|
2005-01-14 19:52:12 +00:00
|
|
|
if (CheckLine(CFG.TextColourF, CFG.TextColourB, FALSE, UseIconv))
|
2004-02-26 20:16:10 +00:00
|
|
|
break;
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
2004-02-26 20:16:10 +00:00
|
|
|
} while ((p = (char *)MsgText_Next()) != NULL);
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
2004-02-26 20:16:10 +00:00
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-02-26 20:16:10 +00:00
|
|
|
if (charset)
|
|
|
|
free(charset);
|
|
|
|
if (charsout)
|
|
|
|
free(charsout);
|
|
|
|
if (charsin)
|
|
|
|
free(charsin);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set the Received status on this message if it's for the user.
|
|
|
|
*/
|
|
|
|
if ((!Msg.Received) && (strlen(Msg.To) > 0) &&
|
2001-08-17 05:46:24 +00:00
|
|
|
((strcasecmp(Msg.To, exitinfo.sUserName) == 0) || (strcasecmp(exitinfo.sHandle, Msg.To) == 0))) {
|
2004-02-26 20:16:10 +00:00
|
|
|
Msg.Received = TRUE;
|
|
|
|
Msg.Read = time(NULL) - (gmt_offset((time_t)0) * 60);
|
|
|
|
if (Msg_Lock(30L)) {
|
|
|
|
Msg_WriteHeader(Num);
|
|
|
|
Msg_UnLock();
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
2004-02-26 20:16:10 +00:00
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-02-26 20:16:10 +00:00
|
|
|
/*
|
|
|
|
* Update lastread pointer if needed. Netmail boards are always updated.
|
|
|
|
*/
|
|
|
|
if (Msg_Lock(30L) && (UpdateLR || msgs.Type == NETMAIL)) {
|
|
|
|
LR.UserID = grecno;
|
|
|
|
p = xstrcpy(exitinfo.sUserName);
|
|
|
|
if (Msg_GetLastRead(&LR) == TRUE) {
|
|
|
|
LR.LastReadMsg = Num;
|
|
|
|
if (Num > LR.HighReadMsg)
|
|
|
|
LR.HighReadMsg = Num;
|
|
|
|
if (LR.HighReadMsg > MsgBase.Highest)
|
|
|
|
LR.HighReadMsg = MsgBase.Highest;
|
|
|
|
LR.UserCRC = StringCRC32(tl(p));
|
|
|
|
if (!Msg_SetLastRead(LR))
|
|
|
|
WriteError("Error update lastread");
|
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* Append new lastread pointer
|
|
|
|
*/
|
|
|
|
LR.UserCRC = StringCRC32(tl(p));
|
|
|
|
LR.UserID = grecno;
|
|
|
|
LR.LastReadMsg = Num;
|
|
|
|
LR.HighReadMsg = Num;
|
|
|
|
if (!Msg_NewLastRead(LR))
|
|
|
|
WriteError("Can't append lastread");
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
2004-02-26 20:16:10 +00:00
|
|
|
free(p);
|
|
|
|
Msg_UnLock();
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-02-26 20:16:10 +00:00
|
|
|
Msg_Close();
|
|
|
|
return TRUE;
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Read Messages, called from menu
|
|
|
|
*/
|
|
|
|
void Read_Msgs()
|
|
|
|
{
|
2004-11-03 20:48:45 +00:00
|
|
|
char *temp;
|
|
|
|
unsigned long Start;
|
|
|
|
lastread LR;
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
temp = calloc(81, sizeof(char));
|
|
|
|
Enter(1);
|
2001-08-17 05:46:24 +00:00
|
|
|
/* Message area \"%s\" contains %lu messages. */
|
2005-08-29 11:15:54 +00:00
|
|
|
snprintf(temp, 81, "%s\"%s\" %s%lu %s", (char *) Language(221), sMsgAreaDesc,
|
2001-11-09 13:53:19 +00:00
|
|
|
(char *) Language(222), MsgBase.Total, (char *) Language(223));
|
2004-11-03 20:48:45 +00:00
|
|
|
pout(CFG.TextColourF, CFG.TextColourB, temp);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
/*
|
|
|
|
* Check for lastread pointer, suggest lastread number for start.
|
|
|
|
*/
|
|
|
|
Start = MsgBase.Lowest;
|
|
|
|
if (Msg_Open(sMsgAreaBase)) {
|
|
|
|
LR.UserID = grecno;
|
|
|
|
if (Msg_GetLastRead(&LR))
|
|
|
|
Start = LR.HighReadMsg + 1;
|
|
|
|
else
|
|
|
|
Start = 1;
|
|
|
|
Msg_Close();
|
2001-08-17 05:46:24 +00:00
|
|
|
/*
|
2004-11-03 20:48:45 +00:00
|
|
|
* If we already have read the last message, the pointer is
|
|
|
|
* higher then HighMsgNum, we set it at HighMsgNum to prevent
|
|
|
|
* errors and read that message again.
|
2001-08-17 05:46:24 +00:00
|
|
|
*/
|
2004-11-03 20:48:45 +00:00
|
|
|
if (Start > MsgBase.Highest)
|
|
|
|
Start = MsgBase.Highest;
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
Enter(1);
|
|
|
|
/* Please enter a message between */
|
2005-08-29 11:15:54 +00:00
|
|
|
snprintf(temp, 81, "%s(%lu - %lu)", (char *) Language(224), MsgBase.Lowest, MsgBase.Highest);
|
2004-11-03 20:48:45 +00:00
|
|
|
pout(WHITE, BLACK, temp);
|
|
|
|
Enter(1);
|
|
|
|
/* Message number [ */
|
2005-08-29 11:15:54 +00:00
|
|
|
snprintf(temp, 81, "%s%lu]: ", (char *) Language(225), Start);
|
2004-11-03 20:48:45 +00:00
|
|
|
PUTSTR(temp);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
colour(CFG.InputColourF, CFG.InputColourB);
|
|
|
|
GetstrC(temp, 80);
|
|
|
|
if ((strcmp(temp, "")) != 0)
|
|
|
|
Start = atoi(temp);
|
|
|
|
free(temp);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
if (!Read_a_Msg(Start, TRUE))
|
|
|
|
return;
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
if (MsgBase.Total == 0)
|
|
|
|
return;
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
while(ReadPanel()) {}
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The panel bar under the messages while reading
|
|
|
|
*/
|
|
|
|
int ReadPanel()
|
|
|
|
{
|
2003-02-20 21:06:46 +00:00
|
|
|
int input;
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-10-11 21:22:16 +00:00
|
|
|
WhosDoingWhat(READ_POST, NULL);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-02-20 21:06:46 +00:00
|
|
|
/*
|
|
|
|
* The writer of the message, sysops, and who has sysop rights to the message area
|
|
|
|
* are allowed to delete messages.
|
|
|
|
*/
|
|
|
|
if ((msgs.UsrDelete && IsMe(Msg.From)) || (exitinfo.Security.level >= CFG.sysop_access) ||
|
|
|
|
Access(exitinfo.Security, msgs.SYSec)) {
|
|
|
|
/* (A)gain, (N)ext, (L)ast, (R)eply, (E)nter, (D)elete, (Q)uit, e(X)port */
|
2004-11-03 20:48:45 +00:00
|
|
|
pout(WHITE, RED, (char *) Language(214));
|
2003-02-20 21:06:46 +00:00
|
|
|
} else {
|
|
|
|
/* (A)gain, (N)ext, (L)ast, (R)eply, (E)nter, (Q)uit, e(X)port */
|
2004-11-03 20:48:45 +00:00
|
|
|
pout(WHITE, RED, (char *) Language(215));
|
2003-02-20 21:06:46 +00:00
|
|
|
}
|
|
|
|
if ((exitinfo.Security.level >= CFG.sysop_access) || Access(exitinfo.Security, msgs.SYSec))
|
2004-11-03 20:48:45 +00:00
|
|
|
PUTSTR((char *)", (!)");
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
PUTSTR((char *)": ");
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-02-20 21:06:46 +00:00
|
|
|
alarm_on();
|
2004-11-03 20:48:45 +00:00
|
|
|
input = toupper(Readkey());
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-02-20 21:06:46 +00:00
|
|
|
if (input == '!') { /* ! Toggle kludges display */
|
|
|
|
if ((exitinfo.Security.level >= CFG.sysop_access) || Access(exitinfo.Security, msgs.SYSec)) {
|
|
|
|
if (Kludges)
|
|
|
|
Kludges = FALSE;
|
|
|
|
else
|
|
|
|
Kludges = TRUE;
|
|
|
|
}
|
|
|
|
Read_a_Msg(LastNum, TRUE);
|
|
|
|
|
|
|
|
} else if (input == Keystroke(214, 0)) { /* (A)gain */
|
|
|
|
Read_a_Msg(LastNum, TRUE);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-02-20 21:06:46 +00:00
|
|
|
} else if (input == Keystroke(214, 4)) { /* (P)ost */
|
|
|
|
Post_Msg();
|
|
|
|
Read_a_Msg(LastNum, TRUE);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-02-20 21:06:46 +00:00
|
|
|
} else if (input == Keystroke(214, 2)) { /* (L)ast */
|
|
|
|
if (LastNum > MsgBase.Lowest)
|
|
|
|
LastNum--;
|
|
|
|
Read_a_Msg(LastNum, TRUE);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-02-20 21:06:46 +00:00
|
|
|
} else if (input == Keystroke(214, 3)) { /* (R)eply */
|
|
|
|
Reply_Msg(TRUE);
|
|
|
|
Read_a_Msg(LastNum, TRUE);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-02-20 21:06:46 +00:00
|
|
|
} else if (input == Keystroke(214, 5)) { /* (Q)uit */
|
|
|
|
/* Quit */
|
2004-11-03 20:48:45 +00:00
|
|
|
pout(WHITE, BLACK, (char *) Language(189));
|
|
|
|
Enter(1);
|
2003-02-20 21:06:46 +00:00
|
|
|
return FALSE;
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-02-20 21:06:46 +00:00
|
|
|
} else if (input == Keystroke(214, 7)) { /* e(X)port */
|
|
|
|
Export_a_Msg(LastNum);
|
|
|
|
Read_a_Msg(LastNum, TRUE);
|
|
|
|
|
|
|
|
} else if (input == '+') {
|
|
|
|
if (Msg.Reply)
|
|
|
|
LastNum = Msg.Reply;
|
|
|
|
Read_a_Msg(LastNum, TRUE);
|
|
|
|
|
|
|
|
} else if (input == '-') {
|
|
|
|
if (Msg.Original)
|
|
|
|
LastNum = Msg.Original;
|
|
|
|
Read_a_Msg(LastNum, TRUE);
|
|
|
|
|
|
|
|
} else if (input == Keystroke(214, 6)) { /* (D)elete */
|
|
|
|
if ((msgs.UsrDelete && IsMe(Msg.From)) || (exitinfo.Security.level >= CFG.sysop_access) ||
|
|
|
|
Access(exitinfo.Security, msgs.SYSec)) {
|
|
|
|
Delete_MsgNum(LastNum);
|
|
|
|
if (LastNum < MsgBase.Highest) {
|
|
|
|
LastNum++;
|
2001-08-17 05:46:24 +00:00
|
|
|
Read_a_Msg(LastNum, TRUE);
|
2003-02-20 21:06:46 +00:00
|
|
|
} else {
|
|
|
|
return FALSE;
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
} else {
|
2003-02-20 21:06:46 +00:00
|
|
|
Read_a_Msg(LastNum, TRUE);
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
2003-02-20 21:06:46 +00:00
|
|
|
|
|
|
|
} else {
|
|
|
|
/* Next */
|
|
|
|
pout(WHITE, BLACK, (char *) Language(216));
|
|
|
|
if (LastNum < MsgBase.Highest)
|
|
|
|
LastNum++;
|
|
|
|
else
|
|
|
|
return FALSE;
|
|
|
|
Read_a_Msg(LastNum, TRUE);
|
|
|
|
}
|
|
|
|
return TRUE;
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Reply message, in Msg.From and Msg.Subject must be the
|
|
|
|
* name to reply to and the subject. IsReply is true if the
|
|
|
|
* message is a real reply, and false for forced messages such
|
|
|
|
* as "message to sysop"
|
|
|
|
*/
|
|
|
|
void Reply_Msg(int IsReply)
|
|
|
|
{
|
2003-11-15 16:36:51 +00:00
|
|
|
int i, j, x, cc;
|
2005-08-29 12:39:37 +00:00
|
|
|
char to[101], from[101], subj[101], msgid[101], replyto[101], replyaddr[101], *tmp, *buf, qin[6], msg[81];
|
2002-07-14 16:20:28 +00:00
|
|
|
faddr *Dest = NULL;
|
|
|
|
|
|
|
|
if (!Post_Allowed())
|
|
|
|
return;
|
|
|
|
|
2005-08-29 12:39:37 +00:00
|
|
|
strncpy(from, Msg.To, 100);
|
|
|
|
strncpy(to, Msg.From, 100);
|
2002-07-14 16:20:28 +00:00
|
|
|
strncpy(replyto, Msg.ReplyTo, 80);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* For some reason there are sometimes spaces at the
|
|
|
|
* beginning of the reply address.
|
|
|
|
*/
|
|
|
|
tmp = Msg.ReplyAddr;
|
|
|
|
while (*tmp && isspace(*tmp))
|
|
|
|
tmp++;
|
2005-08-29 12:39:37 +00:00
|
|
|
strncpy(replyaddr, tmp, 100);
|
2002-07-14 16:20:28 +00:00
|
|
|
|
|
|
|
Dest = parsefnode(Msg.FromAddress);
|
|
|
|
Syslog('m', "Parsed from address %s", ascfnode(Dest, 0x1f));
|
|
|
|
|
|
|
|
if (strncasecmp(Msg.Subject, "Re:", 3) && strncasecmp(Msg.Subject, "Re^2:", 5) && IsReply) {
|
2005-08-29 12:39:37 +00:00
|
|
|
snprintf(subj, 101, "Re: ");
|
|
|
|
strncpy(subj+4, Msg.Subject, 97);
|
2002-07-14 16:20:28 +00:00
|
|
|
} else {
|
2005-08-29 12:39:37 +00:00
|
|
|
strncpy(subj, Msg.Subject, 101);
|
2002-07-14 16:20:28 +00:00
|
|
|
}
|
|
|
|
Syslog('m', "Reply msg to %s, subject %s", to, subj);
|
|
|
|
Syslog('m', "Msgid was %s", Msg.Msgid);
|
2005-08-29 12:39:37 +00:00
|
|
|
strncpy(msgid, Msg.Msgid, 100);
|
2002-07-14 16:20:28 +00:00
|
|
|
|
|
|
|
x = 0;
|
2003-10-11 21:22:16 +00:00
|
|
|
WhosDoingWhat(READ_POST, NULL);
|
2002-07-14 16:20:28 +00:00
|
|
|
clear();
|
2005-08-29 11:15:54 +00:00
|
|
|
snprintf(msg, 81, " %-71s", sMsgAreaDesc);
|
2004-11-03 20:48:45 +00:00
|
|
|
pout(BLUE, LIGHTGRAY, msg);
|
2005-08-29 11:15:54 +00:00
|
|
|
snprintf(msg, 81, "#%-5lu", MsgBase.Highest + 1);
|
2004-11-03 20:48:45 +00:00
|
|
|
pout(RED, LIGHTGRAY, msg);
|
|
|
|
Enter(1);
|
2002-07-14 16:20:28 +00:00
|
|
|
|
|
|
|
colour(CFG.HiliteF, CFG.HiliteB);
|
|
|
|
sLine();
|
|
|
|
|
|
|
|
for (i = 0; i < (TEXTBUFSIZE + 1); i++)
|
2003-09-02 20:25:42 +00:00
|
|
|
Message[i] = (char *) calloc(MAX_LINE_LENGTH +1, sizeof(char));
|
2002-07-14 16:20:28 +00:00
|
|
|
Msg_New();
|
|
|
|
|
2005-08-29 12:39:37 +00:00
|
|
|
strncpy(Msg.Replyid, msgid, 101);
|
|
|
|
strncpy(Msg.ReplyTo, replyto, 101);
|
|
|
|
strncpy(Msg.ReplyAddr, replyaddr, 101);
|
2002-07-14 16:20:28 +00:00
|
|
|
|
|
|
|
/* From : */
|
2003-02-02 15:03:40 +00:00
|
|
|
if (Alias_Option()) {
|
|
|
|
/*
|
|
|
|
* Set handle
|
|
|
|
*/
|
|
|
|
strcpy(Msg.From, exitinfo.sHandle);
|
|
|
|
tlcap(Msg.From); // Do we want this???
|
|
|
|
} else {
|
|
|
|
if (msgs.Type == NEWS) {
|
|
|
|
if (CFG.EmailMode != E_PRMISP) {
|
|
|
|
/*
|
|
|
|
* If no inernet mail domain, use fidonet addressing
|
|
|
|
*/
|
|
|
|
strcpy(Msg.From, exitinfo.sUserName);
|
|
|
|
tlcap(Msg.From);
|
|
|
|
} else {
|
2005-08-29 11:15:54 +00:00
|
|
|
snprintf(Msg.From, 101, "%s@%s (%s)", exitinfo.Name, CFG.sysdomain, exitinfo.sUserName);
|
2003-02-02 15:03:40 +00:00
|
|
|
}
|
|
|
|
} else {
|
2005-08-29 12:39:37 +00:00
|
|
|
strncpy(Msg.From, exitinfo.sUserName, 101);
|
2003-02-02 15:03:40 +00:00
|
|
|
tlcap(Msg.From);
|
|
|
|
}
|
|
|
|
}
|
2002-07-14 16:20:28 +00:00
|
|
|
pout(YELLOW, BLACK, (char *) Language(209));
|
|
|
|
pout(CFG.MsgInputColourF, CFG.MsgInputColourB, Msg.From);
|
|
|
|
Enter(1);
|
|
|
|
|
|
|
|
/* To : */
|
2005-08-29 12:39:37 +00:00
|
|
|
strncpy(Msg.To, to, 101);
|
2002-07-14 16:20:28 +00:00
|
|
|
pout(YELLOW, BLACK, (char *) Language(208));
|
|
|
|
pout(CFG.MsgInputColourF, CFG.MsgInputColourB, Msg.To);
|
|
|
|
Enter(1);
|
|
|
|
|
|
|
|
/* Enter to keep Subject. */
|
|
|
|
pout(LIGHTRED, BLACK, (char *) Language(219));
|
|
|
|
Enter(1);
|
|
|
|
/* Subject : */
|
|
|
|
pout(YELLOW, BLACK, (char *) Language(210));
|
2005-08-29 12:39:37 +00:00
|
|
|
strncpy(Msg.Subject, subj, 101);
|
2002-07-14 16:20:28 +00:00
|
|
|
pout(CFG.MsgInputColourF, CFG.MsgInputColourB, Msg.Subject);
|
|
|
|
|
|
|
|
x = strlen(subj);
|
|
|
|
colour(CFG.MsgInputColourF, CFG.MsgInputColourB);
|
|
|
|
GetstrP(subj, 50, x);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2005-08-10 15:32:42 +00:00
|
|
|
mbse_CleanSubject(subj);
|
2002-07-14 16:20:28 +00:00
|
|
|
if (strlen(subj))
|
|
|
|
strcpy(Msg.Subject, subj);
|
|
|
|
|
|
|
|
Msg.Private = IsPrivate();
|
|
|
|
Enter(1);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If netmail reply and enough security level, allow crashmail.
|
|
|
|
*/
|
|
|
|
if (msgs.Type == NETMAIL) {
|
|
|
|
switch (Crash_Option(Dest)) {
|
|
|
|
case 1: Msg.Crash = TRUE;
|
|
|
|
break;
|
|
|
|
case 2: Msg.Immediate = TRUE;
|
|
|
|
break;
|
2004-08-07 14:52:57 +00:00
|
|
|
case -1:printf("\r");
|
|
|
|
/* Node not known, continue anayway [y/N]: */
|
|
|
|
pout(CYAN, BLACK, (char *) Language(241));
|
|
|
|
alarm_on();
|
2004-11-03 20:48:45 +00:00
|
|
|
if (toupper(Readkey()) == Keystroke(241, 0)) {
|
2004-08-07 14:52:57 +00:00
|
|
|
Syslog('+', "Node not found, forced continue");
|
|
|
|
} else {
|
|
|
|
for (i = 0; i < (TEXTBUFSIZE + 1); i++)
|
|
|
|
free(Message[i]);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
break;
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
2002-07-14 16:20:28 +00:00
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2002-07-14 16:20:28 +00:00
|
|
|
Check_Attach();
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Quote original message now, format the original users
|
|
|
|
* initials into qin. No quoting if this is a message to Sysop.
|
|
|
|
*/
|
|
|
|
Line = 1;
|
|
|
|
if (IsReply) {
|
2005-08-29 11:15:54 +00:00
|
|
|
snprintf(Message[1], TEXTBUFSIZE +1, "%s wrote to %s:", to, from);
|
2002-07-14 16:20:28 +00:00
|
|
|
memset(&qin, 0, sizeof(qin));
|
|
|
|
x = TRUE;
|
|
|
|
j = 0;
|
|
|
|
for (i = 0; i < strlen(to); i++) {
|
|
|
|
if (x && isalpha(to[i])) {
|
|
|
|
qin[j] = to[i];
|
|
|
|
j++;
|
|
|
|
x = FALSE;
|
|
|
|
}
|
|
|
|
if (to[i] == ' ' || to[i] == '.')
|
2001-08-17 05:46:24 +00:00
|
|
|
x = TRUE;
|
2002-07-14 16:20:28 +00:00
|
|
|
if (j == 6)
|
|
|
|
break;
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
2002-07-14 16:20:28 +00:00
|
|
|
Line = 2;
|
|
|
|
|
2004-08-07 14:52:57 +00:00
|
|
|
tmp = calloc(PATH_MAX, sizeof(char));
|
2005-08-29 12:39:37 +00:00
|
|
|
buf = calloc(TEXTBUFSIZE +1, sizeof(char));
|
2002-07-14 16:20:28 +00:00
|
|
|
|
2005-08-29 11:15:54 +00:00
|
|
|
snprintf(tmp, PATH_MAX, "%s/%s/.quote", CFG.bbs_usersdir, exitinfo.Name);
|
2002-07-14 16:20:28 +00:00
|
|
|
if ((qf = fopen(tmp, "r")) != NULL) {
|
2005-08-29 12:39:37 +00:00
|
|
|
while ((fgets(buf, TEXTBUFSIZE, qf)) != NULL) {
|
2002-07-14 16:20:28 +00:00
|
|
|
Striplf(buf);
|
2005-08-29 11:15:54 +00:00
|
|
|
snprintf(Message[Line], TEXTBUFSIZE +1, "%s> %s", (char *)qin, buf);
|
2002-07-14 16:20:28 +00:00
|
|
|
Line++;
|
|
|
|
if (Line == TEXTBUFSIZE)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
fclose(qf);
|
|
|
|
} else
|
|
|
|
WriteError("$Can't read %s", tmp);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2002-07-14 16:20:28 +00:00
|
|
|
free(buf);
|
|
|
|
free(tmp);
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-11-15 16:36:51 +00:00
|
|
|
if (Edit_Msg()) {
|
2004-11-03 20:48:45 +00:00
|
|
|
Enter(1);
|
2003-11-15 16:36:51 +00:00
|
|
|
if (msgs.Type == NETMAIL) {
|
|
|
|
/*
|
|
|
|
* Check for Carbon Copy lines, process them if present.
|
|
|
|
*/
|
|
|
|
cc = 0;
|
|
|
|
for (i = 1; i <= Line; i++) {
|
|
|
|
if (strncasecmp(Message[i], "cc: ", 4)) {
|
|
|
|
break;
|
|
|
|
} else {
|
|
|
|
cc++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Syslog('b', "CC: detected %d", cc);
|
|
|
|
if (cc) {
|
|
|
|
/*
|
|
|
|
* Carbon copies, modify the text to show the presence of CCs.
|
|
|
|
*/
|
|
|
|
for (i = Line; i; i--) {
|
|
|
|
Syslog('b', "%02d: \"%s\"", i, printable(Message[i], 0));
|
2005-08-29 11:15:54 +00:00
|
|
|
snprintf(Message[i + 1], TEXTBUFSIZE +1, Message[i]);
|
2003-11-15 16:36:51 +00:00
|
|
|
}
|
|
|
|
Line++;
|
2005-08-29 11:15:54 +00:00
|
|
|
snprintf(Message[1], TEXTBUFSIZE +1, " +: Original message to %s", ascfnode(Dest, 0x4f));
|
2003-11-15 16:36:51 +00:00
|
|
|
for (i = 1; i <= Line; i++) {
|
|
|
|
Syslog('b', "%02d: \"%s\"", i, printable(Message[i], 0));
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* First sent to original destination
|
|
|
|
*/
|
|
|
|
Save_Msg(IsReply, Dest);
|
|
|
|
/*
|
|
|
|
* Now sent copies
|
|
|
|
*/
|
|
|
|
for (i = 0; i < cc; i++) {
|
|
|
|
Save_CC(IsReply, Message[i+2]);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
Save_Msg(IsReply, Dest);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
Save_Msg(IsReply, Dest);
|
|
|
|
}
|
2004-11-03 20:48:45 +00:00
|
|
|
Enter(1);
|
2003-11-15 16:36:51 +00:00
|
|
|
sleep(3);
|
|
|
|
}
|
2002-07-14 16:20:28 +00:00
|
|
|
|
|
|
|
for (i = 0; i < (TEXTBUFSIZE + 1); i++)
|
|
|
|
free(Message[i]);
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int IsMe(char *Name)
|
|
|
|
{
|
2004-11-03 20:48:45 +00:00
|
|
|
char *p, *q;
|
|
|
|
int i, rc = FALSE;
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
if (strlen(Name) == 0)
|
|
|
|
return FALSE;
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
if (strcasecmp(Name, exitinfo.sUserName) == 0)
|
|
|
|
rc = TRUE;
|
|
|
|
|
|
|
|
if (strcasecmp(Name, exitinfo.sHandle) == 0)
|
|
|
|
rc = TRUE;
|
|
|
|
|
|
|
|
q = xstrcpy(Name);
|
|
|
|
if (strstr(q, (char *)"@")) {
|
|
|
|
p = strtok(q, "@");
|
|
|
|
for (i = 0; i < strlen(p); i++)
|
|
|
|
if (p[i] == '_')
|
|
|
|
p[i] = ' ';
|
|
|
|
if (strcasecmp(p, exitinfo.sUserName) == 0)
|
|
|
|
rc = TRUE;
|
|
|
|
if (strcasecmp(p, exitinfo.sHandle) == 0)
|
|
|
|
rc = TRUE;
|
|
|
|
if (strcasecmp(p, exitinfo.Name) == 0)
|
|
|
|
rc = TRUE;
|
|
|
|
}
|
|
|
|
free(q);
|
|
|
|
return rc ;
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void QuickScan_Msgs()
|
|
|
|
{
|
2003-02-20 21:06:46 +00:00
|
|
|
int FoundMsg = FALSE;
|
|
|
|
long i;
|
2004-11-03 20:48:45 +00:00
|
|
|
char msg[81];
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-02-20 21:06:46 +00:00
|
|
|
iLineCount = 2;
|
2003-10-11 21:22:16 +00:00
|
|
|
WhosDoingWhat(READ_POST, NULL);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-02-20 21:06:46 +00:00
|
|
|
if (MsgBase.Total == 0) {
|
|
|
|
Enter(1);
|
|
|
|
/* There are no messages in this area. */
|
|
|
|
pout(WHITE, BLACK, (char *) Language(205));
|
|
|
|
Enter(3);
|
|
|
|
sleep(3);
|
|
|
|
return;
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-02-20 21:06:46 +00:00
|
|
|
clear();
|
|
|
|
/* # From To Subject */
|
|
|
|
poutCR(YELLOW, BLUE, (char *) Language(220));
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-02-20 21:06:46 +00:00
|
|
|
if (Msg_Open(sMsgAreaBase)) {
|
|
|
|
for (i = MsgBase.Lowest; i <= MsgBase.Highest; i++) {
|
|
|
|
if (Msg_ReadHeader(i) && ((msgs.Type != NETMAIL) ||
|
2001-11-11 12:07:39 +00:00
|
|
|
((msgs.Type == NETMAIL) && ((IsMe(Msg.From)) || (IsMe(Msg.To)))))) {
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2005-08-29 11:15:54 +00:00
|
|
|
snprintf(msg, 81, "%-6lu", Msg.Id);
|
2004-11-03 20:48:45 +00:00
|
|
|
pout(WHITE, BLACK, msg);
|
2005-08-29 11:15:54 +00:00
|
|
|
snprintf(msg, 81, "%s ", padleft(Msg.From, 20, ' '));
|
2003-02-20 21:06:46 +00:00
|
|
|
if (IsMe(Msg.From))
|
2004-11-03 20:48:45 +00:00
|
|
|
pout(LIGHTCYAN, BLACK, msg);
|
2003-02-20 21:06:46 +00:00
|
|
|
else
|
2004-11-03 20:48:45 +00:00
|
|
|
pout(CYAN, BLACK, msg);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2005-08-29 11:15:54 +00:00
|
|
|
snprintf(msg, 81, "%s ", padleft(Msg.To, 20, ' '));
|
2003-02-20 21:06:46 +00:00
|
|
|
if (IsMe(Msg.To))
|
2004-11-03 20:48:45 +00:00
|
|
|
pout(LIGHTGREEN, BLACK, msg);
|
2003-02-20 21:06:46 +00:00
|
|
|
else
|
2004-11-03 20:48:45 +00:00
|
|
|
pout(GREEN, BLACK, msg);
|
2005-08-29 11:15:54 +00:00
|
|
|
snprintf(msg, 81, "%s", padleft(Msg.Subject, 31, ' '));
|
2004-11-03 20:48:45 +00:00
|
|
|
pout(MAGENTA, BLACK, msg);
|
|
|
|
Enter(1);
|
2003-02-20 21:06:46 +00:00
|
|
|
FoundMsg = TRUE;
|
|
|
|
if (LC(1))
|
|
|
|
break;
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
2003-02-20 21:06:46 +00:00
|
|
|
Msg_Close();
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-02-20 21:06:46 +00:00
|
|
|
if (!FoundMsg) {
|
|
|
|
Enter(1);
|
|
|
|
/* There are no messages in this area. */
|
|
|
|
pout(LIGHTGREEN, BLACK, (char *) Language(205));
|
|
|
|
Enter(2);
|
|
|
|
sleep(3);
|
|
|
|
}
|
|
|
|
|
|
|
|
iLineCount = 2;
|
|
|
|
Pause();
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Called from the menu
|
|
|
|
*/
|
|
|
|
void Delete_Msg()
|
|
|
|
{
|
2003-02-20 21:06:46 +00:00
|
|
|
char *temp;
|
|
|
|
unsigned long Msgnum = 0L;
|
|
|
|
|
2003-10-11 21:22:16 +00:00
|
|
|
WhosDoingWhat(READ_POST, NULL);
|
2003-02-20 21:06:46 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* The area data is already set, so we can do the next things
|
|
|
|
*/
|
|
|
|
if (MsgBase.Total == 0) {
|
2004-11-03 20:48:45 +00:00
|
|
|
Enter(1);
|
2003-02-20 21:06:46 +00:00
|
|
|
/* There are no messages in this area */
|
2004-11-03 20:48:45 +00:00
|
|
|
pout(WHITE, BLACK, (char *) Language(205));
|
|
|
|
Enter(2);
|
2003-02-20 21:06:46 +00:00
|
|
|
sleep(3);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
temp = calloc(81, sizeof(char));
|
|
|
|
Enter(1);
|
2003-02-20 21:06:46 +00:00
|
|
|
/* Message area \"%s\" contains %lu messages. */
|
2005-08-29 11:15:54 +00:00
|
|
|
snprintf(temp, 81, "%s\"%s\" %s%lu %s", (char *) Language(221), sMsgAreaDesc,
|
2003-02-20 21:06:46 +00:00
|
|
|
(char *) Language(222), MsgBase.Total, (char *) Language(223));
|
2004-11-03 20:48:45 +00:00
|
|
|
pout(CFG.TextColourF, CFG.TextColourB, temp);
|
2003-02-20 21:06:46 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
Enter(1);
|
2003-02-20 21:06:46 +00:00
|
|
|
/* Please enter a message between */
|
2005-08-29 11:15:54 +00:00
|
|
|
snprintf(temp, 81, "%s(%lu - %lu): ", (char *) Language(224), MsgBase.Lowest, MsgBase.Highest);
|
2004-11-03 20:48:45 +00:00
|
|
|
pout(WHITE, BLACK, temp);
|
2003-02-20 21:06:46 +00:00
|
|
|
|
|
|
|
colour(CFG.InputColourF, CFG.InputColourB);
|
|
|
|
GetstrC(temp, 10);
|
|
|
|
if ((strcmp(temp, "")) != 0)
|
|
|
|
Msgnum = atoi(temp);
|
|
|
|
free(temp);
|
|
|
|
|
|
|
|
if (!Msg_Open(sMsgAreaBase)) {
|
|
|
|
WriteError("Error open JAM base %s", sMsgAreaBase);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!Msg_ReadHeader(Msgnum)) {
|
2004-11-03 20:48:45 +00:00
|
|
|
Enter(1);
|
2003-02-20 21:06:46 +00:00
|
|
|
/* Message doesn't exist */
|
2004-11-03 20:48:45 +00:00
|
|
|
pout(WHITE, BLACK, (char *)Language(77));
|
|
|
|
Enter(2);
|
2003-02-20 21:06:46 +00:00
|
|
|
Msg_Close();
|
|
|
|
sleep(3);
|
2001-08-17 05:46:24 +00:00
|
|
|
return;
|
2003-02-20 21:06:46 +00:00
|
|
|
}
|
|
|
|
Msg_Close();
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Message does exist and a valid number is suplied, check and finally mark the message deleted.
|
|
|
|
*/
|
|
|
|
if ((msgs.UsrDelete && IsMe(Msg.From)) || (exitinfo.Security.level >= CFG.sysop_access) ||
|
|
|
|
Access(exitinfo.Security, msgs.SYSec)) {
|
|
|
|
Delete_MsgNum(Msgnum);
|
|
|
|
} else {
|
2004-11-03 20:48:45 +00:00
|
|
|
Enter(1);
|
|
|
|
pout(LIGHTRED, BLACK, (char *)Language(14));
|
|
|
|
Enter(2);
|
2003-02-20 21:06:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
sleep(3);
|
|
|
|
return;
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Check linecounter for reading messages.
|
|
|
|
*/
|
2005-01-14 19:52:12 +00:00
|
|
|
int CheckLine(int FG, int BG, int Email, int Conv)
|
2001-08-17 05:46:24 +00:00
|
|
|
{
|
2004-11-03 20:48:45 +00:00
|
|
|
int x, z;
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
x = strlen(Language(61));
|
|
|
|
iLineCount++;
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
if ((iLineCount >= (exitinfo.iScreenLen -1)) && (iLineCount < 1000)) {
|
|
|
|
iLineCount = 7;
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
DoNop();
|
|
|
|
pout(CFG.MoreF, CFG.MoreB, (char *) Language(61));
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
alarm_on();
|
|
|
|
z = tolower(Readkey());
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
Blanker(x);
|
|
|
|
|
|
|
|
switch(z) {
|
|
|
|
case 'n': Enter(1);
|
2001-08-17 05:46:24 +00:00
|
|
|
return TRUE;
|
|
|
|
break;
|
2004-11-03 20:48:45 +00:00
|
|
|
case '=': iLineCount = 1000;
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
2004-11-03 20:48:45 +00:00
|
|
|
if (Email)
|
|
|
|
ShowEmailHdr();
|
|
|
|
else
|
2005-01-14 19:52:12 +00:00
|
|
|
ShowMsgHdr(Conv);
|
2004-11-03 20:48:45 +00:00
|
|
|
colour(FG, BG);
|
|
|
|
}
|
|
|
|
return FALSE;
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Select message area from the list.
|
|
|
|
*/
|
|
|
|
void MsgArea_List(char *Option)
|
|
|
|
{
|
2003-02-18 19:58:52 +00:00
|
|
|
FILE *pAreas;
|
|
|
|
int iAreaCount = 6, Recno = 0, iOldArea = 0, iAreaNum = 0, loopcount = 0;
|
|
|
|
int iGotArea = FALSE; /* Flag to check if user typed in area */
|
|
|
|
int iCheckNew = FALSE; /* Flag to check for new mail in area */
|
|
|
|
long offset;
|
2004-11-03 20:48:45 +00:00
|
|
|
char *temp, msg[81];
|
2003-02-18 19:58:52 +00:00
|
|
|
lastread LR;
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-02-18 19:58:52 +00:00
|
|
|
temp = calloc(PATH_MAX, sizeof(char));
|
2005-08-29 11:15:54 +00:00
|
|
|
snprintf(temp, PATH_MAX, "%s/etc/mareas.data", getenv("MBSE_ROOT"));
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-02-18 19:58:52 +00:00
|
|
|
/*
|
|
|
|
* Save old area, incase he picks a invalid area
|
|
|
|
*/
|
|
|
|
iOldArea = iMsgAreaNumber;
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-02-18 19:58:52 +00:00
|
|
|
if ((pAreas = fopen(temp, "rb")) == NULL) {
|
|
|
|
WriteError("$Can't open %s", temp);
|
|
|
|
free(temp);
|
|
|
|
return;
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-02-18 19:58:52 +00:00
|
|
|
/*
|
|
|
|
* Count how many records there are
|
|
|
|
*/
|
|
|
|
fread(&msgshdr, sizeof(msgshdr), 1, pAreas);
|
|
|
|
fseek(pAreas, 0, SEEK_END);
|
|
|
|
iAreaNum = (ftell(pAreas) - msgshdr.hdrsize) / (msgshdr.recsize + msgshdr.syssize);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-02-18 19:58:52 +00:00
|
|
|
/*
|
|
|
|
* If there are menu options, parse them first
|
|
|
|
* 1. Check for New Messages in Area (only option that will continue to display list)
|
|
|
|
* 2. Increment Area, return
|
|
|
|
* 3. Decrement Area, return
|
|
|
|
* 4. Select area direct (via area number), return
|
|
|
|
*/
|
|
|
|
if (strlen(Option) != 0) {
|
|
|
|
if (strcmp(Option, "N") == 0) {
|
|
|
|
iCheckNew = TRUE;
|
|
|
|
} else {
|
|
|
|
if (strcmp(Option, "U+") == 0) {
|
|
|
|
while(TRUE) {
|
|
|
|
iMsgAreaNumber++;
|
|
|
|
if (iMsgAreaNumber >= iAreaNum) {
|
|
|
|
iMsgAreaNumber = 0;
|
|
|
|
loopcount++;
|
|
|
|
if (loopcount > 1) {
|
|
|
|
/* No more areas with unread messages */
|
|
|
|
pout(LIGHTRED, BLACK, (char *) Language(479));
|
|
|
|
iMsgAreaNumber = iOldArea;
|
|
|
|
Enter(2);
|
|
|
|
Pause();
|
|
|
|
free(temp);
|
|
|
|
fclose(pAreas);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2002-12-13 05:43:33 +00:00
|
|
|
|
2003-02-18 19:58:52 +00:00
|
|
|
offset = msgshdr.hdrsize + (iMsgAreaNumber * (msgshdr.recsize + msgshdr.syssize));
|
|
|
|
if (fseek(pAreas, offset, 0) != 0) {
|
|
|
|
WriteError("$Can't move pointer in %s", temp);
|
|
|
|
}
|
2002-12-13 05:43:33 +00:00
|
|
|
|
2003-02-18 19:58:52 +00:00
|
|
|
fread(&msgs, msgshdr.recsize, 1, pAreas);
|
|
|
|
if ((Access(exitinfo.Security, msgs.RDSec)) && (msgs.Active) && (strlen(msgs.Password) == 0)) {
|
|
|
|
if (Msg_Open(msgs.Base)) {
|
|
|
|
MsgBase.Highest = Msg_Highest();
|
|
|
|
LR.UserID = grecno;
|
|
|
|
if (Msg_GetLastRead(&LR) != TRUE) {
|
|
|
|
LR.HighReadMsg = 0;
|
|
|
|
}
|
|
|
|
if (MsgBase.Highest > LR.HighReadMsg) {
|
|
|
|
Msg_Close();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
Msg_Close();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2002-12-13 05:43:33 +00:00
|
|
|
|
2003-02-18 19:58:52 +00:00
|
|
|
if (strcmp(Option, "U-") == 0) {
|
|
|
|
while(TRUE) {
|
|
|
|
iMsgAreaNumber--;
|
|
|
|
if (iMsgAreaNumber < 0) {
|
|
|
|
iMsgAreaNumber = iAreaNum - 1;
|
|
|
|
loopcount++;
|
|
|
|
if (loopcount > 1) {
|
|
|
|
/* No more areas with unread messages */
|
|
|
|
pout(LIGHTRED, BLACK, (char *) Language(479));
|
|
|
|
iMsgAreaNumber = iOldArea;
|
|
|
|
Enter(2);
|
|
|
|
Pause();
|
|
|
|
fclose(pAreas);
|
|
|
|
free(temp);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2002-12-13 05:43:33 +00:00
|
|
|
|
2003-02-18 19:58:52 +00:00
|
|
|
offset = msgshdr.hdrsize + (iMsgAreaNumber * (msgshdr.recsize + msgshdr.syssize));
|
|
|
|
if (fseek(pAreas, offset, 0) != 0) {
|
|
|
|
WriteError("$Can't move pointer in %s", temp);
|
|
|
|
}
|
2002-12-13 05:43:33 +00:00
|
|
|
|
2003-02-18 19:58:52 +00:00
|
|
|
fread(&msgs, msgshdr.recsize, 1, pAreas);
|
|
|
|
if ((Access(exitinfo.Security, msgs.RDSec)) && (msgs.Active) && (strlen(msgs.Password) == 0)) {
|
|
|
|
if (Msg_Open(msgs.Base)) {
|
|
|
|
MsgBase.Highest = Msg_Highest();
|
|
|
|
LR.UserID = grecno;
|
|
|
|
if (Msg_GetLastRead(&LR) != TRUE ){
|
|
|
|
LR.HighReadMsg = 0;
|
|
|
|
}
|
|
|
|
if (MsgBase.Highest > LR.HighReadMsg) {
|
|
|
|
Msg_Close();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
Msg_Close();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (strcmp(Option, "M+") == 0) {
|
|
|
|
while (TRUE) {
|
|
|
|
iMsgAreaNumber++;
|
|
|
|
if (iMsgAreaNumber >= iAreaNum) {
|
|
|
|
iMsgAreaNumber = 0;
|
|
|
|
}
|
|
|
|
offset = msgshdr.hdrsize + (iMsgAreaNumber * (msgshdr.recsize + msgshdr.syssize));
|
|
|
|
if(fseek(pAreas, offset, 0) != 0) {
|
|
|
|
WriteError("$Can't move pointer in %s", temp);
|
|
|
|
}
|
2002-12-12 05:05:02 +00:00
|
|
|
|
2003-02-18 19:58:52 +00:00
|
|
|
fread(&msgs, msgshdr.recsize, 1, pAreas);
|
|
|
|
if ((Access(exitinfo.Security, msgs.RDSec)) && (msgs.Active) && (strlen(msgs.Password) == 0)) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (strcmp(Option, "M-") == 0) {
|
|
|
|
while (TRUE) {
|
|
|
|
iMsgAreaNumber--;
|
|
|
|
if (iMsgAreaNumber < 0) {
|
|
|
|
iMsgAreaNumber = iAreaNum -1;
|
|
|
|
}
|
|
|
|
offset = msgshdr.hdrsize + (iMsgAreaNumber * (msgshdr.recsize + msgshdr.syssize));
|
|
|
|
if (fseek(pAreas, offset, 0) != 0) {
|
|
|
|
WriteError("$Can't move pointer in %s", temp);
|
|
|
|
}
|
2002-12-12 05:05:02 +00:00
|
|
|
|
2003-02-18 19:58:52 +00:00
|
|
|
fread(&msgs, msgshdr.recsize, 1, pAreas);
|
|
|
|
if ((Access(exitinfo.Security, msgs.RDSec)) && (msgs.Active) && (strlen(msgs.Password) == 0)) {
|
|
|
|
break;
|
|
|
|
}
|
2002-12-12 05:05:02 +00:00
|
|
|
}
|
2003-02-18 19:58:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
SetMsgArea(iMsgAreaNumber);
|
|
|
|
Syslog('+', "Msg area %lu %s", iMsgAreaNumber, sMsgAreaDesc);
|
|
|
|
free(temp);
|
|
|
|
fclose(pAreas);
|
|
|
|
return;
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
2003-02-18 19:58:52 +00:00
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-02-18 19:58:52 +00:00
|
|
|
clear();
|
|
|
|
Enter(1);
|
|
|
|
/* Message Areas */
|
|
|
|
pout(CFG.HiliteF, CFG.HiliteB, (char *) Language(231));
|
|
|
|
Enter(2);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-02-18 19:58:52 +00:00
|
|
|
fseek(pAreas, msgshdr.hdrsize, 0);
|
|
|
|
|
|
|
|
while (fread(&msgs, msgshdr.recsize, 1, pAreas) == 1) {
|
|
|
|
/*
|
|
|
|
* Skip the echomail systems
|
|
|
|
*/
|
|
|
|
fseek(pAreas, msgshdr.syssize, SEEK_CUR);
|
|
|
|
if ((Access(exitinfo.Security, msgs.RDSec)) && (msgs.Active)) {
|
|
|
|
msgs.Name[31] = '\0';
|
|
|
|
|
2005-08-29 11:15:54 +00:00
|
|
|
snprintf(msg, 81, "%5d", Recno + 1);
|
2004-11-03 20:48:45 +00:00
|
|
|
pout(WHITE, BLACK, msg);
|
2003-02-18 19:58:52 +00:00
|
|
|
|
|
|
|
colour(LIGHTBLUE, BLACK);
|
|
|
|
/* Check for New Mail if N was put on option data */
|
|
|
|
if (iCheckNew) {
|
|
|
|
if (Msg_Open(msgs.Base)) {
|
|
|
|
MsgBase.Highest = Msg_Highest();
|
|
|
|
LR.UserID = grecno;
|
|
|
|
if (Msg_GetLastRead(&LR) != TRUE) {
|
|
|
|
LR.HighReadMsg = 0;
|
|
|
|
}
|
|
|
|
if (MsgBase.Highest > LR.HighReadMsg ) {
|
|
|
|
pout(YELLOW, BLACK, (char *)" * ");
|
|
|
|
} else {
|
2004-11-03 20:48:45 +00:00
|
|
|
PUTSTR((char *)" . ");
|
2003-02-18 19:58:52 +00:00
|
|
|
}
|
|
|
|
Msg_Close();
|
|
|
|
} else {
|
2004-11-03 20:48:45 +00:00
|
|
|
PUTSTR((char *)" . ");
|
2003-02-18 19:58:52 +00:00
|
|
|
}
|
|
|
|
} else {
|
2004-11-03 20:48:45 +00:00
|
|
|
PUTSTR((char *)" . ");
|
2003-02-18 19:58:52 +00:00
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2005-08-29 11:15:54 +00:00
|
|
|
snprintf(msg, 81, "%-31s", msgs.Name);
|
2004-11-03 20:48:45 +00:00
|
|
|
pout(CYAN, BLACK, msg);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-02-18 19:58:52 +00:00
|
|
|
iAreaCount++;
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-02-18 19:58:52 +00:00
|
|
|
if ((iAreaCount % 2) == 0)
|
2004-11-03 20:48:45 +00:00
|
|
|
Enter(1);
|
2003-02-18 19:58:52 +00:00
|
|
|
else
|
2004-11-03 20:48:45 +00:00
|
|
|
PUTCHAR(' ');
|
2003-02-18 19:58:52 +00:00
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-02-18 19:58:52 +00:00
|
|
|
Recno++;
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-02-18 19:58:52 +00:00
|
|
|
if ((iAreaCount / 2) == exitinfo.iScreenLen) {
|
|
|
|
/* More (Y/n/=/Area #): */
|
|
|
|
pout(CFG.MoreF, CFG.MoreB, (char *) Language(207));
|
|
|
|
/*
|
|
|
|
* Ask user for Area or enter to continue
|
|
|
|
*/
|
|
|
|
colour(CFG.InputColourF, CFG.InputColourB);
|
|
|
|
GetstrC(temp, 7);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-02-18 19:58:52 +00:00
|
|
|
if (toupper(temp[0]) == Keystroke(207, 1))
|
|
|
|
break;
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-02-18 19:58:52 +00:00
|
|
|
if ((strcmp(temp, "")) != 0) {
|
|
|
|
iGotArea = TRUE;
|
|
|
|
break;
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-02-18 19:58:52 +00:00
|
|
|
iAreaCount = 2;
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
2003-02-18 19:58:52 +00:00
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-02-18 19:58:52 +00:00
|
|
|
/*
|
|
|
|
* If user type in area above during area listing
|
|
|
|
* don't ask for it again
|
|
|
|
*/
|
|
|
|
if (!iGotArea) {
|
|
|
|
Enter(1);
|
|
|
|
/* Select Area: */
|
|
|
|
pout(CFG.HiliteF, CFG.HiliteB, (char *) Language(232));
|
|
|
|
colour(CFG.InputColourF, CFG.InputColourB);
|
|
|
|
GetstrC(temp, 80);
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-02-18 19:58:52 +00:00
|
|
|
/*
|
|
|
|
* Check if user pressed ENTER
|
|
|
|
*/
|
|
|
|
if ((strcmp(temp, "")) == 0) {
|
|
|
|
fclose(pAreas);
|
|
|
|
free(temp);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
iMsgAreaNumber = atoi(temp);
|
|
|
|
iMsgAreaNumber--;
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-02-18 19:58:52 +00:00
|
|
|
/*
|
|
|
|
* Do a check in case user presses Zero
|
|
|
|
*/
|
|
|
|
if (iMsgAreaNumber == -1)
|
|
|
|
iMsgAreaNumber = 0;
|
|
|
|
|
|
|
|
offset = msgshdr.hdrsize + (iMsgAreaNumber * (msgshdr.recsize + msgshdr.syssize));
|
|
|
|
if (fseek(pAreas, offset, 0) != 0) {
|
|
|
|
WriteError("$Can't move pointer in mareas.data.");
|
|
|
|
}
|
|
|
|
fread(&msgs, msgshdr.recsize, 1, pAreas);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-02-18 19:58:52 +00:00
|
|
|
/*
|
|
|
|
* Do a check if area is greater or less number than allowed,
|
|
|
|
* security acces (level, flags and age) is oke, and the area
|
|
|
|
* is active.
|
|
|
|
*/
|
|
|
|
if (iMsgAreaNumber > iAreaNum || iMsgAreaNumber < 0 || (Access(exitinfo.Security, msgs.RDSec) == FALSE) || (!msgs.Active)) {
|
|
|
|
Enter(1);
|
2001-08-17 05:46:24 +00:00
|
|
|
/*
|
2003-02-18 19:58:52 +00:00
|
|
|
* Invalid area specified - Please try again ...
|
2001-08-17 05:46:24 +00:00
|
|
|
*/
|
2003-02-18 19:58:52 +00:00
|
|
|
pout(LIGHTRED, BLACK, (char *) Language(233));
|
|
|
|
Enter(2);
|
|
|
|
Pause();
|
|
|
|
fclose(pAreas);
|
|
|
|
iMsgAreaNumber = iOldArea;
|
2001-08-17 05:46:24 +00:00
|
|
|
SetMsgArea(iMsgAreaNumber);
|
2003-02-18 19:58:52 +00:00
|
|
|
free(temp);
|
|
|
|
return;
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-02-18 19:58:52 +00:00
|
|
|
SetMsgArea(iMsgAreaNumber);
|
|
|
|
Syslog('+', "Msg area %lu %s", iMsgAreaNumber, sMsgAreaDesc);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-02-18 19:58:52 +00:00
|
|
|
/*
|
|
|
|
* Check if msg area has a password, if it does ask user for it
|
|
|
|
*/
|
|
|
|
if ((strlen(msgs.Password)) > 2) {
|
|
|
|
Enter(2);
|
|
|
|
/* Please enter Area Password: */
|
|
|
|
pout(WHITE, BLACK, (char *) Language(233));
|
|
|
|
colour(CFG.InputColourF, CFG.InputColourB);
|
|
|
|
GetstrC(temp, 20);
|
|
|
|
|
|
|
|
if ((strcmp(temp, msgs.Password)) != 0) {
|
|
|
|
Enter(1);
|
|
|
|
/* Password is incorrect */
|
|
|
|
pout(WHITE, BLACK, (char *) Language(234));
|
|
|
|
Syslog('!', "Incorrect Message Area # %d password given: %s", iMsgAreaNumber, temp);
|
|
|
|
SetMsgArea(iOldArea);
|
|
|
|
} else {
|
|
|
|
Enter(1);
|
|
|
|
/* Password is correct */
|
|
|
|
pout(WHITE, BLACK, (char *) Language(235));
|
|
|
|
Enter(2);
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
2003-02-18 19:58:52 +00:00
|
|
|
Pause();
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-02-18 19:58:52 +00:00
|
|
|
free(temp);
|
|
|
|
fclose(pAreas);
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Delete_MsgNum(unsigned long MsgNum)
|
|
|
|
{
|
2003-02-20 21:06:46 +00:00
|
|
|
int Result = FALSE;
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-02-20 21:06:46 +00:00
|
|
|
/* Deleting message */
|
|
|
|
pout(LIGHTRED, BLACK, (char *) Language(230));
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-02-20 21:06:46 +00:00
|
|
|
if (Msg_Open(sMsgAreaBase)) {
|
|
|
|
if (Msg_Lock(15L)) {
|
|
|
|
Result = Msg_Delete(MsgNum);
|
|
|
|
Msg_UnLock();
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
2003-02-20 21:06:46 +00:00
|
|
|
Msg_Close();
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-02-20 21:06:46 +00:00
|
|
|
if (Result)
|
|
|
|
Syslog('+', "Deleted msg #%lu in Area #%d (%s)", MsgNum, iMsgAreaNumber, sMsgAreaDesc);
|
|
|
|
else
|
|
|
|
WriteError("ERROR delete msg #%lu in Area #%d (%s)", MsgNum, iMsgAreaNumber, sMsgAreaDesc);
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This Function checks to see if the user exists in the user database
|
|
|
|
* and returns a int TRUE or FALSE
|
|
|
|
*/
|
|
|
|
int CheckUser(char *To)
|
|
|
|
{
|
2004-11-03 20:48:45 +00:00
|
|
|
FILE *pUsrConfig;
|
|
|
|
int Found = FALSE;
|
|
|
|
char *temp;
|
|
|
|
long offset;
|
|
|
|
unsigned long Crc;
|
|
|
|
|
|
|
|
temp = calloc(PATH_MAX, sizeof(char));
|
2005-08-29 11:15:54 +00:00
|
|
|
snprintf(temp, PATH_MAX, "%s/etc/users.data", getenv("MBSE_ROOT"));
|
2004-11-03 20:48:45 +00:00
|
|
|
if ((pUsrConfig = fopen(temp,"rb")) == NULL) {
|
|
|
|
WriteError("$Can't open file %s for reading", temp);
|
|
|
|
Pause();
|
2001-08-17 05:46:24 +00:00
|
|
|
free(temp);
|
2004-11-03 20:48:45 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
free(temp);
|
|
|
|
fread(&usrconfighdr, sizeof(usrconfighdr), 1, pUsrConfig);
|
|
|
|
Crc = StringCRC32(tl(To));
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
while (fread(&usrconfig, usrconfighdr.recsize, 1, pUsrConfig) == 1) {
|
|
|
|
if (StringCRC32(tl(usrconfig.sUserName)) == Crc) {
|
|
|
|
Found = TRUE;
|
|
|
|
break;
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
2004-11-03 20:48:45 +00:00
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
if (!Found)
|
|
|
|
Syslog('!', "User attempted to mail unknown user: %s", tlcap(To));
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
/*
|
|
|
|
* Restore users record
|
|
|
|
*/
|
|
|
|
offset = usrconfighdr.hdrsize + (grecno * usrconfighdr.recsize);
|
|
|
|
if (fseek(pUsrConfig, offset, 0) != 0)
|
|
|
|
WriteError("$Can't move pointer there.");
|
|
|
|
else
|
|
|
|
fread(&usrconfig, usrconfighdr.recsize, 1, pUsrConfig);
|
|
|
|
fclose(pUsrConfig);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
return Found;
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Check for new mail
|
|
|
|
*/
|
|
|
|
void CheckMail()
|
|
|
|
{
|
2003-03-19 22:45:46 +00:00
|
|
|
FILE *pMsgArea, *Tmp;
|
|
|
|
int x, Found = 0, Color, Count = 0, Reading, OldMsgArea;
|
2004-11-03 20:48:45 +00:00
|
|
|
char *temp, *sFileName, msg[81];
|
2003-03-19 22:45:46 +00:00
|
|
|
unsigned long i, Start;
|
|
|
|
typedef struct _Mailrec {
|
|
|
|
long Area;
|
|
|
|
unsigned long Msg;
|
|
|
|
} _Mail;
|
|
|
|
_Mail Mail;
|
|
|
|
lastread LR;
|
|
|
|
|
|
|
|
OldMsgArea = iMsgAreaNumber;
|
|
|
|
iMsgAreaNumber = 0;
|
|
|
|
Syslog('+', "Start checking for new mail");
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-03-19 22:45:46 +00:00
|
|
|
clear();
|
|
|
|
/* Checking your mail box ... */
|
|
|
|
language(LIGHTGREEN, BLACK, 150);
|
|
|
|
Enter(2);
|
|
|
|
Color = LIGHTBLUE;
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-03-19 22:45:46 +00:00
|
|
|
/*
|
|
|
|
* Open temporary file
|
|
|
|
*/
|
|
|
|
if ((Tmp = tmpfile()) == NULL) {
|
|
|
|
WriteError("$unable to open temporary file");
|
|
|
|
return;
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-03-19 22:45:46 +00:00
|
|
|
/*
|
|
|
|
* First check the e-mail mailbox
|
|
|
|
*/
|
|
|
|
temp = calloc(PATH_MAX, sizeof(char));
|
|
|
|
if (exitinfo.Email && strlen(exitinfo.Password)) {
|
|
|
|
check_popmail(exitinfo.Name, exitinfo.Password);
|
|
|
|
colour(Color++, BLACK);
|
2004-11-03 20:48:45 +00:00
|
|
|
PUTCHAR('\r');
|
|
|
|
PUTSTR((char *)"e-mail Private e-mail mailbox");
|
2003-03-19 22:45:46 +00:00
|
|
|
Count = 0;
|
2005-08-29 11:15:54 +00:00
|
|
|
snprintf(temp, PATH_MAX, "%s/%s/mailbox", CFG.bbs_usersdir, exitinfo.Name);
|
2003-03-19 22:45:46 +00:00
|
|
|
SetEmailArea((char *)"mailbox");
|
|
|
|
if (Msg_Open(temp)) {
|
|
|
|
/*
|
|
|
|
* Check lastread pointer, if none found start
|
|
|
|
* at the begin of the messagebase.
|
|
|
|
*/
|
|
|
|
LR.UserID = grecno;
|
|
|
|
if (Msg_GetLastRead(&LR))
|
|
|
|
Start = LR.HighReadMsg + 1;
|
|
|
|
else
|
|
|
|
Start = EmailBase.Lowest;
|
|
|
|
|
|
|
|
for (i = Start; i <= EmailBase.Highest; i++) {
|
|
|
|
if (Msg_ReadHeader(i)) {
|
|
|
|
/*
|
|
|
|
* Only check the received status of the email. The mail
|
|
|
|
* may not be direct addressed to this user (aliases database)
|
|
|
|
* but if it is in his mailbox it is always for the user.
|
2004-11-03 20:48:45 +00:00
|
|
|
* FIXME: mail written by the user is shown as new too.
|
2003-03-19 22:45:46 +00:00
|
|
|
*/
|
|
|
|
if (!Msg.Received) {
|
2001-08-17 05:46:24 +00:00
|
|
|
/*
|
2003-03-19 22:45:46 +00:00
|
|
|
* Store area and message number in temporary file.
|
2001-08-17 05:46:24 +00:00
|
|
|
*/
|
2003-03-19 22:45:46 +00:00
|
|
|
Mail.Area = -1; /* Means e-mail mailbox */
|
|
|
|
Mail.Msg = Msg.Id + EmailBase.Lowest -1;
|
|
|
|
fwrite(&Mail, sizeof(Mail), 1, Tmp);
|
|
|
|
Count++;
|
|
|
|
Found++;
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
2003-03-19 22:45:46 +00:00
|
|
|
}
|
|
|
|
Msg_Close();
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
2003-03-19 22:45:46 +00:00
|
|
|
if (Count) {
|
2004-11-03 20:48:45 +00:00
|
|
|
Enter(2);
|
2003-03-19 22:45:46 +00:00
|
|
|
/* messages in */
|
2005-08-29 11:15:54 +00:00
|
|
|
snprintf(temp, 81, "%d %s private e-mail mailbox", Count, (char *)Language(213));
|
2004-11-03 20:48:45 +00:00
|
|
|
pout(CFG.TextColourF, CFG.TextColourB, temp);
|
|
|
|
Enter(2);
|
2003-03-19 22:45:46 +00:00
|
|
|
Syslog('m', " %d messages in private e-mail mailbox", Count);
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
2003-03-19 22:45:46 +00:00
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-03-19 22:45:46 +00:00
|
|
|
/*
|
|
|
|
* Open the message base configuration
|
|
|
|
*/
|
|
|
|
sFileName = calloc(PATH_MAX, sizeof(char));
|
2005-08-29 11:15:54 +00:00
|
|
|
snprintf(sFileName, PATH_MAX, "%s/etc/mareas.data", getenv("MBSE_ROOT"));
|
2003-03-19 22:45:46 +00:00
|
|
|
if((pMsgArea = fopen(sFileName, "r+")) == NULL) {
|
|
|
|
WriteError("$Can't open: %s", sFileName);
|
|
|
|
free(temp);
|
|
|
|
free(sFileName);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
fread(&msgshdr, sizeof(msgshdr), 1, pMsgArea);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Check all normal areas one by one
|
|
|
|
*/
|
|
|
|
while (fread(&msgs, msgshdr.recsize, 1, pMsgArea) == 1) {
|
|
|
|
fseek(pMsgArea, msgshdr.syssize, SEEK_CUR);
|
|
|
|
if ((msgs.Active) && (exitinfo.Security.level >= msgs.RDSec.level)) {
|
|
|
|
SetMsgArea(iMsgAreaNumber);
|
2005-08-29 11:15:54 +00:00
|
|
|
snprintf(temp, 81, "%d", iMsgAreaNumber + 1);
|
2003-03-19 22:45:46 +00:00
|
|
|
if (Color < WHITE)
|
|
|
|
Color++;
|
|
|
|
else
|
|
|
|
Color = LIGHTBLUE;
|
2004-11-03 20:48:45 +00:00
|
|
|
PUTCHAR('\r');
|
2005-08-29 11:15:54 +00:00
|
|
|
snprintf(msg, 81, "%6s %-40s", temp, sMsgAreaDesc);
|
2004-11-03 20:48:45 +00:00
|
|
|
pout(Color, BLACK, msg);
|
2003-03-19 22:45:46 +00:00
|
|
|
Count = 0;
|
|
|
|
/*
|
|
|
|
* Refresh timers
|
|
|
|
*/
|
|
|
|
Nopper();
|
|
|
|
alarm_on();
|
|
|
|
|
|
|
|
if (Msg_Open(sMsgAreaBase)) {
|
|
|
|
/*
|
|
|
|
* Check lastread pointer, if none found start
|
|
|
|
* at the begin of the messagebase.
|
|
|
|
*/
|
|
|
|
LR.UserID = grecno;
|
|
|
|
if (Msg_GetLastRead(&LR))
|
|
|
|
Start = LR.HighReadMsg + 1;
|
|
|
|
else
|
|
|
|
Start = MsgBase.Lowest;
|
|
|
|
|
|
|
|
for (i = Start; i <= MsgBase.Highest; i++) {
|
|
|
|
if (Msg_ReadHeader(i)) {
|
|
|
|
if ((!Msg.Received) && (IsMe(Msg.To))) {
|
|
|
|
/*
|
|
|
|
* Store area and message number
|
|
|
|
* in temporary file.
|
|
|
|
*/
|
|
|
|
Mail.Area = iMsgAreaNumber;
|
|
|
|
Mail.Msg = Msg.Id + MsgBase.Lowest -1;
|
|
|
|
fwrite(&Mail, sizeof(Mail), 1, Tmp);
|
|
|
|
Count++;
|
|
|
|
Found++;
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
2003-03-19 22:45:46 +00:00
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
2003-03-19 22:45:46 +00:00
|
|
|
Msg_Close();
|
|
|
|
}
|
|
|
|
if (Count) {
|
2004-11-03 20:48:45 +00:00
|
|
|
Enter(2);
|
2003-03-19 22:45:46 +00:00
|
|
|
/* messages in */
|
2005-08-29 11:15:54 +00:00
|
|
|
snprintf(msg, 81, "%d %s %s", Count, (char *)Language(213), sMsgAreaDesc);
|
2004-11-03 20:48:45 +00:00
|
|
|
pout(CFG.TextColourF, CFG.TextColourB, msg);
|
|
|
|
Enter(2);
|
2003-03-19 22:45:46 +00:00
|
|
|
Syslog('m', " %d messages in %s", Count, sMsgAreaDesc);
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
2003-03-19 22:45:46 +00:00
|
|
|
iMsgAreaNumber++;
|
|
|
|
}
|
|
|
|
|
|
|
|
fclose(pMsgArea);
|
2004-11-03 20:48:45 +00:00
|
|
|
PUTCHAR('\r');
|
2003-03-19 22:45:46 +00:00
|
|
|
for (i = 0; i < 48; i++)
|
2004-11-03 20:48:45 +00:00
|
|
|
PUTCHAR(' ');
|
|
|
|
PUTCHAR('\r');
|
2003-03-19 22:45:46 +00:00
|
|
|
|
|
|
|
if (Found) {
|
2004-11-03 20:48:45 +00:00
|
|
|
Enter(1);
|
2003-03-19 22:45:46 +00:00
|
|
|
/* You have messages, read your mail now? [Y/n]: */
|
2005-08-29 11:15:54 +00:00
|
|
|
snprintf(msg, 81, "%s%d %s", (char *) Language(142), Found, (char *) Language(143));
|
2004-11-03 20:48:45 +00:00
|
|
|
pout(YELLOW, BLACK, msg);
|
2003-03-19 22:45:46 +00:00
|
|
|
colour(CFG.InputColourF, CFG.InputColourB);
|
|
|
|
alarm_on();
|
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
if (toupper(Readkey()) != Keystroke(143,1)) {
|
2003-03-19 22:45:46 +00:00
|
|
|
rewind(Tmp);
|
|
|
|
Reading = TRUE;
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-03-19 22:45:46 +00:00
|
|
|
while ((Reading) && (fread(&Mail, sizeof(Mail), 1, Tmp) == 1)) {
|
|
|
|
if (Mail.Area == -1) {
|
|
|
|
/*
|
|
|
|
* Private e-mail
|
|
|
|
*/
|
|
|
|
Read_a_Email(Mail.Msg);
|
|
|
|
} else {
|
|
|
|
SetMsgArea(Mail.Area);
|
|
|
|
Read_a_Msg(Mail.Msg, FALSE);
|
|
|
|
}
|
|
|
|
/* (R)eply, (N)ext, (Q)uit */
|
|
|
|
pout(CFG.CRColourF, CFG.CRColourB, (char *)Language(218));
|
2001-08-17 05:46:24 +00:00
|
|
|
alarm_on();
|
2004-11-03 20:48:45 +00:00
|
|
|
x = toupper(Readkey());
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-03-19 22:45:46 +00:00
|
|
|
if (x == Keystroke(218, 0)) {
|
|
|
|
Syslog('m', " Reply!");
|
|
|
|
if (Mail.Area == -1) {
|
|
|
|
Reply_Email(TRUE);
|
|
|
|
} else {
|
|
|
|
Reply_Msg(TRUE);
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
2003-03-19 22:45:46 +00:00
|
|
|
if (x == Keystroke(218, 2)) {
|
|
|
|
Syslog('m', " Quit check for new mail");
|
|
|
|
iMsgAreaNumber = OldMsgArea;
|
|
|
|
fclose(Tmp);
|
|
|
|
SetMsgArea(OldMsgArea);
|
2004-11-03 20:48:45 +00:00
|
|
|
Enter(2);
|
2003-03-19 22:45:46 +00:00
|
|
|
free(temp);
|
|
|
|
free(sFileName);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
language(LIGHTRED, BLACK, 144);
|
|
|
|
Enter(1);
|
|
|
|
sleep(3);
|
|
|
|
} /* if (Found) */
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-03-19 22:45:46 +00:00
|
|
|
iMsgAreaNumber = OldMsgArea;
|
|
|
|
fclose(Tmp);
|
|
|
|
SetMsgArea(OldMsgArea);
|
2004-11-03 20:48:45 +00:00
|
|
|
Enter(2);
|
2003-03-19 22:45:46 +00:00
|
|
|
free(temp);
|
|
|
|
free(sFileName);
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Status of all mail areas.
|
|
|
|
*/
|
|
|
|
void MailStatus()
|
|
|
|
{
|
2004-11-03 20:48:45 +00:00
|
|
|
FILE *pMsgArea;
|
|
|
|
int Count = 0;
|
|
|
|
int OldMsgArea;
|
|
|
|
char temp[81], msg[81];
|
|
|
|
char *sFileName;
|
|
|
|
unsigned long i;
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
sFileName = calloc(PATH_MAX, sizeof(char));
|
|
|
|
OldMsgArea = iMsgAreaNumber;
|
|
|
|
iMsgAreaNumber = 0;
|
|
|
|
clear();
|
|
|
|
/* Area Type Description Messages Personal */
|
2005-08-29 11:15:54 +00:00
|
|
|
snprintf(msg, 81, "%-79s", (char *)Language(226));
|
2004-11-03 20:48:45 +00:00
|
|
|
pout(YELLOW, BLUE, msg);
|
|
|
|
Enter(1);
|
|
|
|
iLineCount = 2;
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
if (exitinfo.Email) {
|
2005-08-29 11:15:54 +00:00
|
|
|
snprintf(temp, 81, "%s", sMailbox);
|
2004-11-03 20:48:45 +00:00
|
|
|
for (i = 0; i < 3; i++) {
|
|
|
|
switch (i) {
|
|
|
|
case 0: SetEmailArea((char *)"mailbox");
|
|
|
|
break;
|
|
|
|
case 1: SetEmailArea((char *)"archive");
|
|
|
|
break;
|
|
|
|
case 2: SetEmailArea((char *)"trash");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
pout(LIGHTRED, BLACK, (char *)" Email");
|
2005-08-29 11:15:54 +00:00
|
|
|
snprintf(msg, 81, " %-40s", Language(467 + i));
|
2004-11-03 20:48:45 +00:00
|
|
|
pout(LIGHTCYAN, BLACK, msg);
|
|
|
|
if (EmailBase.Highest)
|
2005-08-29 11:15:54 +00:00
|
|
|
snprintf(msg, 81, " %8lu", EmailBase.Highest - EmailBase.Lowest + 1);
|
2004-11-03 20:48:45 +00:00
|
|
|
else
|
2005-08-29 11:15:54 +00:00
|
|
|
snprintf(msg, 81, " 0");
|
2004-11-03 20:48:45 +00:00
|
|
|
pout(YELLOW, BLACK, msg);
|
|
|
|
if (EmailBase.Highest)
|
2005-08-29 11:15:54 +00:00
|
|
|
snprintf(msg, 81, " %8lu", EmailBase.Highest - EmailBase.Lowest + 1);
|
2004-11-03 20:48:45 +00:00
|
|
|
else
|
2005-08-29 11:15:54 +00:00
|
|
|
snprintf(msg, 81, " 0");
|
2004-11-03 20:48:45 +00:00
|
|
|
pout(LIGHTBLUE, BLACK, msg);
|
|
|
|
Enter(1);
|
|
|
|
}
|
|
|
|
iLineCount = 5;
|
|
|
|
SetEmailArea(temp);
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
/*
|
|
|
|
* Open the message base configuration
|
|
|
|
*/
|
2005-08-29 11:15:54 +00:00
|
|
|
snprintf(sFileName, PATH_MAX, "%s/etc/mareas.data", getenv("MBSE_ROOT"));
|
2004-11-03 20:48:45 +00:00
|
|
|
if((pMsgArea = fopen(sFileName, "r+")) == NULL) {
|
|
|
|
WriteError("Can't open file: %s", sFileName);
|
|
|
|
free(sFileName);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
fread(&msgshdr, sizeof(msgshdr), 1, pMsgArea);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
/*
|
|
|
|
* Check all areas one by one
|
|
|
|
*/
|
|
|
|
while (fread(&msgs, msgshdr.recsize, 1, pMsgArea) == 1) {
|
|
|
|
fseek(pMsgArea, msgshdr.syssize, SEEK_CUR);
|
|
|
|
if ((msgs.Active) && (exitinfo.Security.level >= msgs.RDSec.level)) {
|
|
|
|
SetMsgArea(iMsgAreaNumber);
|
2005-08-29 11:15:54 +00:00
|
|
|
snprintf(temp, 81, "%d", iMsgAreaNumber + 1);
|
|
|
|
snprintf(msg, 81, "%5s", temp);
|
2004-11-03 20:48:45 +00:00
|
|
|
pout(WHITE, BLACK, msg);
|
|
|
|
colour(LIGHTRED, BLACK);
|
|
|
|
switch(msgs.Type) {
|
|
|
|
case LOCALMAIL: PUTSTR((char *)" Local");
|
|
|
|
break;
|
|
|
|
case NETMAIL: PUTSTR((char *)" Net ");
|
|
|
|
break;
|
|
|
|
case LIST:
|
|
|
|
case ECHOMAIL: PUTSTR((char *)" Echo ");
|
|
|
|
break;
|
|
|
|
case NEWS: PUTSTR((char *)" News ");
|
2001-08-17 05:46:24 +00:00
|
|
|
break;
|
2004-11-03 20:48:45 +00:00
|
|
|
}
|
2005-08-29 11:15:54 +00:00
|
|
|
snprintf(msg, 81, " %-40s", sMsgAreaDesc);
|
2004-11-03 20:48:45 +00:00
|
|
|
pout(LIGHTCYAN, BLACK, msg);
|
|
|
|
Count = 0;
|
|
|
|
|
|
|
|
if (Msg_Open(sMsgAreaBase)) {
|
|
|
|
for (i = MsgBase.Lowest; i <= MsgBase.Highest; i++) {
|
|
|
|
if (Msg_ReadHeader(i)) {
|
|
|
|
if (IsMe(Msg.To) || IsMe(Msg.From))
|
|
|
|
Count++;
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
2004-11-03 20:48:45 +00:00
|
|
|
Msg_Close();
|
|
|
|
} else
|
|
|
|
WriteError("Error open JAM %s", sMsgAreaBase);
|
|
|
|
if (MsgBase.Highest)
|
2005-08-29 11:15:54 +00:00
|
|
|
snprintf(msg, 81, " %8lu", MsgBase.Highest - MsgBase.Lowest + 1);
|
2004-11-03 20:48:45 +00:00
|
|
|
else
|
2005-08-29 11:15:54 +00:00
|
|
|
snprintf(msg, 81, " 0");
|
2004-11-03 20:48:45 +00:00
|
|
|
pout(YELLOW, BLACK, msg);
|
2005-08-29 11:15:54 +00:00
|
|
|
snprintf(msg, 81, " %8d", Count);
|
2004-11-03 20:48:45 +00:00
|
|
|
pout(LIGHTBLUE, BLACK, msg);
|
|
|
|
Enter(1);
|
|
|
|
if (LC(1))
|
|
|
|
break;
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
2004-11-03 20:48:45 +00:00
|
|
|
iMsgAreaNumber++;
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
fclose(pMsgArea);
|
|
|
|
SetMsgArea(OldMsgArea);
|
|
|
|
free(sFileName);
|
|
|
|
Pause();
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set message area number, set global area description and JAM path
|
|
|
|
*/
|
|
|
|
void SetMsgArea(unsigned long AreaNum)
|
|
|
|
{
|
2004-11-03 20:48:45 +00:00
|
|
|
FILE *pMsgArea;
|
|
|
|
long offset;
|
|
|
|
char *sFileName;
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
sFileName = calloc(PATH_MAX, sizeof(char));
|
2005-08-29 11:15:54 +00:00
|
|
|
snprintf(sFileName, PATH_MAX, "%s/etc/mareas.data", getenv("MBSE_ROOT"));
|
2004-11-03 20:48:45 +00:00
|
|
|
memset(&msgs, 0, sizeof(msgs));
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
if ((pMsgArea = fopen(sFileName, "r")) == NULL) {
|
|
|
|
WriteError("$Can't open file: %s", sFileName);
|
|
|
|
free(sFileName);
|
|
|
|
return;
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
fread(&msgshdr, sizeof(msgshdr), 1, pMsgArea);
|
|
|
|
offset = msgshdr.hdrsize + (AreaNum * (msgshdr.recsize + msgshdr.syssize));
|
|
|
|
if (fseek(pMsgArea, offset, 0) != 0) {
|
|
|
|
WriteError("$Can't move pointer in %s",sFileName);
|
|
|
|
free(sFileName);
|
|
|
|
return;
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
fread(&msgs, msgshdr.recsize, 1, pMsgArea);
|
|
|
|
strcpy(sMsgAreaDesc, msgs.Name);
|
|
|
|
strcpy(sMsgAreaBase, msgs.Base);
|
|
|
|
iMsgAreaNumber = AreaNum;
|
|
|
|
iMsgAreaType = msgs.Type;
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
fclose(pMsgArea);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
/*
|
|
|
|
* Get information from the message base
|
|
|
|
*/
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
if (Msg_Open(sMsgAreaBase)) {
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2004-11-03 20:48:45 +00:00
|
|
|
MsgBase.Lowest = Msg_Lowest();
|
|
|
|
MsgBase.Highest = Msg_Highest();
|
|
|
|
MsgBase.Total = Msg_Number();
|
|
|
|
Msg_Close();
|
|
|
|
} else
|
|
|
|
WriteError("Error open JAM %s", sMsgAreaBase);
|
|
|
|
free(sFileName);
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-03-05 21:32:52 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* External Message Editor
|
|
|
|
*/
|
|
|
|
int Ext_Edit()
|
|
|
|
{
|
|
|
|
int changed;
|
|
|
|
int j, i;
|
|
|
|
char *l, *tmpname;
|
|
|
|
FILE *fd;
|
|
|
|
struct stat st1,st2;
|
|
|
|
|
|
|
|
changed=FALSE;
|
|
|
|
|
|
|
|
tmpname = calloc(PATH_MAX, sizeof(char));
|
|
|
|
|
2005-08-29 11:15:54 +00:00
|
|
|
snprintf(tmpname, PATH_MAX, "%s/%s/data.msg", CFG.bbs_usersdir, exitinfo.Name);
|
2002-03-05 21:32:52 +00:00
|
|
|
if ((fd = fopen(tmpname, "w")) == NULL) {
|
|
|
|
Syslog('+',"EXT_EDIT: Unable to open %s for writing", tmpname);
|
|
|
|
} else {
|
|
|
|
fprintf(fd,"AREA='%s'\n",sMsgAreaDesc);
|
|
|
|
fprintf(fd,"AREANUM='%d'\n",iMsgAreaNumber+1);
|
|
|
|
fprintf(fd,"AREATYPE='%d'\n",iMsgAreaType);
|
|
|
|
fprintf(fd,"MSGFROM='%s'\n",Msg.From);
|
2004-08-18 15:22:11 +00:00
|
|
|
fprintf(fd,"MSGFROMADDR='%s'\n",Msg.FromAddress);
|
2002-03-05 21:32:52 +00:00
|
|
|
fprintf(fd,"MSGTO='%s'\n",Msg.To);
|
|
|
|
fprintf(fd,"MSGTOADDR='%s'\n",Msg.ToAddress);
|
|
|
|
fprintf(fd,"MSGSUBJECT='%s'\n",Msg.Subject);
|
|
|
|
fprintf(fd,"BBSLANGUAGE='%c'\n",exitinfo.iLanguage);
|
|
|
|
fprintf(fd,"BBSFSEDKEYS='%d'\n",exitinfo.FSemacs);
|
|
|
|
fclose(fd);
|
|
|
|
}
|
|
|
|
|
2005-08-29 11:15:54 +00:00
|
|
|
snprintf(tmpname, PATH_MAX, "%s/%s/edit.msg", CFG.bbs_usersdir, exitinfo.Name);
|
2002-03-05 21:32:52 +00:00
|
|
|
if ((fd = fopen(tmpname, "w")) == NULL) {
|
|
|
|
Syslog('+',"EXT_EDIT: Unable to open %s for writing", tmpname);
|
|
|
|
} else {
|
|
|
|
for (i = 1; i <= Line; i++) {
|
|
|
|
fprintf(fd,"%s\n",Message[i]);
|
|
|
|
}
|
|
|
|
fclose(fd);
|
|
|
|
stat( tmpname, &st1 );
|
2003-10-11 21:22:16 +00:00
|
|
|
ExtDoor(CFG.externaleditor,FALSE,TRUE,TRUE,FALSE,TRUE, FALSE, (char *)"Write message");
|
2004-11-03 20:48:45 +00:00
|
|
|
if (rawport() != 0) {
|
|
|
|
WriteError("Unable to set raw mode");
|
|
|
|
}
|
2002-03-05 21:32:52 +00:00
|
|
|
stat( tmpname, &st2 );
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( st1.st_mtime != st2.st_mtime ) {
|
|
|
|
l = calloc(81, sizeof(char));
|
|
|
|
if ((fd = fopen(tmpname, "r")) == NULL) {
|
|
|
|
Syslog('+',"EXT_EDIT: Unable to open %s for reading", tmpname);
|
|
|
|
} else {
|
|
|
|
i=1;
|
|
|
|
while ( (fgets(l,80,fd) != NULL) && (i < TEXTBUFSIZE ) ) {
|
|
|
|
for (j = 0; i < strlen(l); j++) {
|
|
|
|
if (*(l + j) == '\0')
|
|
|
|
break;
|
|
|
|
if (*(l + j) == '\n')
|
|
|
|
*(l + j) = '\0';
|
|
|
|
if (*(l + j) == '\r')
|
|
|
|
*(l + j) = '\0';
|
|
|
|
/*
|
|
|
|
* Make sure that any tear or origin lines are
|
|
|
|
* made invalid.
|
|
|
|
*/
|
|
|
|
if (strncmp(l, (char *)"--- ", 4) == 0)
|
|
|
|
l[1] = 'v';
|
|
|
|
if (strncmp(l, (char *)" * Origin:", 10) == 0)
|
|
|
|
l[1] = '+';
|
|
|
|
}
|
2005-08-29 11:15:54 +00:00
|
|
|
snprintf(Message[i], TEXTBUFSIZE +1, "%s",l);
|
2002-03-05 21:32:52 +00:00
|
|
|
i++;
|
|
|
|
}
|
|
|
|
changed=TRUE;
|
|
|
|
Line=i;
|
|
|
|
fclose(fd);
|
|
|
|
}
|
|
|
|
free(l);
|
|
|
|
}
|
|
|
|
free(tmpname);
|
|
|
|
return changed;
|
|
|
|
}
|
|
|
|
|
|
|
|
|