modules/up/src/rpsl/rpsl/rpsl_item.cc
/* [<][>][^][v][top][bottom][index][help] */
FUNCTIONS
This source file includes following functions.
- print
- print
- print
- print
- print
- print
- print
- print
- print
- print
- print
- print
- print
- print
- print
- print
- print
- print
- print
- print
- print
- print
- print
- print
- ItemFilter
1 // $Id: rpsl_item.cc,v 1.1.1.1 2000/03/10 16:32:23 engin Exp $
2 //
3 // Copyright (c) 1994 by the University of Southern California
4 // All rights reserved.
5 //
6 // Permission to use, copy, modify, and distribute this software and its
7 // documentation in source and binary forms for lawful non-commercial
8 // purposes and without fee is hereby granted, provided that the above
9 // copyright notice appear in all copies and that both the copyright
10 // notice and this permission notice appear in supporting documentation,
11 // and that any documentation, advertising materials, and other materials
12 // related to such distribution and use acknowledge that the software was
13 // developed by the University of Southern California, Information
14 // Sciences Institute. The name of the USC may not be used to endorse or
15 // promote products derived from this software without specific prior
16 // written permission.
17 //
18 // THE UNIVERSITY OF SOUTHERN CALIFORNIA DOES NOT MAKE ANY
19 // REPRESENTATIONS ABOUT THE SUITABILITY OF THIS SOFTWARE FOR ANY
20 // PURPOSE. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
21 // IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
22 // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE,
23 // TITLE, AND NON-INFRINGEMENT.
24 //
25 // IN NO EVENT SHALL USC, OR ANY OTHER CONTRIBUTOR BE LIABLE FOR ANY
26 // SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES, WHETHER IN CONTRACT, TORT,
27 // OR OTHER FORM OF ACTION, ARISING OUT OF OR IN CONNECTION WITH, THE USE
28 // OR PERFORMANCE OF THIS SOFTWARE.
29 //
30 // Questions concerning this software should be directed to
31 // ratoolset@isi.edu.
32 //
33 // Author(s): Cengiz Alaettinoglu <cengiz@ISI.EDU>
34
35 #include "config.h"
36 #include <iostream.h>
37 #include <iomanip.h>
38 #include "rpsl_item.hh"
39 #include "rpsl_filter.hh"
40
41 //// printing ////////////////////////////////////////////////////////
42
43 ostream &Item::print(ostream &out) const {
/* [<][>][^][v][top][bottom][index][help] */
44 return out;
45 }
46 ostream &ItemASNO::print(ostream &out) const {
/* [<][>][^][v][top][bottom][index][help] */
47 out << "AS" << asno;
48 return out;
49 }
50
51 ostream &ItemMSItem::print(ostream &out) const {
/* [<][>][^][v][top][bottom][index][help] */
52 out << *item;
53 switch (code) {
54 case 0:
55 out << "^-";
56 break;
57 case 1:
58 out << "^+";
59 break;
60 case 2:
61 if (n == m)
62 out << "^" << n;
63 else
64 out << "^" << n << "-" << m;
65 }
66 return out;
67 }
68
69
70 ostream &ItemFilter::print(ostream &out) const {
/* [<][>][^][v][top][bottom][index][help] */
71 out << filter;
72 return out;
73 }
74
75 ostream &ItemINT::print(ostream &out) const {
/* [<][>][^][v][top][bottom][index][help] */
76 out << i;
77 return out;
78 }
79
80 ostream &ItemTimeStamp::print(ostream &out) const {
/* [<][>][^][v][top][bottom][index][help] */
81 tm *ts;
82 ts = gmtime(&stamp);
83 out.form("%04d%02d%02d %02d:%02d:%02d +00:00",
84 ts->tm_year + 1900, ts->tm_mon+1, ts->tm_mday,
85 ts->tm_hour, ts->tm_min, ts->tm_sec);
86 return out;
87 }
88
89 ostream &ItemREAL::print(ostream &out) const {
/* [<][>][^][v][top][bottom][index][help] */
90 out << real;
91 return out;
92 }
93
94 ostream &ItemSTRING::print(ostream &out) const {
/* [<][>][^][v][top][bottom][index][help] */
95 out << string;
96 return out;
97 }
98
99 ostream &ItemBLOB::print(ostream &out) const {
/* [<][>][^][v][top][bottom][index][help] */
100 out << blob;
101 return out;
102 }
103
104 ostream &ItemIPV4::print(ostream &out) const {
/* [<][>][^][v][top][bottom][index][help] */
105 out << *ipv4;
106 return out;
107 }
108
109 ostream &ItemPRFXV4::print(ostream &out) const {
/* [<][>][^][v][top][bottom][index][help] */
110 out << *prfxv4;
111 return out;
112 }
113
114 ostream &ItemPRFXV4Range::print(ostream &out) const {
/* [<][>][^][v][top][bottom][index][help] */
115 out << *prfxv4;
116 return out;
117 }
118
119 ostream &ItemConnection::print(ostream &out) const {
/* [<][>][^][v][top][bottom][index][help] */
120 if (ip)
121 out << *ip;
122 else
123 out << host;
124 if (port)
125 out << ":" << port;
126 if (ttl)
127 out << ":" << ttl;
128 return out;
129 }
130
131 ostream &ItemSID::print(ostream &out) const {
/* [<][>][^][v][top][bottom][index][help] */
132 out << name;
133 return out;
134 }
135
136 ostream &ItemBOOLEAN::print(ostream &out) const {
/* [<][>][^][v][top][bottom][index][help] */
137 out << (i ? "true" : "false");
138 return out;
139 }
140
141 ostream &ItemWORD::print(ostream &out) const {
/* [<][>][^][v][top][bottom][index][help] */
142 out << word;
143 return out;
144 }
145
146 ostream &ItemNICHDL::print(ostream &out) const {
/* [<][>][^][v][top][bottom][index][help] */
147 out << nichdl;
148 return out;
149 }
150
151 ostream &ItemPRFXV6::print(ostream &out) const {
/* [<][>][^][v][top][bottom][index][help] */
152 out << word;
153 return out;
154 }
155
156 ostream &ItemEMAIL::print(ostream &out) const {
/* [<][>][^][v][top][bottom][index][help] */
157 out << email;
158 return out;
159 }
160
161 ostream &ItemKEYCRTNAME::print(ostream &out) const {
/* [<][>][^][v][top][bottom][index][help] */
162 out << name;
163 return out;
164 }
165
166 ostream &ItemRange::print(ostream &out) const {
/* [<][>][^][v][top][bottom][index][help] */
167 out << *begin << " - " << *end;
168 return out;
169 }
170
171 ostream &ItemFREETEXT::print(ostream &out) const {
/* [<][>][^][v][top][bottom][index][help] */
172 for (int i = 0; i < length; ++i)
173 out << *(text + i);
174 return out;
175 }
176
177 ostream &ItemList::print(ostream &out, char *delim) const {
/* [<][>][^][v][top][bottom][index][help] */
178 Item *item = head();
179 if (item) {
180 item->print(out);
181 for (item = next(item); item; item = next(item)) {
182 out << delim;
183 item->print(out);
184 }
185 }
186
187 return out;
188 }
189
190 ostream &ItemSequence::print(ostream &out) const {
/* [<][>][^][v][top][bottom][index][help] */
191 Item *item = head();
192 if (item) {
193 item->print(out);
194 for (item = next(item); item; item = next(item)) {
195 out << " ";
196 item->print(out);
197 }
198 }
199
200 return out;
201 }
202
203 ItemFilter::~ItemFilter() {
/* [<][>][^][v][top][bottom][index][help] */
204 if (filter)
205 delete filter;
206 }