:pserver:cvsanon@mok.lvcm.com:/CVS/ReactOS reactos
[reactos.git] / lib / ntdll / stdlib / atoi64.c
1 /* $Id$
2  *
3  * COPYRIGHT:       See COPYING in the top level directory
4  * PROJECT:         ReactOS kernel
5  * FILE:            lib/ntdll/stdlib/atoi64.c
6  * PURPOSE:         converts an ascii string to 64 bit integer
7  */
8
9 #include <stdlib.h>
10 #include <ctype.h>
11
12 __int64
13 _atoi64 (const char *nptr)
14 {
15    int c;
16    __int64 value;
17    int sign;
18
19    while (isspace((int)*nptr))
20         ++nptr;
21
22    c = (int)*nptr++;
23    sign = c;
24    if (c == '-' || c == '+')
25         c = (int)*nptr++;
26
27    value = 0;
28
29    while (isdigit(c))
30      {
31         value = 10 * value + (c - '0');
32         c = (int)*nptr++;
33      }
34
35    if (sign == '-')
36        return -value;
37    else
38        return value;
39 }
40
41 /* EOF */