]> git.mxchange.org Git - simgear.git/blob - simgear/metar/Antoi.cpp
Removed autogen'd files.
[simgear.git] / simgear / metar / Antoi.cpp
1 #pragma comment(compiler)
2 #pragma comment(date)
3 #pragma comment(timestamp)
4  
5 #include <stdlib.h>
6  
7 #pragma title("antoi - char array to integer")
8 #pragma pagesize (80)
9  
10 #pragma page(1)
11 /********************************************************************/
12 /*                                                                  */
13 /*  Title:         antoi                                            */
14 /*  Date:          Jan 28, 1991                                     */
15 /*  Organization:  W/OSO242 - Graphics and Display Section          */
16 /*  Programmer:    Allan Darling                                    */
17 /*  Language:      C/370                                            */
18 /*                                                                  */
19 /*  Abstract:      This function will convert a character array     */
20 /*                 (string) of length (len) into an integer.        */
21 /*                 The integer is created via a call to the         */
22 /*                 function atoi.  This function extends the        */
23 /*                 functionality of atoi by removing the            */
24 /*                 requirement for a sentinal delimited string      */
25 /*                 as input.                                        */
26 /*                                                                  */
27 /*  Input: - Pointer to an array of characters.                     */
28 /*         - Integer indicating the number of character to include  */
29 /*           in the conversion.                                     */
30 /*                                                                  */
31 /*  Output:- An integer corresponding to the value in the character */
32 /*           array or MAXNEG (-2147483648) if the function is       */
33 /*           unable to acquire system storage.                      */
34 /*                                                                  */
35 /*  Modification History:                                           */
36 /*                 None                                             */
37 /*                                                                  */
38 /********************************************************************/
39  
40 int antoi(char * string, int len)
41 {
42  
43     /*******************/
44     /* local variables */
45     /*******************/
46  
47     char * tmpstr;
48     int i,
49         retval;
50  
51  
52     /*****************/
53     /* function body */
54     /*****************/
55  
56     tmpstr = (char *)malloc((len+1) * sizeof(char));
57  
58     if (tmpstr == NULL) return (-2147483648);
59  
60     for (i = 0; i < len; i++)
61        tmpstr[i] = string[i];
62  
63     tmpstr[len] = '\0';
64  
65     retval = atoi(tmpstr);
66  
67     free(tmpstr);
68  
69     return(retval);
70  
71 } /* end antoi */
72  
73 #pragma page(1)