1 //  This may look like C code, but it is really -*- C++ -*-
2 
3 //  ------------------------------------------------------------------
4 //  The Goldware Library
5 //  Copyright (C) 1990-1999 Odinn Sorensen
6 //  ------------------------------------------------------------------
7 //  This library is free software; you can redistribute it and/or
8 //  modify it under the terms of the GNU Library General Public
9 //  License as published by the Free Software Foundation; either
10 //  version 2 of the License, or (at your option) any later version.
11 //
12 //  This library is distributed in the hope that it will be useful,
13 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
14 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 //  Library General Public License for more details.
16 //
17 //  You should have received a copy of the GNU Library General Public
18 //  License along with this program; if not, write to the Free
19 //  Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
20 //  MA 02111-1307, USA
21 //  ------------------------------------------------------------------
22 //  $Id: gmosqsh5.cpp,v 1.6 2006/05/14 11:45:05 ssianky Exp $
23 //  ------------------------------------------------------------------
24 //  Squish msgbase handling and Maximus user functions.
25 //  ------------------------------------------------------------------
26 
27 #include <gdbgtrk.h>
28 #include <gmemall.h>
29 #include <gutlmisc.h>
30 #include <gstrall.h>
31 #include <gmosqsh.h>
32 
33 
34 //  ------------------------------------------------------------------
35 
user_lookup(char * __lookfor)36 char* SquishArea::user_lookup(char* __lookfor)
37 {
38   Path userfile;
39   strxcpy(userfile, AddPath(wide->userpath, "USER.BBS"), sizeof(Path));
40   wide->user->gufh = ::sopen(userfile, O_RDONLY|O_BINARY, WideSharemode, S_STDRD);
41   wide->user->findwild(__lookfor, __lookfor);
42   ::close(wide->user->gufh);
43 
44   if(wide->user->found)
45     return __lookfor;
46   else
47     return NULL;
48 }
49 
50 
51 //  ------------------------------------------------------------------
52 
renumber()53 int SquishArea::renumber() {
54 
55   return false;
56 }
57 
58 
59 //  ------------------------------------------------------------------
60 
make_dump_msg(Line * & lin,gmsg * msg,char * lng_head)61 Line* SquishArea::make_dump_msg(Line*& lin, gmsg* msg, char* lng_head) {
62 
63   GFTRK("SquishMakeDump");
64 
65   // Load the base record
66   SqshBase _base;
67   lseekset(data->fhsqd, 0);
68   read(data->fhsqd, &_base, sizeof(SqshBase));
69 
70   // Load the index record
71   SqshIdx _idx;
72   uint _reln = Msgn->ToReln(msg->msgno);
73   lseekset(data->fhsqi, _reln-1, sizeof(SqshIdx));
74   read(data->fhsqi, &_idx, sizeof(SqshIdx));
75 
76   // Load the message frame
77   SqshFrm _frm;
78   dword _frame = _idx.offset;
79   lseekset(data->fhsqd, _frame);
80   read(data->fhsqd, &_frm, sizeof(SqshFrm));
81 
82   // Load the header and message text
83   SqshHdr _hdr;
84   load_message(GMSG_HDRTXT, msg, _hdr);
85 
86   char buf[100];
87   Line* line = lin =
88   AddLine (NULL, "Hexdump of Squish-style message header and text");
89   AddLineF(line, "------------------------------------------------------------------------------");
90   line = AddLine(line, "");
91   AddLineF(line, "Msgbase        : %s", real_path());
92   AddLineF(line, "From           : %-36.36s", _hdr.from);
93   AddLineF(line, "To             : %-36.36s", _hdr.to);
94   AddLineF(line, "Subject        : %-72.72s", _hdr.subj);
95   AddLineF(line, "DateTime       : %-20.20s", _hdr.ftsc_date);
96   AddLineF(line, "OrigAddr       : %u:%u/%u.%u", _hdr.orig.zone, _hdr.orig.net, _hdr.orig.node, _hdr.orig.point);
97   AddLineF(line, "DestAddr       : %u:%u/%u.%u", _hdr.dest.zone, _hdr.dest.net, _hdr.dest.node, _hdr.dest.point);
98   AddLineF(line, "Umsgid         : %u", _hdr.umsgid);
99   AddLineF(line, "Reply          : %u", _hdr.replyto);
100   AddLineF(line, "See            : %u, %u, %u, %u, %u, %u, %u, %u, %u",
101     _hdr.replies[0], _hdr.replies[1], _hdr.replies[2],
102     _hdr.replies[3], _hdr.replies[4], _hdr.replies[5],
103     _hdr.replies[6], _hdr.replies[7], _hdr.replies[8]
104   );
105   AddLineF(line, "Attr           : %08Xh (%sb)", _hdr.attr, ltob(buf,_hdr.attr,0));
106   AddLineF(line, "DateWritten    : %s (%08Xh)", FTimeToStr(buf, _hdr.date_written), *(dword*)&_hdr.date_written);
107   AddLineF(line, "DateArrived    : %s (%08Xh)", FTimeToStr(buf, _hdr.date_arrived), *(dword*)&_hdr.date_arrived);
108   AddLineF(line, "UTC-Offset     : %u", _hdr.utc_offset);
109   AddLineF(line, "UserRecno      : %u (%s)", wide->userno, WideUsername[0]);
110   line = AddLine(line, "");
111   AddLineF(line, "Message Base Record:");
112   line = AddLine(line, "");
113   AddLineF(line, "TotalMsgs      : %u", _base.totalmsgs);
114   AddLineF(line, "HighestMsg     : %u", _base.highestmsg);
115   AddLineF(line, "NextMsgno      : %u", _base.nextmsgno);
116   AddLineF(line, "HighWaterMark  : %u", _base.highwatermark);
117   AddLineF(line, "FirstFrame     : %08Xh (%u)", _base.firstframe, _base.firstframe);
118   AddLineF(line, "LastFrame      : %08Xh (%u)", _base.lastframe, _base.lastframe);
119   AddLineF(line, "FirstFreeFrame : %08Xh (%u)", _base.firstfreeframe, _base.firstfreeframe);
120   AddLineF(line, "LastFreeFrame  : %08Xh (%u)", _base.lastfreeframe, _base.lastfreeframe);
121   AddLineF(line, "EndFrame       : %08Xh (%u)", _base.endframe, _base.endframe);
122   AddLineF(line, "Max/Skip/Days  : %u  %u  %u", _base.maxmsgs, _base.protmsgs, _base.daystokeep);
123   line = AddLine(line, "");
124   AddLineF(line, "Message Index Record:");
125   line = AddLine(line, "");
126   AddLineF(line, "FrameOffset    : %08Xh (%u)", _idx.offset, _idx.offset);
127   AddLineF(line, "MessageNumber  : %08Xh (%u)", _idx.msgno, _idx.msgno);
128   AddLineF(line, "HashValue      : %08Xh (%u)", _idx.hash, _idx.hash);
129   line = AddLine(line, "");
130   AddLineF(line, "Message Frame Record:");
131   line = AddLine(line, "");
132   AddLineF(line, "Frame-ID       : %08Xh%s", _frm.id, (_frm.id != SQFRAMEID) ? " (error, should be AFAE4453h!)" : "");
133   AddLineF(line, "ThisFrame      : %08Xh (%u)", _frame, _frame);
134   AddLineF(line, "PrevFrame      : %08Xh (%u)", _frm.prev, _frm.prev);
135   AddLineF(line, "NextFrame      : %08Xh (%u)", _frm.next, _frm.next);
136   AddLineF(line, "FrameLength    : %u", _frm.length);
137   AddLineF(line, "TotalLength    : %u", _frm.totsize);
138   AddLineF(line, "CtrlLength     : %u", _frm.ctlsize);
139   line = AddLine(line, "");
140   AddLineF(line, lng_head);
141   line = AddLine(line, "");
142 
143   int _count = 0;
144   char* _ptr = (char*)&_hdr;
145   while(_count < sizeof(SqshHdr)) {
146     sprintf(buf, "%04X   ", _count);
147     HexDump16(buf+7, _ptr, 16, HEX_DUMP2);
148     line = AddLine(line, buf);
149     _count += 16;
150     _ptr += 16;
151   }
152   sprintf(buf, "%04X   ", _count);
153   HexDump16(buf+7, _ptr, sizeof(SqshHdr)%16, HEX_DUMP2);
154   line = AddLine(line, buf);
155 
156   GFTRK(0);
157 
158   return line;
159 }
160 
161 
162 //  ------------------------------------------------------------------
163