19#include <grass/glocale.h>
21#include "manage_local_proto.h"
26static void format_error(
char *,
int,
char *);
51 char element_list[GPATH_MAX];
65 env = getenv(
"ELEMENT_LIST");
69 sprintf(element_list,
"%s/etc/element_list",
G_gisbase());
70 fd = fopen(element_list,
"r");
73 G_fatal_error(_(
"Unable to open data base element list '%s'"),
77 while (
G_getl(buf,
sizeof(buf), fd)) {
81 if (*buf ==
' ' || *buf ==
'\t') {
83 if (sscanf(buf,
"%[^:]:%[^\n]", elem, desc) < 1)
88 format_error(element_list, line, buf);
96 if (sscanf(buf,
"%[^:]:%[^:]:%[^:]:%[^\n]", elem, alias, desc,
98 format_error(element_list, line, buf);
114 if (!check_if_empty || !
M__empty(elem)) {
131void format_error(
char *element_list,
int line,
char *buf)
133 G_fatal_error(_(
"Format error: file ('%s') line (%d) - %s"), element_list,
void M__add_element(const char *elem, const char *desc)
Add element to the list.
int M__empty(char *elem)
Check if element is empty.
int G_getl(char *buf, int n, FILE *fd)
Gets a line of text from a file.
void G_fatal_error(const char *msg,...)
Print a fatal error message to stderr.
const char * G_gisbase(void)
Get full path name of the top level module directory.
int M_read_list(int check_if_empty, int *num)
Read list of elements.
char * G_store(const char *s)
Copy string to allocated memory.
void G_strip(char *buf)
Removes all leading and trailing white space from string.