ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/proj/trunk/WinXPFAQPoll/WinXPFAQPoll.cpp
Revision: 119
Committed: 2003-04-01T14:49:17-08:00 (22 years, 2 months ago) by douglas
File size: 4934 byte(s)
Log Message:
Added and implemented Poller::load() function.

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 119 string programVersion = "1.0";
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 douglas 118 string file = "poll.dat";
67 douglas 104
68     for (unsigned index = 1; index < argc; index++)
69     {
70     string arg = argv[index];
71    
72     if (arg == "-D")
73     {
74     debug = true;
75     }
76     else if (arg == "-help")
77     {
78     cout << "Usage: " << program << " [-account] [-nodelete] [-D] "
79     << "[-version] [-help]\nOptions:\n"
80     << " -account Write an account XML file and test\n"
81     << " -nodelete Do not purge deleted mail messages\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 douglas 116 << "Copyright (C) 2003, Douglas Thrift. All Roghts Reserved.\n"
92 douglas 104 << "\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 douglas 118 else
110     {
111     file = arg;
112     }
113 douglas 104 }
114    
115     if (debug)
116     {
117     cerr << "account = " << (account ? "true" : "false") << "\n"
118 douglas 118 << "nodelete = " << (nodelete ? "true" : "false") << "\n"
119     << "file = " << file << "\n";
120 douglas 104 }
121    
122     if (account) Poller::saveAccount();
123    
124     Poller poller;
125    
126 douglas 118 if (!account) poller.poll(nodelete, file);
127 douglas 104
128     return 0;
129     }
130    
131     void entities(string& line, char character, char* entity)
132     {
133     int begin = 0;
134    
135     while (begin < line.length())
136     {
137     int spot = line.find(character, begin);
138    
139     int end = spot + 1;
140    
141     if (spot != string::npos)
142     {
143     line.replace(spot, 1, entity);
144     }
145     else
146     {
147     break;
148     }
149    
150     begin = end;
151     }
152     }
153    
154     void entities(string& line, char* entity, char character)
155     {
156     int begin = 0;
157    
158     while (begin < line.length())
159     {
160     int spot = line.find(entity, begin);
161    
162     int end = spot + 1;
163    
164     if (spot != string::npos)
165     {
166     line.replace(spot, strlen(entity), 1, character);
167     }
168     else
169     {
170     break;
171     }
172    
173     begin = end;
174     }
175     }