Commit 7444e911 authored by Rocco Rutte's avatar Rocco Rutte

Add mutt_atos(), mutt_atoi() and mutt_atol() (strtol() wrappers)

parent 166546a1
2009-06-01 10:36 +0200 Rocco Rutte <pdmef@gmx.net> (36b7e267ce33)
* send.c: Treat address groups as no recipients
When sending with Sendmail or SMTP we exclude address groups anyway,
so treat these addresses as not present when checking for valid
recipients before sending in the compose menu.
2009-06-01 10:29 +0200 Rocco Rutte <pdmef@gmx.net> (64250df0e9a4)
* ChangeLog, smtp.c: Weed out address groups for SMTP the same way we
do for sendmail
2009-05-31 19:19 -0700 Brendan Cully <brendan@kublai.com> (0024860ab03e)
* doc/Makefile.am: Allow chunked and unchunked manuals to build in
......
......@@ -1006,3 +1006,58 @@ mutt_strsysexit(int e)
return sysexits_h[i].str;
}
int mutt_atos (const char *str, short *dst)
{
int rc;
long res;
short tmp;
short *t = dst ? dst : &tmp;
*t = 0;
if ((rc = mutt_atol (str, &res)) < 0)
return rc;
if ((short) res != res)
return -2;
*t = (short) res;
return 0;
}
int mutt_atoi (const char *str, int *dst)
{
int rc;
long res;
int tmp;
int *t = dst ? dst : &tmp;
*t = 0;
if ((rc = mutt_atol (str, &res)) < 0)
return rc;
if ((int) res != res)
return -2;
*t = (int) res;
return 0;
}
int mutt_atol (const char *str, long *dst)
{
long r;
long *res = dst ? dst : &r;
char *e = NULL;
/* no input: 0 */
if (!str || !*str)
{
*res = 0;
return 0;
}
*res = strtol (str, &e, 10);
if (e && *e != '\0')
return -1;
return 0;
}
......@@ -158,6 +158,16 @@ char *safe_strcat (char *, size_t, const char *);
char *safe_strncat (char *, size_t, const char *, size_t);
char *safe_strdup (const char *);
/* strtol() wrappers with range checking; they return
* 0 success
* -1 format error
* -2 overflow (for int and short)
* the int pointer may be NULL to test only without conversion
*/
int mutt_atos (const char *, short *);
int mutt_atoi (const char *, int *);
int mutt_atol (const char *, long *);
const char *mutt_stristr (const char *, const char *);
const char *mutt_basename (const char *);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment