GRASS GIS 8 Programmer's Manual  8.5.0dev(2024)-36359e2344
manage/list.c
Go to the documentation of this file.
1 /*!
2  \file lib/manage/list.c
3 
4  \brief Manage Library - Element info
5 
6  (C) 2001-2011 by the GRASS Development Team
7 
8  This program is free software under the GNU General Public License
9  (>=v2). Read the file COPYING that comes with GRASS for details.
10 
11  \author Original author CERL
12  */
13 
14 #include <grass/gis.h>
15 
16 #include "manage_local_proto.h"
17 
18 /*!
19  \brief Get list structure
20 
21  \param n element id
22 
23  \return pointer to list structure
24  \return NULL on error
25  */
26 const struct list *M_get_list(int n)
27 {
28  if (n >= nlist)
29  return NULL;
30 
31  return &(list[n]);
32 }
33 
34 /*!
35  \brief Find element type by name
36 
37  \param data_type element type
38 
39  \return element id
40  \return -1 not found
41  */
42 int M_get_element(const char *data_type)
43 {
44  int n;
45 
46  for (n = 0; n < nlist; n++) {
47  if (G_strcasecmp(list[n].alias, data_type) == 0)
48  return n;
49  }
50 
51  return -1;
52 }
#define NULL
Definition: ccmath.h:32
int int G_strcasecmp(const char *, const char *)
String compare ignoring case (upper or lower)
Definition: strings.c:47
int M_get_element(const char *data_type)
Find element type by name.
Definition: manage/list.c:42
const struct list * M_get_list(int n)
Get list structure.
Definition: manage/list.c:26
int nlist
Definition: read_list.c:23
Definition: manage.h:4
char * alias
Definition: manage.h:6