Fixes for mbnntp
This commit is contained in:
parent
4aacf882e6
commit
884cb156ad
@ -6,6 +6,9 @@ v0.51.4 11-Apr-2004
|
||||
Start mbsetup and leave. This wil update the message area
|
||||
records.
|
||||
|
||||
libmsgbase.a:
|
||||
With JAM_Readheader the Msg.Replyid field wasn't filled.
|
||||
|
||||
mbcico:
|
||||
All heavy debug logmessages are now in defines and are only
|
||||
enabled with ./configure --enable-newbinkp
|
||||
|
2
TODO
2
TODO
@ -30,7 +30,7 @@ libdiesel.a:
|
||||
processed, instead the previous macro value will be returned.
|
||||
|
||||
libmsgbase.a:
|
||||
N: Msg.Replyid is not filled. CRC fields are not filled.
|
||||
N: CRC fields are not filled.
|
||||
|
||||
mbsebbs:
|
||||
X: Better word wrapping or paragraph justification in editor.
|
||||
|
339
lib/jammsg.c
339
lib/jammsg.c
@ -845,205 +845,210 @@ int JAM_Previous (unsigned long *ulMsg)
|
||||
|
||||
int JAM_ReadHeader (unsigned long ulMsg)
|
||||
{
|
||||
int i, RetVal = FALSE;
|
||||
unsigned char *pPos;
|
||||
unsigned long ulSubfieldLen, tmp;
|
||||
JAMIDXREC jamIdx;
|
||||
JAMBINSUBFIELD *jamSubField;
|
||||
int i, RetVal = FALSE;
|
||||
unsigned char *pPos;
|
||||
unsigned long ulSubfieldLen, tmp;
|
||||
JAMIDXREC jamIdx;
|
||||
JAMBINSUBFIELD *jamSubField;
|
||||
|
||||
tmp = Msg.Id;
|
||||
JAM_New ();
|
||||
Msg.Id = tmp;
|
||||
tmp = Msg.Id;
|
||||
JAM_New ();
|
||||
Msg.Id = tmp;
|
||||
|
||||
if (Msg.Id == ulMsg) {
|
||||
if (Msg.Id == ulMsg) {
|
||||
// --------------------------------------------------------------------
|
||||
// The user is requesting the header of the last message retrived
|
||||
// so our first attempt is to read the last index from the file and
|
||||
// check if this is the correct one.
|
||||
// --------------------------------------------------------------------
|
||||
lseek (fdJdx, tell (fdJdx) - sizeof (jamIdx), SEEK_SET);
|
||||
if (read (fdJdx, &jamIdx, sizeof (jamIdx)) == sizeof (jamIdx)) {
|
||||
lseek (fdHdr, jamIdx.HdrOffset, SEEK_SET);
|
||||
read (fdHdr, &jamHdr, sizeof (JAMHDR));
|
||||
if (!(jamHdr.Attribute & MSG_DELETED) && jamHdr.MsgNum == ulMsg)
|
||||
RetVal = TRUE;
|
||||
}
|
||||
lseek (fdJdx, tell (fdJdx) - sizeof (jamIdx), SEEK_SET);
|
||||
if (read (fdJdx, &jamIdx, sizeof (jamIdx)) == sizeof (jamIdx)) {
|
||||
lseek (fdHdr, jamIdx.HdrOffset, SEEK_SET);
|
||||
read (fdHdr, &jamHdr, sizeof (JAMHDR));
|
||||
if (!(jamHdr.Attribute & MSG_DELETED) && jamHdr.MsgNum == ulMsg)
|
||||
RetVal = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
if (((Msg.Id + 1) == ulMsg) && (RetVal == FALSE)) {
|
||||
if (((Msg.Id + 1) == ulMsg) && (RetVal == FALSE)) {
|
||||
//---------------------------------------------------------------------
|
||||
// If the user is requesting the header of the next message we attempt
|
||||
// to read the next header and check if this is the correct one.
|
||||
// This is EXPERIMENTAL
|
||||
//---------------------------------------------------------------------
|
||||
if (read(fdJdx, &jamIdx, sizeof(jamIdx)) == sizeof(jamIdx)) {
|
||||
lseek(fdHdr, jamIdx.HdrOffset, SEEK_SET);
|
||||
read(fdHdr, &jamHdr, sizeof(JAMHDR));
|
||||
if (!(jamHdr.Attribute & MSG_DELETED) && jamHdr.MsgNum == ulMsg)
|
||||
RetVal = TRUE;
|
||||
}
|
||||
if (read(fdJdx, &jamIdx, sizeof(jamIdx)) == sizeof(jamIdx)) {
|
||||
lseek(fdHdr, jamIdx.HdrOffset, SEEK_SET);
|
||||
read(fdHdr, &jamHdr, sizeof(JAMHDR));
|
||||
if (!(jamHdr.Attribute & MSG_DELETED) && jamHdr.MsgNum == ulMsg)
|
||||
RetVal = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (RetVal == FALSE) {
|
||||
if (RetVal == FALSE) {
|
||||
// --------------------------------------------------------------------
|
||||
// The message request is not the last retrived or the file pointers
|
||||
// are not positioned where they should be, so now we attempt to
|
||||
// retrive the message header scanning the database from the beginning.
|
||||
// retrieve the message header scanning the database from the beginning.
|
||||
// --------------------------------------------------------------------
|
||||
Msg.Id = 0L;
|
||||
lseek (fdJdx, 0L, SEEK_SET);
|
||||
do {
|
||||
if (read (fdJdx, &jamIdx, sizeof (jamIdx)) == sizeof (jamIdx)) {
|
||||
lseek (fdHdr, jamIdx.HdrOffset, SEEK_SET);
|
||||
read (fdHdr, &jamHdr, sizeof (JAMHDR));
|
||||
if (!(jamHdr.Attribute & MSG_DELETED) && jamHdr.MsgNum == ulMsg)
|
||||
RetVal = TRUE;
|
||||
}
|
||||
} while (RetVal == FALSE && tell (fdJdx) < filelength (fdJdx));
|
||||
}
|
||||
Msg.Id = 0L;
|
||||
lseek (fdJdx, 0L, SEEK_SET);
|
||||
do {
|
||||
if (read (fdJdx, &jamIdx, sizeof (jamIdx)) == sizeof (jamIdx)) {
|
||||
lseek (fdHdr, jamIdx.HdrOffset, SEEK_SET);
|
||||
read (fdHdr, &jamHdr, sizeof (JAMHDR));
|
||||
if (!(jamHdr.Attribute & MSG_DELETED) && jamHdr.MsgNum == ulMsg)
|
||||
RetVal = TRUE;
|
||||
}
|
||||
} while (RetVal == FALSE && tell (fdJdx) < filelength (fdJdx));
|
||||
}
|
||||
|
||||
if (RetVal == TRUE) {
|
||||
Msg.Current = Msg.Id = ulMsg;
|
||||
if (RetVal == TRUE) {
|
||||
Msg.Current = Msg.Id = ulMsg;
|
||||
|
||||
Msg.Local = (unsigned char)((jamHdr.Attribute & MSG_LOCAL) ? TRUE : FALSE);
|
||||
Msg.Intransit = (unsigned char)((jamHdr.Attribute & MSG_INTRANSIT) ? TRUE : FALSE);
|
||||
Msg.Private = (unsigned char)((jamHdr.Attribute & MSG_PRIVATE) ? TRUE : FALSE);
|
||||
Msg.Received = (unsigned char)((jamHdr.Attribute & MSG_READ) ? TRUE : FALSE);
|
||||
Msg.Sent = (unsigned char)((jamHdr.Attribute & MSG_SENT) ? TRUE : FALSE);
|
||||
Msg.KillSent = (unsigned char)((jamHdr.Attribute & MSG_KILLSENT) ? TRUE : FALSE);
|
||||
Msg.ArchiveSent = (unsigned char)((jamHdr.Attribute & MSG_ARCHIVESENT) ? TRUE : FALSE);
|
||||
Msg.Hold = (unsigned char)((jamHdr.Attribute & MSG_HOLD) ? TRUE : FALSE);
|
||||
Msg.Crash = (unsigned char)((jamHdr.Attribute & MSG_CRASH) ? TRUE : FALSE);
|
||||
Msg.Immediate = (unsigned char)((jamHdr.Attribute & MSG_IMMEDIATE) ? TRUE : FALSE);
|
||||
Msg.Direct = (unsigned char)((jamHdr.Attribute & MSG_DIRECT) ? TRUE : FALSE);
|
||||
Msg.Gate = (unsigned char)((jamHdr.Attribute & MSG_GATE) ? TRUE : FALSE);
|
||||
Msg.FileRequest = (unsigned char)((jamHdr.Attribute & MSG_FILEREQUEST) ? TRUE : FALSE);
|
||||
Msg.FileAttach = (unsigned char)((jamHdr.Attribute & MSG_FILEATTACH) ? TRUE : FALSE);
|
||||
Msg.TruncFile = (unsigned char)((jamHdr.Attribute & MSG_TRUNCFILE) ? TRUE : FALSE);
|
||||
Msg.KillFile = (unsigned char)((jamHdr.Attribute & MSG_KILLFILE) ? TRUE : FALSE);
|
||||
Msg.ReceiptRequest = (unsigned char)((jamHdr.Attribute & MSG_RECEIPTREQ) ? TRUE : FALSE);
|
||||
Msg.ConfirmRequest = (unsigned char)((jamHdr.Attribute & MSG_CONFIRMREQ) ? TRUE : FALSE);
|
||||
Msg.Orphan = (unsigned char)((jamHdr.Attribute & MSG_ORPHAN) ? TRUE : FALSE);
|
||||
Msg.Encrypt = (unsigned char)((jamHdr.Attribute & MSG_ENCRYPT) ? TRUE : FALSE);
|
||||
Msg.Compressed = (unsigned char)((jamHdr.Attribute & MSG_COMPRESS) ? TRUE : FALSE);
|
||||
Msg.Escaped = (unsigned char)((jamHdr.Attribute & MSG_ESCAPED) ? TRUE : FALSE);
|
||||
Msg.ForcePU = (unsigned char)((jamHdr.Attribute & MSG_FPU) ? TRUE : FALSE);
|
||||
Msg.Localmail = (unsigned char)((jamHdr.Attribute & MSG_TYPELOCAL) ? TRUE : FALSE);
|
||||
Msg.Echomail = (unsigned char)((jamHdr.Attribute & MSG_TYPEECHO) ? TRUE : FALSE);
|
||||
Msg.Netmail = (unsigned char)((jamHdr.Attribute & MSG_TYPENET) ? TRUE : FALSE);
|
||||
Msg.Nodisplay = (unsigned char)((jamHdr.Attribute & MSG_NODISP) ? TRUE : FALSE);
|
||||
Msg.Locked = (unsigned char)((jamHdr.Attribute & MSG_LOCKED) ? TRUE : FALSE);
|
||||
Msg.Deleted = (unsigned char)((jamHdr.Attribute & MSG_DELETED) ? TRUE : FALSE);
|
||||
Msg.Local = (unsigned char)((jamHdr.Attribute & MSG_LOCAL) ? TRUE : FALSE);
|
||||
Msg.Intransit = (unsigned char)((jamHdr.Attribute & MSG_INTRANSIT) ? TRUE : FALSE);
|
||||
Msg.Private = (unsigned char)((jamHdr.Attribute & MSG_PRIVATE) ? TRUE : FALSE);
|
||||
Msg.Received = (unsigned char)((jamHdr.Attribute & MSG_READ) ? TRUE : FALSE);
|
||||
Msg.Sent = (unsigned char)((jamHdr.Attribute & MSG_SENT) ? TRUE : FALSE);
|
||||
Msg.KillSent = (unsigned char)((jamHdr.Attribute & MSG_KILLSENT) ? TRUE : FALSE);
|
||||
Msg.ArchiveSent = (unsigned char)((jamHdr.Attribute & MSG_ARCHIVESENT) ? TRUE : FALSE);
|
||||
Msg.Hold = (unsigned char)((jamHdr.Attribute & MSG_HOLD) ? TRUE : FALSE);
|
||||
Msg.Crash = (unsigned char)((jamHdr.Attribute & MSG_CRASH) ? TRUE : FALSE);
|
||||
Msg.Immediate = (unsigned char)((jamHdr.Attribute & MSG_IMMEDIATE) ? TRUE : FALSE);
|
||||
Msg.Direct = (unsigned char)((jamHdr.Attribute & MSG_DIRECT) ? TRUE : FALSE);
|
||||
Msg.Gate = (unsigned char)((jamHdr.Attribute & MSG_GATE) ? TRUE : FALSE);
|
||||
Msg.FileRequest = (unsigned char)((jamHdr.Attribute & MSG_FILEREQUEST) ? TRUE : FALSE);
|
||||
Msg.FileAttach = (unsigned char)((jamHdr.Attribute & MSG_FILEATTACH) ? TRUE : FALSE);
|
||||
Msg.TruncFile = (unsigned char)((jamHdr.Attribute & MSG_TRUNCFILE) ? TRUE : FALSE);
|
||||
Msg.KillFile = (unsigned char)((jamHdr.Attribute & MSG_KILLFILE) ? TRUE : FALSE);
|
||||
Msg.ReceiptRequest = (unsigned char)((jamHdr.Attribute & MSG_RECEIPTREQ) ? TRUE : FALSE);
|
||||
Msg.ConfirmRequest = (unsigned char)((jamHdr.Attribute & MSG_CONFIRMREQ) ? TRUE : FALSE);
|
||||
Msg.Orphan = (unsigned char)((jamHdr.Attribute & MSG_ORPHAN) ? TRUE : FALSE);
|
||||
Msg.Encrypt = (unsigned char)((jamHdr.Attribute & MSG_ENCRYPT) ? TRUE : FALSE);
|
||||
Msg.Compressed = (unsigned char)((jamHdr.Attribute & MSG_COMPRESS) ? TRUE : FALSE);
|
||||
Msg.Escaped = (unsigned char)((jamHdr.Attribute & MSG_ESCAPED) ? TRUE : FALSE);
|
||||
Msg.ForcePU = (unsigned char)((jamHdr.Attribute & MSG_FPU) ? TRUE : FALSE);
|
||||
Msg.Localmail = (unsigned char)((jamHdr.Attribute & MSG_TYPELOCAL) ? TRUE : FALSE);
|
||||
Msg.Echomail = (unsigned char)((jamHdr.Attribute & MSG_TYPEECHO) ? TRUE : FALSE);
|
||||
Msg.Netmail = (unsigned char)((jamHdr.Attribute & MSG_TYPENET) ? TRUE : FALSE);
|
||||
Msg.Nodisplay = (unsigned char)((jamHdr.Attribute & MSG_NODISP) ? TRUE : FALSE);
|
||||
Msg.Locked = (unsigned char)((jamHdr.Attribute & MSG_LOCKED) ? TRUE : FALSE);
|
||||
Msg.Deleted = (unsigned char)((jamHdr.Attribute & MSG_DELETED) ? TRUE : FALSE);
|
||||
|
||||
Msg.Written = jamHdr.DateWritten;
|
||||
Msg.Arrived = jamHdr.DateProcessed;
|
||||
Msg.Read = jamHdr.DateReceived;
|
||||
Msg.Written = jamHdr.DateWritten;
|
||||
Msg.Arrived = jamHdr.DateProcessed;
|
||||
Msg.Read = jamHdr.DateReceived;
|
||||
|
||||
Msg.Original = jamHdr.ReplyTo;
|
||||
Msg.Reply = jamHdr.ReplyNext;
|
||||
Msg.Original = jamHdr.ReplyTo;
|
||||
Msg.Reply = jamHdr.ReplyNext;
|
||||
|
||||
if (pSubfield != NULL)
|
||||
free (pSubfield);
|
||||
pSubfield = NULL;
|
||||
if (pSubfield != NULL)
|
||||
free (pSubfield);
|
||||
pSubfield = NULL;
|
||||
|
||||
if (jamHdr.SubfieldLen > 0L) {
|
||||
ulSubfieldLen = jamHdr.SubfieldLen;
|
||||
pPos = pSubfield = (unsigned char *)malloc ((size_t)(ulSubfieldLen + 1));
|
||||
if (pSubfield == NULL)
|
||||
return (FALSE);
|
||||
if (jamHdr.SubfieldLen > 0L) {
|
||||
ulSubfieldLen = jamHdr.SubfieldLen;
|
||||
pPos = pSubfield = (unsigned char *)malloc ((size_t)(ulSubfieldLen + 1));
|
||||
if (pSubfield == NULL)
|
||||
return (FALSE);
|
||||
|
||||
read (fdHdr, pSubfield, (size_t)jamHdr.SubfieldLen);
|
||||
read (fdHdr, pSubfield, (size_t)jamHdr.SubfieldLen);
|
||||
|
||||
while (ulSubfieldLen > 0L) {
|
||||
jamSubField = (JAMBINSUBFIELD *)pPos;
|
||||
pPos += sizeof (JAMBINSUBFIELD);
|
||||
/*
|
||||
* The next check is to prevent a segmentation
|
||||
* fault by corrupted subfields.
|
||||
*/
|
||||
if ((jamSubField->DatLen < 0) || (jamSubField->DatLen > jamHdr.SubfieldLen))
|
||||
return FALSE;
|
||||
|
||||
switch (jamSubField->LoID) {
|
||||
case JAMSFLD_SENDERNAME:
|
||||
if (jamSubField->DatLen > 100) {
|
||||
memcpy (Msg.From, pPos, 100);
|
||||
Msg.From[100] = '\0';
|
||||
} else {
|
||||
memcpy (Msg.From, pPos, (int)jamSubField->DatLen);
|
||||
Msg.From[(int)jamSubField->DatLen] = '\0';
|
||||
}
|
||||
break;
|
||||
|
||||
case JAMSFLD_RECVRNAME:
|
||||
if (jamSubField->DatLen > 100) {
|
||||
memcpy (Msg.To, pPos, 100);
|
||||
Msg.To[100] = '\0';
|
||||
} else {
|
||||
memcpy (Msg.To, pPos, (int)jamSubField->DatLen);
|
||||
Msg.To[(int)jamSubField->DatLen] = '\0';
|
||||
}
|
||||
break;
|
||||
|
||||
case JAMSFLD_SUBJECT:
|
||||
if (jamSubField->DatLen > 100) {
|
||||
memcpy (Msg.Subject, pPos, 100);
|
||||
Msg.Subject[100] = '\0';
|
||||
} else {
|
||||
memcpy (Msg.Subject, pPos, (int)jamSubField->DatLen);
|
||||
Msg.Subject[(int)jamSubField->DatLen] = '\0';
|
||||
}
|
||||
break;
|
||||
|
||||
case JAMSFLD_OADDRESS:
|
||||
if (jamSubField->DatLen > 100) {
|
||||
memcpy (Msg.FromAddress, pPos, 100);
|
||||
Msg.FromAddress[100] = '\0';
|
||||
} else {
|
||||
memcpy (Msg.FromAddress, pPos, (int)jamSubField->DatLen);
|
||||
Msg.FromAddress[(int)jamSubField->DatLen] = '\0';
|
||||
}
|
||||
break;
|
||||
|
||||
case JAMSFLD_DADDRESS:
|
||||
if (jamSubField->DatLen > 100) {
|
||||
memcpy(Msg.ToAddress, pPos, 100);
|
||||
Msg.ToAddress[100] = '\0';
|
||||
} else {
|
||||
memcpy (Msg.ToAddress, pPos, (int)jamSubField->DatLen);
|
||||
Msg.ToAddress[(int)jamSubField->DatLen] = '\0';
|
||||
}
|
||||
break;
|
||||
|
||||
case JAMSFLD_MSGID:
|
||||
memcpy (Msg.Msgid, pPos, (int)jamSubField->DatLen);
|
||||
Msg.Msgid[(int)jamSubField->DatLen] = '\0';
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
ulSubfieldLen -= sizeof (JAMBINSUBFIELD) + jamSubField->DatLen;
|
||||
if (ulSubfieldLen > 0)
|
||||
pPos += (int)jamSubField->DatLen;
|
||||
}
|
||||
}
|
||||
while (ulSubfieldLen > 0L) {
|
||||
jamSubField = (JAMBINSUBFIELD *)pPos;
|
||||
pPos += sizeof (JAMBINSUBFIELD);
|
||||
/*
|
||||
* In the original BBS we found that GEcho was not
|
||||
* setting the FromAddress. We take it from the MSGID
|
||||
* if there is one.
|
||||
* The next check is to prevent a segmentation
|
||||
* fault by corrupted subfields.
|
||||
*/
|
||||
if ((!strlen(Msg.FromAddress)) && (strlen(Msg.Msgid))) {
|
||||
for (i = 0; i < strlen(Msg.Msgid); i++) {
|
||||
if ((Msg.Msgid[i] == '@') || (Msg.Msgid[i] == ' '))
|
||||
break;
|
||||
Msg.FromAddress[i] = Msg.Msgid[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((jamSubField->DatLen < 0) || (jamSubField->DatLen > jamHdr.SubfieldLen))
|
||||
return FALSE;
|
||||
|
||||
return (RetVal);
|
||||
switch (jamSubField->LoID) {
|
||||
case JAMSFLD_SENDERNAME:
|
||||
if (jamSubField->DatLen > 100) {
|
||||
memcpy (Msg.From, pPos, 100);
|
||||
Msg.From[100] = '\0';
|
||||
} else {
|
||||
memcpy (Msg.From, pPos, (int)jamSubField->DatLen);
|
||||
Msg.From[(int)jamSubField->DatLen] = '\0';
|
||||
}
|
||||
break;
|
||||
|
||||
case JAMSFLD_RECVRNAME:
|
||||
if (jamSubField->DatLen > 100) {
|
||||
memcpy (Msg.To, pPos, 100);
|
||||
Msg.To[100] = '\0';
|
||||
} else {
|
||||
memcpy (Msg.To, pPos, (int)jamSubField->DatLen);
|
||||
Msg.To[(int)jamSubField->DatLen] = '\0';
|
||||
}
|
||||
break;
|
||||
|
||||
case JAMSFLD_SUBJECT:
|
||||
if (jamSubField->DatLen > 100) {
|
||||
memcpy (Msg.Subject, pPos, 100);
|
||||
Msg.Subject[100] = '\0';
|
||||
} else {
|
||||
memcpy (Msg.Subject, pPos, (int)jamSubField->DatLen);
|
||||
Msg.Subject[(int)jamSubField->DatLen] = '\0';
|
||||
}
|
||||
break;
|
||||
|
||||
case JAMSFLD_OADDRESS:
|
||||
if (jamSubField->DatLen > 100) {
|
||||
memcpy (Msg.FromAddress, pPos, 100);
|
||||
Msg.FromAddress[100] = '\0';
|
||||
} else {
|
||||
memcpy (Msg.FromAddress, pPos, (int)jamSubField->DatLen);
|
||||
Msg.FromAddress[(int)jamSubField->DatLen] = '\0';
|
||||
}
|
||||
break;
|
||||
|
||||
case JAMSFLD_DADDRESS:
|
||||
if (jamSubField->DatLen > 100) {
|
||||
memcpy(Msg.ToAddress, pPos, 100);
|
||||
Msg.ToAddress[100] = '\0';
|
||||
} else {
|
||||
memcpy (Msg.ToAddress, pPos, (int)jamSubField->DatLen);
|
||||
Msg.ToAddress[(int)jamSubField->DatLen] = '\0';
|
||||
}
|
||||
break;
|
||||
|
||||
case JAMSFLD_MSGID:
|
||||
memcpy (Msg.Msgid, pPos, (int)jamSubField->DatLen);
|
||||
Msg.Msgid[(int)jamSubField->DatLen] = '\0';
|
||||
break;
|
||||
|
||||
case JAMSFLD_REPLYID:
|
||||
memcpy (Msg.Replyid, pPos, (int)jamSubField->DatLen);
|
||||
Msg.Replyid[(int)jamSubField->DatLen] = '\0';
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
ulSubfieldLen -= sizeof (JAMBINSUBFIELD) + jamSubField->DatLen;
|
||||
if (ulSubfieldLen > 0)
|
||||
pPos += (int)jamSubField->DatLen;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* In the original BBS we found that GEcho was not
|
||||
* setting the FromAddress. We take it from the MSGID
|
||||
* if there is one.
|
||||
*/
|
||||
if ((!strlen(Msg.FromAddress)) && (strlen(Msg.Msgid))) {
|
||||
for (i = 0; i < strlen(Msg.Msgid); i++) {
|
||||
if ((Msg.Msgid[i] == '@') || (Msg.Msgid[i] == ' '))
|
||||
break;
|
||||
Msg.FromAddress[i] = Msg.Msgid[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return (RetVal);
|
||||
}
|
||||
|
||||
|
||||
|
@ -408,6 +408,7 @@ int get_xover(char *grpname, long startnr, long endnr, List **art)
|
||||
if ((strlen(resp) == 1) && (strcmp(resp, ".") == 0)) {
|
||||
done = TRUE;
|
||||
} else {
|
||||
Syslogp('n', printable(resp, 0));
|
||||
Marker();
|
||||
Nopper();
|
||||
pov = xoverview;
|
||||
|
@ -44,6 +44,9 @@ char currentgroup[81]; /* Current newsgroup */
|
||||
extern unsigned long sentbytes;
|
||||
|
||||
|
||||
void send_xlat(char *);
|
||||
char *make_msgid(char *);
|
||||
|
||||
|
||||
/*
|
||||
* Safe sending to the client with charset translation.
|
||||
@ -78,11 +81,16 @@ void send_xlat(char *inp)
|
||||
|
||||
|
||||
|
||||
char *make_msgid(unsigned long nr, unsigned long crc)
|
||||
/*
|
||||
* Build a faked RFC msgid, use the CRC32 of the FTN msgid,
|
||||
* the current group and the configured system's fqdn. This
|
||||
* gives a unique string specific for the message.
|
||||
*/
|
||||
char *make_msgid(char *msgid)
|
||||
{
|
||||
static char buf[100];
|
||||
|
||||
sprintf(buf, "<%lu$%8lx@%s>", nr, crc, CFG.sysdomain);
|
||||
sprintf(buf, "<%8lx$%s@%s>", StringCRC32(msgid), currentgroup, CFG.sysdomain);
|
||||
return buf;
|
||||
}
|
||||
|
||||
@ -96,9 +104,9 @@ char *make_msgid(unsigned long nr, unsigned long crc)
|
||||
*/
|
||||
void command_abhs(char *buf)
|
||||
{
|
||||
char *p, *cmd, *opt, dig[128];
|
||||
char *p, *cmd, *opt;
|
||||
unsigned long art = 0L;
|
||||
int i;
|
||||
int found;
|
||||
|
||||
Syslog('+', "%s", buf);
|
||||
cmd = strtok(buf, " \0");
|
||||
@ -117,17 +125,24 @@ void command_abhs(char *buf)
|
||||
}
|
||||
|
||||
if (opt[0] == '<') {
|
||||
Syslog('n', "\"%s\"", printable(opt, 0));
|
||||
strcpy(dig, opt+1);
|
||||
Syslog('n', "\"%s\"", printable(dig, 0));
|
||||
for (i = 0; i < strlen(dig); i++) {
|
||||
if (dig[i] == '$') {
|
||||
dig[i] = '\0';
|
||||
break;
|
||||
/*
|
||||
* We have to read all headers in the area to retrieve the message using the msgid.
|
||||
*/
|
||||
found = FALSE;
|
||||
Syslog('n', "Search from %lu to %lu for %s", MsgBase.Lowest, MsgBase.Highest, opt);
|
||||
for (art = MsgBase.Lowest; art <= MsgBase.Highest; art++) {
|
||||
if (Msg_ReadHeader(art)) {
|
||||
if (strcmp(opt, make_msgid(Msg.Msgid)) == 0) {
|
||||
Syslog('n', "Found message %lu", art);
|
||||
found = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
Syslog('n', "\"%s\"", printable(dig, 0));
|
||||
art = atoi(dig);
|
||||
if (! found) {
|
||||
send_nntp("430 No such article found");
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
art = atoi(opt);
|
||||
}
|
||||
@ -145,7 +160,7 @@ void command_abhs(char *buf)
|
||||
}
|
||||
|
||||
if (strcasecmp(cmd, "STAT") == 0) {
|
||||
send_nntp("223 %lu %s Article retrieved", art, make_msgid(art, StringCRC32(Msg.Msgid)));
|
||||
send_nntp("223 %lu %s Article retrieved", art, make_msgid(Msg.Msgid));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -157,11 +172,11 @@ void command_abhs(char *buf)
|
||||
if (Msg_Read(art, 75)) {
|
||||
|
||||
if (strcasecmp(cmd, "ARTICLE") == 0)
|
||||
send_nntp("220 %ld %s Article retrieved - Head and body follow", art, make_msgid(art, StringCRC32(Msg.Msgid)));
|
||||
send_nntp("220 %ld %s Article retrieved - Head and body follow", art, make_msgid(Msg.Msgid));
|
||||
if (strcasecmp(cmd, "HEAD") == 0)
|
||||
send_nntp("221 %ld %s Article retrieved - Head follows", art, make_msgid(art, StringCRC32(Msg.Msgid)));
|
||||
send_nntp("221 %ld %s Article retrieved - Head follows", art, make_msgid(Msg.Msgid));
|
||||
if (strcasecmp(cmd, "BODY") == 0)
|
||||
send_nntp("222 %ld %s Article retrieved - Body follows", art, make_msgid(art, StringCRC32(Msg.Msgid)));
|
||||
send_nntp("222 %ld %s Article retrieved - Body follows", art, make_msgid(Msg.Msgid));
|
||||
|
||||
if ((strcasecmp(cmd, "ARTICLE") == 0) || (strcasecmp(cmd, "HEAD") == 0)) {
|
||||
|
||||
@ -170,9 +185,9 @@ void command_abhs(char *buf)
|
||||
send_nntp("Newsgroups: %s", currentgroup);
|
||||
send_nntp("Subject: %s", Msg.Subject);
|
||||
send_nntp("Date: %s", rfcdate(Msg.Written));
|
||||
send_nntp("Message-ID: %s", make_msgid(art, StringCRC32(Msg.Msgid)));
|
||||
send_nntp("Message-ID: %s", make_msgid(Msg.Msgid));
|
||||
if (strlen(Msg.Replyid))
|
||||
send_nntp("References: %s", make_msgid(Msg.Reply, StringCRC32(Msg.Replyid)));
|
||||
send_nntp("References: %s", make_msgid(Msg.Replyid));
|
||||
send_nntp("X-JAM-From: %s <%s>", Msg.From, Msg.FromAddress);
|
||||
if (strlen(Msg.To))
|
||||
send_nntp("X-JAM-To: %s", Msg.To);
|
||||
@ -248,7 +263,6 @@ void command_group(char *cmd)
|
||||
while (fread(&msgs, msgshdr.recsize, 1, fp) == 1) {
|
||||
if (msgs.Active && ((msgs.Type == ECHOMAIL) || (msgs.Type == NEWS)) && strlen(msgs.Newsgroup) &&
|
||||
(strcasecmp(opt, msgs.Newsgroup) == 0) && Access(usrconfig.Security, msgs.RDSec)) {
|
||||
Syslog('n', "Found the group");
|
||||
if (Msg_Open(msgs.Base)) {
|
||||
Msg_Number();
|
||||
Msg_Highest();
|
||||
@ -417,10 +431,10 @@ void command_xover(char *cmd)
|
||||
} while ((p = (char *)MsgText_Next()) != NULL);
|
||||
}
|
||||
}
|
||||
sprintf(msgid, "%s", make_msgid(i, StringCRC32(Msg.Msgid)));
|
||||
sprintf(msgid, "%s", make_msgid(Msg.Msgid));
|
||||
reply[0] = 0;
|
||||
if (strlen(Msg.Replyid))
|
||||
sprintf(reply, "%s", make_msgid(Msg.Reply, StringCRC32(Msg.Replyid)));
|
||||
sprintf(reply, "%s", make_msgid(Msg.Replyid));
|
||||
send_nntp("%lu\t%s\t%s <%s>\t%s\t%s\t%s\t%d\t%d", i, Msg.Subject, Msg.From, Msg.FromAddress,
|
||||
rfcdate(Msg.Written), msgid, reply, bytecount, linecount);
|
||||
}
|
||||
|
@ -30,11 +30,14 @@
|
||||
|
||||
#include "../config.h"
|
||||
#include "../lib/mbselib.h"
|
||||
#include "ttyio.h"
|
||||
#include "ttyio.h"
|
||||
#include "openport.h"
|
||||
|
||||
|
||||
int hanged_up = 0;
|
||||
int hanged_up = 0;
|
||||
|
||||
void linedrop(int);
|
||||
void sigpipe(int);
|
||||
|
||||
|
||||
|
||||
@ -63,11 +66,7 @@ int rawport(void)
|
||||
signal(SIGHUP, linedrop);
|
||||
Syslog('t', "SIGPIPE => sigpipe()");
|
||||
signal(SIGPIPE, sigpipe);
|
||||
|
||||
if (isatty(0))
|
||||
return tty_raw(0);
|
||||
else
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@ -78,51 +77,6 @@ int cookedport(void)
|
||||
signal(SIGHUP, SIG_IGN);
|
||||
Syslog('t', "SIGPIPE => SIG_IGN");
|
||||
signal(SIGPIPE, SIG_IGN);
|
||||
if (isatty(0))
|
||||
return tty_cooked();
|
||||
else
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static struct termios savetios;
|
||||
static struct termios tios;
|
||||
|
||||
|
||||
int tty_raw(int speed)
|
||||
{
|
||||
int rc;
|
||||
|
||||
Syslog('t', "Set tty raw");
|
||||
|
||||
if ((rc = tcgetattr(0,&savetios))) {
|
||||
WriteError("$tcgetattr(0,save) return %d",rc);
|
||||
return rc;
|
||||
}
|
||||
|
||||
tios = savetios;
|
||||
tios.c_iflag = 0;
|
||||
tios.c_oflag = 0;
|
||||
tios.c_cflag &= ~(CSTOPB | PARENB | PARODD);
|
||||
tios.c_cflag |= CS8 | CREAD | HUPCL | CLOCAL;
|
||||
tios.c_lflag = 0;
|
||||
tios.c_cc[VMIN] = 1;
|
||||
tios.c_cc[VTIME] = 0;
|
||||
|
||||
if ((rc = tcsetattr(0,TCSADRAIN,&tios)))
|
||||
WriteError("$tcsetattr(0,TCSADRAIN,raw) return %d",rc);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
int tty_cooked(void)
|
||||
{
|
||||
int rc;
|
||||
|
||||
if ((rc = tcsetattr(0,TCSAFLUSH,&savetios)))
|
||||
Syslog('t', "$tcsetattr(0,TCSAFLUSH,save) return %d",rc);
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
|
@ -3,12 +3,8 @@
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
void linedrop(int);
|
||||
void sigpipe(int);
|
||||
int rawport(void);
|
||||
int cookedport(void);
|
||||
|
||||
int tty_raw(int);
|
||||
int tty_cooked(void);
|
||||
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user