2000-02-25 11:04:07 +00:00
|
|
|
|
|
|
|
// ------------------------------------------------------------------
|
|
|
|
// GoldED+
|
|
|
|
// Copyright (C) 1990-1999 Odinn Sorensen
|
|
|
|
// Copyright (C) 1999-2000 Alexander S. Aganichev
|
|
|
|
// ------------------------------------------------------------------
|
|
|
|
// 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$
|
|
|
|
// ------------------------------------------------------------------
|
|
|
|
// Various major job handling funcs
|
|
|
|
// ------------------------------------------------------------------
|
|
|
|
|
|
|
|
#include <golded.h>
|
|
|
|
#include <gutlclip.h>
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------
|
|
|
|
|
2006-04-26 17:06:23 +00:00
|
|
|
static gfile prnfp;
|
2000-02-25 11:04:07 +00:00
|
|
|
static int prnheader;
|
|
|
|
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------
|
|
|
|
|
2001-03-03 13:16:14 +00:00
|
|
|
void SaveLines(int mode, const char* savefile, GMsg* msg, int margin, bool clip) {
|
2000-02-25 11:04:07 +00:00
|
|
|
|
|
|
|
int prn=NO;
|
|
|
|
char fnam[GMAXPATH];
|
|
|
|
char* prnacc;
|
|
|
|
|
2001-03-03 13:16:14 +00:00
|
|
|
if(mode == MODE_APPEND) {
|
2000-02-25 11:04:07 +00:00
|
|
|
prnacc = "at";
|
|
|
|
mode = MODE_WRITE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
prnacc = "wt";
|
|
|
|
|
|
|
|
strcpy(fnam, "PRN");
|
2000-04-05 15:44:02 +00:00
|
|
|
if(mode == MODE_WRITE and streql(savefile, "\001PRN"))
|
2000-02-25 11:04:07 +00:00
|
|
|
prn = YES;
|
2006-04-26 17:06:23 +00:00
|
|
|
else
|
|
|
|
{
|
2000-02-25 11:04:07 +00:00
|
|
|
strcpy(fnam, savefile);
|
|
|
|
strschg_environ(fnam);
|
2006-04-26 17:06:23 +00:00
|
|
|
prnfp.Fopen(fnam, prnacc, CFG->sharemode);
|
2000-02-25 11:04:07 +00:00
|
|
|
}
|
|
|
|
int lines=0;
|
2006-04-26 17:06:23 +00:00
|
|
|
if (prnfp.isopen())
|
|
|
|
{
|
2002-05-10 05:06:56 +00:00
|
|
|
char *old_msg_txt = throw_strdup(msg->txt);
|
2001-02-24 18:37:28 +00:00
|
|
|
#ifdef OLD_STYLE_HEADER
|
2000-02-25 11:04:07 +00:00
|
|
|
if(mode == MODE_WRITE) {
|
2001-03-03 13:16:14 +00:00
|
|
|
if(prnheader) {
|
|
|
|
DispHeader(msg, prn, prnfp, margin);
|
|
|
|
if(prn)
|
|
|
|
lines = 6;
|
|
|
|
}
|
2000-02-25 11:04:07 +00:00
|
|
|
}
|
2001-02-24 18:37:28 +00:00
|
|
|
#else
|
2001-11-02 10:09:23 +00:00
|
|
|
if(mode == MODE_WRITE) {
|
|
|
|
if(AA->LoadMsg(msg, msg->msgno, margin) == false) {
|
|
|
|
msg->txt = throw_strdup("");
|
|
|
|
msg->TextToLines(margin);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if((mode == MODE_SAVE) or (mode == MODE_SAVENOCTRL)) {
|
|
|
|
msg->TextToLines(margin);
|
|
|
|
}
|
2001-03-04 20:30:45 +00:00
|
|
|
TemplateToText(((mode == MODE_WRITE) and prnheader) ? ((prnheader & WRITE_ONLY_HEADER) ? MODE_HEADER : MODE_WRITEHEADER) : MODE_WRITE, msg, msg, AA->WTpl(), CurrArea);
|
2001-11-13 11:35:21 +00:00
|
|
|
msg->TextToLines(margin, false);
|
2001-02-24 18:37:28 +00:00
|
|
|
#endif
|
2000-02-25 11:04:07 +00:00
|
|
|
int n = 0;
|
|
|
|
Line** lin = msg->line;
|
2001-03-03 13:16:14 +00:00
|
|
|
if(lin) {
|
2000-02-25 11:04:07 +00:00
|
|
|
Line* line = lin[n];
|
|
|
|
while(line) {
|
2000-03-22 17:59:18 +00:00
|
|
|
uint lineisctrl = line->type & (GLINE_TEAR|GLINE_ORIG|GLINE_KLUDGE);
|
|
|
|
if(not ((mode == MODE_SAVENOCTRL) and lineisctrl)) {
|
2002-11-23 16:05:59 +00:00
|
|
|
if(mode == MODE_WRITE) {
|
|
|
|
for(std::string::iterator p = line->txt.begin(); p != line->txt.end(); p++) {
|
2000-03-22 17:59:18 +00:00
|
|
|
// Replace control codes, except the ANSI escape code
|
2000-12-24 19:47:06 +00:00
|
|
|
if(iscntrl(*p)) {
|
2000-03-22 17:59:18 +00:00
|
|
|
// only allow ESC in file write
|
|
|
|
if(prn or (*p != '\x1B')) {
|
|
|
|
*p = (*p == CTRL_A) ? '@' : '.';
|
2000-02-25 11:04:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2000-03-22 17:59:18 +00:00
|
|
|
}
|
|
|
|
const char *ptr = line->txt.c_str();
|
2006-04-26 17:06:23 +00:00
|
|
|
prnfp.Fwrite(ptr, strlen(ptr));
|
|
|
|
if (mode == MODE_NEW)
|
|
|
|
{
|
2000-03-22 17:59:18 +00:00
|
|
|
if(EDIT->HardLines()) {
|
|
|
|
if(line->type & GLINE_HARD) {
|
2006-04-26 17:06:23 +00:00
|
|
|
if (not ((line->type & (GLINE_TEAR|GLINE_ORIG|GLINE_KLUDGE|GLINE_QUOT)) or strblank(ptr)))
|
|
|
|
{
|
|
|
|
prnfp.Fwrite(EDIT->HardLine(), strlen(EDIT->HardLine()));
|
2000-02-25 11:04:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2000-03-22 17:59:18 +00:00
|
|
|
}
|
2006-04-26 17:06:23 +00:00
|
|
|
prnfp.Fwrite(prn ? NL : "\n", prn ? sizeof(NL) : 1);
|
|
|
|
if (prn)
|
|
|
|
{
|
2000-03-22 17:59:18 +00:00
|
|
|
lines++;
|
2006-04-26 17:06:23 +00:00
|
|
|
if (lines%CFG->printlength == 0 and CFG->switches.get(printformfeed))
|
|
|
|
prnfp.Fwrite("\f", 1);
|
2000-02-25 11:04:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
line = lin[++n];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Add an empty line and formfeed at the bottom
|
2006-04-26 17:06:23 +00:00
|
|
|
if (mode == MODE_WRITE)
|
|
|
|
prnfp.Fwrite(prn ? NL : "\n", prn ? sizeof(NL) : 1);
|
|
|
|
|
2000-02-25 11:04:07 +00:00
|
|
|
// Add formfeed if requested
|
2006-04-26 17:06:23 +00:00
|
|
|
if ((prn and CFG->switches.get(printformfeed)) or
|
|
|
|
(not prn and not clip and CFG->switches.get(formfeedseparator)))
|
|
|
|
{
|
|
|
|
prnfp.Fwrite("\f", 1);
|
2000-04-05 15:44:02 +00:00
|
|
|
}
|
2006-04-26 17:06:23 +00:00
|
|
|
|
|
|
|
prnfp.Fclose();
|
|
|
|
|
2002-05-10 05:06:56 +00:00
|
|
|
throw_release(msg->txt);
|
|
|
|
msg->txt = old_msg_txt;
|
2000-02-25 11:04:07 +00:00
|
|
|
}
|
2006-05-14 17:17:32 +00:00
|
|
|
else
|
|
|
|
{
|
2000-02-25 11:04:07 +00:00
|
|
|
char buf[256];
|
2006-05-14 17:17:32 +00:00
|
|
|
gsprintf(PRINTF_DECLARE_BUFFER(buf), LNG->CouldNotOpen, fnam);
|
2000-02-25 11:04:07 +00:00
|
|
|
w_info(buf);
|
|
|
|
waitkeyt(10000);
|
|
|
|
w_info(NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------
|
|
|
|
|
2000-04-05 15:44:02 +00:00
|
|
|
static void WriteMsgs(GMsg* msg) {
|
2000-02-25 11:04:07 +00:00
|
|
|
|
2001-03-03 13:16:14 +00:00
|
|
|
int prnmargin;
|
|
|
|
|
2000-02-25 11:04:07 +00:00
|
|
|
if(AA->Msgn.Tags() == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
GFTRK("WriteMsgs");
|
|
|
|
|
|
|
|
char buf[256];
|
|
|
|
char fname[GMAXPATH], ofname[GMAXPATH];
|
|
|
|
|
|
|
|
int overwrite = NO;
|
|
|
|
|
|
|
|
GMenuDomarks MenuDomarks;
|
|
|
|
int source = AA->Mark.Count() ? MenuDomarks.Run(LNG->Write) : WRITE_CURRENT;
|
|
|
|
|
|
|
|
if(source != WRITE_QUIT) {
|
|
|
|
|
|
|
|
GMenuWriteMsg MenuWriteMsg;
|
|
|
|
int target = MenuWriteMsg.Run();
|
|
|
|
|
|
|
|
if(target != WRITE_QUIT) {
|
|
|
|
|
|
|
|
prnheader = (target & (WRITE_NO_HEADER|WRITE_ONLY_HEADER)) ^ WRITE_NO_HEADER;
|
|
|
|
|
|
|
|
if(target & WRITE_PRINTER)
|
|
|
|
prnmargin = CFG->printmargin;
|
|
|
|
else
|
|
|
|
prnmargin = 79;
|
|
|
|
|
|
|
|
if(source == WRITE_MARKED) {
|
|
|
|
if(target & WRITE_FILE) {
|
|
|
|
do {
|
|
|
|
overwrite = NO;
|
|
|
|
strcpy(CFG->outputfile, AA->Outputfile());
|
|
|
|
if(not edit_pathname(CFG->outputfile, sizeof(Path), LNG->WriteMsgs, H_WriteMessage))
|
|
|
|
goto Finish;
|
|
|
|
if(is_dir(CFG->outputfile)) {
|
|
|
|
AddBackslash(CFG->outputfile);
|
|
|
|
strcat(CFG->outputfile, "golded.txt");
|
|
|
|
}
|
|
|
|
AA->SetOutputfile(CFG->outputfile);
|
|
|
|
w_infof(" %s ", AA->Outputfile());
|
|
|
|
if(stricmp(AA->Outputfile(), "PRN") and strnicmp(AA->Outputfile(), "LPT", 3))
|
|
|
|
if(fexist(AA->Outputfile())) {
|
|
|
|
GMenuOverwrite MenuOverwrite;
|
|
|
|
overwrite = MenuOverwrite.Run();
|
|
|
|
}
|
|
|
|
} while(overwrite == -1);
|
|
|
|
}
|
|
|
|
else if(target & WRITE_PRINTER) {
|
|
|
|
#ifdef __UNIX__
|
2006-04-26 17:06:23 +00:00
|
|
|
prnfp.Popen(CFG->printdevice, "w");
|
2000-02-25 11:04:07 +00:00
|
|
|
#else
|
2006-04-26 17:06:23 +00:00
|
|
|
prnfp.Fopen(CFG->printdevice, "wt", CFG->sharemode);
|
2000-02-25 11:04:07 +00:00
|
|
|
#endif
|
2006-04-26 17:06:23 +00:00
|
|
|
if (prnfp.isopen())
|
|
|
|
prnfp.Fwrite(CFG->printinit+1, CFG->printinit[0]);
|
2000-02-25 11:04:07 +00:00
|
|
|
}
|
|
|
|
else if(target & WRITE_CLIPBRD) {
|
|
|
|
overwrite = YES;
|
|
|
|
strcpy(ofname, AA->Outputfile());
|
2001-12-15 23:56:43 +00:00
|
|
|
mktemp(strcpy(fname, AddPath(CFG->temppath, "GDXXXXXX")));
|
2000-02-25 11:04:07 +00:00
|
|
|
AA->SetOutputfile(fname);
|
|
|
|
}
|
|
|
|
w_info(NULL);
|
|
|
|
w_progress(MODE_NEW, C_INFOW, 0, AA->Mark.Count(), LNG->Writing);
|
|
|
|
for(uint n=0; n<AA->Mark.Count(); n++) {
|
|
|
|
if(overwrite and n)
|
|
|
|
overwrite = NO; // Overwrite only the first time
|
|
|
|
if(kbxhit()) {
|
|
|
|
if(kbxget() == Key_Esc) {
|
|
|
|
HandleGEvent(EVTT_JOBFAILED);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2006-01-10 23:53:52 +00:00
|
|
|
update_statuslinef(LNG->WritingMsg, "ST_WRITINGMSG", n+1, AA->Mark.Count());
|
2000-02-25 11:04:07 +00:00
|
|
|
w_progress(MODE_UPDATE, C_INFOW, n+1, AA->Mark.Count(), LNG->Writing);
|
|
|
|
AA->LoadMsg(msg, AA->Mark[n], prnmargin);
|
2006-05-13 16:15:35 +00:00
|
|
|
if (target & WRITE_PRINTER)
|
|
|
|
{
|
|
|
|
if (prnfp.isopen())
|
2001-03-03 13:16:14 +00:00
|
|
|
SaveLines(MODE_WRITE, "\001PRN", msg, prnmargin);
|
2000-02-25 11:04:07 +00:00
|
|
|
}
|
|
|
|
else {
|
2005-10-25 06:11:09 +00:00
|
|
|
SaveLines(overwrite ? MODE_WRITE : MODE_APPEND, AA->Outputfile(), msg, prnmargin, make_bool(target & WRITE_CLIPBRD));
|
2000-02-25 11:04:07 +00:00
|
|
|
}
|
|
|
|
}
|
2006-04-26 17:06:23 +00:00
|
|
|
if (prnfp.isopen())
|
|
|
|
prnfp.Fwrite(CFG->printreset+1, CFG->printreset[0]);
|
|
|
|
if (target & WRITE_CLIPBRD)
|
|
|
|
{
|
2000-02-25 11:04:07 +00:00
|
|
|
AA->SetOutputfile(ofname);
|
|
|
|
|
|
|
|
gclipbrd clipbrd;
|
2006-04-24 16:38:44 +00:00
|
|
|
gfile fp(fname, "rb");
|
2000-02-25 11:04:07 +00:00
|
|
|
|
2006-04-24 16:38:44 +00:00
|
|
|
if (fp.isopen())
|
|
|
|
{
|
|
|
|
long len = fp.FileLength();
|
2000-02-25 11:04:07 +00:00
|
|
|
char* buf = (char*) throw_malloc(len+1);
|
|
|
|
buf[len] = NUL;
|
2006-04-24 16:38:44 +00:00
|
|
|
fp.Fread(buf, len);
|
2000-02-25 11:04:07 +00:00
|
|
|
|
|
|
|
clipbrd.writeclipbrd(buf);
|
|
|
|
|
|
|
|
throw_free(buf);
|
|
|
|
|
2006-04-24 16:38:44 +00:00
|
|
|
fp.Fclose();
|
2000-02-25 11:04:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
remove(fname);
|
|
|
|
}
|
2006-01-20 00:15:05 +00:00
|
|
|
w_progress(MODE_QUIT, BLACK_|_BLACK, 0, 0, NULL);
|
2000-02-25 11:04:07 +00:00
|
|
|
}
|
|
|
|
else if(source == WRITE_CURRENT) {
|
|
|
|
if(target & WRITE_FILE) {
|
|
|
|
do {
|
|
|
|
overwrite = NO;
|
|
|
|
strcpy(CFG->outputfile, AA->Outputfile());
|
|
|
|
if(edit_pathname(CFG->outputfile, sizeof(Path), LNG->WriteMsgs, H_WriteMessage)) {
|
|
|
|
if(is_dir(CFG->outputfile)) {
|
|
|
|
AddBackslash(CFG->outputfile);
|
|
|
|
strcat(CFG->outputfile, "golded.txt");
|
|
|
|
}
|
|
|
|
AA->SetOutputfile(CFG->outputfile);
|
|
|
|
w_infof(" %s ", AA->Outputfile());
|
|
|
|
if(stricmp(AA->Outputfile(), "PRN") and strnicmp(AA->Outputfile(), "LPT", 3)) {
|
|
|
|
if(fexist(AA->Outputfile())) {
|
|
|
|
GMenuOverwrite MenuOverwrite;
|
|
|
|
overwrite = MenuOverwrite.Run();
|
|
|
|
if(overwrite == -1) // Escape was hit
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
2006-05-14 17:17:32 +00:00
|
|
|
gsprintf(PRINTF_DECLARE_BUFFER(buf), LNG->WritingFile, AA->Outputfile());
|
2000-02-25 11:04:07 +00:00
|
|
|
w_info(buf);
|
|
|
|
AA->LoadMsg(msg, msg->msgno, prnmargin);
|
2001-03-03 13:16:14 +00:00
|
|
|
SaveLines(overwrite ? MODE_WRITE : MODE_APPEND, AA->Outputfile(), msg, prnmargin);
|
2000-02-25 11:04:07 +00:00
|
|
|
w_info(NULL);
|
|
|
|
}
|
|
|
|
} while(overwrite == -1);
|
|
|
|
}
|
|
|
|
else if(target & WRITE_PRINTER) {
|
|
|
|
w_info(LNG->WritingPRN);
|
|
|
|
AA->LoadMsg(msg, msg->msgno, prnmargin);
|
|
|
|
#ifdef __UNIX__
|
2006-04-26 17:06:23 +00:00
|
|
|
prnfp.Popen(CFG->printdevice, "w");
|
2000-02-25 11:04:07 +00:00
|
|
|
#else
|
2006-04-26 17:06:23 +00:00
|
|
|
prnfp.Fopen(CFG->printdevice, "wt", CFG->sharemode);
|
2000-02-25 11:04:07 +00:00
|
|
|
#endif
|
2006-04-26 17:06:23 +00:00
|
|
|
if (prnfp.isopen())
|
|
|
|
{
|
|
|
|
prnfp.Fwrite(CFG->printinit+1, CFG->printinit[0]);
|
2001-03-03 13:16:14 +00:00
|
|
|
SaveLines(MODE_WRITE, "\001PRN", msg, prnmargin);
|
2006-04-26 17:06:23 +00:00
|
|
|
prnfp.Fwrite(CFG->printreset+1, CFG->printreset[0]);
|
2000-02-25 11:04:07 +00:00
|
|
|
}
|
|
|
|
w_info(NULL);
|
|
|
|
}
|
|
|
|
else if(target & WRITE_CLIPBRD) {
|
|
|
|
w_info(LNG->Wait);
|
|
|
|
|
2001-12-15 23:56:43 +00:00
|
|
|
mktemp(strcpy(fname, AddPath(CFG->temppath, "GDXXXXXX")));
|
2000-02-25 11:04:07 +00:00
|
|
|
|
|
|
|
AA->LoadMsg(msg, msg->msgno, prnmargin);
|
2001-03-03 13:16:14 +00:00
|
|
|
SaveLines(MODE_WRITE, fname, msg, prnmargin, true);
|
2000-02-25 11:04:07 +00:00
|
|
|
|
|
|
|
gclipbrd clipbrd;
|
2006-04-24 16:38:44 +00:00
|
|
|
gfile fp(fname, "rb");
|
2000-02-25 11:04:07 +00:00
|
|
|
|
2006-04-24 16:38:44 +00:00
|
|
|
if (fp.isopen())
|
|
|
|
{
|
|
|
|
long len = fp.FileLength();
|
2000-02-25 11:04:07 +00:00
|
|
|
char* buf = (char*) throw_malloc(len+1);
|
|
|
|
buf[len] = NUL;
|
2006-04-24 16:38:44 +00:00
|
|
|
fp.Fread(buf, len);
|
2000-02-25 11:04:07 +00:00
|
|
|
|
|
|
|
clipbrd.writeclipbrd(buf);
|
|
|
|
|
|
|
|
throw_free(buf);
|
|
|
|
|
2006-04-24 16:38:44 +00:00
|
|
|
fp.Fclose();
|
2000-02-25 11:04:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
remove(fname);
|
|
|
|
w_info(NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Finish:
|
|
|
|
|
|
|
|
w_info(NULL);
|
|
|
|
|
2006-04-26 17:06:23 +00:00
|
|
|
#ifdef __UNIX__
|
|
|
|
prnfp.Pclose();
|
|
|
|
#else
|
|
|
|
prnfp.Fclose();
|
|
|
|
#endif
|
2000-02-25 11:04:07 +00:00
|
|
|
|
2006-05-14 11:45:05 +00:00
|
|
|
GFTRK(0);
|
2000-02-25 11:04:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------
|
|
|
|
|
|
|
|
void WriteMsg(GMsg* msg) {
|
|
|
|
|
|
|
|
if(AA->Msgn.Count())
|
|
|
|
WriteMsgs(msg);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------
|
|
|
|
// Get name of current quotebuffer filename
|
|
|
|
|
|
|
|
char* GetCurrQuotebuf(char* quotebuf) {
|
|
|
|
|
|
|
|
if(*AA->Quotebuffile()) {
|
|
|
|
strcpy(quotebuf, AA->Quotebuffile());
|
|
|
|
MakePathname(quotebuf, CFG->goldpath, quotebuf);
|
|
|
|
}
|
|
|
|
else {
|
2003-12-10 08:35:16 +00:00
|
|
|
if(streql(AA->basetype(), "EZYCOM"))
|
2000-02-25 11:04:07 +00:00
|
|
|
sprintf(quotebuf, "%sgld%05u.qbf", CFG->ezycom.msgbasepath, AA->board());
|
2003-12-10 08:35:16 +00:00
|
|
|
else if(streql(AA->basetype(), "FTS1") or streql(AA->basetype(), "OPUS"))
|
2000-02-25 11:04:07 +00:00
|
|
|
sprintf(quotebuf, "%s%s", AA->path(), "golded.qbf");
|
2003-12-10 08:35:16 +00:00
|
|
|
else if(streql(AA->basetype(), "GOLDBASE"))
|
2000-02-25 11:04:07 +00:00
|
|
|
sprintf(quotebuf, "%sgoldg%03u.qbf", CFG->goldbasepath, AA->board());
|
2003-12-10 08:35:16 +00:00
|
|
|
else if(streql(AA->basetype(), "HUDSON"))
|
2000-02-25 11:04:07 +00:00
|
|
|
sprintf(quotebuf, "%sgoldh%03u.qbf", CFG->hudsonpath, AA->board());
|
|
|
|
else
|
|
|
|
sprintf(quotebuf, "%s%s", AA->path(), ".qbf");
|
|
|
|
}
|
|
|
|
|
|
|
|
return quotebuf;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------
|
|
|
|
|
|
|
|
void QuoteBuf(GMsg* msg) {
|
|
|
|
|
|
|
|
if(AA->Msgn.Count()) {
|
|
|
|
|
|
|
|
Path quotebuf;
|
|
|
|
char openmode[4];
|
|
|
|
|
|
|
|
TemplateToText(MODE_QUOTEBUF, msg, msg, AA->Tpl(), CurrArea);
|
2001-11-13 11:35:21 +00:00
|
|
|
msg->TextToLines(-CFG->quotemargin, false);
|
2000-02-25 11:04:07 +00:00
|
|
|
msg->charsetlevel = LoadCharset(CFG->xlatlocalset, CFG->xlatlocalset);
|
|
|
|
msg->LinesToText();
|
|
|
|
|
|
|
|
GetCurrQuotebuf(quotebuf);
|
|
|
|
w_infof(" %s ", quotebuf);
|
|
|
|
|
|
|
|
switch(CFG->quotebufmode) {
|
|
|
|
|
|
|
|
case QBUF_ASK:
|
|
|
|
*openmode = NUL;
|
|
|
|
if(fexist(quotebuf)) {
|
|
|
|
GMenuOverwrite MenuOverwrite;
|
|
|
|
switch(MenuOverwrite.Run()) {
|
|
|
|
case true:
|
|
|
|
strcpy(openmode, "wt");
|
|
|
|
break;
|
|
|
|
case false:
|
|
|
|
strcpy(openmode, "at");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
*openmode = NUL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
strcpy(openmode, "wt");
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case QBUF_APPEND:
|
|
|
|
strcpy(openmode, "at");
|
|
|
|
break;
|
|
|
|
|
|
|
|
case QBUF_OVERWRITE:
|
|
|
|
strcpy(openmode, "wt");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2006-04-26 17:06:23 +00:00
|
|
|
if (*openmode)
|
|
|
|
{
|
|
|
|
gfile fp(quotebuf, openmode, CFG->sharemode);
|
|
|
|
if (fp.isopen())
|
|
|
|
{
|
2000-02-25 11:04:07 +00:00
|
|
|
strchg(msg->txt, 0x0D, 0x0A);
|
2006-04-26 17:06:23 +00:00
|
|
|
fp.Fputs(msg->txt);
|
2000-02-25 11:04:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
HandleGEvent(EVTT_JOBDONE);
|
|
|
|
waitkeyt(1000);
|
|
|
|
}
|
|
|
|
w_info(NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------
|
|
|
|
|