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: gftnnl.h,v 1.1.1.1 2000/02/25 10:11:57 asa Exp $
23 //  ------------------------------------------------------------------
24 //  Nodelist Index Base Class.
25 //  ------------------------------------------------------------------
26 
27 #ifndef __gftnnl_h
28 #define __gftnnl_h
29 
30 
31 //  ------------------------------------------------------------------
32 
33 #include <gftnall.h>
34 
35 
36 //  ------------------------------------------------------------------
37 //  Nodelist entry data structure
38 
39 class ftn_nodelist_entry {
40 
41 public:
42 
43   ftn_addr addr;           // FTN 4D address, binary form
44   char     address[30];    // FTN address, string form
45   char     name[80];       // Name of the node (sysop)
46   char     status[20];     // Status of the node
47   char     system[80];     // System name
48   char     location[80];   // System location
49   char     phone[40];      // Phone number
50   char     baud[20];       // Modem baud rate
51   char     flags[80];      // Flags (everything after the baud string)
52 
53   void     unpack(char* line);
54 
55   ftn_nodelist_entry& operator=(const ftn_nodelist_entry& e);
56 
57 };
58 
59 
60 //  ------------------------------------------------------------------
61 //  Nodelist index base class
62 
63 class ftn_nodelist_index_base {
64 
65 protected:
66 
67   ftn_nodelist_entry  data;             // Nodelist data for current node
68   const char*         nlpath;           // Path to the nodelist files
69   bool                exactmatch;       // true if an exact match was found
70   bool                isopen;           // true if index is open and ready
71   bool                namebrowse;       // true if browsing names
72   long                indexmax;         // Maximum index value, if possible
73   long                indexpos;         // Current index position, if possible
74 
75   virtual bool        search() = 0;
76 
77 public:
78 
ftn_nodelist_index_base()79                       ftn_nodelist_index_base()   { indexmax = indexpos = 0; }
~ftn_nodelist_index_base()80   virtual             ~ftn_nodelist_index_base()  { }
81 
82   virtual bool        can_browse_name() const = 0;
83   virtual bool        can_browse_address() const = 0;
84 
browsing_names()85   bool                browsing_names() const      { return namebrowse; }
browsing_addresses()86   bool                browsing_addresses() const  { return not namebrowse; }
87 
set_path(const char * path)88   void                set_path(const char* path)  { nlpath = path; }
89 
90   virtual bool        open() = 0;
91   virtual void        close() = 0;
92 
index_max()93   long                index_max() const           { return indexmax; }
index_pos()94   long                index_pos() const           { return indexpos; }
95 
is_open()96   bool                is_open() const             { return isopen; }
97 
98   virtual bool        find(const char* name) = 0;
99   virtual bool        find(const ftn_addr& addr) = 0;
100 
find_again()101   bool                find_again()                { return search(); }
102 
found()103   bool                found()                     { return exactmatch; }
104 
105   virtual bool        previous() = 0;
106   virtual bool        next() = 0;
107 
108   virtual void        first() = 0;
109   virtual void        last() = 0;
110 
111   virtual void        push_state() = 0;
112   virtual void        pop_state() = 0;
113 
114   virtual const char* index_name() const = 0;
115   virtual const char* nodelist_name() const = 0;
116 
addrs()117   const ftn_addr&     addrs() const               { return data.addr; }
address()118   const char*         address() const             { return data.address; }
name()119   const char*         name() const                { return data.name; }
status()120   const char*         status() const              { return data.status; }
system()121   const char*         system() const              { return data.system; }
location()122   const char*         location() const            { return data.location; }
phone()123   const char*         phone() const               { return data.phone; }
baud()124   const char*         baud() const                { return data.baud; }
flags()125   const char*         flags() const               { return data.flags; }
126 
entry()127   const ftn_nodelist_entry& entry() const         { return data; }
128 
129 };
130 
131 
132 //  ------------------------------------------------------------------
133 
134 #endif
135 
136 //  ------------------------------------------------------------------
137