Fixes for mbnntp

This commit is contained in:
Michiel Broek 2004-04-15 19:38:12 +00:00
parent 4aacf882e6
commit 884cb156ad
7 changed files with 220 additions and 247 deletions

View File

@ -6,6 +6,9 @@ v0.51.4 11-Apr-2004
Start mbsetup and leave. This wil update the message area Start mbsetup and leave. This wil update the message area
records. records.
libmsgbase.a:
With JAM_Readheader the Msg.Replyid field wasn't filled.
mbcico: mbcico:
All heavy debug logmessages are now in defines and are only All heavy debug logmessages are now in defines and are only
enabled with ./configure --enable-newbinkp enabled with ./configure --enable-newbinkp

2
TODO
View File

@ -30,7 +30,7 @@ libdiesel.a:
processed, instead the previous macro value will be returned. processed, instead the previous macro value will be returned.
libmsgbase.a: libmsgbase.a:
N: Msg.Replyid is not filled. CRC fields are not filled. N: CRC fields are not filled.
mbsebbs: mbsebbs:
X: Better word wrapping or paragraph justification in editor. X: Better word wrapping or paragraph justification in editor.

View File

@ -845,205 +845,210 @@ int JAM_Previous (unsigned long *ulMsg)
int JAM_ReadHeader (unsigned long ulMsg) int JAM_ReadHeader (unsigned long ulMsg)
{ {
int i, RetVal = FALSE; int i, RetVal = FALSE;
unsigned char *pPos; unsigned char *pPos;
unsigned long ulSubfieldLen, tmp; unsigned long ulSubfieldLen, tmp;
JAMIDXREC jamIdx; JAMIDXREC jamIdx;
JAMBINSUBFIELD *jamSubField; JAMBINSUBFIELD *jamSubField;
tmp = Msg.Id; tmp = Msg.Id;
JAM_New (); JAM_New ();
Msg.Id = tmp; Msg.Id = tmp;
if (Msg.Id == ulMsg) { if (Msg.Id == ulMsg) {
// -------------------------------------------------------------------- // --------------------------------------------------------------------
// The user is requesting the header of the last message retrived // 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 // so our first attempt is to read the last index from the file and
// check if this is the correct one. // check if this is the correct one.
// -------------------------------------------------------------------- // --------------------------------------------------------------------
lseek (fdJdx, tell (fdJdx) - sizeof (jamIdx), SEEK_SET); lseek (fdJdx, tell (fdJdx) - sizeof (jamIdx), SEEK_SET);
if (read (fdJdx, &jamIdx, sizeof (jamIdx)) == sizeof (jamIdx)) { if (read (fdJdx, &jamIdx, sizeof (jamIdx)) == sizeof (jamIdx)) {
lseek (fdHdr, jamIdx.HdrOffset, SEEK_SET); lseek (fdHdr, jamIdx.HdrOffset, SEEK_SET);
read (fdHdr, &jamHdr, sizeof (JAMHDR)); read (fdHdr, &jamHdr, sizeof (JAMHDR));
if (!(jamHdr.Attribute & MSG_DELETED) && jamHdr.MsgNum == ulMsg) if (!(jamHdr.Attribute & MSG_DELETED) && jamHdr.MsgNum == ulMsg)
RetVal = TRUE; 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 // 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. // to read the next header and check if this is the correct one.
// This is EXPERIMENTAL // This is EXPERIMENTAL
//--------------------------------------------------------------------- //---------------------------------------------------------------------
if (read(fdJdx, &jamIdx, sizeof(jamIdx)) == sizeof(jamIdx)) { if (read(fdJdx, &jamIdx, sizeof(jamIdx)) == sizeof(jamIdx)) {
lseek(fdHdr, jamIdx.HdrOffset, SEEK_SET); lseek(fdHdr, jamIdx.HdrOffset, SEEK_SET);
read(fdHdr, &jamHdr, sizeof(JAMHDR)); read(fdHdr, &jamHdr, sizeof(JAMHDR));
if (!(jamHdr.Attribute & MSG_DELETED) && jamHdr.MsgNum == ulMsg) if (!(jamHdr.Attribute & MSG_DELETED) && jamHdr.MsgNum == ulMsg)
RetVal = TRUE; RetVal = TRUE;
}
} }
}
if (RetVal == FALSE) { if (RetVal == FALSE) {
// -------------------------------------------------------------------- // --------------------------------------------------------------------
// The message request is not the last retrived or the file pointers // The message request is not the last retrived or the file pointers
// are not positioned where they should be, so now we attempt to // 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; Msg.Id = 0L;
lseek (fdJdx, 0L, SEEK_SET); lseek (fdJdx, 0L, SEEK_SET);
do { do {
if (read (fdJdx, &jamIdx, sizeof (jamIdx)) == sizeof (jamIdx)) { if (read (fdJdx, &jamIdx, sizeof (jamIdx)) == sizeof (jamIdx)) {
lseek (fdHdr, jamIdx.HdrOffset, SEEK_SET); lseek (fdHdr, jamIdx.HdrOffset, SEEK_SET);
read (fdHdr, &jamHdr, sizeof (JAMHDR)); read (fdHdr, &jamHdr, sizeof (JAMHDR));
if (!(jamHdr.Attribute & MSG_DELETED) && jamHdr.MsgNum == ulMsg) if (!(jamHdr.Attribute & MSG_DELETED) && jamHdr.MsgNum == ulMsg)
RetVal = TRUE; RetVal = TRUE;
} }
} while (RetVal == FALSE && tell (fdJdx) < filelength (fdJdx)); } while (RetVal == FALSE && tell (fdJdx) < filelength (fdJdx));
} }
if (RetVal == TRUE) { if (RetVal == TRUE) {
Msg.Current = Msg.Id = ulMsg; Msg.Current = Msg.Id = ulMsg;
Msg.Local = (unsigned char)((jamHdr.Attribute & MSG_LOCAL) ? TRUE : FALSE); Msg.Local = (unsigned char)((jamHdr.Attribute & MSG_LOCAL) ? TRUE : FALSE);
Msg.Intransit = (unsigned char)((jamHdr.Attribute & MSG_INTRANSIT) ? TRUE : FALSE); Msg.Intransit = (unsigned char)((jamHdr.Attribute & MSG_INTRANSIT) ? TRUE : FALSE);
Msg.Private = (unsigned char)((jamHdr.Attribute & MSG_PRIVATE) ? TRUE : FALSE); Msg.Private = (unsigned char)((jamHdr.Attribute & MSG_PRIVATE) ? TRUE : FALSE);
Msg.Received = (unsigned char)((jamHdr.Attribute & MSG_READ) ? TRUE : FALSE); Msg.Received = (unsigned char)((jamHdr.Attribute & MSG_READ) ? TRUE : FALSE);
Msg.Sent = (unsigned char)((jamHdr.Attribute & MSG_SENT) ? TRUE : FALSE); Msg.Sent = (unsigned char)((jamHdr.Attribute & MSG_SENT) ? TRUE : FALSE);
Msg.KillSent = (unsigned char)((jamHdr.Attribute & MSG_KILLSENT) ? TRUE : FALSE); Msg.KillSent = (unsigned char)((jamHdr.Attribute & MSG_KILLSENT) ? TRUE : FALSE);
Msg.ArchiveSent = (unsigned char)((jamHdr.Attribute & MSG_ARCHIVESENT) ? TRUE : FALSE); Msg.ArchiveSent = (unsigned char)((jamHdr.Attribute & MSG_ARCHIVESENT) ? TRUE : FALSE);
Msg.Hold = (unsigned char)((jamHdr.Attribute & MSG_HOLD) ? TRUE : FALSE); Msg.Hold = (unsigned char)((jamHdr.Attribute & MSG_HOLD) ? TRUE : FALSE);
Msg.Crash = (unsigned char)((jamHdr.Attribute & MSG_CRASH) ? TRUE : FALSE); Msg.Crash = (unsigned char)((jamHdr.Attribute & MSG_CRASH) ? TRUE : FALSE);
Msg.Immediate = (unsigned char)((jamHdr.Attribute & MSG_IMMEDIATE) ? TRUE : FALSE); Msg.Immediate = (unsigned char)((jamHdr.Attribute & MSG_IMMEDIATE) ? TRUE : FALSE);
Msg.Direct = (unsigned char)((jamHdr.Attribute & MSG_DIRECT) ? TRUE : FALSE); Msg.Direct = (unsigned char)((jamHdr.Attribute & MSG_DIRECT) ? TRUE : FALSE);
Msg.Gate = (unsigned char)((jamHdr.Attribute & MSG_GATE) ? TRUE : FALSE); Msg.Gate = (unsigned char)((jamHdr.Attribute & MSG_GATE) ? TRUE : FALSE);
Msg.FileRequest = (unsigned char)((jamHdr.Attribute & MSG_FILEREQUEST) ? TRUE : FALSE); Msg.FileRequest = (unsigned char)((jamHdr.Attribute & MSG_FILEREQUEST) ? TRUE : FALSE);
Msg.FileAttach = (unsigned char)((jamHdr.Attribute & MSG_FILEATTACH) ? TRUE : FALSE); Msg.FileAttach = (unsigned char)((jamHdr.Attribute & MSG_FILEATTACH) ? TRUE : FALSE);
Msg.TruncFile = (unsigned char)((jamHdr.Attribute & MSG_TRUNCFILE) ? TRUE : FALSE); Msg.TruncFile = (unsigned char)((jamHdr.Attribute & MSG_TRUNCFILE) ? TRUE : FALSE);
Msg.KillFile = (unsigned char)((jamHdr.Attribute & MSG_KILLFILE) ? TRUE : FALSE); Msg.KillFile = (unsigned char)((jamHdr.Attribute & MSG_KILLFILE) ? TRUE : FALSE);
Msg.ReceiptRequest = (unsigned char)((jamHdr.Attribute & MSG_RECEIPTREQ) ? TRUE : FALSE); Msg.ReceiptRequest = (unsigned char)((jamHdr.Attribute & MSG_RECEIPTREQ) ? TRUE : FALSE);
Msg.ConfirmRequest = (unsigned char)((jamHdr.Attribute & MSG_CONFIRMREQ) ? TRUE : FALSE); Msg.ConfirmRequest = (unsigned char)((jamHdr.Attribute & MSG_CONFIRMREQ) ? TRUE : FALSE);
Msg.Orphan = (unsigned char)((jamHdr.Attribute & MSG_ORPHAN) ? TRUE : FALSE); Msg.Orphan = (unsigned char)((jamHdr.Attribute & MSG_ORPHAN) ? TRUE : FALSE);
Msg.Encrypt = (unsigned char)((jamHdr.Attribute & MSG_ENCRYPT) ? TRUE : FALSE); Msg.Encrypt = (unsigned char)((jamHdr.Attribute & MSG_ENCRYPT) ? TRUE : FALSE);
Msg.Compressed = (unsigned char)((jamHdr.Attribute & MSG_COMPRESS) ? TRUE : FALSE); Msg.Compressed = (unsigned char)((jamHdr.Attribute & MSG_COMPRESS) ? TRUE : FALSE);
Msg.Escaped = (unsigned char)((jamHdr.Attribute & MSG_ESCAPED) ? TRUE : FALSE); Msg.Escaped = (unsigned char)((jamHdr.Attribute & MSG_ESCAPED) ? TRUE : FALSE);
Msg.ForcePU = (unsigned char)((jamHdr.Attribute & MSG_FPU) ? TRUE : FALSE); Msg.ForcePU = (unsigned char)((jamHdr.Attribute & MSG_FPU) ? TRUE : FALSE);
Msg.Localmail = (unsigned char)((jamHdr.Attribute & MSG_TYPELOCAL) ? TRUE : FALSE); Msg.Localmail = (unsigned char)((jamHdr.Attribute & MSG_TYPELOCAL) ? TRUE : FALSE);
Msg.Echomail = (unsigned char)((jamHdr.Attribute & MSG_TYPEECHO) ? TRUE : FALSE); Msg.Echomail = (unsigned char)((jamHdr.Attribute & MSG_TYPEECHO) ? TRUE : FALSE);
Msg.Netmail = (unsigned char)((jamHdr.Attribute & MSG_TYPENET) ? TRUE : FALSE); Msg.Netmail = (unsigned char)((jamHdr.Attribute & MSG_TYPENET) ? TRUE : FALSE);
Msg.Nodisplay = (unsigned char)((jamHdr.Attribute & MSG_NODISP) ? TRUE : FALSE); Msg.Nodisplay = (unsigned char)((jamHdr.Attribute & MSG_NODISP) ? TRUE : FALSE);
Msg.Locked = (unsigned char)((jamHdr.Attribute & MSG_LOCKED) ? TRUE : FALSE); Msg.Locked = (unsigned char)((jamHdr.Attribute & MSG_LOCKED) ? TRUE : FALSE);
Msg.Deleted = (unsigned char)((jamHdr.Attribute & MSG_DELETED) ? TRUE : FALSE); Msg.Deleted = (unsigned char)((jamHdr.Attribute & MSG_DELETED) ? TRUE : FALSE);
Msg.Written = jamHdr.DateWritten; Msg.Written = jamHdr.DateWritten;
Msg.Arrived = jamHdr.DateProcessed; Msg.Arrived = jamHdr.DateProcessed;
Msg.Read = jamHdr.DateReceived; Msg.Read = jamHdr.DateReceived;
Msg.Original = jamHdr.ReplyTo; Msg.Original = jamHdr.ReplyTo;
Msg.Reply = jamHdr.ReplyNext; Msg.Reply = jamHdr.ReplyNext;
if (pSubfield != NULL) if (pSubfield != NULL)
free (pSubfield); free (pSubfield);
pSubfield = NULL; pSubfield = NULL;
if (jamHdr.SubfieldLen > 0L) { if (jamHdr.SubfieldLen > 0L) {
ulSubfieldLen = jamHdr.SubfieldLen; ulSubfieldLen = jamHdr.SubfieldLen;
pPos = pSubfield = (unsigned char *)malloc ((size_t)(ulSubfieldLen + 1)); pPos = pSubfield = (unsigned char *)malloc ((size_t)(ulSubfieldLen + 1));
if (pSubfield == NULL) if (pSubfield == NULL)
return (FALSE); return (FALSE);
read (fdHdr, pSubfield, (size_t)jamHdr.SubfieldLen); read (fdHdr, pSubfield, (size_t)jamHdr.SubfieldLen);
while (ulSubfieldLen > 0L) { while (ulSubfieldLen > 0L) {
jamSubField = (JAMBINSUBFIELD *)pPos; jamSubField = (JAMBINSUBFIELD *)pPos;
pPos += sizeof (JAMBINSUBFIELD); 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;
}
}
/* /*
* In the original BBS we found that GEcho was not * The next check is to prevent a segmentation
* setting the FromAddress. We take it from the MSGID * fault by corrupted subfields.
* if there is one.
*/ */
if ((!strlen(Msg.FromAddress)) && (strlen(Msg.Msgid))) { if ((jamSubField->DatLen < 0) || (jamSubField->DatLen > jamHdr.SubfieldLen))
for (i = 0; i < strlen(Msg.Msgid); i++) { return FALSE;
if ((Msg.Msgid[i] == '@') || (Msg.Msgid[i] == ' '))
break;
Msg.FromAddress[i] = Msg.Msgid[i];
}
}
}
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);
} }

View File

@ -408,6 +408,7 @@ int get_xover(char *grpname, long startnr, long endnr, List **art)
if ((strlen(resp) == 1) && (strcmp(resp, ".") == 0)) { if ((strlen(resp) == 1) && (strcmp(resp, ".") == 0)) {
done = TRUE; done = TRUE;
} else { } else {
Syslogp('n', printable(resp, 0));
Marker(); Marker();
Nopper(); Nopper();
pov = xoverview; pov = xoverview;

View File

@ -44,6 +44,9 @@ char currentgroup[81]; /* Current newsgroup */
extern unsigned long sentbytes; extern unsigned long sentbytes;
void send_xlat(char *);
char *make_msgid(char *);
/* /*
* Safe sending to the client with charset translation. * 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]; 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; return buf;
} }
@ -96,9 +104,9 @@ char *make_msgid(unsigned long nr, unsigned long crc)
*/ */
void command_abhs(char *buf) void command_abhs(char *buf)
{ {
char *p, *cmd, *opt, dig[128]; char *p, *cmd, *opt;
unsigned long art = 0L; unsigned long art = 0L;
int i; int found;
Syslog('+', "%s", buf); Syslog('+', "%s", buf);
cmd = strtok(buf, " \0"); cmd = strtok(buf, " \0");
@ -117,17 +125,24 @@ void command_abhs(char *buf)
} }
if (opt[0] == '<') { if (opt[0] == '<') {
Syslog('n', "\"%s\"", printable(opt, 0)); /*
strcpy(dig, opt+1); * We have to read all headers in the area to retrieve the message using the msgid.
Syslog('n', "\"%s\"", printable(dig, 0)); */
for (i = 0; i < strlen(dig); i++) { found = FALSE;
if (dig[i] == '$') { Syslog('n', "Search from %lu to %lu for %s", MsgBase.Lowest, MsgBase.Highest, opt);
dig[i] = '\0'; for (art = MsgBase.Lowest; art <= MsgBase.Highest; art++) {
break; 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)); if (! found) {
art = atoi(dig); send_nntp("430 No such article found");
return;
}
} else { } else {
art = atoi(opt); art = atoi(opt);
} }
@ -145,7 +160,7 @@ void command_abhs(char *buf)
} }
if (strcasecmp(cmd, "STAT") == 0) { 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; return;
} }
@ -157,11 +172,11 @@ void command_abhs(char *buf)
if (Msg_Read(art, 75)) { if (Msg_Read(art, 75)) {
if (strcasecmp(cmd, "ARTICLE") == 0) 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) 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) 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)) { 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("Newsgroups: %s", currentgroup);
send_nntp("Subject: %s", Msg.Subject); send_nntp("Subject: %s", Msg.Subject);
send_nntp("Date: %s", rfcdate(Msg.Written)); 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)) 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); send_nntp("X-JAM-From: %s <%s>", Msg.From, Msg.FromAddress);
if (strlen(Msg.To)) if (strlen(Msg.To))
send_nntp("X-JAM-To: %s", 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) { while (fread(&msgs, msgshdr.recsize, 1, fp) == 1) {
if (msgs.Active && ((msgs.Type == ECHOMAIL) || (msgs.Type == NEWS)) && strlen(msgs.Newsgroup) && if (msgs.Active && ((msgs.Type == ECHOMAIL) || (msgs.Type == NEWS)) && strlen(msgs.Newsgroup) &&
(strcasecmp(opt, msgs.Newsgroup) == 0) && Access(usrconfig.Security, msgs.RDSec)) { (strcasecmp(opt, msgs.Newsgroup) == 0) && Access(usrconfig.Security, msgs.RDSec)) {
Syslog('n', "Found the group");
if (Msg_Open(msgs.Base)) { if (Msg_Open(msgs.Base)) {
Msg_Number(); Msg_Number();
Msg_Highest(); Msg_Highest();
@ -417,10 +431,10 @@ void command_xover(char *cmd)
} while ((p = (char *)MsgText_Next()) != NULL); } 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; reply[0] = 0;
if (strlen(Msg.Replyid)) 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, 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); rfcdate(Msg.Written), msgid, reply, bytecount, linecount);
} }

