extract built-in template text from function code into new header file getpls.h and optimise built-in template

This commit is contained in:
Stas Degteff 2012-05-05 20:54:11 +00:00
parent 15cecc91ac
commit e17a990f8d
2 changed files with 99 additions and 2 deletions

View File

@ -32,6 +32,7 @@
#endif #endif
#include <algorithm> #include <algorithm>
#include <golded.h> #include <golded.h>
#include <getpls.h>
#if defined(__USE_ALLOCA__) #if defined(__USE_ALLOCA__)
#include <malloc.h> #include <malloc.h>
@ -236,16 +237,23 @@ int TemplateToText(int mode, GMsg* msg, GMsg* oldmsg, const char* tpl, int origa
fp.Fopen(tplfile, "wt", CFG->sharemode); fp.Fopen(tplfile, "wt", CFG->sharemode);
if (fp.isopen()) if (fp.isopen())
{ {
fp.Fputs(TPL_BUILTIN_TOP_MAIN);
/*
fp.Fputs("@header= @oecho (@caddr) @align{79}{=}\n" fp.Fputs("@header= @oecho (@caddr) @align{79}{=}\n"
"@header Msg : @msgno of @msgs@align{44}@attr\n"); "@header Msg : @msgno of @msgs@align{44}@attr\n");
*/
if (AA->isinternet()) if (AA->isinternet())
{ {
fp.Fputs(TPL_BUILTIN_TOP_INTERNET);
/*
fp.Fputs("@header From : @ofrom@align{60}@odtime\n" fp.Fputs("@header From : @ofrom@align{60}@odtime\n"
"@header To : @oto\n"); "@header To : @oto\n");
*/
} }
else else
{ {
fp.Fputs(TPL_BUILTIN_TOP_FTN);
/*
fp.Fputs("@header From : @oname@align{44}@oaddr@align{60}@odtime\n"); fp.Fputs("@header From : @oname@align{44}@oaddr@align{60}@odtime\n");
if (AA->isnet()) if (AA->isnet())
@ -253,7 +261,9 @@ int TemplateToText(int mode, GMsg* msg, GMsg* oldmsg, const char* tpl, int origa
else else
fp.Fputs("@header To : @dname\n"); fp.Fputs("@header To : @dname\n");
} }
*/
fp.Fputs(TPL_BUILTIN_BODY);
/*
fp.Fputs("@header Subj : @subject\n" fp.Fputs("@header Subj : @subject\n"
"@header@align{79}{=}\n" "@header@align{79}{=}\n"
"@moved* Replying to a msg in @oecho (@odesc)\n@moved\n" "@moved* Replying to a msg in @oecho (@odesc)\n@moved\n"
@ -278,6 +288,7 @@ int TemplateToText(int mode, GMsg* msg, GMsg* oldmsg, const char* tpl, int origa
"@quotebuf\n" "@quotebuf\n"
"@quote\n\n" "@quote\n\n"
"@cfname\n\n"); "@cfname\n\n");
*/
fp.Fclose(); fp.Fclose();
} }
} // built-in template } // built-in template

86
golded3/getpls.h Normal file
View File

@ -0,0 +1,86 @@
// ------------------------------------------------------------------
// GoldED+
// Copyright (C) 1990-1999 Odinn Sorensen
// Copyright (C) 1999-2000 Alexander S. Aganichev
// Copyright (C) 2012 Golded+ team
// ------------------------------------------------------------------
// This program 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 of the
// License, or (at your option) any later version.
//
// This program 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 this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston,
// MA 02111-1307 USA
// ------------------------------------------------------------------
// $Id$
// ------------------------------------------------------------------
// Template handling definitions.
// ------------------------------------------------------------------
// top lines of built-in template
#define TPL_BUILTIN_TOP_MAIN \
"@header= @oecho (@caddr) @align{79}{=}\n" \
"@header Msg : @msgno of @msgs@align{44}@attr\n"
// second lines of built-in template, only for email/news areas
#define TPL_BUILTIN_TOP_INTERNET \
"@header From : @ofrom@align{60}@odtime\n" \
"@header To : @oto\n"
// second lines of built-in template, only for FTN areas
#define TPL_BUILTIN_TOP_FTN_FROM \
"@header From : @oname@align{44}@oaddr@align{60}@odtime\n"
// third lines of built-in template, only for FTN NETMAIL areas
#define TPL_BUILTIN_TOP_FTN_TO_NETMAIL \
"@header To : @dname@align{44}@daddr\n"
// third lines of built-in template, only for FTN non-NETMAIL areas
#define TPL_BUILTIN_TOP_FTN_TO_NOTNETMAIL \
"@header To : @dname\n" \
// alternate lines of built-in template, only for FTN (all areas)
#define TPL_BUILTIN_TOP_FTN \
"@header From : @oname@align{44}@oaddr@align{60}@odtime\n"
"@net@header To : @dname@align{44}@daddr\n" \
"@echo@header To : @dname\n" \
"@local@header To : @dname\n"
// rest lines of built-in template, for all cases
#define TPL_BUILTIN_BODY \
"@header Subj : @subject\n" \
"@header@align{79}{=}\n" \
"@moved* Replying to a msg in @oecho (@odesc)\n@moved\n" \
"@changed* Changed by @cname (@caddr), @cdate @ctime.\n" \
"@changed\n" \
"@forward* Forwarded from @oecho by @fname (@faddr).\n" \
"@forward* Originally by: @oname (@oaddr), @odate @otime.\n" \
"@forward* Originally to: @dname{}{}{all}.\n" \
"@forward\n" \
"@message\n" \
"@forward\n" \
"\n" \
" Hello @pseudo{}{}{everybody}!\n" \
"@new\n" \
"@position\n" \
"@replyReplying to a msg dated @odate @otime, from @oname{me}{you} to @dname{me}{you}{all}.\n" \
"@reply@position\n" \
"@quoted@odate @otime, @oname{I}{you} wrote to @dname{me}{you}{all}:\n" \
"@quoted@position\n" \
"@comment@odate @otime, @oname{I}{you} wrote to @dname{me}{you}{all}:\n" \
"@comment@position\n" \
"@quotebuf\n" \
"@quotebuf@odate @otime, @oname{I}{you} wrote to @dname{me}{you}{all}:\n" \
"@quotebuf\n" \
"@quote\n\n" \
"@cfname\n\n" \
"\n"