internet handling fixes

This commit is contained in:
Alexander S. Aganichev 2001-03-04 20:30:45 +00:00
parent d9b791db8e
commit fc8735b3a1
19 changed files with 126 additions and 61 deletions

View File

@ -12,6 +12,17 @@ ______________________________________________________________________
Notes for GoldED+ 1.1.5, March xx 2001
______________________________________________________________________
+ Added new keyword WRITETEMPLATE which defines template to be used on
saving messages. Could be used in Random System Groups or globally.
+ You can explicitly select built-in template by defining "built-in".
! A lot of manipulations with Internet addressing was done. If at
least one person will be able to send message to expected
destination I'll be happy :-) If you'll find a bug please write me
a detailed guide (functional requirements specification :)) on how
everything should work.
! Fixed filelocking in UNIX version.
- Fixed "Via" kludge handling in JAM areas.
@ -47,9 +58,6 @@ ______________________________________________________________________
- Template keyword now properly extracts filename within random system
groups.
! If @ofrom or @oto is about to expanding to nothing they expanded to
real name of person (if available).
! @*addr macroses now expanded by default without domain, if you ever
need 5d addresses use @*addr{domain} scheme.
@ -83,6 +91,8 @@ ______________________________________________________________________
@odtime expanded according to MS_DateTimeFmt for original
message time
@cdtime current time in MS_DateTimeFmt format
@fpgp either e-mail or name from "From" field
@dpgp either e-mail or name from "To" field
- Fixed bug in expanding fixed lenght macroses.

View File

