From cfd5f411041c7ef44087b032751792fadc74586d Mon Sep 17 00:00:00 2001 From: Pierre Habouzit Date: Wed, 7 Nov 2007 22:27:27 +0100 Subject: [PATCH] The NNTP patch is a joke, let's drop it altogether. Reason is that I believe it's not done properly, it has tons of issues, clutters the code, and well, will be revieved, eventually (or maybe not). Signed-off-by: Pierre Habouzit --- CMakeLists.txt | 11 - OPS | 21 +- account.c | 19 - account.h | 1 - browser.c | 496 ++------- browser.h | 7 - compose.c | 150 +-- functions.def | 45 - globals.h | 11 - headers.c | 5 +- init.c | 21 - init.h | 173 --- lib-lib/url.c | 4 - lib-lib/url.h | 2 - lib-mime/mime-types.h | 8 - lib-mime/mime.cpkg | 5 - lib-mime/rfc822parse.c | 24 - lib-mx/hcache.c | 16 - lib-mx/mx.c | 32 +- lib-mx/mx.h | 3 - lib-ui/complete.c | 47 - lib-ui/curs_main.c | 210 +--- lib-ui/hdrline.c | 7 - main.c | 52 +- mutt.h | 9 - muttlib.c | 8 - nntp.c | 2385 ---------------------------------------- nntp.h | 108 -- pager.c | 72 -- pattern.c | 9 - postpone.c | 11 - recvattach.c | 35 - recvcmd.c | 47 +- send.c | 154 +-- sendlib.c | 124 +-- sort.c | 14 +- 36 files changed, 172 insertions(+), 4174 deletions(-) delete mode 100644 nntp.c delete mode 100644 nntp.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 6cd5e20..0d03b50 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -37,7 +37,6 @@ ADD_DEFINITIONS("-DMUTTLOCALEDIR=\\\"${DATADIR}/locale\\\"") SET(MAILPATH CACHE STRING "Where new mail is spooled") OPTION(WITH_GPGME "Use GPGME [default: on]" ON) -OPTION(WITH_NNTP "Build NNTP support [default: off]") OPTION(WITH_IDN "Use GNU libidn for domain names [default: off]") OPTION(USE_FLOCK "Use flock to lock files [default: off]") @@ -207,11 +206,6 @@ IF(USE_HCACHE) ENDIF(NOT USE_HCACHE) ENDIF(USE_HCACHE) -IF(WITH_NNTP AND NOT USE_NNTP) - SET(USE_NNTP 1) - MESSAGE(STATUS "building NNTP support") -ENDIF(WITH_NNTP AND NOT USE_NNTP) - # }}} # C flags {{{ # big debug flags @@ -339,11 +333,6 @@ MADMUTT_SOURCES(madmuttsrc madmuttgen main.c ) -IF(WITH_NNTP) - MADMUTT_SOURCES(madmuttsrc madmuttgen - nntp.c - ) -ENDIF(WITH_NNTP) STRING(REGEX REPLACE ";" " " MUTTLIBS "${MUTTLIBS}") ADD_EXECUTABLE(madmutt ${madmuttsrc}) diff --git a/OPS b/OPS index fb8bc8d..1f0883e 100644 --- a/OPS +++ b/OPS @@ -8,16 +8,14 @@ OP_BOUNCE_MESSAGE "remail a message to another user" OP_BROWSER_NEW_FILE "select a new file in this directory" OP_BROWSER_VIEW_FILE "view file" OP_BROWSER_TELL "display the currently selected file's name" -OP_BROWSER_SUBSCRIBE "subscribe to current (IMAP/NNTP only)" -OP_BROWSER_UNSUBSCRIBE "unsubscribe to current (IMAP/NNTP only)" +OP_BROWSER_SUBSCRIBE "subscribe to current (IMAP only)" +OP_BROWSER_UNSUBSCRIBE "unsubscribe to current (IMAP only)" OP_BROWSER_TOGGLE_LSUB "toggle view all/subscribed mailboxes (IMAP only)" OP_BUFFY_LIST "list mailboxes with new mail" -OP_CATCHUP "mark all articles in newsgroup as read" OP_CHANGE_DIRECTORY "change directories" OP_CHECK_NEW "check mailboxes for new mail" OP_COMPOSE_ATTACH_FILE "attach a file(s) to this message" OP_COMPOSE_ATTACH_MESSAGE "attach message(s) to this message" -OP_COMPOSE_ATTACH_NEWS_MESSAGE "attach newsmessage(s) to this message" OP_COMPOSE_EDIT_BCC "edit the BCC list" OP_COMPOSE_EDIT_CC "edit the CC list" OP_COMPOSE_EDIT_DESCRIPTION "edit attachment description" @@ -28,9 +26,7 @@ OP_COMPOSE_EDIT_FROM "edit the from field" OP_COMPOSE_EDIT_HEADERS "edit the message with headers" OP_COMPOSE_EDIT_MESSAGE "edit the message" OP_COMPOSE_EDIT_MIME "edit attachment using mailcap entry" -OP_COMPOSE_EDIT_NEWSGROUPS "edit the newsgroups list" OP_COMPOSE_EDIT_REPLY_TO "edit the Reply-To field" -OP_COMPOSE_EDIT_FOLLOWUP_TO "edit the Followup-To field" OP_COMPOSE_EDIT_SUBJECT "edit the subject of this message" OP_COMPOSE_EDIT_TO "edit the TO list" OP_CREATE_MAILBOX "create a new mailbox (IMAP only)" @@ -88,13 +84,8 @@ OP_EXIT "exit this menu" OP_FILTER "filter attachment through a shell command" OP_FIRST_ENTRY "move to the first entry" OP_FLAG_MESSAGE "toggle a message's 'important' flag" -OP_FOLLOWUP "followup to newsgroup" -OP_FORWARD_TO_GROUP "forward to newsgroup" OP_FORWARD_MESSAGE "forward a message with comments" OP_GENERIC_SELECT_ENTRY "select the current entry" -OP_GET_CHILDREN "get all children of the current message" -OP_GET_MESSAGE "get message with Message-Id" -OP_GET_PARENT "get parent of the current message" OP_GROUP_REPLY "reply to all recipients" OP_HALF_DOWN "scroll down 1/2 page" OP_HALF_UP "scroll up 1/2 page" @@ -102,17 +93,13 @@ OP_HELP "this screen" OP_JUMP "jump to an index number" OP_LAST_ENTRY "move to the last entry" OP_LIST_REPLY "reply to specified mailing list" -OP_LOAD_ACTIVE "load active file from NNTP server" OP_MACRO "execute a macro" OP_MAIL "compose a new mail message" OP_MAIN_BREAK_THREAD "break the thread in two" OP_MAIN_CHANGE_FOLDER "open a different folder" OP_MAIN_CHANGE_FOLDER_READONLY "open a different folder in read only mode" -OP_MAIN_CHANGE_GROUP "open a different newsgroup" -OP_MAIN_CHANGE_GROUP_READONLY "open a different newsgroup in read only mode" OP_MAIN_CLEAR_FLAG "clear a status flag from a message" OP_MAIN_DELETE_PATTERN "delete messages matching a pattern" -OP_RECONSTRUCT_THREAD "reconstruct thread containing current message" OP_MAIN_IMAP_FETCH "force retrieval of mail from IMAP server" OP_MAIN_FETCH_MAIL "retrieve mail from POP server" OP_MAIN_FIRST_MESSAGE "move to the first message" @@ -148,7 +135,6 @@ OP_PAGER_HIDE_QUOTED "toggle display of quoted text" OP_PAGER_SKIP_QUOTED "skip beyond quoted text" OP_PAGER_TOP "jump to the top of the message" OP_PIPE "pipe message/attachment to a shell command" -OP_POST "post message to newsgroup" OP_PREV_ENTRY "move to the previous entry" OP_PREV_LINE "scroll up one line" OP_PREV_PAGE "move to the previous page" @@ -172,7 +158,6 @@ OP_SEARCH_TOGGLE "toggle search pattern coloring" OP_SHELL_ESCAPE "invoke a command in a subshell" OP_SORT "sort messages" OP_SORT_REVERSE "sort messages in reverse order" -OP_SUBSCRIBE_PATTERN "subscribe to newsgroups matching a pattern" OP_TAG "tag the current entry" OP_TAG_PREFIX "apply next function to tagged messages" OP_TAG_PREFIX_COND "apply next function ONLY to tagged messages" @@ -183,11 +168,9 @@ OP_TOGGLE_READ "toggle view of read messages" OP_TOGGLE_WRITE "toggle whether the mailbox will be rewritten" OP_TOGGLE_MAILBOXES "toggle whether to browse mailboxes or all files" OP_TOP_PAGE "move to the top of the page" -OP_UNCATCHUP "mark all articles in newsgroup as unread" OP_UNDELETE "undelete the current entry" OP_UNDELETE_THREAD "undelete all messages in thread" OP_UNDELETE_SUBTHREAD "undelete all messages in subthread" -OP_UNSUBSCRIBE_PATTERN "unsubscribe from newsgroups matching a pattern" OP_VERSION "show the Mutt version number and date" OP_VIEW_ATTACH "view attachment using mailcap entry if necessary" OP_VIEW_ATTACHMENTS "show MIME attachments" diff --git a/account.c b/account.c index bd4a776..78f80c6 100644 --- a/account.c +++ b/account.c @@ -34,11 +34,6 @@ int mutt_account_match (const ACCOUNT * a1, const ACCOUNT * a2) if (a1->type == M_ACCT_TYPE_POP && !m_strisempty(PopUser)) user = PopUser; -#ifdef USE_NNTP - if (a1->type == M_ACCT_TYPE_NNTP && !m_strisempty(NntpUser)) - user = NntpUser; -#endif - if (a1->has_user && a2->has_user) return !m_strcmp(a1->user, a2->user); if (a1->has_user) @@ -92,12 +87,6 @@ void mutt_account_tourl(ACCOUNT *account, ciss_url_t *url) url->scheme = account->has_ssl ? U_POPS : U_POP; } -#ifdef USE_NNTP - if (account->type == M_ACCT_TYPE_NNTP) { - url->scheme = account->has_ssl ? U_NNTPS : U_NNTP; - } -#endif - url->host = account->host; if (account->has_port) url->port = account->port; @@ -119,10 +108,6 @@ int mutt_account_getuser (ACCOUNT * account) m_strcpy(account->user, sizeof(account->user), ImapUser); else if ((account->type == M_ACCT_TYPE_POP) && !m_strisempty(PopUser)) m_strcpy(account->user, sizeof(account->user), PopUser); -#ifdef USE_NNTP - else if ((account->type == M_ACCT_TYPE_NNTP) && !m_strisempty(NntpUser)) - m_strcpy(account->user, sizeof(account->user), NntpUser); -#endif /* prompt (defaults to unix username), copy into account->user */ else { snprintf(prompt, sizeof(prompt), _("Username at %s: "), account->host); @@ -167,10 +152,6 @@ int mutt_account_getpass (ACCOUNT * account) m_strcpy(account->pass, sizeof(account->pass), ImapPass); else if ((account->type == M_ACCT_TYPE_POP) && !m_strisempty(PopPass)) m_strcpy(account->pass, sizeof(account->pass), PopPass); -#ifdef USE_NNTP - else if ((account->type == M_ACCT_TYPE_NNTP) && !m_strisempty(NntpPass)) - m_strcpy(account->pass, sizeof(account->pass), NntpPass); -#endif else { snprintf(prompt, sizeof(prompt), _("Password for %s@%s: "), account->has_login ? account->login : account->user, diff --git a/account.h b/account.h index 0cb7122..0c44f6e 100644 --- a/account.h +++ b/account.h @@ -17,7 +17,6 @@ enum { M_ACCT_TYPE_NONE = 0, M_ACCT_TYPE_IMAP, - M_ACCT_TYPE_NNTP, M_ACCT_TYPE_POP }; diff --git a/browser.c b/browser.c index f001c3d..44839d2 100644 --- a/browser.c +++ b/browser.c @@ -26,9 +26,6 @@ #include "attach.h" #include -#ifdef USE_NNTP -#include "nntp.h" -#endif typedef struct folder_t { struct folder_file *ff; @@ -90,17 +87,9 @@ static void browser_sort (struct browser_state *state) case SORT_ORDER: return; case SORT_DATE: -#ifdef USE_NNTP - if (option (OPTNEWS)) - return; -#endif f = browser_compare_date; break; case SORT_SIZE: -#ifdef USE_NNTP - if (option (OPTNEWS)) - return; -#endif f = browser_compare_size; break; case SORT_SUBJECT: @@ -286,105 +275,9 @@ folder_format_str(char *dest, ssize_t destlen, char op, return src; } -#ifdef USE_NNTP -static const char * -newsgroup_format_str(char *dest, ssize_t destlen, char op, - const char *src, const char *fmt, - const char *ifstr, const char *elstr, - anytype data, format_flag flags) -{ - char fn[STRING], tmp[STRING]; - FOLDER *folder = data.ptr; - - switch (op) { - case 'C': - snprintf (tmp, sizeof (tmp), "%%%sd", fmt); - snprintf (dest, destlen, tmp, folder->num + 1); - break; - - case 'f': - m_strcpy(fn, sizeof(fn), folder->ff->name); - snprintf (tmp, sizeof (tmp), "%%%ss", fmt); - snprintf (dest, destlen, tmp, fn); - break; - - case 'N': - snprintf (tmp, sizeof (tmp), "%%%sc", fmt); - if (folder->ff->nd->subscribed) - snprintf (dest, destlen, tmp, ' '); - else - snprintf (dest, destlen, tmp, folder->ff->new ? 'N' : 'u'); - break; - - case 'M': - snprintf (tmp, sizeof (tmp), "%%%sc", fmt); - if (folder->ff->nd->deleted) - snprintf (dest, destlen, tmp, 'D'); - else - snprintf (dest, destlen, tmp, folder->ff->nd->allowed ? ' ' : '-'); - break; - - case 's': - if (flags & M_FORMAT_OPTIONAL) { - if (folder->ff->nd->unread != 0) - m_strformat(dest, destlen, 0, ifstr, newsgroup_format_str, - data, flags); - else - m_strformat (dest, destlen, 0, elstr, newsgroup_format_str, - data, flags); - } - else if (Context && Context->data == folder->ff->nd) { - snprintf (tmp, sizeof (tmp), "%%%sd", fmt); - snprintf (dest, destlen, tmp, Context->unread); - } - else { - snprintf (tmp, sizeof (tmp), "%%%sd", fmt); - snprintf (dest, destlen, tmp, folder->ff->nd->unread); - } - break; - - case 'n': - if (Context && Context->data == folder->ff->nd) { - snprintf (tmp, sizeof (tmp), "%%%sd", fmt); - snprintf (dest, destlen, tmp, Context->new); - } - else if (option (OPTMARKOLD) && - folder->ff->nd->lastCached >= folder->ff->nd->first && - folder->ff->nd->lastCached <= folder->ff->nd->last) { - snprintf (tmp, sizeof (tmp), "%%%sd", fmt); - snprintf (dest, destlen, tmp, - folder->ff->nd->last - folder->ff->nd->lastCached); - } - else { - snprintf (tmp, sizeof (tmp), "%%%sd", fmt); - snprintf (dest, destlen, tmp, folder->ff->nd->unread); - } - break; - case 'd': - if (folder->ff->nd->desc != NULL) { - snprintf (tmp, sizeof (tmp), "%%%ss", fmt); - snprintf (dest, destlen, tmp, folder->ff->nd->desc); - } - else { - snprintf (tmp, sizeof (tmp), "%%%ss", fmt); - snprintf (dest, destlen, tmp, ""); - } - break; - } - return (src); -} -#endif /* USE_NNTP */ - -#ifdef USE_NNTP -static void add_folder (MUTTMENU * m, struct browser_state *state, - const char *name, const struct stat *s, - void *data, int new) -#else static void add_folder (MUTTMENU * m, struct browser_state *state, - const char *name, const struct stat *s, - int new) -#endif + const char *name, const struct stat *s, int new) { if (state->entrylen == state->entrymax) { /* need to allocate more space */ @@ -405,10 +298,6 @@ static void add_folder (MUTTMENU * m, struct browser_state *state, (state->entry)[state->entrylen].name = m_strdup(name); (state->entry)[state->entrylen].desc = m_strdup(name); (state->entry)[state->entrylen].imap = 0; -#ifdef USE_NNTP - if (option (OPTNEWS)) - (state->entry)[state->entrylen].nd = data; -#endif (state->entrylen)++; } @@ -426,87 +315,62 @@ static void init_state (struct browser_state *state, MUTTMENU * menu) static int examine_directory (MUTTMENU * menu, struct browser_state *state, char *d, const char *prefix) { -#ifdef USE_NNTP - if (option (OPTNEWS)) { - nntp_data_t *data; - nntp_server_t *news = CurrentNewsSrv; - -/* buffy_check (0); */ - init_state (state, menu); - - for (data = news->list; data; data = data->next) { - nntp_sync_sidebar(data); - if (m_strncmp (prefix, data->group, m_strlen(prefix)) != 0) - continue; - if (!((regexec (Mask.rx, data->group, 0, NULL, 0) == 0) ^ Mask.neg)) + + struct stat s; + DIR *dp; + struct dirent *de; + char buffer[_POSIX_PATH_MAX + STRING]; + int i = -1; + + while (stat (d, &s) == -1) { + if (errno == ENOENT) { + /* The last used directory is deleted, try to use the parent dir. */ + char *c = strrchr (d, '/'); + + if (c && (c > d)) { + *c = 0; continue; - add_folder (menu, state, data->group, NULL, data, data->new); - } - sidebar_draw (); - } - else -#endif /* USE_NNTP */ - { - struct stat s; - DIR *dp; - struct dirent *de; - char buffer[_POSIX_PATH_MAX + STRING]; - int i = -1; - - while (stat (d, &s) == -1) { - if (errno == ENOENT) { - /* The last used directory is deleted, try to use the parent dir. */ - char *c = strrchr (d, '/'); - - if (c && (c > d)) { - *c = 0; - continue; - } } - mutt_perror (d); - return (-1); } + mutt_perror (d); + return (-1); + } - if (!S_ISDIR (s.st_mode)) { - mutt_error (_("%s is not a directory."), d); - return (-1); - } + if (!S_ISDIR (s.st_mode)) { + mutt_error (_("%s is not a directory."), d); + return (-1); + } - buffy_check (0); + buffy_check (0); - if ((dp = opendir (d)) == NULL) { - mutt_perror (d); - return (-1); - } + if ((dp = opendir (d)) == NULL) { + mutt_perror (d); + return (-1); + } - init_state (state, menu); + init_state (state, menu); - while ((de = readdir (dp)) != NULL) { - if (m_strcmp(de->d_name, ".") == 0) - continue; /* we don't need . */ + while ((de = readdir (dp)) != NULL) { + if (m_strcmp(de->d_name, ".") == 0) + continue; /* we don't need . */ - if (m_strncmp(prefix, de->d_name, m_strlen(prefix)) != 0) - continue; - if (!((regexec (Mask.rx, de->d_name, 0, NULL, 0) == 0) ^ Mask.neg)) - continue; + if (m_strncmp(prefix, de->d_name, m_strlen(prefix)) != 0) + continue; + if (!((regexec (Mask.rx, de->d_name, 0, NULL, 0) == 0) ^ Mask.neg)) + continue; - mutt_concat_path(buffer, sizeof(buffer), d, de->d_name); - if (lstat (buffer, &s) == -1) - continue; + mutt_concat_path(buffer, sizeof(buffer), d, de->d_name); + if (lstat (buffer, &s) == -1) + continue; - if ((!S_ISREG (s.st_mode)) && (!S_ISDIR (s.st_mode)) && - (!S_ISLNK (s.st_mode))) - continue; + if ((!S_ISREG (s.st_mode)) && (!S_ISDIR (s.st_mode)) && + (!S_ISLNK (s.st_mode))) + continue; - i = buffy_lookup (buffer); -#ifdef USE_NNTP - add_folder (menu, state, de->d_name, &s, NULL, i >= 0 ? Incoming.arr[i]->new : 0); -#else - add_folder (menu, state, de->d_name, &s, i >= 0 ? Incoming.arr[i]->new : 0); -#endif - } - closedir (dp); + i = buffy_lookup (buffer); + add_folder (menu, state, de->d_name, &s, i >= 0 ? Incoming.arr[i]->new : 0); } + closedir (dp); sidebar_draw (); browser_sort (state); return 0; @@ -517,88 +381,44 @@ static int examine_mailboxes (MUTTMENU * menu, struct browser_state *state) { struct stat s; char buffer[LONG_STRING]; + int i = 0; + BUFFY* tmp; -#ifdef USE_NNTP - if (option (OPTNEWS)) { - nntp_data_t *data; - nntp_server_t *news = CurrentNewsSrv; + if (!Incoming.len) + return (-1); + buffy_check (0); -/* buffy_check (0); */ - init_state (state, menu); + init_state (state, menu); - for (data = news->list; data; data = data->next) { - nntp_sync_sidebar (data); - if ((data->new || (data->subscribed && - (!option (OPTSHOWONLYUNREAD)|| data->unread)))) - add_folder (menu, state, data->group, NULL, data, data->new); + for (i = 0; i < Incoming.len; i++) { + tmp = Incoming.arr[i]; + tmp->magic = mx_get_magic (tmp->path); + if (tmp->magic == M_IMAP) { + add_folder (menu, state, tmp->path, NULL, tmp->new); + continue; } - sidebar_draw (); - } - else -#endif - { - int i = 0; - BUFFY* tmp; - - if (!Incoming.len) - return (-1); - buffy_check (0); - - init_state (state, menu); - - for (i = 0; i < Incoming.len; i++) { - tmp = Incoming.arr[i]; - tmp->magic = mx_get_magic (tmp->path); - if (tmp->magic == M_IMAP) { -#ifdef USE_NNTP - add_folder (menu, state, tmp->path, NULL, NULL, tmp->new); -#else - add_folder (menu, state, tmp->path, NULL, tmp->new); -#endif - continue; - } - if (tmp->magic == M_POP) { -#ifdef USE_NNTP - add_folder (menu, state, tmp->path, NULL, NULL, tmp->new); -#else - add_folder (menu, state, tmp->path, NULL, tmp->new); -#endif - continue; - } -#ifdef USE_NNTP - if (tmp->magic == M_NNTP) { - add_folder (menu, state, tmp->path, NULL, NULL, tmp->new); - continue; - } -#endif - if (lstat (tmp->path, &s) == -1) - continue; - - if ((!S_ISREG (s.st_mode)) && (!S_ISDIR (s.st_mode)) && - (!S_ISLNK (s.st_mode))) - continue; + if (tmp->magic == M_POP) { + add_folder (menu, state, tmp->path, NULL, tmp->new); + continue; + } + if (lstat (tmp->path, &s) == -1) + continue; - m_strcpy(buffer, sizeof(buffer), NONULL(tmp->path)); - mutt_pretty_mailbox (buffer); + if ((!S_ISREG (s.st_mode)) && (!S_ISDIR (s.st_mode)) && + (!S_ISLNK (s.st_mode))) + continue; -#ifdef USE_NNTP - add_folder (menu, state, buffer, &s, NULL, tmp->new); -#else - add_folder (menu, state, buffer, &s, tmp->new); -#endif - } + m_strcpy(buffer, sizeof(buffer), NONULL(tmp->path)); + mutt_pretty_mailbox (buffer); + add_folder (menu, state, buffer, &s, tmp->new); } + browser_sort (state); return 0; } static int select_file_search (MUTTMENU * menu, regex_t * re, int n) { -#ifdef USE_NNTP - if (option (OPTNEWS)) - return (regexec - (re, ((struct folder_file *) menu->data)[n].desc, 0, NULL, 0)); -#endif return (regexec (re, ((struct folder_file *) menu->data)[n].name, 0, NULL, 0)); } @@ -610,14 +430,8 @@ static void folder_entry (char *s, ssize_t slen, MUTTMENU * menu, int num) folder.ff = &((struct folder_file *) menu->data)[num]; folder.num = num; -#ifdef USE_NNTP - if (option (OPTNEWS)) - m_strformat(s, slen, getmaxx(main_w), GroupFormat, newsgroup_format_str, - &folder, 0); - else -#endif - m_strformat(s, slen, getmaxx(main_w), FolderFormat, folder_format_str, - &folder, 0); + m_strformat(s, slen, getmaxx(main_w), FolderFormat, folder_format_str, + &folder, 0); } static void init_menu (struct browser_state *state, MUTTMENU * menu, @@ -636,16 +450,6 @@ static void init_menu (struct browser_state *state, MUTTMENU * menu, menu->tagged = 0; -#ifdef USE_NNTP - if (option (OPTNEWS)) { - if (buffy) - snprintf (title, titlelen, "%s", _("Subscribed newsgroups")); - else - snprintf (title, titlelen, _("Newsgroups on server [%s]"), - CurrentNewsSrv->conn->account.host); - } - else -#endif if (buffy) snprintf(title, titlelen, _("Mailboxes [%d]"), buffy_check(0)); else { @@ -700,25 +504,6 @@ void mutt_select_file (char *f, ssize_t flen, int flags, char ***files, if (!folder) m_strcpy(LastDirBackup, sizeof(LastDirBackup), LastDir); -#ifdef USE_NNTP - if (option (OPTNEWS)) { - if (*f) - m_strcpy(prefix, sizeof(prefix), f); - else { - nntp_data_t *list; - - /* default state for news reader mode is browse subscribed newsgroups */ - buffy = 0; - for (list = CurrentNewsSrv->list; list; list = list->next) { - if (list->subscribed) { - buffy = 1; - break; - } - } - } - } - else -#endif if (*f) { mutt_expand_path (f, flen); if (imap_is_magic (f, NULL) == M_IMAP) { @@ -900,12 +685,7 @@ void mutt_select_file (char *f, ssize_t flen, int flags, char ***files, } } -#ifdef USE_NNTP - if (buffy || option (OPTNEWS)) /* news have not path */ -#else - if (buffy) -#endif - { + if (buffy) { m_strcpy(f, flen, state.entry[menu->current].name); mutt_expand_path (f, flen); } @@ -1042,12 +822,6 @@ void mutt_select_file (char *f, ssize_t flen, int flags, char ***files, break; case OP_CHANGE_DIRECTORY: - -#ifdef USE_NNTP - if (option (OPTNEWS)) - break; -#endif - m_strcpy(buf, sizeof(buf), LastDir); if (!state.imap_browse) { @@ -1285,132 +1059,12 @@ void mutt_select_file (char *f, ssize_t flen, int flags, char ***files, } break; -#ifdef USE_NNTP - case OP_CATCHUP: - case OP_UNCATCHUP: - if (option (OPTNEWS)) { - struct folder_file *folder_f = &state.entry[menu->current]; - nntp_data_t *nd; - - if (i == OP_CATCHUP) - nd = mutt_newsgroup_catchup (CurrentNewsSrv, folder_f->name); - else - nd = mutt_newsgroup_uncatchup (CurrentNewsSrv, folder_f->name); - - if (nd) { - if (menu->current + 1 < menu->max) - menu->current++; - menu->redraw = REDRAW_MOTION_RESYNCH; - } - } - break; - - case OP_LOAD_ACTIVE: - if (!option (OPTNEWS)) - break; - - { - nntp_data_t *data; - - for (data = CurrentNewsSrv->list; data; data = data->next) { - data->deleted = 1; - } - } - nntp_get_active (CurrentNewsSrv); - - destroy_state (&state); - if (buffy) - examine_mailboxes (menu, &state); - else - examine_directory (menu, &state, NULL, NULL); - init_menu (&state, menu, title, sizeof (title), buffy); - break; -#endif /* USE_NNTP */ - case OP_BROWSER_SUBSCRIBE: case OP_BROWSER_UNSUBSCRIBE: -#ifdef USE_NNTP - case OP_SUBSCRIBE_PATTERN: - case OP_UNSUBSCRIBE_PATTERN: - if (option (OPTNEWS)) { - regex_t *rx = p_new(regex_t, 1); - char *s = buf; - int j = menu->current; - nntp_data_t *nd; - nntp_server_t *news = CurrentNewsSrv; - - if (i == OP_SUBSCRIBE_PATTERN || i == OP_UNSUBSCRIBE_PATTERN) { - char tmp[STRING]; - int err; - - buf[0] = 0; - if (i == OP_SUBSCRIBE_PATTERN) - snprintf (tmp, sizeof (tmp), _("Subscribe pattern: ")); - else - snprintf (tmp, sizeof (tmp), _("Unsubscribe pattern: ")); - if (mutt_get_field (tmp, buf, sizeof (buf), 0) != 0 || !buf[0]) { - p_delete(&rx); - break; - } - - if ((err = REGCOMP (rx, s, REG_NOSUB)) != 0) { - regerror (err, rx, buf, sizeof (buf)); - regfree (rx); - p_delete(&rx); - mutt_error ("%s", buf); - break; - } - menu->redraw = REDRAW_FULL; - j = 0; - } - else if (!state.entrylen) { - mutt_error _("No newsgroups match the mask"); - - break; - } - - for (; j < state.entrylen; j++) { - struct folder_file *folderf = &state.entry[j]; - - if (i == OP_BROWSER_SUBSCRIBE || i == OP_BROWSER_UNSUBSCRIBE || - regexec (rx, folderf->name, 0, NULL, 0) == 0) { - if (i == OP_BROWSER_SUBSCRIBE || i == OP_SUBSCRIBE_PATTERN) - nd = mutt_newsgroup_subscribe (news, folderf->name); - else - nd = mutt_newsgroup_unsubscribe (news, folderf->name); - } - if (i == OP_BROWSER_SUBSCRIBE || i == OP_BROWSER_UNSUBSCRIBE) { - if (menu->current + 1 < menu->max) - menu->current++; - menu->redraw = REDRAW_MOTION_RESYNCH; - break; - } - } - if (i == OP_SUBSCRIBE_PATTERN) { - nd = news ? news->list : NULL; - for (; nd; nd = nd->next) { - if (nd->group && !nd->subscribed) { - if (regexec (rx, nd->group, 0, NULL, 0) == 0) { - mutt_newsgroup_subscribe (news, nd->group); - add_folder (menu, &state, nd->group, NULL, nd, nd->new); - } - } - } - init_menu (&state, menu, title, sizeof (title), buffy); - } - mutt_newsrc_update (news); - if (i != OP_BROWSER_SUBSCRIBE && i != OP_BROWSER_UNSUBSCRIBE) - regfree (rx); - p_delete(&rx); - } + if (i == OP_BROWSER_SUBSCRIBE) + imap_subscribe (state.entry[menu->current].name, 1); else -#endif /* USE_NNTP */ - { - if (i == OP_BROWSER_SUBSCRIBE) - imap_subscribe (state.entry[menu->current].name, 1); - else - imap_subscribe (state.entry[menu->current].name, 0); - } + imap_subscribe (state.entry[menu->current].name, 0); } } diff --git a/browser.h b/browser.h index 721889b..c4aa293 100644 --- a/browser.h +++ b/browser.h @@ -10,10 +10,6 @@ #ifndef _BROWSER_H #define _BROWSER_H 1 -#ifdef USE_NNTP -#include "nntp.h" -#endif - struct folder_file { mode_t mode; off_t size; @@ -29,9 +25,6 @@ struct folder_file { unsigned imap:1; unsigned selectable:1; unsigned inferiors:1; -#ifdef USE_NNTP - nntp_data_t *nd; -#endif unsigned tagged:1; }; diff --git a/compose.c b/compose.c index 4fe6eb4..02d4aae 100644 --- a/compose.c +++ b/compose.c @@ -31,10 +31,6 @@ #include "charset.h" #include "buffy.h" -#ifdef USE_NNTP -#include "nntp.h" -#endif - #define CHECK_COUNT \ if (idxlen == 0) { \ mutt_error _("There are no attachments."); \ @@ -53,17 +49,7 @@ enum { HDR_CRYPT, HDR_CRYPTINFO, -#ifdef USE_NNTP - HDR_NEWSGROUPS, - HDR_FOLLOWUPTO, - HDR_XCOMMENTTO, -#endif - -#ifndef USE_NNTP - HDR_ATTACH = (HDR_FCC + 5) /* where to start printing the attachments */ -#else HDR_ATTACH = (HDR_FCC + 7) -#endif }; #define HDR_XOFFSET 14 @@ -78,9 +64,6 @@ static const char *Prompts[] = { "Subject: ", "Reply-To: ", "Fcc: ", -#ifdef USE_NNTP - "", "", "", "Newsgroups: ", "Followup-To: ", "X-Comment-To: " -#endif }; static void snd_entry (char *b, ssize_t blen, MUTTMENU * menu, int num) { @@ -179,20 +162,9 @@ static void draw_envelope_addr (int line, address_t * addr) static void draw_envelope (HEADER * msg, char *fcc) { draw_envelope_addr (HDR_FROM, msg->env->from); -#ifdef USE_NNTP - if (!option (OPTNEWSSEND)) { -#endif - draw_envelope_addr (HDR_TO, msg->env->to); - draw_envelope_addr (HDR_CC, msg->env->cc); - draw_envelope_addr (HDR_BCC, msg->env->bcc); -#ifdef USE_NNTP - } else { - mvwprintw (main_w, HDR_TO, 0, TITLE_FMT, Prompts[HDR_NEWSGROUPS - 1]); - mutt_paddstr (main_w, W, NONULL (msg->env->newsgroups)); - mvwprintw (main_w, HDR_CC, 0, TITLE_FMT, Prompts[HDR_FOLLOWUPTO - 1]); - mutt_paddstr (main_w, W, NONULL (msg->env->followup_to)); - } -#endif + draw_envelope_addr (HDR_TO, msg->env->to); + draw_envelope_addr (HDR_CC, msg->env->cc); + draw_envelope_addr (HDR_BCC, msg->env->bcc); mvwprintw (main_w, HDR_SUBJECT, 0, TITLE_FMT, Prompts[HDR_SUBJECT - 1]); mutt_paddstr (main_w, W, NONULL (msg->env->subject)); draw_envelope_addr (HDR_REPLYTO, msg->env->reply_to); @@ -424,13 +396,6 @@ int mutt_compose_menu (HEADER * msg, /* structure for new message */ int oldSort, oldSortAux; struct stat st; -#ifdef USE_NNTP - int news = 0; /* is it a news article ? */ - - if (option (OPTNEWSSEND)) - news++; -#endif - mutt_attach_init (msg->content); idx = mutt_gen_attach_list (msg->content, -1, idx, &idxlen, &idxmax, 0, 1); @@ -443,9 +408,6 @@ int mutt_compose_menu (HEADER * msg, /* structure for new message */ menu->data = idx; while (loop) { -#ifdef USE_NNTP - unset_option (OPTNEWS); /* for any case */ -#endif switch (op = mutt_menuLoop (menu)) { case OP_REDRAW: draw_envelope (msg, fcc); @@ -457,74 +419,17 @@ int mutt_compose_menu (HEADER * msg, /* structure for new message */ mutt_message_hook (NULL, msg, M_SEND2HOOK); break; case OP_COMPOSE_EDIT_TO: -#ifdef USE_NNTP - if (!news) { -#endif - menu->redraw = edit_address_list (HDR_TO, &msg->env->to); - mutt_message_hook (NULL, msg, M_SEND2HOOK); -#ifdef USE_NNTP - } -#endif + menu->redraw = edit_address_list (HDR_TO, &msg->env->to); + mutt_message_hook (NULL, msg, M_SEND2HOOK); break; case OP_COMPOSE_EDIT_BCC: -#ifdef USE_NNTP - if (!news) { -#endif - menu->redraw = edit_address_list (HDR_BCC, &msg->env->bcc); - mutt_message_hook (NULL, msg, M_SEND2HOOK); -#ifdef USE_NNTP - } -#endif + menu->redraw = edit_address_list (HDR_BCC, &msg->env->bcc); + mutt_message_hook (NULL, msg, M_SEND2HOOK); break; case OP_COMPOSE_EDIT_CC: -#ifdef USE_NNTP - if (!news) { -#endif - menu->redraw = edit_address_list (HDR_CC, &msg->env->cc); - mutt_message_hook (NULL, msg, M_SEND2HOOK); -#ifdef USE_NNTP - } -#endif - break; -#ifdef USE_NNTP - case OP_COMPOSE_EDIT_NEWSGROUPS: - if (news) { - if (msg->env->newsgroups) - m_strcpy(buf, sizeof(buf), msg->env->newsgroups); - else - buf[0] = 0; - if (mutt_get_field ("Newsgroups: ", buf, sizeof (buf), 0) == 0 - && buf[0]) { - p_delete(&msg->env->newsgroups); - m_strrtrim(buf); - msg->env->newsgroups = m_strdup(skipspaces(buf)); - wmove (main_w, HDR_TO, HDR_XOFFSET); - wclrtoeol (main_w); - if (msg->env->newsgroups) - wprintw (main_w, "%-*.*s", W, W, msg->env->newsgroups); - } - } - break; - - case OP_COMPOSE_EDIT_FOLLOWUP_TO: - if (news) { - buf[0] = 0; - if (msg->env->followup_to) - m_strcpy(buf, sizeof(buf), msg->env->followup_to); - if (mutt_get_field ("Followup-To: ", buf, sizeof (buf), 0) == 0 - && buf[0]) { - p_delete(&msg->env->followup_to); - m_strrtrim(buf); - msg->env->followup_to = m_strdup(skipspaces(buf)); - wmove (main_w, HDR_CC, HDR_XOFFSET); - wclrtoeol (main_w); - if (msg->env->followup_to) - wprintw (main_w, "%-*.*s", W, W, msg->env->followup_to); - } - } + menu->redraw = edit_address_list (HDR_CC, &msg->env->cc); + mutt_message_hook (NULL, msg, M_SEND2HOOK); break; - -#endif case OP_COMPOSE_EDIT_SUBJECT: if (msg->env->subject) m_strcpy(buf, sizeof(buf), msg->env->subject); @@ -645,9 +550,6 @@ int mutt_compose_menu (HEADER * msg, /* structure for new message */ break; case OP_COMPOSE_ATTACH_MESSAGE: -#ifdef USE_NNTP - case OP_COMPOSE_ATTACH_NEWS_MESSAGE: -#endif { const char *prompt; HEADER *h; @@ -655,21 +557,8 @@ int mutt_compose_menu (HEADER * msg, /* structure for new message */ fname[0] = 0; prompt = _("Open mailbox to attach message from"); -#ifdef USE_NNTP - unset_option (OPTNEWS); - if (op == OP_COMPOSE_ATTACH_NEWS_MESSAGE) { - if (!(CurrentNewsSrv = mutt_select_newsserver (NewsServer))) - break; - - prompt = _("Open newsgroup to attach message from"); - set_option (OPTNEWS); - } -#endif if (Context) -#ifdef USE_NNTP - if ((op == OP_COMPOSE_ATTACH_MESSAGE) ^ (Context->magic == M_NNTP)) -#endif { m_strcpy(fname, sizeof(fname), NONULL(Context->path)); mutt_pretty_mailbox (fname); @@ -679,22 +568,13 @@ int mutt_compose_menu (HEADER * msg, /* structure for new message */ == -1 || !fname[0]) break; -#ifdef USE_NNTP - if (option (OPTNEWS)) - nntp_expand_path (fname, sizeof (fname), - &CurrentNewsSrv->conn->account); - else -#endif - mutt_expand_path (fname, sizeof (fname)); + mutt_expand_path (fname, sizeof (fname)); if (mx_get_magic (fname) != M_IMAP && mx_get_magic (fname) != M_POP) { -#ifdef USE_NNTP - if (mx_get_magic (fname) != M_NNTP && !option (OPTNEWS)) -#endif /* check to make sure the file exists and is readable */ - if (access (fname, R_OK) == -1) { - mutt_perror (fname); - break; - } + if (access (fname, R_OK) == -1) { + mutt_perror (fname); + break; + } } menu->redraw = REDRAW_FULL; @@ -764,8 +644,8 @@ int mutt_compose_menu (HEADER * msg, /* structure for new message */ /* Restore old $sort and $sort_aux */ Sort = oldSort; SortAux = oldSortAux; + mutt_message_hook (NULL, msg, M_SEND2HOOK); } - mutt_message_hook (NULL, msg, M_SEND2HOOK); break; case OP_DELETE: diff --git a/functions.def b/functions.def index c4b730d..7b5f3f5 100644 --- a/functions.def +++ b/functions.def @@ -90,10 +90,6 @@ LIST(OpMain) ITEM("break-thread", OP_MAIN_BREAK_THREAD, "#") ITEM("change-folder", OP_MAIN_CHANGE_FOLDER, "c") ITEM("change-folder-readonly", OP_MAIN_CHANGE_FOLDER_READONLY,"\033c") -#ifdef USE_NNTP - ITEM("change-newsgroup", OP_MAIN_CHANGE_GROUP, "i") - ITEM("change-newsgroup-readonly", OP_MAIN_CHANGE_GROUP_READONLY, "\033i") -#endif ITEM("collapse-thread", OP_MAIN_COLLAPSE_THREAD, "\033v") ITEM("collapse-all", OP_MAIN_COLLAPSE_ALL, "\033V") ITEM("copy-message", OP_COPY_MESSAGE, "C") @@ -106,14 +102,6 @@ LIST(OpMain) ITEM("edit", OP_EDIT_MESSAGE, "e") ITEM("edit-type", OP_EDIT_TYPE, "\005") ITEM("forward-message", OP_FORWARD_MESSAGE, "f") -#ifdef USE_NNTP - ITEM("forward-to-group", OP_FORWARD_TO_GROUP, "\033F") - ITEM("followup-message", OP_FOLLOWUP, "F") - ITEM("get-children", OP_GET_CHILDREN, NULL) - ITEM("get-message", OP_GET_MESSAGE, "\007") - ITEM("get-parent", OP_GET_PARENT, "\033G") - ITEM("reconstruct-thread", OP_RECONSTRUCT_THREAD, NULL) -#endif ITEM("flag-message", OP_FLAG_MESSAGE, "\033f") ITEM("group-reply", OP_GROUP_REPLY, "g") ITEM("fetch-mail", OP_MAIN_FETCH_MAIL, "G") @@ -137,9 +125,6 @@ LIST(OpMain) ITEM("sort-mailbox", OP_SORT, "o") ITEM("sort-reverse", OP_SORT_REVERSE, "O") ITEM("print-message", OP_PRINT, "p") -#ifdef USE_NNTP - ITEM("post-message", OP_POST, "P") -#endif ITEM("previous-thread", OP_MAIN_PREV_THREAD, "\020") ITEM("previous-subthread", OP_MAIN_PREV_SUBTHREAD, "\033p") ITEM("recall-message", OP_RECALL_MESSAGE, "R") @@ -160,9 +145,6 @@ LIST(OpMain) ITEM("set-flag", OP_MAIN_SET_FLAG, "w") ITEM("clear-flag", OP_MAIN_CLEAR_FLAG, "W") ITEM("toggle-read", OP_TOGGLE_READ, "X") -#ifdef USE_NNTP - ITEM("catchup", OP_CATCHUP, "y") -#endif ITEM("display-message", OP_DISPLAY_MESSAGE, "\n") ITEM("buffy-list", OP_BUFFY_LIST, ".") ITEM("sync-mailbox", OP_MAIN_SYNC_FOLDER, "$") @@ -199,10 +181,6 @@ LIST(OpPager) ITEM("bounce-message", OP_BOUNCE_MESSAGE, "b") ITEM("change-folder", OP_MAIN_CHANGE_FOLDER, "c") ITEM("change-folder-readonly", OP_MAIN_CHANGE_FOLDER_READONLY, "\033c") -#ifdef USE_NNTP - ITEM("change-newsgroup", OP_MAIN_CHANGE_GROUP, "i") - ITEM("change-newsgroup-readonly", OP_MAIN_CHANGE_GROUP_READONLY, "\033i") -#endif ITEM("copy-message", OP_COPY_MESSAGE, "C") ITEM("decode-copy", OP_DECODE_COPY, "\033C") ITEM("delete-message", OP_DELETE, "d") @@ -210,10 +188,6 @@ LIST(OpPager) ITEM("delete-subthread", OP_DELETE_SUBTHREAD, "\033d") ITEM("edit", OP_EDIT_MESSAGE, "e") ITEM("edit-type", OP_EDIT_TYPE, "\005") -#ifdef USE_NNTP - ITEM("followup-message", OP_FOLLOWUP, "F") - ITEM("forward-to-group", OP_FORWARD_TO_GROUP, "\033F") -#endif ITEM("forward-message", OP_FORWARD_MESSAGE, "f") ITEM("flag-message", OP_FLAG_MESSAGE, "\033f") ITEM("group-reply", OP_GROUP_REPLY, "g") @@ -232,9 +206,6 @@ LIST(OpPager) ITEM("next-thread", OP_MAIN_NEXT_THREAD, "\016") ITEM("next-subthread", OP_MAIN_NEXT_SUBTHREAD, "\033n") ITEM("print-message", OP_PRINT, "p") -#ifdef USE_NNTP - ITEM("post-message", OP_POST, "P") -#endif ITEM("previous-thread", OP_MAIN_PREV_THREAD, "\020") ITEM("previous-subthread", OP_MAIN_PREV_SUBTHREAD, "\033p") ITEM("purge-message", OP_PURGE_MESSAGE, NULL) @@ -302,10 +273,6 @@ LIST(OpAttach) ITEM("bounce-message", OP_BOUNCE_MESSAGE, "b") ITEM("display-toggle-weed", OP_DISPLAY_HEADERS, "h") ITEM("edit-type", OP_EDIT_TYPE, "\005") -#ifdef USE_NNTP - ITEM("followup-message", OP_FOLLOWUP, "F") - ITEM("forward-to-group", OP_FORWARD_TO_GROUP, "\033F") -#endif ITEM("print-entry", OP_PRINT, "p") ITEM("save-entry", OP_SAVE, "s") ITEM("pipe-entry", OP_PIPE, "|") @@ -328,7 +295,6 @@ ENDLIST LIST(OpCompose) ITEM("attach-file", OP_COMPOSE_ATTACH_FILE, "a") ITEM("attach-message", OP_COMPOSE_ATTACH_MESSAGE, "A") - ITEM("attach-news-message", OP_COMPOSE_ATTACH_NEWS_MESSAGE, "\033a") ITEM("edit-bcc", OP_COMPOSE_EDIT_BCC, "b") ITEM("edit-cc", OP_COMPOSE_EDIT_CC, "c") ITEM("copy-file", OP_SAVE, "C") @@ -347,10 +313,6 @@ LIST(OpCompose) ITEM("print-entry", OP_PRINT, "l") ITEM("edit-mime", OP_COMPOSE_EDIT_MIME, "m") ITEM("new-mime", OP_COMPOSE_NEW_MIME, "n") -#ifdef USE_NNTP - ITEM("edit-newsgroups", OP_COMPOSE_EDIT_NEWSGROUPS, "N") - ITEM("edit-followup-to", OP_COMPOSE_EDIT_FOLLOWUP_TO, "o") -#endif ITEM("postpone-message", OP_COMPOSE_POSTPONE_MESSAGE, "P") ITEM("edit-reply-to", OP_COMPOSE_EDIT_REPLY_TO, "r") ITEM("rename-file", OP_COMPOSE_RENAME_FILE, "R") @@ -388,13 +350,6 @@ LIST(OpBrowser) ITEM("select-new", OP_BROWSER_NEW_FILE, "N") ITEM("check-new", OP_CHECK_NEW, NULL) ITEM("toggle-mailboxes", OP_TOGGLE_MAILBOXES, "\t") -#ifdef USE_NNTP - ITEM("reload-active", OP_LOAD_ACTIVE, "g") - ITEM("subscribe-pattern", OP_SUBSCRIBE_PATTERN, "S") - ITEM("unsubscribe-pattern", OP_UNSUBSCRIBE_PATTERN, "U") - ITEM("catchup", OP_CATCHUP, "y") - ITEM("uncatchup", OP_UNCATCHUP, "Y") -#endif ITEM("view-file", OP_BROWSER_VIEW_FILE, " ") ITEM("buffy-list", OP_BUFFY_LIST, ".") ITEM("create-mailbox", OP_CREATE_MAILBOX, "C") diff --git a/globals.h b/globals.h index 43c7d81..f8c7a2f 100644 --- a/globals.h +++ b/globals.h @@ -64,12 +64,6 @@ WHERE char *Tunnel INITVAL (NULL); WHERE short NetInc; WHERE char *Muttrc INITVAL (NULL); -#ifdef USE_NNTP -WHERE char *GroupFormat; -WHERE char *NewsServer; -WHERE char *NntpUser; -WHERE char *NntpPass; -#endif WHERE char *PagerFmt; WHERE char *PipeSep; @@ -113,11 +107,6 @@ WHERE unsigned char Options[(OPTMAX + 7) / 8]; /* bit vector for the yes/no/ask variable type */ WHERE unsigned char QuadOptions[(OPT_MAX * 2 + 7) / 8]; -#ifdef USE_NNTP -WHERE short NewsPollTimeout; -WHERE short NntpContext; -#endif - WHERE short ConnectTimeout; WHERE short HistSize; WHERE short MenuContext; diff --git a/headers.c b/headers.c index 1215985..b083ded 100644 --- a/headers.c +++ b/headers.c @@ -96,10 +96,7 @@ void mutt_edit_headers(const char *body, n = NULL; if (!msg->env->in_reply_to) -#ifdef USE_NNTP - if (!option (OPTNEWSSEND)) -#endif - string_list_wipe(&msg->env->references); + string_list_wipe(&msg->env->references); mutt_expand_aliases_env (msg->env); diff --git a/init.c b/init.c index 7106e97..beca05f 100644 --- a/init.c +++ b/init.c @@ -1655,27 +1655,6 @@ void mutt_init (int skip_sys_rc, string_list_t * commands) Realname = m_strdup(rnbuf); } -#ifdef USE_NNTP - { - FILE *f; - char *q; - - if ((f = safe_fopen (SYSCONFDIR "/nntpserver", "r"))) { - buffer[0] = '\0'; - fgets (buffer, sizeof(buffer), f); - p = vskipspaces(buffer); - q = (char*)p; - while (*q && !isspace(*q)) - q++; - *q = '\0'; - NewsServer = m_strdup(p); - m_fclose(&f); - } - } - if ((p = getenv ("NNTPSERVER"))) - NewsServer = m_strdup(p); -#endif - if ((p = getenv("MAIL") ?: getenv("MAILDIR"))) { Spoolfile = m_strdup(p); } else { diff --git a/init.h b/init.h index 2ccc464..9031847 100644 --- a/init.h +++ b/init.h @@ -364,11 +364,7 @@ struct option_t MuttVars[] = { ** Which empty header fields to show is controlled by the ** $$editor_headers option. */ -#ifdef USE_NNTP - {"editor_headers", DT_STR, UL &EditorHeaders, "From: To: Cc: Bcc: Subject: Reply-To: Newsgroups: Followup-To: X-Comment-To:" }, -#else {"editor_headers", DT_STR, UL &EditorHeaders, "From: To: Cc: Bcc: Subject: Reply-To:" }, -#endif /* ** .pp ** If $$edit_headers is \fIset\fP, this space-separated list specifies @@ -1943,175 +1939,6 @@ struct option_t MuttVars[] = { ** $$xterm_set_titles has been \fIset\fP. This string is identical in formatting ** to the one used by ``$$status_format''. */ -#ifdef USE_NNTP - {"nntp_post_moderated", DT_QUAD, OPT_TOMODERATED, "ask-yes" }, - /* - ** .pp - ** Availability: NNTP - ** - ** .pp - ** If set to \fIyes\fP, Madmutt will post articles to newsgroup that have - ** not permissions to post (e.g. moderated). - ** .pp - ** \fBNote:\fP if the newsserver - ** does not support posting to that newsgroup or a group is totally read-only, that - ** posting will not have any effect. - */ - {"nntp_host", DT_STR, UL &NewsServer, "" }, - /* - ** .pp - ** Availability: NNTP - ** - ** .pp - ** This variable specifies the name (or address) of the NNTP server to be used. - ** .pp - ** It - ** defaults to the value specified via the environment variable - ** \fT$$$NNTPSERVER\fP or contained in the file \fT/etc/nntpserver\fP. - ** .pp - ** You can also - ** specify a username and an alternative port for each newsserver, e.g. - ** .pp - ** \fT[nntp[s]://][username[:password]@]newsserver[:port]\fP - ** .pp - ** \fBNote:\fP Using a password as shown and stored in a configuration file - ** presents a security risk since the superuser of your machine may read it - ** regardless of the file's permissions. - */ - {"nntp_context", DT_NUM, UL &NntpContext, "1000" }, - /* - ** .pp - ** Availability: NNTP - ** - ** .pp - ** This variable controls how many news articles to cache per newsgroup - ** (if caching is enabled, see $$nntp_cache_dir) and how many news articles - ** to show in the ``index'' menu. - ** .pp - ** If there're more articles than defined with $$nntp_context, all older ones - ** will be removed/not shown in the index. - */ - {"nntp_load_description", DT_BOOL, OPTLOADDESC, "yes" }, - /* - ** .pp - ** Availability: NNTP - ** - ** .pp - ** This variable controls whether or not descriptions for newsgroups - ** are to be loaded when subscribing to a newsgroup. - */ - {"nntp_user", DT_STR, UL &NntpUser, ""}, - /* - ** .pp - ** Availability: NNTP - ** - ** .pp - ** Your login name on the NNTP server. If \fIunset\fP and the server requires - ** authentification, Madmutt will prompt you for your account name. - */ - {"nntp_pass", DT_STR, UL &NntpPass, ""}, - /* - ** .pp - ** Availability: NNTP - ** - ** .pp - ** Your password for NNTP account. - ** .pp - ** \fBNote:\fP Storing passwords in a configuration file - ** presents a security risk since the superuser of your machine may read it - ** regardless of the file's permissions. - */ - {"nntp_mail_check", DT_NUM, UL &NewsPollTimeout, "60" }, - /* - ** .pp - ** Availability: NNTP - ** - ** .pp - ** The time in seconds until any operations on a newsgroup except posting a new - ** article will cause a recheck for new news. If set to 0, Madmutt will - ** recheck on each operation in index (stepping, read article, etc.). - */ - {"nntp_reconnect", DT_QUAD, OPT_NNTPRECONNECT, "ask-yes" }, - /* - ** .pp - ** Availability: NNTP - ** - ** .pp - ** Controls whether or not Madmutt will try to reconnect to a newsserver when the - ** was connection lost. - */ - {"nntp_group_index_format", DT_STR, UL &GroupFormat, "%4C %M%N %5s %-45.45f %d"}, - /* - ** .pp - ** Availability: NNTP - ** - ** .pp - ** This variable allows you to customize the newsgroup browser display to - ** your personal taste. This string is similar to ``$index_format'', but - ** has its own set of \fTprintf(3)\fP-like sequences: - ** .pp - ** .ts - ** %C current newsgroup number - ** %d description of newsgroup (retrieved from server) - ** %f newsgroup name - ** %M ``-'' if newsgroup not allowed for direct post (moderated for example) - ** %N ``N'' if newsgroup is new, ``u'' if unsubscribed, blank otherwise - ** %n number of new articles in newsgroup - ** %s number of unread articles in newsgroup - ** %>X right justify the rest of the string and pad with character "X" - ** %|X pad to the end of the line with character "X" - ** .te - */ - {"nntp_followup_to_poster", DT_QUAD, OPT_FOLLOWUPTOPOSTER, "ask-yes" }, - /* - ** .pp - ** Availability: NNTP - ** - ** .pp - ** If this variable is \fIset\fP and the keyword "\fTposter\fP" is present in - ** the \fTFollowup-To:\fP header field, a follow-up to the newsgroup is not - ** permitted. The message will be mailed to the submitter of the - ** message via mail. - */ - {"nntp_catchup", DT_QUAD, OPT_CATCHUP, "ask-yes" }, - /* - ** .pp - ** Availability: NNTP - ** - ** .pp - ** If this variable is \fIset\fP, Madmutt will mark all articles in a newsgroup - ** as read when you leaving it. - */ - {"nntp_ask_followup_to", DT_BOOL, OPTASKFOLLOWUP, "no" }, - /* - ** .pp - ** Availability: NNTP - ** - ** .pp - ** If \fIset\fP, Madmutt will prompt you for the \fTFollowup-To:\fP header - ** field before editing the body of an outgoing news article. - */ - {"nntp_show_new_news", DT_BOOL, OPTSHOWNEWNEWS, "yes" }, - /* - ** .pp - ** Availability: NNTP - ** - ** .pp - ** If \fIset\fP, the newsserver will be asked for new newsgroups on entering - ** the browser. Otherwise, it will be done only once for a newsserver. - ** Also controls whether or not the number of new articles of subscribed - ** newsgroups will be checked. - */ - {"nntp_show_only_unread", DT_BOOL, OPTSHOWONLYUNREAD, "no" }, - /* - ** .pp - ** Availability: NNTP - ** - ** .pp - ** If \fIset\fP, only subscribed newsgroups that contain unread articles - ** will be displayed in the newsgroup browser. - */ -#endif /*--*/ { NULL, -1, -1, NULL } }; diff --git a/lib-lib/url.c b/lib-lib/url.c index a60f859..79bf79e 100644 --- a/lib-lib/url.c +++ b/lib-lib/url.c @@ -37,10 +37,6 @@ static struct mapping_t UrlMap[] = { {"imaps", U_IMAPS}, {"pop", U_POP}, {"pops", U_POPS}, - {"nntp", U_NNTP}, - {"news", U_NNTP}, - {"nntps", U_NNTPS}, - {"snews", U_NNTPS}, {"mailto", U_MAILTO}, {NULL, U_UNKNOWN} }; diff --git a/lib-lib/url.h b/lib-lib/url.h index 795c4d0..f4410dd 100644 --- a/lib-lib/url.h +++ b/lib-lib/url.h @@ -31,8 +31,6 @@ typedef enum url_scheme { U_POPS, U_IMAP, U_IMAPS, - U_NNTP, - U_NNTPS, U_MAILTO, U_UNKNOWN } url_scheme_t; diff --git a/lib-mime/mime-types.h b/lib-mime/mime-types.h index c57c90e..ac99d87 100644 --- a/lib-mime/mime-types.h +++ b/lib-mime/mime-types.h @@ -133,11 +133,6 @@ typedef struct envelope_t { char *date; char *x_label; char *organization; -#ifdef USE_NNTP - char *newsgroups; - char *xref; - char *followup_to; -#endif BUFFER *spam; string_list_t *references; /* message references (in reverse order) */ string_list_t *in_reply_to; /* in-reply-to header content */ @@ -322,9 +317,6 @@ see: crypt.h pgplib.h, smime.h */ ENVELOPE *env; /* envelope information */ BODY *content; /* list of MIME parts */ char *path; -#ifdef USE_NNTP - int article_num; -#endif char *tree; /* character string to print thread tree */ struct thread *thread; diff --git a/lib-mime/mime.cpkg b/lib-mime/mime.cpkg index de979ee..c128636 100644 --- a/lib-mime/mime.cpkg +++ b/lib-mime/mime.cpkg @@ -288,11 +288,6 @@ void envelope_wipe(ENVELOPE *p) p_delete(&p->date); p_delete(&p->x_label); p_delete(&p->organization); -#ifdef USE_NNTP - p_delete(&p->newsgroups); - p_delete(&p->xref); - p_delete(&p->followup_to); -#endif mutt_buffer_free (&p->spam); string_list_wipe(&p->references); diff --git a/lib-mime/rfc822parse.c b/lib-mime/rfc822parse.c index 3afeb7c..a1b4d54 100644 --- a/lib-mime/rfc822parse.c +++ b/lib-mime/rfc822parse.c @@ -670,15 +670,6 @@ string_list_t **mutt_parse_rfc822_line(ENVELOPE *e, HEADER *hdr, char *line, cha hdr->expired = 1; break; -#ifdef USE_NNTP - case MIME_FOLLOWUP_TO: - if (!e->followup_to) { - m_strrtrim(p); - e->followup_to = m_strdup(skipspaces(p)); - } - break; -#endif - case MIME_FROM: e->from = rfc822_parse_adrlist(e->from, p); /* don't leave from info NULL if there's an invalid address (or @@ -750,14 +741,6 @@ string_list_t **mutt_parse_rfc822_line(ENVELOPE *e, HEADER *hdr, char *line, cha hdr->mime = 1; break; -#ifdef USE_NNTP - case MIME_NEWSGROUPS: - p_delete(&e->newsgroups); - m_strrtrim(p); - e->newsgroups = m_strdup(skipspaces(p)); - break; -#endif - case MIME_ORGANIZATION: if (!e->organization && mime_which_token(p, -1) == MIME_UNKNOWN) e->organization = m_strdup(p); @@ -826,13 +809,6 @@ string_list_t **mutt_parse_rfc822_line(ENVELOPE *e, HEADER *hdr, char *line, cha e->x_label = m_strdup(p); break; -#ifdef USE_NNTP - case MIME_XREF: - if (!e->xref) - e->xref = m_strdup(p); - break; -#endif - case MIME_X_STATUS: if (hdr) { while (*p) { diff --git a/lib-mx/hcache.c b/lib-mx/hcache.c index 1b781d2..bb38c81 100644 --- a/lib-mx/hcache.c +++ b/lib-mx/hcache.c @@ -60,9 +60,6 @@ static int generate_crc32(void) #endif crc = crc32(crc, "USE_POP", m_strlen("USE_POP")); crc = crc32(crc, "USE_IMAP", m_strlen("USE_IMAP")); -#ifdef USE_NNTP - crc = crc32(crc, "USE_NNTP", m_strlen("USE_NNTP")); -#endif return crc; } @@ -276,12 +273,6 @@ static void dump_envelope(buffer_t *buf, ENVELOPE * e) dump_cstr(buf, e->x_label); dump_cstr(buf, e->list_post); -#ifdef USE_NNTP - dump_cstr(buf, e->newsgroups); - dump_cstr(buf, e->xref); - dump_cstr(buf, e->followup_to); -#endif - dump_list(buf, e->references); dump_list(buf, e->in_reply_to); dump_list(buf, e->userhdrs); @@ -313,16 +304,9 @@ static const void *restore_envelope(const char *d, ENVELOPE *e) d = restore_cstr(d, &e->x_label); d = restore_cstr(d, &e->list_post); -#ifdef USE_NNTP - d = restore_cstr(d, &e->newsgroups); - d = restore_cstr(d, &e->xref); - d = restore_cstr(d, &e->followup_to); -#endif - d = restore_list(d, &e->references); d = restore_list(d, &e->in_reply_to); d = restore_list(d, &e->userhdrs); - return d; } diff --git a/lib-mx/mx.c b/lib-mx/mx.c index bebaa34..6693d27 100644 --- a/lib-mx/mx.c +++ b/lib-mx/mx.c @@ -32,9 +32,6 @@ #include #include "pop.h" -#ifdef USE_NNTP -#include "nntp.h" -#endif static mx_t const *mxfmts[] = { &mbox_mx, @@ -42,9 +39,6 @@ static mx_t const *mxfmts[] = { &maildir_mx, &imap_mx, &pop_mx, -#ifdef USE_NNTP - &nntp_mx, -#endif &compress_mx, }; @@ -582,15 +576,6 @@ static int _mx_close_mailbox (CONTEXT * ctx, int *index_hint) ctx->closing = 1; -#ifdef USE_NNTP - if (ctx->magic == M_NNTP) { - int ret; - - ret = nntp_close_mailbox (ctx); - mx_fastclose_mailbox (ctx); - return ret; - } -#endif if (ctx->readonly || ctx->dontwrite) { /* mailbox is readonly or we don't want to write */ mx_fastclose_mailbox (ctx); @@ -1064,15 +1049,6 @@ MESSAGE *mx_open_message (CONTEXT * ctx, int msgno) break; } -#ifdef USE_NNTP - case M_NNTP: - { - if (nntp_fetch_message (msg, ctx, msgno) != 0) - p_delete(&msg); - break; - } -#endif /* USE_NNTP */ - default: p_delete(&msg); break; @@ -1097,12 +1073,8 @@ int mx_close_message (MESSAGE ** msg) int r = 0; if ((*msg)->magic == M_MH || (*msg)->magic == M_MAILDIR - || (*msg)->magic == M_IMAP - || (*msg)->magic == M_POP -#ifdef USE_NNTP - || (*msg)->magic == M_NNTP -#endif - ) { + || (*msg)->magic == M_IMAP || (*msg)->magic == M_POP) + { r = m_fclose(&(*msg)->fp); } else diff --git a/lib-mx/mx.h b/lib-mx/mx.h index a017576..64068f7 100644 --- a/lib-mx/mx.h +++ b/lib-mx/mx.h @@ -28,9 +28,6 @@ enum { M_MAILDIR, M_IMAP, M_POP, -#ifdef USE_NNTP - M_NNTP, -#endif M_COMPRESSED }; diff --git a/lib-ui/complete.c b/lib-ui/complete.c index 426da78..aa51e5b 100644 --- a/lib-ui/complete.c +++ b/lib-ui/complete.c @@ -12,9 +12,6 @@ #include "mutt.h" #include -#ifdef USE_NNTP -#include "nntp.h" -#endif /* given a partial pathname, this routine fills in as much of the rest of the * path as is unique. @@ -33,50 +30,6 @@ int mutt_complete (char *s, ssize_t slen) char imap_path[LONG_STRING]; -#ifdef USE_NNTP - if (option (OPTNEWS)) { - nntp_data_t *l = CurrentNewsSrv->list; - - m_strcpy(filepart, sizeof(filepart), s); - - /* - * special case to handle when there is no filepart yet. - * find the first subscribed newsgroup - */ - if ((len = m_strlen(filepart)) == 0) { - for (; l; l = l->next) { - if (l->subscribed) { - m_strcpy(filepart, sizeof(filepart), l->group); - init++; - l = l->next; - break; - } - } - } - - for (; l; l = l->next) { - if (l->subscribed && m_strncmp(l->group, filepart, len) == 0) { - if (init) { - for (i = 0; filepart[i] && l->group[i]; i++) { - if (filepart[i] != l->group[i]) { - filepart[i] = 0; - break; - } - } - filepart[i] = 0; - } else { - m_strcpy(filepart, sizeof(filepart), l->group); - init = 1; - } - } - } - - m_strcpy(s, slen, filepart); - - return (init ? 0 : -1); - } -#endif - /* we can use '/' as a delimiter, imap_complete rewrites it */ if (*s == '=' || *s == '+' || *s == '!') { const char *q = NONULL(*s == '!' ? Spoolfile : Maildir); diff --git a/lib-ui/curs_main.c b/lib-ui/curs_main.c index 2103d25..6fdbc16 100644 --- a/lib-ui/curs_main.c +++ b/lib-ui/curs_main.c @@ -30,10 +30,6 @@ #include -#ifdef USE_NNTP -#include "nntp.h" -#endif - static const char *No_mailbox_is_open = N_("No mailbox is open."); static const char *There_are_no_messages = N_("There are no messages."); static const char *Mailbox_is_read_only = N_("Mailbox is read-only."); @@ -600,8 +596,7 @@ int mutt_index_menu (void) } mutt_clear_error (); - } - else { + } else { if (menu->current < menu->max) menu->oldcurrent = menu->current; else @@ -610,10 +605,6 @@ int mutt_index_menu (void) mutt_curs_set (1); /* fallback from the pager */ } -#ifdef USE_NNTP - unset_option (OPTNEWS); /* for any case */ -#endif - switch (op) { /* ---------------------------------------------------------------------- @@ -663,110 +654,6 @@ int mutt_index_menu (void) menu_current_bottom (menu); break; -#ifdef USE_NNTP - case OP_GET_MESSAGE: - case OP_GET_PARENT: - CHECK_MSGCOUNT; - if (Context->magic == M_NNTP) { - HEADER *h; - - if (op == OP_GET_MESSAGE) { - buf[0] = 0; - if (mutt_get_field (_("Enter Message-ID: "), buf, sizeof (buf), 0) - != 0 || !buf[0]) - break; - } - else { - string_list_t *ref = CURHDR->env->references; - - if (!ref) { - mutt_error (_("Article has no parent reference!")); - - break; - } - m_strcpy(buf, sizeof(buf), ref->data); - } - if (!Context->id_hash) - Context->id_hash = mutt_make_id_hash (Context); - if ((h = hash_find (Context->id_hash, buf))) { - if (h->virtual != -1) { - menu->current = h->virtual; - menu->redraw = REDRAW_MOTION_RESYNCH; - } - else if (h->collapsed) { - mutt_uncollapse_thread (Context, h); - mutt_set_virtual (Context); - menu->current = h->virtual; - menu->redraw = REDRAW_MOTION_RESYNCH; - } - else - mutt_error (_("Message not visible in limited view.")); - } - else { - if (nntp_check_msgid (Context, buf) == 0) { - h = Context->hdrs[Context->msgcount - 1]; - mutt_sort_headers (Context, 0); - menu->current = h->virtual; - menu->redraw = REDRAW_FULL; - } - else - mutt_error (_("Article %s not found on server"), buf); - } - } - break; - - case OP_GET_CHILDREN: - case OP_RECONSTRUCT_THREAD: - CHECK_MSGCOUNT; - if (Context->magic == M_NNTP) { - HEADER *h; - int old = CURHDR->index; - - if (!CURHDR->env->message_id) { - mutt_error (_("No Message-ID. Unable to perform operation")); - - break; - } - - if (!Context->id_hash) - Context->id_hash = mutt_make_id_hash (Context); - m_strcpy(buf, sizeof(buf), CURHDR->env->message_id); - - if (op == OP_RECONSTRUCT_THREAD) { - string_list_t *ref = CURHDR->env->references; - - while (ref) { - nntp_check_msgid (Context, ref->data); - /* the last msgid in References is the root message */ - if (!ref->next) - m_strcpy(buf, sizeof(buf), ref->data); - ref = ref->next; - } - } - mutt_message (_("Check for children of message...")); - - if (nntp_check_children (Context, buf) == 0) { - mutt_sort_headers (Context, (op == OP_RECONSTRUCT_THREAD)); - h = hash_find (Context->id_hash, buf); - /* if the root message was retrieved, move to it */ - if (h) - menu->current = h->virtual; - else /* try to restore old position */ - for (i = 0; i < Context->msgcount; i++) - if (Context->hdrs[i]->index == old) { - menu->current = Context->hdrs[i]->virtual; - /* As an added courtesy, recenter the menu - * with the current entry at the middle of the screen */ - menu_check_recenter (menu); - menu_current_middle (menu); - } - } - menu->redraw = REDRAW_FULL; - mutt_clear_error (); - } - break; -#endif - case OP_JUMP: CHECK_MSGCOUNT; CHECK_VISIBLE; @@ -1065,15 +952,7 @@ int mutt_index_menu (void) case OP_SIDEBAR_OPEN: case OP_MAIN_CHANGE_FOLDER: case OP_MAIN_CHANGE_FOLDER_READONLY: -#ifdef USE_NNTP - case OP_MAIN_CHANGE_GROUP: - case OP_MAIN_CHANGE_GROUP_READONLY: -#endif - if (attach_msg || -#ifdef USE_NNTP - op == OP_MAIN_CHANGE_GROUP_READONLY || -#endif - op == OP_MAIN_CHANGE_FOLDER_READONLY) + if (attach_msg || op == OP_MAIN_CHANGE_FOLDER_READONLY) flags = M_READONLY; else flags = 0; @@ -1084,26 +963,10 @@ int mutt_index_menu (void) cp = _("Open mailbox"); buf[0] = '\0'; -#ifdef USE_NNTP - unset_option (OPTNEWS); - if (op == OP_MAIN_CHANGE_GROUP || op == OP_MAIN_CHANGE_GROUP_READONLY) { - set_option (OPTNEWS); - if (!(CurrentNewsSrv = mutt_select_newsserver (NewsServer))) - break; - if (flags) - cp = _("Open newsgroup in read-only mode"); - else - cp = _("Open newsgroup"); - nntp_buffy (buf, sizeof (buf)); - } - else -#endif - { - if (Context && Context->path) - m_strcpy(buf, sizeof(buf), Context->path); - if (op != OP_SIDEBAR_OPEN) - buffy_next (buf, sizeof (buf)); - } + if (Context && Context->path) + m_strcpy(buf, sizeof(buf), Context->path); + if (op != OP_SIDEBAR_OPEN) + buffy_next (buf, sizeof (buf)); if (op == OP_SIDEBAR_OPEN) { m_strcpy(buf, sizeof(buf), sidebar_get_current()); @@ -1120,14 +983,7 @@ int mutt_index_menu (void) break; } -#ifdef USE_NNTP - if (option (OPTNEWS)) { - unset_option (OPTNEWS); - nntp_expand_path (buf, sizeof (buf), &CurrentNewsSrv->conn->account); - } - else -#endif - mutt_expand_path (buf, sizeof (buf)); + mutt_expand_path (buf, sizeof (buf)); if (mx_get_magic (buf) <= 0) { mutt_error (_("%s is not a mailbox."), buf); break; @@ -1834,16 +1690,6 @@ int mutt_index_menu (void) } break; -#ifdef USE_NNTP - case OP_CATCHUP: - if (Context && Context->magic == M_NNTP) { - if (mutt_newsgroup_catchup (CurrentNewsSrv, - ((nntp_data_t *) Context->data)->group)) - menu->redraw = REDRAW_INDEX | REDRAW_STATUS; - } - break; -#endif - case OP_DISPLAY_ADDRESS: CHECK_MSGCOUNT; CHECK_VISIBLE; @@ -1997,44 +1843,6 @@ int mutt_index_menu (void) menu->redraw = REDRAW_FULL; break; -#ifdef USE_NNTP - case OP_POST: - case OP_FOLLOWUP: - case OP_FORWARD_TO_GROUP: - CHECK_ATTACH; - if ((op == OP_FOLLOWUP || op == OP_FORWARD_TO_GROUP) && - Context && Context->msgcount == 0) { - mutt_error (_("There are no messages.")); - sleep (2); - } - else if (op != OP_FOLLOWUP || !CURHDR->env->followup_to || - m_strcasecmp(CURHDR->env->followup_to, "poster") || - query_quadoption (OPT_FOLLOWUPTOPOSTER, - _("Reply by mail as poster prefers?")) != - M_YES) { - if (Context && Context->magic == M_NNTP - && !((nntp_data_t *) Context->data)->allowed - && query_quadoption (OPT_TOMODERATED, - _ - ("Posting to this group not allowed, may be moderated. Continue?")) - != M_YES) - break; - if (op == OP_POST) - ci_send_message (SENDNEWS, NULL, NULL, Context, NULL); - else { - CHECK_MSGCOUNT; - if (op == OP_FOLLOWUP) - ci_send_message (SENDNEWS | SENDREPLY, NULL, NULL, Context, - tag ? NULL : CURHDR); - else - ci_send_message (SENDNEWS | SENDFORWARD, NULL, NULL, Context, - tag ? NULL : CURHDR); - } - menu->redraw = REDRAW_FULL; - break; - } -#endif - case OP_REPLY: CHECK_ATTACH; CHECK_MSGCOUNT; @@ -2175,10 +1983,6 @@ int mutt_index_menu (void) if (!attach_msg) { /* Close all open IMAP connections */ imap_logout_all (); -#ifdef USE_NNTP - /* Close all open NNTP connections */ - nntp_logout_all (); -#endif } mutt_menuDestroy (&menu); diff --git a/lib-ui/hdrline.c b/lib-ui/hdrline.c index c0cef6d..5bbff4a 100644 --- a/lib-ui/hdrline.c +++ b/lib-ui/hdrline.c @@ -404,13 +404,6 @@ hdr_format_str(char *dest, ssize_t destlen, optional = 0; break; -#ifdef USE_NNTP - case 'g': - mutt_format_s (dest, destlen, prefix, - hdr->env->newsgroups ? hdr->env->newsgroups : ""); - break; -#endif - case 'H': /* (Hormel) spam score */ if (optional) diff --git a/main.c b/main.c index f53dc03..6247429 100644 --- a/main.c +++ b/main.c @@ -45,10 +45,6 @@ extern int optind; #include #endif -#ifdef USE_NNTP -#include "nntp.h" -#endif - #ifdef USE_HCACHE #if defined(HAVE_QDBM) #include @@ -83,10 +79,6 @@ usage: madmutt [ -nRyzZ ] [ -e ] [ -F ] [ -f ]\n\ puts(_(" -e specify a command to be executed after initialization")); puts(_(" -f specify which mailbox to read")); puts(_(" -F specify an alternate Madmuttrc file")); -#ifdef USE_NNTP - puts(_(" -g specify a newsserver")); - puts(_(" -G select a newsgroup")); -#endif puts(_(" -H specify a draft file to read header and body from")); puts(_(" -i specify a file which Madmutt should include in the body")); puts(_(" -n causes Madmutt not to read the system Madmuttrc")); @@ -153,11 +145,6 @@ static void show_version (void) #else " -USE_HCACHE" #endif -#ifdef USE_NNTP - " +USE_NNTP" -#else - " -USE_NNTP" -#endif #ifdef HAVE_LIBIDN " +HAVE_LIBIDN" #else @@ -232,11 +219,7 @@ int main (int argc, char **argv) srand48 (time (NULL)); umask (077); - while ((i = getopt(argc, argv, "a:b:F:f:c:e:H:s:i:hnpRTtvyzZ" -#ifdef USE_NNTP - "g:G" -#endif - )) >= 0) + while ((i = getopt(argc, argv, "a:b:F:f:c:e:H:s:i:hnpRTtvyzZ")) >= 0) switch (i) { case 'a': if (strlen(optarg)<=512) @@ -304,20 +287,6 @@ int main (int argc, char **argv) flags |= M_SELECT; break; -#ifdef USE_NNTP - case 'g': /* Specify a newsserver */ - { - char buf[LONG_STRING]; - - snprintf (buf, sizeof (buf), "set nntp_host=%s", optarg); - commands = mutt_add_list (commands, buf); - } - - case 'G': /* List of newsgroups */ - flags |= M_SELECT | M_NEWS; - break; -#endif - case 'z': flags |= M_IGNORE; break; @@ -511,15 +480,6 @@ int main (int argc, char **argv) buffy_next (folder, sizeof (folder)); } else if (flags & M_SELECT) { -#ifdef USE_NNTP - if (flags & M_NEWS) { - set_option (OPTNEWS); - if (!(CurrentNewsSrv = mutt_select_newsserver (NewsServer))) { - mutt_endwin (Errorbuf); - exit (1); - } - } else -#endif if (!Incoming.len) { mutt_endwin _("No incoming mailboxes defined."); @@ -537,15 +497,7 @@ int main (int argc, char **argv) if (!folder[0]) m_strcpy(folder, sizeof(folder), NONULL(Spoolfile)); -#ifdef USE_NNTP - if (option (OPTNEWS)) { - unset_option (OPTNEWS); - nntp_expand_path (folder, sizeof (folder), - &CurrentNewsSrv->conn->account); - } else -#endif - mutt_expand_path (folder, sizeof (folder)); - + mutt_expand_path (folder, sizeof (folder)); m_strreplace(&CurrentFolder, folder); m_strreplace(&LastFolder, folder); diff --git a/mutt.h b/mutt.h index 5830c09..b1c5995 100644 --- a/mutt.h +++ b/mutt.h @@ -128,9 +128,6 @@ enum { M_PGP_KEY, M_XLABEL, M_MIMEATTACH, -#ifdef USE_NNTP - M_NEWSGROUPS, -#endif M_REALNAME, M_MULTIPART, @@ -170,12 +167,6 @@ enum { OPT_RECALL, OPT_SUBJECT, OPT_LISTREPLY, -#ifdef USE_NNTP - OPT_TOMODERATED, - OPT_NNTPRECONNECT, - OPT_CATCHUP, - OPT_FOLLOWUPTOPOSTER, -#endif /* USE_NNTP */ /* THIS MUST BE THE LAST VALUE. */ OPT_MAX diff --git a/muttlib.c b/muttlib.c index b34cede..338cb01 100644 --- a/muttlib.c +++ b/muttlib.c @@ -312,14 +312,6 @@ int mutt_save_confirm (const char *s, struct stat *st) return 1; } -#ifdef USE_NNTP - if (magic == M_NNTP) { - mutt_error _("Can't save message to newsserver."); - - return 0; - } -#endif - if (magic > 0 && !mx_access (s, W_OK)) { if (option (OPTCONFIRMAPPEND) && (!TrashPath || (m_strcmp(s, TrashPath) != 0))) { diff --git a/nntp.c b/nntp.c deleted file mode 100644 index 92e0bae..0000000 --- a/nntp.c +++ /dev/null @@ -1,2385 +0,0 @@ -/* - * Copyright notice from original mutt: - * Copyright (C) 1998 Brandon Long - * Copyright (C) 1999 Andrej Gritsenko - * Copyright (C) 2000-2002 Vsevolod Volkov - * - * This file is part of mutt-ng, see http://www.muttng.org/. - * It's licensed under the GNU General Public License, - * please see the file GPL in the top level source directory. - */ - -#include - -#include - -#include -#include -#include -#include - -#include "mutt.h" -#include "sort.h" -#include "nntp.h" -#include "buffy.h" -#include "crypt.h" - -#define NNTP_PORT 119 -#define NNTP_SSL_PORT 563 - -static struct { - unsigned use_cache : 1; - - int checked; -} nntp = { true, 0 }; - -static int nntp_check_newgroups (nntp_server_t *, int); - -static void nntp_free_acache(nntp_data_t * data) -{ - for (int i = 0; i < countof(data->acache); i++) { - if (data->acache[i].path) { - unlink(data->acache[i].path); - p_delete(&data->acache[i].path); - } - } -} - -void nntp_data_wipe(nntp_data_t *data) -{ - p_delete(&data->entries); - p_delete(&data->desc); - p_delete(&data->cache); - p_delete(&data->group); - nntp_free_acache(data); -} - -/* newsrc {{{ */ - -static void mutt_newsgroup_stat(nntp_data_t *data) -{ - data->unread = 0; - if (data->last == 0 || data->first > data->last) - return; - - data->unread = data->last - data->first + 1; - for (int i = 0; i < data->num; i++) { - int first = MAX(data->entries[i].first, data->first); - int last = MIN(data->entries[i].last, data->last); - data->unread -= MAX(0, last - first + 1); - } -} - -static int nntp_parse_newsrc_line(nntp_server_t *news, const char *line) -{ - nntp_data_t *data; - char group[LONG_STRING]; - const char *p; - int x = 1; - - for (p = line; *p; p++) { - x += *p == ','; - } - - p = strpbrk(line, ":!"); - if (!p) - return -1; - - m_strncpy(group, ssizeof(group), line, p - line); - data = hash_find(news->newsgroups, group); - if (!data) { - data = nntp_data_new(); - data->group = p_dupstr(line, p - line); - data->nserv = news; - data->deleted = 1; - hash_insert(news->newsgroups, data->group, data); - news->tail = nntp_data_list_append(news->tail, data); - } else { - p_delete(&data->entries); - } - - data->rc = 1; - data->entries = p_new(NEWSRC_ENTRY, x * 2); - data->max = x * 2; - data->subscribed = (*p++ == ':'); - p = skipspaces(p); - - for (x = 0; *p; p++) { - data->entries[x].first = strtol(p, (char **)&p, 10); - p += strcspn(p, "-,"); - if (*p == '-') { - if (!*p) - break; - data->entries[x].last = strtol(p + 1, (char **)&p, 10); - } else { - data->entries[x].last = data->entries[x].first; - p = strchrnul(p, ','); - } - x += data->entries[x].last != 0; - } - - if (x && !data->last) - data->last = data->entries[x - 1].last; - data->num = x; - mutt_newsgroup_stat(data); - return 0; -} - -static int slurp_newsrc (nntp_server_t * news) -{ - FILE *fp; - char *buf = NULL; - size_t n = 0; - struct stat sb; - - news->stat = stat(news->newsrc, &sb); - news->size = sb.st_size; - news->mtime = sb.st_mtime; - - if ((fp = safe_fopen(news->newsrc, "r")) == NULL) - return -1; - - /* hmm, should we use dotlock? */ - if (mx_lock_file(news->newsrc, fileno (fp), 0, 0, 1)) { - m_fclose(&fp); - return -1; - } - - while (getline(&buf, &n, fp) >= 0) { - nntp_parse_newsrc_line(news, buf); - } - p_delete(&buf); - - mx_unlock_file (news->newsrc, fileno (fp), 0); - m_fclose(&fp); - return 0; -} - -#define nntp_cache_expand(dst, dlen, fmt, ...) \ - do { \ - snprintf((dst), (dlen), "%s/" fmt, mod_core.cachedir, ##__VA_ARGS__);\ - mutt_expand_path((dst), (dlen)); \ - } while (0) - -/* Loads $news_cache_dir/.index into memory, loads newsserver data - * and newsgroup cache names */ -static int nntp_parse_cacheindex(nntp_server_t *news) -{ - char buf[HUGE_STRING]; - FILE *idx; - - p_delete(&news->cache); - if (m_strisempty(mod_core.cachedir)) - return 0; - - nntp_cache_expand(buf, sizeof(buf), "%s.index", news->conn->account.host); - if (!(idx = safe_fopen(buf, "a+"))) - return 0; - rewind(idx); - - while (fgets(buf, sizeof(buf), idx)) { - buf[m_strlen(buf) - 1] = 0; /* strip ending '\n' */ - if (!m_strncmp(buf, "#: ", 3) - && !m_strcasecmp(buf + 3, news->conn->account.host)) { - break; - } - } - - while (fgets(buf, sizeof(buf), idx)) { - char *p, *q; - int l, m, t; - - if (m_strstart(buf, "#:", NULL)) - break; - - p = strchrnul(buf, ' '); - if (!*p) - continue; - *p++ = '\0'; - p = vskipspaces(p); - q = strchrnul(p, ' '); - if (!*q) - continue; - *q++ = '\0'; - l = strtol(q, &q, 10); - m = strtol(q, &q, 10); - - if (!m_strcmp(buf, "ALL")) { - m_strreplace(&news->cache, m_strdup(p)); - news->newgroups_time = m; - continue; - } - - if (news->newsgroups) { - nntp_data_t *data = hash_find(news->newsgroups, buf); - - if (!data) { - data = nntp_data_new(); - data->group = m_strdup(buf); - data->nserv = news; - data->deleted = 1; - hash_insert (news->newsgroups, data->group, data); - news->tail = nntp_data_list_append(news->tail, data); - } - m_strreplace(&data->cache, p); - - t = !data->first || data->last < m; - if (!data->first) - data->first = l; - if (data->last < m) - data->last = m; - data->lastCached = m; - if (t || !data->unread) - mutt_newsgroup_stat(data); - } - } - - m_fclose(&idx); - return 0; -} - -/* nntp_parse_url: given an NNPT URL, return host, port, - * username, password and newsgroup will recognise. */ -static int nntp_parse_url(const char *server, ACCOUNT *act, char *group, - ssize_t group_len) -{ - ciss_url_t url; - char s[STRING]; - - act->flags = 0; - act->port = 0; - act->type = M_ACCT_TYPE_NNTP; - - m_strcpy(s, sizeof(s), server); - url_parse_ciss(&url, s); - - if (url.scheme != U_NNTP && url.scheme != U_NNTPS) - return -1; - - act->has_ssl = (url.scheme == U_NNTPS); - if (!act->port) { - act->port = act->has_ssl ? NNTP_SSL_PORT : NNTP_PORT; - } - m_strcpy(group, group_len, url.path); - - return mutt_account_fromurl(act, &url); -} - -void nntp_expand_path(char *line, ssize_t len, ACCOUNT *act) -{ - ciss_url_t url = { .path = alloca(len) }; - - m_strcpy(url.path, len, line); - mutt_account_tourl (act, &url); - url_ciss_tostring(&url, line, len, 0); -} - -static int add_group(char *buf, void *serv) -{ - char mod, group[HUGE_STRING], desc[HUGE_STRING]; - nntp_server_t *srv = serv; - nntp_data_t *data; - static int n = 0; - int first, last; - - nntp.checked = n; /* nntp.checked have N, where N = number of groups */ - if (!buf) /* at EOF must be zerouth */ - n = 0; - - if (!srv || !buf) - return 0; - - *desc = '\0'; - sscanf(buf, "%s %d %d %c %[^\n]", group, &last, &first, &mod, desc); - - if (!(data = hash_find(srv->newsgroups, group))) { - n++; - data = nntp_data_new(); - data->group = m_strdup(group); - data->nserv = srv; - hash_insert(srv->newsgroups, data->group, data); - srv->tail = nntp_data_list_append(srv->tail, data); - } - - data->deleted = 0; - data->first = first; - data->last = last; - data->allowed = mod == 'y'; - m_strreplace(&data->desc, desc); - mutt_newsgroup_stat(data); - return 0; -} - -static int nntp_get_cache_all(nntp_server_t * serv) -{ - char buf[HUGE_STRING]; - FILE *f; - - nntp_cache_expand(buf, ssizeof(buf), "%s", serv->cache); - if ((f = fopen(buf, "r"))) { - int i = 0; - - while (fgets(buf, sizeof(buf), f)) { - if (ReadInc && (i % ReadInc == 0)) - mutt_message (_("Loading list from cache... %d"), i); - add_group(buf, serv); - i++; - } - add_group (NULL, NULL); - m_fclose(&f); - mutt_clear_error(); - return 0; - } - - p_delete(&serv->cache); - return -1; -} - -/* - * Automatically loads a newsrc into memory, if necessary. - * Checks the size/mtime of a newsrc file, if it doesn't match, load - * again. Hmm, if a system has broken mtimes, this might mean the file - * is reloaded every time, which we'd have to fix. - * - * a newsrc file is a line per newsgroup, with the newsgroup, then a - * ':' denoting subscribed or '!' denoting unsubscribed, then a - * comma separated list of article numbers and ranges. - */ -nntp_server_t *mutt_select_newsserver (char *server) -{ - char file[_POSIX_PATH_MAX]; - char *buf, *p; - nntp_data_t *list; - ACCOUNT act; - nntp_server_t *serv; - CONNECTION *conn; - - p_clear(&act, 1); - - if (m_strisempty(server)) { - mutt_error _("No newsserver defined!"); - return NULL; - } - - buf = p = p_new(char, m_strlen(server) + 10); - if (url_check_scheme (server) == U_UNKNOWN) { - strcpy (buf, "nntp://"); - p = strchr (buf, '\0'); - } - strcpy (p, server); - - if ((nntp_parse_url(buf, &act, file, sizeof(file))) < 0 || *file) { - p_delete(&buf); - mutt_error (_("%s is an invalid newsserver specification!"), server); - return NULL; - } - p_delete(&buf); - - conn = mutt_conn_find (NULL, &act); - if (!conn) - return NULL; - - nntp_cache_expand(file, sizeof(file), "%s.newsrc", conn->account.host); - serv = (nntp_server_t *) conn->data; - if (serv) { - struct stat sb; - - /* externally modified? */ - if (serv->stat != stat(file, &sb) - || (!serv->stat && (serv->size != sb.st_size - || serv->mtime != sb.st_mtime))) - { - for (list = serv->list; list; list = list->next) { - list->subscribed = list->rc = list->num = 0; - } - slurp_newsrc(serv); - } - - if (serv->status == NNTP_BYE) - serv->status = NNTP_NONE; - nntp_check_newgroups(serv, 0); - return serv; - } - - /* New newsserver */ - serv = p_new(nntp_server_t, 1); - serv->tail = &serv->list; - serv->conn = conn; - serv->newsrc = m_strdup(file); - serv->newsgroups = hash_new(SHRT_MAX, false); - slurp_newsrc(serv); /* load .newsrc */ - nntp_parse_cacheindex(serv); /* load .index */ - if (nntp.use_cache && serv->cache && nntp_get_cache_all(serv) >= 0) { - nntp_check_newgroups (serv, 1); - } else if (nntp_get_active(serv) < 0) { - hash_delete(&serv->newsgroups, NULL); - nntp_data_list_wipe(&serv->list); - p_delete(&serv->newsrc); - p_delete(&serv->cache); - p_delete(&serv); - return NULL; - } - - conn->data = serv; - return serv; -} - -/* - * full status flags are not supported by nntp, but we can fake some - * of them. This is how: - * Read = a read message number is in the .newsrc - * New = a message is new since we last read this newsgroup - * Old = anything else - * So, Read is marked as such in the newsrc, old is anything that is - * "skipped" in the newsrc, and new is anything not in the newsrc nor - * in the cache. By skipped, I mean before the last unread message - */ -static void -nntp_get_status(CONTEXT *ctx, HEADER *h, const char *group, int article) -{ - nntp_data_t *data = ctx->data; - - if (group) - data = hash_find(data->nserv->newsgroups, group); - if (!data) - return; - - for (int i = 0; i < data->num; i++) { - if ((article >= data->entries[i].first) && - (article <= data->entries[i].last)) - { - /* we cannot use mutt_set_flag() because mx_update_context() - didn't called yet */ - h->read = 1; - return; - } - } - - /* If article was not cached yet, it is new! :) */ - if (!data->cache || article > data->lastCached) - return; - - /* Old articles are articles which aren't read but an article after them - * has been cached */ - if (option(OPTMARKOLD)) - h->old = 1; -} - -static void newsrc_gen_entries (CONTEXT * ctx) -{ - nntp_data_t *data = (nntp_data_t *) ctx->data; - int series, x; - int last = 0, first = 1; - int save_sort = SORT_ORDER; - - if (Sort != SORT_ORDER) { - save_sort = Sort; - Sort = SORT_ORDER; - mutt_sort_headers (ctx, 0); - } - - if (!data->max) { - data->entries = p_new(NEWSRC_ENTRY, 5); - data->max = 5; - } - - /* - * Set up to fake initial sequence from 1 to the article before the - * first article in our list - */ - data->num = 0; - series = 1; - - for (x = 0; x < ctx->msgcount; x++) { - if (series) { /* search for first unread */ - /* - * We don't actually check sequential order, since we mark - * "missing" entries as read/deleted - */ - last = ctx->hdrs[x]->article_num; - if (last >= data->first && !ctx->hdrs[x]->deleted && - !ctx->hdrs[x]->read) { - if (data->num >= data->max) { - data->max = data->max * 2; - p_realloc(&data->entries, data->max); - } - data->entries[data->num].first = first; - data->entries[data->num].last = last - 1; - data->num++; - series = 0; - } - } - else { /* search for first read */ - - if (ctx->hdrs[x]->deleted || ctx->hdrs[x]->read) { - first = last + 1; - series = 1; - } - last = ctx->hdrs[x]->article_num; - } - } - if (series && first <= data->lastLoaded) { - if (data->num >= data->max) { - data->max = data->max * 2; - p_realloc(&data->entries, data->max); - } - data->entries[data->num].first = first; - data->entries[data->num].last = data->lastLoaded; - data->num++; - } - - if (save_sort != Sort) { - Sort = save_sort; - mutt_sort_headers (ctx, 0); - } -} - -static int mutt_update_list_file (char *filename, char *section, - const char *key, const char *line) -{ - FILE *ifp; - FILE *ofp; - char buf[HUGE_STRING]; - char tmpf[_POSIX_PATH_MAX], lnk[_POSIX_PATH_MAX]; - char *c; - int ext = 0, done = 0, r = 0, l = 0; - - /* if file not exist, create it */ - if ((ifp = safe_fopen (filename, "a"))) - m_fclose(&ifp); - if (!(ifp = safe_fopen (filename, "r"))) { - mutt_error (_("Unable to open %s for reading"), filename); - return -1; - } - if (mx_lock_file (filename, fileno (ifp), 0, 0, 1)) { - m_fclose(&ifp); - mutt_error (_("Unable to lock %s"), filename); - return -1; - } - - /* use m_tempfile() to get a tempfile in the same - * directory as filename is so that we can follow symlinks - * via rename(2); as dirname(2) may modify its argument, - * temporarily use buf as copy of it - */ - m_strcpy(buf, sizeof(buf), filename); - ofp = m_tempfile(tmpf, sizeof(tmpf), dirname(buf), filename); - if (!ofp) { - m_fclose(&ifp); - mutt_error (_("Unable to open %s for writing"), tmpf); - return -1; - } - - if (section) { - while (r != EOF && !done && fgets (buf, sizeof (buf), ifp)) { - r = fputs (buf, ofp); - c = buf; - while (*c && *c != '\n') c++; - c[0] = 0; /* strip EOL */ - if (!strncmp (buf, "#: ", 3) && !m_strcasecmp(buf+3, section)) - done++; - } - if (r != EOF && !done) { - snprintf (buf, sizeof(buf), "#: %s\n", section); - r = fputs (buf, ofp); - } - done = 0; - } - - while (r != EOF && fgets (buf, sizeof (buf), ifp)) { - if (ext) { - c = buf; - while (*c && (*c != '\r') && (*c != '\n')) c++; - c--; - if (*c != '\\') ext = 0; - } else if ((section && !strncmp (buf, "#: ", 3))) { - if (!done && line) { - fputs (line, ofp); - fputc ('\n', ofp); - } - r = fputs (buf, ofp); - done++; - break; - } else if (key && !strncmp (buf, key, strlen(key)) && - (!*key || buf[strlen(key)] == ' ')) { - c = buf; - ext = 0; - while (*c && (*c != '\r') && (*c != '\n')) c++; - c--; - if (*c == '\\') ext = 1; - if (!done && line) { - r = fputs (line, ofp); - if (*key) - r = fputc ('\n', ofp); - done++; - } - } else { - r = fputs (buf, ofp); - } - } - - while (r != EOF && fgets (buf, sizeof (buf), ifp)) - r = fputs (buf, ofp); - - /* If there wasn't a line to replace, put it on the end of the file */ - if (r != EOF && !done && line) { - fputs (line, ofp); - r = fputc ('\n', ofp); - } - mx_unlock_file (filename, fileno (ifp), 0); - m_fclose(&ofp); - m_fclose(&ifp); - if (r == EOF) { - unlink (tmpf); - mutt_error (_("Can't write %s"), tmpf); - return -1; - } - lnk[0] = '\0'; - if ((l = readlink (filename, lnk, sizeof(lnk)-1)) > 0) - lnk[l] = '\0'; - if (rename (tmpf, l > 0 ? lnk : filename) < 0) { - unlink (tmpf); - mutt_error (_("Can't rename %s to %s"), tmpf, l > 0 ? lnk : filename); - return -1; - } - return 0; -} - -int mutt_newsrc_update (nntp_server_t * news) -{ - buffer_t buf; - nntp_data_t *data; - int r = -1; - - if (!news) - return -1; - - buffer_init(&buf); - - /* we will generate full newsrc here */ - for (data = news->list; data; data = data->next) { - if (!data || !data->rc) - continue; - - buffer_addstr(&buf, data->group); - buffer_addch(&buf, data->subscribed ? ':' : '!'); - - for (int x = 0; x < data->num; x++) { - buffer_addch(&buf, x ? ',' : ' '); - buffer_addf(&buf, "%d-%d", data->entries[x].first, - data->entries[x].last); - } - buffer_addch(&buf, '\n'); - } - - /* newrc being fully rewritten */ - if (news->newsrc - && (r = mutt_update_list_file(news->newsrc, NULL, "", buf.data)) == 0) - { - struct stat st; - - stat (news->newsrc, &st); - news->size = st.st_size; - news->mtime = st.st_mtime; - } - - buffer_wipe(&buf); - return r; -} - -static FILE *mutt_mkname (char *s) -{ - char buf[_POSIX_PATH_MAX], *pc; - int fd; - FILE *fp; - - nntp_cache_expand(buf, ssizeof(buf), "%s", s); - if ((fp = safe_fopen (buf, "w"))) - return fp; - - nntp_cache_expand(buf, ssizeof(buf), "cache-XXXXXX"); - pc = buf + m_strlen(buf) - 12; /* positioning to "cache-XXXXXX" */ - if ((fd = mkstemp (buf)) == -1) - return NULL; - strcpy (s, pc); /* generated name */ - return fdopen (fd, "w"); -} - -/* Updates info into .index file: ALL or about selected newsgroup */ -static int nntp_update_cacheindex (nntp_server_t * serv, nntp_data_t * data) -{ - char buf[LONG_STRING]; - char file[_POSIX_PATH_MAX]; - const char *key = "ALL"; - - if (!serv || !serv->conn || !serv->conn->account.host) - return -1; - - if (data && data->group) { - key = data->group; - snprintf(buf, sizeof(buf), "%s %s %d %d", key, data->cache, - data->first, data->lastLoaded); - } else { - m_strcpy(file, sizeof(file), serv->cache); - snprintf(buf, sizeof (buf), "ALL %s 0 %d", file, - (int)serv->newgroups_time); - } - nntp_cache_expand(file, ssizeof(file), "%s.index", serv->conn->account.host); - return mutt_update_list_file(file, serv->conn->account.host, key, buf); -} - -static void nntp_delete_cache (nntp_data_t * data) -{ - char buf[_POSIX_PATH_MAX]; - - if (!nntp.use_cache || !data || !data->cache || !data->nserv) - return; - - nntp_cache_expand(buf, ssizeof(buf), "%s", data->cache); - unlink (buf); - p_delete(&data->cache); - data->lastCached = 0; - nntp_cache_expand(buf, ssizeof(buf), "%s.index", - data->nserv->conn->account.host); - mutt_update_list_file(buf, data->nserv->conn->account.host, data->group, - NULL); -} - -static int nntp_save_cache_index (nntp_server_t * news) -{ - char buf[HUGE_STRING]; - char file[_POSIX_PATH_MAX]; - nntp_data_t *d; - FILE *f; - - if (!news || !news->newsgroups) - return -1; - if (!nntp.use_cache) - return 0; - - if (news->cache) { - nntp_cache_expand(file, ssizeof(file), "%s", news->cache); - unlink(file); - f = safe_fopen(file, "w"); - } else { - m_strcpy(buf, ssizeof(buf), news->conn->account.host); - f = mutt_mkname(buf); - news->cache = m_strdup(buf); - nntp_cache_expand(file, ssizeof(file), "%s", buf); - } - if (!f) - return -1; - - for (d = news->list; d; d = d->next) { - if (!d->deleted) { - if (d->desc) - snprintf (buf, sizeof (buf), "%s %d %d %c %s\n", d->group, - d->last, d->first, d->allowed ? 'y' : 'n', - d->desc); - else - snprintf (buf, sizeof (buf), "%s %d %d %c\n", d->group, - d->last, d->first, d->allowed ? 'y' : 'n'); - if (fputs (buf, f) == EOF) { - m_fclose(&f); - unlink (file); - return -1; - } - } - } - m_fclose(&f); - - if (nntp_update_cacheindex (news, NULL)) { - unlink (file); - return -1; - } - return 0; -} - -static int nntp_save_cache_group (CONTEXT * ctx) -{ - char buf[HUGE_STRING], addr[STRING]; - char file[_POSIX_PATH_MAX]; - FILE *f; - HEADER *h; - int i = 0, save = SORT_ORDER; - int prev = 0; - - if (!nntp.use_cache) - return 0; - if (!ctx || !ctx->data || ctx->magic != M_NNTP) - return -1; - - if (((nntp_data_t *) ctx->data)->cache) { - nntp_cache_expand(file, ssizeof(file), "%s", - ((nntp_data_t *)ctx->data)->cache); - unlink (file); - f = safe_fopen (file, "w"); - } - else { - snprintf(buf, ssizeof(buf), "%s-%s", - ((nntp_data_t *)ctx->data)->nserv->conn->account.host, - ((nntp_data_t *)ctx->data)->group); - f = mutt_mkname (buf); - ((nntp_data_t *)ctx->data)->cache = m_strdup(buf); - nntp_cache_expand(file, ssizeof(file), "%s", buf); - } - if (!f) - return -1; - - if (Sort != SORT_ORDER) { - save = Sort; - Sort = SORT_ORDER; - mutt_sort_headers (ctx, 0); - } - - /* Save only $nntp_context messages... */ - ((nntp_data_t *) ctx->data)->lastCached = 0; - if (NntpContext && ctx->msgcount > NntpContext) - i = ctx->msgcount - NntpContext; - for (; i < ctx->msgcount; i++) { - if (!ctx->hdrs[i]->deleted && ctx->hdrs[i]->article_num != prev) { - char *loc; - h = ctx->hdrs[i]; - addr[0] = 0; - rfc822_addrcat(addr, sizeof(addr), h->env->from, 0); - - loc = setlocale(LC_TIME, "C"); - strftime(buf, sizeof(buf), "%d %b %Y %H:%M:%S GMT", gmtime(&h->date_sent)); - setlocale(LC_TIME, loc); - - fprintf(f, "%d\t%s\t%s\t%s\t%s\t\n", h->article_num, h->env->subject, - addr, buf, h->env->message_id); - if (h->env->references) - mutt_write_references (h->env->references, f); - if (fprintf(f, "\t%zd\t%d\tXref: %s\n", h->content->length, h->lines, - NONULL(h->env->xref)) == EOF) - { - m_fclose(&f); - unlink (file); - return -1; - } - } - prev = ctx->hdrs[i]->article_num; - } - - if (save != Sort) { - Sort = save; - mutt_sort_headers (ctx, 0); - } - m_fclose(&f); - - if (nntp_update_cacheindex (((nntp_data_t *) ctx->data)->nserv, - (nntp_data_t *) ctx->data)) { - unlink (file); - return -1; - } - ((nntp_data_t *) ctx->data)->lastCached = - ((nntp_data_t *) ctx->data)->lastLoaded; - return 0; -} - -nntp_data_t *mutt_newsgroup_subscribe (nntp_server_t * news, char *group) -{ - nntp_data_t *data; - - if (!news || !news->newsgroups || !group || !*group) - return NULL; - if (!(data = (nntp_data_t *) hash_find (news->newsgroups, group))) { - data = nntp_data_new(); - data->group = m_strdup(group); - data->nserv = news; - data->deleted = 1; - hash_insert (news->newsgroups, data->group, data); - news->tail = nntp_data_list_append(news->tail, data); - } - if (!data->subscribed) { - data->subscribed = 1; - data->rc = 1; - } - return data; -} - -nntp_data_t *mutt_newsgroup_unsubscribe (nntp_server_t * news, char *group) -{ - nntp_data_t *data; - - if (!news || !news->newsgroups || !group || !*group || - !(data = (nntp_data_t *) hash_find (news->newsgroups, group))) - return NULL; - if (data->subscribed) { - data->subscribed = 0; - } - return data; -} - -nntp_data_t *mutt_newsgroup_catchup (nntp_server_t * news, char *group) -{ - nntp_data_t *data; - - if (!news || !news->newsgroups || !group || !*group || - !(data = (nntp_data_t *) hash_find (news->newsgroups, group))) - return NULL; - if (!data->max) { - data->entries = p_new(NEWSRC_ENTRY, 5); - data->max = 5; - } - data->num = 1; - data->entries[0].first = 1; - data->unread = 0; - data->entries[0].last = data->last; - if (Context && Context->data == data) { - int x; - - for (x = 0; x < Context->msgcount; x++) - mutt_set_flag (Context, Context->hdrs[x], M_READ, 1); - } - return data; -} - -nntp_data_t *mutt_newsgroup_uncatchup (nntp_server_t * news, char *group) -{ - nntp_data_t *data; - - if (!news || !news->newsgroups || !group || !*group || - !(data = (nntp_data_t *) hash_find (news->newsgroups, group))) - return NULL; - if (!data->max) { - data->entries = p_new(NEWSRC_ENTRY, 5); - data->max = 5; - } - data->num = 1; - data->entries[0].first = 1; - data->entries[0].last = data->first - 1; - if (Context && Context->data == data) { - int x; - - data->unread = Context->msgcount; - for (x = 0; x < Context->msgcount; x++) - mutt_set_flag (Context, Context->hdrs[x], M_READ, 0); - } - else - data->unread = data->last - data->entries[0].last; - return data; -} - -/* this routine gives the first newsgroup with new messages */ -void nntp_buffy (char* dst, ssize_t dstlen) { - nntp_data_t *list; - int count = 0; - - /* forward to current group */ - for (list = CurrentNewsSrv->list; list; list = list->next) { - if (list->subscribed && list->unread - && Context && Context->magic == M_NNTP - && m_strcmp(list->group, ((nntp_data_t *)Context->data)->group) == 0) - { - list = list->next; - break; - } - } - - *dst = '\0'; - - while (count < 2) { - - if (!list) - list = CurrentNewsSrv->list; - - for (; list; list = list->next) { - if (list->subscribed && list->unread) { - if (Context && Context->magic == M_NNTP && - !m_strcmp(list->group, ((nntp_data_t *)Context->data)->group)) { - int i, unread = 0; - - for (i = 0; i < Context->msgcount; i++) - if (!Context->hdrs[i]->read && !Context->hdrs[i]->deleted) - unread++; - if (!unread) - continue; - } - m_strcpy(dst, dstlen, list->group); - break; - } - } - /* done if found */ - if (dst && *dst) - return; - count++; - } - *dst = '\0'; -} - -/* }}} */ -/* nntp protocol {{{ */ - -void nntp_sync_sidebar (nntp_data_t* data) { - int i = 0; - BUFFY* tmp = NULL; - char buf[STRING]; - - if (!Incoming.len) - return; - - snprintf(buf, sizeof (buf), "nntp%s://%s%s%s%s/%s", - data->nserv->conn->account.has_ssl ? "s" : "", - NONULL(data->nserv->conn->account.user), - *data->nserv->conn->account.pass ? ":" : "", - *data->nserv->conn->account.pass ? data->nserv->conn->account.pass : "", - data->nserv->conn->account.host, - data->group); - - /* bail out if group not found via mailboxes */ - if ((i = buffy_lookup (buf)) < 0) - return; - - tmp = Incoming.arr[i]; - /* copied from browser.c */ - if (option (OPTMARKOLD) && - data->lastCached >= data->first && - data->lastCached <= data->last) - tmp->msg_unread = data->last - data->lastCached; - else - tmp->msg_unread = data->unread; - tmp->new = data->unread > 0; - /* this is closest to a "total" count we can get */ - tmp->msgcount = data->last - data->first; -} - -static int nntp_auth (nntp_server_t * serv) -{ - CONNECTION *conn = serv->conn; - char buf[STRING]; - int flags = conn->account.flags; - - if (mutt_account_getuser(&conn->account) || !conn->account.user[0] || - mutt_account_getpass(&conn->account) || !conn->account.pass[0]) { - conn->account.flags = flags; - return -2; - } - - mutt_message _("Logging in..."); - - snprintf (buf, sizeof (buf), "AUTHINFO USER %s\r\n", conn->account.user); - mutt_socket_write (conn, buf); - if (mutt_socket_readln (buf, sizeof (buf), conn) < 0) { - conn->account.flags = flags; - return -1; - } - - snprintf (buf, sizeof (buf), "AUTHINFO PASS %s\r\n", conn->account.pass); - mutt_socket_write(conn, buf); - if (mutt_socket_readln (buf, sizeof (buf), conn) < 0) { - conn->account.flags = flags; - return -1; - } - - if (m_strncmp("281", buf, 3)) { - conn->account.flags = flags; - mutt_error _("Login failed."); - - sleep (2); - return -3; - } - - return 0; -} - -static int nntp_connect_error (nntp_server_t * serv) -{ - serv->status = NNTP_NONE; - mutt_socket_close (serv->conn); - mutt_error _("Server closed connection!"); - - sleep (2); - return -1; -} - -static int nntp_connect_and_auth (nntp_server_t * serv) -{ - CONNECTION *conn = serv->conn; - char buf[STRING]; - int rc; - - serv->status = NNTP_NONE; - - if (mutt_socket_open (conn) < 0) - return -1; - - if (mutt_socket_readln (buf, sizeof (buf), conn) < 0) - return nntp_connect_error (serv); - - if (!m_strncmp("200", buf, 3)) - mutt_message (_("Connected to %s. Posting ok."), conn->account.host); - else if (!m_strncmp("201", buf, 3)) - mutt_message (_("Connected to %s. Posting NOT ok."), conn->account.host); - else { - mutt_socket_close(conn); - m_strrtrim(buf); - mutt_error("%s", buf); - sleep (2); - return -1; - } - - /* Tell INN to switch to mode reader if it isn't so. Ignore all - returned codes and messages. */ - mutt_socket_write (conn, "MODE READER\r\n"); - if (mutt_socket_readln (buf, sizeof (buf), conn) < 0) - return nntp_connect_error (serv); - - mutt_socket_write (conn, "STAT\r\n"); - if (mutt_socket_readln (buf, sizeof (buf), conn) < 0) - return nntp_connect_error (serv); - - if (!conn->account.has_user && m_strncmp("480", buf, 3)) { - serv->status = NNTP_OK; - return 0; - } - - rc = nntp_auth (serv); - if (rc == -1) - return nntp_connect_error (serv); - if (rc == -2) { - mutt_socket_close (conn); - serv->status = NNTP_BYE; - return -1; - } - if (rc < 0) { - mutt_socket_close (conn); - mutt_error _("Login failed."); - - sleep (2); - return -1; - } - serv->status = NNTP_OK; - return 0; -} - -static int nntp_attempt_features (nntp_server_t * serv) -{ - char buf[LONG_STRING]; - CONNECTION *conn = serv->conn; - - if (serv->feat_known) - return 0; - - mutt_socket_write (conn, "XOVER\r\n"); - if (mutt_socket_readln (buf, sizeof (buf), conn) < 0) - return nntp_connect_error (serv); - if (m_strncmp("500", buf, 3)) - serv->hasXOVER = 1; - - mutt_socket_write (conn, "XPAT\r\n"); - if (mutt_socket_readln (buf, sizeof (buf), conn) < 0) - return nntp_connect_error (serv); - if (m_strncmp("500", buf, 3)) - serv->hasXPAT = 1; - - mutt_socket_write (conn, "LISTGROUP\r\n"); - if (mutt_socket_readln (buf, sizeof (buf), conn) < 0) - return (nntp_connect_error (serv)); - if (m_strncmp("500", buf, 3)) - serv->hasLISTGROUP = 1; - - mutt_socket_write (conn, "XGTITLE +\r\n"); - if (mutt_socket_readln (buf, sizeof (buf), conn) < 0) - return nntp_connect_error (serv); - if (m_strncmp("500", buf, 3)) - serv->hasXGTITLE = 1; - - if (!m_strncmp("282", buf, 3)) { - do { - if (mutt_socket_readln (buf, sizeof (buf), conn) < 0) - return nntp_connect_error (serv); - } while (!(buf[0] == '.' && buf[1] == '\0')); - } - - serv->feat_known = 1; - return 0; -} - -static int nntp_open_connection (nntp_server_t * serv) -{ - if (serv->status == NNTP_OK) - return 0; - if (serv->status == NNTP_BYE) - return -1; - if (nntp_connect_and_auth (serv) < 0) - return -1; - if (nntp_attempt_features (serv) < 0) - return -1; - return 0; -} - -static int nntp_reconnect (nntp_server_t * serv) -{ - char buf[STRING]; - - mutt_socket_close (serv->conn); - - for (;;) { - if (nntp_connect_and_auth (serv) == 0) - return 0; - - snprintf (buf, sizeof (buf), _("Connection to %s lost. Reconnect?"), - serv->conn->account.host); - if (query_quadoption (OPT_NNTPRECONNECT, buf) != M_YES) { - serv->status = NNTP_BYE; - return -1; - } - } -} - -/* Send data from line[LONG_STRING] and receive answer to same line */ -static int mutt_nntp_query (nntp_data_t * data, char *line, size_t linelen) -{ - char buf[LONG_STRING]; - int done = TRUE; - - if (data->nserv->status == NNTP_BYE) - return -1; - - do { - if (*line) { - mutt_socket_write (data->nserv->conn, line); - } - else if (data->group) { - snprintf (buf, sizeof (buf), "GROUP %s\r\n", data->group); - mutt_socket_write (data->nserv->conn, buf); - } - - done = TRUE; - if (mutt_socket_readln (buf, sizeof (buf), data->nserv->conn) < 0) { - if (nntp_reconnect (data->nserv) < 0) - return -1; - - if (data->group) { - snprintf (buf, sizeof (buf), "GROUP %s\r\n", data->group); - mutt_socket_write (data->nserv->conn, buf); - if (mutt_socket_readln (buf, sizeof (buf), data->nserv->conn) < 0) - return -1; - } - if (*line) - done = FALSE; - } - else if ((!m_strncmp("480", buf, 3)) && nntp_auth (data->nserv) < 0) - return -1; - } while (!done); - - m_strcpy(line, linelen, buf); - return 0; -} - -/* - * This function calls funct(*line, *data) for each received line, - * funct(NULL, *data) if rewind(*data) needs, exits when fail or done. - * Returned codes: - * 0 - successful, - * 1 - correct but not performed (may be, have to be continued), - * -1 - conection lost, - * -2 - invalid command or execution error, - * -3 - error in funct(*line, *data). - */ -static int mutt_nntp_fetch (nntp_data_t * nntp_data, const char *query, - const char *msg, progress_t* bar, - int (*funct) (char *, void *), - void *data, int tagged) -{ - char buf[LONG_STRING]; - char *inbuf, *p; - int done = FALSE; - int chunk, line; - long pos = 0; - size_t lenbuf = 0; - int ret; - - do { - m_strcpy(buf, sizeof(buf), query); - if (mutt_nntp_query (nntp_data, buf, sizeof (buf)) < 0) - return -1; - if (buf[0] == '5') - return -2; - if (buf[0] != '2') - return 1; - - ret = 0; - line = 0; - inbuf = p_new(char, sizeof(buf)); - - for (;;) { - chunk = mutt_socket_readln(buf, sizeof (buf), nntp_data->nserv->conn); - if (chunk < 0) - break; - - p = buf; - if (!lenbuf && buf[0] == '.') { - if (buf[1] == '\0') { - done = TRUE; - break; - } - if (buf[1] == '.') - p++; - } - - m_strcpy(inbuf + lenbuf, sizeof(buf), p); - pos += chunk; - - if (chunk >= ssizeof (buf)) { - lenbuf += m_strlen(p); - } - else { - if (bar) { - mutt_progress_bar (bar, pos); - } else if (msg) { - line++; - if (ReadInc && (line % ReadInc == 0)) { - if (tagged) - mutt_message (_("%s (tagged: %d) %d"), msg, tagged, line); - else - mutt_message ("%s %d", msg, line); - } - } - - if (ret == 0 && funct (inbuf, data) < 0) - ret = -3; - lenbuf = 0; - } - - p_realloc(&inbuf, lenbuf + sizeof (buf)); - } - p_delete(&inbuf); - funct (NULL, data); - } - while (!done); - return ret; -} - -static int nntp_read_tempfile (char *line, void *file) -{ - FILE *f = (FILE *) file; - - if (!line) - rewind (f); - else { - fputs (line, f); - if (fputc ('\n', f) == EOF) - return -1; - } - return 0; -} - -static void nntp_parse_xref (CONTEXT * ctx, char *group, char *xref, - HEADER * h) -{ - register char *p, *b; - register char *colon = NULL; - - b = p = xref; - while (*p) { - /* skip to next word */ - b = p; - while (*b && ((*b == ' ') || (*b == '\t'))) - b++; - p = b; - colon = NULL; - /* skip to end of word */ - while (*p && (*p != ' ') && (*p != '\t')) { - if (*p == ':') - colon = p; - p++; - } - if (*p) { - *p = '\0'; - p++; - } - if (colon) { - *colon = '\0'; - colon++; - nntp_get_status (ctx, h, b, atoi (colon)); - if (h && h->article_num == 0 && m_strcmp(group, b) == 0) - h->article_num = atoi (colon); - } - } -} - -/* - * returns: - * 0 on success - * 1 if article not found - * -1 if read or write error on tempfile or socket - */ -static int nntp_read_header (CONTEXT * ctx, const char *msgid, - int article_num) -{ - nntp_data_t *nntp_data = ((nntp_data_t *) ctx->data); - FILE *f; - char buf[LONG_STRING]; - char tempfile[_POSIX_PATH_MAX]; - int ret; - HEADER *h = ctx->hdrs[ctx->msgcount]; - - f = m_tempfile(tempfile, sizeof(tempfile), NONULL(mod_core.tmpdir), NULL); - if (!f) - return -1; - - if (!msgid) - snprintf (buf, sizeof (buf), "HEAD %d\r\n", article_num); - else - snprintf (buf, sizeof (buf), "HEAD %s\r\n", msgid); - - ret = mutt_nntp_fetch (nntp_data, buf, NULL, NULL, nntp_read_tempfile, f, 0); - if (ret) { - m_fclose(&f); - unlink (tempfile); - return (ret == -1 ? -1 : 1); - } - - h->article_num = article_num; - h->env = mutt_read_rfc822_header (f, h, 0, 0); - m_fclose(&f); - unlink (tempfile); - - if (h->env->xref != NULL) - nntp_parse_xref (ctx, nntp_data->group, h->env->xref, h); - else if (h->article_num == 0 && msgid) { - snprintf (buf, sizeof (buf), "STAT %s\r\n", msgid); - if (mutt_nntp_query (nntp_data, buf, sizeof (buf)) == 0) - h->article_num = atoi (buf + 4); - } - - return 0; -} - -static int parse_description (char *line, void *n) -{ - register char *d = line; - nntp_data_t *data; - nntp_server_t *news = n; - - if (!line) - return 0; - while (*d && *d != '\t' && *d != ' ') - d++; - *d = 0; - d++; - while (*d && (*d == '\t' || *d == ' ')) - d++; - if ((data = (nntp_data_t *) hash_find (news->newsgroups, line)) != NULL && - m_strcmp(d, data->desc)) { - p_delete(&data->desc); - data->desc = m_strdup(d); - } - return 0; -} - -static void nntp_get_desc (nntp_data_t * data, const char *mask, char *msg, progress_t* bar) -{ - char buf[STRING]; - - if (!option (OPTLOADDESC) || !data || !data->nserv) - return; - - /* Get newsgroup description, if we can */ - if (data->nserv->hasXGTITLE) - snprintf (buf, sizeof (buf), "XGTITLE %s\r\n", mask); - else - snprintf (buf, sizeof (buf), "LIST NEWSGROUPS %s\r\n", mask); - mutt_nntp_fetch (data, buf, msg, bar, parse_description, data->nserv, 0); -} - -/* - * XOVER returns a tab separated list of: - * id|subject|from|date|Msgid|references|bytes|lines|xref - * - * This has to duplicate some of the functionality of - * mutt_read_rfc822_header(), since it replaces the call to that (albeit with - * a limited number of headers which are "parsed" by placement in the list) - */ -static int nntp_parse_xover (CONTEXT * ctx, char *buf, HEADER * hdr) -{ - nntp_data_t *nntp_data = (nntp_data_t *) ctx->data; - char *p, *b; - int x, done = 0; - - hdr->env = envelope_new(); - hdr->env->newsgroups = m_strdup(nntp_data->group); - hdr->content = body_new(); - hdr->content->type = TYPETEXT; - hdr->content->subtype = m_strdup("plain"); - hdr->content->encoding = ENC7BIT; - hdr->content->disposition = DISPINLINE; - hdr->content->length = -1; - b = p = buf; - - for (x = 0; !done && x < 9; x++) { - /* if from file, need to skip newline character */ - while (*p && *p != '\n' && *p != '\t') - p++; - if (!*p) - done++; - *p = '\0'; - p++; - switch (x) { - case 0: - hdr->article_num = atoi (b); - nntp_get_status (ctx, hdr, NULL, hdr->article_num); - break; - case 1: - hdr->env->subject = m_strdup(b); - break; - case 2: - address_list_wipe(&hdr->env->from); - hdr->env->from = rfc822_parse_adrlist (hdr->env->from, b); - /* same as for mutt_parse_rfc822_line(): - * don't leave from info NULL if there's an invalid address (or - * whatever) in From: field; mutt would just display it as empty - * and mark mail/(esp.) news article as your own. aaargh! this - * bothered me for _years_ */ - if (!hdr->env->from) { - hdr->env->from = address_new (); - hdr->env->from->personal = m_strdup(b); - } - break; - case 3: - hdr->date_sent = mutt_parse_date (b, hdr); - hdr->received = hdr->date_sent; - break; - case 4: - p_delete(&hdr->env->message_id); - hdr->env->message_id = m_strdup(b); - break; - case 5: - string_list_wipe(&hdr->env->references); - hdr->env->references = mutt_parse_references (b, 0); - break; - case 6: - hdr->content->length = atoi (b); - break; - case 7: - hdr->lines = atoi (b); - break; - case 8: - if (!hdr->read) - p_delete(&hdr->env->xref); - b = b + 6; /* skips the "Xref: " */ - hdr->env->xref = m_strdup(b); - nntp_parse_xref (ctx, nntp_data->group, b, hdr); - } - rfc2047_decode_envelope(hdr->env); - if (!*p) - return -1; - b = p; - } - return 0; -} - -typedef struct { - CONTEXT *ctx; - int first; - int last; - bits_t messages; - const char *msg; -} FETCH_CONTEXT; - -static int nntp_fetch_numbers (char *line, void *c) -{ - FETCH_CONTEXT *fc = c; - - if (line) { - int num = atoi(line); - if (num < fc->first || num > fc->last) - return 0; - - bit_set(&fc->messages, num); - } - return 0; -} - -static int add_xover_line (char *line, void *c) -{ - int num, total; - FETCH_CONTEXT *fc = c; - CONTEXT *ctx = fc->ctx; - nntp_data_t *data = (nntp_data_t *) ctx->data; - - if (!line) - return 0; - - if (ctx->msgcount >= ctx->hdrmax) - mx_alloc_memory (ctx); - ctx->hdrs[ctx->msgcount] = header_new(); - ctx->hdrs[ctx->msgcount]->index = ctx->msgcount; - - nntp_parse_xover (ctx, line, ctx->hdrs[ctx->msgcount]); - num = ctx->hdrs[ctx->msgcount]->article_num; - - if (num >= fc->first && num <= fc->last) { - ctx->msgcount++; - if (num > data->lastLoaded) - data->lastLoaded = num; - num = num - fc->first + 1; - total = fc->last - fc->first + 1; - if (!ctx->quiet && fc->msg && ReadInc && (num % ReadInc == 0)) - mutt_message ("%s %d/%d", fc->msg, num, total); - } else { - header_delete(&ctx->hdrs[ctx->msgcount]); /* skip it */ - } - - return 0; -} - - -static int nntp_fetch_headers(CONTEXT * ctx, int first, int last) -{ - char buf[HUGE_STRING]; - const char *msg = _("Fetching message headers..."); - const char *msg2 = _("Fetching headers from cache..."); - nntp_data_t *nntp_data = ((nntp_data_t *) ctx->data); - int ret, num, oldmsgcount, current; - FILE *f; - FETCH_CONTEXT fc; - - /* if empty group or nothing to do */ - if (!last || first > last) - return 0; - - /* fetch list of articles */ - mutt_message _("Fetching list of articles..."); - - fc.ctx = ctx; - fc.first = first; - fc.last = last; - - /* CACHE: must be loaded xover cache here */ - num = nntp_data->lastCached - first + 1; - if (nntp.use_cache && nntp_data->cache && num > 0) { - nntp_cache_expand(buf, ssizeof(buf), "%s", nntp_data->cache); - mutt_message (msg2); - - if ((f = safe_fopen (buf, "r"))) { - int r = 0, c = 0; - - /* counting number of lines */ - while (fgets (buf, sizeof (buf), f) != NULL) - r++; - rewind (f); - while (r > num && fgets (buf, sizeof (buf), f) != NULL) - r--; - oldmsgcount = ctx->msgcount; - fc.first = first; - fc.last = first + num - 1; - fc.msg = NULL; - while (fgets (buf, sizeof (buf), f) != NULL) { - if (ReadInc && ((++c) % ReadInc == 0)) - mutt_message ("%s %d/%d", msg2, c, r); - add_xover_line (buf, &fc); - } - m_fclose(&f); - nntp_data->lastLoaded = fc.last; - first = fc.last + 1; - if (ctx->msgcount > oldmsgcount) - mx_update_context (ctx, ctx->msgcount - oldmsgcount); - } - else - nntp_delete_cache (nntp_data); - } - num = last - first + 1; - if (num <= 0) { - return 0; - } - - /* - * Without XOVER, we have to fetch each article header and parse - * it. With XOVER, we ask for all of them - */ - mutt_message (msg); - if (nntp_data->nserv->hasXOVER) { - oldmsgcount = ctx->msgcount; - fc.first = first; - fc.last = last; - fc.msg = msg; - snprintf (buf, sizeof (buf), "XOVER %d-%d\r\n", first, last); - ret = mutt_nntp_fetch (nntp_data, buf, NULL, NULL, add_xover_line, &fc, 0); - if (ctx->msgcount > oldmsgcount) - mx_update_context (ctx, ctx->msgcount - oldmsgcount); - if (ret != 0) { - mutt_error (_("XOVER command failed: %s"), buf); - return -1; - } - } else { - bits_init(&fc.messages); - - if (nntp_data->nserv->hasLISTGROUP) { - snprintf (buf, sizeof (buf), "LISTGROUP %s\r\n", nntp_data->group); - if (mutt_nntp_fetch(nntp_data, buf, NULL, NULL, - nntp_fetch_numbers, &fc, 0)) - { - mutt_error (_("LISTGROUP command failed: %s"), buf); - sleep (2); - bits_wipe(&fc.messages); - return -1; - } - } else { - for (num = first; num <= last; num++) - bit_set(&fc.messages, num); - } - - for (current = first; current <= last; current++) { - HEADER *h; - - ret = current - first + 1; - mutt_message ("%s %d/%d", msg, ret, num); - - if (!bit_isset(&fc.messages, current)) - continue; - - if (ctx->msgcount >= ctx->hdrmax) - mx_alloc_memory (ctx); - h = ctx->hdrs[ctx->msgcount] = header_new(); - h->index = ctx->msgcount; - - ret = nntp_read_header (ctx, NULL, current); - if (ret == 0) { /* Got article. Fetch next header */ - nntp_get_status (ctx, h, NULL, h->article_num); - ctx->msgcount++; - mx_update_context (ctx, 1); - } - else - header_delete(&h); /* skip it */ - if (ret == -1) { - bits_wipe(&fc.messages); - return -1; - } - - if (current > nntp_data->lastLoaded) - nntp_data->lastLoaded = current; - } - bits_wipe(&fc.messages); - } - - nntp_data->lastLoaded = last; - mutt_clear_error (); - return 0; -} - -/* - * currently, nntp "mailbox" is "newsgroup" - */ -static int nntp_open_mailbox (CONTEXT * ctx) -{ - nntp_data_t *nntp_data; - nntp_server_t *serv; - char buf[HUGE_STRING]; - char server[LONG_STRING]; - int count = 0, first; - ACCOUNT act; - - p_clear(&act, 1); - - if (nntp_parse_url (ctx->path, &act, buf, sizeof (buf)) < 0 || !*buf) { - mutt_error (_("%s is an invalid newsgroup specification!"), ctx->path); - mutt_sleep (2); - return -1; - } - - server[0] = '\0'; - nntp_expand_path (server, sizeof (server), &act); - if (!(serv = mutt_select_newsserver (server)) || serv->status != NNTP_OK) - return -1; - - CurrentNewsSrv = serv; - - /* create NNTP-specific state struct if nof found in list */ - if ((nntp_data = hash_find(serv->newsgroups, buf)) == NULL) { - nntp_data = nntp_data_new(); - nntp_data->group = m_strdup(buf); - hash_insert(serv->newsgroups, nntp_data->group, nntp_data); - serv->tail = nntp_data_list_append(serv->tail, nntp_data); - } - ctx->data = nntp_data; - nntp_data->nserv = serv; - - mutt_message (_("Selecting %s..."), nntp_data->group); - - if (!nntp_data->desc) { - nntp_get_desc (nntp_data, nntp_data->group, NULL, NULL); - if (nntp_data->desc) - nntp_save_cache_index (serv); - } - - buf[0] = 0; - if (mutt_nntp_query (nntp_data, buf, sizeof (buf)) < 0) { - return -1; - } - - if (m_strncmp("211", buf, 3)) { - nntp_data_t **l; - - /* GROUP command failed */ - if (!m_strncmp("411", buf, 3)) { - mutt_error (_("Newsgroup %s not found on server %s"), - nntp_data->group, serv->conn->account.host); - - /* CACHE: delete cache and line from .index */ - nntp_delete_cache (nntp_data); - hash_remove(serv->newsgroups, nntp_data->group, NULL, NULL); - for (l = &serv->list; *l; l = &(*l)->next) { - if ((*l) == nntp_data) { - nntp_data_list_pop(l); - nntp_data_delete(&nntp_data); - if (!*l) - serv->tail = l; - break; - } - } - nntp_data_delete(&nntp_data); - sleep (2); - } - - return -1; - } - - sscanf (buf + 4, "%d %u %u %s", &count, &nntp_data->first, - &nntp_data->last, buf); - - nntp_data->deleted = 0; - - time (&serv->check_time); - - /* - * Check for max adding context. If it is greater than $nntp_context, - * strip off extra articles - */ - first = nntp_data->first; - if (NntpContext && nntp_data->last - first + 1 > NntpContext) - first = nntp_data->last - NntpContext + 1; - if (first) - nntp_data->lastLoaded = first - 1; - return nntp_fetch_headers (ctx, first, nntp_data->last); -} - -int nntp_fetch_message (MESSAGE * msg, CONTEXT * ctx, int msgno) -{ - char buf[LONG_STRING]; - char path[_POSIX_PATH_MAX]; - NNTP_CACHE *cache; - int ret; - progress_t bar; - - /* see if we already have the message in our cache */ - cache = - &((nntp_data_t *) ctx->data)->acache[ctx->hdrs[msgno]->index % - NNTP_CACHE_LEN]; - - /* if everything is fine, assign msg->fp and return */ - if (cache->path && cache->index == ctx->hdrs[msgno]->index && - (msg->fp = fopen (cache->path, "r"))) - return 0; - - /* clear the previous entry */ - unlink (cache->path); - p_delete(&cache->path); - - cache->index = ctx->hdrs[msgno]->index; - msg->fp = m_tempfile(path, sizeof(path), NONULL(mod_core.tmpdir), NULL); - if (!msg->fp) { - return -1; - } - cache->path = m_strdup(path); - - if (ctx->hdrs[msgno]->article_num == 0) - snprintf (buf, sizeof (buf), "ARTICLE %s\r\n", - ctx->hdrs[msgno]->env->message_id); - else - snprintf (buf, sizeof (buf), "ARTICLE %d\r\n", - ctx->hdrs[msgno]->article_num); - - bar.msg = _("Fetching message..."); - bar.size = 0; - mutt_progress_bar (&bar, 0); - - ret = mutt_nntp_fetch ((nntp_data_t *) ctx->data, buf, NULL, &bar, nntp_read_tempfile, - msg->fp, ctx->tagged); - if (ret == 1) { - mutt_error (_("Article %d not found on server"), - ctx->hdrs[msgno]->article_num); - } - - if (ret) { - m_fclose(&msg->fp); - unlink (path); - p_delete(&cache->path); - return -1; - } - - envelope_delete(&ctx->hdrs[msgno]->env); - ctx->hdrs[msgno]->env = - mutt_read_rfc822_header (msg->fp, ctx->hdrs[msgno], 0, 0); - /* fix content length */ - fseeko (msg->fp, 0, SEEK_END); - ctx->hdrs[msgno]->content->length = ftello (msg->fp) - - ctx->hdrs[msgno]->content->offset; - - /* this is called in mutt before the open which fetches the message, - * which is probably wrong, but we just call it again here to handle - * the problem instead of fixing it. - */ - mutt_parse_mime_message (ctx, ctx->hdrs[msgno]); - - /* These would normally be updated in mx_update_context(), but the - * full headers aren't parsed with XOVER, so the information wasn't - * available then. - */ - ctx->hdrs[msgno]->security = crypt_query (ctx->hdrs[msgno]->content); - - mutt_clear_error (); - rewind (msg->fp); - - return 0; -} - -/* Post article */ -int nntp_post (const char *msg) -{ - char buf[LONG_STRING]; - size_t len; - FILE *f; - nntp_data_t *nntp_data; - - if (Context && Context->magic == M_NNTP) - nntp_data = (nntp_data_t *)Context->data; - else { - if (!(CurrentNewsSrv = mutt_select_newsserver(NewsServer)) || - !CurrentNewsSrv->list) - { - mutt_error (_("Can't post article. No connection to news server.")); - return -1; - } - nntp_data = CurrentNewsSrv->list; - } - - if (!(f = safe_fopen (msg, "r"))) { - mutt_error (_("Can't post article. Unable to open %s"), msg); - return -1; - } - - m_strcpy(buf, sizeof(buf), "POST\r\n"); - if (mutt_nntp_query (nntp_data, buf, sizeof (buf)) < 0) { - mutt_error (_("Can't post article. Connection to %s lost."), - nntp_data->nserv->conn->account.host); - return -1; - } - if (buf[0] != '3') { - mutt_error (_("Can't post article: %s"), buf); - return -1; - } - - buf[0] = '.'; - buf[1] = '\0'; - while (fgets (buf + 1, sizeof (buf) - 2, f) != NULL) { - len = m_strlen(buf); - if (buf[len - 1] == '\n') { - buf[len - 1] = '\r'; - buf[len] = '\n'; - len++; - buf[len] = '\0'; - } - if (buf[1] == '.') - mutt_socket_write(nntp_data->nserv->conn, buf); - else - mutt_socket_write(nntp_data->nserv->conn, buf + 1); - } - m_fclose(&f); - - if (buf[m_strlen(buf) - 1] != '\n') - mutt_socket_write(nntp_data->nserv->conn, "\r\n"); - mutt_socket_write(nntp_data->nserv->conn, ".\r\n"); - if (mutt_socket_readln (buf, sizeof (buf), nntp_data->nserv->conn) < 0) { - mutt_error (_("Can't post article. Connection to %s lost."), - nntp_data->nserv->conn->account.host); - return -1; - } - if (buf[0] != '2') { - mutt_error (_("Can't post article: %s"), buf); - return -1; - } - - return 0; -} - -/* nntp_logout_all: close all open connections. */ -void nntp_logout_all (void) -{ - char buf[LONG_STRING]; - CONNECTION *conn; - - conn = mutt_socket_head (); - - while (conn) { - CONNECTION* next = conn->next; - if (conn->account.type == M_ACCT_TYPE_NNTP) { - mutt_message (_("Closing connection to %s..."), conn->account.host); - mutt_socket_write (conn, "QUIT\r\n"); - mutt_socket_readln (buf, sizeof (buf), conn); - mutt_clear_error (); - mutt_socket_close (conn); - mutt_socket_free (conn); - } - conn = next; - } -} - -static int nntp_sync_mailbox (CONTEXT * ctx, int unused1, int* unused2) -{ - nntp_data_t *data = ctx->data; - - nntp_save_cache_group(ctx); - nntp_free_acache(data); - - data->nserv->check_time = 0; /* next nntp_check_mailbox() will really check */ - return 0; -} - -static void nntp_fastclose_mailbox (CONTEXT * ctx) -{ - nntp_data_t *data = (nntp_data_t *) ctx->data, *tmp; - - if (!data) - return; - nntp_free_acache (data); - if (!data->nserv || !data->nserv->newsgroups || !data->group) - return; - nntp_save_cache_index (data->nserv); - if ((tmp = hash_find (data->nserv->newsgroups, data->group)) == NULL - || tmp != data) - nntp_data_delete(&data); - else - nntp_sync_sidebar (data); -} - -/* commit changes and terminate connection */ -int nntp_close_mailbox (CONTEXT * ctx) -{ - if (!ctx) - return -1; - mutt_message _("Quitting newsgroup..."); - - if (ctx->data) { - nntp_data_t *data = (nntp_data_t *) ctx->data; - int ret; - - if (data->nserv && data->nserv->conn && ctx->unread) { - ret = query_quadoption (OPT_CATCHUP, _("Mark all articles read?")); - if (ret == M_YES) - mutt_newsgroup_catchup (data->nserv, data->group); - else if (ret < 0) - return -1; - } - } - nntp_sync_mailbox (ctx, 0, NULL); - if (ctx->data && ((nntp_data_t *) ctx->data)->nserv) { - nntp_server_t *news; - - news = ((nntp_data_t *) ctx->data)->nserv; - newsrc_gen_entries (ctx); - ((nntp_data_t *) ctx->data)->unread = ctx->unread; - mutt_newsrc_update (news); - } - mutt_clear_error (); - return 0; -} - -/* use the GROUP command to poll for new mail */ -static int _nntp_check_mailbox (CONTEXT * ctx, nntp_data_t * nntp_data) -{ - char buf[LONG_STRING]; - int count = 0; - - if (nntp_data->nserv->check_time + NewsPollTimeout > time (NULL)) - return 0; - - buf[0] = 0; - if (mutt_nntp_query (nntp_data, buf, sizeof (buf)) < 0) { - return -1; - } - if (m_strncmp("211", buf, 3)) { - buf[0] = 0; - if (mutt_nntp_query (nntp_data, buf, sizeof (buf)) < 0) { - return -1; - } - } - if (!m_strncmp("211", buf, 3)) { - int first; - int last; - - sscanf (buf + 4, "%d %d %d", &count, &first, &last); - nntp_data->first = first; - nntp_data->last = last; - if (ctx && last > nntp_data->lastLoaded) { - nntp_fetch_headers (ctx, nntp_data->lastLoaded + 1, last); - time (&nntp_data->nserv->check_time); - return 1; - } - if (!last || (!nntp_data->rc && !nntp_data->lastCached)) - nntp_data->unread = count; - else - mutt_newsgroup_stat (nntp_data); - /* active was renumbered? */ - if (last < nntp_data->lastLoaded) { - if (!nntp_data->max) { - nntp_data->entries = p_new(NEWSRC_ENTRY, 5); - nntp_data->max = 5; - } - nntp_data->lastCached = 0; - nntp_data->num = 1; - nntp_data->entries[0].first = 1; - nntp_data->entries[0].last = 0; - } - nntp_sync_sidebar (nntp_data); - } - - time (&nntp_data->nserv->check_time); - return 0; -} - -static int nntp_check_mailbox (CONTEXT * ctx, int* unused1, int unused2) -{ - return _nntp_check_mailbox (ctx, (nntp_data_t *) ctx->data); -} - -static int nntp_check_newgroups (nntp_server_t * serv, int force) -{ - char buf[LONG_STRING]; - nntp_data_t nntp_data; - nntp_data_t *l, **emp; - time_t now; - struct tm *t; - - if (!serv || !serv->newgroups_time) - return -1; - - if (nntp_open_connection (serv) < 0) - return -1; - - /* check subscribed groups for new news */ - if (option (OPTSHOWNEWNEWS)) { - mutt_message _("Checking for new messages..."); - - for (l = serv->list; l; l = l->next) { - serv->check_time = 0; /* really check! */ - if (l->subscribed) - _nntp_check_mailbox (NULL, l); - } - sidebar_draw (); - } - else if (!force) - return 0; - - mutt_message _("Checking for new newsgroups..."); - - now = serv->newgroups_time; - time (&serv->newgroups_time); - t = gmtime (&now); - snprintf (buf, sizeof (buf), "NEWGROUPS %02d%02d%02d %02d%02d%02d GMT\r\n", - (t->tm_year % 100), t->tm_mon + 1, t->tm_mday, t->tm_hour, - t->tm_min, t->tm_sec); - nntp_data.nserv = serv; - if (Context && Context->magic == M_NNTP) - nntp_data.group = ((nntp_data_t *) Context->data)->group; - else - nntp_data.group = NULL; - - emp = nntp_data_list_last(&serv->list); - if (mutt_nntp_fetch (&nntp_data, buf, _("Adding new newsgroups..."), NULL, - add_group, serv, 0) != 0) { - return -1; - } - - mutt_message _("Loading descriptions..."); - - for (l = *emp; l; l = l->next) { - l->new = 1; - nntp_get_desc(l, l->group, NULL, NULL); - } - if (*emp) - nntp_save_cache_index(serv); - mutt_clear_error(); - return nntp.checked; -} - -/* Load list of all newsgroups from active */ -int nntp_get_active (nntp_server_t * serv) -{ - char msg[STRING]; - nntp_data_t nntp_data, **tmp = &serv->list; - - if (nntp_open_connection (serv) < 0) - return -1; - - snprintf (msg, sizeof (msg), - _("Loading list of all newsgroups on server %s..."), - serv->conn->account.host); - mutt_message (msg); - time (&serv->newgroups_time); - nntp_data.nserv = serv; - nntp_data.group = NULL; - - if (mutt_nntp_fetch (&nntp_data, "LIST\r\n", msg, NULL, add_group, serv, 0) < 0) { - return -1; - } - - m_strcpy(msg, sizeof(msg), _("Loading descriptions...")); - mutt_message (msg); - nntp_get_desc (&nntp_data, "*", msg, NULL); - - while (*tmp) { - if ((*tmp)->deleted && !(*tmp)->rc) { - nntp_data_t *d = nntp_data_list_pop(tmp); - nntp_delete_cache(d); - hash_remove(serv->newsgroups, d->group, NULL, NULL); - nntp_data_delete(&d); - } else { - tmp = &(*tmp)->next; - } - } - serv->tail = tmp; - nntp_save_cache_index(serv); - - mutt_clear_error (); - return nntp.checked; -} - -/* - * returns -1 if error ocurred while retrieving header, - * number of articles which ones exist in context on success. - */ -int nntp_check_msgid (CONTEXT * ctx, const char *msgid) -{ - int ret; - - /* if msgid is already in context, don't reload them */ - if (hash_find (ctx->id_hash, msgid)) - return 1; - if (ctx->msgcount == ctx->hdrmax) - mx_alloc_memory (ctx); - ctx->hdrs[ctx->msgcount] = header_new(); - ctx->hdrs[ctx->msgcount]->index = ctx->msgcount; - - mutt_message (_("Fetching %s from server..."), msgid); - ret = nntp_read_header (ctx, msgid, 0); - /* since nntp_read_header() may set read flag, we must reset it */ - ctx->hdrs[ctx->msgcount]->read = 0; - if (ret != 0) - header_delete(&ctx->hdrs[ctx->msgcount]); - else { - ctx->msgcount++; - mx_update_context (ctx, 1); - ctx->changed = 1; - } - return ret; -} - -typedef struct { - CONTEXT *ctx; - int num; - int max; - int *child; -} CHILD_CONTEXT; - -static int check_children (char *s, void *c) -{ - CHILD_CONTEXT *cc = c; - int i, n; - - if (!s || (n = atoi (s)) == 0) - return 0; - for (i = 0; i < cc->ctx->msgcount; i++) - if (cc->ctx->hdrs[i]->article_num == n) - return 0; - if (cc->num >= cc->max) - p_realloc(&cc->child, cc->max += 25); - cc->child[cc->num++] = n; - - return 0; -} - -int nntp_check_children (CONTEXT * ctx, const char *msgid) -{ - nntp_data_t *nntp_data = (nntp_data_t *) ctx->data; - char buf[STRING]; - int i, ret = 0, tmp = 0; - CHILD_CONTEXT cc = { ctx, 0, 0, NULL }; - - if (!nntp_data || !nntp_data->nserv || !nntp_data->nserv->conn || - !nntp_data->nserv->conn->account.host) - return -1; - if (nntp_data->first > nntp_data->lastLoaded) - return 0; - if (!nntp_data->nserv->hasXPAT) { - mutt_error (_("Server %s does not support this operation!"), - nntp_data->nserv->conn->account.host); - return -1; - } - - snprintf (buf, sizeof (buf), "XPAT References %d-%d *%s*\r\n", - nntp_data->first, nntp_data->lastLoaded, msgid); - - if (mutt_nntp_fetch (nntp_data, buf, NULL, NULL, check_children, &cc, 0)) { - p_delete(&cc.child); - return -1; - } - - /* dont try to read the xover cache. check_children() already - * made sure that we dont have the article, so we need to visit - * the server. Reading the cache at this point is also bad - * because it would duplicate messages */ - if (nntp.use_cache) { - tmp++; - nntp.use_cache = false; - } - for (i = 0; i < cc.num; i++) { - if ((ret = nntp_fetch_headers (ctx, cc.child[i], cc.child[i]))) - break; - if (ctx->msgcount && - ctx->hdrs[ctx->msgcount - 1]->article_num == cc.child[i]) - ctx->hdrs[ctx->msgcount - 1]->read = 0; - } - if (tmp) - nntp.use_cache = true; - p_delete(&cc.child); - return ret; -} - -static int nntp_is_magic (const char* path, struct stat* st) { - url_scheme_t s = url_check_scheme(NONULL(path)); - return s == U_NNTP || s == U_NNTPS ? M_NNTP : -1; -} - -static int acl_check_nntp (CONTEXT* ctx, int bit) { - switch (bit) { - case ACL_INSERT: /* editing messages */ - case ACL_WRITE: /* change importance */ - return (0); - case ACL_DELETE: /* (un)deletion */ - case ACL_SEEN: /* mark as read */ - return (1); - default: - return (0); - } -} - -mx_t const nntp_mx = { - M_NNTP, - 0, - nntp_is_magic, - NULL, - NULL, - nntp_open_mailbox, - NULL, - acl_check_nntp, - nntp_check_mailbox, - nntp_fastclose_mailbox, - nntp_sync_mailbox, - NULL, -}; - -/* }}} */ diff --git a/nntp.h b/nntp.h deleted file mode 100644 index 09472c5..0000000 --- a/nntp.h +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Copyright notice from original mutt: - * Copyright (C) 1998 Brandon Long - * Copyright (C) 1999 Andrej Gritsenko - * Copyright (C) 2000-2002 Vsevolod Volkov - * - * This file is part of mutt-ng, see http://www.muttng.org/. - * It's licensed under the GNU General Public License, - * please see the file GPL in the top level source directory. - */ - -#ifndef _NNTP_H_ -#define _NNTP_H_ 1 - -#include -#include - -extern mx_t const nntp_mx; - -/* number of entries in the hash table */ -#define NNTP_CACHE_LEN 10 - -enum { - NNTP_NONE = 0, - NNTP_OK, - NNTP_BYE -}; - -typedef struct nntp_data_t nntp_data_t; - -typedef struct nntp_server_t { - unsigned feat_known : 1; - unsigned hasXPAT : 1; - unsigned hasXGTITLE : 1; - unsigned hasXOVER : 1; - unsigned hasLISTGROUP : 1; - unsigned status : 3; - char *newsrc; - char *cache; - int stat; - off_t size; - time_t mtime; - time_t newgroups_time; - time_t check_time; - hash_t *newsgroups; - nntp_data_t *list; /* list of newsgroups */ - nntp_data_t **tail; - CONNECTION *conn; -} nntp_server_t; - -typedef struct { - int index; - char *path; -} NNTP_CACHE; - -typedef struct { - int first; - int last; -} NEWSRC_ENTRY; - -struct nntp_data_t { - struct nntp_data_t *next; - - NEWSRC_ENTRY *entries; - int num; /* number of used entries */ - int max; /* number of allocated entries */ - int unread; - int first, last; - int lastLoaded; - int lastCached; - unsigned subscribed:1; - unsigned rc:1; - unsigned new:1; - unsigned allowed:1; - unsigned deleted:1; - char *group; - char *desc; - char *cache; - nntp_server_t *nserv; - NNTP_CACHE acache[NNTP_CACHE_LEN]; -}; - -DO_INIT(nntp_data_t, nntp_data); -void nntp_data_wipe(nntp_data_t *); -DO_NEW(nntp_data_t, nntp_data); -DO_DELETE(nntp_data_t, nntp_data); -DO_SLIST(nntp_data_t, nntp_data, nntp_data_delete); - -nntp_server_t *mutt_select_newsserver (char *); -nntp_data_t *mutt_newsgroup_subscribe (nntp_server_t *, char *); -nntp_data_t *mutt_newsgroup_unsubscribe (nntp_server_t *, char *); -nntp_data_t *mutt_newsgroup_catchup (nntp_server_t *, char *); -nntp_data_t *mutt_newsgroup_uncatchup (nntp_server_t *, char *); -int mutt_newsrc_update (nntp_server_t *); -int nntp_close_mailbox (CONTEXT *); -int nntp_fetch_message (MESSAGE *, CONTEXT *, int); -int nntp_post (const char *); -int nntp_check_msgid (CONTEXT *, const char *); -int nntp_check_children (CONTEXT *, const char *); -int nntp_get_active (nntp_server_t *); -void nntp_buffy (char* dst, ssize_t dstlen); -void nntp_expand_path (char *, ssize_t, ACCOUNT *); -void nntp_logout_all(void); -void nntp_sync_sidebar (nntp_data_t*); - -WHERE nntp_server_t *CurrentNewsSrv INITVAL (NULL); - -#endif /* _NNTP_H_ */ diff --git a/pager.c b/pager.c index e0643b5..b287a6b 100644 --- a/pager.c +++ b/pager.c @@ -817,10 +817,6 @@ fill_buffer (FILE * f, off_t *last_pos, off_t offset, unsigned char *buf, return b_read; } -#ifdef USE_NNTP -#include "nntp.h" -#endif - static int format_line (struct line_t **lineInfo, int n, unsigned char *buf, int flags, ansi_attr * pa, int cnt, int *pspace, int *pvch, int *pcol, int *pspecial) @@ -1243,10 +1239,6 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t * extra) int old_PagerIndexLines; /* some people want to resize it * while inside the pager... */ -#ifdef USE_NNTP - char *followup_to; -#endif - if (!(flags & M_SHOWCOLOR)) flags |= M_SHOWFLAT; @@ -2052,70 +2044,6 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t * extra) redraw = REDRAW_FULL; break; -#ifdef USE_NNTP - case OP_POST: - CHECK_MODE (IsHeader (extra) && !IsAttach (extra)); - CHECK_ATTACH; - if (extra->ctx && extra->ctx->magic == M_NNTP && - !((nntp_data_t *) extra->ctx->data)->allowed && - query_quadoption (OPT_TOMODERATED, - _ - ("Posting to this group not allowed, may be moderated. Continue?")) - != M_YES) - break; - ci_send_message (SENDNEWS, NULL, NULL, extra->ctx, NULL); - redraw = REDRAW_FULL; - break; - - case OP_FORWARD_TO_GROUP: - CHECK_MODE (IsHeader (extra) || IsMsgAttach (extra)); - CHECK_ATTACH; - if (extra->ctx && extra->ctx->magic == M_NNTP && - !((nntp_data_t *) extra->ctx->data)->allowed && - query_quadoption (OPT_TOMODERATED, - _ - ("Posting to this group not allowed, may be moderated. Continue?")) - != M_YES) - break; - if (IsMsgAttach (extra)) - mutt_attach_forward (extra->fp, extra->hdr, extra->idx, - extra->idxlen, extra->bdy, SENDNEWS); - else - ci_send_message (SENDNEWS | SENDFORWARD, NULL, NULL, extra->ctx, - extra->hdr); - redraw = REDRAW_FULL; - break; - - case OP_FOLLOWUP: - CHECK_MODE (IsHeader (extra) || IsMsgAttach (extra)); - CHECK_ATTACH; - - if (IsMsgAttach (extra)) - followup_to = extra->bdy->hdr->env->followup_to; - else - followup_to = extra->hdr->env->followup_to; - - if (!followup_to || m_strcasecmp(followup_to, "poster") || - query_quadoption (OPT_FOLLOWUPTOPOSTER, - _("Reply by mail as poster prefers?")) != M_YES) { - if (extra->ctx && extra->ctx->magic == M_NNTP - && !((nntp_data_t *) extra->ctx->data)->allowed - && query_quadoption (OPT_TOMODERATED, - _ - ("Posting to this group not allowed, may be moderated. Continue?")) - != M_YES) - break; - if (IsMsgAttach (extra)) - mutt_attach_reply (extra->fp, extra->hdr, extra->idx, - extra->idxlen, extra->bdy, SENDNEWS | SENDREPLY); - else - ci_send_message (SENDNEWS | SENDREPLY, NULL, NULL, - extra->ctx, extra->hdr); - redraw = REDRAW_FULL; - break; - } -#endif - case OP_REPLY: CHECK_MODE (IsHeader (extra) || IsMsgAttach (extra)); CHECK_ATTACH; diff --git a/pattern.c b/pattern.c index 7744e95..cd3ba3b 100644 --- a/pattern.c +++ b/pattern.c @@ -70,9 +70,6 @@ static struct pattern_flags { {'u', M_SUBSCRIBED_LIST, 0, NULL}, {'v', M_COLLAPSED, 0, NULL}, {'V', M_CRYPT_VERIFIED, 0, NULL}, -#ifdef USE_NNTP - {'w', M_NEWSGROUPS, 0, eat_regexp}, -#endif {'x', M_REFERENCE, 0, eat_regexp}, {'X', M_MIMEATTACH, 0, eat_range}, {'y', M_XLABEL, 0, eat_regexp}, @@ -1053,12 +1050,6 @@ mutt_pattern_exec (struct pattern_t *pat, pattern_exec_flag flags, && valid_realname(h->env-> from->personal) && h->env->from->mailbox) )) ^ pat->not; -#ifdef USE_NNTP - case M_NEWSGROUPS: - return (pat-> - not ^ (h->env->newsgroups - && patmatch (pat, h->env->newsgroups) == 0)); -#endif } mutt_error (_("error: unknown op %d (report this error)."), pat->op); return (-1); diff --git a/postpone.c b/postpone.c index 06b5929..44cbdb2 100644 --- a/postpone.c +++ b/postpone.c @@ -90,26 +90,15 @@ int mutt_num_postponed (int force) } if (LastModify < st.st_mtime) { -#ifdef USE_NNTP - int optnews = option (OPTNEWS); -#endif LastModify = st.st_mtime; if (access (Postponed, R_OK | F_OK) != 0) return (PostCount = 0); -#ifdef USE_NNTP - if (optnews) - unset_option (OPTNEWS); -#endif if (mx_open_mailbox (Postponed, M_NOSORT | M_QUIET, &ctx) == NULL) PostCount = 0; else PostCount = ctx.msgcount; mx_fastclose_mailbox (&ctx); -#ifdef USE_NNTP - if (optnews) - set_option (OPTNEWS); -#endif } return (PostCount); diff --git a/recvattach.c b/recvattach.c index 91d6434..ac2861d 100644 --- a/recvattach.c +++ b/recvattach.c @@ -965,15 +965,6 @@ void mutt_view_attachments (HEADER * hdr) break; } -#ifdef USE_NNTP - if (Context->magic == M_NNTP) { - mutt_flushinp (); - mutt_error _("Can't delete attachment from newsserver."); - - break; - } -#endif - if (hdr->security & (~PGP_TRADITIONAL_CHECKED)) { mutt_message _("Deletion of attachments from encrypted messages is unsupported."); @@ -1058,32 +1049,6 @@ void mutt_view_attachments (HEADER * hdr) menu->redraw = REDRAW_FULL; break; -#ifdef USE_NNTP - case OP_FORWARD_TO_GROUP: - CHECK_ATTACH; - mutt_attach_forward (fp, hdr, idx, idxlen, - menu->tagprefix ? NULL : idx[menu->current]-> - content, SENDNEWS); - menu->redraw = REDRAW_FULL; - break; - - case OP_FOLLOWUP: - CHECK_ATTACH; - - if (!idx[menu->current]->content->hdr->env->followup_to || - m_strcasecmp(idx[menu->current]->content->hdr->env->followup_to, - "poster") - || query_quadoption (OPT_FOLLOWUPTOPOSTER, - _("Reply by mail as poster prefers?")) != - M_YES) { - mutt_attach_reply (fp, hdr, idx, idxlen, - menu->tagprefix ? NULL : idx[menu->current]-> - content, SENDNEWS | SENDREPLY); - menu->redraw = REDRAW_FULL; - break; - } -#endif - case OP_REPLY: case OP_GROUP_REPLY: case OP_LIST_REPLY: diff --git a/recvcmd.c b/recvcmd.c index d9dd323..15858e2 100644 --- a/recvcmd.c +++ b/recvcmd.c @@ -709,37 +709,25 @@ attach_reply_envelope_defaults (ENVELOPE * env, ATTACHPTR ** idx, return -1; } -#ifdef USE_NNTP - if ((flags & SENDNEWS)) { - /* in case followup set Newsgroups: with Followup-To: if it present */ - if (!env->newsgroups && curenv && - m_strcasecmp(curenv->followup_to, "poster")) - env->newsgroups = m_strdup(curenv->followup_to); - } - else -#endif - { - if (parent) { - if (mutt_fetch_recips (env, curenv, flags) == -1) + if (parent) { + if (mutt_fetch_recips (env, curenv, flags) == -1) + return -1; + } else { + for (i = 0; i < idxlen; i++) { + if (idx[i]->content->tagged + && mutt_fetch_recips (env, idx[i]->content->hdr->env, + flags) == -1) return -1; } - else { - for (i = 0; i < idxlen; i++) { - if (idx[i]->content->tagged - && mutt_fetch_recips (env, idx[i]->content->hdr->env, - flags) == -1) - return -1; - } - } - - if ((flags & SENDLISTREPLY) && !env->to) { - mutt_error _("No mailing lists found!"); + } - return (-1); - } + if ((flags & SENDLISTREPLY) && !env->to) { + mutt_error _("No mailing lists found!"); - mutt_fix_reply_recipients (env); + return (-1); } + + mutt_fix_reply_recipients (env); mutt_make_misc_reply_headers (env, Context, curhdr, curenv); if (parent) @@ -797,13 +785,6 @@ void mutt_attach_reply (FILE * fp, HEADER * hdr, char prefix[STRING]; int rc; -#ifdef USE_NNTP - if (flags & SENDNEWS) - set_option (OPTNEWSSEND); - else - unset_option (OPTNEWSSEND); -#endif - if (check_all_msg (idx, idxlen, cur, 0) == -1) { nattach = count_tagged (idx, idxlen); if ((parent = find_parent (idx, idxlen, cur, nattach)) == NULL) diff --git a/send.c b/send.c index e44222a..05536b8 100644 --- a/send.c +++ b/send.c @@ -23,10 +23,6 @@ #include "mutt_idna.h" #include "attach.h" -#ifdef USE_NNTP -#include "nntp.h" -#endif - int url_parse_mailto(ENVELOPE *e, char **body, const char *src) { char *t; @@ -243,36 +239,12 @@ static int edit_envelope (ENVELOPE * en, int flags) string_list_t *uh = UserHeader; regmatch_t pat_match[1]; -#ifdef USE_NNTP - if (option (OPTNEWSSEND)) { - if (en->newsgroups) - m_strcpy(buf, sizeof(buf), en->newsgroups); - else - buf[0] = 0; - if (mutt_get_field ("Newsgroups: ", buf, sizeof (buf), 0) != 0) - return (-1); - p_delete(&en->newsgroups); - en->newsgroups = m_strdup(buf); - - if (en->followup_to) - m_strcpy(buf, sizeof(buf), en->followup_to); - else - buf[0] = 0; - if (option (OPTASKFOLLOWUP) - && mutt_get_field ("Followup-To: ", buf, sizeof (buf), 0) != 0) - return (-1); - p_delete(&en->followup_to); - en->followup_to = m_strdup(buf); - } else -#endif - { - if (edit_address (&en->to, "To: ") == -1 || en->to == NULL) - return (-1); - if (option (OPTASKCC) && edit_address (&en->cc, "Cc: ") == -1) - return (-1); - if (option (OPTASKBCC) && edit_address (&en->bcc, "Bcc: ") == -1) - return (-1); - } + if (edit_address (&en->to, "To: ") == -1 || en->to == NULL) + return (-1); + if (option (OPTASKCC) && edit_address (&en->cc, "Cc: ") == -1) + return (-1); + if (option (OPTASKBCC) && edit_address (&en->bcc, "Bcc: ") == -1) + return (-1); if (en->subject) { if (option (OPTFASTREPLY)) @@ -322,13 +294,6 @@ static int edit_envelope (ENVELOPE * en, int flags) return 0; } -#ifdef USE_NNTP -static char *nntp_get_header(const char *s) -{ - return m_strdup(skipspaces(s)); -} -#endif - static void process_user_recips (ENVELOPE * env) { string_list_t *uh = UserHeader; @@ -348,14 +313,6 @@ static void process_user_recips (ENVELOPE * env) case MIME_BCC: env->bcc = rfc822_parse_adrlist(env->bcc, p); break; -#ifdef USE_NNTP - case MIME_NEWSGROUPS: - env->newsgroups = nntp_get_header(p); - break; - case MIME_FOLLOWUP_TO: - env->followup_to = nntp_get_header(p); - break; -#endif default: break; } } @@ -390,10 +347,6 @@ static void process_user_header(ENVELOPE * env) case MIME_TO: case MIME_CC: case MIME_BCC: -#ifdef USE_NNTP - case MIME_NEWSGROUPS: - case MIME_FOLLOWUP_TO: -#endif case MIME_SUPERSEDES: case MIME_SUPERCEDES: case MIME_SUBJECT: @@ -747,15 +700,6 @@ envelope_defaults (ENVELOPE * env, CONTEXT * ctx, HEADER * cur, int flags) curenv = cur->env; if (flags & SENDREPLY) { -#ifdef USE_NNTP - if ((flags & SENDNEWS)) { - /* in case followup set Newsgroups: with Followup-To: if it present */ - if (!env->newsgroups && curenv && - m_strcasecmp(curenv->followup_to, "poster")) - env->newsgroups = m_strdup(curenv->followup_to); - } - else -#endif if (tag) { HEADER *h; @@ -878,14 +822,6 @@ void mutt_set_followup_to (ENVELOPE * e) if (!option(OPTFOLLOWUPTO)) return; -#ifdef USE_NNTP - if (option(OPTNEWSSEND)) { - if (!e->followup_to && e->newsgroups && strrchr(e->newsgroups, ',')) - e->followup_to = m_strdup(e->newsgroups); - return; - } -#endif - if (e->mail_followup_to) return; @@ -1088,13 +1024,6 @@ int ci_send_message (int flags, /* send mode */ int rv = -1; -#ifdef USE_NNTP - if (flags & SENDNEWS) - set_option (OPTNEWSSEND); - else - unset_option (OPTNEWSSEND); -#endif - if (!flags && !msg && quadoption (OPT_RECALL) != M_NO && mutt_num_postponed (1)) { /* If the user is composing a new message, check to see if there @@ -1124,20 +1053,6 @@ int ci_send_message (int flags, /* send mode */ if ((flags = mutt_get_postponed (ctx, msg, &cur, fcc, sizeof (fcc))) < 0) goto cleanup; -#ifdef USE_NNTP - /* - * If postponed message is a news article, it have - * a "Newsgroups:" header line, then set appropriate flag. - */ - if (msg->env->newsgroups) { - flags |= SENDNEWS; - set_option (OPTNEWSSEND); - } - else { - flags &= ~SENDNEWS; - unset_option (OPTNEWSSEND); - } -#endif } if (flags & (SENDPOSTPONED | SENDRESEND)) { @@ -1232,12 +1147,6 @@ int ci_send_message (int flags, /* send mode */ /* Expand aliases and remove duplicates/crossrefs */ mutt_fix_reply_recipients (msg->env); -#ifdef USE_NNTP - if ((flags & SENDNEWS) && ctx && ctx->magic == M_NNTP - && !msg->env->newsgroups) - msg->env->newsgroups = m_strdup(((nntp_data_t *)ctx->data)->group); -#endif - if (!(option (OPTAUTOEDIT) && option (OPTEDITHDRS)) && !((flags & SENDREPLY) && option (OPTFASTREPLY))) { if (edit_envelope (msg->env, flags) == -1) @@ -1450,13 +1359,7 @@ int ci_send_message (int flags, /* send mode */ i = mutt_compose_menu (msg, fcc, sizeof (fcc), cur); if (i == -1) { /* abort */ -#ifdef USE_NNTP - if (flags & SENDNEWS) - mutt_message (_("Article not posted.")); - - else -#endif - mutt_message _("Mail not sent."); + mutt_message _("Mail not sent."); goto cleanup; } else if (i == 1) { @@ -1492,21 +1395,18 @@ int ci_send_message (int flags, /* send mode */ } } -#ifdef USE_NNTP - if (!(flags & SENDNEWS)) -#endif - if (!msg->env->to && !msg->env->cc && !msg->env->bcc) { - if (!(flags & SENDBATCH)) { - mutt_error _("No recipients are specified!"); + if (!msg->env->to && !msg->env->cc && !msg->env->bcc) { + if (!(flags & SENDBATCH)) { + mutt_error _("No recipients are specified!"); - goto main_loop; - } - else { - puts _("No recipients were specified."); + goto main_loop; + } + else { + puts _("No recipients were specified."); - goto cleanup; - } + goto cleanup; } + } if (mutt_env_to_idna (msg->env, &tag, &err)) { mutt_error (_("Bad IDN in \"%s\": '%s'"), tag, err); @@ -1527,19 +1427,6 @@ int ci_send_message (int flags, /* send mode */ goto main_loop; } -#ifdef USE_NNTP - if ((flags & SENDNEWS) && !msg->env->subject) { - mutt_error _("No subject specified."); - - goto main_loop; - } - - if ((flags & SENDNEWS) && !msg->env->newsgroups) { - mutt_error _("No newsgroup specified."); - - goto main_loop; - } -#endif if (msg->content->next) msg->content = mutt_make_multipart (msg->content); @@ -1735,14 +1622,7 @@ int ci_send_message (int flags, /* send mode */ } } else if (!option (OPTNOCURSES)) - mutt_message (i != 0 ? _("Sending in background.") : -#ifdef USE_NNTP - (flags & SENDNEWS) ? _("Article posted.") : - _("Mail sent.") -#else - _("Mail sent.") -#endif - ); + mutt_message (i != 0 ? _("Sending in background.") : _("Mail sent.")); if (msg->security & ENCRYPT) p_delete(&pgpkeylist); diff --git a/sendlib.c b/sendlib.c index 9881bbe..91318ed 100644 --- a/sendlib.c +++ b/sendlib.c @@ -28,10 +28,6 @@ #include "charset.h" #include "mutt_idna.h" -#ifdef USE_NNTP -#include "nntp.h" -#endif - #ifdef HAVE_SYSEXITS_H #include #else /* Make sure EX_OK is defined */ @@ -1347,11 +1343,8 @@ int mutt_write_rfc822_header (FILE * fp, ENVELOPE * env, BODY * attach, string_list_t *tmp = env->userhdrs; int has_agent = 0; /* user defined user-agent header field exists */ -#ifdef USE_NNTP - if (!option (OPTNEWSSEND)) -#endif - if (mode == 0) - fputs (mutt_make_date (buffer, sizeof (buffer)), fp); + if (mode == 0) + fputs (mutt_make_date (buffer, sizeof (buffer)), fp); /* OPTUSEFROM is not consulted here so that we can still write a From: * field if the user sets it with the `my_hdr' command @@ -1367,22 +1360,16 @@ int mutt_write_rfc822_header (FILE * fp, ENVELOPE * env, BODY * attach, mutt_write_address_list (env->to, fp, 4, 0); } else if (mode > 0) -#ifdef USE_NNTP - if (!option (OPTNEWSSEND)) -#endif - if (edit_header(mode, "To:")) - fputs ("To:\n", fp); + if (edit_header(mode, "To:")) + fputs ("To:\n", fp); if (env->cc) { fputs ("Cc: ", fp); mutt_write_address_list (env->cc, fp, 4, 0); } else if (mode > 0) -#ifdef USE_NNTP - if (!option (OPTNEWSSEND)) -#endif - if (edit_header(mode, "Cc:")) - fputs ("Cc:\n", fp); + if (edit_header(mode, "Cc:")) + fputs ("Cc:\n", fp); if (env->bcc) { if (mode != 0 || option (OPTWRITEBCC)) { @@ -1391,23 +1378,8 @@ int mutt_write_rfc822_header (FILE * fp, ENVELOPE * env, BODY * attach, } } else if (mode > 0) -#ifdef USE_NNTP - if (!option (OPTNEWSSEND)) -#endif - if (edit_header(mode, "Bcc:")) - fputs ("Bcc:\n", fp); - -#ifdef USE_NNTP - if (env->newsgroups) - fprintf (fp, "Newsgroups: %s\n", env->newsgroups); - else if (mode == 1 && option (OPTNEWSSEND) && edit_header(mode, "Newsgroups:")) - fputs ("Newsgroups:\n", fp); - - if (env->followup_to) - fprintf (fp, "Followup-To: %s\n", env->followup_to); - else if (mode == 1 && option (OPTNEWSSEND) && edit_header(mode, "Followup-To:")) - fputs ("Followup-To:\n", fp); -#endif + if (edit_header(mode, "Bcc:")) + fputs ("Bcc:\n", fp); if (env->subject) fprintf (fp, "Subject: %s\n", env->subject); @@ -1425,14 +1397,10 @@ int mutt_write_rfc822_header (FILE * fp, ENVELOPE * env, BODY * attach, else if (mode > 0 && edit_header(mode, "Reply-To:")) fputs ("Reply-To:\n", fp); - if (env->mail_followup_to) -#ifdef USE_NNTP - if (!option (OPTNEWSSEND)) -#endif - { - fputs ("Mail-Followup-To: ", fp); - mutt_write_address_list (env->mail_followup_to, fp, 18, 0); - } + if (env->mail_followup_to) { + fputs ("Mail-Followup-To: ", fp); + mutt_write_address_list (env->mail_followup_to, fp, 18, 0); + } if (mode <= 0) { if (env->references) { @@ -1805,16 +1773,7 @@ int mutt_invoke_mta(address_t *from, address_t *to, address_t *cc, ssize_t argslen = 0, argsmax = 0; int i; -#ifdef USE_NNTP - if (option (OPTNEWSSEND)) { - i = nntp_post(msg); - unlink(msg); - return i; - } else -#endif - { - m_strcpy(cmd, sizeof(cmd), MTransport.sendmail); - } + m_strcpy(cmd, sizeof(cmd), MTransport.sendmail); ps = cmd; i = 0; @@ -1837,36 +1796,30 @@ int mutt_invoke_mta(address_t *from, address_t *to, address_t *cc, i++; } -#ifdef USE_NNTP - if (!option (OPTNEWSSEND)) { -#endif - if (eightbit && MTransport.use_8bitmime) - args = add_option(args, &argslen, &argsmax, "-B8BITMIME"); - - if (MTransport.use_envelope_from) { - address_t *f = MTransport.envelope_from_address; - if (!f && from && !from->next) - f = from; - if (f) { - args = add_option (args, &argslen, &argsmax, "-f"); - args = add_args (args, &argslen, &argsmax, f); - } - } - if (MTransport.dsn_notify) { - args = add_option (args, &argslen, &argsmax, "-N"); - args = add_option (args, &argslen, &argsmax, MTransport.dsn_notify); - } - if (MTransport.dsn_return) { - args = add_option (args, &argslen, &argsmax, "-R"); - args = add_option (args, &argslen, &argsmax, MTransport.dsn_return); + if (eightbit && MTransport.use_8bitmime) + args = add_option(args, &argslen, &argsmax, "-B8BITMIME"); + + if (MTransport.use_envelope_from) { + address_t *f = MTransport.envelope_from_address; + if (!f && from && !from->next) + f = from; + if (f) { + args = add_option (args, &argslen, &argsmax, "-f"); + args = add_args (args, &argslen, &argsmax, f); } - args = add_option (args, &argslen, &argsmax, "--"); - args = add_args (args, &argslen, &argsmax, to); - args = add_args (args, &argslen, &argsmax, cc); - args = add_args (args, &argslen, &argsmax, bcc); -#ifdef USE_NNTP } -#endif + if (MTransport.dsn_notify) { + args = add_option (args, &argslen, &argsmax, "-N"); + args = add_option (args, &argslen, &argsmax, MTransport.dsn_notify); + } + if (MTransport.dsn_return) { + args = add_option (args, &argslen, &argsmax, "-R"); + args = add_option (args, &argslen, &argsmax, MTransport.dsn_return); + } + args = add_option (args, &argslen, &argsmax, "--"); + args = add_args (args, &argslen, &argsmax, to); + args = add_args (args, &argslen, &argsmax, cc); + args = add_args (args, &argslen, &argsmax, bcc); if (argslen >= argsmax) p_realloc(&args, ++argsmax); @@ -2025,15 +1978,8 @@ int mutt_bounce_message (FILE * fp, HEADER * h, address_t * to) return -1; } rfc822_addrcat(resent_from, sizeof(resent_from), from, 0); - -#ifdef USE_NNTP - unset_option (OPTNEWSSEND); -#endif - ret = _mutt_bounce_message (fp, h, to, resent_from, from); - address_list_wipe(&from); - return ret; } diff --git a/sort.c b/sort.c index 3e1e92c..d97535f 100644 --- a/sort.c +++ b/sort.c @@ -153,18 +153,8 @@ static int compare_order (const void *a, const void *b) { HEADER **ha = (HEADER **) a; HEADER **hb = (HEADER **) b; - -#ifdef USE_NNTP - if ((*ha)->article_num && (*hb)->article_num) { - int result = (*ha)->article_num - (*hb)->article_num; - - AUXSORT (result, a, b); - return (SORTCODE (result)); - } - else -#endif - /* no need to auxsort because you will never have equality here */ - return (SORTCODE ((*ha)->index - (*hb)->index)); + /* no need to auxsort because you will never have equality here */ + return (SORTCODE ((*ha)->index - (*hb)->index)); } static int compare_spam (const void *a, const void *b) -- 2.20.1