commit-mailutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[SCM] GNU Mailutils branch, master, updated. mu-1-2-90-separate-argp-cfg


From: Sergey Poznyakoff
Subject: [SCM] GNU Mailutils branch, master, updated. mu-1-2-90-separate-argp-cfg-255-g8826030
Date: Fri, 27 Mar 2009 14:37:16 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU Mailutils".

http://git.savannah.gnu.org/cgit/mailutils.git/commit/?id=88260300b2288f9a2515bbf94339a949fea2c425

The branch, master has been updated
       via  88260300b2288f9a2515bbf94339a949fea2c425 (commit)
      from  40fffffb6c6b5b10642428408f49bec401668f68 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 88260300b2288f9a2515bbf94339a949fea2c425
Author: Sergey Poznyakoff <address@hidden>
Date:   Fri Mar 27 16:36:52 2009 +0200

    Implement guile output redirection in maidag
    
    * libmu_scm/mu_guimb.c: Remove
    * libmu_scm/mu_dbgport.c: New file.
    * libmu_scm/Makefile.am: Update.
    * include/mailutils/guile.h (mu_process_mailbox): Remove.
    (mu_scm_make_debug_port, mu_scm_debug_port_init): New prototypes.
    * libmu_scm/mu_scm.c (mu_scm_init): Call mu_scm_debug_port_init.
    * maidag/guile.c (scheme_check_msg): Redirect error/output to MU port.
    
    * mailbox/mutil.c (mu_expand_path_pattern): Expand ~.

-----------------------------------------------------------------------

Summary of changes:
 include/mailutils/guile.h |    4 +-
 libmu_scm/Makefile.am     |    4 +-
 libmu_scm/mu_dbgport.c    |  119 +++++++++++++++++++++++++++++++++++++++++++++
 libmu_scm/mu_guimb.c      |   78 -----------------------------
 libmu_scm/mu_scm.c        |    2 +
 maidag/guile.c            |   11 ++++
 mailbox/mutil.c           |   58 ++++++++++++----------
 7 files changed, 167 insertions(+), 109 deletions(-)
 create mode 100644 libmu_scm/mu_dbgport.c
 delete mode 100644 libmu_scm/mu_guimb.c

diff --git a/include/mailutils/guile.h b/include/mailutils/guile.h
index cdc9c09..c9e8972 100644
--- a/include/mailutils/guile.h
+++ b/include/mailutils/guile.h
@@ -71,8 +71,10 @@ extern void mu_scm_message_add_owner (SCM MESG, SCM owner);
 
 extern void mu_scm_mutil_init (void);
 
-extern void mu_process_mailbox (int argc, char *argv[], mu_guimb_param_t 
*param);
+SCM mu_scm_make_debug_port (mu_debug_t debug, mu_log_level_t level);
+void mu_scm_debug_port_init (void);
 
+  
 extern void mu_guile_init (int debug);
 extern int mu_guile_load (char *filename, int argc, char **argv);
 extern int mu_guile_eval (const char *string);
diff --git a/libmu_scm/Makefile.am b/libmu_scm/Makefile.am
index 282d262..c0ba41f 100644
--- a/libmu_scm/Makefile.am
+++ b/libmu_scm/Makefile.am
@@ -26,8 +26,8 @@ EXTRA_LTLIBRARIES=libmu_scm.la
 C_SRCS=\
  mu_address.c\
  mu_body.c\
+ mu_dbgport.c\
  mu_guile.c\
- mu_guimb.c\
  mu_mailbox.c\
  mu_message.c\
  mu_mime.c\
@@ -61,7 +61,6 @@ address@hidden@
 DOT_X_FILES=\
  mu_address.x\
  mu_body.x\
- mu_guimb.x\
  mu_mailbox.x\
  mu_message.x\
  mu_mime.x\
@@ -73,7 +72,6 @@ DOT_X_FILES=\
 DOT_DOC_FILES=\
  mu_address.doc\
  mu_body.doc\
- mu_guimb.doc\
  mu_mailbox.doc\
  mu_message.doc\
  mu_mime.doc\
