static gint verbose = 1;
-static void nntp_gen_send(gint sock, const gchar *format, ...);
-static gint nntp_gen_recv(gint sock, gchar *buf, gint size);
+static void nntp_gen_send(SockInfo *sock, const gchar *format, ...);
+static gint nntp_gen_recv(SockInfo *sock, gchar *buf, gint size);
-gint nntp_open(const gchar *server, gushort port, gchar *buf)
+SockInfo *nntp_open(const gchar *server, gushort port, gchar *buf)
{
- SockInfo *sockinfo;
- gint sock;
+ SockInfo *sock;
- if ((sockinfo = sock_connect(server, port)) == NULL) {
+ if ((sock = sock_connect(server, port)) == NULL) {
log_warning(_("Can't connect to NNTP server: %s:%d\n"),
server, port);
- return -1;
+ return NULL;
}
- sock = sockinfo->sock;
- sock_sockinfo_free(sockinfo);
if (nntp_ok(sock, buf) == NN_SUCCESS)
return sock;
else {
sock_close(sock);
- return -1;
+ return NULL;
}
}
-gint nntp_group(gint sock, const gchar *group,
+gint nntp_group(SockInfo *sock, const gchar *group,
gint *num, gint *first, gint *last)
{
gint ok;
return NN_SUCCESS;
}
-gint nntp_get_article(gint sock, const gchar *cmd, gint num, gchar **msgid)
+gint nntp_get_article(SockInfo *sock, const gchar *cmd, gint num, gchar **msgid)
{
gint ok;
gchar buf[NNTPBUFSIZE];
return NN_SUCCESS;
}
-gint nntp_article(gint sock, gint num, gchar **msgid)
+gint nntp_article(SockInfo *sock, gint num, gchar **msgid)
{
return nntp_get_article(sock, "ARTICLE", num, msgid);
}
-gint nntp_body(gint sock, gint num, gchar **msgid)
+gint nntp_body(SockInfo *sock, gint num, gchar **msgid)
{
return nntp_get_article(sock, "BODY", num, msgid);
}
-gint nntp_head(gint sock, gint num, gchar **msgid)
+gint nntp_head(SockInfo *sock, gint num, gchar **msgid)
{
return nntp_get_article(sock, "HEAD", num, msgid);
}
-gint nntp_stat(gint sock, gint num, gchar **msgid)
+gint nntp_stat(SockInfo *sock, gint num, gchar **msgid)
{
return nntp_get_article(sock, "STAT", num, msgid);
}
-gint nntp_next(gint sock, gint *num, gchar **msgid)
+gint nntp_next(SockInfo *sock, gint *num, gchar **msgid)
{
gint ok;
gint resp;
return NN_SUCCESS;
}
-gint nntp_xover(gint sock, gint first, gint last)
+gint nntp_xover(SockInfo *sock, gint first, gint last)
{
gint ok;
gchar buf[NNTPBUFSIZE];
return NN_SUCCESS;
}
-gint nntp_post(gint sock, FILE *fp)
+gint nntp_post(SockInfo *sock, FILE *fp)
{
gint ok;
gchar buf[NNTPBUFSIZE];
return NN_SUCCESS;
}
-gint nntp_newgroups(gint sock)
+gint nntp_newgroups(SockInfo *sock)
{
return NN_SUCCESS;
}
-gint nntp_newnews(gint sock)
+gint nntp_newnews(SockInfo *sock)
{
return NN_SUCCESS;
}
-gint nntp_mode(gint sock, gboolean stream)
+gint nntp_mode(SockInfo *sock, gboolean stream)
{
gint ok;
return ok;
}
-gint nntp_authinfo_user(gint sock, const gchar *user)
+gint nntp_authinfo_user(SockInfo *sock, const gchar *user)
{
gint ok;
gchar buf[NNTPBUFSIZE];
return ok;
}
-gint nntp_authinfo_pass(gint sock, const gchar *pass)
+gint nntp_authinfo_pass(SockInfo *sock, const gchar *pass)
{
gint ok;
gchar buf[NNTPBUFSIZE];
return ok;
}
-gint nntp_ok(gint sock, gchar *argbuf)
+gint nntp_ok(SockInfo *sock, gchar *argbuf)
{
gint ok;
gchar buf[NNTPBUFSIZE];
return ok;
}
-static void nntp_gen_send(gint sock, const gchar *format, ...)
+static void nntp_gen_send(SockInfo *sock, const gchar *format, ...)
{
gchar buf[NNTPBUFSIZE];
va_list args;
sock_write(sock, buf, strlen(buf));
}
-static gint nntp_gen_recv(gint sock, gchar *buf, gint size)
+static gint nntp_gen_recv(SockInfo *sock, gchar *buf, gint size)
{
if (sock_read(sock, buf, size) == -1)
return NN_SOCKET;
a function is needed to read the newsgroups list.
*/
-gint nntp_list(gint sock)
+gint nntp_list(SockInfo *sock)
{
GList * result = NULL;
nntp_gen_send(sock, "LIST");
if ((ok = nntp_ok(sock, buf)) != NN_SUCCESS)
- return NN_ERROR;
+ return ok;
if (verbose)
log_print("NNTP< %s\n", buf);