#include "intl.h"
#include "nntp.h"
#include "socket.h"
+#include "ssl.h"
#include "utils.h"
static gint verbose = 1;
const gchar *format,
...);
+#if USE_SSL
+NNTPSockInfo *nntp_open(const gchar *server, gushort port, gchar *buf, gboolean use_ssl)
+#else
NNTPSockInfo *nntp_open(const gchar *server, gushort port, gchar *buf)
+#endif
{
SockInfo *sock;
NNTPSockInfo *nntp_sock;
server, port);
return NULL;
}
+
+#if USE_SSL
+ if (use_ssl && !ssl_init_socket(sock)) {
+ sock_close(sock);
+ return NULL;
+ }
+#endif
+
nntp_sock = g_new0(NNTPSockInfo, 1);
nntp_sock->sock = sock;
}
}
+#if USE_SSL
+NNTPSockInfo *nntp_open_auth(const gchar *server, gushort port, gchar *buf,
+ const gchar *userid, const gchar *passwd, gboolean use_ssl)
+#else
NNTPSockInfo *nntp_open_auth(const gchar *server, gushort port, gchar *buf,
const gchar *userid, const gchar *passwd)
+#endif
{
NNTPSockInfo *sock;
+#if USE_SSL
+ sock = nntp_open(server, port, buf, use_ssl);
+#else
sock = nntp_open(server, port, buf);
+#endif
+
if (!sock) return NULL;
sock->userid = g_strdup(userid);
ok = nntp_gen_command(sock, buf, "GROUP %s", group);
+ if (ok != NN_SUCCESS) {
+ ok = nntp_gen_command(sock, buf, "MODE READER");
+ if (ok == NN_SUCCESS)
+ ok = nntp_gen_command(sock, buf, "GROUP %s", group);
+ }
if (ok != NN_SUCCESS)
return ok;
gchar buf[NNTPBUFSIZE];
if ((ok = nntp_gen_recv(sock, buf, sizeof(buf))) == NN_SUCCESS) {
- if (strlen(buf) < 4)
+ if (strlen(buf) < 3)
return NN_ERROR;
if ((buf[0] == '1' || buf[0] == '2' || buf[0] == '3') &&
- buf[3] == ' ') {
+ (buf[3] == ' ' || buf[3] == '\0')) {
if (argbuf)
strcpy(argbuf, buf);
- if (!strncmp(buf, "381 ", 4))
+ if (!strncmp(buf, "381", 3))
return NN_AUTHCONT;
return NN_SUCCESS;
- } else if (!strncmp(buf, "480 ", 4))
+ } else if (!strncmp(buf, "480", 3))
return NN_AUTHREQ;
else
return NN_ERROR;