diff --git a/libmu_scm/mu_dbgport.c b/libmu_scm/mu_dbgport.c
new file mode 100644
index 0000000..0d0ffd7
--- /dev/null
+++ b/libmu_scm/mu_dbgport.c
@@ -0,0 +1,119 @@
+/* GNU Mailutils -- a suite of utilities for electronic mail
+   Copyright (C) 2009 Free Software Foundation, Inc.
+
+   This library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 3 of the License, or (at your option) any later version.
+
+   This library 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
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General
+   Public License along with this library; if not, write to the
+   Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+   Boston, MA 02110-1301 USA */
+
+#include "mu_scm.h"
+
+struct _mu_debug_port
+{
+  mu_debug_t      debug;
+  mu_log_level_t  level;
+};
+
+static long     scm_tc16_mu_debug_port;
+
+SCM
+mu_scm_make_debug_port (mu_debug_t debug, mu_log_level_t level)
+{
+  struct _mu_debug_port *dp;
+  SCM             port;
+  scm_port       *pt;
+
+  dp = scm_gc_malloc (sizeof (struct _mu_debug_port), "mu-debug-port");
+  dp->debug = debug;
+  dp->level = level;
+  port = scm_cell (scm_tc16_mu_debug_port, 0);
+  pt = scm_add_to_port_table (port);
+  SCM_SETPTAB_ENTRY (port, pt);
+  pt->rw_random = 0;
+  SCM_SET_CELL_TYPE (port,
+                    (scm_tc16_mu_debug_port | SCM_OPN | SCM_WRTNG |
+                     SCM_BUF0));
+  SCM_SETSTREAM (port, dp);
+  return port;
+}
+
+#define MU_DEBUG_PORT(x) ((struct _mu_debug_port *) SCM_STREAM (x))
+
+static SCM
+_mu_debug_port_mark (SCM port)
+{
+  return SCM_BOOL_F;
+}
+
+static void
+_mu_debug_port_flush (SCM port)
+{
+  struct _mu_debug_port *dp = MU_DEBUG_PORT (port);
+
+  /* FIXME: */
+}
+
+static int
+_mu_debug_port_close (SCM port)
+{
+  struct _mu_debug_port *dp = MU_DEBUG_PORT (port);
+
+  if (dp)
+    {
+      _mu_debug_port_flush (port);
+      SCM_SETSTREAM (port, NULL);
+      scm_gc_free (dp, sizeof (struct _mu_debug_port), "mu-debug-port");
+    }
+  return 0;
+}
+
+static scm_sizet
+_mu_debug_port_free (SCM port)
+{
+  _mu_debug_port_close (port);
+  return 0;
+}
+
+static int
+_mu_debug_port_fill_input (SCM port)
+{
+  return EOF;
+}
+
+static void
+_mu_debug_port_write (SCM port, const void *data, size_t size)
+{
+  struct _mu_debug_port *dp = MU_DEBUG_PORT (port);
+
+  mu_debug_printf (dp->debug, dp->level, "%.*s", size, (const char *)data);
+}
+
+static int
+_mu_debug_port_print (SCM exp, SCM port, scm_print_state * pstate)
+{
+  scm_puts ("#<Mailutis debug port>", port);
+  return 1;
+}
+
+void
+mu_scm_debug_port_init ()
+{
+  scm_tc16_mu_debug_port = scm_make_port_type ("mu-debug-port",
+                                              _mu_debug_port_fill_input,
+                                              _mu_debug_port_write);
+  scm_set_port_mark (scm_tc16_mu_debug_port, _mu_debug_port_mark);
+  scm_set_port_free (scm_tc16_mu_debug_port, _mu_debug_port_free);
+  scm_set_port_print (scm_tc16_mu_debug_port, _mu_debug_port_print);
+  scm_set_port_flush (scm_tc16_mu_debug_port, _mu_debug_port_flush);
+  scm_set_port_close (scm_tc16_mu_debug_port, _mu_debug_port_close);
+}
diff --git a/libmu_scm/mu_guimb.c b/libmu_scm/mu_guimb.c
deleted file mode 100644
index 3d266ed..0000000
--- a/libmu_scm/mu_guimb.c
+++ /dev/null
@@ -1,78 +0,0 @@
-/* GNU Mailutils -- a suite of utilities for electronic mail
-   Copyright (C) 1999, 2000, 2001, 2007 Free Software Foundation, Inc.
-
-   This library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 3 of the License, or (at your option) any later version.
-
-   This library 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
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General
-   Public License along with this library; if not, write to the
-   Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-   Boston, MA 02110-1301 USA */
-
-#include "mu_scm.h"
-
-static void _scheme_main (void *closure, int argc, char **argv);
-
-void
-mu_process_mailbox (int argc, char *argv[], mu_guimb_param_t *param)
-{
-  scm_boot_guile (argc, argv, _scheme_main, param);
-}
-
-SCM _current_mailbox;
-SCM _user_name;
-
-static SCM
-catch_body (void *closure)
-{
-  mu_guimb_param_t *param = closure;
-  return param->catch_body (param->data, param->mbox);
-}
-
-void
-_scheme_main (void *closure, int argc, char **argv)
-{
-  mu_guimb_param_t *param = closure;
-  
-  if (param->debug_guile)
-    {
-      SCM_DEVAL_P = 1;
-      SCM_BACKTRACE_P = 1;
-      SCM_RECORD_POSITIONS_P = 1;
-      SCM_RESET_DEBUG_MODE;
-    }
-
-/* Initialize scheme library */
-  mu_scm_init ();
-
-  /* Provide basic primitives */
-#include <mu_guimb.x>
-
-  _current_mailbox = mu_scm_mailbox_create (param->mbox);
-  mu_set_variable ("current-mailbox", _current_mailbox);
-
-  _user_name = param->user_name ?
-                       scm_makfrom0str (param->user_name) : SCM_BOOL_F;
-  mu_set_variable ("user-name", _user_name);
-
-  if (param->init) 
-    param->init (param->data);
-  
-  do {
-    scm_internal_lazy_catch (SCM_BOOL_T,
-                            catch_body, closure,
-                            param->catch_handler, param->data);
-  } while (param->next && param->next (param->data, param->mbox));
-
-  if (param->exit)
-    exit (param->exit (param->data, param->mbox));
-
-  exit (0);
-}
diff --git a/libmu_scm/mu_scm.c b/libmu_scm/mu_scm.c
index 187d8bc..7cec22a 100644
--- a/libmu_scm/mu_scm.c
+++ b/libmu_scm/mu_scm.c
@@ -217,6 +217,8 @@ mu_scm_init ()
   mu_scm_logger_init ();
   mu_scm_port_init ();
   mu_scm_mime_init ();
