//$Header: /cvsroot/esrg/sfesrg/esrgnxpj/sfnthcgi0304/auxfuncs.c,v 1.2 2003/04/17 20:02:05 dtashley Exp $ // //******************************************************************************** //Copyright (C) 2003 David T. Ashley //******************************************************************************** //This program or source file is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License as published by //the Free Software Foundation; either version 2 of the License, or (at your //option) any later version. // //This program or source file is distributed in the hope that it will //be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //GNU General Public License for more details. // //You may have received a copy of the GNU General Public License //along with this program; if not, write to the Free Software //Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA //******************************************************************************** // #define MODULE_AUXFUNCS #include #include #include #include #include #include #include "auxfuncs.h" /******************************************************************/ /*** CHARACTER CLASSIFICATION FUNCTIONS ************************/ /******************************************************************/ int AUXFUNCS_is_digit(char c) { if ((c >= '0') && (c <= '9')) return(1); else return(0); } int AUXFUNCS_digit_to_val(char digit) { switch (digit) { case '0': return(0); break; case '1': return(1); break; case '2': return(2); break; case '3': return(3); break; case '4': return(4); break; case '5': return(5); break; case '6': return(6); break; case '7': return(7); break; case '8': return(8); break; case '9': return(9); break; default: return(-1); break; } } /******************************************************************/ /*** INTEGER SIZE_T FUNCTIONS ************************/ /******************************************************************/ size_t AUXFUNCS_size_t_min(size_t a, size_t b) { if (a < b) return(a); else return(b); } size_t AUXFUNCS_size_t_max(size_t a, size_t b) { if (a > b) return(a); else return(b); } /******************************************************************/ /*** CONTRACTING STRING FUNCTIONS *******************************/ /******************************************************************/ void AUXFUNCS_remove_non_digits(char *s) { char *src; char *dst; src = s; dst = s; while(*src) { if (AUXFUNCS_is_digit(*src)) { *dst = *src; dst++; } src++; } *dst = 0; } void AUXFUNCS_remove_leading_zeros(char *s) { char *src; char *dst; src = s; dst = s; while((*src) && (*src == '0')) { src++; } while(*src) { *dst = *src; src++; dst++; } *dst = 0; } /******************************************************************/ /*** VERSION CONTROL IDENTITY FUNCTIONS ************************/ /******************************************************************/ const char *AUXFUNCS_cvcinfo(void) { return("$Header: /cvsroot/esrg/sfesrg/esrgnxpj/sfnthcgi0304/auxfuncs.c,v 1.2 2003/04/17 20:02:05 dtashley Exp $"); } const char *AUXFUNCS_hvcinfo(void) { return(AUXFUNCS_H_VERSION); } //******************************************************************************** // $Log: auxfuncs.c,v $ // Revision 1.2 2003/04/17 20:02:05 dtashley // License text for the GPL added. All source files are now under the GPL, // after some discussion on the GMP list. // // Revision 1.1 2003/04/13 23:46:06 dtashley // Initial checkin. //******************************************************************************** // End of AUXFUNCS.C. //********************************************************************************