Commit 5ba906d2 authored by Thomas Roessler's avatar Thomas Roessler

Brandon's IMAP clean-up; new czech translation.

parent e4f9683b
......@@ -6,6 +6,9 @@ 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 mailbox (IMAP Only)"
OP_BROWSER_UNSUBSCRIBE "unsubscribe to current mailbox (IMAP Only)"
OP_BROWSER_TOGGLE_LSUB "toggle view all/subscribed mailboxes (IMAP Only)"
OP_CHANGE_DIRECTORY "change directories"
OP_CHECK_NEW "check mailboxes for new mail"
OP_COMPOSE_ATTACH_FILE "attach a file(s) to this message"
......@@ -143,7 +146,7 @@ OP_TAG_SUBTHREAD "tag the current subthread"
OP_TAG_THREAD "tag the current thread"
OP_TOGGLE_NEW "toggle a message's 'new' flag"
OP_TOGGLE_WRITE "toggle whether the mailbox will be rewritten"
OP_TOGGLE_MAILBOXES "toggle wether to browse mailboxes or all files"
OP_TOGGLE_MAILBOXES "toggle whether to browse mailboxes or all files"
OP_TOP_PAGE "move to the top of the page"
OP_UNDELETE "undelete the current entry"
OP_UNDELETE_THREAD "undelete all messages in thread"
......
......@@ -23,6 +23,10 @@
#include "mapping.h"
#include "sort.h"
#include "mailbox.h"
#include "browser.h"
#ifdef USE_IMAP
#include "imap.h"
#endif
#include <stdlib.h>
#include <dirent.h>
......@@ -33,23 +37,6 @@
#include <pwd.h>
#include <grp.h>
struct folder_file
{
mode_t mode;
time_t mtime;
off_t size;
char *name;
char *desc;
short tagged;
};
struct browser_state
{
struct folder_file *entry;
short entrylen; /* number of real entries */
short entrymax; /* max entry */
};
static struct mapping_t FolderHelp[] = {
{ N_("Exit"), OP_EXIT },
{ N_("Chdir"), OP_CHANGE_DIRECTORY },
......@@ -456,6 +443,12 @@ static void init_menu (struct browser_state *state, MUTTMENU *menu, char *title,
{
strfcpy (path, LastDir, sizeof (path));
mutt_pretty_mailbox (path);
#ifdef USE_IMAP
if (state->imap_browse && option (OPTIMAPLSUB))
snprintf (title, titlelen, _("Subscribed [%s], File mask: %s"),
path, Mask.pattern);
else
#endif
snprintf (title, titlelen, _("Directory [%s], File mask: %s"),
path, Mask.pattern);
}
......@@ -491,6 +484,17 @@ void _mutt_select_file (char *f, size_t flen, int buffy,
if (*f)
{
mutt_expand_path (f, flen);
#ifdef USE_IMAP
if (mx_is_imap (f))
{
init_state (&state, NULL);
state.imap_browse = 1;
imap_init_browse (f, &state);
strfcpy (LastDir, f, sizeof (LastDir));
}
else
{
#endif
for (i = mutt_strlen (f) - 1; i > 0 && f[i] != '/' ; i--);
if (i > 0)
{
......@@ -520,9 +524,23 @@ void _mutt_select_file (char *f, size_t flen, int buffy,
else
strfcpy (prefix, f + i + 1, sizeof (prefix));
killPrefix = 1;
#ifdef USE_IMAP
}
#endif
}
else
{
if (!LastDir[0])
strfcpy (LastDir, NONULL(Maildir), sizeof (LastDir));
#ifdef USE_IMAP
if (!buffy && mx_is_imap (LastDir))
{
init_state (&state, NULL);
state.imap_browse = 1;
imap_init_browse (LastDir, &state);
}
#endif
}
else if (!LastDir[0])
strfcpy (LastDir, NONULL(Maildir), sizeof (LastDir));
*f = 0;
......@@ -531,7 +549,11 @@ void _mutt_select_file (char *f, size_t flen, int buffy,
if (examine_mailboxes (NULL, &state) == -1)
return;
}
else if (examine_directory (NULL, &state, LastDir, prefix) == -1)
else
#ifdef USE_IMAP
if (!state.imap_browse)
#endif
if (examine_directory (NULL, &state, LastDir, prefix) == -1)
return;
menu = mutt_new_menu ();
......@@ -561,7 +583,11 @@ void _mutt_select_file (char *f, size_t flen, int buffy,
if (S_ISDIR (state.entry[menu->current].mode) ||
(S_ISLNK (state.entry[menu->current].mode) &&
link_is_dir (state.entry[menu->current].name)))
link_is_dir (state.entry[menu->current].name))
#ifdef USE_IMAP
|| state.entry[menu->current].notfolder
#endif
)
{
/* make sure this isn't a MH or maildir mailbox */
if (buffy)
......@@ -569,11 +595,21 @@ void _mutt_select_file (char *f, size_t flen, int buffy,
strfcpy (buf, state.entry[menu->current].name, sizeof (buf));
mutt_expand_path (buf, sizeof (buf));
}
#ifdef USE_IMAP
else if (state.imap_browse)
{
strfcpy (buf, state.entry[menu->current].name, sizeof (buf));
}
#endif
else
snprintf (buf, sizeof (buf), "%s/%s", LastDir,
state.entry[menu->current].name);
if (mx_get_magic (buf) <= 0)
if ((mx_get_magic (buf) <= 0)
#ifdef USE_IMAP
|| state.entry[menu->current].notfolder
#endif
)
{
char OldLastDir[_POSIX_PATH_MAX];
......@@ -604,6 +640,13 @@ void _mutt_select_file (char *f, size_t flen, int buffy,
sprintf (LastDir, "%s", state.entry[menu->current].name);
mutt_expand_path (LastDir, sizeof (LastDir));
}
#ifdef USE_IMAP
else if (state.imap_browse)
{
strfcpy (LastDir, state.entry[menu->current].name,
sizeof (LastDir));
}
#endif
else
sprintf (LastDir + mutt_strlen (LastDir), "/%s",
state.entry[menu->current].name);
......@@ -615,6 +658,16 @@ void _mutt_select_file (char *f, size_t flen, int buffy,
killPrefix = 0;
}
buffy = 0;
#ifdef USE_IMAP
if (state.imap_browse)
{
init_state (&state, NULL);
state.imap_browse = 1;
imap_init_browse (LastDir, &state);
menu->data = state.entry;
}
else
#endif
if (examine_directory (menu, &state, LastDir, prefix) == -1)
{
/* try to restore the old values */
......@@ -637,6 +690,12 @@ void _mutt_select_file (char *f, size_t flen, int buffy,
strfcpy (f, state.entry[menu->current].name, flen);
mutt_expand_path (f, flen);
}
#ifdef USE_IMAP
else if (state.imap_browse)
{
strfcpy (f, state.entry[menu->current].name, flen);
}
#endif
else
snprintf (f, flen, "%s/%s", LastDir, state.entry[menu->current].name);
......@@ -684,10 +743,35 @@ void _mutt_select_file (char *f, size_t flen, int buffy,
if(state.entrylen)
mutt_message(state.entry[menu->current].name);
break;
#ifdef USE_IMAP
case OP_BROWSER_SUBSCRIBE:
imap_subscribe (state.entry[menu->current].name, 1);
break;
case OP_BROWSER_UNSUBSCRIBE:
imap_subscribe (state.entry[menu->current].name, 0);
break;
case OP_BROWSER_TOGGLE_LSUB:
if (option (OPTIMAPLSUB))
{
unset_option (OPTIMAPLSUB);
}
else
{
set_option (OPTIMAPLSUB);
}
mutt_ungetch (0, OP_CHECK_NEW);
break;
#endif
case OP_CHANGE_DIRECTORY:
strfcpy (buf, LastDir, sizeof (buf));
#ifdef USE_IMAP
if (!state.imap_browse)
#endif
{/* add '/' at the end of the directory name */
int len=mutt_strlen(LastDir);
if (sizeof (buf) > len)
......@@ -699,6 +783,21 @@ void _mutt_select_file (char *f, size_t flen, int buffy,
{
buffy = 0;
mutt_expand_path (buf, sizeof (buf));
#ifdef USE_IMAP
if (mx_is_imap (buf))
{
strfcpy (LastDir, buf, sizeof (LastDir));
destroy_state (&state);
init_state (&state, NULL);
state.imap_browse = 1;
imap_init_browse (LastDir, &state);
menu->data = state.entry;
menu->current = 0;
menu->top = 0;
init_menu (&state, menu, title, sizeof (title), buffy);
}
else
#endif
if (stat (buf, &st) == 0)
{
if (S_ISDIR (st.st_mode))
......@@ -834,11 +933,21 @@ void _mutt_select_file (char *f, size_t flen, int buffy,
destroy_state (&state);
prefix[0] = 0;
killPrefix = 0;
if (buffy)
{
if (examine_mailboxes (menu, &state) == -1)
return;
}
#ifdef USE_IMAP
else if (mx_is_imap (LastDir))
{
init_state (&state, NULL);
state.imap_browse = 1;
imap_init_browse (LastDir, &state);
menu->data = state.entry;
}
#endif
else if (examine_directory (menu, &state, LastDir, prefix) == -1)
return;
init_menu (&state, menu, title, sizeof (title), buffy);
......
/* $Id$ */
/*
* Copyright (C) 1996-8 Michael R. Elkins <me@cs.hmc.edu>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef _BROWSER_H
#define _BROWSER_H 1
struct folder_file
{
mode_t mode;
time_t mtime;
off_t size;
char *name;
char *desc;
#ifdef USE_IMAP
short notfolder;
#endif
};
struct browser_state
{
struct folder_file *entry;
short entrylen; /* number of real entries */
short entrymax; /* max entry */
#ifdef USE_IMAP
short imap_browse;
int noselect : 1;
int marked : 1;
int unmarked : 1;
#endif
};
#endif /* _BROWSER_H */
......@@ -32,7 +32,7 @@
int mutt_complete (char *s)
{
char *p;
DIR *dirp;
DIR *dirp = NULL;
struct dirent *de;
int i ,init=0;
size_t len;
......@@ -85,12 +85,23 @@ int mutt_complete (char *s)
/* no directory name, so assume current directory. */
dirpart[0] = 0;
strfcpy (filepart, s, sizeof (filepart));
dirp = opendir (".");
#ifdef USE_IMAP
if (s[0] != '{')
#endif
dirp = opendir (".");
}
}
if (dirp == NULL)
{
#ifdef USE_IMAP
/* If we are trying to complete an IMAP folder, it will start with {
* in which case, we just return 0 at this point. Eventually, we
* might complete the actually folder name from the server
*/
if ((s[0] == '{') || (exp_dirpart[0] == '{'))
return 0;
#endif
dprint (1, (debugfile, "mutt_complete(): %s: %s (errno %d).\n", exp_dirpart, strerror (errno), errno));
return (-1);
}
......
......@@ -1811,7 +1811,7 @@ url="http://www.ccil.org/~esr/fetchmail" name="fetchmail">
If Mutt was compiled with IMAP support (by running the <em/configure/
script with the <em/--enable-imap/ flag), it has the ability to work
with folders located on a remote imap server.
with folders located on a remote IMAP server.
You can access the remote inbox by selecting the folder
<tt/{imapserver}inbox/, where <tt/imapserver/ is the name of the IMAP
......@@ -1821,8 +1821,30 @@ server, you should use <tt>{imapserver}path/to/folder</tt> where
<tt>path/to/folder</tt> is the path of the folder you want to access
relative to your home directory.
<bf/Note:/ The IMAP support is in a very early state and quite
unstable at the moment. If you need a more stable way to access your
You can select an alternative port by specifying it with the server, ie:
<tt/{imapserver:port}inbox/.
Note that not all servers use / as the hierarchy separator. Mutt should
correctly notice which separator is being used by the server and convert
paths accordingly.
When browsing folders on an IMAP server, you can toggle whether to look
at only the folders you are subscribed to, or all folders with the
<em/toggle-subscribed/ command. See also the
<ref id="imap&lowbar;list&lowbar;subscribed" name="&dollar;imap&lowbar;list&lowbar;subscribed"> variable.
Mutt was designed to work with IMAP4rev1 servers, and has been tested
with both the UWash IMAP server v11.241 and the Cyrus IMAP server v1.5.14.
Note that if you are using mbox as the mail store on the UWash server,
the server will disconnect a client if another client selects the same
folder.
Mutt currently does not support completion of IMAP folder names. Hit
the <em/complete/ key again to go to the IMAP browser.
<bf/Note:/ The IMAP support has had very limited testing due to a lack
of developers using it. It should work with the reference servers
mentioned above, but if you need a more stable way to access your
IMAP folder, consider using a specialized program, such as <htmlurl
url="http://www.ccil.org/~esr/fetchmail" name="fetchmail">.
......@@ -2953,6 +2975,15 @@ Default: 0
This variable configures how often (in seconds) IMAP should look for
new mail.
<sect2>imap&lowbar;list&lowbar;subscribed<label id="imap_list_subscribed">
<p>
Type: boolean<newline>
Default: unset
This variable configures whether IMAP folder browsing will look for only
subscribed folders or all folders. This can be toggled in the IMAP
browser with the <em/toggle-subscribed/ command.
<sect2>imap&lowbar;pass<label id="imap_pass">
<p>
Type: string<newline>
......@@ -2964,6 +2995,16 @@ you should only use this option when you are on a fairly secure machine,
because the superuser can read your muttrc even if you are the only one who
can read the file.
<sect2>imap&lowbar;passive<label id="imap_passive">
<p>
Type: boolean<newline>
Default: set
When set, mutt will not open new IMAP connections to check for new mail.
Mutt will only check for new mail over existing IMAP connections. This
is useful if you don't want to be prompted to user/password pairs on
mutt invocation, or if opening the connection is slow.
<sect2>imap&lowbar;user<label id="imap_user">
<p>
Type: string<newline>
......@@ -4604,6 +4645,11 @@ search-reverse ESC / search backwards for a regular expression
select-new N select a new file in this directory
sort o sort messages
sort-reverse O sort messages in reverse order
toggle-mailboxes TAB toggle whether to browse mailboxes or all files
view-file SPACE view file
subscribe s subscribe to current mailbox (IMAP Only)
unsubscribe u unsubscribe to current mailbox (IMAP Only)
toggle-subscribed T toggle view all/subscribed mailboxes (IMAP Only)
</verb>
<sect2>pgp
<p>
......
......@@ -323,6 +323,11 @@ struct binding_t OpBrowser[] = {
{ "check-new", OP_CHECK_NEW, NULL },
{ "toggle-mailboxes", OP_TOGGLE_MAILBOXES, "\t" },
{ "view-file", OP_BROWSER_VIEW_FILE, " " },
#ifdef USE_IMAP
{ "subscribe", OP_BROWSER_SUBSCRIBE, "s" },
{ "unsubscribe", OP_BROWSER_UNSUBSCRIBE, "u" },
{ "toggle-subscribed", OP_BROWSER_TOGGLE_LSUB, "T" },
#endif
{ NULL, 0, NULL }
};
......
This diff is collapsed.
......@@ -17,15 +17,19 @@
*/
#ifndef _IMAP_H
#define _IMAP_H
#define _IMAP_H 1
extern int imap_append_message (CONTEXT *ctx, MESSAGE *msg);
extern int imap_check_mailbox (CONTEXT *ctx, int *index_hint);
extern int imap_fetch_message (MESSAGE *msg, CONTEXT *ctx, int msgno);
extern int imap_open_mailbox (CONTEXT *ctx);
extern int imap_open_mailbox_append (CONTEXT *ctx);
extern int imap_sync_mailbox (CONTEXT *ctx);
extern void imap_fastclose_mailbox (CONTEXT *ctx);
extern int imap_buffy_check (char *path);
#include "browser.h"
int imap_append_message (CONTEXT *ctx, MESSAGE *msg);
int imap_check_mailbox (CONTEXT *ctx, int *index_hint);
int imap_fetch_message (MESSAGE *msg, CONTEXT *ctx, int msgno);
int imap_open_mailbox (CONTEXT *ctx);
int imap_open_mailbox_append (CONTEXT *ctx);
int imap_sync_mailbox (CONTEXT *ctx);
void imap_fastclose_mailbox (CONTEXT *ctx);
int imap_buffy_check (char *path);
int imap_subscribe (char *path, int subscribe);
int imap_init_browse (char *path, struct browser_state *state);
#endif
......@@ -123,9 +123,11 @@ struct option_t MuttVars[] = {
{ "history", DT_NUM, R_NONE, UL &HistSize, 10 },
{ "hostname", DT_STR, R_NONE, UL &Fqdn, 0 },
#ifdef USE_IMAP
{ "imap_checkinterval", DT_NUM, R_NONE, UL &ImapCheckTime, 0 },
{ "imap_list_subscribed", DT_BOOL, R_NONE, OPTIMAPLSUB, 0 },
{ "imap_user", DT_STR, R_NONE, UL &ImapUser, UL 0 },
{ "imap_pass", DT_STR, R_NONE, UL &ImapPass, UL 0 },
{ "imap_checkinterval", DT_NUM, R_NONE, UL &ImapCheckTime, 0 },
{ "imap_passive", DT_BOOL, R_NONE, OPTIMAPPASSIVE, 1 },
#endif
{ "implicit_autoview", DT_BOOL,R_NONE, OPTIMPLICITAUTOVIEW, 0},
{ "in_reply_to", DT_STR, R_NONE, UL &InReplyTo, UL "%i; from %n on %{!%a, %b %d, %Y at %I:%M:%S%p %Z}" },
......
......@@ -102,8 +102,15 @@ void menu_redraw_full (MUTTMENU *menu)
{
SETCOLOR (MT_COLOR_NORMAL);
/* clear() doesn't optimize screen redraws */
#if 0
move (0, 0);
clrtobot ();
#else
/* my ncurses library seems to run into
* endless loops in clrtobot...
*/
clear();
#endif
if (option (OPTHELP))
{
......
......@@ -303,6 +303,10 @@ enum
OPTHELP,
OPTHIDDENHOST,
OPTIGNORELISTREPLYTO,
#ifdef USE_IMAP
OPTIMAPLSUB,
OPTIMAPPASSIVE,
#endif
OPTIMPLICITAUTOVIEW,
OPTMARKERS,
OPTMARKOLD,
......
......@@ -37,5 +37,7 @@ int mutt_socket_read_line (char *buf, size_t buflen, CONNECTION *conn);
int mutt_socket_read_line_d (char *buf, size_t buflen, CONNECTION *conn);
int mutt_socket_write (CONNECTION *conn, const char *buf);
CONNECTION *mutt_socket_select_connection (char *host, int port, int flags);
int mutt_socket_open_connection (CONNECTION *conn);
#endif /* _MUTT_SOCKET_H_ */
......@@ -786,6 +786,10 @@ int mx_close_mailbox (CONTEXT *ctx)
return (-1);
}
#ifdef USE_IMAP
/* IMAP doesn't support an OLD flag */
if (ctx->magic != M_IMAP)
#endif
if (option (OPTMARKOLD))
{
for (i = 0; i < ctx->msgcount; i++)
......
......@@ -164,11 +164,11 @@ msgstr "Souborov
#: browser.c:745
msgid "Reverse sort by (d)ate, (a)lpha, si(z)e or do(n)'t sort? "
msgstr "Obrcen azen dle (d)ata, psmen(a), ro(z)mru nebo (n)eadit?"
msgstr "Obrcen azen dle (d)ata, (p)smena, (v)elikosti i (n)eadit?"
#: browser.c:746
msgid "Sort by (d)ate, (a)lpha, si(z)e or do(n)'t sort? "
msgstr "adit dle (d)ata, (p)smena, (v)elikosti nebo (n)eadit?"
msgstr "adit dle (d)ata, (p)smena, (v)elikosti i (n)eadit?"
#: browser.c:747
msgid "dazn"
......@@ -306,13 +306,13 @@ msgid ""
"Rev-Sort (d)ate/(f)rm/(r)ecv/(s)ubj/t(o)/(t)hread/(u)nsort/si(z)e/s(c)ore?: "
msgstr ""
"adit opan "
"(d)at/(o)d/p(j)/(v)c/(p)ro/v(l)kno/(n)ese/veli(k)/s(k)re?: "
"(d)at/(o)d/p(j)/(v)c/(p)ro/v(l)kno/(n)ese/veli(k)/(s)kre?: "
#: commands.c:402
msgid ""
"Sort (d)ate/(f)rm/(r)ecv/(s)ubj/t(o)/(t)hread/(u)nsort/si(z)e/s(c)ore?: "
msgstr ""
"adit (d)at/(o)d/p(j)/(v)c/(p)ro/v(l)kno/(n)ese/veli(k)/s(k)re?: "
"adit (d)at/(o)d/p(j)/(v)c/(p)ro/v(l)kno/(n)ese/veli(k)/(s)kre?: "
#: commands.c:403
msgid "dfrsotuzc"
......@@ -353,7 +353,7 @@ msgstr "Kop
#: commands.c:575
msgid " tagged"
msgstr " oznaeno"
msgstr " oznaen"
#: commands.c:644
#, c-format
......@@ -386,7 +386,7 @@ msgstr "Zru
#: compose.c:82 compose.c:539
msgid "Attach file"
msgstr "Pipojit soubor"
msgstr "Piloit soubor"
#: compose.c:83
msgid "Descrip"
......@@ -848,7 +848,7 @@ msgstr "[-- P
#: handler.c:1082
#, c-format
msgid "[-- Type: %s/%s, Encoding: %s, Size: %s --]\n"
msgstr "[-- Typ: %s%s, Kdovn: %s, Velikost: %s --]\n"
msgstr "[-- Typ: %s/%s, Kdovn: %s, Velikost: %s --]\n"
#: handler.c:1141
#, c-format
......@@ -1891,7 +1891,7 @@ msgid "To contact the developers, please mail to <mutt-dev@mutt.org>.\n"
msgstr ""
"Vvoje programu mete kontaktovat na adrese <mutt-dev@mutt.org> "
"(anglicky).\n"
"Pipomnky k pekladu zaslejte na adresu <cs@li.org> (wsky).\n"
"Pipomnky k pekladu zaslejte na adresu <cs@li.org> (esky).\n"
#: main.c:43
msgid ""
......@@ -1973,6 +1973,19 @@ msgid ""
" You should have received a copy of the full distribution terms\n"
" along with this program; if not, write to the program's developers.\n"
msgstr ""
"\n"
"Implementace SHA1 Copyright (C) 1995-7 Eric A. Young <eay@cryptsoft.com>\n"
"\n"
" en a uvn ve zdrojov i binrn form (a ji s pravami i bez\n"
" nich) je pi dodren jistch podmnek povoleno.\n"
"\n"
" Na implementaci SHA1 NEN poskytovna JAKKOLI ZRUKA; neposkytuj se\n"
" ani odvozen zruky PRODEJNOSTI anebo VHODNOSTI PRO NJAK KONKRTN\n"
" EL.\n"
"\n"
" Kopie podmnek en mla bt dodna spolu s tmto programem; pokud se\n"
" tak nestalo, napite o ni vvojm programu.\n"
#: main.c:100
msgid ""
......@@ -2760,7 +2773,7 @@ msgstr "Chyba p
#: pop.c:306
#, c-format
msgid "%s [%d messages read]"
msgstr "%s [poet petench zprv - %d]"
msgstr "%s [poet petench zprv: %d]"
#: postpone.c:112
msgid "Postponed Messages"
......@@ -2856,7 +2869,7 @@ msgstr "Vytisknout p
#: recvattach.c:654
msgid "You may only bounce message/rfc822 parts."
msgstr "Peposlat lze pouze zprvu nebo jej sti vyhovujc rfc 822."
msgstr "Peposlat lze pouze sti typu 'message/rfc822'."
#: recvattach.c:690
#, c-format
......
......@@ -26,6 +26,7 @@
#include <stdlib.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <string.h>
/* support for multiple socket connections */
......@@ -105,3 +106,34 @@ CONNECTION *mutt_socket_select_connection (char *host, int port, int flags)
return conn;
}
int mutt_socket_open_connection (CONNECTION *conn)
{
struct sockaddr_in sin;
struct hostent *he;
memset (&sin, 0, sizeof (sin));
sin.sin_port = htons (conn->port);
sin.sin_family = AF_INET;
if ((he = gethostbyname (conn->server)) == NULL)
{
mutt_perror (conn->server);
return (-1);
}
memcpy (&sin.sin_addr, he->h_addr_list[0], he->h_length);
if ((conn->fd = socket (AF_INET, SOCK_STREAM, IPPROTO_IP)) < 0)
{
mutt_perror ("socket");
return (-1);
}
mutt_message (_("Connecting to %s..."), conn->server);
if (connect (conn->fd, (struct sockaddr *) &sin, sizeof (sin)) < 0)
{
mutt_perror ("connect");
close (conn->fd);
}
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment