]> git.mxchange.org Git - simgear.git/blob - simgear/metar/Stspack2.cpp
- Refactoring configure.ac a bit to use $host (please test on your platform)
[simgear.git] / simgear / metar / Stspack2.cpp
1 #include "Local.h"     /* standard header file */
2  
3 /********************************************************************/
4 /*                                                                  */
5 /*  Title:         stspack2                                         */
6 /*  Organization:  W/OSO242 - GRAPHICS AND DISPLAY SECTION          */
7 /*  Date:          05 Oct 1992                                      */
8 /*  Programmer:    ALLAN DARLING                                    */
9 /*  Language:      C/2                                              */
10 /*                                                                  */
11 /*  Abstract:      The stspack2 package contains functions to       */
12 /*                 perform the isalnum through isxdigit functions   */
13 /*                 on strings.  The functions come in four forms:   */
14 /*                 those that test NULL delimited strings and are   */
15 /*                 named in the form sxxxxxxx, those that test at   */
16 /*                 most n characters and are named in the form      */
17 /*                 nxxxxxxx, those that search forward in a string  */
18 /*                 and are named in the form nxtyyyyy, and those    */
19 /*                 that search backward in a string and are named   */
20 /*                 in the form lstyyyyy.                            */
21 /*                                                                  */
22 /*                 The xxxxxxx is the name of the test applied to   */
23 /*                 each character in the string, such as isalpha,   */
24 /*                 thus a function to test a NULL delimited string  */
25 /*                 an return a nonzero value if all characters in   */
26 /*                 the string are digits is named sisdigit.         */
27 /*                                                                  */
28 /*                 The yyyyy is the name of the test applied to     */
29 /*                 characters in a string, minus the 'is' prefix.   */
30 /*                 Thus a function to find the next digit in a NULL */
31 /*                 delimited string and return a pointer to it is   */
32 /*                 named nxtdigit.                                  */
33 /*                                                                  */
34 /*                 The only exception to the naming rule is for the */
35 /*                 functions that test for hexadecimal digits.      */
36 /*                 These are named sisxdigi, nisxdigi, nxtxdigi,    */
37 /*                 and lstxdigi because of the eight character      */
38 /*                 function name limitation.                        */
39 /*                                                                  */
40 /*                 The nxxxxxxx class of functions will test up to  */
41 /*                 n characters or the first NULL character         */
42 /*                 encountered, whichever comes first.  For all     */
43 /*                 classes of functions, the string sentinal is     */
44 /*                 not included in the test.                        */
45 /*                                                                  */
46 /*  External Functions Called:                                      */
47 /*                 isalnum, isalpha, iscntrl, isdigit, isgraph,     */
48 /*                 islower, isprint, ispunct, isspace, isupper,     */
49 /*                 isxdigit.                                        */
50 /*                                                                  */
51 /*  Input:         For sxxxxxxx class functions, a pointer to a     */
52 /*                 NULL delimited character string.                 */
53 /*                                                                  */
54 /*                 For nxtyyyyy class functions, a pointer to a     */
55 /*                 NULL delimited character string.                 */
56 /*                                                                  */
57 /*                 for nxxxxxxx class functions, a pointer to a     */
58 /*                 character array, and a positive, nonzero integer.*/
59 /*                                                                  */
60 /*                 for lstyyyyy class functions, a pointer to a     */
61 /*                 character array, and a positive, nonzero integer.*/
62 /*                                                                  */
63 /*  Output:        A nonzero value if the test is true for all      */
64 /*                 characters in the string, a zero value otherwise.*/
65 /*                                                                  */
66 /*  Modification History:                                           */
67 /*                 None.                                            */
68 /*                                                                  */
69 /********************************************************************/
70  
71 int nisalnum(char *s, int n) {
72  
73    for (; *s && n; s++, n--)
74  
75       if (!isalnum(*s))
76          return (0);
77  
78    return (1);
79  
80 } /* end nisalnum */
81  
82  
83 int nisalpha(char *s, int n) {
84  
85    for (; *s && n; s++, n--)
86  
87       if (!isalpha(*s))
88          return (0);
89  
90    return (1);
91  
92 } /* end nisalpha */
93  
94  
95 int niscntrl(char *s, int n) {
96  
97    for (; *s && n; s++, n--)
98  
99       if (!iscntrl(*s))
100          return (0);
101  
102    return (1);
103  
104 } /* end niscntrl */
105  
106  
107 int nisdigit(char *s, int n) {
108  
109    for (; *s && n; s++, n--)
110  
111       if (!isdigit(*s))
112          return (0);
113  
114    return (1);
115  
116 } /* end nisdigit */
117  
118  
119 int nisgraph(char *s, int n) {
120  
121    for (; *s && n; s++, n--)
122  
123       if (!isgraph(*s))
124          return (0);
125  
126    return (1);
127  
128 } /* end nisgraph */
129  
130  
131 int nislower(char *s, int n) {
132  
133    for (; *s && n; s++, n--)
134  
135       if (!islower(*s))
136          return (0);
137  
138    return (1);
139  
140 } /* end nislower */
141  
142  
143 int nisprint(char *s, int n) {
144  
145    for (; *s && n; s++, n--)
146  
147       if (!isprint(*s))
148          return (0);
149  
150    return (1);
151  
152 } /* end nisprint */
153  
154  
155 int nispunct(char *s, int n) {
156  
157    for (; *s && n; s++, n--)
158  
159       if (!ispunct(*s))
160          return (0);
161  
162    return (1);
163  
164 } /* end nispunct */
165  
166  
167 int nisspace(char *s, int n) {
168  
169    for (; *s && n; s++, n--)
170  
171       if (!isspace(*s))
172          return (0);
173  
174    return (1);
175  
176 } /* end nisspace */
177  
178  
179 int nisupper(char *s, int n) {
180  
181    for (; *s && n; s++, n--)
182  
183       if (!isupper(*s))
184          return (0);
185  
186    return (1);
187  
188 } /* end nisupper */
189  
190  
191 int nisxdigi(char *s, int n) {
192  
193    for (; *s && n; s++, n--)
194  
195       if (!isxdigit(*s))
196          return (0);
197  
198    return (1);
199  
200 } /* end nisxdigi */
201