@ -612,6 +612,7 @@ CfgGed::CfgGed() {
// twitname.clear();
// twitsubj.clear();
// username.clear();
// wtpl.clear();
// xlatcharset.clear();
// xlatescset.clear();

View File

@ -373,6 +373,7 @@ const word CRC_VIEWKLUDGE = 0x4078;
const word CRC_VIEWQUOTE = 0x0AB3;
const word CRC_WHOTO = 0xB25F;
const word CRC_WILDCATUSERNO = 0xC2FE;
const word CRC_WRITETEMPLATE = 0xF4CB;
const word CRC_XLATCHARSET = 0xA860;
const word CRC_XLATESCSET = 0x4BA7;
const word CRC_XLATEXPORT = 0x29CB;

View File

@ -579,6 +579,7 @@ SwitchW:
switch(crc) {
case CRC_WHOTO : CfgWhoto (); break;
case CRC_WILDCATUSERNO : CfgWildcatuserno (); break;
case CRC_WRITETEMPLATE : CfgWritetemplate (); break;
default : found = false;
}
goto End;

View File

@ -435,6 +435,20 @@ void CfgWildcatuserno() {
// ------------------------------------------------------------------
void CfgWritetemplate() {
if(cfgingroup) {
Path buf;
strxcpy(buf, val, sizeof(buf));
CFG->grp.AddItm(GRP_WRITETEMPLATE, buf, strlen(buf)+1);
}
else {
CFG->wtpl = val;
}
}
// ------------------------------------------------------------------
void CfgXlatcharset() {
Map xlt;

View File

@ -357,6 +357,7 @@ void CfgViewkludge ();
void CfgViewquote ();
void CfgWhoto ();
void CfgWildcatuserno ();
void CfgWritetemplate ();
void CfgXlatcharset ();
void CfgXlatescset ();
void CfgXlatexport ();

View File

@ -351,6 +351,7 @@ public:
bool viewquote;
Name whoto;
int wildcatuserno;
string wtpl;
vector<Map> xlatcharset;
vector<Map> xlatescset;
char xlatexport[17]; // exportcharset[17];

View File

@ -35,6 +35,14 @@
int _use_fwd = true;
// ------------------------------------------------------------------
bool isuucp(const char *name) {
return strieql("UUCP", name) or (*AA->Internetgate().name and strieql(AA->Internetgate().name, name));
}
// ------------------------------------------------------------------
char* MakeOrigin(GMsg* msg, const char* orig) {
@ -537,17 +545,8 @@ void DoKludges(int mode, GMsg* msg, bool attronly) {
}
if(AA->isnet()) {
if(*msg->iaddr and not AA->isinternet()) {
if(not (CFG->internetgateexp == RFCAddress) and *msg->To() and (strpbrk(msg->iaddr, "<>()\"") == NULL) and not strieql(msg->To(), *AA->Internetgate().name ? AA->Internetgate().name : "UUCP")) {
Name name;
strcpy(name, msg->To());
if(CFG->internetgateexp == ((RFCName << 2) | RFCAddress))
sprintf(buf, "To: \"%s\" <%s>\r", StripQuotes(name), msg->iaddr);
else
sprintf(buf, "To: %s (%s)\r", msg->iaddr, StripQuotes(name));
}
else
sprintf(buf, "To: %s\r", msg->iaddr);
if(*msg->ito and not AA->isinternet()) {
sprintf(buf, "To: %s\r", msg->ito);
line = AddKludge(line, buf);
}
}

View File

@ -67,7 +67,7 @@ void SaveLines(int mode, const char* savefile, GMsg* msg, int margin, bool clip)
}
}
#else
TemplateToText(((mode == MODE_WRITE) and prnheader) ? ((prnheader & WRITE_ONLY_HEADER) ? MODE_HEADER : MODE_WRITEHEADER) : MODE_WRITE, msg, msg, AA->Tpl(), CurrArea);
TemplateToText(((mode == MODE_WRITE) and prnheader) ? ((prnheader & WRITE_ONLY_HEADER) ? MODE_HEADER : MODE_WRITEHEADER) : MODE_WRITE, msg, msg, AA->WTpl(), CurrArea);
msg->attr.tou1();
msg->TextToLines(margin);
msg->attr.tou0();

View File

@ -472,6 +472,8 @@ void IEclass::GoEOL() {
// Move cursor to the last char on the line
col = currline->txt.length();
if(currline->txt[col-1] == '\n')
--col;
// String must not be longer than the window width
_test_haltab(col > maxcol, col, maxcol);

View File

@ -305,23 +305,21 @@ bool GMsgHeaderEdit::validate() {
fromaddr.buf = ffromaddr->buf; fromaddr.update = false;
subj.buf = fsubj->buf; subj.update = false;
INam iaddr, realto;
strcpy(iaddr, msg->iaddr);
strcpy(realto, msg->realto);
string iaddr(msg->iaddr), realto(msg->realto);
bool res = set_to_address(msg, &toname, &toaddr, &fromaddr, &subj, 0, LNG->SelectDestNode, lookup);
vcurshow();
char bot2[200];
__extension__ char bot2[EDIT->HdrNodeLen()+1];
MakeAttrStr(bot2, sizeof(bot2), &msg->attr);
strsetsz(bot2, EDIT->HdrNodeLen());
window.prints(1, EDIT->HdrNodePos(), C_HEADW, bot2);
// once we changed name invalidate realto and internet address
if(not strieql(orig_toname.c_str(), toname.buf)) {
if(strieql(realto, msg->realto))
if(strieql(realto.c_str(), msg->realto))
*msg->realto = NUL;
if(not AA->isinternet() and strieql(iaddr, msg->iaddr))
if(not AA->isinternet() and strieql(iaddr.c_str(), msg->iaddr))
*msg->iaddr = NUL;
}
@ -445,7 +443,7 @@ int EditHeaderinfo(int mode, GMsgHeaderView &view) {
to_name = tmp_to_name;
if(AA->isinternet()) {
strcpy(msg->to, to_name.c_str());
strcpy(msg->to, *AA->Internetgate().name ? AA->Internetgate().name : to_name.c_str());
strcpy(msg->realby, msg->by);
strcpy(msg->realto, msg->to);
strcpy(msg->iorig, from_addr.c_str());
@ -481,15 +479,21 @@ int EditHeaderinfo(int mode, GMsgHeaderView &view) {
strcpy(msg->to, to_name.c_str());
if(*msg->iaddr) {
if(*msg->To() and (strpbrk(msg->iaddr, "<>()\"") == NULL) and not strieql(msg->To(), *AA->Internetgate().name ? AA->Internetgate().name : "UUCP")) {
if(not (CFG->internetgateexp == RFCAddress) and *msg->To() and (strpbrk(msg->iaddr, "<>()\"") == NULL) and not isuucp(msg->To())) {
Name name;
strcpy(name, msg->To());
sprintf(msg->ito, "%s (%s)", msg->iaddr, StripQuotes(name));
if(CFG->internetgateexp == ((RFCName << 2) | RFCAddress))
sprintf(msg->ito, "\"%s\" <%s>", StripQuotes(name), msg->iaddr);
else
sprintf(msg->ito, "%s (%s)", msg->iaddr, StripQuotes(name));
}
else
strcpy(msg->ito, msg->iaddr);
}
if(not *msg->realto and isuucp(msg->to))
strcpy(msg->realto, strlword(msg->iaddr, "@"));
Addr address;
address = AA->Aka().addr;

View File

@ -174,9 +174,9 @@ char* TokenXlat(int mode, char* input, GMsg* msg, GMsg* oldmsg, int __origarea)
continue;
if(tokenxchg(dst, "@otzoffset", (oldmsg->tzutc == -32767) ? "" : (sprintf(buf, " %+05d", oldmsg->tzutc), buf)))
continue;
if(tokenxchg(dst, "@ofrom", *oldmsg->ifrom ? oldmsg->ifrom : oldmsg->By()))
if(tokenxchg(dst, "@ofrom", oldmsg->ifrom))
continue;
if(tokenxchg(dst, "@oto", *oldmsg->ito ? oldmsg->ito : oldmsg->To()))
if(tokenxchg(dst, "@oto", oldmsg->ito))
continue;
if(tokenxchg(dst, "@omessageid", oldmsg->messageid ? oldmsg->messageid : ""))
continue;
@ -185,6 +185,8 @@ char* TokenXlat(int mode, char* input, GMsg* msg, GMsg* oldmsg, int __origarea)
if(tokenxchg(dst, "@dname", strbtrim(strtmp(oldmsg->To())), 34, 3,
msg->to_me(), msg->to_you(), oldmsg->to_all()))
continue;
if(tokenxchg(dst, "@dpgp", *msg->iaddr ? msg->iaddr : msg->To()))
continue;
if(tokenxchg(dst, "@dfname", strlword(oldmsg->To()), 0, 3,
msg->to_me(), msg->to_you(), oldmsg->to_all()))
continue;
@ -268,9 +270,9 @@ char* TokenXlat(int mode, char* input, GMsg* msg, GMsg* oldmsg, int __origarea)
continue;
if(tokenxchg(dst, "@clname", strrword(strcpy(buf, AA->Username().name))))
continue;
if(tokenxchg(dst, "@cfrom", *msg->ifrom ? msg->ifrom : msg->By()))
if(tokenxchg(dst, "@cfrom", msg->ifrom))
continue;
if(tokenxchg(dst, "@cto", *msg->ito ? msg->ito : msg->To()))
if(tokenxchg(dst, "@cto", msg->ito))
continue;
if(tokenxchg(dst, "@cdate", cdate))
continue;
@ -282,6 +284,8 @@ char* TokenXlat(int mode, char* input, GMsg* msg, GMsg* oldmsg, int __origarea)
continue;
if(tokenxchg(dst, "@fname", strbtrim(strtmp(msg->By())), 34))
continue;
if(tokenxchg(dst, "fpgp", *msg->iorig ? msg->iorig : msg->By()))
continue;
if(tokenxchg(dst, "@ffname", strlword(msg->By())))
continue;
if(tokenxchg(dst, "@flname", strrword(msg->By())))

View File

@ -832,7 +832,7 @@ void MakeMsg(int mode, GMsg* omsg, bool ignore_replyto) {
omsg->attr.tou0();
omsg->TextToLines(-CFG->quotemargin);
if(ignore_replyto)
omsg->ireplyto[0] = NUL;
*omsg->ireplyto = NUL;
if(omsg->attr.rot())
Rot13(omsg);
// Drop through
@ -859,14 +859,12 @@ void MakeMsg(int mode, GMsg* omsg, bool ignore_replyto) {
}
// Do aka matching
{
if(AA->Akamatching()) {
// ... but only if we did NOT change aka manually
if(AA->Aka().addr.equals(AA->aka())) {
Addr aka_addr = AA->Aka().addr;
AkaMatch(&aka_addr, &omsg->orig);
AA->SetAka(aka_addr);
}
if(AA->Akamatching()) {
// ... but only if we did NOT change aka manually
if(AA->Aka().addr.equals(AA->aka())) {
Addr aka_addr = AA->Aka().addr;
AkaMatch(&aka_addr, &omsg->orig);
AA->SetAka(aka_addr);
}
}
@ -882,6 +880,8 @@ void MakeMsg(int mode, GMsg* omsg, bool ignore_replyto) {
msg->dest = omsg->orig;
strcpy(msg->idest, *omsg->ireplyto ? omsg->ireplyto : omsg->iorig);
}
if(not *msg->iaddr)
strcpy(msg->iaddr, msg->idest);
strcpy(msg->re, omsg->re);
if(AA->Replyre() or AA->isinternet()) {
@ -928,13 +928,15 @@ void MakeMsg(int mode, GMsg* omsg, bool ignore_replyto) {
msg->dest.set(msg->igate);
char* ptr = strchr(msg->igate, ' ');
if(ptr) {
strcpy(msg->realto, msg->to);
if(not isuucp(msg->to))
strcpy(msg->realto, msg->to);
strcpy(msg->to, strskip_wht(ptr));
}
}
}
else if(*omsg->iaddr and (strlen(omsg->iaddr) < sizeof(Name))) {
strcpy(msg->realto, msg->to);
if(not isuucp(msg->to))
strcpy(msg->realto, msg->to);
strcpy(msg->to, omsg->iaddr);
}
}

View File

@ -442,6 +442,11 @@ inline char *spanfeeds(const char *str) {
}
// ------------------------------------------------------------------
bool isuucp(const char *name);
// ------------------------------------------------------------------
#endif

View File

@ -310,6 +310,11 @@ void Area::RandomizeData(int mode) {
strxcpy(adat->tpl, buf, sizeof(adat->tpl));
}
}
if(CFG->grp.GetItm(GRP_WRITETEMPLATE, buf, sizeof(buf))) {
if(*buf == '@')
GetRandomLine(buf, sizeof(buf), buf+1);
strxcpy(adat->wtpl, buf, sizeof(adat->wtpl));
}
CFG->grp.GetItm(GRP_TEMPLATEMATCH, adat->templatematch);
CFG->grp.GetItm(GRP_TWITMODE, adat->twitmode);

View File

@ -179,24 +179,30 @@ int TemplateToText(int mode, GMsg* msg, GMsg* oldmsg, const char* tpl, int origa
strcpy(tplfile, tpl);
if(AA->Templatematch() and not (CFG->tplno or AA->isnewsgroup() or AA->isemail())) {
if(not ((mode == MODE_NEW or mode == MODE_REPLYCOMMENT or mode == MODE_FORWARD)
and (AA->isecho() or AA->islocal()))) {
vector<Tpl>::iterator tp;
for(tp = CFG->tpl.begin(); tp != CFG->tpl.end(); tp++)
if(tp->match.net and msg->dest.match(tp->match)) {
strcpy(tplfile, tp->file);
break;
}
if((mode != MODE_WRITEHEADER) and (mode != MODE_WRITE) and (mode != MODE_HEADER)) {
if(AA->Templatematch() and not (CFG->tplno or AA->isnewsgroup() or AA->isemail())) {
if(not ((mode == MODE_NEW or mode == MODE_REPLYCOMMENT or mode == MODE_FORWARD)
and (AA->isecho() or AA->islocal()))) {
vector<Tpl>::iterator tp;
for(tp = CFG->tpl.begin(); tp != CFG->tpl.end(); tp++)
if(tp->match.net and msg->dest.match(tp->match)) {
strcpy(tplfile, tp->file);
break;
}
}
}
}
if(tplfile == CleanFilename(tplfile))
strcpy(tplfile, AddPath(CFG->templatepath, tplfile));
if(not strieql(tplfile, "built-in")) {
if(tplfile == CleanFilename(tplfile))
strcpy(tplfile, AddPath(CFG->templatepath, tplfile));
if(not fexist(tplfile) and not CFG->tpl.empty())
strcpy(tplfile, AddPath(CFG->templatepath, CFG->tpl[CFG->tplno].file));
if(not fexist(tplfile) or CFG->tpl.empty()) {
if((mode != MODE_WRITEHEADER) and (mode != MODE_WRITE) and (mode != MODE_HEADER)) {
if(not fexist(tplfile) and not CFG->tpl.empty())
strcpy(tplfile, AddPath(CFG->templatepath, CFG->tpl[CFG->tplno].file));
}
}
if(strieql(tplfile, "built-in") or not fexist(tplfile) or CFG->tpl.empty()) {
tmptpl = YES; // Create a temporary template
mktemp(strcpy(tplfile, AddPath(CFG->templatepath, "GDXXXXXX")));
fp = fsopen(tplfile, "wt", CFG->sharemode);

View File

@ -715,7 +715,7 @@ void guserbase::update_addressbook(GMsg* msg, bool reverse, bool force) {
INam name;
strcpy(name, (reverse ? msg->By() : msg->To()));
strcpy(iaddr, (reverse ? msg->iorig : msg->idest));
strcpy(iaddr, (reverse ? (*msg->iorig ? msg->iorig : msg->iaddr) : msg->idest));
fidoaddr = (reverse ? msg->orig : msg->dest);
if(not strblank(name)) {
@ -755,7 +755,7 @@ void guserbase::update_addressbook(GMsg* msg, bool reverse, bool force) {
}
// 6. It's a UUCP name
if(strieql("UUCP", name) or (*AA->Internetgate().name and strieql(AA->Internetgate().name, name)))
if(isuucp(name))
return;
// 7. If it is already an email address
@ -815,7 +815,17 @@ bool guserbase::lookup_addressbook(GMsg* msg, char* name, char* aka, bool browse
found = true;
strcpy(name, entry.name);
if(*msg->iaddr and not AA->isinternet()) {
// do UUCP addressing
strcpy(msg->realto, entry.name);
if(*AA->Internetgate().name)
strcpy(name, AA->Internetgate().name);
else
strcpy(name, entry.name);
}
else
strcpy(name, entry.name);
if(not strblank(entry.pseudo))
strcpy(msg->pseudoto, entry.pseudo);
@ -826,14 +836,10 @@ bool guserbase::lookup_addressbook(GMsg* msg, char* name, char* aka, bool browse
else {
entry.fidoaddr.make_string(aka);
if(strblank(aka) and not strblank(entry.iaddr)) {
// do UUCP addressing
strcpy(msg->realto, entry.name);
strcpy(msg->idest, entry.iaddr);
strcpy(msg->iaddr, entry.iaddr);
if(AA->Internetgate().addr.valid())
AA->Internetgate().addr.make_string(aka);
if(*AA->Internetgate().name)
strcpy(name, AA->Internetgate().name);
}
}
}
@ -849,7 +855,7 @@ bool guserbase::lookup_addressbook(GMsg* msg, char* name, char* aka, bool browse
void guserbase::build_pseudo(GMsg* msg, char* name, char* aka, bool direction) {
if(*msg->iaddr and strieql("UUCP", name) or (*AA->Internetgate().name and strieql(AA->Internetgate().name, name)))
if(*msg->iaddr and isuucp(name))
strcpy(direction ? msg->pseudoto : msg->pseudofrom, strlword(msg->iaddr, " @"));
else
strcpy(direction ? msg->pseudoto : msg->pseudofrom, strlword(name, " @"));

View File

@ -310,6 +310,7 @@ struct AreaData {
Node username;
bool usetzutc;
IAdr whoto;
Path wtpl;
XlatName xlatexport;
XlatName xlatimport;
@ -569,6 +570,7 @@ public:
bool Viewkludge() const { return adat->viewkludge; }
bool Viewquote() const { return adat->viewquote; }
const char* Whoto() const { return adat->whoto; }
const char* WTpl() const { return adat->wtpl; }
const char* Xlatexport() const { return adat->xlatexport; }
const char* Xlatimport() const { return adat->xlatimport; }

View File

@ -100,6 +100,7 @@ enum {
GRP_VIEWKLUDGE,
GRP_VIEWQUOTE,
GRP_WHOTO,
GRP_WRITETEMPLATE,
GRP_XLATEXPORT,
GRP_XLATIMPORT,