gs_storage_sqlite_util.c

Go to the documentation of this file.
00001 /* 
00002  * @file
00003  *
00004  * This file contains various utility functions used for
00005  * the agent database.  Many of the functions in this file
00006  * were taken from the sqlite source, which is public
00007  * domain.  That is why they do not have an gs_ prefix.
00008  */
00009 /* $Id: gs_storage_sqlite_util.c,v 1.14 2007/03/22 22:41:16 seymour Exp $ */
00010 /* $UTK_Copyright: $ */
00011 
00012 #include <assert.h>
00013 #include <ctype.h>
00014 #include <stdio.h>
00015 #include <string.h>
00016 
00017 #include "sqlite3.h"
00018 
00023 static int 
00024 isNumber(const char *z, int *realnum)
00025 {
00026   if( *z=='-' || *z=='+' ) z++;
00027   if( !isdigit(*z) ){
00028     return 0;
00029   }
00030   z++;
00031   if( realnum ) *realnum = 0;
00032   while( isdigit(*z) ){ z++; }
00033   if( *z=='.' ){
00034     z++;
00035     if( !isdigit(*z) ) return 0;
00036     while( isdigit(*z) ){ z++; }
00037     if( realnum ) *realnum = 1;
00038   }
00039   if( *z=='e' || *z=='E' ){
00040     z++;
00041     if( *z=='+' || *z=='-' ) z++;
00042     if( !isdigit(*z) ) return 0;
00043     while( isdigit(*z) ){ z++; }
00044     if( realnum ) *realnum = 1;
00045   }
00046   return *z==0;
00047 }
00048 
00049 int 
00050 sqliteIsNumber(const char *c)
00051 {
00052   return isNumber(c,0);
00053 }