diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2017-06-14 15:04:17 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2017-06-14 15:04:17 +0300 |
commit | 7ae106db9767abe3f7716a50bb8b189e47083efe (patch) | |
tree | c293d8678bb0da4e81c22ce3cdf2bf7ff5dca411 | |
parent | 1dbebc4d49b15e4715ab01f4e23a76cb713c90d3 (diff) | |
download | mailutils-7ae106db9767abe3f7716a50bb8b189e47083efe.tar.gz mailutils-7ae106db9767abe3f7716a50bb8b189e47083efe.tar.bz2 |
Provide backward compatibility layer for deprecated functions.
* include/mailutils/sieve.h (mu_sieve_compile_text): New proto.
(mu_sieve_compile_buffer): Backward-compatible proto.
* include/mailutils/stream.h ((MU_IOCTL_LOGSTREAM_GET_LOCUS_DEPRECATED)
(MU_IOCTL_LOGSTREAM_SET_LOCUS_DEPRECATED): New defines.
(MU_IOCTL_LOGSTREAM_GET_LOCUS)
(MU_IOCTL_LOGSTREAM_SET_LOCUS): Use external functions to make
sure any references to these are marked as deprecated.
* include/mailutils/types.hin (mu_locus_DEPRECATED): New struct.
(mu_locus): Define to mu_locus_DEPRECATED
* libmailutils/stream/logstream.c (_log_ctl): Handle the deprecated
ctls.
* libmu_sieve/extensions/moderator.c (moderator_filter_message): Use
mu_sieve_compile_text.
* libmu_sieve/sieve-gram.y (mu_sieve_compile_buffer): Rename to
mu_sieve_compile_text. Re-introduce it as a backward-compatibility
API.
* sieve/sieve.c: Call mu_sieve_compile_text instead of
mu_sieve_compile_buffer.
-rw-r--r-- | include/mailutils/sieve.h | 6 | ||||
-rw-r--r-- | include/mailutils/stream.h | 16 | ||||
-rw-r--r-- | include/mailutils/types.hin | 10 | ||||
-rw-r--r-- | libmailutils/stream/logstream.c | 66 | ||||
-rw-r--r-- | libmu_sieve/extensions/moderator.c | 6 | ||||
-rw-r--r-- | libmu_sieve/sieve-gram.y | 19 | ||||
-rw-r--r-- | sieve/sieve.c | 2 |
7 files changed, 115 insertions, 10 deletions
diff --git a/include/mailutils/sieve.h b/include/mailutils/sieve.h index 99d328286..63d81c7d4 100644 --- a/include/mailutils/sieve.h +++ b/include/mailutils/sieve.h @@ -326,9 +326,13 @@ const char *mu_sieve_type_str (mu_sieve_data_type type); /* Principal entry points */ int mu_sieve_compile (mu_sieve_machine_t mach, const char *name); +int mu_sieve_compile_text (mu_sieve_machine_t mach, + const char *buf, size_t bufsize, + struct mu_locus_point const *pt); int mu_sieve_compile_buffer (mu_sieve_machine_t mach, const char *buf, int bufsize, - struct mu_locus_point const *pt); + const char *fname, int line) + MU_DEPRECATED; int mu_sieve_mailbox (mu_sieve_machine_t mach, mu_mailbox_t mbox); int mu_sieve_message (mu_sieve_machine_t mach, mu_message_t message); int mu_sieve_disass (mu_sieve_machine_t mach); diff --git a/include/mailutils/stream.h b/include/mailutils/stream.h index 50cffc591..4e82b9239 100644 --- a/include/mailutils/stream.h +++ b/include/mailutils/stream.h @@ -106,8 +106,20 @@ enum mu_buffer_type */ #define MU_IOCTL_LOGSTREAM_GET_SEVERITY 0 #define MU_IOCTL_LOGSTREAM_SET_SEVERITY 1 - - /* Codes 2 and 3 are reserved */ + + /* The following two subcommands are deprecated and provided for + backward compatibility. Please use the MU_IOCTL_LOGSTREAM_GET_LOCUS_RANGE + and MU_IOCTL_LOGSTREAM_SET_LOCUS_RANGE instead. */ + /* Get or set locus. + Arg: struct mu_locus_DEPRECATED * + */ +#define MU_IOCTL_LOGSTREAM_GET_LOCUS_DEPRECATED 2 +#define MU_IOCTL_LOGSTREAM_SET_LOCUS_DEPRECATED 3 + +int mu_ioctl_logstream_get_locus_deprecated (void) MU_DEPRECATED; +#define MU_IOCTL_LOGSTREAM_GET_LOCUS mu_ioctl_logstream_get_locus_deprecated () +int mu_ioctl_logstream_set_locus_deprecated (void) MU_DEPRECATED; +#define MU_IOCTL_LOGSTREAM_SET_LOCUS mu_ioctl_logstream_set_locus_deprecated () /* Get or set log mode. Arg: int * diff --git a/include/mailutils/types.hin b/include/mailutils/types.hin index cc7709c9c..fa729fbb5 100644 --- a/include/mailutils/types.hin +++ b/include/mailutils/types.hin @@ -149,6 +149,16 @@ typedef unsigned int mu_debug_level_t; #define MU_DEFAULT_RECORD _MU_DEFAULT_RECORD_ +/* The use of this structure and associated ioctl is deprecated. This + definition is provided for transition period */ +struct mu_locus_DEPRECATED +{ + char *mu_file; + unsigned mu_line; + unsigned mu_col; +}; +#define mu_locus mu_locus_DEPRECATED + #ifdef __cplusplus } #endif diff --git a/libmailutils/stream/logstream.c b/libmailutils/stream/logstream.c index 010cd9310..e79b27514 100644 --- a/libmailutils/stream/logstream.c +++ b/libmailutils/stream/logstream.c @@ -480,6 +480,48 @@ _log_ctl (struct _mu_stream *str, int code, int opcode, void *arg) } break; + case MU_IOCTL_LOGSTREAM_GET_LOCUS_DEPRECATED: + if (!arg) + return EINVAL; + else + { + struct mu_locus_DEPRECATED *ploc = arg; + if (sp->locrange.beg.mu_file) + { + ploc->mu_file = strdup (sp->locrange.beg.mu_file); + if (!ploc->mu_file) + return ENOMEM; + } + else + ploc->mu_file = NULL; + ploc->mu_line = sp->locrange.beg.mu_line; + ploc->mu_col = sp->locrange.beg.mu_col; + } + break; + + case MU_IOCTL_LOGSTREAM_SET_LOCUS_DEPRECATED: + { + struct mu_locus_DEPRECATED *ploc = arg; + + mu_ident_deref (sp->locrange.end.mu_file); + sp->locrange.end.mu_file = NULL; + if (arg) + { + status = lr_set_file (&sp->locrange, ploc->mu_file, 0, 0); + if (status) + return status; + lr_set_line (&sp->locrange, ploc->mu_line, 0); + lr_set_col (&sp->locrange, ploc->mu_col, 0); + } + else + { + mu_ident_deref (sp->locrange.beg.mu_file); + sp->locrange.beg.mu_file = NULL; + } + + break; + } + case MU_IOCTL_LOGSTREAM_SET_LOCUS_LINE: if (!arg) return EINVAL; @@ -606,5 +648,29 @@ mu_log_stream_create (mu_stream_t *pstr, mu_stream_t transport) return 0; } + +int +mu_ioctl_logstream_get_locus_deprecated (void) +{ + static int warned; + if (!warned) + { + mu_error (_("the program uses MU_IOCTL_LOGSTREAM_GET_LOCUS, which is deprecated")); + warned = 1; + } + return MU_IOCTL_LOGSTREAM_GET_LOCUS_DEPRECATED; +} + +int +mu_ioctl_logstream_set_locus_deprecated (void) +{ + static int warned; + if (!warned) + { + mu_error (_("program uses MU_IOCTL_LOGSTREAM_SET_LOCUS, which is deprecated")); + warned = 1; + } + return MU_IOCTL_LOGSTREAM_SET_LOCUS_DEPRECATED; +} diff --git a/libmu_sieve/extensions/moderator.c b/libmu_sieve/extensions/moderator.c index 2584f206c..510c00f54 100644 --- a/libmu_sieve/extensions/moderator.c +++ b/libmu_sieve/extensions/moderator.c @@ -113,9 +113,9 @@ moderator_filter_message (mu_sieve_machine_t mach, return 1; } mu_sieve_get_locus (mach, &locrange); - rc = mu_sieve_compile_buffer (newmach, - arg, strlen (arg), - &locrange.beg); + rc = mu_sieve_compile_text (newmach, + arg, strlen (arg), + &locrange.beg); if (rc) mu_sieve_error (mach, _("cannot compile subprogram")); } diff --git a/libmu_sieve/sieve-gram.y b/libmu_sieve/sieve-gram.y index bf3db2442..077011ece 100644 --- a/libmu_sieve/sieve-gram.y +++ b/libmu_sieve/sieve-gram.y @@ -1568,9 +1568,9 @@ sieve_compile_strbuf (void *name) } int -mu_sieve_compile_buffer (mu_sieve_machine_t mach, - const char *str, int strsize, - struct mu_locus_point const *loc) +mu_sieve_compile_text (mu_sieve_machine_t mach, + const char *str, size_t strsize, + struct mu_locus_point const *loc) { struct strbuf buf; buf.ptr = str; @@ -1579,6 +1579,19 @@ mu_sieve_compile_buffer (mu_sieve_machine_t mach, return with_machine (mach, sieve_compile_strbuf, &buf); } +int +mu_sieve_compile_buffer (mu_sieve_machine_t mach, + const char *buf, int bufsize, + const char *fname, int line) +{ + int rc; + struct mu_locus_point loc; + mu_locus_point_init (&loc, fname); + loc.mu_line = line; + rc = mu_sieve_compile_text (mach, buf, bufsize, &loc); + mu_locus_point_deinit (&loc); + return rc; +} diff --git a/sieve/sieve.c b/sieve/sieve.c index 32c044fa7..6d718e078 100644 --- a/sieve/sieve.c +++ b/sieve/sieve.c @@ -500,7 +500,7 @@ main (int argc, char *argv[]) pt.mu_file = "stdin"; pt.mu_line = 1; pt.mu_col = 0; - rc = mu_sieve_compile_buffer (mach, script, strlen (script), &pt); + rc = mu_sieve_compile_text (mach, script, strlen (script), &pt); } else rc = mu_sieve_compile (mach, script); |