/[dtapublic]/projs/dtats/trunk/projs/2018/20180707_cgi_web_tools_aux_exe/auxfuncs.c
ViewVC logotype

Contents of /projs/dtats/trunk/projs/2018/20180707_cgi_web_tools_aux_exe/auxfuncs.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 175 - (show annotations) (download)
Mon Jul 9 00:00:34 2018 UTC (6 years, 3 months ago) by dashley
File MIME type: text/plain
File size: 4593 byte(s)
Update license (GPL->MIT) and copyright information.  Remove CVS log, which SVN does not support.
1 //$Header$
2 //********************************************************************************
3 //Copyright (c) 2003, 2018 David T. Ashley.
4 //********************************************************************************
5 //This file is part of "arith_large_cgi", a program that is designed to be
6 //invoked by a PHP script as part of serving a web page that performs
7 //calculations involving large integers. (A secondary compiled program is
8 //used because a compiled program can perform certain calculation-intensive
9 //tasks far more efficiently than a PHP script.) This program is provided by
10 //David T. Ashley (dashley@gmail.com) under the MIT License (reproduced
11 //immediately below).
12 //********************************************************************************
13 //Permission is hereby granted, free of charge, to any person obtaining a copy
14 //of this software and associated documentation files (the "Software"), to deal
15 //in the Software without restriction, including without limitation the rights
16 //to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
17 //copies of the Software, and to permit persons to whom the Software is
18 //furnished to do so, subject to the following conditions:
19 //
20 //The above copyright notice and this permission notice shall be included in all
21 //copies or substantial portions of the Software.
22 //
23 //THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24 //IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25 //FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
26 //AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27 //LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
28 //OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
29 //SOFTWARE.
30 //********************************************************************************
31 //
32 #define MODULE_AUXFUNCS
33
34 #include <assert.h>
35 #include <ctype.h>
36 #include <stddef.h>
37 #include <stdio.h>
38 #include <string.h>
39 #include <time.h>
40
41 #include "auxfuncs.h"
42
43
44 /******************************************************************/
45 /*** CHARACTER CLASSIFICATION FUNCTIONS ************************/
46 /******************************************************************/
47 int AUXFUNCS_is_digit(char c)
48 {
49 if ((c >= '0') && (c <= '9'))
50 return(1);
51 else
52 return(0);
53 }
54
55 int AUXFUNCS_digit_to_val(char digit)
56 {
57 switch (digit)
58 {
59 case '0': return(0);
60 break;
61 case '1': return(1);
62 break;
63 case '2': return(2);
64 break;
65 case '3': return(3);
66 break;
67 case '4': return(4);
68 break;
69 case '5': return(5);
70 break;
71 case '6': return(6);
72 break;
73 case '7': return(7);
74 break;
75 case '8': return(8);
76 break;
77 case '9': return(9);
78 break;
79 default: return(-1);
80 break;
81 }
82 }
83
84 /******************************************************************/
85 /*** INTEGER SIZE_T FUNCTIONS ************************/
86 /******************************************************************/
87 size_t AUXFUNCS_size_t_min(size_t a, size_t b)
88 {
89 if (a < b)
90 return(a);
91 else
92 return(b);
93 }
94
95 size_t AUXFUNCS_size_t_max(size_t a, size_t b)
96 {
97 if (a > b)
98 return(a);
99 else
100 return(b);
101 }
102
103
104 /******************************************************************/
105 /*** CONTRACTING STRING FUNCTIONS *******************************/
106 /******************************************************************/
107 void AUXFUNCS_remove_non_digits(char *s)
108 {
109 char *src;
110 char *dst;
111
112 src = s;
113 dst = s;
114
115 while(*src)
116 {
117 if (AUXFUNCS_is_digit(*src))
118 {
119 *dst = *src;
120 dst++;
121 }
122 src++;
123 }
124
125 *dst = 0;
126 }
127
128 void AUXFUNCS_remove_leading_zeros(char *s)
129 {
130 char *src;
131 char *dst;
132
133 src = s;
134 dst = s;
135
136 while((*src) && (*src == '0'))
137 {
138 src++;
139 }
140
141 while(*src)
142 {
143 *dst = *src;
144 src++;
145 dst++;
146 }
147
148 *dst = 0;
149 }
150
151
152 /******************************************************************/
153 /*** VERSION CONTROL IDENTITY FUNCTIONS ************************/
154 /******************************************************************/
155 const char *AUXFUNCS_cvcinfo(void)
156 {
157 return("$Header$");
158 }
159
160 const char *AUXFUNCS_hvcinfo(void)
161 {
162 return(AUXFUNCS_H_VERSION);
163 }
164
165 //********************************************************************************
166 // End of AUXFUNCS.C.
167 //********************************************************************************

Properties

Name Value
svn:eol-style native
svn:keywords Header

dashley@gmail.com
ViewVC Help
Powered by ViewVC 1.1.25