ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/proj/trunk/IMAPHandler/IMAPHandler.cpp
(Generate patch)

Comparing trunk/IMAPHandler/IMAPHandler.cpp (file contents):
Revision 113 by douglas, 2003-03-31T22:44:44-08:00 vs.
Revision 124 by douglas, 2003-04-02T21:13:46-08:00

# Line 198 | Line 198 | string IMAPHandler::imap(const string& i
198                  }
199                  else
200                  {
201 <                        result += input + "\r\n";
201 >                        result += input + "\n";
202                  }
203          }
204  
# Line 229 | Line 229 | string IMAPHandler::imap(const string& i
229                  }
230                  else
231                  {
232 <                        result += input + "\r\n";
232 >                        result += input + "\n";
233                  }
234          }
235  
# Line 241 | Line 241 | string IMAPHandler::imap(const string& i
241   {
242          string result;
243  
244 <        //
244 >        string sequence = command();
245 >        putline(sequence + " " + imap + " " + args);
246 >        putline(message);
247 >
248 >        while (true)
249 >        {
250 >                string input = getline();
251 >
252 >                if (input.find(sequence + " OK") == 0)
253 >                {
254 >                        success = true;
255 >                        break;
256 >                }
257 >                else if (input.find(sequence + " NO") == 0 || input.find(sequence +
258 >                        " BAD") == 0)
259 >                {
260 >                        success = false;
261 >                        break;
262 >                }
263 >                else
264 >                {
265 >                        result += input + "\n";
266 >                }
267 >        }
268  
269          return result;
270   }
271  
272   void IMAPHandler::putline(const string line)
273   {
274 <        if (debug) cerr << line << "\n";
274 >        istringstream lines(line);
275  
276 <        sprintf(buffer, "%s\r\n", line.c_str());
254 <
255 <        if (tls)
276 >        while (lines.good())
277          {
278 <                if (int code = SSL_write(ssl, buffer, strlen(buffer)) <= 0)
279 <                {
280 <                        error(program + ": SSL Write", code);
281 <                        exit(1);
278 >                string line;
279 >
280 >                std::getline(lines, line);
281 >                if (debug) cerr << line << "\n";
282 >
283 >                sprintf(buffer, "%s\r\n", line.c_str());
284 >
285 > //              for (unsigned index = 0; index < strlen(buffer); index++)
286 > //              {
287 > //                      cout << "\"" << buffer[index] << "\" = " << int(buffer[index])
288 > //                              << "\n";
289 > //              }
290 >
291 >                if (tls)
292 >                {
293 >                        if (int code = SSL_write(ssl, buffer, strlen(buffer)) <= 0)
294 >                        {
295 >                                error(program + ": SSL Write", code);
296 >                                exit(1);
297 >                        }
298                  }
299 <        }
263 <        else
264 <        {
265 <                if (send(sock, buffer, strlen(buffer), 0) == SOCKET_ERROR)
299 >                else
300                  {
301 <                        error(program + ": Send");
302 <                        exit(1);
301 >                        if (send(sock, buffer, strlen(buffer), 0) == SOCKET_ERROR)
302 >                        {
303 >                                error(program + ": Send");
304 >                                exit(1);
305 >                        }
306                  }
307 +
308 +                lines.peek();
309          }
310   }
311  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines