5e8a7c81b30499e647ef69ded755c5275a1ed76f
[oweals/cde.git] / cde / lib / tt / lib / util / tt_host_equiv.h
1 /*
2  * CDE - Common Desktop Environment
3  *
4  * Copyright (c) 1993-2012, The Open Group. All rights reserved.
5  *
6  * These libraries and programs are free software; you can
7  * redistribute them and/or modify them under the terms of the GNU
8  * Lesser General Public License as published by the Free Software
9  * Foundation; either version 2 of the License, or (at your option)
10  * any later version.
11  *
12  * These libraries and programs are distributed in the hope that
13  * they will be useful, but WITHOUT ANY WARRANTY; without even the
14  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15  * PURPOSE. See the GNU Lesser General Public License for more
16  * details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with these libraries and programs; if not, write
20  * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21  * Floor, Boston, MA 02110-1301 USA
22  */
23 /*%%  (c) Copyright 1993, 1994 Hewlett-Packard Company                   */
24 /*%%  (c) Copyright 1993, 1994 International Business Machines Corp.     */
25 /*%%  (c) Copyright 1993, 1994 Sun Microsystems, Inc.                    */
26 /*%%  (c) Copyright 1993, 1994 Novell, Inc.                              */
27 /*%%  $XConsortium: tt_host_equiv.h /main/3 1995/10/23 10:39:54 rswiston $                                                       */
28 /*
29  *
30  * tt_host_equiv.h
31  *
32  * Copyright (c) 1994 by Sun Microsystems, Inc.
33  *
34  * This file implements the _Tt_host_equiv object which is a utility object
35  * that handles determining if one hostname refers to the same host
36  * as that of another hostname.
37  */
38 #ifndef _TT_HOST_EQUIV_H
39 #define _TT_HOST_EQUIV_H
40
41 #include <netdb.h>
42 #include <stdlib.h>
43 #include <sys/types.h>
44 #include <netinet/in.h>
45 #include "util/tt_string.h"
46 #include "util/tt_table.h"
47
48 declare_list_of(_Tt_hostname_cache)
49 declare_table_of(_Tt_hostname_cache)
50 declare_ptr_to(_Tt_host_equiv)
51
52 class _Tt_hostname_cache : public _Tt_object {
53         public:
54                 // a null constructor is required by the
55                 // table_of macro; DO NOT USE THIS.
56                 _Tt_hostname_cache();
57
58                 _Tt_hostname_cache(_Tt_string & hostname);
59
60                 ~_Tt_hostname_cache();
61
62                 // key functions must be static
63                 static _Tt_string h_keyfn(_Tt_object_ptr & p);
64
65                 _Tt_string hostname_val() { return hostname; }
66
67                 _Tt_string      hostname;
68
69                 // length of each address in _addr_list
70                 int addr_length;
71
72                 _Tt_string_list_ptr addr_list;
73 };
74
75 class _Tt_host_equiv : public _Tt_object {
76       public:
77                 _Tt_host_equiv();
78
79                 ~_Tt_host_equiv();
80
81                 _Tt_string prefix_host(const _Tt_string & host1,
82                                        const _Tt_string & localhost);
83
84                 int hostname_equiv(const _Tt_string & host1,
85                                    const _Tt_string & host2);
86       private:
87                 _Tt_hostname_cache_table_ptr _cache_table;
88 };
89
90 #endif                          /* _TT_HOST_EQUIV_H */