(builtin_unre): Use munre_subject()
(builtin_isreply,builtin_reply_regex): New functions
Showing
1 changed file
with
33 additions
and
30 deletions
... | @@ -1794,37 +1794,10 @@ builtin_putaddr (struct mh_machine *mach) | ... | @@ -1794,37 +1794,10 @@ builtin_putaddr (struct mh_machine *mach) |
1794 | static void | 1794 | static void |
1795 | builtin_unre (struct mh_machine *mach) | 1795 | builtin_unre (struct mh_machine *mach) |
1796 | { | 1796 | { |
1797 | char *start, *p; | 1797 | char *p; |
1798 | 1798 | int rc = munre_subject (strobj_ptr (&mach->arg_str), &p); | |
1799 | for (p = strobj_ptr (&mach->arg_str); *p; p++) | 1799 | if (rc == 0 && p != strobj_ptr (&mach->arg_str)) |
1800 | if (!isspace (*p)) | ||
1801 | break; | ||
1802 | |||
1803 | start = p; | ||
1804 | |||
1805 | if (strncasecmp (p, "re", 2) == 0) | ||
1806 | { | ||
1807 | if (p[2] == ':') | ||
1808 | p += 3; | ||
1809 | else if (p[2] == '[') | ||
1810 | { | ||
1811 | for (p += 3; *p; p++) | ||
1812 | if (*p == ']' || !isdigit (*p)) | ||
1813 | break; | ||
1814 | if (*p == ']' && p[1] == ':') | ||
1815 | p += 2; | ||
1816 | else | ||
1817 | p = start; | ||
1818 | } | ||
1819 | else | ||
1820 | p = start; | ||
1821 | } | ||
1822 | |||
1823 | if (p != strobj_ptr (&mach->arg_str)) | ||
1824 | { | 1800 | { |
1825 | for (; *p && isspace (*p); p++) | ||
1826 | ; | ||
1827 | |||
1828 | p = strdup (p); | 1801 | p = strdup (p); |
1829 | strobj_free (&mach->arg_str); | 1802 | strobj_free (&mach->arg_str); |
1830 | strobj_create (&mach->arg_str, p); | 1803 | strobj_create (&mach->arg_str, p); |
... | @@ -1832,6 +1805,34 @@ builtin_unre (struct mh_machine *mach) | ... | @@ -1832,6 +1805,34 @@ builtin_unre (struct mh_machine *mach) |
1832 | } | 1805 | } |
1833 | } | 1806 | } |
1834 | 1807 | ||
1808 | static void | ||
1809 | builtin_isreply (struct mh_machine *mach) | ||
1810 | { | ||
1811 | char *p; | ||
1812 | int rc; | ||
1813 | |||
1814 | if (strobj_is_null (&mach->arg_str)) | ||
1815 | { | ||
1816 | header_t hdr = NULL; | ||
1817 | char *value = NULL; | ||
1818 | message_get_header (mach->message, &hdr); | ||
1819 | |||
1820 | header_aget_value (hdr, MU_HEADER_SUBJECT, &value); | ||
1821 | rc = munre_subject (value, NULL); | ||
1822 | free (value); | ||
1823 | } | ||
1824 | else | ||
1825 | rc = munre_subject (strobj_ptr (&mach->arg_str), NULL); | ||
1826 | |||
1827 | mach->arg_num = !rc; | ||
1828 | } | ||
1829 | |||
1830 | static void | ||
1831 | builtin_reply_regex (struct mh_machine *mach) | ||
1832 | { | ||
1833 | mh_set_reply_regex (strobj_ptr (&mach->arg_str)); | ||
1834 | } | ||
1835 | |||
1835 | int | 1836 | int |
1836 | mh_decode_rcpt_flag (const char *arg) | 1837 | mh_decode_rcpt_flag (const char *arg) |
1837 | { | 1838 | { |
... | @@ -2038,6 +2039,8 @@ mh_builtin_t builtin_tab[] = { | ... | @@ -2038,6 +2039,8 @@ mh_builtin_t builtin_tab[] = { |
2038 | { "package", builtin_package, mhtype_str, mhtype_none }, | 2039 | { "package", builtin_package, mhtype_str, mhtype_none }, |
2039 | { "package_string", builtin_package_string, mhtype_str, mhtype_none }, | 2040 | { "package_string", builtin_package_string, mhtype_str, mhtype_none }, |
2040 | { "version", builtin_version, mhtype_str, mhtype_none }, | 2041 | { "version", builtin_version, mhtype_str, mhtype_none }, |
2042 | { "reply_regex", builtin_reply_regex, mhtype_none, mhtype_str }, | ||
2043 | { "isreply", builtin_isreply, mhtype_num, mhtype_str, MHA_OPTARG }, | ||
2041 | { 0 } | 2044 | { 0 } |
2042 | }; | 2045 | }; |
2043 | 2046 | ... | ... |
-
Please register or sign in to post a comment