GRASS Programmer's Manual  6.4.2(2012)
 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 }