#endif
#include "mutt.h"
+#include "ascii.h"
#include "charset.h"
#include "mutt_idna.h"
#include "lib/mem.h"
#include "lib/intl.h"
#include "lib/str.h"
+#include "lib/debug.h"
/* The low-level interface we use. */
int mutt_idna_to_local (const char *in, char **out, int flags)
{
- *out = safe_strdup (in);
+ *out = str_dup (in);
return 1;
}
int mutt_local_to_idna (const char *in, char **out)
{
- *out = safe_strdup (in);
+ *out = str_dup (in);
return 0;
}
if ((flags & MI_MAY_BE_IRREVERSIBLE) == 0) {
int irrev = 0;
char *t2 = NULL;
- char *tmp = safe_strdup (*out);
+ char *tmp = str_dup (*out);
if (mutt_convert_string (&tmp, Charset, "utf-8", M_ICONV_HOOK_FROM) == -1)
irrev = 1;
if (!irrev && idna_to_ascii_8z (tmp, &t2, 1) != IDNA_SUCCESS)
irrev = 1;
if (!irrev && ascii_strcasecmp (t2, in)) {
- dprint (1,
- (debugfile,
- "mutt_idna_to_local: Not reversible. in = '%s', t2 = '%s'.\n",
- in, t2));
+ debug_print (1, ("not reversible. in = '%s', t2 = '%s'.\n", in, t2));
irrev = 1;
}
- FREE (&t2);
- FREE (&tmp);
+ mem_free (&t2);
+ mem_free (&tmp);
if (irrev)
goto notrans;
return 0;
notrans:
- FREE (out);
- *out = safe_strdup (in);
+ mem_free (out);
+ *out = str_dup (in);
return 1;
}
int mutt_local_to_idna (const char *in, char **out)
{
int rv = 0;
- char *tmp = safe_strdup (in);
+ char *tmp = str_dup (in);
*out = NULL;
if (!rv && idna_to_ascii_8z (tmp, out, 1) != IDNA_SUCCESS)
rv = -2;
- FREE (&tmp);
+ mem_free (&tmp);
if (rv < 0) {
- FREE (out);
- *out = safe_strdup (in);
+ mem_free (out);
+ *out = str_dup (in);
}
return rv;
}
p = strchr (mbx, '@');
if (!p)
return -1;
- *user = safe_calloc ((p - mbx + 1), sizeof (mbx[0]));
+ *user = mem_calloc ((p - mbx + 1), sizeof (mbx[0]));
strfcpy (*user, mbx, (p - mbx + 1));
- *domain = safe_strdup (p + 1);
+ *domain = str_dup (p + 1);
return 0;
}
if (mutt_local_to_idna (domain, &tmp) < 0) {
e = 1;
if (err)
- *err = safe_strdup (domain);
+ *err = str_dup (domain);
}
else {
- safe_realloc (&a->mailbox, mutt_strlen (user) + mutt_strlen (tmp) + 2);
+ mem_realloc (&a->mailbox, str_len (user) + str_len (tmp) + 2);
sprintf (a->mailbox, "%s@%s", NONULL (user), NONULL (tmp)); /* __SPRINTF_CHECKED__ */
}
- FREE (&domain);
- FREE (&user);
- FREE (&tmp);
+ mem_free (&domain);
+ mem_free (&user);
+ mem_free (&tmp);
if (e)
return -1;
continue;
if (mutt_idna_to_local (domain, &tmp, 0) == 0) {
- safe_realloc (&a->mailbox, mutt_strlen (user) + mutt_strlen (tmp) + 2);
+ mem_realloc (&a->mailbox, str_len (user) + str_len (tmp) + 2);
sprintf (a->mailbox, "%s@%s", NONULL (user), NONULL (tmp)); /* __SPRINTF_CHECKED__ */
}
- FREE (&domain);
- FREE (&user);
- FREE (&tmp);
+ mem_free (&domain);
+ mem_free (&user);
+ mem_free (&tmp);
}
return 0;
char *domain = NULL;
char *user = NULL;
- FREE (&buff);
+ mem_free (&buff);
if (mbox_to_udomain (a->mailbox, &user, &domain) != 0)
return a->mailbox;
if (mutt_idna_to_local (domain, &tmp, MI_MAY_BE_IRREVERSIBLE) != 0) {
- FREE (&user);
- FREE (&domain);
- FREE (&tmp);
+ mem_free (&user);
+ mem_free (&domain);
+ mem_free (&tmp);
return a->mailbox;
}
- safe_realloc (&buff, mutt_strlen (tmp) + mutt_strlen (user) + 2);
+ mem_realloc (&buff, str_len (tmp) + str_len (user) + 2);
sprintf (buff, "%s@%s", NONULL (user), NONULL (tmp)); /* __SPRINTF_CHECKED__ */
- FREE (&tmp);
- FREE (&user);
- FREE (&domain);
+ mem_free (&tmp);
+ mem_free (&user);
+ mem_free (&domain);
return buff;
}