File: hostentry.h.html

package info (click to toggle)
rudiments 0.31-2
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 7,516 kB
  • ctags: 3,248
  • sloc: asm: 23,776; cpp: 22,792; sh: 7,769; ansic: 1,769; makefile: 1,054; xml: 169; perl: 19
file content (107 lines) | stat: -rw-r--r-- 9,224 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
<html>
<head>
<title>~/src/firstworks/rudiments-0.31/include/rudiments/hostentry.h.html</title>
<meta name="Generator" content="Vim/7.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body bgcolor="#ffffff" text="#000000">
<pre>
<font color="#0000ff">// Copyright (c) 2002 David Muse</font>
<font color="#0000ff">// See the COPYING file for more information.</font>

<font color="#a020f0">#ifndef RUDIMENTS_HOSTENTRY_H</font>
<font color="#a020f0">#define RUDIMENTS_HOSTENTRY_H</font>

<font color="#a020f0">#include </font><font color="#ff00ff">&lt;rudiments/private/hostentryincludes.h&gt;</font>

<font color="#0000ff">// The hostentry class provides methods for retrieving entries from /etc/hosts</font>

<font color="#a020f0">#ifdef RUDIMENTS_NAMESPACE</font>
<font color="#2e8b57"><b>namespace</b></font> rudiments {
<font color="#a020f0">#endif</font>

<font color="#2e8b57"><b>class</b></font> hostentryprivate;

<font color="#2e8b57"><b>class</b></font> hostentry {
        <font color="#a52a2a"><b>public</b></font>:

                <font color="#0000ff">// If you need to quickly look up a specific field, use one of</font>
                <font color="#0000ff">// these methods.</font>
                <font color="#0000ff">//</font>
                <font color="#0000ff">// These methods return true on success and false on failure.</font>
                <font color="#2e8b57"><b>static</b></font>        <font color="#2e8b57"><b>bool</b></font>   getAliasList(<font color="#2e8b57"><b>const</b></font> <font color="#2e8b57"><b>char</b></font> *hostname,
                                                <font color="#2e8b57"><b>char</b></font> ***aliaslist);
                <font color="#2e8b57"><b>static</b></font>        <font color="#2e8b57"><b>bool</b></font>   getAddressType(<font color="#2e8b57"><b>const</b></font> <font color="#2e8b57"><b>char</b></font> *hostname,
                                                <font color="#2e8b57"><b>int</b></font> *addresstype);
                <font color="#2e8b57"><b>static</b></font>        <font color="#2e8b57"><b>bool</b></font>   getAddressLength(<font color="#2e8b57"><b>const</b></font> <font color="#2e8b57"><b>char</b></font> *hostname,
                                                <font color="#2e8b57"><b>int</b></font> *addresslength);
                <font color="#2e8b57"><b>static</b></font>        <font color="#2e8b57"><b>bool</b></font>   getAddressList(<font color="#2e8b57"><b>const</b></font> <font color="#2e8b57"><b>char</b></font> *hostname,
                                                <font color="#2e8b57"><b>char</b></font> ***addresslist);
                <font color="#2e8b57"><b>static</b></font>        <font color="#2e8b57"><b>bool</b></font>   getAddressString(<font color="#2e8b57"><b>const</b></font> <font color="#2e8b57"><b>char</b></font> *hostname,
                                                <font color="#2e8b57"><b>int</b></font> index,
                                                <font color="#2e8b57"><b>char</b></font> **addressstring);

                <font color="#2e8b57"><b>static</b></font>        <font color="#2e8b57"><b>bool</b></font>   getName(<font color="#2e8b57"><b>const</b></font> <font color="#2e8b57"><b>char</b></font> *address,
                                                <font color="#2e8b57"><b>int</b></font> len, <font color="#2e8b57"><b>int</b></font> type,
                                                <font color="#2e8b57"><b>char</b></font> **name);
                <font color="#2e8b57"><b>static</b></font>        <font color="#2e8b57"><b>bool</b></font>   getAliasList(<font color="#2e8b57"><b>const</b></font> <font color="#2e8b57"><b>char</b></font> *address,
                                                <font color="#2e8b57"><b>int</b></font> len, <font color="#2e8b57"><b>int</b></font> type,
                                                <font color="#2e8b57"><b>char</b></font> ***aliaslist);
                <font color="#2e8b57"><b>static</b></font>        <font color="#2e8b57"><b>bool</b></font>   getAddressList(<font color="#2e8b57"><b>const</b></font> <font color="#2e8b57"><b>char</b></font> *address,
                                                <font color="#2e8b57"><b>int</b></font> len, <font color="#2e8b57"><b>int</b></font> type,
                                                <font color="#2e8b57"><b>char</b></font> ***addresslist);
                <font color="#2e8b57"><b>static</b></font>        <font color="#2e8b57"><b>bool</b></font>   getAddressString(<font color="#2e8b57"><b>const</b></font> <font color="#2e8b57"><b>char</b></font> *address,
                                                <font color="#2e8b57"><b>int</b></font> len, <font color="#2e8b57"><b>int</b></font> type,
                                                <font color="#2e8b57"><b>int</b></font> index,
                                                <font color="#2e8b57"><b>char</b></font> **addressstring);

                <font color="#0000ff">// If you need to look up a host entry and refer to multiple</font>
                <font color="#0000ff">// fields, use these methods.</font>
                                hostentry();
                                hostentry(<font color="#2e8b57"><b>const</b></font> hostentry &amp;h);
                hostentry       &amp;<font color="#a52a2a"><b>operator</b></font>=(<font color="#2e8b57"><b>const</b></font> hostentry &amp;h);
                                ~hostentry();

                <font color="#2e8b57"><b>bool</b></font>  initialize(<font color="#2e8b57"><b>const</b></font> <font color="#2e8b57"><b>char</b></font> *hostname);
                        <font color="#0000ff">// Looks up a host entry by name.</font>
                <font color="#2e8b57"><b>bool</b></font>  initialize(<font color="#2e8b57"><b>const</b></font> <font color="#2e8b57"><b>char</b></font> *address, <font color="#2e8b57"><b>int</b></font> len, <font color="#2e8b57"><b>int</b></font> type);
                        <font color="#0000ff">// Looks up a host entry by address.</font>

                <font color="#2e8b57"><b>const</b></font> <font color="#2e8b57"><b>char</b></font>            *getName() <font color="#2e8b57"><b>const</b></font>;
                <font color="#2e8b57"><b>const</b></font> <font color="#2e8b57"><b>char</b></font> * <font color="#2e8b57"><b>const</b></font>    *getAliasList() <font color="#2e8b57"><b>const</b></font>;
                <font color="#2e8b57"><b>int</b></font>                   getAddressType() <font color="#2e8b57"><b>const</b></font>;
                <font color="#2e8b57"><b>int</b></font>                   getAddressLength() <font color="#2e8b57"><b>const</b></font>;
                <font color="#2e8b57"><b>const</b></font> <font color="#2e8b57"><b>char</b></font> * <font color="#2e8b57"><b>const</b></font>    *getAddressList() <font color="#2e8b57"><b>const</b></font>;
                <font color="#2e8b57"><b>char</b></font>                  *getAddressString(<font color="#2e8b57"><b>int</b></font> index) <font color="#2e8b57"><b>const</b></font>;
                                        <font color="#0000ff">// This method allocates a buffer</font>
                                        <font color="#0000ff">// internally and returns it.  The</font>
                                        <font color="#0000ff">// calling program must deallocate the</font>
                                        <font color="#0000ff">// buffer.</font>

                <font color="#2e8b57"><b>void</b></font>  print() <font color="#2e8b57"><b>const</b></font>;
                        <font color="#0000ff">// Prints out the host entry.</font>

                <font color="#2e8b57"><b>static</b></font>        <font color="#2e8b57"><b>bool</b></font>   needsMutex();
                        <font color="#0000ff">// If your system doesn't support gethostbyname_r()</font>
                        <font color="#0000ff">// and gethostbyaddr_r() then this class needs a</font>
                        <font color="#0000ff">// mutex to assure thread safety.</font>
                        <font color="#0000ff">//</font>
                        <font color="#0000ff">// This method returns true if this class needs a mutex</font>
                        <font color="#0000ff">// to operate safely in a threaded environment and false</font>
                        <font color="#0000ff">// otherwise.</font>
                <font color="#2e8b57"><b>static</b></font>        <font color="#2e8b57"><b>void</b></font>   setMutex(mutex *mtx);
                        <font color="#0000ff">// Allows you to supply a mutex is the class needs it.</font>
                        <font color="#0000ff">// If your application is not multithreaded, then</font>
                        <font color="#0000ff">// there is no need to supply a mutex.</font>

<font color="#a020f0">        #include </font><font color="#ff00ff">&lt;rudiments/private/hostentry.h&gt;</font>
};

<font color="#a020f0">#ifdef RUDIMENTS_NAMESPACE</font>
}
<font color="#a020f0">#endif</font>

<font color="#a020f0">#endif</font>
</pre>
</body>
</html>