legal_dbname.c

Go to the documentation of this file.
00001 #include <grass/gis.h>
00002 #include <grass/dbmi.h>
00003 #include <grass/glocale.h>
00004 
00005 /* TODO: are we as restrictive here as for vector names? */
00006 
00017 int db_legal_tablename (char *s)
00018 {
00019     char buf[GNAME_MAX];
00020     
00021     sprintf(buf, "%s", s);
00022     
00023     if (*s == '.' || *s == 0) {
00024         fprintf(stderr, _("Illegal table map name <%s>. May not contain '.' or 'NULL'.\n"), buf);
00025         return DB_FAILED;
00026     }
00027 
00028     /* file name must start with letter */
00029     if (! ((*s >= 'A' && *s <= 'Z') || (*s >= 'a' && *s <= 'z')) ) {
00030         fprintf(stderr, _("Illegal table map name <%s>. Must start with a letter.\n"), buf);
00031         return DB_FAILED;
00032     }
00033 
00034     for (s++ ; *s; s++)
00035         if (! ((*s >= 'A' && *s <= 'Z') || (*s >= 'a' && *s <= 'z') || (*s >= '0' && *s <= '9') || *s == '_' || *s == '@' ) ) {
00036                 fprintf(stderr, _("Illegal table map name <%s>. Character <%c> not allowed.\n"), buf, *s);
00037             return DB_FAILED;
00038         }
00039 
00040     return DB_OK;
00041 }

Generated on Sun Apr 6 17:31:38 2008 for GRASS by  doxygen 1.5.5