+  mu_scm_debug_port_init ();
+  
 #include "mu_scm.x"
 
   mu_registrar_record (MU_DEFAULT_RECORD);
diff --git a/maidag/guile.c b/maidag/guile.c
index 9e2b193..ce374be 100644
--- a/maidag/guile.c
+++ b/maidag/guile.c
@@ -32,6 +32,17 @@ scheme_check_msg (mu_message_t msg, struct mu_auth_data 
*auth,
   if (!initialized)
     {
       mu_guile_init (debug_guile);
+      if (!log_to_stderr)
+       {
+         mu_debug_t debug;
+         SCM port;
+         
+         mu_diag_get_debug (&debug);
+         port = mu_scm_make_debug_port (debug, MU_DIAG_ERROR);
+         scm_set_current_error_port(port);
+         port = mu_scm_make_debug_port (debug, MU_DIAG_INFO);
+         scm_set_current_output_port(port);
+       }
       initialized = 1;
     }
   mu_guile_load (prog, 0, NULL);
diff --git a/mailbox/mutil.c b/mailbox/mutil.c
index 31a5e94..df0b9f7 100644
--- a/mailbox/mutil.c
+++ b/mailbox/mutil.c
@@ -819,10 +819,10 @@ mu_unroll_symlink (char *out, size_t outsz, const char 
*in)
 char *
 mu_expand_path_pattern (const char *pattern, const char *username)
 {
-  const char *p, *startp;
+  const char *p;
   char *q;
   char *path;
-  int len = 0;
+  size_t len = 0;
   struct mu_auth_data *auth = NULL;
   
   for (p = pattern; *p; p++)
@@ -869,39 +869,43 @@ mu_expand_path_pattern (const char *pattern, const char 
*username)
   if (!path)
     return NULL;
 
-  startp = pattern;
+  p = pattern;
   q = path;
-  while (*startp && (p = strchr (startp, '%')) != NULL)
+  while (*p)
     {
-      memcpy (q, startp, p - startp);
-      q += p - startp;
-      switch (*++p)
+      size_t off = strcspn (p, "~%");
+      memcpy (q, p, off);
+      q += off;
+      p += off;
+      if (*p == '~')
        {
-       case 'u':
-         strcpy (q, username);
-         q += strlen (username);
-         break;
-         
-       case 'h':
          strcpy (q, auth->dir);
          q += strlen (auth->dir);
-         break;
+         p++;
+       }
+      else if (*p)
+       switch (*++p)
+         {
+         case 'u':
+           strcpy (q, username);
+           q += strlen (username);
+           break;
+           
+         case 'h':
+           strcpy (q, auth->dir);
+           q += strlen (auth->dir);
+           break;
          
-       case '%':
-         *q++ = '%';
-         break;
+         case '%':
+           *q++ = '%';
+           break;
          
-       default:
-         *q++ = '%';
-         *q++ = *p;
-       }
-      startp = p + 1;
-    }
-  if (*startp)
-    {
-      strcpy (q, startp);
-      q += strlen (startp);
+         default:
+           *q++ = '%';
+           *q++ = *p;
+         }
     }
+
   *q = 0;
   if (auth)
     mu_auth_data_free (auth);


hooks/post-receive
--
GNU Mailutils




reply via email to

[Prev in Thread] Current Thread [Next in Thread]