mutt_debug(2, "Handling EXPUNGE\n");
- if (mutt_atoui(s, &exp_msn) < 0 || exp_msn < 1 || exp_msn > idata->max_msn)
+ if (mutt_str_atoui(s, &exp_msn) < 0 || exp_msn < 1 || exp_msn > idata->max_msn)
return;
h = idata->msn_index[exp_msn - 1];
mutt_debug(3, "Handling FETCH\n");
- if (mutt_atoui(s, &msn) < 0 || msn < 1 || msn > idata->max_msn)
+ if (mutt_str_atoui(s, &msn) < 0 || msn < 1 || msn > idata->max_msn)
{
mutt_debug(3, "#1 FETCH response ignored for this message\n");
return;
{
s += 3;
SKIPWS(s);
- if (mutt_atoui(s, &uid) < 0)
+ if (mutt_str_atoui(s, &uid) < 0)
{
mutt_debug(2, "Illegal UID. Skipping update.\n");
return;
while ((s = imap_next_word((char *) s)) && *s != '\0')
{
- if (mutt_atoui(s, &uid) < 0)
+ if (mutt_str_atoui(s, &uid) < 0)
continue;
h = (struct Header *) mutt_hash_int_find(idata->uid_hash, uid);
if (h)
mutt_debug(2, "Handling EXISTS\n");
/* new mail arrived */
- if (mutt_atoui(pn, &count) < 0)
+ if (mutt_str_atoui(pn, &count) < 0)
{
mutt_debug(1, "Malformed EXISTS: '%s'\n", pn);
}
mutt_debug(3, "Getting mailbox UIDVALIDITY\n");
pc += 3;
pc = imap_next_word(pc);
- if (mutt_atoui(pc, &idata->uid_validity) < 0)
+ if (mutt_str_atoui(pc, &idata->uid_validity) < 0)
goto fail;
status->uidvalidity = idata->uid_validity;
}
mutt_debug(3, "Getting mailbox UIDNEXT\n");
pc += 3;
pc = imap_next_word(pc);
- if (mutt_atoui(pc, &idata->uidnext) < 0)
+ if (mutt_str_atoui(pc, &idata->uidnext) < 0)
goto fail;
status->uidnext = idata->uidnext;
}
{
s += 3;
SKIPWS(s);
- if (mutt_atoui(s, &h->data->uid) < 0)
+ if (mutt_str_atoui(s, &h->data->uid) < 0)
return -1;
s = imap_next_word(s);
/* skip to message number */
buf = imap_next_word(buf);
- if (mutt_atoui(buf, &h->data->msn) < 0)
+ if (mutt_str_atoui(buf, &h->data->msn) < 0)
return rc;
/* find FETCH tag */
if (mutt_str_strncasecmp("UID", pc, 3) == 0)
{
pc = imap_next_word(pc);
- if (mutt_atoui(pc, &uid) < 0)
+ if (mutt_str_atoui(pc, &uid) < 0)
goto bail;
if (uid != HEADER_DATA(h)->uid)
mutt_error(_(
while (isdigit((unsigned char) *pc))
pc++;
*pc = '\0';
- if (mutt_atoui(pn, bytes) < 0)
+ if (mutt_str_atoui(pn, bytes) < 0)
return -1;
return 0;
* | mutt_str_atoi() | Convert ASCII string to an integer
* | mutt_str_atol() | Convert ASCII string to a long
* | mutt_str_atos() | Convert ASCII string to a short
+ * | mutt_str_atoui() | Convert ASCII string to an unsigned integer
+ * | mutt_str_atoul() | Convert ASCII string to an unsigned long
* | mutt_str_dequote_comment() | Un-escape characters in an email address comment
* | mutt_str_find_word() | Find the next word (non-space)
* | mutt_str_getenv() | Get an environment variable
return 0;
}
+/**
+ * mutt_str_atoui - Convert ASCII string to an unsigned integer
+ * @param[in] str String to read
+ * @param[out] dst Store the result
+ * @retval 1 Successful conversion, with trailing characters
+ * @retval 0 Successful conversion
+ * @retval -1 Invalid input
+ * @retval -2 Input out of range
+ *
+ * @note
+ * This function's return value differs from the other functions.
+ * They return -1 if there is input beyond the number.
+ */
+int mutt_str_atoui(const char *str, unsigned int *dst)
+{
+ int rc;
+ unsigned long res = 0;
+ unsigned int tmp = 0;
+ unsigned int *t = dst ? dst : &tmp;
+
+ *t = 0;
+
+ rc = mutt_str_atoul(str, &res);
+ if (rc < 0)
+ return rc;
+ if ((unsigned int) res != res)
+ return -2;
+
+ *t = (unsigned int) res;
+ return rc;
+}
+
+/**
+ * mutt_str_atoul - Convert ASCII string to an unsigned long
+ * @param[in] str String to read
+ * @param[out] dst Store the result
+ * @retval 1 Successful conversion, with trailing characters
+ * @retval 0 Successful conversion
+ * @retval -1 Invalid input
+ *
+ * @note
+ * This function's return value differs from the other functions.
+ * They return -1 if there is input beyond the number.
+ */
+int mutt_str_atoul(const char *str, unsigned long *dst)
+{
+ unsigned long r = 0;
+ unsigned long *res = dst ? dst : &r;
+ char *e = NULL;
+
+ /* no input: 0 */
+ if (!str || !*str)
+ {
+ *res = 0;
+ return 0;
+ }
+
+ errno = 0;
+ *res = strtoul(str, &e, 10);
+ if ((*res == ULONG_MAX) && (errno == ERANGE))
+ return -1;
+ if (e && (*e != '\0'))
+ return 1;
+ return 0;
+}
/**
* mutt_str_strdup - Copy a string, safely
* @param s String to copy
int mutt_str_atoi(const char *str, int *dst);
int mutt_str_atol(const char *str, long *dst);
int mutt_str_atos(const char *str, short *dst);
+int mutt_str_atoui(const char *str, unsigned int *dst);
+int mutt_str_atoul(const char *str, unsigned long *dst);
void mutt_str_dequote_comment(char *s);
const char *mutt_str_find_word(const char *src);
const char *mutt_str_getenv(const char *name);
return 0;
}
-/* NOTE: this function's return value breaks with the above three functions.
- * The imap code lexes uint values out of a stream of characters without
- * tokenization. The above functions return -1 if there is input beyond
- * the number.
- *
- * returns: 1 - successful conversion, with trailing characters
- * 0 - successful conversion
- * -1 - invalid input
- * -2 - input out of range
- */
-int mutt_atoui(const char *str, unsigned int *dst)
-{
- int rc;
- unsigned long res;
- unsigned int tmp;
- unsigned int *t = dst ? dst : &tmp;
-
- *t = 0;
-
- if ((rc = mutt_atoul(str, &res)) < 0)
- return rc;
- if ((unsigned int) res != res)
- return -2;
-
- *t = (unsigned int) res;
- return rc;
-}
-
-/* NOTE: this function's return value is different from mutt_atol.
- *
- * returns: 1 - successful conversion, with trailing characters
- * 0 - successful conversion
- * -1 - invalid input
- */
-int mutt_atoul(const char *str, unsigned long *dst)
-{
- unsigned long r;
- unsigned long *res = dst ? dst : &r;
- char *e = NULL;
-
- /* no input: 0 */
- if (!str || !*str)
- {
- *res = 0;
- return 0;
- }
-
- errno = 0;
- *res = strtoul(str, &e, 10);
- if (*res == ULONG_MAX && errno == ERANGE)
- return -1;
- if (e && *e != '\0')
- return 1;
- return 0;
-}
int mutt_addrlist_to_intl(struct Address *a, char **err);
int mutt_addrlist_to_local(struct Address *a);
-int mutt_atoui(const char *str, unsigned int *dst);
-int mutt_atoul(const char *str, unsigned long *dst);
-
#endif /* _MUTT_PROTOS_H */