list.c 877 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*!
  2. \file lib/manage/list.c
  3. \brief Manage Library - Element info
  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 <grass/gis.h>
  10. #include "manage_local_proto.h"
  11. /*!
  12. \brief Get list structure
  13. \param n element id
  14. \return pointer to list structure
  15. \return NULL on error
  16. */
  17. const struct list *M_get_list(int n)
  18. {
  19. if (n >= nlist)
  20. return NULL;
  21. return &(list[n]);
  22. }
  23. /*!
  24. \brief Find element type by name
  25. \param data_type element type
  26. \return element id
  27. \return -1 not found
  28. */
  29. int M_get_element(const char *data_type)
  30. {
  31. int n;
  32. for (n = 0; n < nlist; n++) {
  33. if (G_strcasecmp(list[n].alias, data_type) == 0)
  34. return n;
  35. }
  36. return -1;
  37. }