View File

@ -30,11 +30,14 @@
#include "../config.h" #include "../config.h"
#include "../lib/mbselib.h" #include "../lib/mbselib.h"
#include "ttyio.h" #include "ttyio.h"
#include "openport.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); signal(SIGHUP, linedrop);
Syslog('t', "SIGPIPE => sigpipe()"); Syslog('t', "SIGPIPE => sigpipe()");
signal(SIGPIPE, sigpipe); signal(SIGPIPE, sigpipe);
return 0;
if (isatty(0))
return tty_raw(0);
else
return 0;
} }
@ -78,51 +77,6 @@ int cookedport(void)
signal(SIGHUP, SIG_IGN); signal(SIGHUP, SIG_IGN);
Syslog('t', "SIGPIPE => SIG_IGN"); Syslog('t', "SIGPIPE => SIG_IGN");
signal(SIGPIPE, SIG_IGN); signal(SIGPIPE, SIG_IGN);
if (isatty(0)) return 0;
return tty_cooked();
else
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;
}

View File

@ -3,12 +3,8 @@
/* $Id$ */ /* $Id$ */
void linedrop(int);
void sigpipe(int);
int rawport(void); int rawport(void);
int cookedport(void); int cookedport(void);
int tty_raw(int);
int tty_cooked(void);
#endif #endif