1 |
|
/* ============================================================================ |
2 |
|
* Douglas Thrift's Search Engine License |
3 |
|
* |
4 |
< |
* Copyright (C) 2002, Douglas Thrift. All Rights Reserved. |
4 |
> |
* Copyright (C) 2002-2003, Douglas Thrift. All Rights Reserved. |
5 |
|
* Redistribution and use in source and binary forms, with or without |
6 |
|
* modification, are permitted provided that the following conditions are met: |
7 |
|
* |
46 |
|
// |
47 |
|
// Douglas Thrift |
48 |
|
// |
49 |
< |
// Page.cpp |
49 |
> |
// $Id: Page.cpp,v 1.5 2003/12/27 03:31:33 douglas Exp $ |
50 |
|
|
51 |
|
#include "Page.h" |
52 |
|
|
83 |
|
istream& operator>>(istream& is, Page& data) |
84 |
|
{ |
85 |
|
string line; |
86 |
+ |
#ifdef _OpenSSL_ |
87 |
+ |
bool set = false; |
88 |
+ |
#endif |
89 |
+ |
|
90 |
|
getline(is, line); |
91 |
+ |
|
92 |
|
if (line == " <page>") |
93 |
|
{ |
94 |
|
do |
113 |
|
unsigned start = line.find("<port>") + 6; |
114 |
|
unsigned finish = line.find("</port>", start); |
115 |
|
|
116 |
< |
data.setPort(strtoul(line.substr(start, finish - |
117 |
< |
start).c_str(), 0, 0)); |
116 |
> |
istringstream buffer(line.substr(start, finish - start)); |
117 |
> |
unsigned port; |
118 |
> |
|
119 |
> |
buffer >> port; |
120 |
> |
|
121 |
> |
data.setPort(port); |
122 |
> |
|
123 |
> |
#ifdef _OpenSSL_ |
124 |
> |
set = true; |
125 |
> |
#endif |
126 |
> |
} |
127 |
> |
#ifdef _OpenSSL_ |
128 |
> |
else if (line.find(" <tls>") == 0) |
129 |
> |
{ |
130 |
> |
unsigned start = line.find("<tls>") + 5; |
131 |
> |
unsigned finish = line.find("</tls>", start); |
132 |
> |
|
133 |
> |
istringstream buffer(line.substr(start, finish - start)); |
134 |
> |
bool tls; |
135 |
> |
|
136 |
> |
buffer.setf(ios_base::boolalpha); |
137 |
> |
buffer >> tls; |
138 |
> |
|
139 |
> |
data.setTls(tls); |
140 |
> |
|
141 |
> |
if (!set && tls) data.setPort(443); |
142 |
|
} |
143 |
+ |
#endif |
144 |
|
else if (line.find(" <path>") == 0) |
145 |
|
{ |
146 |
|
unsigned start = line.find("<path>") + 6; |
159 |
|
unsigned start = line.find("<size>") + 6; |
160 |
|
unsigned finish = line.find("</size>", start); |
161 |
|
|
162 |
< |
data.setSize(strtoul(line.substr(start, finish - |
163 |
< |
start).c_str(), 0, 0)); |
162 |
> |
istringstream buffer(line.substr(start, finish - start)); |
163 |
> |
unsigned size; |
164 |
> |
|
165 |
> |
buffer >> size; |
166 |
> |
|
167 |
> |
data.setSize(size); |
168 |
|
} |
169 |
|
else if (line.find(" <title>") == 0) |
170 |
|
{ |
256 |
|
|
257 |
|
os << " <page>\n" << " <address>" << address << "</address>\n"; |
258 |
|
|
259 |
+ |
#ifndef _OpenSSL_ |
260 |
|
if (data.getPort() != 80) |
261 |
+ |
#else |
262 |
+ |
if ((data.getPort() != 80 && !data.getTls()) || data.getPort() != 443) |
263 |
+ |
#endif |
264 |
|
{ |
265 |
|
os << " <port>" << data.getPort() << "</port>\n"; |
266 |
|
} |
267 |
|
|
268 |
+ |
#ifdef _OpenSSL_ |
269 |
+ |
os.setf(ios::boolalpha); |
270 |
+ |
os << " <tls>" << data.getTls() << "</tls>\n"; |
271 |
+ |
#endif |
272 |
+ |
|
273 |
|
string path = data.getPath(); |
274 |
|
|
275 |
|
entities(path, '&', "&"); |