find.c 827 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /*!
  2. \file lib/manage/find.c
  3. \brief Manage Library - Find element in data base
  4. (C) 2001-2011 by the GRASS Development Team
  5. This program is free software under the GNU General Public License
  6. (>=v2). Read the file COPYING that comes with GRASS for details.
  7. \author Original author CERL
  8. */
  9. #include <string.h>
  10. #include <grass/gis.h>
  11. #include "manage_local_proto.h"
  12. /*!
  13. \brief Find element in data base
  14. \param n element id
  15. \param name element name
  16. \param mapsets name of mapsets
  17. \return mapset if found
  18. \return if not found
  19. */
  20. const char *M_find(int n, char *name, const char *mapsets)
  21. {
  22. const char *mapset;
  23. mapset = G_find_file2(list[n].element[0], name, mapsets);
  24. if (mapset) {
  25. char temp[GNAME_MAX];
  26. sscanf(name, "%s", temp);
  27. strcpy(name, temp);
  28. }
  29. return mapset;
  30. }