Add GNU LGPL headers to all .c .C and .h files
[oweals/cde.git] / cde / lib / tt / lib / util / tt_host.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 librararies 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.h /main/3 1995/10/23 10:39:40 rswiston $                                                     */
28 /*
29  *
30  * tt_host.h
31  *
32  * Copyright (c) 1990, 1994 by Sun Microsystems, Inc.
33  *
34  * This file implements the _Tt_host object which is a utility object
35  * that handles locating a host address by name or locating a host name
36  * by a host address. 
37  */
38 #ifndef _TT_HOST_H
39 #define _TT_HOST_H
40
41 #include <netdb.h>
42 #include <stdlib.h>
43 #include <sys/types.h>
44 #include <netinet/in.h>
45 #include "util/tt_object.h"
46 #include "util/tt_string.h"
47
48 class _Tt_host : public _Tt_object {
49       public:
50         _Tt_host();
51         virtual ~_Tt_host();
52         int                     init_byaddr(_Tt_string addr);
53         int                     init_byname(_Tt_string name);
54         int                     init_bystringaddr(_Tt_string addr);
55         const _Tt_string &      name()        const {return _name;};
56         const _Tt_string &      netname()     const {return _netname;};
57         const _Tt_string &      addr()        const {return _addr;};
58         int                     addr_length() const;
59         const _Tt_string &      stringaddr()  const {return _string_address;};
60         bool_t                  xdr(XDR *xdrs);         
61
62       private:
63         int                     init_from_hostent(hostent *h);
64         // Internet '.' notation
65         _Tt_string              _string_address;
66         _Tt_string              _name;
67         //
68         // IP_QUALIFIER:<ip_address>
69         // TLI_QUALIFIER:<fully_qualified_hostname>
70         //
71         _Tt_string              _netname;
72         _Tt_string              _addr;
73 };
74
75 _Tt_string _tt_host_addr(_Tt_object_ptr &o);
76 _Tt_string _tt_host_name(_Tt_object_ptr &o);
77 #endif                          /* _TT_HOST_H */