18 |
/* This module implements execution of MH format strings. */ |
/* This module implements execution of MH format strings. */ |
19 |
|
|
20 |
#include <mh.h> |
#include <mh.h> |
21 |
|
#include <mailutils/mime.h> |
22 |
|
|
23 |
#ifdef HAVE_STRINGS_H |
#ifdef HAVE_STRINGS_H |
24 |
# include <strings.h> |
# include <strings.h> |
514 |
header_t hdr = NULL; |
header_t hdr = NULL; |
515 |
char *value = NULL; |
char *value = NULL; |
516 |
message_get_header (mach.message, &hdr); |
message_get_header (mach.message, &hdr); |
517 |
header_aget_value (hdr, strobj_ptr (&mach.arg_str), &value); |
header_aget_value_unfold (hdr, strobj_ptr (&mach.arg_str), &value); |
518 |
strobj_free (&mach.arg_str); |
strobj_free (&mach.arg_str); |
519 |
if (value) |
if (value) |
520 |
{ |
{ |
1809 |
static void |
static void |
1810 |
builtin_isreply (struct mh_machine *mach) |
builtin_isreply (struct mh_machine *mach) |
1811 |
{ |
{ |
|
char *p; |
|
1812 |
int rc; |
int rc; |
1813 |
|
|
1814 |
if (strobj_is_null (&mach->arg_str)) |
if (strobj_is_null (&mach->arg_str)) |
1828 |
} |
} |
1829 |
|
|
1830 |
static void |
static void |
1831 |
|
decode_string (strobj_t *obj) |
1832 |
|
{ |
1833 |
|
char *charset = NULL; |
1834 |
|
char *tmp; |
1835 |
|
int rc; |
1836 |
|
|
1837 |
|
if (strobj_is_null (obj)) |
1838 |
|
return; |
1839 |
|
charset = mh_global_profile_get ("Charset", NULL); |
1840 |
|
if (!charset) |
1841 |
|
return; |
1842 |
|
if (strcasecmp (charset, "auto") == 0) |
1843 |
|
{ |
1844 |
|
/* Try to deduce the charset from LC_ALL variable */ |
1845 |
|
|
1846 |
|
tmp = getenv ("LC_ALL"); |
1847 |
|
if (tmp) |
1848 |
|
{ |
1849 |
|
char *sp; |
1850 |
|
char *lang; |
1851 |
|
char *terr; |
1852 |
|
|
1853 |
|
lang = strtok_r (tmp, "_", &sp); |
1854 |
|
terr = strtok_r (NULL, ".", &sp); |
1855 |
|
charset = strtok_r (NULL, "@", &sp); |
1856 |
|
|
1857 |
|
if (!charset) |
1858 |
|
charset = mu_charset_lookup (lang, terr); |
1859 |
|
} |
1860 |
|
} |
1861 |
|
|
1862 |
|
if (!charset) |
1863 |
|
return; |
1864 |
|
|
1865 |
|
rc = rfc2047_decode (charset, strobj_ptr (obj), &tmp); |
1866 |
|
if (!rc) |
1867 |
|
{ |
1868 |
|
strobj_free (obj); |
1869 |
|
strobj_create (obj, tmp); |
1870 |
|
free (tmp); |
1871 |
|
} |
1872 |
|
} |
1873 |
|
|
1874 |
|
static void |
1875 |
|
builtin_decode (struct mh_machine *mach) |
1876 |
|
{ |
1877 |
|
decode_string (&mach->arg_str); |
1878 |
|
} |
1879 |
|
|
1880 |
|
static void |
1881 |
builtin_reply_regex (struct mh_machine *mach) |
builtin_reply_regex (struct mh_machine *mach) |
1882 |
{ |
{ |
1883 |
mh_set_reply_regex (strobj_ptr (&mach->arg_str)); |
mh_set_reply_regex (strobj_ptr (&mach->arg_str)); |
2091 |
{ "version", builtin_version, mhtype_str, mhtype_none }, |
{ "version", builtin_version, mhtype_str, mhtype_none }, |
2092 |
{ "reply_regex", builtin_reply_regex, mhtype_none, mhtype_str }, |
{ "reply_regex", builtin_reply_regex, mhtype_none, mhtype_str }, |
2093 |
{ "isreply", builtin_isreply, mhtype_num, mhtype_str, MHA_OPTARG }, |
{ "isreply", builtin_isreply, mhtype_num, mhtype_str, MHA_OPTARG }, |
2094 |
|
{ "decode", builtin_decode, mhtype_str, mhtype_str }, |
2095 |
{ 0 } |
{ 0 } |
2096 |
}; |
}; |
2097 |
|
|