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 122 by douglas, 2003-04-02T15:48:57-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   }
# Line 250 | Line 273 | void IMAPHandler::putline(const string l
273   {
274          if (debug) cerr << line << "\n";
275  
276 <        sprintf(buffer, "%s\r\n", line.c_str());
276 >        istringstream lines(line);
277  
278 <        if (tls)
278 >        while (lines.good())
279          {
280 <                if (int code = SSL_write(ssl, buffer, strlen(buffer)) <= 0)
280 >                string line;
281 >
282 >                std::getline(lines, line);
283 >                sprintf(buffer, "%s\r\n", line.c_str());
284 >
285 >                if (tls)
286                  {
287 <                        error(program + ": SSL Write", code);
288 <                        exit(1);
287 >                        if (int code = SSL_write(ssl, buffer, strlen(buffer)) <= 0)
288 >                        {
289 >                                error(program + ": SSL Write", code);
290 >                                exit(1);
291 >                        }
292                  }
293 <        }
263 <        else
264 <        {
265 <                if (send(sock, buffer, strlen(buffer), 0) == SOCKET_ERROR)
293 >                else
294                  {
295 <                        error(program + ": Send");
296 <                        exit(1);
295 >                        if (send(sock, buffer, strlen(buffer), 0) == SOCKET_ERROR)
296 >                        {
297 >                                error(program + ": Send");
298 >                                exit(1);
299 >                        }
300                  }
301 +
302 +                lines.peek();
303          }
304   }
305  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines