ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/proj/WinXPFAQPoll/WinXPFAQPoll.cpp
Revision: 116
Committed: 2003-04-01T00:43:13-08:00 (22 years, 2 months ago) by douglas
Original Path: trunk/WinXPFAQPoll/WinXPFAQPoll.cpp
File size: 4839 byte(s)
Log Message:
That is better.

File Contents

# User Rev Content
1 douglas 104 /* ============================================================================
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 douglas 116 string programVersion = "1.1";
58 douglas 104 bool debug = false;
59    
60     int main(int argc, char* argv[])
61     {
62     program = argv[0];
63    
64     bool account = false;
65     bool nodelete = false;
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] [-D] "
78     << "[-version] [-help]\nOptions:\n"
79     << " -account Write an account XML file and test\n"
80     << " -nodelete Do not purge deleted mail messages\n"
81     << " -D Display debug information\n"
82     << " -version Display version information and exit\n"
83     << " -help Display this message and exit\n";
84    
85     return 0;
86     }
87     else if (arg == "-version")
88     {
89     cout << programName << ' ' << programVersion << "\n\n"
90 douglas 116 << "Copyright (C) 2003, Douglas Thrift. All Roghts Reserved.\n"
91 douglas 104 << "\nThis product includes software developed by Douglas "
92     << "Thrift\n"
93     << "(http://computers.douglasthrift.net/imaphandler.html).\n\n"
94     << "This product includes software developed by Douglas Thrift"
95     << "\n(http://computers.douglasthrift.net/webcontact.html).\n"
96     << '\n';
97    
98     return 0;
99     }
100     else if (arg == "-account")
101     {
102     account = true;
103     }
104     else if (arg == "-nodelete")
105     {
106     nodelete = true;
107     }
108     }
109    
110     if (debug)
111     {
112     cerr << "account = " << (account ? "true" : "false") << "\n"
113     << "nodelete = " << (nodelete ? "true" : "false") << "\n";
114     }
115    
116     if (account) Poller::saveAccount();
117    
118     Poller poller;
119    
120     if (!account) poller.poll(nodelete);
121    
122     return 0;
123     }
124    
125     void entities(string& line, char character, char* entity)
126     {
127     int begin = 0;
128    
129     while (begin < line.length())
130     {
131     int spot = line.find(character, begin);
132    
133     int end = spot + 1;
134    
135     if (spot != string::npos)
136     {
137     line.replace(spot, 1, entity);
138     }
139     else
140     {
141     break;
142     }
143    
144     begin = end;
145     }
146     }
147    
148     void entities(string& line, char* entity, char character)
149     {
150     int begin = 0;
151    
152     while (begin < line.length())
153     {
154     int spot = line.find(entity, begin);
155    
156     int end = spot + 1;
157    
158     if (spot != string::npos)
159     {
160     line.replace(spot, strlen(entity), 1, character);
161     }
162     else
163     {
164     break;
165     }
166    
167     begin = end;
168     }
169     }