modules/up/src/Core/util/atoll.c
/* [<][>][^][v][top][bottom][index][help] */
FUNCTIONS
This source file includes following functions.
- atollRA
1 // $Id: atoll.c,v 1.2 2001/09/07 11:44:46 shane Exp $
2 //
3 // Copyright (c) 1994 by the University of Southern California
4 // All rights reserved.
5 //
6 // Permission to use, copy, modify, and distribute this software and its
7 // documentation in source and binary forms for lawful non-commercial
8 // purposes and without fee is hereby granted, provided that the above
9 // copyright notice appear in all copies and that both the copyright
10 // notice and this permission notice appear in supporting documentation,
11 // and that any documentation, advertising materials, and other materials
12 // related to such distribution and use acknowledge that the software was
13 // developed by the University of Southern California, Information
14 // Sciences Institute. The name of the USC may not be used to endorse or
15 // promote products derived from this software without specific prior
16 // written permission.
17 //
18 // THE UNIVERSITY OF SOUTHERN CALIFORNIA DOES NOT MAKE ANY
19 // REPRESENTATIONS ABOUT THE SUITABILITY OF THIS SOFTWARE FOR ANY
20 // PURPOSE. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
21 // IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
22 // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE,
23 // TITLE, AND NON-INFRINGEMENT.
24 //
25 // IN NO EVENT SHALL USC, OR ANY OTHER CONTRIBUTOR BE LIABLE FOR ANY
26 // SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES, WHETHER IN CONTRACT, TORT,
27 // OR OTHER FORM OF ACTION, ARISING OUT OF OR IN CONNECTION WITH, THE USE
28 // OR PERFORMANCE OF THIS SOFTWARE.
29 //
30 // Questions concerning this software should be directed to
31 // ratoolset@isi.edu.
32 //
33 // Author(s): Cengiz Alaettinoglu <cengiz@isi.edu>
34
35 #include <ctype.h>
36
37 // Convert a string to a long long int
38 void atollRA(const char *text, long long int *result)
/* [<][>][^][v][top][bottom][index][help] */
39 {
40 const char *p;
41 int negative = 0;
42
43 *result = 0;
44
45 for (p = text; *p && isspace(*p); p++) ;
46
47 if (*p && *p == '-') {
48 negative = 1;
49 p++;
50 }
51 if (*p && *p == '+')
52 p++;
53
54 for (; *p && isspace(*p); p++) ;
55
56 for (; *p && isdigit(*p); p++) {
57 *result *= 10;
58 *result += *p - '0';
59 }
60 if (negative)
61 *result *= -1;
62 }