Go to the documentation of this file.00001 #include <stdlib.h>
00002 #include <string.h>
00003 #include <unistd.h>
00004 #include <grass/gis.h>
00005
00006 static char *G__find_etc(const char *name)
00007 {
00008 char path[GPATH_MAX];
00009 const char *pathlist = getenv("GRASS_ADDON_ETC");
00010
00011
00012
00013
00014 if (*name == 0 || *name == '.')
00015 return NULL;
00016
00017
00018
00019
00020 if (pathlist) {
00021 char **dirs = G_tokenize(pathlist, ":");
00022 char *result = NULL;
00023 int i;
00024
00025 for (i = 0; dirs[i]; i++) {
00026 sprintf(path, "%s/%s", dirs[i], name);
00027
00028 if (access(path, 0) == 0) {
00029 result = G_store(path);
00030 break;
00031 }
00032 }
00033
00034 G_free_tokens(dirs);
00035
00036 if (result)
00037 return result;
00038 }
00039
00040
00041
00042
00043 sprintf(path, "%s/etc/%s", G_gisbase(), name);
00044 if (access(path, 0) == 0)
00045 return G_store(path);
00046
00047 return NULL;
00048 }
00049
00050
00063 char *G_find_etc(const char *name)
00064 {
00065 return G__find_etc(name);
00066 }