/**************************************************************************** * miscutils.c * * * * LocalGate Local Filesystem -> WWW Gateway * * * * LocalGate allows a user to access HTML files on the local filesystem * * as if they had a web server to access the files. * * * * miscutils.c: miscellaneous routines for LocalGate. * * * * Copyright (C) 1997 Michael Chu * * This file is part of the LocalGate local filesystem -> WWW gateway. * * * * This program 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 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 should have received a copy of the GNU General Public License * * along with this program; if not, write to the Free Software * * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * * * * Contact information: Michael Chu * * mmchu@pobox.com * ****************************************************************************/ /*********************************** INCLUDES *******************************/ #include #include #include #include "miscutils.h" /********************************** FUNCTIONS *******************************/ /**************************************************************************** * isUnsignedInteger: * * * * Summary: Returns whether string represents an unsigned integer. * * * * Input: numberString: string to check. * * * * Returns: 0 (zero) if numberString does not represents an unsigned * * integer. * * 1 (one) if numberString represents an unsigned integer. * * * * Global State Affected: * * None. * ****************************************************************************/ int isUnsignedInteger(char *numberString) { int stringLength = 0; /* length of string. */ int stringIndex = 0; /* index of string. */ /* make sure that numberString is not NULL. */ assert(numberString != NULL); /* get the string length. */ stringLength = strlen(numberString); /* if the length was zero, then it was not an unsigned integer. */ if (stringLength == 0) { /* this is not an unsigned integer. */ return(0); } /* check all characters for digits. */ for (stringIndex = 0; stringIndex < stringLength; stringIndex++) { if (!(isdigit(numberString[stringIndex]))) { /* this is not an unsigned integer. */ return(0); } } /* if we got this far, then it is an unsigned integer. */ return(1); }