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: gmoezyc3.cpp,v 1.4 2006/05/14 11:45:05 ssianky Exp $
23 // ------------------------------------------------------------------
24 // Ezycom msgbase handling
25 // ------------------------------------------------------------------
26
27
28 // ------------------------------------------------------------------
29
30 #include <gmemdbg.h>
31 #include <gdbgtrk.h>
32 #include <gstrall.h>
33 #include <gutlmisc.h>
34
35 #include <gmoezyc.h>
36
37
38 // ------------------------------------------------------------------
39
load_message(int __mode,gmsg * __msg,EzycHdr & __hdr)40 int EzycomArea::load_message(int __mode, gmsg* __msg, EzycHdr& __hdr) {
41
42 // Load the header
43 memset(&__hdr, 0, sizeof(EzycHdr));
44 lseekset(data->fhhdr, __msg->msgno-1, sizeof(EzycHdr));
45 read(data->fhhdr, &__hdr, sizeof(EzycHdr));
46
47 // Convert header data
48
49 __msg->link.to_set(__hdr.replyto);
50 __msg->link.first_set(__hdr.reply1st);
51
52 __msg->cost = __hdr.cost;
53
54 __msg->txtstart = __hdr.startposition;
55 __msg->txtlength = __hdr.messagelength;
56
57 strnp2cc(__msg->by, __hdr.whofrom, EZYC_MAXNAME-1);
58 strnp2cc(__msg->to, __hdr.whoto, EZYC_MAXNAME-1);
59 strnp2cc(__msg->re, __hdr.subject, EZYC_MAXSUBJ-1);
60
61 __msg->orig.zone = __msg->oorig.zone = __hdr.orignet.zone;
62 __msg->orig.net = __msg->oorig.net = __hdr.orignet.net;
63 __msg->orig.node = __msg->oorig.node = __hdr.orignet.node;
64 __msg->orig.point = __msg->oorig.point = __hdr.orignet.point;
65
66 __msg->dest.zone = __msg->odest.zone = __hdr.destnet.zone;
67 __msg->dest.net = __msg->odest.net = __hdr.destnet.net;
68 __msg->dest.node = __msg->odest.node = __hdr.destnet.node;
69 __msg->dest.point = __msg->odest.point = __hdr.destnet.point;
70
71 // Convert date and time
72 SwapWord32((uint32_t*)&__hdr.posttimedate);
73 SwapWord32((uint32_t*)&__hdr.recvtimedate);
74 __msg->written = FTimeToTime(&__hdr.posttimedate);
75 __msg->arrived = FTimeToTime(&__hdr.recvtimedate);
76
77 // Convert attributes
78 __msg->attr.del(__hdr.msgattr & EZYC_MSGATTR_DELETED);
79 __msg->attr.pvt(__hdr.msgattr & EZYC_MSGATTR_PRIVATE);
80 __msg->attr.rcv(__hdr.msgattr & EZYC_MSGATTR_RECEIVED);
81 __msg->attr.loc(__hdr.msgattr & EZYC_MSGATTR_LOCAL);
82 __msg->attr.lok(__hdr.msgattr & EZYC_MSGATTR_NOKILL);
83 __msg->attr.k_s(__hdr.netattr & EZYC_NETATTR_KILLSENT);
84 __msg->attr.snt(__hdr.netattr & EZYC_NETATTR_SENT);
85 __msg->attr.att(__hdr.netattr & EZYC_NETATTR_ATTACH);
86 __msg->attr.cra(__hdr.netattr & EZYC_NETATTR_CRASH);
87 __msg->attr.frq(__hdr.netattr & EZYC_NETATTR_FREQ);
88 __msg->attr.rrq(__hdr.netattr & EZYC_NETATTR_RREQ);
89 __msg->attr.arq(__hdr.netattr & EZYC_NETATTR_AREQ);
90 __msg->attr.rrc(__hdr.netattr & EZYC_NETATTR_RREC);
91 __msg->attr.uns(((__hdr.msgattr & EZYC_MSGATTR_NETPEND) or (__hdr.msgattr & EZYC_MSGATTR_ECHOPEND)) ? 1 : 0);
92
93 __msg->ezycom.extattr = __hdr.extattr;
94 __msg->timesread = (__hdr.extattr & EZYC_EXTATTR_SEEN) ? 1 : 0;
95
96 if(__mode & GMSG_TXT) {
97
98 __msg->txt = (char*)throw_calloc(1, (uint)(__hdr.messagelength+256));
99 lseekset(data->fhtxt, __hdr.startposition);
100 read(data->fhtxt, __msg->txt, (uint)__hdr.messagelength);
101 }
102
103 GFTRK(0);
104
105 return true;
106 }
107
108
109 // ------------------------------------------------------------------
110
load_hdr(gmsg * __msg)111 int EzycomArea::load_hdr(gmsg* __msg) {
112
113 GFTRK("EzycomLoadHdr");
114
115 EzycHdr _hdr;
116 return load_message(GMSG_HDR, __msg, _hdr);
117 }
118
119
120 // ------------------------------------------------------------------
121
load_msg(gmsg * __msg)122 int EzycomArea::load_msg(gmsg* __msg) {
123
124 GFTRK("EzycomLoadMsg");
125
126 EzycHdr _hdr;
127 return load_message(GMSG_HDRTXT, __msg, _hdr);
128 }
129
130
131 // ------------------------------------------------------------------
132
133