/[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 172 - (show annotations) (download)
Sun Jul 8 21:17:26 2018 UTC (6 years, 5 months ago) by dashley
File MIME type: text/plain
File size: 4054 byte(s)
Add keyword expansion, native EOL.
1 //$Header$
2 //
3 //********************************************************************************
4 //Copyright (C) 2003 David T. Ashley
5 //********************************************************************************
6 //This program or source file is free software; you can redistribute it and/or
7 //modify it under the terms of the GNU General Public License as published by
8 //the Free Software Foundation; either version 2 of the License, or (at your
9 //option) any later version.
10 //
11 //This program or source file is distributed in the hope that it will
12 //be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
13 //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 //GNU General Public License for more details.
15 //
16 //You may have received a copy of the GNU General Public License
17 //along with this program; if not, write to the Free Software
18 //Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 //********************************************************************************
20 //
21 #define MODULE_AUXFUNCS
22
23 #include <assert.h>
24 #include <ctype.h>
25 #include <stddef.h>
26 #include <stdio.h>
27 #include <string.h>
28 #include <time.h>
29
30 #include "auxfuncs.h"
31
32
33 /******************************************************************/
34 /*** CHARACTER CLASSIFICATION FUNCTIONS ************************/
35 /******************************************************************/
36 int AUXFUNCS_is_digit(char c)
37 {
38 if ((c >= '0') && (c <= '9'))
39 return(1);
40 else
41 return(0);
42 }
43
44 int AUXFUNCS_digit_to_val(char digit)
45 {
46 switch (digit)
47 {
48 case '0': return(0);
49 break;
50 case '1': return(1);
51 break;
52 case '2': return(2);
53 break;
54 case '3': return(3);
55 break;
56 case '4': return(4);
57 break;
58 case '5': return(5);
59 break;
60 case '6': return(6);
61 break;
62 case '7': return(7);
63 break;
64 case '8': return(8);
65 break;
66 case '9': return(9);
67 break;
68 default: return(-1);
69 break;
70 }
71 }
72
73 /******************************************************************/
74 /*** INTEGER SIZE_T FUNCTIONS ************************/
75 /******************************************************************/
76 size_t AUXFUNCS_size_t_min(size_t a, size_t b)
77 {
78 if (a < b)
79 return(a);
80 else
81 return(b);
82 }
83
84 size_t AUXFUNCS_size_t_max(size_t a, size_t b)
85 {
86 if (a > b)
87 return(a);
88 else
89 return(b);
90 }
91
92
93 /******************************************************************/
94 /*** CONTRACTING STRING FUNCTIONS *******************************/
95 /******************************************************************/
96 void AUXFUNCS_remove_non_digits(char *s)
97 {
98 char *src;
99 char *dst;
100
101 src = s;
102 dst = s;
103
104 while(*src)
105 {
106 if (AUXFUNCS_is_digit(*src))
107 {
108 *dst = *src;
109 dst++;
110 }
111 src++;
112 }
113
114 *dst = 0;
115 }
116
117 void AUXFUNCS_remove_leading_zeros(char *s)
118 {
119 char *src;
120 char *dst;
121
122 src = s;
123 dst = s;
124
125 while((*src) && (*src == '0'))
126 {
127 src++;
128 }
129
130 while(*src)
131 {
132 *dst = *src;
133 src++;
134 dst++;
135 }
136
137 *dst = 0;
138 }
139
140
141 /******************************************************************/
142 /*** VERSION CONTROL IDENTITY FUNCTIONS ************************/
143 /******************************************************************/
144 const char *AUXFUNCS_cvcinfo(void)
145 {
146 return("$Header$");
147 }
148
149 const char *AUXFUNCS_hvcinfo(void)
150 {
151 return(AUXFUNCS_H_VERSION);
152 }
153
154 //********************************************************************************
155 // $Log: auxfuncs.c,v $
156 // Revision 1.2 2003/04/17 20:02:05 dtashley
157 // License text for the GPL added. All source files are now under the GPL,
158 // after some discussion on the GMP list.
159 //
160 // Revision 1.1 2003/04/13 23:46:06 dtashley
161 // Initial checkin.
162 //********************************************************************************
163 // End of AUXFUNCS.C.
164 //********************************************************************************

Properties

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

dashley@gmail.com
ViewVC Help
Powered by ViewVC 1.1.25