From fc8735b3a185f275ed7f6c8a3523a43d034cf075 Mon Sep 17 00:00:00 2001 From: "Alexander S. Aganichev" Date: Sun, 4 Mar 2001 20:30:45 +0000 Subject: [PATCH] internet handling fixes --- docs/notework.txt | 16 +++++++++++++--- golded3/gccfgg.cpp | 1 + golded3/gccfgg.h | 1 + golded3/gccfgg0.cpp | 1 + golded3/gccfgg8.cpp | 14 ++++++++++++++ golded3/gcprot.h | 1 + golded3/gecfgg.h | 1 + golded3/gectrl.cpp | 21 ++++++++++----------- golded3/gedoit.cpp | 2 +- golded3/geedit.cpp | 2 ++ golded3/gehdre.cpp | 22 +++++++++++++--------- golded3/gemsgs.cpp | 12 ++++++++---- golded3/gepost.cpp | 24 +++++++++++++----------- golded3/geprot.h | 5 +++++ golded3/gerand.cpp | 5 +++++ golded3/getpls.cpp | 34 ++++++++++++++++++++-------------- golded3/geusrbse.cpp | 22 ++++++++++++++-------- golded3/gmarea.h | 2 ++ goldlib/gall/gutlgrp.h | 1 + 19 files changed, 126 insertions(+), 61 deletions(-) diff --git a/docs/notework.txt b/docs/notework.txt index da98c60..757124a 100644 --- a/docs/notework.txt +++ b/docs/notework.txt @@ -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. diff --git a/golded3/gccfgg.cpp b/golded3/gccfgg.cpp index 81600e2..74876f7 100644 --- a/golded3/gccfgg.cpp +++ b/golded3/gccfgg.cpp @@ -612,6 +612,7 @@ CfgGed::CfgGed() { // twitname.clear(); // twitsubj.clear(); // username.clear(); + // wtpl.clear(); // xlatcharset.clear(); // xlatescset.clear(); diff --git a/golded3/gccfgg.h b/golded3/gccfgg.h index 7200c4a..bb2f253 100644 --- a/golded3/gccfgg.h +++ b/golded3/gccfgg.h @@ -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; diff --git a/golded3/gccfgg0.cpp b/golded3/gccfgg0.cpp index 9d65621..dbe7f5f 100644 --- a/golded3/gccfgg0.cpp +++ b/golded3/gccfgg0.cpp @@ -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; diff --git a/golded3/gccfgg8.cpp b/golded3/gccfgg8.cpp index d751721..6c34655 100644 --- a/golded3/gccfgg8.cpp +++ b/golded3/gccfgg8.cpp @@ -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; diff --git a/golded3/gcprot.h b/golded3/gcprot.h index 6b8f74a..3913cea 100644 --- a/golded3/gcprot.h +++ b/golded3/gcprot.h @@ -357,6 +357,7 @@ void CfgViewkludge (); void CfgViewquote (); void CfgWhoto (); void CfgWildcatuserno (); +void CfgWritetemplate (); void CfgXlatcharset (); void CfgXlatescset (); void CfgXlatexport (); diff --git a/golded3/gecfgg.h b/golded3/gecfgg.h index 9c66c18..48a8c49 100644 --- a/golded3/gecfgg.h +++ b/golded3/gecfgg.h @@ -351,6 +351,7 @@ public: bool viewquote; Name whoto; int wildcatuserno; + string wtpl; vector xlatcharset; vector xlatescset; char xlatexport[17]; // exportcharset[17]; diff --git a/golded3/gectrl.cpp b/golded3/gectrl.cpp index c125a21..32bb52b 100644 --- a/golded3/gectrl.cpp +++ b/golded3/gectrl.cpp @@ -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); } } diff --git a/golded3/gedoit.cpp b/golded3/gedoit.cpp index d497498..466077f 100644 --- a/golded3/gedoit.cpp +++ b/golded3/gedoit.cpp @@ -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(); diff --git a/golded3/geedit.cpp b/golded3/geedit.cpp index ef7486a..923c1d9 100644 --- a/golded3/geedit.cpp +++ b/golded3/geedit.cpp @@ -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); diff --git a/golded3/gehdre.cpp b/golded3/gehdre.cpp index 8ebe515..8110fe7 100644 --- a/golded3/gehdre.cpp +++ b/golded3/gehdre.cpp @@ -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; diff --git a/golded3/gemsgs.cpp b/golded3/gemsgs.cpp index 6ec5469..3283c96 100644 --- a/golded3/gemsgs.cpp +++ b/golded3/gemsgs.cpp @@ -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()))) diff --git a/golded3/gepost.cpp b/golded3/gepost.cpp index 2f021b5..2710bd6 100644 --- a/golded3/gepost.cpp +++ b/golded3/gepost.cpp @@ -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); } } diff --git a/golded3/geprot.h b/golded3/geprot.h index 03bdbf6..5411458 100644 --- a/golded3/geprot.h +++ b/golded3/geprot.h @@ -442,6 +442,11 @@ inline char *spanfeeds(const char *str) { } +// ------------------------------------------------------------------ + +bool isuucp(const char *name); + + // ------------------------------------------------------------------ #endif diff --git a/golded3/gerand.cpp b/golded3/gerand.cpp index 0fa9b34..e6bb3be 100644 --- a/golded3/gerand.cpp +++ b/golded3/gerand.cpp @@ -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); diff --git a/golded3/getpls.cpp b/golded3/getpls.cpp index 4d81faf..281fd52 100644 --- a/golded3/getpls.cpp +++ b/golded3/getpls.cpp @@ -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::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::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); diff --git a/golded3/geusrbse.cpp b/golded3/geusrbse.cpp index 490532a..68dd996 100644 --- a/golded3/geusrbse.cpp +++ b/golded3/geusrbse.cpp @@ -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, " @")); diff --git a/golded3/gmarea.h b/golded3/gmarea.h index 5451573..8381773 100644 --- a/golded3/gmarea.h +++ b/golded3/gmarea.h @@ -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; } diff --git a/goldlib/gall/gutlgrp.h b/goldlib/gall/gutlgrp.h index 1081ec0..e0569e2 100644 --- a/goldlib/gall/gutlgrp.h +++ b/goldlib/gall/gutlgrp.h @@ -100,6 +100,7 @@ enum { GRP_VIEWKLUDGE, GRP_VIEWQUOTE, GRP_WHOTO, + GRP_WRITETEMPLATE, GRP_XLATEXPORT, GRP_XLATIMPORT,