Commit 737e2f6e 737e2f6ef46763a249009398b9c009d34d5baf57 by Sergey Poznyakoff

(builtin_unre): Use munre_subject()

(builtin_isreply,builtin_reply_regex): New functions
1 parent 23c81ead
...@@ -1794,42 +1794,43 @@ builtin_putaddr (struct mh_machine *mach) ...@@ -1794,42 +1794,43 @@ 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)) 1800 {
1801 break; 1801 p = strdup (p);
1802 strobj_free (&mach->arg_str);
1803 strobj_create (&mach->arg_str, p);
1804 free (p);
1805 }
1806 }
1802 1807
1803 start = p; 1808 static void
1809 builtin_isreply (struct mh_machine *mach)
1810 {
1811 char *p;
1812 int rc;
1804 1813
1805 if (strncasecmp (p, "re", 2) == 0) 1814 if (strobj_is_null (&mach->arg_str))
1806 { 1815 {
1807 if (p[2] == ':') 1816 header_t hdr = NULL;
1808 p += 3; 1817 char *value = NULL;
1809 else if (p[2] == '[') 1818 message_get_header (mach->message, &hdr);
1810 { 1819
1811 for (p += 3; *p; p++) 1820 header_aget_value (hdr, MU_HEADER_SUBJECT, &value);
1812 if (*p == ']' || !isdigit (*p)) 1821 rc = munre_subject (value, NULL);
1813 break; 1822 free (value);
1814 if (*p == ']' && p[1] == ':')
1815 p += 2;
1816 else
1817 p = start;
1818 } 1823 }
1819 else 1824 else
1820 p = start; 1825 rc = munre_subject (strobj_ptr (&mach->arg_str), NULL);
1821 }
1822 1826
1823 if (p != strobj_ptr (&mach->arg_str)) 1827 mach->arg_num = !rc;
1824 { 1828 }
1825 for (; *p && isspace (*p); p++)
1826 ;
1827 1829
1828 p = strdup (p); 1830 static void
1829 strobj_free (&mach->arg_str); 1831 builtin_reply_regex (struct mh_machine *mach)
1830 strobj_create (&mach->arg_str, p); 1832 {
1831 free (p); 1833 mh_set_reply_regex (strobj_ptr (&mach->arg_str));
1832 }
1833 } 1834 }
1834 1835
1835 int 1836 int
...@@ -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
......