From af04ed630f18e9003756317cc627a11084d0d59a Mon Sep 17 00:00:00 2001 From: Sergey Poznyakoff Date: Mon, 12 Oct 2009 21:14:00 +0300 Subject: Do not require Mailutils. Provide missing functions. * Makefile.am (ACLOCAL_AMFLAGS): Add grecs/am * bootstrap.conf: Skip po. Initialize submodule. * configure.ac: Mailutils no longer needed. (AC_CONFIG_FILES): Add new subdirs. * gnulib.modules: Add more modules. Arrange entries alphabetically. * lib/Makefile.am: Rename library to libpies. * lib/libpies.h (mf_privs) (switch_to_privs, get_user_groups) (mf_priv_setup, mf_epriv_setup): Move to src/pies.h (config_array_to_argv, config_array_to_string) (config_cb_timeout): Remove. (tokendef): New struct. (strtotok_len, strtotok_len_ci) (strtotok, strtotok_ci, toktostr): New prototypes. * lib/nls.c: Remove call to mu_init_nls. * src/acl.c: New file. * src/addrfmt.c: New file. * src/diag.c: New file. * src/meta.c: New file. * src/url.c: New file. * src/userprivs.c: New file. * src/acl.h: New file. * src/pp-setup: New file. * src/Makefile.am (pies_SOURCES): Add acl.c, addrfmt.c, diag.c, meta.c, url.c, userprivs.c. (noinst_HEADERS): Add acl.h. (inc_DATA): Add pp-setup. * src/limits.c, src/meta1gram.y, src/meta1lex.h, src/meta1lex.l, src/pies.c, src/pies.h, src/progman.c, src/socket.c, src/userprivs.c: Remove calls to functions from Mailutils. --- src/meta1lex.l | 83 ++++++++++++++++++++++++++++------------------------------ 1 file changed, 40 insertions(+), 43 deletions(-) (limited to 'src/meta1lex.l') diff --git a/src/meta1lex.l b/src/meta1lex.l index 312a1fd..0f08d87 100644 --- a/src/meta1lex.l +++ b/src/meta1lex.l @@ -1,6 +1,6 @@ %{ -/* MeTA1 configuration lexer for Mailfromd. - Copyright (C) 2008 Sergey Poznyakoff +/* MeTA1 configuration lexer for Pies. + Copyright (C) 2008, 2009 Sergey Poznyakoff 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 @@ -22,9 +22,10 @@ #include "meta1gram.h" #include "meta1lex.h" -mu_cfg_locus_t meta1_locus; +grecs_locus_t meta1_locus; size_t meta1_error_count; -mu_opool_t meta1_pool; +struct obstack meta1_stk; +int meta1_stk_init; char *meta1_queue_dir; #define yylval meta1lval @@ -98,7 +99,22 @@ yywrap () void meta1_line_add (const char *text, size_t len) { - mu_opool_append (meta1_pool, text, len); + obstack_grow (&meta1_stk, text, len); +} + +static char quote_transtab[] = "\\\\\"\"a\ab\bf\fn\nr\rt\tv\v"; + +static int +unescape_char (int c) +{ + char *p; + + for (p = quote_transtab; *p; p += 2) + { + if (*p == c) + return p[1]; + } + return c; } static void @@ -110,17 +126,17 @@ unescape_to_line (int c) t = '\v'; else { - t = mu_argcv_unquote_char (c); + t = unescape_char (c); if (t == c && t != '\\' && t != '\"') meta1_parse_error (_("unknown escape sequence '\\%c'"), c); } - mu_opool_append_char (meta1_pool, t); + obstack_1grow (&meta1_stk, t); } void meta1_line_add_unescape_last (const char *text, size_t len) { - mu_opool_append (meta1_pool, text, len - 2); + obstack_grow (&meta1_stk, text, len - 2); unescape_to_line (text[len - 1]); } @@ -129,24 +145,25 @@ meta1_line_add_unescape_hex (const char *text, size_t len) { for (; text[len-1] != 'x' && len > 0; len--) ; - mu_opool_append (meta1_pool, text, len - 2); - mu_opool_append_char (meta1_pool, (char) strtoul (text + len, NULL, 16)); + obstack_grow (&meta1_stk, text, len - 2); + obstack_1grow (&meta1_stk, (char) strtoul (text + len, NULL, 16)); } void meta1_line_begin () { - if (!meta1_pool) - mu_opool_create (&meta1_pool, 1); - else - mu_opool_clear (meta1_pool); + if (!meta1_stk_init) + { + obstack_init (&meta1_stk); + meta1_stk_init = 1; + } } char * meta1_line_finish () { - mu_opool_append_char (meta1_pool, 0); - return mu_opool_finish (meta1_pool, NULL); + obstack_1grow (&meta1_stk, 0); + return obstack_finish (&meta1_stk); } char * @@ -161,34 +178,23 @@ void meta1_parse_error (const char *fmt, ...) { va_list ap; - mu_debug_t debug; - mu_diag_get_debug (&debug); - mu_debug_printf (debug, 0, "%s:%lu: ", meta1_locus.file, + logmsg_printf (LOG_ERR, "%s:%lu: ", meta1_locus.file, (unsigned long) meta1_locus.line); va_start (ap, fmt); - mu_debug_vprintf (debug, 0, fmt, ap); - mu_debug_printf (debug, 0, "\n"); + logmsg_vprintf (LOG_ERR, fmt, ap); va_end (ap); + logmsg_printf (LOG_ERR, "\n"); meta1_error_count++; } void meta1_lexer_set_debug () { - mu_log_level_t lev = mu_global_debug_level ("meta1"); - yy_flex_debug = (lev & MU_DEBUG_LEVEL_MASK (MU_DEBUG_TRACE7)); + char *p = getenv ("META1_DEBUG_LEX"); + yy_flex_debug = p && (*p - '0') > 0; } -static int -_cfg_default_printer (void *unused, mu_log_level_t level, const char *str) -{ - fprintf (stderr, "%s", str); - return 0; -} - -mu_cfg_tree_t *meta1_parse_tree; - /* Parse MeTA1 configuration file `name'. Populate `meta1_parse_tree' with the parse tree. */ int @@ -200,7 +206,8 @@ meta1_config_parse (const char *name) fp = fopen (name, "r"); if (!fp) { - mu_error (_("%s: cannot open file: %s"), name, mu_strerror (errno)); + logmsg (LOG_ERR, + _("%s: cannot open file: %s"), name, strerror (errno)); return 1; } meta1_locus.file = meta1_string (name, strlen (name)); @@ -213,16 +220,6 @@ meta1_config_parse (const char *name) fclose (fp); if (meta1_error_count) rc = 1; - if (rc == 0) - { - meta1_parse_tree = mu_alloc (sizeof (*meta1_parse_tree)); - mu_debug_create (&meta1_parse_tree->debug, NULL); - mu_debug_set_print (meta1_parse_tree->debug, _cfg_default_printer, NULL); - mu_debug_set_level (meta1_parse_tree->debug, - mu_global_debug_level ("meta1")); - meta1_parse_tree->node = meta1_parse_head; - meta1_parse_tree->pool = meta1_pool; - } return rc; } -- cgit v1.2.1