Move #include from h/mh.h to source files
[mmh] / sbr / m_atoi.c
1 /*
2 ** m_atoi.c -- Parse a string representation of a message number, and
3 **          -- return the numeric value of the message.  If the string
4 **          -- contains any non-digit characters, then return 0.
5 **
6 ** This code is Copyright (c) 2002, by the authors of nmh.  See the
7 ** COPYRIGHT file in the root directory of the nmh distribution for
8 ** complete copyright information.
9 */
10
11 #include <h/mh.h>
12 #include <ctype.h>
13
14
15 int
16 m_atoi(char *str)
17 {
18         int i;
19         unsigned char *cp;
20
21         for (i = 0, cp = str; *cp; cp++) {
22                 if (!isdigit(*cp))
23                         return 0;
24
25                 i *= 10;
26                 i += (*cp - '0');
27         }
28
29         return i;
30 }