1. 05 Oct, 2010 1 commit
    • * configure.ac: Test for tcgetattr and tcsetattr.
      * gnulib.modules (getpass-gnu): Remove.
      * include/mailutils/mutil.h (mu_getpass): New proto.
      * include/mailutils/stream.h (MU_IOCTL_GET_ECHO)
      (MU_IOCTL_SET_ECHO): New ioctls.
      * include/mailutils/sys/file_stream.h (_MU_FILE_STREAM_ECHO_OFF): New flag.
      (_mu_file_stream) <echo_state>: New member.
      * libmailutils/getpass.c: New file.
      * libmailutils/Makefile.am (libmailutils_la_SOURCES): Add getpass.c.
      * libmailutils/file_stream.c (fd_done): Free echo_state.
      (fd_ioctl): Implement MU_IOCTL_GET_ECHO and MU_IOCTL_SET_ECHO.
      * mu/mu.h (mustrin): New extern.
      * mu/pop.c (com_pass): Use mu_getpass.
      * mu/shell.c (mustrin): New variable.
      (readline): Use mu_stream_getline instead of getline.
      (mutool_shell): Create mustrin.
      * pop3d/popauth.c (options): Fix typo.
      (fill_pass): Use mu_getpass.
      Sergey Poznyakoff authored
  2. 03 Oct, 2010 2 commits
    • One of stream flags bits indicates whether the stream is
      open or not.  The mu_stream_open function refuses to act if it
      already is.  The rest of functions (including mu_stream_close)
      refuses to act if the stream was not open.  A special function
      (mu_stream_is_open) is provided to check if the stream is in
      open state.
      
      Any stream creation function returns an already open stream.  The
      function mu_stream_open should be called only if the stream was
      previously closed by a call to mu_stream_close.
      
      * include/mailutils/stream.h (mu_stream_is_open): New proto.
      * include/mailutils/sys/stream.h (_MU_STR_OPEN): New flag.
      * libmailutils/stream.c (_mu_stream_create): Permit setting the
      _MU_STR_OPEN flag.
      (_stream_init): New static.
      (mu_stream_open): Return MU_ERR_OPEN if the stream is already open.
      (mu_stream_is_open): New function.
      (mu_stream_seek, mu_stream_read, mu_stream_readdelim)
      (mu_stream_getdelim, mu_stream_write, mu_stream_flush)
      (mu_stream_close, mu_stream_size, mu_stream_wait)
      (mu_stream_truncate): Check if the stream is open. Return MU_ERR_NOT_OPEN
      otherwise.
      
      * libmailutils/errors (MU_ERR_OPEN): Reword the diagnostics.
      
      * libmailutils/dbgstream.c (mu_dbgstream_create): Open the stream.
      * libmailutils/file_stream.c (mu_file_stream_create)
      (mu_fd_stream_create): Open the stream.
      * libmailutils/filter_iconv.c (mu_filter_iconv_create): Open the stream.
      * libmailutils/mapfile_stream.c (mu_mapfile_stream_create): Open the stream.
      * libmailutils/fltstream.c (mu_filter_stream_create): Mark the stream
      as open.
      * libmailutils/iostream.c (mu_iostream_create): Likewise.
      * libmailutils/memory_stream.c: Likewise.
      * libmailutils/message.c (_message_stream_create): Likewise.
      * libmailutils/message_stream.c (mu_message_stream_create): Likewise.
      * libmailutils/prog_stream.c (mu_prog_stream_create): Likewise.
      * libmailutils/socket_stream.c (mu_socket_stream_create): Likewise.
      * libmailutils/temp_file_stream.c (mu_temp_file_stream_create): Likewise.
      
      * libmailutils/amd.c (_amd_attach_message): Mark stream as open.
      * libmailutils/body.c (_body_get_stream): Likewise.
      * libmailutils/memory_stream.c: Likewise.
      * libmailutils/rdcache_stream.c (mu_rdcache_stream_create: Likewise.
      * libmailutils/stdio_stream.c (mu_stdio_stream_create): Likewise.
      * libmailutils/streamref.c (mu_streamref_create_abridged): Likewise.
      * libmailutils/tcp.c (mu_tcp_stream_create_with_source_ip): Likewise.
      * libmailutils/xscript-stream.c (mu_xscript_stream_create): Likewise.
      * libmu_auth/tls.c (_mu_tls_io_stream_create): Likewise.
      (_mu_tls_stream_create): Likewise.
      * libproto/pop/pop3_stream.c (mu_pop3_stream_create): Likewise.
      
      * examples/base64.c: Remove unnecessary mu_stream_open.
      * examples/http.c: Likewise.
      * examples/iconv.c: Likewise.
      * examples/msg-send.c: Likewise.
      * examples/murun.c: Likewise.
      * examples/musocio.c: Likewise.
      * examples/pop3client.c: Likewise.
      * imap4d/append.c: Likewise.
      * imap4d/io.c: Likewise.
      * imap4d/preauth.c: Likewise.
      * lib/mailcap.c: Likewise.
      * libmailutils/attachment.c: Likewise.
      * libmailutils/cfg_driver.c: Likewise.
      * libmailutils/header.c: Likewise.
      * libmailutils/mailcap.c: Likewise.
      * libmailutils/mimehdr.c: Likewise.
      * libmailutils/mutil.c: Likewise.
      * libmailutils/tests/fltst.c: Likewise.
      * libmailutils/tests/mailcap.c: Likewise.
      * libmailutils/vartab.c: Likewise.
      * libmailutils/wicket.c: Likewise.
      * libmu_argp/muinit.c: Likewise.
      * libmu_auth/ldap.c: Likewise.
      * libmu_sieve/extensions/pipe.c: Likewise.
      * libmu_sieve/extensions/spamd.c: Likewise.
      * libmu_sieve/extensions/vacation.c: Likewise.
      * libproto/imap/folder.c: Likewise.
      * libproto/mailer/smtp.c: Likewise.
      * libproto/mailer/smtp_starttls.c: Likewise.
      * libproto/mbox/mbox.c: Likewise.
      * libproto/nntp/nntp_connect.c: Likewise.
      * libproto/pop/mbox.c: Likewise.
      * libproto/pop/pop3_connect.c: Likewise.
      * libproto/pop/pop3_stls.c: Likewise.
      * maidag/mailtmp.c: Likewise.
      * mail/decode.c: Likewise.
      * mail/pipe.c: Likewise.
      * mail/send.c: Likewise.
      * mail/send.c: Likewise.
      * mail/write.c: Likewise.
      * mh/burst.c: Likewise.
      * mh/comp.c: Likewise.
      * mh/compcommon.c: Likewise.
      * mh/forw.c: Likewise.
      * mh/mh_init.c: Likewise.
      * mh/mh_whatnow.c: Likewise.
      * mh/mhl.c: Likewise.
      * mh/mhn.c: Likewise.
      * mh/repl.c: Likewise.
      * mimeview/mimeview.c: Likewise.
      * pop3d/extra.c: Likewise.
      * sieve/sieve.c: Likewise.
      * testsuite/smtpsend.c: Likewise.
      Sergey Poznyakoff authored
    • * include/mailutils/sys/smtp.h (_mu_smtp_get_streams)
      (_mu_smtp_set_streams): New protos.
      * libproto/mailer/smtp_gsasl.c (insert_gsasl_stream): Use _mu_smtp_get_streams
      and _mu_smtp_set_streams to change streams.
      * libproto/mailer/smtp_starttls.c (smtp_get_streams): Rename to
      _mu_smtp_get_streams. All callers changed.
      (smtp_set_streams): Rename to
      _mu_smtp_set_streams. All callers changed.
      Sergey Poznyakoff authored
  3. 25 Sep, 2010 1 commit
    • * include/mailutils/stream.h (MU_IOCTL_SWAP_STREAM): Remove.
      (MU_IOCTL_GET_STREAM, MU_IOCTL_SET_STREAM): New ioctls.
      * include/mailutils/sys/stream.h (_MU_SWAP_FIRST_ONLY)
      (_MU_SWAP_IOCTL_MUST_SUCCEED): Remove.
      (_mu_stream_swap_streams): Remove.
      * libmailutils/stream.c (_mu_stream_swap_streams): Remove.
      
      * libmailutils/filter_iconv.c (_icvt_ioctl): Handle MU_IOCTL_GET_STREAM,
      MU_IOCTL_SET_STREAM instead of MU_IOCTL_SWAP_STREAM.
      * libmailutils/iostream.c (_iostream_ctl): Likewise.
      * libmailutils/xscript-stream.c (_xscript_ctl): Likewise.
      
      * imap4d/auth_gsasl.c (restore_and_return): Unref the contents of str.
      (auth_gsasl): Use MU_IOCTL_GET_STREAM/MU_IOCTL_SET_STREAM to
      change the underlying transport streams.
      * imap4d/io.c (imap4d_init_tls_server): Likewise.
      * libproto/mailer/smtp_gsasl.c (insert_gsasl_stream): Likewise.
      * pop3d/extra.c (pop3d_init_tls_server): Likewise.
      
      * libproto/mailer/smtp_starttls.c (smtp_get_streams)
      (smtp_set_streams): New functions.
      (smtp_swap_streams): Remove.
      (mu_smtp_starttls): Use smtp_get_streams and smtp_set_streams
      instead of smtp_swap_streams.
      * libproto/pop/pop3_stls.c (pop3_get_streams)
      (pop3_set_streams): New functions.
      (pop3_swap_streams): Remove.
      (mu_pop3_stls): Use pop3_get_streams and pop3_set_streams.
      
      * testsuite/smtpsend.c (main): Uncomment mu_stream_unref on
      the carrier.
      Sergey Poznyakoff authored
  4. 21 Sep, 2010 1 commit
    • * include/mailutils/cpp/pop3.h (capa): Add reread parameter.
      (getline): Add new prototype.
      (send, readline): Remove.
      (response, stat): Change prototype.
      * libmu_cpp/pop3.cc: Likewise.
      * include/mailutils/cpp/stream.h
      (read, write, readline): Change prototype.
      (sequential_readline, sequential_write): Remove.
      * libmu_cpp/stream.cc: Likewise.
      Wojciech Polak authored
  5. 20 Sep, 2010 2 commits
    • * include/mailutils/smtp.h (mu_smtp_write): Mark as printf-like.
      (mu_smtp_mail_basic, mu_smtp_rcpt_basic): Take variable number
      of arguments.  Mark as printf-like.
      (mu_smtp_data): New prototype.
      * include/mailutils/sys/smtp.h (_MU_SMTP_SAVEBUF): New flag.
      (_mu_smtp) <savebuf>: New member.
      (_mu_smtp_data_begin, _mu_smtp_data_end): New protos.
      * libproto/mailer/smtp_send.c: New file.
      * libproto/mailer/smtp_data.c (_mu_smtp_data_begin)
      (_mu_smtp_data_end, mu_smtp_data): New functions.
      
      * libproto/mailer/Makefile.am (libmu_mailer_la_SOURCES): Add smtp_send.c.
      * libproto/mailer/smtp_ehlo.c (mu_smtp_ehlo): Switch to MU_SMTP_EHLO
      only if in MU_SMTP_MAIL state.
      * libproto/mailer/smtp_mail.c (mu_smtp_mail_basic): Take variable number
      of arguments.
      * libproto/mailer/smtp_param.c (mu_smtp_get_param): Add missing typecast.
      * libproto/mailer/smtp_rcpt.c (mu_smtp_rcpt_basic): Take variable number
      of arguments.
      * libproto/mailer/smtp_send.c (_smtp_data_send): Use _mu_smtp_data_begin and
      _mu_smtp_data_end.
      * testsuite/smtpsend.c: Emulate sending from a MU message.
      Sergey Poznyakoff authored
    • * include/mailutils/stream.h (mu_stream_printf): Mark as printf-like.
      * include/mailutils/sys/stream.h (_MU_STR_EVENT_CLOSE): New event.
      (_mu_stream) <event_cb_data>: New member.
      * libmailutils/stream.c (mu_stream_seek): Avoid unnecessary seeks
      in mu_buffer_none mode.  Complements 906499db.
      (mu_stream_close): Mark _MU_STR_EVENT_CLOSE event.
      Sergey Poznyakoff authored
  6. 19 Sep, 2010 2 commits
    • * include/mailutils/smtp.h (MU_SMTP_PARAM_URL): New parameter code.
      * include/mailutils/sys/smtp.h (_MU_SMTP_CLNPASS): New flag.
      (_mu_smtp) <secret>: New member.
      * libproto/mailer/smtp_auth.c (get_ticket)
      (_mu_smtp_fixup_params): New static functions.
      (mu_smtp_auth): Call _mu_smtp_fixup_params to supply missing
      pararameters.
      * libproto/mailer/smtp_create.c (mu_smtp_destroy): Destroy secret.
      Take care to erase eventual plaintext representation of the password.
      * libproto/mailer/smtp_gsasl.c (_smtp_callback): Use mu_smtp_get_param
      to obtain parameters.
      * libproto/mailer/smtp_param.c (mu_smtp_set_param): Setting
      MU_SMTP_PARAM_PASSWORD updates secret.  param[MU_SMTP_PARAM_PASSWORD]
      points (temporarly and on request only) to plaintext password.
      (mu_smtp_get_param): Likewise for retrieving password.
      * testsuite/smtpsend.c (main): New parameter url=.
      Sergey Poznyakoff authored
    • * libmu_auth/gsasl.c (_gsasl_encoder,_gsasl_decoder): Do not free flt.
      * include/mailutils/stream.h [__cplusplus]: Protect contents by extern "C".
      Sergey Poznyakoff authored
  7. 18 Sep, 2010 1 commit
    • * configure.ac (MU_COND_GSASL): New cond.
      * include/mailutils/smtp.h (MU_SMTP_PARAM_DOMAIN)
      (MU_SMTP_PARAM_USERNAME, MU_SMTP_PARAM_PASSWORD)
      (MU_SMTP_PARAM_SERVICE, MU_SMTP_PARAM_REALM)
      (MU_SMTP_PARAM_HOST, MU_SMTP_MAX_PARAM): New constants.
      (mu_smtp_set_domain, mu_smtp_get_param): Remove.
      (mu_smtp_set_param, mu_smtp_get_param): New prototypes.
      (mu_smtp_auth, mu_smtp_add_auth_mech)
      (mu_smtp_add_auth_mech_list, mu_smtp_mech_select): New prototypes.
      * include/mailutils/sys/smtp.h (_mu_smtp) <domain>: Remove.
      (_mu_smtp) <authimpl, param, authmech>: New members.
      (_mu_smtp_gsasl_auth, _mu_smtp_mech_impl): New prototypes.
      
      * libproto/mailer/Makefile.am [MU_COND_GSASL]: Define SMTP_GSASL.
      (libmu_mailer_la_SOURCES): Add new sources.
      * libproto/mailer/smtp_domain.c: Remove.
      * libproto/mailer/smtp_param.c: New file.
      * libproto/mailer/smtp_mech.c: New file.
      * libproto/mailer/smtp_auth.c: New file.
      * libproto/mailer/smtp_gsasl.c: New file.
      * libproto/mailer/smtp_create.c (mu_smtp_destroy): Free new members of
      struct _mu_smtp.
      * libproto/mailer/smtp_ehlo.c (mu_smtp_ehlo): Use param[MU_SMTP_PARAM_DOMAIN]
      instead of domain.
      * testsuite/smtpsend.c: Handle SMTP AUTH.
      
      * libmu_auth/gsasl.c (mu_gsasl_stream_create): Bugfix.
      
      * libmailutils/xscript-stream.c (_xscript_ctl)
      <MU_IOCTL_SWAP_STREAM>: If instream!=outstream, combine them first
      into an iostream.
      Sergey Poznyakoff authored
  8. 17 Sep, 2010 2 commits
    • * include/mailutils/smtp.h (mu_smtp_mail_basic)
      (mu_smtp_rcpt_basic, mu_smtp_send_stream)
      (mu_smtp_rset, mu_smtp_quit): New prototypes.
      * include/mailutils/sys/smtp.h (MU_SMTP_RCPT)
      (MU_SMTP_MORE, MU_SMTP_DOT, MU_SMTP_QUIT, MU_SMTP_CLOS): New states.
      (_mu_smtp_xscript_level): New proto.
      * libmailutils/errors (MU_ERR_REPLY): New error code.
      * libproto/mailer/Makefile.am (libmu_mailer_la_SOURCES): Add new sources.
      * libproto/mailer/smtp_data.c: New file.
      * libproto/mailer/smtp_mail.c: New file.
      * libproto/mailer/smtp_quit.c: New file.
      * libproto/mailer/smtp_rcpt.c: New file.
      * libproto/mailer/smtp_rset.c: New file.
      * libproto/mailer/smtp_ehlo.c: Return MU_ERR_REPLY if the server replied
      with a code other than 2xx.
      * libproto/mailer/smtp_open.c: Likewise.
      * testsuite/smtpsend.c: Implement full sending cycle (excepting
      authorization).
      Sergey Poznyakoff authored
    • * include/mailutils/smtp.h: New file.
      * include/mailutils/Makefile.am (pkginclude_HEADERS): Add smtp.h.
      * include/mailutils/list.h (mu_list_clear): New proto.
      * include/mailutils/sys/smtp.h: New file.
      * include/mailutils/sys/Makefile.am (sysinclude_HEADERS): Add smtp.h.
      * libmailutils/errors (MU_ERR_BADREPLY, MU_ERR_SEQ): New error codes.
      * libmailutils/list.c (mu_list_clear): New function.
      * libproto/mailer/Makefile.am (libmu_mailer_la_SOURCES): Add new sources.
      * libproto/mailer/smtp_capa.c: New file.
      * libproto/mailer/smtp_carrier.c: New file.
      * libproto/mailer/smtp_create.c: New file.
      * libproto/mailer/smtp_disconnect.c: New file.
      * libproto/mailer/smtp_domain.c: New file.
      * libproto/mailer/smtp_ehlo.c: New file.
      * libproto/mailer/smtp_io.c: New file.
      * libproto/mailer/smtp_open.c: New file.
      * libproto/mailer/smtp_starttls.c: New file.
      * libproto/mailer/smtp_trace.c: New file.
      * testsuite/smtpsend.c: New file.
      * testsuite/Makefile.am (noinst_PROGRAMS): Add smtpsend.
      Sergey Poznyakoff authored
  9. 16 Sep, 2010 1 commit
    • That's the first commit since the merge six days ago that passes
      distcheck (with python, cxx, imap and nntp disabled, of course).
      
      * testsuite/folder/DISTFILES: Restore. It is needed for some
      of the remaining DejaGNU tests.
      * testsuite/spool/DISTFILES: Likewise.
      * testsuite/testsuite.at: New file.
      * testsuite/atlocal.in: New file.
      * libmailutils/tests/mbdel.at: Move to testsuite/.
      * libmailutils/tests/mbdel.c: Likewise.
      * libmailutils/tests/mime.at: Likewise.
      * libmailutils/tests/mimetest.c: Likewise.
      
      * Makefile.am (SUBDIRS): Place testsuite after libproto.
      * configure.ac (AM_INIT_AUTOMAKE): Remove dist-lzma.
      (AC_CONFIG_FILES): Add testsuite/atlocal.
      * libmailutils/base64.c (_base64_decoder)
      (_base64_encoder): Fix the use of uninitialized variables.
      * libmailutils/tests/.gitignore: Remove mbdel and mimetest.
      * libmailutils/tests/Makefile.am (noinst_PROGRAMS): Remove mbdel and mimetest.
      (LDADD): Leave only MU_LIB_MAILUTILS.
      (TESTSUITE_AT): Remove mbdel.at and mime.at
      * libmailutils/tests/atlocal.in (PATH): Bugfix.
      * libmailutils/tests/testsuite.at: Remove inclusion of mbdel.at and mime.at.
      * po/POTFILES.in: Replace mailbox/ with libmailutils/.
      
      * testsuite/.gitignore: Rewrite.
      * testsuite/Makefile.am: Rewrite.
      * testsuite/mbdel.at: Set +w on all copied mailboxes.
      * testsuite/mimetest.c (main): Open mailbox for reading only.
      
      * sieve/Makefile.am: Add examples/ to the distribution.
      
      * libproto/mbox/mbox.c (mbox_open): Create locker only
      if the mailbox is open for modification.
      All users updated to check for mailbox->locker!=NULL before
      using it.
      Sergey Poznyakoff authored
  10. 15 Sep, 2010 1 commit
    • * include/mailutils/mailbox.h (mu_mailbox_remove): New function.
      * include/mailutils/stream.h: Add some comments.
      * include/mailutils/sys/amd.h (_amd_data)<remove>: New method.
      (amd_remove_dir): New function.
      * include/mailutils/sys/mailbox.h (_mu_mailbox)<_remove>: New
      method.
      * libmailutils/amd.c (amd_remove_mbox): New function.
      (amd_init_mailbox): Initialize the _remove method.
      (amd_remove_dir): New function.
      * libmailutils/errors (MU_ERR_MBX_REMOVED)
      (MU_ERR_NOT_OPEN, MU_ERR_OPEN): New error codes.
      * libmailutils/mailbox.c: Keep state of the mailbox (open vs. not
      open, removed). Check it before doing anything on it.
      (_MU_MAILBOX_OPEN, _MU_MAILBOX_REMOVED, _MU_MAILBOX_MASK): New
      defines.
      (mu_mailbox_open): Set _MU_MAILBOX_OPEN if the operation succeeds.
      (mu_mailbox_close): Clear _MU_MAILBOX_OPEN if the operation succeeds.
      Refuse to run if the mailbox was not opened.
      (mu_mailbox_remove): New function.
      (all functions): return MU_ERR_MBX_NULL if the mbox argument is
      NULL.
      Check mailbox state on entry and proceed accordingly.
      * libproto/maildir/mbox.c: Implement _remove method.
      (maildir_remove): New function.
      (_mailbox_maildir_init): Initialize amd->_remove.
      * libproto/mbox/mbox.c: Implement _remove method.
      (mbox_remove): New function.
      (_mailbox_mbox_init): Initialize amd->_remove.
      * libproto/mh/mbox.c: Implement _remove method.
      (mh_remove): New function.
      (_mailbox_mh_init): Initialize amd->_remove.
      
      * libmailutils/tests/mbdel.c: New file.
      * libmailutils/tests/.gitignore: Add mbdel.
      * libmailutils/tests/Makefile.am (noinst_PROGRAMS): Likewise.
      (LDADD): List all mailbox formats.
      
      * imap4d/delete.c (imap4d_delete): Use mu_mailbox_remove to
      delete the folder.  Fall back to remove() if it does not appear
      to be a mailbox.
      Sergey Poznyakoff authored
  11. 14 Sep, 2010 1 commit
    • * configure.ac: Create libmailutils/tests/atlocal and
      libmailutils/tests/Makefile. Remove libmailutils/testsuite.
      * examples/Makefile.am (noinst_PROGRAMS): Remove programs moved
      to libmailutils/tests.
      * examples/argcv.c -> libmailutils/tests/argcv.c
      * libmailutils/testsuite/Decode -> libmailutils/tests/Decode
      * libmailutils/testsuite/Encode -> libmailutils/tests/Encode
      * examples/decode2047.c: Move to libmailutils/tests
      * examples/encode2047.c: Move to libmailutils/tests
      * examples/mailcap.c: Likewise.
      * examples/url-parse.c: Likewise.
      
      * include/mailutils/Makefile.am: Minor changes.
      * libmailutils/Makefile.am (SUBDIRS): Replace testsuite with tests.
      * libmailutils/tests/Makefile.am: New file.
      * libmailutils/tests/addr.c: New file.
      * libmailutils/tests/address.at: New file.
      * libmailutils/tests/argcv.at: New file.
      * libmailutils/tests/atlocal.in: New file.
      * libmailutils/tests/base64d.at: New file.
      * libmailutils/tests/base64e.at: New file.
      * libmailutils/tests/decode2047.at: New file.
      * libmailutils/tests/encode2047.at: New file.
      * libmailutils/tests/fltst.c: New file.
      * libmailutils/tests/mailcap.at: New file.
      * libmailutils/tests/mime.at: New file.
      * libmailutils/tests/testsuite.at: New file.
      * libmailutils/tests/url.at: New file.
      
      * libmailutils/testsuite/: Delete.
      
      * frm/tests/Makefile.am: Prefix package.m4 creation commands with $(AM_V_GEN).
      * readmsg/tests/Makefile.am: Likewise.
      * sieve/tests/Makefile.am: Likewise.
      * frm/tests/testsuite.at: Minor changes.
      * readmsg/tests/testsuite.at: Include testsuite.inc.
      * sieve/tests/testsuite.at: Likewise.
      * sieve/tests/version.at: Comment out inclusion of testsuite.inc.
      * testsuite/testsuite.inc: Add m4_version_prereq.
      Sergey Poznyakoff authored
  12. 13 Sep, 2010 1 commit
    • * include/mailutils/sys/stream.h (_MU_STR_EVENT_SET): Rename
      to _MU_STR_EVENT_SET.
      (_MU_STR_EVENT_CLR): Rename to _MU_STR_EVENT_CLRFLAG.
      (_MU_STR_EVENT_FILLBUF, _MU_STR_EVENT_FLUSHBUF): New event codes.
      (_MU_STR_EVMASK): New macro.
      (_mu_stream) <cur>: Replace with pos, indicating current position
      in the buffer.
      (event_cb): Change signature.
      (mu_stream_read_unbuffered): Remove.
      (mu_stream_write_unbuffered): Remove.
      
      * mailbox/iostream.c (mu_iostream_create): Provide the readdelim method
      only if the underlying input transpor stream provides it.
      * mailbox/streamref.c (mu_streamref_create_abridged): Likewise.
      
      * mailbox/stream.c (_stream_event): New macro.
      (mu_stream_read_unbuffered): Rename to static _stream_read_unbuffered.
      (mu_stream_write_unbuffered): Rename to static _stream_write_unbuffered.
      (_stream_advance_buffer, _stream_buffer_offset)
      (_stream_orig_level): Remove macros.
      (_stream_buffer_freespace): Rewrite.
      (_stream_curp): New macro.
      (_stream_fill_buffer): Make sure the `offset' indicates the offset
      int the transport, corresponding to the beginning of the current
      buffer.
      (_stream_flush_buffer): Essentially rewritten.
      (mu_stream_seek): Reflect changes to the _mu_stream structure. Optimize
      calls to the seek method.
      (_stream_skip_input_bytes): Likewise.
      (mu_stream_read, _stream_scandelim, mu_stream_write): Rewrite using
      new _mu_stream structure.
      
      * mailbox/xscript-stream.c: Rewrite using stream events.
      
      * mailbox/base64.c (_base64_encoder): Bugfix.
      
      * libproto/pop/pop3_stream.c (_pop3_event_cb): Update signature to
      match the changes above.
      * examples/mimetest.c (main): Add more error checking.
      * mail/testsuite/mail/write.exp: Minor fix.
      Sergey Poznyakoff authored
  13. 12 Sep, 2010 1 commit
    • * imap4d/quota.c: New file.
      * imap4d/Makefile.am (imap4d_SOURCES): Add quota.c
      * imap4d/append.c (imap4d_append0): Refuse to append if
      the quota is exceeded or would be exceeded after completing
      the operation.
      * imap4d/copy.c (imap4d_copy0): Refuse to copy messages if
      the quota is exceeded or would be exceeded after completing
      the operation.
      Return a meaningful textual description.
      Attempt to restore mailbox to its original size if the operation failed.
      * imap4d/imap4d.c (imap4d_session_setup0): Call quota_setup.
      * imap4d/imap4d.h (quota_setup, quota_check, quota_update): New functions.
      
      * include/mailutils/folder.h (mu_list_response) <format>: New member.
      * include/mailutils/mailbox.h (mu_mailbox_create_from_record): New
      function.
      * include/mailutils/types.hin (MU_FOLDER_ATTRIBUTE_LINK): New flag.
      * libproto/mbox/folder.c (list_helper): Do not return symbolic links
      unless MU_FOLDER_ATTRIBUTE_LINK is set.
      Fill in the resp->format member.
      * mailbox/mailbox.c (_mailbox_create_from_record): New static function.
      (_create_mailbox0): Rewrite as a wrapper over _mailbox_create_from_record.
      (mu_mailbox_create_from_record): New function.
      Sergey Poznyakoff authored
  14. 11 Sep, 2010 2 commits
    • As a side note, previous versions of pop3d did not do
      byte-stuffing when sending RETR output.  This commit fixes
      it.
      
      * include/mailutils/filter.h (mu_dot_filter): New filter.
      * mailbox/dot.c: New file.
      * mailbox/Makefile.am (libmailutils_la_SOURCES): Add dot.c
      * mailbox/crlfdot.c (_crlfdot_encoder): Bugfix. Do not
      dereference iobuf until we know it is not NULL.
      * mailbox/filter.c (mu_filter_get_list): Register mu_dot_filter.
      * mailbox/fltstream.c (filter_wr_close, filter_rd_close): New
      close methods, depending on the filter stream mode.
      (mu_filter_stream_create): Set filter_rd_close for MU_STREAM_READ
      and filter_wr_close for MU_STREAM_WRITE streams.
      * mailbox/stream.c (mu_stream_readdelim): Update stream offset
      when using stream->readdelim.
      
      * pop3d/pop3d.h (pop3d_send_payload): New proto.
      * pop3d/retr.c (pop3d_send_payload): Change function to be
      optionally used in pop3d_top.  Use DOT filter on output.
      * pop3d/top.c (pop3d_top): Rewrite using pop3d_send_payload.
      
      * libproto/pop/pop3_retr.c (mu_pop3_retr): Default return
      code is EINPROGRESS.
      * libproto/pop/pop3_stream.c: Remove the filter stuff.
      Use CRLFDOT instead.
      
      * mailbox/amd.c (amd_body_stream_readdelim): Bugfix.  Increase
      offset by nread bytes.
      Sergey Poznyakoff authored
    • * include/mailutils/filter.h (mu_filter_command) <mu_filter_flush> New command.
      (mu_filter_result) <mu_filter_again>: New result code.
      (MU_FILTER_MAX_AGAIN): New constant.
      (mu_crlfdot_filter): New filter.
      * include/mailutils/sys/stream.h (_MU_STR_DIRTY, _MU_STR_WRT)
      (_MU_STR_ERR, _MU_STR_EOF, _MU_STR_INTERN_MASK): Avoid conflicts with
      MU_STREAM_ constants from mailutils/stream.h
      
      * mailbox/crlfdot.c: New source.
      * mailbox/Makefile.am (libmailutils_la_SOURCES): Add crlfdot.c.
      * mailbox/filter.c (mu_filter_get_list): Register mu_crlfdot_filter.
      * mailbox/fltstream.c (init_iobuf): Fix initialization of isize and
      input.
      (filter_read): Redo the loop, allowing xcode to request a new
      iteration by returning mu_filter_again.
      (filter_write_internal): Likewise.
      (filter_wr_flush): Call filter_write_internal with mu_filter_flush, reserving
      mu_filter_lastbuf for really last buffers.
      (filter_close): Call filter_write_internal with mu_filter_lastbuf.
      * mailbox/stream.c (mu_stream_skip_input_bytes): Clear MU_STREAM_SEEK bit
      before actually doing anything.
      
      * include/mailutils/sys/pop3.h [DMALLOC]: Remove unneeded cond.
      Sergey Poznyakoff authored
  15. 09 Sep, 2010 1 commit
    • New ioctls MU_IOCTL_GET_TRANSPORT_BUFFER and
      MU_IOCTL_SET_TRANSPORT_BUFFER return and modify bufferization
      mode in the lowest level transport stream.  Both server and
      client programs use this to switch to full buffering before
      sending large amounts of data. This has a particular impact
      on the output speed and CPU usage when TLS is in use.
      
      * include/mailutils/stream.h (MU_IOCTL_GET_TRANSPORT_BUFFER)
      (MU_IOCTL_SET_TRANSPORT_BUFFER): New ioctls.
      (MU_TRANSPORT_INPUT, MU_TRANSPORT_OUTPUT): New constants.
      (MU_TRANSPORT_VALID_TYPE): New macro.
      (mu_buffer_query): New struct.
      (mu_stream_get_buffer): New proto.
      
      * libmu_auth/tls.c (_tls_io_ioctl): Return ENOSYS
      if op is not supported.
      (_tls_ioctl): Support MU_IOCTL_[GS]ET_TRANSPORT_BUFFER.
      * mailbox/file_stream.c (fd_ioctl): Support MU_IOCTL_[GS]ET_TRANSPORT_BUFFER.
      Return ENOSYS if op is not supported.
      * mailbox/filter_iconv.c (_icvt_ioctl): Likewise.
      * mailbox/iostream.c (_iostream_ctl): Likewise.
      * mailbox/mapfile_stream.c (_mapfile_ioctl): Likewise.
      * mailbox/memory_stream.c (_memory_ioctl): Likewise.
      * mailbox/rdcache_stream.c (rdcache_ioctl): Likewise.
      * mailbox/xscript-stream.c (_xscript_ctl): Likewise.
      * mailbox/prog_stream.c (_prog_ioctl): Return ENOSYS if op is not
      supported.
      * mailbox/tcp.c (_tcp_ioctl): Likewise.
      
      * mailbox/stream.c (mu_stream_default_buffer_size): New global.
      (mu_stream_seek): Do not call seek method if the requested offset
      is the same as the current one.
      (mu_stream_set_buffer): Size==0 means use the default value.
      (mu_stream_get_buffer): New function.
      (mu_stream_truncate): Flush the buffer before truncating.
      
      * mailbox/mime.c (mime_reset_state): New function.
      (_mime_body_stream_seek): Rewrite using mime_reset_state.
      (_mime_body_stream_ioctl): Return ENOSYS if op is not
      supported.
      (create_mime_body_stream): Reset mime state (_mime_body_stream_seek
      may not be called due to the optimization in mu_stream_seek.
      
      * mailbox/header.c (header_parse): Exit correctly if the buffer is
      not terminated with a \n.
      
      * libproto/mbox/mbox.c (mbox_open): Enforce full buffering on the
      mailbox stream.
      * libproto/pop/mbox.c (pop_header_fill): Minor fix.
      * libproto/pop/pop3_stream.c (_POP3F_DONE)
      (_POP3F_CHBUF): New constants.
      (mu_pop3_stream)<done>: Remove. Replaced with flags.
      <oldbuf>: New member.
      (_pop3_event_cb): If _POP3F_CHBUF flag is set, restore
      the initial buffering mode on the transport stream.
      (mu_pop3_filter_create): Save away current buffering mode
      and enforce full buffering while transferring bulk data.
      
      * mail/from.c (hdr_from): Check return value from mu_message_get_header.
      * mail/mail.c (main): Allow for MAILRC having empty value.
      Always close the mailbox before exiting.
      
      * pop3d/pop3d.c (pop3d_cfg_param): New statement output-buffer-size.
      * pop3d/pop3d.h (pop3d_output_bufsize): New global.
      * pop3d/retr.c (pop3d_send_payload): New function.
      (pop3d_retr): Rewrite using pop3d_send_payload. Save away
      current buffering mode and enforce full buffering while
      transferring bulk data.
      * pop3d/top.c (pop3d_top_: Likewise.
      Sergey Poznyakoff authored
  16. 08 Sep, 2010 20 commits
    • * include/mailutils/stream.h (MU_IOCTL_LEVEL): New ioctl op.
      (XSCRIPT_NORMAL, XSCRIPT_SECURE, XSCRIPT_PAYLOAD): New constants.
      * include/mailutils/sys/xscript-stream.h (_mu_xscript_stream)
      <level>: New member.
      * mailbox/xscript-stream.c (TRANS_DISABLED): New flag.
      (print_transcript): Amount of output varies depending on the
      current output level.  For secure data, try to recognize passwords
      and to replace them with *** on output.
      (_xscript_ctl): Support MU_IOCTL_LEVEL.
      * pop3d/extra.c (set_xscript_level): New function.
      * pop3d/pop3d.h (set_xscript_level): New proto.
      * pop3d/retr.c (pop3d_retr): Set XSCRIPT_PAYLOAD level before
      sending actual data and reset it to XSCRIPT_NORMAL afterwards.
      * pop3d/top.c (pop3d_top): Likewise.
      * pop3d/user.c: Set XSCRIPT_SECURE level while expecting the
      PASS command.
      
      * imap4d/fetch.c (imap4d_fetch): Run imap4d_fetch0 in XSCRIPT_PAYLOAD
      level.
      * imap4d/uid.c (imap4d_uid): Likewise.
      * imap4d/imap4d.c (imap4d_mainloop): Unless started in preauth mode,
      select XSCRIPT_SECURE mode until authentication has been passed.
      * imap4d/imap4d.h (set_xscript_level): New proto.
      * imap4d/io.c (io_format_completion_response): Switch to XSCRIPT_NORMAL
      level when changing to the authenticated state.
      (imap4d_readline): Read literals in XSCRIPT_PAYLOAD level.
      * imap4d/util.c (set_xscript_level): New function.
      
      * include/mailutils/pop3.h (mu_pop3_trace_mask): New prototype.
      (MU_POP3_XSCRIPT_MASK): New macro.
      (_mu_pop3_xscript_level): New proto.
      * libproto/pop/pop3_pass.c (mu_pop3_pass): Set XSCRIPT_SECURE
      while sending the password.
      * libproto/pop/pop3_retr.c (mu_pop3_retr): Set XSCRIPT_PAYLOAD before
      going to MU_POP3_RETR_RX state.
      * libproto/pop/pop3_stream.c (_pop3_event_cb): Set XSCRIPT_NORMAL.
      * libproto/pop/pop3_top.c (mu_pop3_top): Set XSCRIPT_PAYLOAD before
      going to MU_POP3_TOP_RX state.
      * libproto/pop/pop3_trace.c (mu_pop3_trace_mask)
      (_mu_pop3_xscript_level): New functions.
      * libproto/pop/mbox.c (pop_open): Set trace masks depending on the
      trace6 and trace7 debug levels.
      
      * examples/pop3client.c (com_verbose): Allow to mask/unmask transcript
      levels.
      Sergey Poznyakoff authored
    • * mailbox/msgscan.c: New file.
      * mailbox/Makefile.am (libmailutils_la_SOURCES): Add it.
      
      * include/mailutils/body.h (mu_body_set_get_stream): New prototype.
      * include/mailutils/message.h (MU_SCAN_SEEK, MU_SCAN_SIZE): New
      defines.
      (mu_message_scan): New structure.
      (mu_stream_scan_message): New prototype.
      (mu_message_set_get_stream): New prototype.
      * include/mailutils/stream.h (mu_stream_copy): Change signature: takes
      4 arguments now.
      * include/mailutils/sys/body.h (_mu_body) <_get_stream>: New method.
      * include/mailutils/sys/message.h (_mu_message) <_get_stream>: New method.
      * mailbox/body.c (_body_get_stream): Call _get_stream, if provided.
      * mailbox/message.c (_message_get_stream): Call _get_stream, if provided.
      
      * mailbox/stream.c (_stream_flush_buffer): Avoid infinite recursion:
      call stream->seek directly.
      * mailbox/streamcpy.c (mu_stream_copy): Return the number of bytes
      actually copied in the fourth argument. All uses updated.
      * mailbox/streamref.c (streamref_return): Do not propagate internal
      flags.
      (_streamref_readdelim): Ensure there is enough buffer space for the
      mu_stream_readdelim call.
      
      * libproto/pop/mbox.c: Finish client implementation.
      
      * mail/print.c (mail_print_msg): Close pager before returning on
      error.
      Sergey Poznyakoff authored
    • * include/mailutils/sys/stdio_stream.h: Remove.
      * include/mailutils/sys/socket_stream.h: Remove.
      * include/mailutils/sys/rdcache_stream.h: New file.
      * include/mailutils/sys/Makefile.am: Update.
      * mailbox/rdcache_stream.c: New file.
      * mailbox/Makefile.am: Update.
      
      * examples/mucat.c: New example.
      * examples/musocio.c: New example.
      * examples/Makefile.am (noinst_PROGRAMS): Build new examples.
      
      * include/mailutils/stream.h (mu_fd_stream_create): New proto.
      (mu_rdcache_stream_create): New proto.
      * include/mailutils/sys/file_stream.h (_mu_file_stream_create): Change
      prototype.
      * mailbox/file_stream.c (fd_open): Raise the MU_STREAM_AUTOCLOSE bit.
      (fd_ioctl): Support MU_IOCTL_SET_TRANSPORT.
      (_mu_file_stream_create): Change signature. All uses updated.
      Allocate a copy of the filename argument, unless it is NULL.
      (mu_fd_stream_create): New function.
      
      * mailbox/socket_stream.c: Rewrite using file_stream directly.
      * mailbox/stdio_stream.c: Rewrite. Use rdcache_stream if
      the seek capability is required on an input stream.
      * mailbox/streamcpy.c (mu_stream_copy): Handle eventual
      EACCES return from mu_stream_seek as equivalent to ENOSYS.
      Sergey Poznyakoff authored
    • * examples/pop3client.c (com_capa): Call mu_pop3_capa_test.
      (com_stat): Count is size_t.
      
      * include/mailutils/opool.h (mu_opool_copy): New proto.
      * mailbox/opool.c (mu_opool_copy): New function.
      * mailbox/xscript-stream.c (_xscript_ctl)
      <MU_IOCTL_SWAP_STREAM>: Avoid coredumping if sp->transport
      is NULL.
      
      * include/mailutils/pop3.h (pop3_capa_test): Rename to
      mu_pop3_capa_test.
      (mu_pop3_stat): Third argument is a pointer to mu_off_t.
      * libproto/pop/pop3_capatst.c (pop3_capa_test): Rename to
      mu_pop3_capa_test.
      * libproto/pop/pop3_stat.c (mu_pop3_stat): Third argument is
      a pointer to mu_off_t.
      
      * libproto/pop/Makefile.am (libmu_pop_la_SOURCES): Put back
      folder.c, url.c and mbox.c.
      * libproto/pop/mbox.c: Begin rewriting.
      Sergey Poznyakoff authored
    • * include/mailutils/sys/stream.h (_MU_STR_EVENT_SET)
      (_MU_STR_EVENT_CLR): New defines.
      (_mu_stream) <event_cb, event_mask>: New members.
      * mailbox/stream.c (_stream_setflag, _stream_clrflag): New static
      functions.
      All functions use these instead of setting/clearing flags directly.
      (_mu_stream_cleareof, _mu_stream_seteof): New extern functions.
      (_stream_cleareof): Remove define, use _mu_stream_cleareof instead.
      (_stream_fill_buffer): Set EOF marker when end of stream is reached.
      
      * mailbox/fltstream.c (filter_read): Call _mu_stream_seteof to set
      EOF flag.
      
      * include/mailutils/pop3.h: Get rid of the superfluous "extern" in
      front of function prototypes.
      Add new prototypes.
      Remove extra whitespace.
      
      * libproto/pop/pop3_capatst.c: New file.
      * libproto/pop/pop3_list_cmd.c: New file.
      * libproto/pop/pop3_listas.c: New file.
      * libproto/pop/pop3_rdlist.c: New file.
      * libproto/pop/pop3_uidl_cmd.c: New file.
      * libproto/pop/pop3_uidlas.c: New file.
      * libproto/pop/Makefile.am: Add new files.
      * libproto/pop/pop3_capa.c (_mu_pop3_fill_list): Remove.
      Use mu_pop3_read_list instead.
      (capa_comp): New comparator for capa lists.
      * libproto/pop/pop3_list.c (mu_pop3_list): Fix format specifier.
      * libproto/pop/pop3_lista.c (mu_pop3_list_all): Rewrite.
      * libproto/pop/pop3_retr.c (mu_pop3_retr) <MU_POP3_RETR_RX>: do not
      reset state, this is done by the EOF event callback.
      * libproto/pop/pop3_top.c (mu_pop3_top) <MU_POP3_TOP_RX>: Likewise.
      * libproto/pop/pop3_stream.c (pop3_decode_state): New state pds_char.
      Change semantics of pds_init.
      (newstate, _pop3_decoder): Handle .\r\n in the initial state.
      (_pop3_event_cb): New event callback.
      (mu_pop3_filter_create): Set event callback on the filter stream.
      * libproto/pop/pop3_uidla.c (mu_pop3_uidl_all): Rewrite.
      
      * examples/Makefile.am (pop3client_CPPFLAGS): Add MU_APP_COMMON_INCLUDES.
      * examples/pop3client.c: Rewrite command parser.
      Sergey Poznyakoff authored
    • * include/mailutils/tls.h (mu_tls_readline_fn)
      (mu_tls_writeline_fn, mu_tls_stream_ctl_fn): Remove typedefs.
      (mu_tls_begin): Remove prototype.
      * libmu_auth/tls.c (mu_tls_begin): Remove function.
      * libproto/mailer/smtp.c: Revamp STARTTLS support.
      Sergey Poznyakoff authored
    • * include/mailutils/filter.h (mu_filter_io) <eof>: New member.
      * mailbox/fltstream.c (init_iobuf): Initialize eof to 0.
      (filter_read): Break the loop if the decoder has set eof.
      * mailbox/xscript-stream.c (_xscript_ctl) <MU_IOCTL_SWAP_STREAM>: Handle
      a special case when the transport does not support stream swapping.
      
      * include/mailutils/pop3.h (mu_pop3_set_debug): Remove.
      (MU_POP3_TRACE_CLR, MU_POP3_TRACE_SET, MU_POP3_TRACE_QRY): New macros.
      (mu_pop3_trace): New proto.
      (mu_pop3_readline): Remove.
      (mu_pop3_getline): New proto.
      (mu_pop3_capa): Change signature.
      * include/mailutils/sys/pop3.h (mu_pop3_state): Remove the *_ACK states.
      (mu_pop3_work_buf): Remove.
      (MU_POP3_ACK, MU_POP3_TRACE): New defines.
      (_mu_pop3): Rewrite the structure.
      (mu_pop3_debug_cmd, mu_pop3_debug_ack): Remove functions.
      (MU_POP3_FISSET, MU_POP3_FSET, MU_POP3_FCLR): New macros.
      (_mu_pop3_trace_enable, _mu_pop3_trace_disable)
      (_mu_pop3_init): New protos.
      
      * include/mailutils/tls.h (mu_tls_stream_ctl_fn)
      (mu_tls_writeline_fn): Change typedefs.
      * libmu_auth/tls.c (mu_tls_begin): Update function calls
      accordingly.
      
      * libproto/pop/pop3_debug.c: Remove.
      * libproto/pop/pop3_trace.c: New function.
      * libproto/pop/Makefile.am (libmu_pop_la_SOURCES): Temporarly
      comment out folder.c, mbox.c and url.c.
      Remove pop3_debug.c.
      Add pop3_trace.c.
      * libproto/pop/pop3_capa.c: Rewrite.
      * libproto/pop/pop3_create.c: Rewrite.
      * libproto/pop/pop3_iterator.c: Rewrite.
      * libproto/pop/pop3_response.c: Rewrite.
      * libproto/pop/pop3_sendline.c: Rewrite.
      * libproto/pop/pop3_stls.c: Rewrite.
      * libproto/pop/pop3_stream.c: Rewrite.
      * libproto/pop/pop3_apop.c: Reflect changes to the pop3 framework.
      * libproto/pop/pop3_carrier.c: Likewise.
      * libproto/pop/pop3_connect.c: Likewise.
      * libproto/pop/pop3_dele.c: Likewise.
      * libproto/pop/pop3_destroy.c: Likewise.
      * libproto/pop/pop3_disconnect.c: Likewise.
      * libproto/pop/pop3_list.c: Likewise.
      * libproto/pop/pop3_lista.c: Likewise.
      * libproto/pop/pop3_noop.c: Likewise.
      * libproto/pop/pop3_pass.c: Likewise.
      * libproto/pop/pop3_quit.c: Likewise.
      * libproto/pop/pop3_retr.c: Likewise.
      * libproto/pop/pop3_readline.c: Likewise.
      * libproto/pop/pop3_rset.c: Likewise.
      * libproto/pop/pop3_stat.c: Likewise.
      * libproto/pop/pop3_top.c: Likewise.
      * libproto/pop/pop3_uidl.c: Likewise.
      * libproto/pop/pop3_uidla.c: Likewise.
      * libproto/pop/pop3_user.c: Likewise.
      
      * examples/pop3client.c: Implement the stls comand.
      (main) [WITH_TLS]: Call mu_init_tls_libs.
      (com_verbose): Redo verbose support.
      (com_capa): Implement "reread" option.
      Sergey Poznyakoff authored
    • Move libproto/include/(*)0.h to include/mailutils/sys/\1.h
      Remove libproto/include.
      Sergey Poznyakoff authored
    • * libmu_auth/lbuf.c: Removed.
      * libmu_auth/lbuf.h: Removed.
      * libmu_auth/Makefile.am : Remove lbuf stuff.
      
      * include/mailutils/sys/gsasl-stream.h: New file.
      * include/mailutils/sys/Makefile.am: Add gsasl-stream.h.
      * include/mailutils/gsasl.h (mu_gsasl_stream_create): Remove.
      (gsasl_encoder_stream, gsasl_decoder_stream): New prototypes.
      
      * libmu_auth/gsasl.c: Rewrite.
      
      * imap4d/authenticate.c (auth_data): Remove.
      Use struct imap4d_auth instead.
      (_auth_try): Use new authentication API.
      (imap4d_authenticate): Likewise.
      * imap4d/imap4d.h (util_register_event, util_event_remove)
      (util_run_events): Remove.
      (imap4d_auth_handler_fp): Change prototype.
      (imap4d_auth): New struct.
      (imap4d_auth_result): New enum.
      * imap4d/io.c (io_format_completion_response)
      (io_stream_completion_response): New functions.
      (io_completion_response): Rewrite using io_format_completion_response.
      * imap4d/util.c (sc2string): Remove leftover prototype.
      (util_register_event, util_event_remove)
      (util_run_events): Remove.
      * imap4d/auth_gsasl.c: Revamp using new streams and the new
      authentication interface.
      * imap4d/auth_gss.c: Likewise (though yet untested).
      
      * mailbox/xscript-stream.c (_xscript_ctl): Remove unused variables.
      Sergey Poznyakoff authored
    • * include/mailutils/stream.h (MU_IOCTL_SWAP_STREAM): New ioctl op.
      (mu_stream_seterr): New function.
      * include/mailutils/sys/stream.h (_MU_SWAP_FIRST_ONLY)
      (_MU_SWAP_IOCTL_MUST_SUCCEED): New defines.
      (_mu_stream_swap_streams): New proto.
      * mailbox/amd.c (amd_body_stream_read): Always update *pnread.
      * mailbox/errors (MU_ERR_NO_TRANSPORT): New error code.
      
      * mailbox/stream.c (_stream_seterror): Rename to mu_stream_seterr,
      remove static qualifier. All uses updated.
      (_mu_stream_swap_streams): New function.
      
      * mailbox/filter_iconv.c (_icvt_ioctl): Implement MU_IOCTL_SWAP_STREAM.
      * mailbox/iostream.c (_iostream_ctl): Likewise.
      * mailbox/xscript-stream.c (_xscript_ctl): Likewise.
      
      * pop3d/extra.c (real_istream, real_ostream): Remove statics.
      (pop3d_init_tls_server): Use MU_IOCTL_SWAP_STREAM to replace
      bottom-level transport layers without recreating the entire stream
      chain.
      Sergey Poznyakoff authored
    • If a stream takes another stream(s) as a transport, it
      always increases its reference count.  This means that
      when that stream is destroyed the underlying stream is
      not destroyed by default (its refcount is decreased, that's
      all). To force destruction of the underlying stream,
      the caller must explicitly unreference it after creating
      the stream that uses it (or give its creation function
      the MU_STREAM_AUTOCLOSE flag, if it supports flags).
      
      Similarly, if a stream uses a non-stream object (e.g. a file
      descriptor) as the transport, it will not destroy it, unless
      it has been created with the MU_STREAM_AUTOCLOSE flag. This
      differs from the previous behavior.
      
      The MU_STREAM_NO_CHECK and MU_STREAM_NO_CLOSE flags are removed.
      
      * examples/base64.c (main): Call mu_filter_create with the
      MU_STREAM_AUTOCLOSE flag.
      * examples/mimetest.c (message_display_parts): Likewise.
      * examples/murun.c (main): Unref the input stream after
      passing it to mu_filter_prog_stream_create.
      * imap4d/fetch.c (fetch_io): Update arguments to mu_filter_create
      and mu_memory_stream_create.
      * imap4d/preauth.c (decode64_buf)
      (do_preauth_ident): Update arguments to mu_memory_stream_create and
      mu_tcp_stream_create.
      * imap4d/util.c (util_setio): Update arguments to mu_filter_create and
      mu_stdio_stream_create.
      * include/mailutils/stream.h (MU_STREAM_NO_CLOSE)
      (MU_STREAM_NO_CHECK): Remove.
      (MU_STREAM_AUTOCLOSE): New flag.
      (mu_iostream_create): Remove the `flags' argument.
      * libmu_argp/muinit.c (mu_app_init): Update arguments to
      mu_stdio_stream_create.
      * libmu_auth/ldap.c: Update arguments to
      mu_memory_stream_create and mu_filter_create.
      * libmu_auth/tls.c (_tls_io_close, _tls_close): Always try to close the
      transport stream. Rely on refcount to protect it.
      (_tls_io_done, _tls_done): Likewise, always unreference it.
      (_mu_tls_io_stream_create): Increase reference counter on the
      transport stream, unless MU_STREAM_AUTOCLOSE is requested.
      (_mu_tls_stream_create): Rewrite using the new MU_STREAM_AUTOCLOSE
      logic.
      * libmu_sieve/extensions/spamd.c (spamd_connect_tcp): Update arguments to
      mu_tcp_stream_create.
      (spamd_connect_tcp): Update arguments to mu_socket_stream_create and
      mu_filter_create.
      * libmu_sieve/extensions/vacation.c (build_mime): Update arguments to
      mu_filter_create.
      * mail/decode.c (display_submessage): Update arguments to
      mu_filter_create.
      * mailbox/attachment.c (mu_message_save_attachment): Update arguments to
      mu_filter_create.
      * mailbox/cfg_driver.c (mu_cfg_tree_reduce): Update arguments to
      mu_stdio_stream_create.
      * mailbox/dbgstream.c (_dbg_done): Use MU_STREAM_AUTOCLOSE bit to
      decide whether to destroy the debug object.
      (mu_dbgstream_create): Use MU_STREAM_AUTOCLOSE instead of
      MU_STREAM_NO_CLOSE.
      * mailbox/file_stream.c (fd_close): Use MU_STREAM_AUTOCLOSE bit to
      decide whether to close the descriptor.
      (mu_file_stream_create): Force MU_STREAM_AUTOCLOSE bit.
      * mailbox/filter.c (filter_create_rd, filter_create_wr): Change
      substream creation logic.
      * mailbox/filter_iconv.c (_icvt_close): Always try to close the
      transport stream. Rely on refcount to protect it.
      (_icvt_done): Ditto for destroying it.
      (mu_filter_iconv_create): Increase refcount on the transport stream,
      unless MU_STREAM_AUTOCLOSE is requested.
      * mailbox/fltstream.c (filter_done): Always dereference the
      transport stream. Rely on refcount to protect it.
      (filter_close): Ditto for closing it.
      (mu_filter_stream_create): Increase refcount on the transport stream,
      unless MU_STREAM_AUTOCLOSE is requested.
      * mailbox/iostream.c (_iostream_close) : Always try to close the
      transport stream. Rely on refcount to protect it.
      (_iostream_done): Ditto for closing it.
      (mu_iostream_create): Remove the use of MU_STREAM_NO_CLOSE.
      * mailbox/mimehdr.c (mu_mimehdr_decode_param): Remove the use of
      MU_STREAM_NO_CLOSE.
      * mailbox/mutil.c (mu_decode_filter) Change substream creation logic.
      * mailbox/prog_stream.c (_prog_open): Use MU_STREAM_AUTOCLOSE bit
      in arguments to mu_stdio_stream_create.
      (mu_filter_prog_stream_create): Increase refcount on the transport
      (input) stream.
      * mailbox/rfc2047.c (mu_rfc2047_decode): Dereference in_stream after
      passing it to mu_decode_filter.
      Pass MU_STREAM_AUTOCLOSE in flags to mu_filter_create.
      * mailbox/socket_stream.c (mu_socket_stream_create): Force
      MU_STREAM_AUTOCLOSE bit.
      * mailbox/streamref.c (_streamref_close): Always close the
      transport stream (refcount will protect it, if necessary).
      (mu_streamref_create_abridged): Mask out the MU_STREAM_AUTOCLOSE bit.
      * mailbox/temp_file_stream.c (mu_temp_file_stream_create: Force
      MU_STREAM_AUTOCLOSE bit.
      * mailbox/xscript-stream.c (_xscript_close): Always close the
      transport stream (refcount will protect it, if necessary).
      (mu_xscript_stream_create): Increase refcounts on both underlying streams,
      unless MU_STREAM_AUTOCLOSE is set.
      * pop3d/extra.c (pop3d_setio): Remove uses of MU_STREAM_NO_CLOSE.
      
      * examples/nntpclient.c: Remove uses of MU_STREAM_NO_CHECK/MU_STREAM_NO_CLOSE.
      * examples/pop3client.c: Likewise.
      * libmu_auth/gsasl.c: Likewise.
      * libproto/nntp/nntp_stream.c: Likewise.
      * libproto/pop/pop3_stream.c: Likewise.
      * mailbox/tcp.c: Likewise.
      * mailbox/vartab.c: Likewise.
      * mh/mh_list.c: Likewise.
      * mimeview/mimeview.c: Likewise.
      * mh/mhn.c: Likewise.
      (edit_mime): Use MU_STREAM_AUTOCLOSE.
      
      Bugfixes:
      
      * mailbox/fltstream.c (init_iobuf): Fix input initialization.
      (filter_write_internal): Bugfix.
      * mailbox/stream.c (_stream_buffer_freespace): New macro.
      (_stream_buffer_is_full): New macro.
      (BUFFER_FULL_P): Remove, use _stream_buffer_is_full instead. All callers
      updated.
      (_stream_flush_buffer): Operation for full buffered streams does not
      depend on the `all' flag.
      (mu_stream_write): Fix calculation of the bytes available in the
      buffer.
      Sergey Poznyakoff authored
    • * include/mailutils/stream.h (MU_STREAM_RDTHRU)
      (MU_STREAM_WRTHRU,MU_IOCTL_SET_TRANSPORT): New flags.
      (mu_xscript_stream_create, mu_iostream_create)
      (mu_dbgstream_create): New prototypes.
      * include/mailutils/sys/dbgstream.h: New header.
      * include/mailutils/sys/iostream.h: New header.
      * include/mailutils/sys/xscript-stream.h: New header.
      * include/mailutils/sys/Makefile.am (sysinclude_HEADERS): Add
      dbgstream.h, iostream.h and xscript-stream.h
      * mailbox/dbgstream.c: New file.
      * mailbox/iostream.c: New file.
      * mailbox/xscript-stream.c: New file.
      * mailbox/Makefile.am (libmailutils_la_SOURCES): Add dbgstream.c,
      iostream.c and xscript-stream.c
      * mailbox/filter_iconv.c (_icvt_ioctl): Simplify the declaration
      of ptrans.
      * mailbox/mapfile_stream.c (_mapfile_ioctl): Likewise.
      * mailbox/memory_stream.c (_memory_ioctl): Likewise.
      * mailbox/prog_stream.c (_prog_ioctl): Likewise.
      * mailbox/tcp.c (_tcp_ioctl): Likewise.
      * mailbox/fltstream.c (filter_ctl): Likewise.
      (filter_read_through, filter_write_through): New methods.
      (mu_filter_stream_create): Allow for use of MU_STREAM_RDTHRU
      and MU_STREAM_WRTHRU to create two-way filters (writing
      triggers filtering while reading is transparent or vice versa).
      * pop3d/extra.c (istream, ostream): Remove globals.
      (iostream): New variable.
      (real_istream, real_ostream): New variables.
      (pop3d_setio): Set transcript stream on top of the I/O one,
      if required.
      (pop3d_init_tls_server): Rewrite. Revert the meaning of the
      return code to match the usual convention (0 - success).
      (transcript): Removed.
      (pop3d_outf): Remove calls to transcript.
      * pop3d/pop3d.h (istream, ostream): Remove externs.
      (iostream): New extern.
      * pop3d/retr.c: Use iostream, instear of ostream.
      * pop3d/top.c: Likewise.
      * pop3d/stls.c: Update the call to pop3d_init_tls_server.
      
      * mailbox/stream_vprintf.c (mu_stream_vprintf): Fix return
      value to match the usual convention.
      Sergey Poznyakoff authored
    • STLS in pop3d is already working.
      
      * include/mailutils/sys/tls-stream.h: New header.
      * include/mailutils/tls.h (mu_tls_stream_create)
      (mu_tls_stream_create_client)
      (mu_tls_stream_create_client_from_tcp): Remove.
      (mu_tls_server_stream_create, mu_tls_client_stream_create): New
      protos.
      * libmu_auth/tls.c: Rewrite.
      
      * imap4d/util.c: Use mu_tls_server_stream_create.
      * libproto/pop/mbox.c: Use mu_tls_server_stream_create/
      mu_tls_client_stream_create.
      * libproto/pop/pop3_stls.c: Use mu_tls_client_stream_create.
      * libproto/imap/folder.c: Use mu_tls_client_stream_create.
      
      * pop3d/capa.c (pop3d_capa): CAPA is allowed in both states.
      * pop3d/extra.c (pop3d_setio): Rewrite.
      Sergey Poznyakoff authored
    • * examples/mta.c (finalize_option): New variable.
      (message_finalize): Don't modify the message if finalize_option
      is 0.
      * include/mailutils/sys/message.h (_mu_message)
      <orig_header_size>: New member.
      * include/mailutils/sys/mime.h (_mu_mime) <part_stream>: New member.
      * libmu_sieve/actions.c (mime_create_reason)
      (mime_create_ds): Use mu_body_get_streamref.
      (mime_create_quote): Use mu_body_get_streamref/mu_message_get_streamref.
      (sieve_action_reject): Set the To: header.
      * mailbox/message.c (mu_message_get_header): Set orig_header_size.
      (mu_message_get_body): Use orig_header_size instead of relying
      on mu_header_size.
      * mailbox/mime.c (_mime_part_size): New static.
      (_mime_body_stream_size): New method.
      (_mime_body_seek): Rename to _mime_body_stream_seek.
      (_mime_body_read): Rewrite and rename to _mime_body_stream_read.
      (_mime_body_ioctl): Rename to _mime_body_stream_ioctl.
      (create_mime_body_stream): Take mu_mime_t as the 2nd parameter.
      Initialize sp->stream.size and sp->mime.
      (_mime_body_size): Rewrite using _mime_part_size.
      (mu_mime_destroy): Destroy part_stream.
      * sieve/testsuite/Redirect: Reflect new mta behavior.
      * sieve/testsuite/Reject: Likewise.
      Sergey Poznyakoff authored
    • * include/mailutils/message.h (mu_message_set_stream): Mark as deprecated.
      * pop3d/retr.c (pop3d_retr): Rewind the stream obtained from
      mu_message_get_stream.
      * pop3d/top.c (pop3d_top): Rewind the streams obtained from
      mu_body_get_stream and mu_header_get_stream.
      Sergey Poznyakoff authored
    • * include/mailutils/header.h (mu_header_invalidate): New proto.
      * mailbox/header.c (mu_header_invalidate): New function.
      
      * libmu_argp/muinit.c (get_canonical_name): Avoid coredumping
      if argp_program_version is NULL.
      * mailbox/base64.c (mu_base64_decode): Fix inconsistent return
      code.
      * mailbox/debug.c (mu_debug_destroy): Allow for debug->stream == NULL.
      
      * mailbox/mapfile_stream.c (_mapfile_truncate): Incorrect size
      was used when unmapping.
      * mailbox/message.c (mu_message_create_copy): Use a temporary
      memory stream.
      (mu_message_get_body): Comment out the check for MESSAGE_INTERNAL_STREAM.
      (_message_get_stream): Initialize message header and body.
      
      * mailbox/progmailer.c (mu_progmailer_send): Check  return
      from the mu_header_get_streamref.
      
      * mailbox/stream.c (_stream_scandelim, _stream_readdelim): If
      size is 0, return MU_ERR_BUFSPACE.
      Sergey Poznyakoff authored
    • * include/mailutils/stream.h (mu_stream_skip_input_bytes): New proto.
      * mailbox/stream.c (mu_stream_skip_input_bytes): New function.
      * mailbox/fltstream.c (filter_seek): Re-implement on top of
      mu_stream_skip_input_bytes.
      (mu_filter_stream_create): Fix flag validity checking.
      
      * examples/base64.c: Add new option (-s) for testing seek operations
      on filters.
      Sergey Poznyakoff authored
    • * include/mailutils/libargp.h (mu_program_version_hook): New proto.
      * libmu_argp/Makefile.am (libmu_argp_a_SOURCES): Remove mu_argp.h.
      * libmu_argp/mu_argp.h: Remove.
      * libmu_argp/muinit.c [MU_ALPHA_RELEASE]: Include git-describe.h
      (mu_program_version_hook): New function.
      (mu_argp_init): Set mu_program_version_hook, unless vers is given.
      
      * comsat/comsat.c (main): Call mu_argp_init with NULL arguments.
      * config/mailutils-config.c: Likewise.
      * dotlock/dotlock.c: Likewise.
      * examples/muauth.c: Likewise.
      * frm/frm.c: Likewise.
      * frm/from.c: Likewise.
      * guimb/main.c: Likewise.
      * imap4d/imap4d.c: Likewise.
      * maidag/maidag.c: Likewise.
      * mail/mail.c: Likewise.
      * messages/messages.c: Likewise.
      * mimeview/mimeview.c: Likewise.
      * movemail/movemail.c: Likewise.
      * pop3d/pop3d.c: Likewise.
      * pop3d/popauth.c: Likewise.
      * readmsg/readmsg.c: Likewise.
      * sieve/sieve.c: Likewise.
      Sergey Poznyakoff authored
    • * .gitignore: Add git-describe and git-describe.h.
      * Makefile.am (MU_COND_LIBMU_CPP): Replaced with MU_COND_SUPPORT_CXX
      (SUBDIRS): Begin with .
      (EXTRA_DIST, BUILT_SOURCES): Add git-describe and git-describe.h.
      (git-describe, git-describe.h): New rules.
      (alpha, alphacheck): Use git-describe to produce additional suffix.
      * enable.m4 (MU_ENABLE_SUPPORT): Create an Automake condition.
      * configure.ac: Fix MU_ENABLE_SUPPORT calls.
      (--without-python): Replace with --disable-python.
      * examples/Makefile.am: Disable components based on MU_COND conditions.
      * libproto/Makefile.am: Likewise.
      * include/mailutils/Makefile.am (MU_COND_LIBMU_CPP): Replace with
      MU_COND_SUPPORT_CXX.
      
      * mailbox/nullrec.c: New file.
      * mailbox/Makefile.am (libmailutils_la_SOURCES): Add nullrec.c.
      
      * mail/decode.c: Remove unused variable.
      * mailbox/streamref.c: Likewise.
      Sergey Poznyakoff authored