GRASS Programmer's Manual  6.4.2(2012)
nme_in_mps.c
Go to the documentation of this file.
00001 
00016 #include <string.h>
00017 #include <grass/gis.h>
00018 
00032 #ifndef COMMENTED_OUT
00033 int G__name_in_mapset(const char *name_in, char *name_out, char *mapset)
00034 {
00035     char in[1024];
00036 
00037     *in = 0;
00038     return (sscanf(name_in, "%s %s %s", name_out, in, mapset) == 3 &&
00039             strcmp(in, "in") == 0);
00040 }
00041 #endif
00042 
00057 int G__name_is_fully_qualified(const char *fullname, char *name, char *mapset)
00058 {
00059     const char *p;
00060     char *q;
00061 
00062     /* search for name@mapset */
00063 
00064     *name = *mapset = 0;
00065 
00066     for (p = fullname; *p; p++)
00067         if (*p == '@')
00068             break;
00069 
00070     if (*p == 0)
00071         return 0;
00072 
00073     /* copy the name part */
00074     q = name;
00075     while (fullname != p)
00076         *q++ = *fullname++;
00077     *q = 0;
00078 
00079     /* copy the mapset part */
00080     p++;                        /* skip the @ */
00081     q = mapset;
00082     while ((*q++ = *p++)) ;
00083 
00084     return (*name && *mapset);
00085 }
00086 
00087 
00118 char *G_fully_qualified_name(const char *name, const char *mapset)
00119 {
00120     char fullname[GNAME_MAX + GMAPSET_MAX];
00121 
00122     if (strchr(name, '@'))
00123         sprintf(fullname, "%s", name);
00124     else
00125         sprintf(fullname, "%s@%s", name, mapset);
00126 
00127     return G_store(fullname);
00128 }
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines