Rocco Rutte:
[apps/madmutt.git] / nntp / nntp.c
index 9640ba2..a0fd012 100644 (file)
 #include "rfc2047.h"
 #include "nntp.h"
 
-#ifdef HAVE_PGP
-#include "pgp.h"
-#endif
-
-#ifdef HAVE_SMIME
-#include "smime.h"
-#endif
+#include "mutt_crypt.h"
 
 #include "lib/mem.h"
 #include "lib/str.h"
 #include "lib/intl.h"
+#include "lib/debug.h"
 
 #include <unistd.h>
 #include <string.h>
 
 static unsigned int _checked = 0;
 
-#ifdef DEBUG
-static void nntp_error (const char *where, const char *msg)
-{
-  dprint (1,
-          (debugfile, "nntp_error(): unexpected response in %s: %s\n", where,
-           msg));
+static void nntp_error (const char *where, const char *msg) {
+  debug_print (1, ("unexpected response in %s: %s\n", where, msg));
 }
-#endif /* DEBUG */
 
 static int nntp_auth (NNTP_SERVER * serv)
 {
@@ -74,8 +64,8 @@ static int nntp_auth (NNTP_SERVER * serv)
 
 #ifdef DEBUG
   /* don't print the password unless we're at the ungodly debugging level */
-  if (debuglevel < M_SOCK_LOG_FULL)
-    dprint (M_SOCK_LOG_CMD, (debugfile, "> AUTHINFO PASS *\n"));
+  if (DebugLevel < M_SOCK_LOG_FULL)
+    debug_print (M_SOCK_LOG_CMD, ("> AUTHINFO PASS *\n"));
 #endif
   snprintf (buf, sizeof (buf), "AUTHINFO PASS %s\r\n", conn->account.pass);
   mutt_socket_write_d (conn, buf, M_SOCK_LOG_FULL);
@@ -125,7 +115,7 @@ static int nntp_connect_and_auth (NNTP_SERVER * serv)
     mutt_message (_("Connected to %s. Posting NOT ok."), conn->account.host);
   else {
     mutt_socket_close (conn);
-    mutt_remove_trailing_ws (buf);
+    str_skip_trailws (buf);
     mutt_error ("%s", buf);
     sleep (2);
     return -1;
@@ -331,7 +321,7 @@ static int mutt_nntp_fetch (NNTP_DATA * nntp_data, char *query, char *msg,
       strfcpy (inbuf + lenbuf, p, sizeof (buf));
 
       if (chunk >= sizeof (buf)) {
-        lenbuf += safe_strlen (p);
+        lenbuf += mutt_strlen (p);
       }
       else {
         line++;
@@ -398,7 +388,7 @@ static void nntp_parse_xref (CONTEXT * ctx, char *group, char *xref,
       *colon = '\0';
       colon++;
       nntp_get_status (ctx, h, p, atoi (colon));
-      if (h && h->article_num == 0 && safe_strcmp (group, b) == 0)
+      if (h && h->article_num == 0 && mutt_strcmp (group, b) == 0)
         h->article_num = atoi (colon);
     }
   }
@@ -431,10 +421,8 @@ static int nntp_read_header (CONTEXT * ctx, const char *msgid,
 
   ret = mutt_nntp_fetch (nntp_data, buf, NULL, nntp_read_tempfile, f, 0);
   if (ret) {
-#ifdef DEBUG
     if (ret != -1)
-      dprint (1, (debugfile, "nntp_read_header: %s\n", buf));
-#endif
+      debug_print (1, ("%s\n", buf));
     fclose (f);
     unlink (tempfile);
     return (ret == -1 ? -1 : 1);
@@ -470,9 +458,9 @@ static int parse_description (char *line, void *n)
   d++;
   while (*d && (*d == '\t' || *d == ' '))
     d++;
-  dprint (2, (debugfile, "group: %s, desc: %s\n", line, d));
+  debug_print (2, ("group: %s, desc: %s\n", line, d));
   if ((data = (NNTP_DATA *) hash_find (news->newsgroups, line)) != NULL &&
-      safe_strcmp (d, data->desc)) {
+      mutt_strcmp (d, data->desc)) {
     FREE (&data->desc);
     data->desc = safe_strdup (d);
   }
@@ -826,7 +814,7 @@ int nntp_open_mailbox (CONTEXT * ctx)
 
   /* create NNTP-specific state struct if nof found in list */
   if ((nntp_data = (NNTP_DATA *) hash_find (serv->newsgroups, buf)) == NULL) {
-    nntp_data = safe_calloc (1, sizeof (NNTP_DATA) + safe_strlen (buf) + 1);
+    nntp_data = safe_calloc (1, sizeof (NNTP_DATA) + mutt_strlen (buf) + 1);
     nntp_data->group = (char *) nntp_data + sizeof (NNTP_DATA);
     strcpy (nntp_data->group, buf);
     hash_insert (serv->newsgroups, nntp_data->group, nntp_data, 0);
@@ -937,7 +925,7 @@ int nntp_fetch_message (MESSAGE * msg, CONTEXT * ctx, int msgno)
   if (ret == 1) {
     mutt_error (_("Article %d not found on server"),
                 ctx->hdrs[msgno]->article_num);
-    dprint (1, (debugfile, "nntp_fetch_message: %s\n", buf));
+    debug_print (1, ("%s\n", buf));
   }
 
   if (ret) {
@@ -965,9 +953,7 @@ int nntp_fetch_message (MESSAGE * msg, CONTEXT * ctx, int msgno)
    * full headers aren't parsed with XOVER, so the information wasn't
    * available then.
    */
-#if defined(HAVE_PGP) || defined(HAVE_SMIME)
   ctx->hdrs[msgno]->security = crypt_query (ctx->hdrs[msgno]->content);
-#endif /* HAVE_PGP || HAVE_SMIME */
 
   mutt_clear_error ();
   rewind (msg->fp);
@@ -1013,7 +999,7 @@ int nntp_post (const char *msg)
   buf[0] = '.';
   buf[1] = '\0';
   while (fgets (buf + 1, sizeof (buf) - 2, f) != NULL) {
-    len = safe_strlen (buf);
+    len = mutt_strlen (buf);
     if (buf[len - 1] == '\n') {
       buf[len - 1] = '\r';
       buf[len] = '\n';
@@ -1027,7 +1013,7 @@ int nntp_post (const char *msg)
   }
   fclose (f);
 
-  if (buf[safe_strlen (buf) - 1] != '\n')
+  if (buf[mutt_strlen (buf) - 1] != '\n')
     mutt_socket_write_d (nntp_data->nserv->conn, "\r\n", M_SOCK_LOG_HDR);
   mutt_socket_write_d (nntp_data->nserv->conn, ".\r\n", M_SOCK_LOG_HDR);
   if (mutt_socket_readln (buf, sizeof (buf), nntp_data->nserv->conn) < 0) {
@@ -1094,7 +1080,7 @@ void nntp_delete_data (void *p)
   FREE (p);
 }
 
-int nntp_sync_mailbox (CONTEXT * ctx)
+int nntp_sync_mailbox (CONTEXT * ctx, int unused1, int* unused2)
 {
   NNTP_DATA *data = ctx->data;
 
@@ -1141,7 +1127,7 @@ int nntp_close_mailbox (CONTEXT * ctx)
         return -1;
     }
   }
-  nntp_sync_mailbox (ctx);
+  nntp_sync_mailbox (ctx, 0, NULL);
   if (ctx->data && ((NNTP_DATA *) ctx->data)->nserv) {
     NNTP_SERVER *news;
 
@@ -1212,7 +1198,7 @@ static int _nntp_check_mailbox (CONTEXT * ctx, NNTP_DATA * nntp_data)
   return 0;
 }
 
-int nntp_check_mailbox (CONTEXT * ctx)
+int nntp_check_mailbox (CONTEXT * ctx, int* unused1, int unused2)
 {
   return _nntp_check_mailbox (ctx, (NNTP_DATA *) ctx->data);
 }
@@ -1238,7 +1224,7 @@ static int add_group (char *buf, void *serv)
     return 0;
   if ((nntp_data = (NNTP_DATA *) hash_find (s->newsgroups, group)) == NULL) {
     n++;
-    nntp_data = safe_calloc (1, sizeof (NNTP_DATA) + safe_strlen (group) + 1);
+    nntp_data = safe_calloc (1, sizeof (NNTP_DATA) + mutt_strlen (group) + 1);
     nntp_data->group = (char *) nntp_data + sizeof (NNTP_DATA);
     strcpy (nntp_data->group, group);
     nntp_data->nserv = s;