1 |
/* ============================================================================ |
2 |
* Douglas Thrift's Web Contact License |
3 |
* |
4 |
* Copyright (C) 2002, Douglas Thrift. All Rights Reserved. |
5 |
* |
6 |
* Redistribution and use in source and binary forms, with or without |
7 |
* modification, are permitted provided that the following conditions are met: |
8 |
* |
9 |
* 1. Redistributions of source code must retain the above copyright notice, |
10 |
* this list of conditions and the following disclaimer. |
11 |
* |
12 |
* 2. Redistributions in binary form must reproduce the above copyright notice, |
13 |
* this list of conditions and the following disclaimer in the documentation |
14 |
* and/or other materials provided with the distribution. |
15 |
* |
16 |
* 3. The end-user documentation included with the redistribution, if any, must |
17 |
* include the following acknowledgment: |
18 |
* |
19 |
* "This product includes software developed by Douglas Thrift |
20 |
* (http://computers.douglasthrift.net/webcontact.html)." |
21 |
* |
22 |
* Alternately, this acknowledgment may appear in the software itself, if |
23 |
* and wherever such third-party acknowledgments normally appear. |
24 |
* |
25 |
* 4. The names "Douglas Thrift" and "Douglas Thrift's Web Contact" must not be |
26 |
* used to endorse or promote products derived from this software without |
27 |
* specific prior written permission. For written permission, please visit |
28 |
* http://www.douglasthrift.net/contact.html for contact information. |
29 |
* |
30 |
* 5. Products derived from this software may not be called "Douglas Thrift's |
31 |
* Web Contact", nor may "Douglas Thrift's Web Contact" appear in their |
32 |
* name, without prior written permission. |
33 |
* |
34 |
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, |
35 |
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND |
36 |
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
37 |
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
38 |
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
39 |
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, |
40 |
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
41 |
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
42 |
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, |
43 |
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
44 |
* ============================================================================ |
45 |
*/ |
46 |
// Windows XP FAQ Poll |
47 |
// |
48 |
// Douglas Thrift |
49 |
// |
50 |
// WinXPFAQPoll.cpp |
51 |
|
52 |
#include "WinXPFAQPoll.h" |
53 |
#include "Poller.h" |
54 |
|
55 |
string program; |
56 |
string programName = "Windows XP FAQ Poll"; |
57 |
string programVersion = "1.1"; |
58 |
bool debug = false; |
59 |
|
60 |
int main(int argc, char* argv[]) |
61 |
{ |
62 |
program = argv[0]; |
63 |
|
64 |
bool account = false, nodelete = false, approve = false; |
65 |
string file = "poll.dat"; |
66 |
|
67 |
for (unsigned index = 1; index < argc; index++) |
68 |
{ |
69 |
string arg = argv[index]; |
70 |
|
71 |
if (arg == "-D") |
72 |
{ |
73 |
debug = true; |
74 |
} |
75 |
else if (arg == "-help") |
76 |
{ |
77 |
cout << "Usage: " << program << " [-account] [-nodelete] [-approve" |
78 |
<< "] [-D] [-version] [-help]\nOptions:\n" |
79 |
<< " -account Write an account XML file and test\n" |
80 |
<< " -nodelete Do not purge deleted mail messages\n" |
81 |
<< " -approve Check for approvals and disapprovals\n" |
82 |
<< " -D Display debug information\n" |
83 |
<< " -version Display version information and exit\n" |
84 |
<< " -help Display this message and exit\n"; |
85 |
|
86 |
return 0; |
87 |
} |
88 |
else if (arg == "-version") |
89 |
{ |
90 |
cout << programName << ' ' << programVersion << "\n\n" |
91 |
<< "Copyright (C) 2003, Douglas Thrift. All Roghts Reserved.\n" |
92 |
<< "\nThis product includes software developed by Douglas " |
93 |
<< "Thrift\n" |
94 |
<< "(http://computers.douglasthrift.net/imaphandler.html).\n\n" |
95 |
<< "This product includes software developed by Douglas Thrift" |
96 |
<< "\n(http://computers.douglasthrift.net/webcontact.html).\n" |
97 |
<< '\n'; |
98 |
|
99 |
return 0; |
100 |
} |
101 |
else if (arg == "-account") |
102 |
{ |
103 |
account = true; |
104 |
} |
105 |
else if (arg == "-nodelete") |
106 |
{ |
107 |
nodelete = true; |
108 |
} |
109 |
else if (arg == "-approve") |
110 |
{ |
111 |
approve = true; |
112 |
} |
113 |
else |
114 |
{ |
115 |
file = arg; |
116 |
} |
117 |
} |
118 |
|
119 |
if (debug) |
120 |
{ |
121 |
cerr << "account = " << (account ? "true" : "false") << "\n" |
122 |
<< "nodelete = " << (nodelete ? "true" : "false") << "\n" |
123 |
<< "approve = " << (approve ? "true" : "false") << "\n" |
124 |
<< "file = " << file << "\n"; |
125 |
} |
126 |
|
127 |
if (account) Poller::saveAccount(); |
128 |
|
129 |
Poller poller; |
130 |
|
131 |
if (!account) poller.poll(nodelete, file, approve); |
132 |
|
133 |
return 0; |
134 |
} |
135 |
|
136 |
void entities(string& line, char character, char* entity) |
137 |
{ |
138 |
int begin = 0; |
139 |
|
140 |
while (begin < line.length()) |
141 |
{ |
142 |
int spot = line.find(character, begin); |
143 |
|
144 |
int end = spot + 1; |
145 |
|
146 |
if (spot != string::npos) |
147 |
{ |
148 |
line.replace(spot, 1, entity); |
149 |
} |
150 |
else |
151 |
{ |
152 |
break; |
153 |
} |
154 |
|
155 |
begin = end; |
156 |
} |
157 |
} |
158 |
|
159 |
void entities(string& line, char* entity, char character) |
160 |
{ |
161 |
int begin = 0; |
162 |
|
163 |
while (begin < line.length()) |
164 |
{ |
165 |
int spot = line.find(entity, begin); |
166 |
|
167 |
int end = spot + 1; |
168 |
|
169 |
if (spot != string::npos) |
170 |
{ |
171 |
line.replace(spot, strlen(entity), 1, character); |
172 |
} |
173 |
else |
174 |
{ |
175 |
break; |
176 |
} |
177 |
|
178 |
begin = end; |
179 |
} |
180 |
} |