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.
Showing
7 changed files
with
111 additions
and
6 deletions
... | @@ -326,9 +326,13 @@ const char *mu_sieve_type_str (mu_sieve_data_type type); | ... | @@ -326,9 +326,13 @@ const char *mu_sieve_type_str (mu_sieve_data_type type); |
326 | /* Principal entry points */ | 326 | /* Principal entry points */ |
327 | 327 | ||
328 | int mu_sieve_compile (mu_sieve_machine_t mach, const char *name); | 328 | int mu_sieve_compile (mu_sieve_machine_t mach, const char *name); |
329 | int mu_sieve_compile_text (mu_sieve_machine_t mach, | ||
330 | const char *buf, size_t bufsize, | ||
331 | struct mu_locus_point const *pt); | ||
329 | int mu_sieve_compile_buffer (mu_sieve_machine_t mach, | 332 | int mu_sieve_compile_buffer (mu_sieve_machine_t mach, |
330 | const char *buf, int bufsize, | 333 | const char *buf, int bufsize, |
331 | struct mu_locus_point const *pt); | 334 | const char *fname, int line) |
335 | MU_DEPRECATED; | ||
332 | int mu_sieve_mailbox (mu_sieve_machine_t mach, mu_mailbox_t mbox); | 336 | int mu_sieve_mailbox (mu_sieve_machine_t mach, mu_mailbox_t mbox); |
333 | int mu_sieve_message (mu_sieve_machine_t mach, mu_message_t message); | 337 | int mu_sieve_message (mu_sieve_machine_t mach, mu_message_t message); |
334 | int mu_sieve_disass (mu_sieve_machine_t mach); | 338 | int mu_sieve_disass (mu_sieve_machine_t mach); | ... | ... |
... | @@ -107,7 +107,19 @@ enum mu_buffer_type | ... | @@ -107,7 +107,19 @@ enum mu_buffer_type |
107 | #define MU_IOCTL_LOGSTREAM_GET_SEVERITY 0 | 107 | #define MU_IOCTL_LOGSTREAM_GET_SEVERITY 0 |
108 | #define MU_IOCTL_LOGSTREAM_SET_SEVERITY 1 | 108 | #define MU_IOCTL_LOGSTREAM_SET_SEVERITY 1 |
109 | 109 | ||
110 | /* Codes 2 and 3 are reserved */ | 110 | /* The following two subcommands are deprecated and provided for |
111 | backward compatibility. Please use the MU_IOCTL_LOGSTREAM_GET_LOCUS_RANGE | ||
112 | and MU_IOCTL_LOGSTREAM_SET_LOCUS_RANGE instead. */ | ||
113 | /* Get or set locus. | ||
114 | Arg: struct mu_locus_DEPRECATED * | ||
115 | */ | ||
116 | #define MU_IOCTL_LOGSTREAM_GET_LOCUS_DEPRECATED 2 | ||
117 | #define MU_IOCTL_LOGSTREAM_SET_LOCUS_DEPRECATED 3 | ||
118 | |||
119 | int mu_ioctl_logstream_get_locus_deprecated (void) MU_DEPRECATED; | ||
120 | #define MU_IOCTL_LOGSTREAM_GET_LOCUS mu_ioctl_logstream_get_locus_deprecated () | ||
121 | int mu_ioctl_logstream_set_locus_deprecated (void) MU_DEPRECATED; | ||
122 | #define MU_IOCTL_LOGSTREAM_SET_LOCUS mu_ioctl_logstream_set_locus_deprecated () | ||
111 | 123 | ||
112 | /* Get or set log mode. | 124 | /* Get or set log mode. |
113 | Arg: int * | 125 | Arg: int * | ... | ... |
... | @@ -149,6 +149,16 @@ typedef unsigned int mu_debug_level_t; | ... | @@ -149,6 +149,16 @@ typedef unsigned int mu_debug_level_t; |
149 | 149 | ||
150 | #define MU_DEFAULT_RECORD _MU_DEFAULT_RECORD_ | 150 | #define MU_DEFAULT_RECORD _MU_DEFAULT_RECORD_ |
151 | 151 | ||
152 | /* The use of this structure and associated ioctl is deprecated. This | ||
153 | definition is provided for transition period */ | ||
154 | struct mu_locus_DEPRECATED | ||
155 | { | ||
156 | char *mu_file; | ||
157 | unsigned mu_line; | ||
158 | unsigned mu_col; | ||
159 | }; | ||
160 | #define mu_locus mu_locus_DEPRECATED | ||
161 | |||
152 | #ifdef __cplusplus | 162 | #ifdef __cplusplus |
153 | } | 163 | } |
154 | #endif | 164 | #endif | ... | ... |
... | @@ -480,6 +480,48 @@ _log_ctl (struct _mu_stream *str, int code, int opcode, void *arg) | ... | @@ -480,6 +480,48 @@ _log_ctl (struct _mu_stream *str, int code, int opcode, void *arg) |
480 | } | 480 | } |
481 | break; | 481 | break; |
482 | 482 | ||
483 | case MU_IOCTL_LOGSTREAM_GET_LOCUS_DEPRECATED: | ||
484 | if (!arg) | ||
485 | return EINVAL; | ||
486 | else | ||
487 | { | ||
488 | struct mu_locus_DEPRECATED *ploc = arg; | ||
489 | if (sp->locrange.beg.mu_file) | ||
490 | { | ||
491 | ploc->mu_file = strdup (sp->locrange.beg.mu_file); | ||
492 | if (!ploc->mu_file) | ||
493 | return ENOMEM; | ||
494 | } | ||
495 | else | ||
496 | ploc->mu_file = NULL; | ||
497 | ploc->mu_line = sp->locrange.beg.mu_line; | ||
498 | ploc->mu_col = sp->locrange.beg.mu_col; | ||
499 | } | ||
500 | break; | ||
501 | |||
502 | case MU_IOCTL_LOGSTREAM_SET_LOCUS_DEPRECATED: | ||
503 | { | ||
504 | struct mu_locus_DEPRECATED *ploc = arg; | ||
505 | |||
506 | mu_ident_deref (sp->locrange.end.mu_file); | ||
507 | sp->locrange.end.mu_file = NULL; | ||
508 | if (arg) | ||
509 | { | ||
510 | status = lr_set_file (&sp->locrange, ploc->mu_file, 0, 0); | ||
511 | if (status) | ||
512 | return status; | ||
513 | lr_set_line (&sp->locrange, ploc->mu_line, 0); | ||
514 | lr_set_col (&sp->locrange, ploc->mu_col, 0); | ||
515 | } | ||
516 | else | ||
517 | { | ||
518 | mu_ident_deref (sp->locrange.beg.mu_file); | ||
519 | sp->locrange.beg.mu_file = NULL; | ||
520 | } | ||
521 | |||
522 | break; | ||
523 | } | ||
524 | |||
483 | case MU_IOCTL_LOGSTREAM_SET_LOCUS_LINE: | 525 | case MU_IOCTL_LOGSTREAM_SET_LOCUS_LINE: |
484 | if (!arg) | 526 | if (!arg) |
485 | return EINVAL; | 527 | return EINVAL; |
... | @@ -607,4 +649,28 @@ mu_log_stream_create (mu_stream_t *pstr, mu_stream_t transport) | ... | @@ -607,4 +649,28 @@ mu_log_stream_create (mu_stream_t *pstr, mu_stream_t transport) |
607 | return 0; | 649 | return 0; |
608 | } | 650 | } |
609 | 651 | ||
652 | int | ||
653 | mu_ioctl_logstream_get_locus_deprecated (void) | ||
654 | { | ||
655 | static int warned; | ||
656 | if (!warned) | ||
657 | { | ||
658 | mu_error (_("the program uses MU_IOCTL_LOGSTREAM_GET_LOCUS, which is deprecated")); | ||
659 | warned = 1; | ||
660 | } | ||
661 | return MU_IOCTL_LOGSTREAM_GET_LOCUS_DEPRECATED; | ||
662 | } | ||
663 | |||
664 | int | ||
665 | mu_ioctl_logstream_set_locus_deprecated (void) | ||
666 | { | ||
667 | static int warned; | ||
668 | if (!warned) | ||
669 | { | ||
670 | mu_error (_("program uses MU_IOCTL_LOGSTREAM_SET_LOCUS, which is deprecated")); | ||
671 | warned = 1; | ||
672 | } | ||
673 | return MU_IOCTL_LOGSTREAM_SET_LOCUS_DEPRECATED; | ||
674 | } | ||
675 | |||
610 | 676 | ... | ... |
... | @@ -113,7 +113,7 @@ moderator_filter_message (mu_sieve_machine_t mach, | ... | @@ -113,7 +113,7 @@ moderator_filter_message (mu_sieve_machine_t mach, |
113 | return 1; | 113 | return 1; |
114 | } | 114 | } |
115 | mu_sieve_get_locus (mach, &locrange); | 115 | mu_sieve_get_locus (mach, &locrange); |
116 | rc = mu_sieve_compile_buffer (newmach, | 116 | rc = mu_sieve_compile_text (newmach, |
117 | arg, strlen (arg), | 117 | arg, strlen (arg), |
118 | &locrange.beg); | 118 | &locrange.beg); |
119 | if (rc) | 119 | if (rc) | ... | ... |
... | @@ -1568,8 +1568,8 @@ sieve_compile_strbuf (void *name) | ... | @@ -1568,8 +1568,8 @@ sieve_compile_strbuf (void *name) |
1568 | } | 1568 | } |
1569 | 1569 | ||
1570 | int | 1570 | int |
1571 | mu_sieve_compile_buffer (mu_sieve_machine_t mach, | 1571 | mu_sieve_compile_text (mu_sieve_machine_t mach, |
1572 | const char *str, int strsize, | 1572 | const char *str, size_t strsize, |
1573 | struct mu_locus_point const *loc) | 1573 | struct mu_locus_point const *loc) |
1574 | { | 1574 | { |
1575 | struct strbuf buf; | 1575 | struct strbuf buf; |
... | @@ -1579,6 +1579,19 @@ mu_sieve_compile_buffer (mu_sieve_machine_t mach, | ... | @@ -1579,6 +1579,19 @@ mu_sieve_compile_buffer (mu_sieve_machine_t mach, |
1579 | return with_machine (mach, sieve_compile_strbuf, &buf); | 1579 | return with_machine (mach, sieve_compile_strbuf, &buf); |
1580 | } | 1580 | } |
1581 | 1581 | ||
1582 | int | ||
1583 | mu_sieve_compile_buffer (mu_sieve_machine_t mach, | ||
1584 | const char *buf, int bufsize, | ||
1585 | const char *fname, int line) | ||
1586 | { | ||
1587 | int rc; | ||
1588 | struct mu_locus_point loc; | ||
1589 | mu_locus_point_init (&loc, fname); | ||
1590 | loc.mu_line = line; | ||
1591 | rc = mu_sieve_compile_text (mach, buf, bufsize, &loc); | ||
1592 | mu_locus_point_deinit (&loc); | ||
1593 | return rc; | ||
1594 | } | ||
1582 | 1595 | ||
1583 | 1596 | ||
1584 | 1597 | ... | ... |
... | @@ -500,7 +500,7 @@ main (int argc, char *argv[]) | ... | @@ -500,7 +500,7 @@ main (int argc, char *argv[]) |
500 | pt.mu_file = "stdin"; | 500 | pt.mu_file = "stdin"; |
501 | pt.mu_line = 1; | 501 | pt.mu_line = 1; |
502 | pt.mu_col = 0; | 502 | pt.mu_col = 0; |
503 | rc = mu_sieve_compile_buffer (mach, script, strlen (script), &pt); | 503 | rc = mu_sieve_compile_text (mach, script, strlen (script), &pt); |
504 | } | 504 | } |
505 | else | 505 | else |
506 | rc = mu_sieve_compile (mach, script); | 506 | rc = mu_sieve_compile (mach, script); | ... | ... |
-
Please register or sign in to post a comment