1 /*
2  *  RNtrack - FTN message tracker/router
3  *
4  *  nodelist.hpp - Work with nodelists
5  *
6  *  Copyright (c) 2003-2005 Alex Soukhotine, 2:5030/1157
7  *
8  *  This program is free software; you can redistribute it and/or modify
9  *  it under the terms of the GNU General Public License as published by
10  *  the Free Software Foundation; either version 2 of the License, or
11  *  (at your option) any later version.
12  *
13  *  $Id: nodelist.hpp 131 2011-03-20 16:48:35Z dukelsky $
14  */
15 
16 #ifndef _NODELIST_HPP_
17 #define _NODELIST_HPP_
18 
19 #include "fidoaddr.hpp"
20 
21 #define DefaultIndex "rntrack.ndl" // default index file
22 #define NdlSign      0xfeda3033U   // Signature of nodelist index
23 #define A_NONE       0x00000000U
24 #define A_DOWN       0x01000000U
25 #define A_HOLD       0x02000000U
26 #define A_HUB        0x03000000U
27 #define A_HOST       0x04000000U
28 #define A_PVT        0x05000000U
29 #define A_REGION     0x06000000U
30 #define A_NONODE     0xffffffffU
31 #define A_MASK       0xffff0000U
32 
33 extern char * NodelistPath;
34 
35 typedef struct
36 {
37     char     Name[512];
38     time_t   Time;
39     dword    StartZone;
40 } NodeListElem;
41 
42 typedef struct _Nch
43 {
44     dword         Number;
45     struct _Nch * Sub;
46 } Nch;
47 
48 
49 class NodeLists
50 {
51     NodeListElem * NList;
52     int Lists;
53     char * IndexName;
54     Nch * Index;
55     int StartZone;
56 private:
57     bool CompileNeed(void);
58     bool Compile(void);
59     bool LoadOneIndex(FILE * fh, Nch * & Ind);
60     Nch * Srch(Nch * Addr, unsigned int Number);
61 
62 public:
63     NodeLists();
64     ~NodeLists();
65     int AddNodelist(char * tmt, int TempZone);
66     void IndexFile(char * Name);
67     void Print(void);
68     bool Load(void);
69     unsigned int ExistInNodelist(FA const & f);
70     unsigned int GetFlags(FA const & f);
71     bool InSubHubs(FA const & Addr, FA const & Mask);
72     unsigned int FindHub(FA const & f);
73 
Enabled(void)74     int Enabled(void)
75     {
76         return Lists != 0;
77     }
78     char * Names(char * Buf);
79 };
80 
81 int SetMaxNodelistAge(int tmt);
82 int SetNodelist(char * tmt, int TempZone);
83 void SayNodelistFlags(FA const & f);
84 
85 #endif
86