00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include <config.h>
00021
00022 #include <stdio.h>
00023 #include <errno.h>
00024
00025 #ifdef HAVE_STRING_H
00026 #include <string.h>
00027 #endif
00028
00029 #include "protocol.h"
00030
00041 int check_pop(Port_T p) {
00042
00043 char buf[STRLEN];
00044 const char *command= "QUIT\r\n";
00045 const char *ok= "+OK";
00046
00047 if ( sock_recv(p->socket, buf, sizeof(buf), 0) <= 0 ) {
00048 log("POP: error receiving data -- %s\n", STRERROR);
00049 return FALSE;
00050 }
00051
00052 chomp(buf);
00053
00054 if ( strncasecmp(buf, ok, strlen(ok)) != 0 ) {
00055 log("POP error: %s\n", buf);
00056 return FALSE;
00057 }
00058
00059 if ( sock_send(p->socket, command, strlen(command), 0) < 0 ) {
00060 log("POP: error sending data -- %s\n", STRERROR);
00061 return FALSE;
00062 }
00063
00064 if ( sock_recv(p->socket, buf, sizeof(buf), 0) <= 0 ) {
00065 log("POP: error receiving data -- %s\n", STRERROR);
00066 return FALSE;
00067 }
00068
00069 chomp(buf);
00070
00071 if ( strncasecmp(buf, ok, strlen(ok)) != 0 ) {
00072 log("POP error: %s\n", buf);
00073 return FALSE;
00074 }
00075
00076 return TRUE;
00077
00078 }
00079