GRASS Programmer's Manual  6.5.svn(2014)-r66266
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
nme_in_mps.c
Go to the documentation of this file.
1 
16 #include <string.h>
17 #include <grass/gis.h>
18 
32 #ifndef COMMENTED_OUT
33 int G__name_in_mapset(const char *name_in, char *name_out, char *mapset)
34 {
35  char in[1024];
36 
37  *in = 0;
38  return (sscanf(name_in, "%s %s %s", name_out, in, mapset) == 3 &&
39  strcmp(in, "in") == 0);
40 }
41 #endif
42 
57 int G__name_is_fully_qualified(const char *fullname, char *name, char *mapset)
58 {
59  const char *p;
60  char *q;
61 
62  /* search for name@mapset */
63 
64  *name = *mapset = 0;
65 
66  for (p = fullname; *p; p++)
67  if (*p == '@')
68  break;
69 
70  if (*p == 0)
71  return 0;
72 
73  /* copy the name part */
74  q = name;
75  while (fullname != p)
76  *q++ = *fullname++;
77  *q = 0;
78 
79  /* copy the mapset part */
80  p++; /* skip the @ */
81  q = mapset;
82  while ((*q++ = *p++)) ;
83 
84  return (*name && *mapset);
85 }
86 
87 
118 char *G_fully_qualified_name(const char *name, const char *mapset)
119 {
120  char fullname[GNAME_MAX + GMAPSET_MAX];
121 
122  if (strchr(name, '@'))
123  sprintf(fullname, "%s", name);
124  else
125  sprintf(fullname, "%s@%s", name, mapset);
126 
127  return G_store(fullname);
128 }
129 
149 int G_unqualified_name(const char *name, const char *mapset,
150  char *xname, char *xmapset)
151 {
152  if (G__name_is_fully_qualified(name, xname, xmapset)) {
153  if (mapset && *mapset && strcmp(mapset, xmapset) != 0)
154  return -1;
155  return 1;
156  }
157 
158  strcpy(xname, name);
159  strcpy(xmapset, mapset);
160 
161  return 0;
162 }
sprintf(buf2,"%s", G3D_CATS_ELEMENT)
char * G_store(const char *s)
Copy string to allocated memory.
Definition: store.c:32
char xmapset[512]
Definition: g3dcats.c:89
tuple q
Definition: forms.py:2019
string name
Definition: render.py:1314
int G_unqualified_name(const char *name, const char *mapset, char *xname, char *xmapset)
Returns unqualified map name (without @ mapset)
Definition: nme_in_mps.c:149
char * G_fully_qualified_name(const char *name, const char *mapset)
fully qualified file name
Definition: nme_in_mps.c:118
char xname[512]
Definition: g3dcats.c:89
int G__name_in_mapset(const char *name_in, char *name_out, char *mapset)
Checks to see if &#39;name_in&#39; is in the format: &lt;name&gt; in &lt;mapset&gt;
Definition: nme_in_mps.c:33
int G__name_is_fully_qualified(const char *fullname, char *name, char *mapset)
Check if map name is fully qualified (map @ mapset)
Definition: nme_in_mps.c:57