GRASS Programmer's Manual  6.5.svn(2014)-r66266
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
legal_dbname.c
Go to the documentation of this file.
1 #include <grass/gis.h>
2 #include <grass/dbmi.h>
3 #include <grass/glocale.h>
4 
5 /* TODO: are we as restrictive here as for vector names? */
6 
17 int db_legal_tablename(const char *s)
18 {
19  char buf[GNAME_MAX];
20 
21  sprintf(buf, "%s", s);
22 
23  if (*s == '.' || *s == 0) {
24  fprintf(stderr,
25  _("Illegal table map name <%s>. May not contain '.' or 'NULL'.\n"),
26  buf);
27  return DB_FAILED;
28  }
29 
30  /* file name must start with letter */
31  if (!((*s >= 'A' && *s <= 'Z') || (*s >= 'a' && *s <= 'z'))) {
32  fprintf(stderr,
33  _("Illegal table map name <%s>. Must start with a letter.\n"),
34  buf);
35  return DB_FAILED;
36  }
37 
38  for (s++; *s; s++)
39  if (!
40  ((*s >= 'A' && *s <= 'Z') || (*s >= 'a' && *s <= 'z') ||
41  (*s >= '0' && *s <= '9') || *s == '_' || *s == '@')) {
42  fprintf(stderr,
43  _("Illegal table map name <%s>. Character <%c> not allowed.\n"),
44  buf, *s);
45  return DB_FAILED;
46  }
47 
48  return DB_OK;
49 }
sprintf(buf2,"%s", G3D_CATS_ELEMENT)
char buf[GNAME_MAX+sizeof(G3D_DIRECTORY)+2]
Definition: g3drange.c:62