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_nntp(Port_T p) {
00042
00043 int status;
00044 char buf[STRLEN];
00045 char msg[STRLEN];
00046 const char *command= "QUIT\r\n";
00047
00048 ASSERT(p);
00049
00050 if(port_recv(p, buf, sizeof(buf), 0) <= 0) {
00051 log("NNTP: error receiving data -- %s\n", STRERROR);
00052 return FALSE;
00053 }
00054
00055 chomp(buf);
00056
00057 sscanf(buf, "%d %s", &status, msg);
00058 if(status != 200) {
00059 log("NNTP error: %s\n", buf);
00060 return FALSE;
00061 }
00062
00063 if(port_send(p, command, strlen(command), 0) < 0) {
00064 log("NNTP: error sending data -- %s\n", STRERROR);
00065 return FALSE;
00066 }
00067
00068 if(port_recv(p, buf, sizeof(buf), 0) <= 0) {
00069 log("NNTP: error receiving data -- %s\n", STRERROR);
00070 return FALSE;
00071 }
00072
00073 chomp(buf);
00074
00075 sscanf(buf, "%d %s", &status, msg);
00076 if(status != 205) {
00077 log("NNTP error: %s\n", buf);
00078 return FALSE;
00079 }
00080
00081 return TRUE;
00082
00083 }
00084