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

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 170 by dashley, Sun Jul 8 21:12:48 2018 UTC revision 175 by dashley, Mon Jul 9 00:00:34 2018 UTC
# Line 1  Line 1 
1  //$Header: /cvsroot/esrg/sfesrg/esrgnxpj/sfnthcgi0304/auxfuncs.c,v 1.2 2003/04/17 20:02:05 dtashley Exp $  //$Header$
2  //  //********************************************************************************
3  //********************************************************************************  //Copyright (c) 2003, 2018 David T. Ashley.
4  //Copyright (C) 2003 David T. Ashley  //********************************************************************************
5  //********************************************************************************  //This file is part of "arith_large_cgi", a program that is designed to be
6  //This program or source file is free software; you can redistribute it and/or  //invoked by a PHP script as part of serving a web page that performs
7  //modify it under the terms of the GNU General Public License as published by  //calculations involving large integers.  (A secondary compiled program is
8  //the Free Software Foundation; either version 2 of the License, or (at your  //used because a compiled program can perform certain  calculation-intensive
9  //option) any later version.  //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  //This program or source file is distributed in the hope that it will  //immediately below).
12  //be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of  //********************************************************************************
13  //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the  //Permission is hereby granted, free of charge, to any person obtaining a copy
14  //GNU General Public License for more details.  //of this software and associated documentation files (the "Software"), to deal
15  //  //in the Software without restriction, including without limitation the rights
16  //You may have received a copy of the GNU General Public License  //to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
17  //along with this program; if not, write to the Free Software  //copies of the Software, and to permit persons to whom the Software is
18  //Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA  //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  #define MODULE_AUXFUNCS  //copies or substantial portions of the Software.
22    //
23  #include <assert.h>  //THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24  #include <ctype.h>  //IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25  #include <stddef.h>  //FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
26  #include <stdio.h>  //AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27  #include <string.h>  //LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
28  #include <time.h>  //OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
29    //SOFTWARE.
30  #include "auxfuncs.h"  //********************************************************************************
31    //
32    #define MODULE_AUXFUNCS
33  /******************************************************************/  
34  /***  CHARACTER CLASSIFICATION FUNCTIONS   ************************/  #include <assert.h>
35  /******************************************************************/  #include <ctype.h>
36  int AUXFUNCS_is_digit(char c)  #include <stddef.h>
37     {  #include <stdio.h>
38     if ((c >= '0') && (c <= '9'))  #include <string.h>
39        return(1);  #include <time.h>
40     else  
41        return(0);  #include "auxfuncs.h"
42     }  
43    
44  int AUXFUNCS_digit_to_val(char digit)  /******************************************************************/
45  {  /***  CHARACTER CLASSIFICATION FUNCTIONS   ************************/
46    switch (digit)  /******************************************************************/
47      {  int AUXFUNCS_is_digit(char c)
48      case '0':  return(0);     {
49        break;     if ((c >= '0') && (c <= '9'))
50      case '1':  return(1);        return(1);
51        break;     else
52      case '2':  return(2);        return(0);
53        break;     }
54      case '3':  return(3);  
55        break;  int AUXFUNCS_digit_to_val(char digit)
56      case '4':  return(4);  {
57        break;    switch (digit)
58      case '5':  return(5);      {
59        break;      case '0':  return(0);
60      case '6':  return(6);        break;
61        break;      case '1':  return(1);
62      case '7':  return(7);        break;
63        break;      case '2':  return(2);
64      case '8':  return(8);        break;
65        break;      case '3':  return(3);
66      case '9':  return(9);        break;
67        break;      case '4':  return(4);
68      default:   return(-1);        break;
69        break;      case '5':  return(5);
70      }        break;
71  }      case '6':  return(6);
72          break;
73  /******************************************************************/      case '7':  return(7);
74  /***  INTEGER SIZE_T FUNCTIONS             ************************/        break;
75  /******************************************************************/      case '8':  return(8);
76  size_t AUXFUNCS_size_t_min(size_t a, size_t b)        break;
77     {      case '9':  return(9);
78     if (a < b)        break;
79        return(a);      default:   return(-1);
80     else        break;
81        return(b);      }
82     }  }
83    
84  size_t AUXFUNCS_size_t_max(size_t a, size_t b)  /******************************************************************/
85     {  /***  INTEGER SIZE_T FUNCTIONS             ************************/
86     if (a > b)  /******************************************************************/
87        return(a);  size_t AUXFUNCS_size_t_min(size_t a, size_t b)
88     else     {
89        return(b);     if (a < b)
90     }        return(a);
91       else
92          return(b);
93  /******************************************************************/     }
94  /***  CONTRACTING STRING FUNCTIONS  *******************************/  
95  /******************************************************************/  size_t AUXFUNCS_size_t_max(size_t a, size_t b)
96  void AUXFUNCS_remove_non_digits(char *s)     {
97     {     if (a > b)
98     char *src;        return(a);
99     char *dst;     else
100          return(b);
101     src = s;     }
102     dst = s;  
103    
104     while(*src)  /******************************************************************/
105        {  /***  CONTRACTING STRING FUNCTIONS  *******************************/
106        if (AUXFUNCS_is_digit(*src))  /******************************************************************/
107           {  void AUXFUNCS_remove_non_digits(char *s)
108           *dst = *src;     {
109           dst++;     char *src;
110           }     char *dst;
111        src++;  
112        }     src = s;
113       dst = s;
114     *dst = 0;  
115     }     while(*src)
116          {
117  void AUXFUNCS_remove_leading_zeros(char *s)        if (AUXFUNCS_is_digit(*src))
118     {           {
119     char *src;           *dst = *src;
120     char *dst;           dst++;
121             }
122     src = s;        src++;
123     dst = s;        }
124    
125     while((*src) && (*src == '0'))     *dst = 0;
126        {     }
127        src++;  
128        }  void AUXFUNCS_remove_leading_zeros(char *s)
129       {
130     while(*src)     char *src;
131        {     char *dst;
132        *dst = *src;  
133        src++;     src = s;
134        dst++;     dst = s;
135        }  
136       while((*src) && (*src == '0'))
137     *dst = 0;        {
138     }        src++;
139          }
140    
141  /******************************************************************/     while(*src)
142  /***  VERSION CONTROL IDENTITY FUNCTIONS   ************************/        {
143  /******************************************************************/        *dst = *src;
144  const char *AUXFUNCS_cvcinfo(void)        src++;
145     {        dst++;
146     return("$Header: /cvsroot/esrg/sfesrg/esrgnxpj/sfnthcgi0304/auxfuncs.c,v 1.2 2003/04/17 20:02:05 dtashley Exp $");        }
147     }  
148       *dst = 0;
149  const char *AUXFUNCS_hvcinfo(void)     }
150     {  
151     return(AUXFUNCS_H_VERSION);  
152     }  /******************************************************************/
153    /***  VERSION CONTROL IDENTITY FUNCTIONS   ************************/
154  //********************************************************************************  /******************************************************************/
155  // $Log: auxfuncs.c,v $  const char *AUXFUNCS_cvcinfo(void)
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,     return("$Header$");
158  // after some discussion on the GMP list.     }
159  //  
160  // Revision 1.1  2003/04/13 23:46:06  dtashley  const char *AUXFUNCS_hvcinfo(void)
161  // Initial checkin.     {
162  //********************************************************************************     return(AUXFUNCS_H_VERSION);
163  // End of AUXFUNCS.C.     }
164  //********************************************************************************  
165    //********************************************************************************
166    // End of AUXFUNCS.C.
167    //********************************************************************************

Legend:
Removed from v.170  
changed lines
  Added in v.175

dashley@gmail.com
ViewVC Help
Powered by ViewVC 1.1.25