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 // Copyright (C) 1999-2000 Alexander S. Aganichev 7 // ------------------------------------------------------------------ 8 // This library is free software; you can redistribute it and/or 9 // modify it under the terms of the GNU Library General Public 10 // License as published by the Free Software Foundation; either 11 // version 2 of the License, or (at your option) any later version. 12 // 13 // This library is distributed in the hope that it will be useful, 14 // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 // Library General Public License for more details. 17 // 18 // You should have received a copy of the GNU Library General Public 19 // License along with this program; if not, write to the Free 20 // Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, 21 // MA 02111-1307, USA 22 // ------------------------------------------------------------------ 23 // $Id: gmohuds.h,v 1.7 2011/12/17 21:46:02 stas_degteff Exp $ 24 // ------------------------------------------------------------------ 25 // Hudson. 26 // ------------------------------------------------------------------ 27 28 29 // ------------------------------------------------------------------ 30 // Only include once! 31 32 #ifndef __GMHUDS_H 33 #define __GMHUDS_H 34 35 36 // ------------------------------------------------------------------ 37 // Required 38 39 #include <gmoarea.h> 40 #include <gusrhuds.h> 41 #include <gusrra2.h> 42 #include <gusrgold.h> 43 44 // ------------------------------------------------------------------ 45 46 #include <limits.h> 47 #include <stdlib.h> 48 #include <gdbgerr.h> 49 #include <gdefs.h> 50 #include <gmemdbg.h> 51 #include <gdbgtrk.h> 52 #include <gstrall.h> 53 #include <gmemall.h> 54 #include <gutlmisc.h> 55 56 57 // ------------------------------------------------------------------ 58 59 #define HUDS_DELETEDMSGNO 0xFFFFu 60 #define HUDS_MAXBOARD 200 61 #define HUDS_EXT ".bbs" 62 #define HUDS_NAME "Hudson" 63 64 #define GOLD_DELETEDMSGNO 0xFFFFFFFFL 65 #define GOLD_MAXBOARD 500 66 #define GOLD_EXT ".dat" 67 #define GOLD_NAME "Goldbase" 68 69 70 // ------------------------------------------------------------------ 71 72 #if defined(GOLD_CANPACK) 73 #pragma pack(1) 74 #endif 75 76 77 // ------------------------------------------------------------------ 78 // Hudson Message Attributes 79 80 #define HUDS_DELETED 0x01 81 #define HUDS_NETTRANS 0x02 82 #define HUDS_NETMSG 0x04 83 #define HUDS_PVT 0x08 84 #define HUDS_RECEIVED 0x10 85 #define HUDS_ECHOTRANS 0x20 86 #define HUDS_LOCAL 0x40 87 #define HUDS_GROUPMSG 0x80 88 89 #define HUDS_KILLSENT 0x01 90 #define HUDS_SENT 0x02 91 #define HUDS_ATTACH 0x04 92 #define HUDS_CRASH 0x08 93 #define HUDS_RETRECREQ 0x10 94 #define HUDS_AUDITREQ 0x20 95 #define HUDS_RETREC 0x40 96 #define HUDS_FREQ 0x80 97 98 99 // ------------------------------------------------------------------ 100 // Hudson Message Header (MSGHDR.BBS) 101 102 template <class msgn_t, class rec_t, class attr_t, class board_t, class last_t> 103 struct _HudsHdr { 104 msgn_t msgno; 105 msgn_t replyto; 106 msgn_t reply1st; 107 word timesread; 108 rec_t startrec; 109 word numrecs; 110 word destnet; 111 word destnode; 112 word orignet; 113 word orignode; 114 byte destzone; 115 byte origzone; 116 word cost; 117 attr_t msgattr; 118 attr_t netattr; 119 board_t board; 120 char time[6]; 121 char date[9]; 122 char to[36]; 123 char by[36]; 124 char re[73]; 125 } __attribute__ ((packed)); 126 127 128 // ------------------------------------------------------------------ 129 // Hudson Messagebase Information (MSGINFO.BBS) 130 131 template <class msgn_t, class rec_t, class attr_t, class board_t, class last_t> 132 struct _HudsInfo { 133 msgn_t low; 134 msgn_t high; 135 msgn_t total; 136 last_t active; 137 } __attribute__ ((packed)); 138 139 140 // ------------------------------------------------------------------ 141 // Hudson Message Header Index (MSGIDX.BBS) 142 143 template <class msgn_t, class rec_t, class attr_t, class board_t, class last_t> 144 struct _HudsIdx { 145 msgn_t msgno; 146 board_t board; 147 } __attribute__((packed)); 148 149 150 // ------------------------------------------------------------------ 151 // Hudson Message Name Index (MSGTOIDX.BBS) 152 153 struct HudsToIdx { 154 char name[36]; 155 } __attribute__((packed)); 156 157 158 // ------------------------------------------------------------------ 159 160 typedef word HudsLast[HUDS_MAXBOARD] 161 #ifndef __DJGPP__ 162 __attribute__((packed)) 163 #endif 164 ; 165 typedef word GoldLast[GOLD_MAXBOARD] 166 #ifndef __DJGPP__ 167 __attribute__((packed)) 168 #endif 169 ; 170 171 172 // ------------------------------------------------------------------ 173 174 #if defined(GOLD_CANPACK) 175 #pragma pack() 176 #endif 177 178 179 // ------------------------------------------------------------------ 180 181 struct HudsScan { 182 uint count; 183 uint active; 184 uint32_t lastread; 185 uint lastreadreln; 186 uint32_t lastreadfound; 187 uint32_t firstmsgno; 188 uint32_t lastmsgno; 189 uint pmcount; 190 }; 191 192 193 // ------------------------------------------------------------------ 194 195 196 template <class msgn_t, class rec_t, class attr_t, class board_t, class last_t, bool __HUDSON> 197 struct _HudsWide { 198 199 #if defined(GOLD_CANPACK) 200 #pragma pack(1) 201 #endif 202 // <class msgn_t, class rec_t, class attr_t, class board_t, class last_t> 203 typedef _HudsHdr<msgn_t, rec_t, attr_t, board_t, last_t> HudsHdr; 204 typedef _HudsInfo<msgn_t, rec_t, attr_t, board_t, last_t> HudsInfo; 205 typedef _HudsIdx<msgn_t, rec_t, attr_t, board_t, last_t> HudsIdx; 206 #if defined(GOLD_CANPACK) 207 #pragma pack() 208 #endif 209 210 gfile fhtxt; 211 gfile fhhdr; 212 gfile fhidx; 213 gfile fhinf; 214 gfile fhlrd; 215 gfile fhtoi; 216 gfile fhusr; 217 gfile fhuix; 218 gfile fhuxi; 219 int isopen; 220 int islocked; 221 int timesposted; 222 int32_t msgidxsize; 223 HudsIdx* msgidxptr; 224 HudsInfo msginfo; 225 last_t lastrec; 226 GUser* user; 227 int userno; 228 HudsScan* scn; 229 HudsIdx* pmscan; 230 uint pmscantotal; 231 int iswideopen; 232 int ispmscanned; 233 int iswidescanned; 234 const char* path; 235 const char* syspath; 236 int32_t sizewarn; 237 int ra2usersbbs; 238 239 void init(); 240 void exit(); 241 242 void open(); 243 void close(); 244 245 void lock(); 246 void unlock(); 247 248 void scan(); 249 250 void raw_open_scan(); 251 void scan_pm(); 252 253 void realloc_pm_scan(); 254 255 void update_netecho(const char* __name, msgn_t __hdridx, int __delete); 256 257 void test_open(gfile &__file, const char* __fname, int __oaccess); 258 void raw_open(int __oaccess=0, int __all=true); 259 void raw_close(); 260 void refresh(); 261 void save_lastread(board_t board, msgn_t msgno); 262 }; 263 264 265 // ------------------------------------------------------------------ 266 267 template <class msgn_t, class rec_t, class attr_t, class board_t, class last_t, bool __HUDSON> 268 class _HudsArea : public gmo_area { 269 270 // <class msgn_t, class rec_t, class attr_t, class board_t, class last_t, bool __HUDSON> 271 typedef _HudsWide<msgn_t, rec_t, attr_t, board_t, last_t, __HUDSON> HudsWide; 272 273 #if defined(GOLD_CANPACK) 274 #pragma pack(1) 275 #endif 276 // <class msgn_t, class rec_t, class attr_t, class board_t, class last_t> 277 typedef _HudsHdr<msgn_t, rec_t, attr_t, board_t, last_t> HudsHdr; 278 typedef _HudsInfo<msgn_t, rec_t, attr_t, board_t, last_t> HudsInfo; 279 typedef _HudsIdx<msgn_t, rec_t, attr_t, board_t, last_t> HudsIdx; 280 #if defined(GOLD_CANPACK) 281 #pragma pack() 282 #endif 283 284 protected: 285 286 HudsWide* wide; 287 288 void data_open(); 289 void data_close(); 290 291 void raw_scan(int __keep_index); 292 293 msgn_t get_hdr_idx(gmsg* __msg, char* __file__, int __line__); 294 295 int load_message(int __mode, gmsg* __msg, HudsHdr& __hdr); 296 void save_message(int __mode, gmsg* __msg, HudsHdr& __hdr); 297 298 public: 299 _HudsArea()300 _HudsArea() { wide = NULL; } ~_HudsArea()301 virtual ~_HudsArea() {} 302 havearrivedstamp()303 virtual bool havearrivedstamp() const { return false; } havereceivedstamp()304 virtual bool havereceivedstamp() const { return false; } 305 306 // ---------------------------------------------------------------- 307 // Messagebase member functions 308 309 void open(); 310 void close(); 311 312 void suspend(); 313 void resume(); 314 315 void lock(); 316 void unlock(); 317 318 void scan(); 319 void scan_area(); 320 void scan_area_pm(); 321 322 int load_hdr(gmsg* msg); 323 int load_msg(gmsg* msg); 324 325 void save_hdr(int mode, gmsg* msg); 326 void save_msg(int mode, gmsg* msg); 327 328 void del_msg(gmsg* msg); 329 330 void new_msgno(gmsg* msg); 331 char* user_lookup(char* lookfor); 332 int renumber(); 333 334 void update_timesread(gmsg* msg); 335 336 Line* make_dump_msg(Line*& lin, gmsg* msg, char* lng_head); 337 }; 338 339 340 // ------------------------------------------------------------------ 341 342 // <class msgn_t, class rec_t, class attr_t, class board_t, class last_t, bool __HUDSON> 343 typedef _HudsWide<word, word, byte, byte, HudsLast, true> HudsWide; 344 typedef _HudsWide<dword, int32_t, word, word, GoldLast, false> GoldWide; 345 typedef _HudsArea<word, word, byte, byte, HudsLast, true> HudsArea; 346 typedef _HudsArea<dword, int32_t, word, word, GoldLast, false> GoldArea; 347 348 349 // ------------------------------------------------------------------ 350 351 extern HudsWide* hudsonwide; 352 extern GoldWide* goldbasewide; 353 354 355 // ------------------------------------------------------------------ 356 357 #include <gmohuds1.cpp> 358 #include <gmohuds2.cpp> 359 #include <gmohuds3.cpp> 360 #include <gmohuds4.cpp> 361 #include <gmohuds5.cpp> 362 363 364 // ------------------------------------------------------------------ 365 366 #endif 367 368 // ------------------------------------------------------------------ 369 370